react-native-unit-components 1.0.0 → 1.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/android/src/main/java/com/unitreactnativecomponents/UnitAddToWalletButtonViewManager.kt +27 -0
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsEvent.kt +21 -0
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -1
- package/android/src/main/java/com/unitreactnativecomponents/visapresentation/UNGooglePayView.kt +197 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_background.xml +6 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_content.xml +48 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_no_shadow_background.xml +6 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_overlay.xml +12 -0
- package/android/src/main/res/drawable/un_border.xml +6 -0
- package/android/src/main/res/drawable/un_condensed_googlepay.xml +27 -0
- package/android/src/main/res/drawable/un_googlepay_button_background.xml +18 -0
- package/android/src/main/res/drawable/un_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_content.xml +48 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background.xml +18 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_overlay.xml +11 -0
- package/android/src/main/res/drawable/un_ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/drawable/un_ic_unit_logo.xml +25 -0
- package/android/src/main/res/drawable/un_ic_visa.xml +13 -0
- package/android/src/main/res/drawable-bg/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-bg/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ca/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-ca/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-cs/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-cs/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-da/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-da/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-de/un_add_to_googlepay_button_content.xml +60 -0
- package/android/src/main/res/drawable-de/un_black_add_to_googlepay_button_content.xml +60 -0
- package/android/src/main/res/drawable-el/un_add_to_googlepay_button_content.xml +67 -0
- package/android/src/main/res/drawable-el/un_black_add_to_googlepay_button_content.xml +67 -0
- package/android/src/main/res/drawable-es/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-es/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-et/un_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-et/un_black_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-fi/un_add_to_googlepay_button_content.xml +39 -0
- package/android/src/main/res/drawable-fi/un_black_add_to_googlepay_button_content.xml +39 -0
- package/android/src/main/res/drawable-fr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-fr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-hr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-hr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-hu/un_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-hu/un_black_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-in/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-in/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-it/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-it/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-iw/un_add_to_googlepay_button_content.xml +41 -0
- package/android/src/main/res/drawable-iw/un_black_add_to_googlepay_button_content.xml +41 -0
- package/android/src/main/res/drawable-ja/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ja/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ko/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ko/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-lt/un_add_to_googlepay_button_content.xml +70 -0
- package/android/src/main/res/drawable-lt/un_black_add_to_googlepay_button_content.xml +70 -0
- package/android/src/main/res/drawable-lv/un_add_to_googlepay_button_content.xml +61 -0
- package/android/src/main/res/drawable-lv/un_black_add_to_googlepay_button_content.xml +61 -0
- package/android/src/main/res/drawable-ms/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ms/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-nb/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-nb/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-nl/un_add_to_googlepay_button_content.xml +58 -0
- package/android/src/main/res/drawable-nl/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-pl/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-pl/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-pt/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-pt/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ro/un_add_to_googlepay_button_content.xml +58 -0
- package/android/src/main/res/drawable-ro/un_black_add_to_googlepay_button_content.xml +58 -0
- package/android/src/main/res/drawable-ru/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ru/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sk/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sk/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sl/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sl/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sv/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-sv/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-th/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-th/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-tr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-tr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-uk/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-uk/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_background.xml +7 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_no_shadow_background.xml +7 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-v24/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable-v24/un_border.xml +6 -0
- package/android/src/main/res/drawable-v24/un_ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/drawable-v24/un_ic_unit_logo.xml +25 -0
- package/android/src/main/res/drawable-v24/un_ic_visa.xml +13 -0
- package/android/src/main/res/drawable-zh/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-zh/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/layout/un_black_add_to_googlepay_button.xml +32 -0
- package/android/src/main/res/layout/un_view_google_push_provisioning.xml +45 -0
- package/android/src/main/res/layout/un_white_add_to_googlepay_button.xml +31 -0
- package/android/src/main/res/layout/un_white_add_to_googlepay_button_no_shadow.xml +31 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/white_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/values/colors.xml +14 -0
- package/android/src/main/res/values/googlepay_strings.xml +7 -0
- package/android/src/main/res/values/strings.xml +4 -0
- package/android/src/main/res/values/themes.xml +16 -0
- package/android/src/main/res/values-night/themes.xml +16 -0
- package/ios/UnitReactNativeComponents.xcodeproj/project.pbxproj +8 -8
- package/ios/UnitReactNativeComponentsViewManager.m +3 -2
- package/ios/UnitReactNativeComponentsViewManager.swift +39 -25
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +39 -6
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +7 -6
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/commonjs/messages/webMessages/pageMessage.js.map +1 -1
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js +13 -0
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +14 -2
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +37 -5
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.js +7 -6
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/messages/webMessages/pageMessage.js.map +1 -1
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js +4 -0
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +14 -2
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +6 -0
- package/lib/typescript/helpers/BottomSheet/BottomSheet.d.ts +2 -0
- package/lib/typescript/nativeComponent/UNNativeAddToWalletButton.d.ts +6 -0
- package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +1 -1
- package/lib/typescript/webComponent/WebComponent.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +1 -1
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +1 -1
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +35 -4
- package/src/components/UNCardComponent/UNCardComponent.tsx +1 -1
- package/src/helpers/BottomSheet/BottomSheet.tsx +7 -5
- package/src/messages/webMessages/pageMessage.ts +1 -1
- package/src/nativeComponent/UNNativeAddToWalletButton.tsx +12 -0
- package/src/unitSdkManager/UnitSdkManager.ts +1 -1
- package/src/webComponent/WebComponent.tsx +16 -4
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsViewManager.kt +0 -19
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js +0 -19
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js.map +0 -1
- package/lib/module/nativeComponenet/NativeComponentExample.js +0 -10
- package/lib/module/nativeComponenet/NativeComponentExample.js.map +0 -1
- package/lib/typescript/nativeComponenet/NativeComponentExample.d.ts +0 -7
- package/src/nativeComponenet/NativeComponentExample.tsx +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UNBookPaymentComponent","props","handleWebViewMessage","message","type","BookPaymentMessage","PAYMENT_CREATED","onPaymentCreated","response","details","data","WebComponentType","bookPayment","PresentationMode","Inherit","getBookPaymentParams","getBookPaymentScript"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { UNBookPaymentData } from '../../sharedTypes';\n\nexport interface UNBookPaymentComponentProps {\n accountId: string;\n customerToken: string;\n isSameCustomer: boolean;\n counterPartyAccountId: string;\n counterPartyName: string;\n theme?: string;\n onPaymentCreated?: (data: UNBookPaymentData) => void;\n}\n\nexport const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {\n const response = message.details as BookPaymentEvent;\n props.onPaymentCreated(response.data);\n }\n };\n\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={PresentationMode.Inherit}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n
|
|
1
|
+
{"version":3,"names":["UNBookPaymentComponent","props","handleWebViewMessage","message","type","BookPaymentMessage","PAYMENT_CREATED","onPaymentCreated","response","details","data","WebComponentType","bookPayment","PresentationMode","Inherit","getBookPaymentParams","getBookPaymentScript"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { UNBookPaymentData } from '../../sharedTypes';\n\nexport interface UNBookPaymentComponentProps {\n accountId: string;\n customerToken: string;\n isSameCustomer: boolean;\n counterPartyAccountId: string;\n counterPartyName: string;\n theme?: string;\n onPaymentCreated?: (data: UNBookPaymentData) => void;\n}\n\nexport const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {\n const response = message.details as BookPaymentEvent;\n props.onPaymentCreated(response.data);\n }\n };\n\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={PresentationMode.Inherit}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;AAaO,MAAMA,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBC,sCAAA,CAAmBC,eAApC,IAAuDL,KAAK,CAACM,gBAAjE,EAAmF;MACjF,MAAMC,QAAQ,GAAGL,OAAO,CAACM,OAAzB;MACAR,KAAK,CAACM,gBAAN,CAAuBC,QAAQ,CAACE,IAAhC;IACD;EACF,CALD;;EAOA,oBACE,6BAAC,0BAAD;IACE,IAAI,EAAEC,8BAAA,CAAiBC,WADzB;IAEE,gBAAgB,EAAEC,0BAAA,CAAiBC,OAFrC;IAGE,MAAM,EAAE,IAAAC,4CAAA,EAAqBd,KAArB,CAHV;IAIE,MAAM,EAAE,IAAAe,4CAAA,GAJV;IAKE,SAAS,EAAGb,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;IAME,YAAY,EAAE;EANhB,EADF;AAUD,CAlBM"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UNBottomSheetComponent = void 0;
|
|
6
|
+
exports.UNBottomSheetComponent = exports.ScrollState = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
@@ -37,11 +37,22 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
37
37
|
|
|
38
38
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
39
|
|
|
40
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
41
|
+
let ScrollState;
|
|
42
|
+
exports.ScrollState = ScrollState;
|
|
43
|
+
|
|
44
|
+
(function (ScrollState) {
|
|
45
|
+
ScrollState["onTop"] = "onTop";
|
|
46
|
+
ScrollState["onlyWebView"] = "webViewScroll";
|
|
47
|
+
ScrollState["onlyBottomSheet"] = "onlyBottomSheet";
|
|
48
|
+
ScrollState["unScrollable"] = "unScrollable";
|
|
49
|
+
})(ScrollState || (exports.ScrollState = ScrollState = {}));
|
|
50
|
+
|
|
40
51
|
const UNBottomSheetComponent = () => {
|
|
41
52
|
const [isBottomSheetActive, setIsBottomSheetActive] = (0, _react.useState)(false);
|
|
42
53
|
const [height, setHeight] = (0, _react.useState)(0);
|
|
43
54
|
const [renderingRequest, setRenderingRequest] = (0, _react.useState)(null);
|
|
44
|
-
const [
|
|
55
|
+
const [scrollState, setScrollState] = (0, _react.useState)(ScrollState.onTop);
|
|
45
56
|
const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = (0, _react.useState)(false);
|
|
46
57
|
const [newHeightMessage, setNewHeightMessage] = (0, _react.useState)(null);
|
|
47
58
|
const isAppActive = (0, _useAppStateListener.useAppStateListener)();
|
|
@@ -70,6 +81,7 @@ const UNBottomSheetComponent = () => {
|
|
|
70
81
|
webRef.current && (0, _UNBottomSheetComponent.resetHtml)(webRef.current);
|
|
71
82
|
setHeight(0);
|
|
72
83
|
setRenderingRequest(null);
|
|
84
|
+
setScrollState(ScrollState.onTop);
|
|
73
85
|
}
|
|
74
86
|
}, [isBottomSheetActive]);
|
|
75
87
|
(0, _react.useEffect)(() => {
|
|
@@ -90,10 +102,10 @@ const UNBottomSheetComponent = () => {
|
|
|
90
102
|
if (nativePlace == 'overFullScreen') {
|
|
91
103
|
const bottomSheetNewHeight = (0, _UNBottomSheetComponent.handleHtmlFullHeight)(webRef.current, _reactNative.Dimensions.get('window').height);
|
|
92
104
|
setHeight(bottomSheetNewHeight);
|
|
93
|
-
|
|
105
|
+
setScrollState(ScrollState.onTop);
|
|
94
106
|
} else {
|
|
95
107
|
setHeight(message.details.height);
|
|
96
|
-
|
|
108
|
+
setScrollState(ScrollState.unScrollable);
|
|
97
109
|
}
|
|
98
110
|
}
|
|
99
111
|
};
|
|
@@ -140,6 +152,24 @@ const UNBottomSheetComponent = () => {
|
|
|
140
152
|
}
|
|
141
153
|
};
|
|
142
154
|
|
|
155
|
+
const onScrollWebView = event => {
|
|
156
|
+
if (scrollState === ScrollState.unScrollable) return;
|
|
157
|
+
const currY = event.nativeEvent.contentOffset.y;
|
|
158
|
+
|
|
159
|
+
if (ScrollState.onTop && currY < 5) {
|
|
160
|
+
setScrollState(ScrollState.onlyBottomSheet);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (scrollState !== ScrollState.onlyWebView && scrollState === ScrollState.onTop && currY > 5) {
|
|
164
|
+
setScrollState(ScrollState.onlyWebView);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const handleWebViewScroll = () => {
|
|
169
|
+
if (scrollState === ScrollState.unScrollable) return;
|
|
170
|
+
setScrollState(ScrollState.onlyWebView);
|
|
171
|
+
};
|
|
172
|
+
|
|
143
173
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
144
174
|
pointerEvents: isBottomSheetActive ? undefined : 'none',
|
|
145
175
|
style: styles.container
|
|
@@ -147,14 +177,17 @@ const UNBottomSheetComponent = () => {
|
|
|
147
177
|
isOpen: isBottomSheetActive,
|
|
148
178
|
height: height,
|
|
149
179
|
onClose: () => setIsBottomSheetActive(false),
|
|
150
|
-
onOpen: () => setIsBottomSheetActive(true)
|
|
180
|
+
onOpen: () => setIsBottomSheetActive(true),
|
|
181
|
+
handleWebViewScroll: () => handleWebViewScroll(),
|
|
182
|
+
shouldEnableBottomSheetScroll: scrollState !== ScrollState.onlyWebView
|
|
151
183
|
}, isAppActive && /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
|
|
152
184
|
ref: webRef,
|
|
153
185
|
type: _WebComponent.WebComponentType.slot,
|
|
154
186
|
presentationMode: _bodyHtml.PresentationMode.CoverInjectedHeight,
|
|
155
187
|
script: (0, _UNBottomSheetComponent.getBottomSheetScript)(),
|
|
156
188
|
onMessage: onWebMessage,
|
|
157
|
-
|
|
189
|
+
isScrollable: scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop,
|
|
190
|
+
handleScroll: onScrollWebView
|
|
158
191
|
}))));
|
|
159
192
|
};
|
|
160
193
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","useState","height","setHeight","renderingRequest","setRenderingRequest","shouldEnableWebViewScroll","setShouldEnableWebViewScroll","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","isAppActive","useAppStateListener","styles","getStylesObject","webRef","useRef","listenerAction","data","useEffect","current","renderingBottomSheetRequest","resetHtml","setNewHeight","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_RENDERING","action","message","nativePlace","JSON","parse","bottomSheetNewHeight","handleHtmlFullHeight","Dimensions","get","details","onWebMessage","type","PageMessage","PAGE_HEIGHT","setTimeout","CardMessage","CARD_STATUS_CHANGED","EventBus","Instance","event","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","Linking","openURL","undefined","container","WebComponentType","slot","PresentationMode","CoverInjectedHeight","getBottomSheetScript"],"sources":["UNBottomSheetComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport type WebView from 'react-native-webview';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { Dimensions, Linking, View } from 'react-native';\nimport BottomSheet from '../../helpers/BottomSheet/BottomSheet';\nimport EventBus from '../../helpers/EventBus';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { RequestOpenLinkEvent, RequestRenderingData, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { CardMessage, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest, resetHtml } from './UNBottomSheetComponent.utils';\nimport { getStylesObject } from './UNBottomSheetComponent.styles';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { useAppStateListener } from '../../hooks/useAppStateListener';\n\nexport const UNBottomSheetComponent = () => {\n const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);\n const [height, setHeight] = useState(0);\n\n const [renderingRequest, setRenderingRequest] = useState<string | null>(null);\n const [shouldEnableWebViewScroll, setShouldEnableWebViewScroll] = useState(false);\n\n const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);\n const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null);\n\n const isAppActive = useAppStateListener();\n\n const styles = getStylesObject();\n\n const webRef = useRef<WebView>(null);\n\n const listenerAction = (data: string) => {\n setRenderingRequest(data);\n setIsBottomSheetActive(true);\n };\n\n useEffect(() => {\n if (!isAppActive) {\n setIsBottomSheetActive(false);\n }\n }, [isAppActive]);\n\n useEffect(() => {\n if (!webRef.current) return;\n if (renderingRequest) {\n renderingBottomSheetRequest(webRef.current, renderingRequest);\n }\n }, [webRef.current, renderingRequest]);\n\n useEffect(() => {\n if (!isBottomSheetActive) {\n webRef.current && resetHtml(webRef.current);\n setHeight(0);\n setRenderingRequest(null);\n }\n }, [isBottomSheetActive]);\n\n useEffect(() => {\n if (!waitForLoadingNewComponent && newHeightMessage) {\n setWaitForLoadingNewComponent(false);\n setNewHeight(newHeightMessage);\n }\n }, [waitForLoadingNewComponent, newHeightMessage]);\n\n useListenerToBus([{ busEventKey: UnitMessage.UNIT_REQUEST_RENDERING, action: listenerAction }]);\n\n const setNewHeight = (message: WebViewMessage) => {\n if (renderingRequest) {\n const nativePlace = (JSON.parse(renderingRequest) as RequestRenderingData).nativePlace;\n if (nativePlace == 'overFullScreen') {\n const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);\n setHeight(bottomSheetNewHeight);\n setShouldEnableWebViewScroll(true);\n } else {\n setHeight((message.details as HeightEvent).height);\n setShouldEnableWebViewScroll(false);\n }\n }\n };\n\n const onWebMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case PageMessage.PAGE_HEIGHT:\n renderingRequest && setNewHeightMessage(message);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING:\n // eslint-disable-next-line no-case-declarations\n const { data } = (message.details as RequestRenderingEvent);\n if (data != renderingRequest) {\n setHeight(0);\n setRenderingRequest(data);\n setWaitForLoadingNewComponent(true);\n setTimeout(() => setWaitForLoadingNewComponent(false), 400);\n }\n break;\n case CardMessage.CARD_STATUS_CHANGED:\n EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card);\n break;\n case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:\n setIsBottomSheetActive(false);\n break;\n case UnitMessage.UNIT_REQUEST_OPEN_LINK:\n // eslint-disable-next-line no-case-declarations\n const { href } = (message.details as RequestOpenLinkEvent);\n Linking.openURL(href);\n break;\n }\n };\n\n return (\n <>\n <View\n pointerEvents={isBottomSheetActive ? undefined : 'none'}\n style={styles.container}\n >\n <BottomSheet\n isOpen={isBottomSheetActive}\n height={height}\n onClose={() => setIsBottomSheetActive(false)}\n onOpen={() => setIsBottomSheetActive(true)}\n >\n { isAppActive && (\n <WebComponent\n ref={webRef}\n type={WebComponentType.slot}\n presentationMode={PresentationMode.CoverInjectedHeight}\n script={getBottomSheetScript()}\n onMessage={onWebMessage}\n shouldEnableWebViewScroll={shouldEnableWebViewScroll}\n />)}\n </BottomSheet>\n </View>\n </>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,sBAAsB,GAAG,MAAM;EAC1C,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgD,IAAAC,eAAA,EAAS,KAAT,CAAtD;EACA,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAA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BAAmB,CAACc,IAAD,CAAnB;UACAV,6BAA6B,CAAC,IAAD,CAA7B;UACAkC,UAAU,CAAC,MAAMlC,6BAA6B,CAAC,KAAD,CAApC,EAA6C,GAA7C,CAAV;QACD;;QACD;;MACF,KAAKmC,wBAAA,CAAYC,mBAAjB;QACEC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBJ,wBAAA,CAAYC,mBAApC,EAA0Df,OAAO,CAACQ,OAAT,CAA4CW,IAArG;;QACA;;MACF,KAAKtB,yBAAA,CAAYuB,uBAAjB;QACElD,sBAAsB,CAAC,KAAD,CAAtB;QACA;;MACF,KAAK2B,yBAAA,CAAYwB,sBAAjB;QACE;QACA,MAAM;UAAEC;QAAF,IAAYtB,OAAO,CAACQ,OAA1B;;QACAe,oBAAA,CAAQC,OAAR,CAAgBF,IAAhB;;QACA;IAxBJ;EA0BD,CA3BD;;EA6BA,oBACE,yEACE,6BAAC,iBAAD;IACE,aAAa,EAAErD,mBAAmB,GAAGwD,SAAH,GAAe,MADnD;IAEE,KAAK,EAAEzC,MAAM,CAAC0C;EAFhB,gBAIE,6BAAC,oBAAD;IACE,MAAM,EAAEzD,mBADV;IAEE,MAAM,EAAEG,MAFV;IAGE,OAAO,EAAE,MAAMF,sBAAsB,CAAC,KAAD,CAHvC;IAIE,MAAM,EAAE,MAAMA,sBAAsB,CAAC,IAAD;EAJtC,GAMIY,WAAW,iBACX,6BAAC,0BAAD;IACE,GAAG,EAAEI,MADP;IAEE,IAAI,EAAEyC,8BAAA,CAAiBC,IAFzB;IAGE,gBAAgB,EAAEC,0BAAA,CAAiBC,mBAHrC;IAIE,MAAM,EAAE,IAAAC,4CAAA,GAJV;IAKE,SAAS,EAAEtB,YALb;IAME,yBAAyB,EAAEjC;EAN7B,EAPJ,CAJF,CADF,CADF;AAyBD,CAvHM"}
|
|
1
|
+
{"version":3,"names":["ScrollState","UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","useState","height","setHeight","renderingRequest","setRenderingRequest","scrollState","setScrollState","onTop","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","isAppActive","useAppStateListener","styles","getStylesObject","webRef","useRef","listenerAction","data","useEffect","current","renderingBottomSheetRequest","resetHtml","setNewHeight","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_RENDERING","action","message","nativePlace","JSON","parse","bottomSheetNewHeight","handleHtmlFullHeight","Dimensions","get","details","unScrollable","onWebMessage","type","PageMessage","PAGE_HEIGHT","setTimeout","CardMessage","CARD_STATUS_CHANGED","EventBus","Instance","event","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","Linking","openURL","onScrollWebView","currY","nativeEvent","contentOffset","y","onlyBottomSheet","onlyWebView","handleWebViewScroll","undefined","container","WebComponentType","slot","PresentationMode","CoverInjectedHeight","getBottomSheetScript"],"sources":["UNBottomSheetComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useRef, useState } from 'react';\nimport type WebView from 'react-native-webview';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { Dimensions, Linking, View } from 'react-native';\nimport BottomSheet from '../../helpers/BottomSheet/BottomSheet';\nimport EventBus from '../../helpers/EventBus';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { RequestOpenLinkEvent, RequestRenderingData, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { CardMessage, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest, resetHtml } from './UNBottomSheetComponent.utils';\nimport { getStylesObject } from './UNBottomSheetComponent.styles';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { useAppStateListener } from '../../hooks/useAppStateListener';\n\nexport enum ScrollState {\n onTop = 'onTop',\n onlyWebView = 'webViewScroll',\n onlyBottomSheet = 'onlyBottomSheet',\n unScrollable = 'unScrollable'\n}\n\nexport const UNBottomSheetComponent = () => {\n const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);\n const [height, setHeight] = useState(0);\n\n const [renderingRequest, setRenderingRequest] = useState<string | null>(null);\n const [scrollState, setScrollState] = useState<ScrollState>(ScrollState.onTop);\n\n const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);\n const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null);\n\n const isAppActive = useAppStateListener();\n\n const styles = getStylesObject();\n\n const webRef = useRef<WebView>(null);\n\n const listenerAction = (data: string) => {\n setRenderingRequest(data);\n setIsBottomSheetActive(true);\n };\n\n useEffect(() => {\n if (!isAppActive) {\n setIsBottomSheetActive(false);\n }\n }, [isAppActive]);\n\n useEffect(() => {\n if (!webRef.current) return;\n if (renderingRequest) {\n renderingBottomSheetRequest(webRef.current, renderingRequest);\n }\n }, [webRef.current, renderingRequest]);\n\n useEffect(() => {\n if (!isBottomSheetActive) {\n webRef.current && resetHtml(webRef.current);\n setHeight(0);\n setRenderingRequest(null);\n setScrollState(ScrollState.onTop);\n }\n }, [isBottomSheetActive]);\n\n useEffect(() => {\n if (!waitForLoadingNewComponent && newHeightMessage) {\n setWaitForLoadingNewComponent(false);\n setNewHeight(newHeightMessage);\n }\n }, [waitForLoadingNewComponent, newHeightMessage]);\n\n useListenerToBus([{ busEventKey: UnitMessage.UNIT_REQUEST_RENDERING, action: listenerAction }]);\n\n const setNewHeight = (message: WebViewMessage) => {\n if (renderingRequest) {\n const nativePlace = (JSON.parse(renderingRequest) as RequestRenderingData).nativePlace;\n if (nativePlace == 'overFullScreen') {\n const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);\n setHeight(bottomSheetNewHeight);\n setScrollState(ScrollState.onTop);\n } else {\n setHeight((message.details as HeightEvent).height);\n setScrollState(ScrollState.unScrollable);\n }\n }\n };\n\n const onWebMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case PageMessage.PAGE_HEIGHT:\n renderingRequest && setNewHeightMessage(message);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING:\n // eslint-disable-next-line no-case-declarations\n const { data } = (message.details as RequestRenderingEvent);\n if (data != renderingRequest) {\n setHeight(0);\n setRenderingRequest(data);\n setWaitForLoadingNewComponent(true);\n setTimeout(() => setWaitForLoadingNewComponent(false), 400);\n }\n break;\n case CardMessage.CARD_STATUS_CHANGED:\n EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card);\n break;\n case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:\n setIsBottomSheetActive(false);\n break;\n case UnitMessage.UNIT_REQUEST_OPEN_LINK:\n // eslint-disable-next-line no-case-declarations\n const { href } = (message.details as RequestOpenLinkEvent);\n Linking.openURL(href);\n break;\n }\n };\n\n const onScrollWebView = (event: any) => {\n if (scrollState === ScrollState.unScrollable) return;\n\n const currY = event.nativeEvent.contentOffset.y;\n\n if (ScrollState.onTop && currY < 5) {\n setScrollState(ScrollState.onlyBottomSheet);\n }\n\n if ( scrollState !== ScrollState.onlyWebView && scrollState === ScrollState.onTop && currY > 5) {\n setScrollState(ScrollState.onlyWebView);\n }\n };\n\n const handleWebViewScroll = () => {\n if (scrollState === ScrollState.unScrollable) return;\n setScrollState(ScrollState.onlyWebView);\n };\n\n return (\n <>\n <View\n pointerEvents={isBottomSheetActive ? undefined : 'none'}\n style={styles.container}\n >\n <BottomSheet\n isOpen={isBottomSheetActive}\n height={height}\n onClose={() => setIsBottomSheetActive(false)}\n onOpen={() => setIsBottomSheetActive(true)}\n handleWebViewScroll={() => handleWebViewScroll()}\n shouldEnableBottomSheetScroll={scrollState !== ScrollState.onlyWebView}\n >\n { isAppActive && (\n <WebComponent\n ref={webRef}\n type={WebComponentType.slot}\n presentationMode={PresentationMode.CoverInjectedHeight}\n script={getBottomSheetScript()}\n onMessage={onWebMessage}\n isScrollable={scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop}\n handleScroll={onScrollWebView}\n />)}\n </BottomSheet>\n </View>\n </>\n );\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;AAfA;IAiBYA,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W;;AAOL,MAAMC,sBAAsB,GAAG,MAAM;EAC1C,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgD,IAAAC,eAAA,EAAS,KAAT,CAAtD;EACA,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAF,eAAA,EAAS,CAAT,CAA5B;EAEA,MAAM,CAACG,gBAAD,EAAmBC,mBAAnB,IAA0C,IAAAJ,eAAA,EAAwB,IAAxB,CAAhD;EACA,MAAM,CAACK,WAAD,EAAcC,cAAd,IAAgC,IAAAN,eAAA,EAAsBJ,WAAW,CAACW,KAAlC,CAAtC;EAEA,MAAM,CAACC,0BAAD,EAA6BC,6BAA7B,IAA8D,IAAAT,eAAA,EAAS,KAAT,CAApE;EACA,MAAM,CAACU,gBAAD,EAAmBC,mBAAnB,IAA0C,IAAAX,eAAA,EAAgC,IAAhC,CAAhD;EAEA,MAAMY,WAAW,GAAG,IAAAC,wCAAA,GAApB;EAEA,MAAMC,MAAM,GAAG,IAAAC,wCAAA,GAAf;EAEA,MAAMC,MAAM,GAAG,IAAAC,aAAA,EAAgB,IAAhB,CAAf;;EAEA,MAAMC,cAAc,GAAIC,IAAD,IAAkB;IACvCf,mBAAmB,CAACe,IAAD,CAAnB;IACApB,sBAAsB,CAAC,IAAD,CAAtB;EACD,CAHD;;EAKA,IAAAqB,gBAAA,EAAU,MAAM;IACd,IAAI,CAACR,WAAL,EAAkB;MAChBb,sBAAsB,CAAC,KAAD,CAAtB;IACD;EACF,CAJD,EA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PhB,EATJ,CAJF,CADF,CADF;AA4BD,CA9IM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UNCardComponent","props","height","setHeight","useState","requestRefreshEvent","setRequestRefreshEvent","windowWidth","Dimensions","get","width","webRef","useRef","cardStatusChanged","card","onStatusChanged","requestRefresh","data","useListenerToBus","busEventKey","CardMessage","CARD_STATUS_CHANGED","action","UnitMessage","UNIT_REQUEST_REFRESH","useEffect","injectRefreshEventIfNeeded","current","cardId","handleMessage","message","type","UNIT_REQUEST_RENDERING","EventBus","Instance","event","details","PageMessage","PAGE_HEIGHT","WebComponentType","PresentationMode","Default","getCardParams","getCardScript"],"sources":["UNCardComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getCardParams, getCardScript, injectRefreshEventIfNeeded } from './UNCardComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { UNCardData } from '../../sharedTypes';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\n\nexport interface UNCardComponentProps {\n cardId: string;\n customerToken: string;\n theme?: string;\n onStatusChanged?: (card: UNCardData) => void;\n}\n\nexport const UNCardComponent = (props: UNCardComponentProps) => {\n const [height, setHeight] = useState(0);\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n const windowWidth = Dimensions.get('window').width;\n\n const webRef = useRef<WebView>(null);\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n useListenerToBus([\n { busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged },\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent, props.cardId);\n }, [requestRefreshEvent]);\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING:\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, (message.details as RequestRenderingEvent).data);\n break;\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.card}\n presentationMode={PresentationMode.Default}\n params={getCardParams(props)}\n script={getCardScript()}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n
|
|
1
|
+
{"version":3,"names":["UNCardComponent","props","height","setHeight","useState","requestRefreshEvent","setRequestRefreshEvent","windowWidth","Dimensions","get","width","webRef","useRef","cardStatusChanged","card","onStatusChanged","requestRefresh","data","useListenerToBus","busEventKey","CardMessage","CARD_STATUS_CHANGED","action","UnitMessage","UNIT_REQUEST_REFRESH","useEffect","injectRefreshEventIfNeeded","current","cardId","handleMessage","message","type","UNIT_REQUEST_RENDERING","EventBus","Instance","event","details","PageMessage","PAGE_HEIGHT","WebComponentType","PresentationMode","Default","getCardParams","getCardScript"],"sources":["UNCardComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getCardParams, getCardScript, injectRefreshEventIfNeeded } from './UNCardComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { UNCardData } from '../../sharedTypes';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\n\nexport interface UNCardComponentProps {\n cardId: string;\n customerToken: string;\n theme?: string;\n onStatusChanged?: (card: UNCardData) => void;\n}\n\nexport const UNCardComponent = (props: UNCardComponentProps) => {\n const [height, setHeight] = useState(0);\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n const windowWidth = Dimensions.get('window').width;\n\n const webRef = useRef<WebView>(null);\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n useListenerToBus([\n { busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged },\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent, props.cardId);\n }, [requestRefreshEvent]);\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING:\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, (message.details as RequestRenderingEvent).data);\n break;\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.card}\n presentationMode={PresentationMode.Default}\n params={getCardParams(props)}\n script={getCardScript()}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;A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O,CAACM,OAAT,CAAiClC,MAAlC,CAAT;QACA;IANJ;EAQD,CATD;;EAWA,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAEA;IAAF;EAAb,gBACE,6BAAC,0BAAD;IACE,GAAG,EAAES,MADP;IAEE,IAAI,EAAE4B,8BAAA,CAAiBzB,IAFzB;IAGE,gBAAgB,EAAE0B,0BAAA,CAAiBC,OAHrC;IAIE,MAAM,EAAE,IAAAC,8BAAA,EAAczC,KAAd,CAJV;IAKE,MAAM,EAAE,IAAA0C,8BAAA,GALV;IAME,SAAS,EAAEb,OAAO,IAAID,aAAa,CAACC,OAAD,CANrC;IAOE,KAAK,EAAEvB,WAPT;IAQE,YAAY,EAAE;EARhB,EADF,CADF;AAcD,CAnDM"}
|
|
@@ -35,13 +35,15 @@ const BottomSheet = props => {
|
|
|
35
35
|
const [dy, setDy] = (0, _react.useState)(0);
|
|
36
36
|
|
|
37
37
|
const _parentPanResponder = _reactNative.PanResponder.create({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//gestureState) => {
|
|
41
|
-
return false; // return Math.abs(gestureState.dy) > 10
|
|
38
|
+
onMoveShouldSetPanResponderCapture: (_, gestureState) => {
|
|
39
|
+
return props.shouldEnableBottomSheetScroll && Math.abs(gestureState.dy) > 10;
|
|
42
40
|
},
|
|
43
41
|
|
|
44
42
|
onPanResponderMove(_, gestureState) {
|
|
43
|
+
if (props.shouldEnableBottomSheetScroll && gestureState.dy < 5) {
|
|
44
|
+
props.handleWebViewScroll();
|
|
45
|
+
}
|
|
46
|
+
|
|
45
47
|
if (currentHeight + gestureState.dy < 0) return;
|
|
46
48
|
if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;
|
|
47
49
|
panelHeightValue.setValue(currentHeight + gestureState.dy);
|
|
@@ -193,8 +195,7 @@ const BottomSheet = props => {
|
|
|
193
195
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
|
|
194
196
|
source: _images.CloseIcon
|
|
195
197
|
})), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
196
|
-
onLayout: _setSize
|
|
197
|
-
style: [styles.innerContent]
|
|
198
|
+
onLayout: _setSize
|
|
198
199
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.KeyboardAvoidingView, {
|
|
199
200
|
behavior: "padding",
|
|
200
201
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BottomSheet","props","panelHeightValue","useRef","Animated","Value","sliderMaxHeight","current","fadeAnim","styles","getStylesObject","isPanelOpened","setIsPanelOpened","useState","isOpen","contentHeight","setContentHeight","undefined","currentHeight","setCurrentHeight","dy","setDy","_parentPanResponder","PanResponder","create","onMoveShouldSetPanResponderCapture","_","onPanResponderMove","gestureState","expandToMaxHeightEnabled","setValue","onPanResponderRelease","collapse","setToContentHeight","expand","useEffect","fadeIn","_dismiss","BackHandler","addEventListener","_onBackPress","id","addListener","e","value","removeEventListener","removeListener","timing","toValue","duration","useNativeDriver","start","fadeOut","onClose","animationDuration","easing","Easing","quad","_setSize","newContentHeight","nativeEvent","layout","height","children","outsideContainer","animation","panHandlers","container","transform","translateY","outerContent","closeButton","CloseIcon","innerContent","BOTTOM_SHEET_MAX_PRECANTAGE_SIZE","propTypes","PropTypes","oneOfType","node","bool","number","func","onOpen","defaultProps","Dimensions","get"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState } from 'react';\nimport {\n Animated,\n BackHandler,\n Dimensions,\n Easing,\n Image,\n KeyboardAvoidingView,\n LayoutChangeEvent,\n PanResponder,\n TouchableOpacity,\n View,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { CloseIcon } from '../../assets/images';\nimport { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';\nimport { getStylesObject } from './BottomSheet.styles';\n\nexport interface BottomSheetProps {\n isOpen: boolean\n children: ReactNode\n sliderMaxHeight: number\n onOpen: () => void\n onClose: () => void\n height: number,\n animationDuration: number,\n expandToMaxHeightEnabled: boolean\n}\n\nconst BottomSheet = (props: BottomSheetProps) => {\n const panelHeightValue = useRef(new Animated.Value(props.sliderMaxHeight)).current;\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const styles = getStylesObject(fadeAnim);\n const [isPanelOpened, setIsPanelOpened] = useState(props.isOpen);\n const [contentHeight, setContentHeight] = useState<number | undefined>(undefined);\n\n const [currentHeight, setCurrentHeight] = useState<number>(props.sliderMaxHeight);\n\n const [dy, setDy] = useState(0);\n\n const _parentPanResponder = PanResponder.create({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onMoveShouldSetPanResponderCapture: (_,) => { //gestureState) => {\n return false;\n // return Math.abs(gestureState.dy) > 10\n },\n onPanResponderMove(_, gestureState) {\n if (currentHeight + gestureState.dy < 0) return;\n if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;\n panelHeightValue.setValue(currentHeight + gestureState.dy);\n setDy(gestureState.dy);\n },\n onPanResponderRelease: () => {\n if (dy > 0) {\n collapse();\n } else if (!props.expandToMaxHeightEnabled) {\n contentHeight && setToContentHeight(contentHeight);\n } else if (dy < 0) {\n expand();\n } else {\n expand();\n }\n }\n });\n\n useEffect(() => {\n if (props.isOpen && !isPanelOpened) {\n fadeIn();\n } else if (isPanelOpened) {\n setContentHeight(0);\n _dismiss();\n }\n }, [props.isOpen]);\n\n useEffect(() => {\n BackHandler.addEventListener('hardwareBackPress', _onBackPress);\n const id = panelHeightValue.addListener(e => setCurrentHeight(e.value));\n\n return (() => {\n BackHandler.removeEventListener('hardwareBackPress', _onBackPress);\n panelHeightValue.removeListener(id);\n });\n }, []);\n\n const fadeIn = () => {\n Animated.timing(fadeAnim, {\n toValue: 0.3,\n duration: 500,\n useNativeDriver: false\n }).start(() => { setIsPanelOpened(true); });\n };\n\n const fadeOut = () => {\n Animated.timing(fadeAnim, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false\n }).start(() => {\n setIsPanelOpened(false);\n props.onClose();\n });\n };\n\n const setToContentHeight = (contentHeight: number) => {\n Animated.timing(panelHeightValue, {\n duration: props.animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight - contentHeight,\n useNativeDriver: false,\n }).start();\n };\n\n const expand = () => {\n const { animationDuration } = props;\n\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n setToContentHeight(contentHeight);\n return;\n }\n\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: 0,\n useNativeDriver: false,\n }).start();\n };\n\n const collapse = () => {\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n _dismiss();\n return;\n }\n\n contentHeight && setToContentHeight(contentHeight);\n };\n\n const _onBackPress = () => {\n isPanelOpened && collapse();\n return isPanelOpened;\n };\n\n const _setSize = (e: LayoutChangeEvent) => {\n const newContentHeight = e.nativeEvent.layout.height;\n\n setContentHeight(newContentHeight);\n setToContentHeight(newContentHeight);\n };\n\n const _dismiss = () => {\n const { animationDuration } = props;\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight,\n useNativeDriver: false,\n }).start(() => {\n null;\n });\n fadeOut();\n };\n\n const {\n sliderMaxHeight,\n children,\n } = props;\n\n return (\n <>\n <TouchableOpacity\n style={styles.outsideContainer} activeOpacity={1}\n onPress={_dismiss}\n >\n <Animated.View\n style={styles.animation}\n >\n </Animated.View>\n </TouchableOpacity>\n <Animated.View\n {..._parentPanResponder.panHandlers}\n style={{\n ...styles.container,\n height: sliderMaxHeight,\n transform: [\n { translateY: panelHeightValue },\n ],\n }}\n >\n <View\n style={styles.outerContent}\n >\n <TouchableOpacity\n activeOpacity={1}\n style={styles.closeButton}\n onPress={_dismiss}\n >\n <Image source={CloseIcon} />\n </TouchableOpacity>\n\n <View\n onLayout={_setSize}\n style={[styles.innerContent]}\n >\n <KeyboardAvoidingView\n behavior=\"padding\"\n style={{ height: props.height }}\n keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PRECANTAGE_SIZE)}\n >\n {children}\n </KeyboardAvoidingView>\n </View>\n </View>\n </Animated.View>\n </>\n );\n};\n\nBottomSheet.propTypes = {\n children: PropTypes.oneOfType([PropTypes.node]),\n isOpen: PropTypes.bool,\n sliderMaxHeight: PropTypes.number,\n animation: PropTypes.func,\n animationDuration: PropTypes.number,\n onOpen: PropTypes.func,\n onClose: PropTypes.func,\n expandToMaxHeightEnabled: PropTypes.bool\n};\n\nBottomSheet.defaultProps = {\n children: <View />,\n isOpen: true,\n sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PRECANTAGE_SIZE,\n animationDuration: 200,\n onOpen: () => null,\n onClose: () => null,\n expandToMaxHeightEnabled: false\n};\n\nexport default BottomSheet;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAYA;;AACA;;AACA;;AACA;;;;;;;;;;AAaA,MAAMA,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAMC,gBAAgB,GAAG,IAAAC,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmBJ,KAAK,CAACK,eAAzB,CAAP,EAAkDC,OAA3E;EACA,MAAMC,QAAQ,GAAG,IAAAL,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmB,CAAnB,CAAP,EAA8BE,OAA/C;EACA,MAAME,MAAM,GAAG,IAAAC,4BAAA,EAAgBF,QAAhB,CAAf;EACA,MAAM,CAACG,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAC,eAAA,EAASZ,KAAK,CAACa,MAAf,CAA1C;EACA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAH,eAAA,EAA6BI,SAA7B,CAA1C;EAEA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAN,eAAA,EAAiBZ,KAAK,CAACK,eAAvB,CAA1C;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iBAAiB,EAAEsB,kBAAA,CAAUI,MALP;EAMtBE,MAAM,EAAEN,kBAAA,CAAUK,IANI;EAOtB5B,OAAO,EAAEuB,kBAAA,CAAUK,IAPG;EAQtBpD,wBAAwB,EAAE+C,kBAAA,CAAUG;AARd,CAAxB;AAWA/E,WAAW,CAACmF,YAAZ,GAA2B;EACzBpB,QAAQ,eAAE,6BAAC,iBAAD,OADe;EAEzBjD,MAAM,EAAE,IAFiB;EAGzBR,eAAe,EAAE8E,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBvB,MAAzB,GAAkCY,wDAH1B;EAIzBpB,iBAAiB,EAAE,GAJM;EAKzB4B,MAAM,EAAE,MAAM,IALW;EAMzB7B,OAAO,EAAE,MAAM,IANU;EAOzBxB,wBAAwB,EAAE;AAPD,CAA3B;eAUe7B,W"}
|
|
1
|
+
{"version":3,"names":["BottomSheet","props","panelHeightValue","useRef","Animated","Value","sliderMaxHeight","current","fadeAnim","styles","getStylesObject","isPanelOpened","setIsPanelOpened","useState","isOpen","contentHeight","setContentHeight","undefined","currentHeight","setCurrentHeight","dy","setDy","_parentPanResponder","PanResponder","create","onMoveShouldSetPanResponderCapture","_","gestureState","shouldEnableBottomSheetScroll","Math","abs","onPanResponderMove","handleWebViewScroll","expandToMaxHeightEnabled","setValue","onPanResponderRelease","collapse","setToContentHeight","expand","useEffect","fadeIn","_dismiss","BackHandler","addEventListener","_onBackPress","id","addListener","e","value","removeEventListener","removeListener","timing","toValue","duration","useNativeDriver","start","fadeOut","onClose","animationDuration","easing","Easing","quad","_setSize","newContentHeight","nativeEvent","layout","height","children","outsideContainer","animation","panHandlers","container","transform","translateY","outerContent","closeButton","CloseIcon","BOTTOM_SHEET_MAX_PRECANTAGE_SIZE","propTypes","PropTypes","oneOfType","node","bool","number","func","onOpen","defaultProps","Dimensions","get"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState } from 'react';\nimport {\n Animated,\n BackHandler,\n Dimensions,\n Easing,\n Image,\n KeyboardAvoidingView,\n LayoutChangeEvent,\n PanResponder,\n TouchableOpacity,\n View,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { CloseIcon } from '../../assets/images';\nimport { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';\nimport { getStylesObject } from './BottomSheet.styles';\n\nexport interface BottomSheetProps {\n isOpen: boolean\n children: ReactNode\n sliderMaxHeight: number\n onOpen: () => void\n onClose: () => void\n height: number,\n animationDuration: number,\n expandToMaxHeightEnabled: boolean\n handleWebViewScroll: () => void\n shouldEnableBottomSheetScroll: boolean\n}\n\nconst BottomSheet = (props: BottomSheetProps) => {\n const panelHeightValue = useRef(new Animated.Value(props.sliderMaxHeight)).current;\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const styles = getStylesObject(fadeAnim);\n const [isPanelOpened, setIsPanelOpened] = useState(props.isOpen);\n const [contentHeight, setContentHeight] = useState<number | undefined>(undefined);\n\n const [currentHeight, setCurrentHeight] = useState<number>(props.sliderMaxHeight);\n\n const [dy, setDy] = useState(0);\n\n const _parentPanResponder = PanResponder.create({\n onMoveShouldSetPanResponderCapture: (_, gestureState) => {\n return props.shouldEnableBottomSheetScroll && Math.abs(gestureState.dy) > 10;\n },\n onPanResponderMove(_, gestureState) {\n if (props.shouldEnableBottomSheetScroll && gestureState.dy < 5) {\n props.handleWebViewScroll();\n }\n if (currentHeight + gestureState.dy < 0) return;\n if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;\n panelHeightValue.setValue(currentHeight + gestureState.dy);\n setDy(gestureState.dy);\n },\n onPanResponderRelease: () => {\n if (dy > 0) {\n collapse();\n } else if (!props.expandToMaxHeightEnabled) {\n contentHeight && setToContentHeight(contentHeight);\n } else if (dy < 0) {\n expand();\n } else {\n expand();\n }\n }\n });\n\n useEffect(() => {\n if (props.isOpen && !isPanelOpened) {\n fadeIn();\n } else if (isPanelOpened) {\n setContentHeight(0);\n _dismiss();\n }\n }, [props.isOpen]);\n\n useEffect(() => {\n BackHandler.addEventListener('hardwareBackPress', _onBackPress);\n const id = panelHeightValue.addListener(e => setCurrentHeight(e.value));\n\n return (() => {\n BackHandler.removeEventListener('hardwareBackPress', _onBackPress);\n panelHeightValue.removeListener(id);\n });\n }, []);\n\n const fadeIn = () => {\n Animated.timing(fadeAnim, {\n toValue: 0.3,\n duration: 500,\n useNativeDriver: false\n }).start(() => { setIsPanelOpened(true); });\n };\n\n const fadeOut = () => {\n Animated.timing(fadeAnim, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false\n }).start(() => {\n setIsPanelOpened(false);\n props.onClose();\n });\n };\n\n const setToContentHeight = (contentHeight: number) => {\n Animated.timing(panelHeightValue, {\n duration: props.animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight - contentHeight,\n useNativeDriver: false,\n }).start();\n };\n\n const expand = () => {\n const { animationDuration } = props;\n\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n setToContentHeight(contentHeight);\n return;\n }\n\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: 0,\n useNativeDriver: false,\n }).start();\n };\n\n const collapse = () => {\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n _dismiss();\n return;\n }\n\n contentHeight && setToContentHeight(contentHeight);\n };\n\n const _onBackPress = () => {\n isPanelOpened && collapse();\n return isPanelOpened;\n };\n\n const _setSize = (e: LayoutChangeEvent) => {\n const newContentHeight = e.nativeEvent.layout.height;\n\n setContentHeight(newContentHeight);\n setToContentHeight(newContentHeight);\n };\n\n const _dismiss = () => {\n const { animationDuration } = props;\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight,\n useNativeDriver: false,\n }).start(() => {\n null;\n });\n fadeOut();\n };\n\n const {\n sliderMaxHeight,\n children,\n } = props;\n\n return (\n <>\n <TouchableOpacity\n style={styles.outsideContainer} activeOpacity={1}\n onPress={_dismiss}\n >\n <Animated.View\n style={styles.animation}\n >\n </Animated.View>\n </TouchableOpacity>\n <Animated.View\n {..._parentPanResponder.panHandlers}\n style={{\n ...styles.container,\n height: sliderMaxHeight,\n transform: [\n { translateY: panelHeightValue },\n ],\n }}\n >\n <View\n style={styles.outerContent}\n >\n <TouchableOpacity\n activeOpacity={1}\n style={styles.closeButton}\n onPress={_dismiss}\n >\n <Image source={CloseIcon} />\n </TouchableOpacity>\n\n <View\n onLayout={_setSize}\n >\n <KeyboardAvoidingView\n behavior=\"padding\"\n style={{ height: props.height }}\n keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PRECANTAGE_SIZE)}\n >\n {children}\n </KeyboardAvoidingView>\n </View>\n </View>\n </Animated.View>\n </>\n );\n};\n\nBottomSheet.propTypes = {\n children: PropTypes.oneOfType([PropTypes.node]),\n isOpen: PropTypes.bool,\n sliderMaxHeight: PropTypes.number,\n animation: PropTypes.func,\n animationDuration: PropTypes.number,\n onOpen: PropTypes.func,\n onClose: PropTypes.func,\n expandToMaxHeightEnabled: PropTypes.bool\n};\n\nBottomSheet.defaultProps = {\n children: <View />,\n isOpen: true,\n sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PRECANTAGE_SIZE,\n animationDuration: 200,\n onOpen: () => null,\n onClose: () => null,\n expandToMaxHeightEnabled: false\n};\n\nexport default BottomSheet;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAYA;;AACA;;AACA;;AACA;;;;;;;;;;AAeA,MAAMA,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAMC,gBAAgB,GAAG,IAAAC,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmBJ,KAAK,CAACK,eAAzB,CAAP,EAAkDC,OAA3E;EACA,MAAMC,QAAQ,GAAG,IAAAL,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmB,CAAnB,CAAP,E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AAD;IACE,QAAQ,EAAC,SADX;IAEE,KAAK,EAAE;MAAEI,MAAM,EAAEjE,KAAK,CAACiE;IAAhB,CAFT;IAGE,sBAAsB,EAAEjE,KAAK,CAACiE,MAAN,IAAgB,IAAIW,wDAApB;EAH1B,GAKGV,QALH,CAHF,CAXF,CAVF,CAVF,CADF;AA+CD,CA1LD;;AA4LAnE,WAAW,CAAC8E,SAAZ,GAAwB;EACtBX,QAAQ,EAAEY,kBAAA,CAAUC,SAAV,CAAoB,CAACD,kBAAA,CAAUE,IAAX,CAApB,CADY;EAEtBnE,MAAM,EAAEiE,kBAAA,CAAUG,IAFI;EAGtB5E,eAAe,EAAEyE,kBAAA,CAAUI,MAHL;EAItBd,SAAS,EAAEU,kBAAA,CAAUK,IAJC;EAKtB1B,iBAAiB,EAAEqB,kBAAA,CAAUI,MALP;EAMtBE,MAAM,EAAEN,kBAAA,CAAUK,IANI;EAOtB3B,OAAO,EAAEsB,kBAAA,CAAUK,IAPG;EAQtBnD,wBAAwB,EAAE8C,kBAAA,CAAUG;AARd,CAAxB;AAWAlF,WAAW,CAACsF,YAAZ,GAA2B;EACzBnB,QAAQ,eAAE,6BAAC,iBAAD,OADe;EAEzBrD,MAAM,EAAE,IAFiB;EAGzBR,eAAe,EAAEiF,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBtB,MAAzB,GAAkCW,wDAH1B;EAIzBnB,iBAAiB,EAAE,GAJM;EAKzB2B,MAAM,EAAE,MAAM,IALW;EAMzB5B,OAAO,EAAE,MAAM,IANU;EAOzBxB,wBAAwB,EAAE;AAPD,CAA3B;eAUejC,W"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PageMessage"],"sources":["pageMessage.ts"],"sourcesContent":["export enum PageMessage {\n PAGE_LOADED = 'pageLoaded',\n PAGE_HEIGHT = 'pageHeight'
|
|
1
|
+
{"version":3,"names":["PageMessage"],"sources":["pageMessage.ts"],"sourcesContent":["export enum PageMessage {\n PAGE_LOADED = 'pageLoaded',\n PAGE_HEIGHT = 'pageHeight',\n}\n\nexport interface HeightEvent {\n height: number;\n}\n\nexport type PageEvent =\n | HeightEvent\n"],"mappings":";;;;;;IAAYA,W;;;WAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
const UnitAddToWalletButtonView = (0, _reactNative.requireNativeComponent)('UnitAddToWalletButtonView');
|
|
11
|
+
var _default = UnitAddToWalletButtonView;
|
|
12
|
+
exports.default = _default;
|
|
13
|
+
//# sourceMappingURL=UNNativeAddToWalletButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UnitAddToWalletButtonView","requireNativeComponent"],"sources":["UNNativeAddToWalletButton.tsx"],"sourcesContent":["import {\n requireNativeComponent,\n} from 'react-native';\n\ntype UnitAddToWalletButtonViewProps = {\n style: object;\n onAddToWalletClicked: () => void;\n};\n\nconst UnitAddToWalletButtonView = requireNativeComponent<UnitAddToWalletButtonViewProps>('UnitAddToWalletButtonView');\n\nexport default UnitAddToWalletButtonView;\n"],"mappings":";;;;;;;AAAA;;AASA,MAAMA,yBAAyB,GAAG,IAAAC,mCAAA,EAAuD,2BAAvD,CAAlC;eAEeD,yB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UNEnvironment","UNIT_SCRIPT_URL","sandbox","production","UnitSDK","env","theme","fetchUnitScript","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import { fetchUnitScript } from './UnitSdk.api';\n\nexport enum UNEnvironment {\n sandbox = 'sandbox',\n production = 'production'\n}\n\nexport const UNIT_SCRIPT_URL = {\n [UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',\n [UNEnvironment.production]: 'https://ui.unit.co/components.js'\n};\nexport class UnitSDK {\n protected static env?: UNEnvironment;\n protected static theme?: string;\n\n public static init = async (env: UNEnvironment, theme
|
|
1
|
+
{"version":3,"names":["UNEnvironment","UNIT_SCRIPT_URL","sandbox","production","UnitSDK","env","theme","fetchUnitScript","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import { fetchUnitScript } from './UnitSdk.api';\n\nexport enum UNEnvironment {\n sandbox = 'sandbox',\n production = 'production'\n}\n\nexport const UNIT_SCRIPT_URL = {\n [UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',\n [UNEnvironment.production]: 'https://ui.unit.co/components.js'\n};\nexport class UnitSDK {\n protected static env?: UNEnvironment;\n protected static theme?: string;\n\n public static init = async (env: UNEnvironment, theme?: string) => {\n try {\n this.env = env;\n this.theme = theme;\n await fetchUnitScript();\n } catch (e) {\n console.log(e);\n }\n };\n\n public static getEnv = () => {\n return this.env;\n };\n\n public static getTheme = () => {\n return this.theme;\n };\n}\n"],"mappings":";;;;;;;AAAA;;;;IAEYA,a;;;WAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a;;AAKL,MAAMC,eAAe,GAAG;EAC7B,CAACD,aAAa,CAACE,OAAf,GAAyB,oCADI;EAE7B,CAACF,aAAa,CAACG,UAAf,GAA4B;AAFC,CAAxB;;;AAIA,MAAMC,OAAN,CAAc;;;;gBAARA,O;;gBAAAA,O;;gBAAAA,O,UAIU,OAAOC,GAAP,EAA2BC,KAA3B,KAA8C;EACjE,IAAI;IALKF,OAMP,CAAKC,GAAL,GAAWA,GAAX;IANOD,OAOP,CAAKE,KAAL,GAAaA,KAAb;IACA,MAAM,IAAAC,wBAAA,GAAN;EACD,CAJD,CAIE,OAAOC,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;EACD;AACF,C;;gBAZUJ,O,YAcY,MAAM;EAC3B,OAfSA,OAeF,CAAKC,GAAZ;AACD,C;;gBAhBUD,O,cAkBc,MAAM;EAC7B,OAnBSA,OAmBF,CAAKE,KAAZ;AACD,C"}
|
|
@@ -29,6 +29,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
29
29
|
|
|
30
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
31
|
|
|
32
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
32
33
|
let WebComponentType;
|
|
33
34
|
exports.WebComponentType = WebComponentType;
|
|
34
35
|
|
|
@@ -42,6 +43,7 @@ exports.WebComponentType = WebComponentType;
|
|
|
42
43
|
const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponent(props, webRef) {
|
|
43
44
|
const [unitScript, setUnitScript] = (0, _react.useState)(_UnitSdk.globalUnitScript);
|
|
44
45
|
const [sourceHtml, setSourceHtml] = (0, _react.useState)(null);
|
|
46
|
+
const width = props.width ?? '100%';
|
|
45
47
|
|
|
46
48
|
const listenerAction = data => {
|
|
47
49
|
setUnitScript(data.unitScript);
|
|
@@ -74,14 +76,24 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponen
|
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
if (!sourceHtml) return null;
|
|
79
|
+
|
|
80
|
+
const _onScroll = event => {
|
|
81
|
+
if (props.handleScroll) {
|
|
82
|
+
props.handleScroll(event);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
|
|
77
88
|
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
78
89
|
ref: webRef,
|
|
79
90
|
cacheEnabled: false,
|
|
80
|
-
scrollEnabled: props.
|
|
91
|
+
scrollEnabled: props.isScrollable,
|
|
92
|
+
onScroll: _onScroll,
|
|
81
93
|
overScrollMode: "never",
|
|
82
94
|
injectedJavaScript: unitScript,
|
|
83
95
|
style: {
|
|
84
|
-
width:
|
|
96
|
+
width: width,
|
|
85
97
|
flex: 1
|
|
86
98
|
},
|
|
87
99
|
source: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","listenerAction","data","useListenerToBus","busEventKey","NativeMessage","IS_SCRIPT_FETCHED","action","useEffect","fetchUnitScript","newHtml","html","replace","HTML_PLACEHOLDER","BODY","getHtmlBody","type","valueOf","params","presentationMode","SCRIPT_FROM_NATIVE","script","onMessage","e","message","JSON","parse","nativeEvent","UnitMessage","UNIT_REQUEST_REFRESH","details","EventBus","Instance","event","
|
|
1
|
+
{"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","width","listenerAction","data","useListenerToBus","busEventKey","NativeMessage","IS_SCRIPT_FETCHED","action","useEffect","fetchUnitScript","newHtml","html","replace","HTML_PLACEHOLDER","BODY","getHtmlBody","type","valueOf","params","presentationMode","SCRIPT_FROM_NATIVE","script","onMessage","e","message","JSON","parse","nativeEvent","UnitMessage","UNIT_REQUEST_REFRESH","details","EventBus","Instance","event","_onScroll","handleScroll","isScrollable","flex"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport { getHtmlBody, PresentationMode } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport type { WebViewMessage } from '../messages/webMessages';\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n handleScroll?: (event: any) => void,\n width?: number;\n}\n\nexport enum WebComponentType {\n card = 'unit-elements-card',\n bookPayment = 'unit-elements-book-payment',\n activity = 'unit-elements-activity',\n slot = 'unit-elements-sdk-slot'\n}\n\nexport const WebComponent = React.forwardRef<WebView, WebComponentProps>(function WebComponent(props, webRef) {\n const [unitScript, setUnitScript] = useState<string | undefined>(globalUnitScript);\n const [sourceHtml, setSourceHtml] = useState<string | null>(null);\n const width = props.width ?? '100%';\n\n const listenerAction = (data: { unitScript?: string }) => {\n setUnitScript(data.unitScript);\n };\n\n useListenerToBus([{ busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: listenerAction }]);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), props.params, props.presentationMode));\n newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');\n setSourceHtml(newHtml);\n\n }, [props.params, unitScript]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n if (message.type == UnitMessage.UNIT_REQUEST_REFRESH && message.details) {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n } else {\n props.onMessage && props.onMessage(message);\n }\n };\n\n if (!sourceHtml) return null;\n\n const _onScroll = (event: any) => {\n if (props.handleScroll) {\n props.handleScroll(event);\n }\n\n return null;\n };\n\n return (\n <WebView\n ref={webRef}\n cacheEnabled={false}\n scrollEnabled={props.isScrollable}\n onScroll={_onScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: width, flex: 1 }}\n source={{ html: sourceHtml }}\n onMessage={onMessage} />\n );\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AATA;IAuBYA,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAOL,MAAMC,YAAY,gBAAGC,cAAA,CAAMC,UAAN,CAA6C,SAASF,YAAT,CAAsBG,KAAtB,EAA6BC,MAA7B,EAAqC;EAC5G,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,IAAAC,eAAA,EAA6BC,yBAA7B,CAApC;EACA,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,IAAAH,eAAA,EAAwB,IAAxB,CAApC;EACA,MAAMI,KAAK,GAAGR,KAAK,CAACQ,KAAN,IAAe,MAA7B;;EAEA,MAAMC,cAAc,GAAIC,IAAD,IAAmC;IACxDP,aAAa,CAACO,IAAI,CAACR,UAAN,CAAb;EACD,CAFD;;EAIA,IAAAS,+BAAA,EAAiB,CAAC;IAAEC,WAAW,EAAEC,6BAAA,CAAcC,iBAA7B;IAAgDC,MAAM,EAAEN;EAAxD,CAAD,CAAjB;EAEA,IAAAO,gBAAA,EAAU,MAAM;IACd,IAAI,CAACd,UAAL,EAAiB;MACf,IAAAe,wBAAA;MACA;IACD;;IAED,IAAIC,OAAO,GAAGC,aAAA,CAAKC,OAAL,CAAaC,sBAAA,CAAiBC,IAA9B,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,KAAK,EAAEA,KAAT;MAAgBqC,IAAI,EAAE;IAAtB,CAPT;IAQE,MAAM,EAAE;MAAE1B,IAAI,EAAEb;IAAR,CARV;IASE,SAAS,EAAEwB;EATb,EADF;AAYD,CAtD2B,CAArB"}
|
|
@@ -7,7 +7,7 @@ export const UNActivityComponent = props => {
|
|
|
7
7
|
type: WebComponentType.activity,
|
|
8
8
|
presentationMode: PresentationMode.Inherit,
|
|
9
9
|
params: getActivityParams(props),
|
|
10
|
-
|
|
10
|
+
isScrollable: false
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=UNActivityComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","PresentationMode","WebComponent","WebComponentType","getActivityParams","UNActivityComponent","props","activity","Inherit"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n return (\n <WebComponent\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n
|
|
1
|
+
{"version":3,"names":["React","PresentationMode","WebComponent","WebComponentType","getActivityParams","UNActivityComponent","props","activity","Inherit"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n return (\n <WebComponent\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n isScrollable={false}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AAQA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,oBACE,oBAAC,YAAD;IACE,IAAI,EAAEH,gBAAgB,CAACI,QADzB;IAEE,gBAAgB,EAAEN,gBAAgB,CAACO,OAFrC;IAGE,MAAM,EAAEJ,iBAAiB,CAACE,KAAD,CAH3B;IAIE,YAAY,EAAE;EAJhB,EADF;AAQD,CATM"}
|
|
@@ -17,7 +17,7 @@ export const UNBookPaymentComponent = props => {
|
|
|
17
17
|
params: getBookPaymentParams(props),
|
|
18
18
|
script: getBookPaymentScript(),
|
|
19
19
|
onMessage: message => handleWebViewMessage(message),
|
|
20
|
-
|
|
20
|
+
isScrollable: false
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
//# sourceMappingURL=UNBookPaymentComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","WebComponent","WebComponentType","PresentationMode","getBookPaymentParams","getBookPaymentScript","BookPaymentMessage","UNBookPaymentComponent","props","handleWebViewMessage","message","type","PAYMENT_CREATED","onPaymentCreated","response","details","data","bookPayment","Inherit"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { UNBookPaymentData } from '../../sharedTypes';\n\nexport interface UNBookPaymentComponentProps {\n accountId: string;\n customerToken: string;\n isSameCustomer: boolean;\n counterPartyAccountId: string;\n counterPartyName: string;\n theme?: string;\n onPaymentCreated?: (data: UNBookPaymentData) => void;\n}\n\nexport const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {\n const response = message.details as BookPaymentEvent;\n props.onPaymentCreated(response.data);\n }\n };\n\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={PresentationMode.Inherit}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n
|
|
1
|
+
{"version":3,"names":["React","WebComponent","WebComponentType","PresentationMode","getBookPaymentParams","getBookPaymentScript","BookPaymentMessage","UNBookPaymentComponent","props","handleWebViewMessage","message","type","PAYMENT_CREATED","onPaymentCreated","response","details","data","bookPayment","Inherit"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { UNBookPaymentData } from '../../sharedTypes';\n\nexport interface UNBookPaymentComponentProps {\n accountId: string;\n customerToken: string;\n isSameCustomer: boolean;\n counterPartyAccountId: string;\n counterPartyName: string;\n theme?: string;\n onPaymentCreated?: (data: UNBookPaymentData) => void;\n}\n\nexport const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {\n const response = message.details as BookPaymentEvent;\n props.onPaymentCreated(response.data);\n }\n };\n\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={PresentationMode.Inherit}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,oBAAT,EAA+BC,oBAA/B,QAA2D,gCAA3D;AAEA,SAA2BC,kBAA3B,QAAqD,+CAArD;AAaA,OAAO,MAAMC,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBL,kBAAkB,CAACM,eAApC,IAAuDJ,KAAK,CAACK,gBAAjE,EAAmF;MACjF,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,OAAzB;MACAP,KAAK,CAACK,gBAAN,CAAuBC,QAAQ,CAACE,IAAhC;IACD;EACF,CALD;;EAOA,oBACE,oBAAC,YAAD;IACE,IAAI,EAAEd,gBAAgB,CAACe,WADzB;IAEE,gBAAgB,EAAEd,gBAAgB,CAACe,OAFrC;IAGE,MAAM,EAAEd,oBAAoB,CAACI,KAAD,CAH9B;IAIE,MAAM,EAAEH,oBAAoB,EAJ9B;IAKE,SAAS,EAAGK,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;IAME,YAAY,EAAE;EANhB,EADF;AAUD,CAlBM"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
3
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
4
|
import { Dimensions, Linking, View } from 'react-native';
|
|
@@ -11,11 +12,20 @@ import { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest
|
|
|
11
12
|
import { getStylesObject } from './UNBottomSheetComponent.styles';
|
|
12
13
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
13
14
|
import { useAppStateListener } from '../../hooks/useAppStateListener';
|
|
15
|
+
export let ScrollState;
|
|
16
|
+
|
|
17
|
+
(function (ScrollState) {
|
|
18
|
+
ScrollState["onTop"] = "onTop";
|
|
19
|
+
ScrollState["onlyWebView"] = "webViewScroll";
|
|
20
|
+
ScrollState["onlyBottomSheet"] = "onlyBottomSheet";
|
|
21
|
+
ScrollState["unScrollable"] = "unScrollable";
|
|
22
|
+
})(ScrollState || (ScrollState = {}));
|
|
23
|
+
|
|
14
24
|
export const UNBottomSheetComponent = () => {
|
|
15
25
|
const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);
|
|
16
26
|
const [height, setHeight] = useState(0);
|
|
17
27
|
const [renderingRequest, setRenderingRequest] = useState(null);
|
|
18
|
-
const [
|
|
28
|
+
const [scrollState, setScrollState] = useState(ScrollState.onTop);
|
|
19
29
|
const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);
|
|
20
30
|
const [newHeightMessage, setNewHeightMessage] = useState(null);
|
|
21
31
|
const isAppActive = useAppStateListener();
|
|
@@ -44,6 +54,7 @@ export const UNBottomSheetComponent = () => {
|
|
|
44
54
|
webRef.current && resetHtml(webRef.current);
|
|
45
55
|
setHeight(0);
|
|
46
56
|
setRenderingRequest(null);
|
|
57
|
+
setScrollState(ScrollState.onTop);
|
|
47
58
|
}
|
|
48
59
|
}, [isBottomSheetActive]);
|
|
49
60
|
useEffect(() => {
|
|
@@ -64,10 +75,10 @@ export const UNBottomSheetComponent = () => {
|
|
|
64
75
|
if (nativePlace == 'overFullScreen') {
|
|
65
76
|
const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);
|
|
66
77
|
setHeight(bottomSheetNewHeight);
|
|
67
|
-
|
|
78
|
+
setScrollState(ScrollState.onTop);
|
|
68
79
|
} else {
|
|
69
80
|
setHeight(message.details.height);
|
|
70
|
-
|
|
81
|
+
setScrollState(ScrollState.unScrollable);
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
84
|
};
|
|
@@ -111,6 +122,24 @@ export const UNBottomSheetComponent = () => {
|
|
|
111
122
|
}
|
|
112
123
|
};
|
|
113
124
|
|
|
125
|
+
const onScrollWebView = event => {
|
|
126
|
+
if (scrollState === ScrollState.unScrollable) return;
|
|
127
|
+
const currY = event.nativeEvent.contentOffset.y;
|
|
128
|
+
|
|
129
|
+
if (ScrollState.onTop && currY < 5) {
|
|
130
|
+
setScrollState(ScrollState.onlyBottomSheet);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (scrollState !== ScrollState.onlyWebView && scrollState === ScrollState.onTop && currY > 5) {
|
|
134
|
+
setScrollState(ScrollState.onlyWebView);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const handleWebViewScroll = () => {
|
|
139
|
+
if (scrollState === ScrollState.unScrollable) return;
|
|
140
|
+
setScrollState(ScrollState.onlyWebView);
|
|
141
|
+
};
|
|
142
|
+
|
|
114
143
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
115
144
|
pointerEvents: isBottomSheetActive ? undefined : 'none',
|
|
116
145
|
style: styles.container
|
|
@@ -118,14 +147,17 @@ export const UNBottomSheetComponent = () => {
|
|
|
118
147
|
isOpen: isBottomSheetActive,
|
|
119
148
|
height: height,
|
|
120
149
|
onClose: () => setIsBottomSheetActive(false),
|
|
121
|
-
onOpen: () => setIsBottomSheetActive(true)
|
|
150
|
+
onOpen: () => setIsBottomSheetActive(true),
|
|
151
|
+
handleWebViewScroll: () => handleWebViewScroll(),
|
|
152
|
+
shouldEnableBottomSheetScroll: scrollState !== ScrollState.onlyWebView
|
|
122
153
|
}, isAppActive && /*#__PURE__*/React.createElement(WebComponent, {
|
|
123
154
|
ref: webRef,
|
|
124
155
|
type: WebComponentType.slot,
|
|
125
156
|
presentationMode: PresentationMode.CoverInjectedHeight,
|
|
126
157
|
script: getBottomSheetScript(),
|
|
127
158
|
onMessage: onWebMessage,
|
|
128
|
-
|
|
159
|
+
isScrollable: scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop,
|
|
160
|
+
handleScroll: onScrollWebView
|
|
129
161
|
}))));
|
|
130
162
|
};
|
|
131
163
|
//# sourceMappingURL=UNBottomSheetComponent.js.map
|