react-native-unit-components 1.0.0 → 1.0.2
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 +39 -8
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +0 -3
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +41 -10
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -3
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.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 +2 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +0 -3
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.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/nativeMessages/index.js +1 -0
- package/lib/commonjs/messages/nativeMessages/index.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/scripts/html/bodyHtml.js +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +8 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +31 -6
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +33 -7
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +0 -2
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +36 -9
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -2
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.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 +2 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +0 -2
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.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/nativeMessages/index.js +1 -0
- package/lib/module/messages/nativeMessages/index.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/scripts/html/bodyHtml.js +1 -1
- package/lib/module/scripts/html/bodyHtml.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdkManager.js +3 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +29 -6
- 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/messages/nativeMessages/index.d.ts +2 -1
- 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 +5 -2
- package/package.json +1 -1
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +33 -7
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +0 -2
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +35 -9
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +0 -2
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +35 -4
- package/src/components/UNCardComponent/UNCardComponent.tsx +2 -1
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +0 -2
- package/src/helpers/BottomSheet/BottomSheet.tsx +7 -5
- package/src/messages/nativeMessages/index.ts +2 -1
- package/src/messages/webMessages/pageMessage.ts +1 -1
- package/src/nativeComponent/UNNativeAddToWalletButton.tsx +12 -0
- package/src/scripts/html/bodyHtml.ts +1 -1
- package/src/unitSdkManager/UnitSdkManager.ts +4 -1
- package/src/webComponent/WebComponent.tsx +33 -9
- 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":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAG,kBAAlB;;IAEKC,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAcL,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,
|
|
1
|
+
{"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''} }> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAG,kBAAlB;;IAEKC,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAcL,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,SAAQD,aAAc,GAA7F;;EAEA,QAAQE,gBAAR;IACE,KAAKJ,gBAAgB,CAACM,mBAAtB;MACE,OAAOC,gCAAgC,CAACF,gBAAD,CAAvC;;IACF,KAAKL,gBAAgB,CAACQ,OAAtB;MACE,OAAOC,0BAA0B,CAACJ,gBAAD,CAAjC;;IACF;MACE,OAAOA,gBAAP;EANJ;AAQD,CAXM;;;;AAaP,MAAME,gCAAgC,GAAIG,iBAAD,IAA+B;EACtE,OAAQ;AACV,cAAcX,SAAU;AACxB;AACA,UAAUW,iBAAkB;AAC5B;AACA;AACA,GANE;AAOD,CARD;;AAUA,MAAMD,0BAA0B,GAAIC,iBAAD,IAA+B;EAChE,OAAQ;AACV;AACA,QAAQA,iBAAkB;AAC1B;AACA,GAJE;AAKD,CAND"}
|
|
@@ -5,8 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UnitSDK = exports.UNIT_SCRIPT_URL = exports.UNEnvironment = void 0;
|
|
7
7
|
|
|
8
|
+
var _EventBus = _interopRequireDefault(require("../helpers/EventBus"));
|
|
9
|
+
|
|
10
|
+
var _nativeMessages = require("../messages/nativeMessages");
|
|
11
|
+
|
|
8
12
|
var _UnitSdk = require("./UnitSdk.api");
|
|
9
13
|
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
10
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
17
|
|
|
12
18
|
let UNEnvironment;
|
|
@@ -36,6 +42,8 @@ _defineProperty(UnitSDK, "init", async (env, theme) => {
|
|
|
36
42
|
UnitSDK.env = env;
|
|
37
43
|
UnitSDK.theme = theme;
|
|
38
44
|
await (0, _UnitSdk.fetchUnitScript)();
|
|
45
|
+
|
|
46
|
+
_EventBus.default.Instance.event(_nativeMessages.NativeMessage.IS_SDK_INITIALIZED, {});
|
|
39
47
|
} catch (e) {
|
|
40
48
|
console.log(e);
|
|
41
49
|
}
|
|
@@ -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","EventBus","Instance","event","NativeMessage","IS_SDK_INITIALIZED","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import EventBus from '../helpers/EventBus';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport { 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 EventBus.Instance.event(NativeMessage.IS_SDK_INITIALIZED, { });\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;;AACA;;AACA;;;;;;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;;IACAC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBC,6BAAA,CAAcC,kBAAtC,EAA0D,EAA1D;EACD,CALD,CAKE,OAAOC,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;EACD;AACF,C;;gBAbUT,O,YAeY,MAAM;EAC3B,OAhBSA,OAgBF,CAAKC,GAAZ;AACD,C;;gBAjBUD,O,cAmBc,MAAM;EAC7B,OApBSA,OAoBF,CAAKE,KAAZ;AACD,C"}
|
|
@@ -23,12 +23,15 @@ var _UnitSdk = require("../unitSdkManager/UnitSdk.api");
|
|
|
23
23
|
|
|
24
24
|
var _nativeMessages = require("../messages/nativeMessages");
|
|
25
25
|
|
|
26
|
+
var _UnitSdkManager = require("../unitSdkManager/UnitSdkManager");
|
|
27
|
+
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
29
|
|
|
28
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
31
|
|
|
30
32
|
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
33
|
|
|
34
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
32
35
|
let WebComponentType;
|
|
33
36
|
exports.WebComponentType = WebComponentType;
|
|
34
37
|
|
|
@@ -42,14 +45,23 @@ exports.WebComponentType = WebComponentType;
|
|
|
42
45
|
const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponent(props, webRef) {
|
|
43
46
|
const [unitScript, setUnitScript] = (0, _react.useState)(_UnitSdk.globalUnitScript);
|
|
44
47
|
const [sourceHtml, setSourceHtml] = (0, _react.useState)(null);
|
|
48
|
+
const [componentCurrentTheme, setComponentCurrentTheme] = (0, _react.useState)(props.theme ?? _UnitSdkManager.UnitSDK.getTheme());
|
|
49
|
+
const width = props.width ?? '100%';
|
|
45
50
|
|
|
46
|
-
const
|
|
51
|
+
const updateUnitScript = data => {
|
|
47
52
|
setUnitScript(data.unitScript);
|
|
48
53
|
};
|
|
49
54
|
|
|
55
|
+
const updateInitializedParams = () => {
|
|
56
|
+
setComponentCurrentTheme(props.theme ?? _UnitSdkManager.UnitSDK.getTheme());
|
|
57
|
+
};
|
|
58
|
+
|
|
50
59
|
(0, _listenerToBus.useListenerToBus)([{
|
|
51
60
|
busEventKey: _nativeMessages.NativeMessage.IS_SCRIPT_FETCHED,
|
|
52
|
-
action:
|
|
61
|
+
action: updateUnitScript
|
|
62
|
+
}, {
|
|
63
|
+
busEventKey: _nativeMessages.NativeMessage.IS_SDK_INITIALIZED,
|
|
64
|
+
action: updateInitializedParams
|
|
53
65
|
}]);
|
|
54
66
|
(0, _react.useEffect)(() => {
|
|
55
67
|
if (!unitScript) {
|
|
@@ -57,11 +69,13 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponen
|
|
|
57
69
|
return;
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
|
|
72
|
+
const componentParams = (props.params || '') + (componentCurrentTheme ? ` theme="${componentCurrentTheme}"` : '');
|
|
73
|
+
|
|
74
|
+
let newHtml = _html.default.replace(_html.HTML_PLACEHOLDER.BODY, (0, _bodyHtml.getHtmlBody)(props.type.valueOf(), componentParams, props.presentationMode));
|
|
61
75
|
|
|
62
76
|
newHtml = newHtml.replace(_html.HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');
|
|
63
77
|
setSourceHtml(newHtml);
|
|
64
|
-
}, [props.params, unitScript]);
|
|
78
|
+
}, [props.params, unitScript, props.presentationMode, componentCurrentTheme]);
|
|
65
79
|
|
|
66
80
|
const onMessage = e => {
|
|
67
81
|
const message = JSON.parse(e.nativeEvent.data);
|
|
@@ -74,14 +88,25 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponen
|
|
|
74
88
|
};
|
|
75
89
|
|
|
76
90
|
if (!sourceHtml) return null;
|
|
91
|
+
|
|
92
|
+
const _onScroll = event => {
|
|
93
|
+
if (props.handleScroll) {
|
|
94
|
+
props.handleScroll(event);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return null;
|
|
98
|
+
};
|
|
99
|
+
|
|
77
100
|
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
78
101
|
ref: webRef,
|
|
79
102
|
cacheEnabled: false,
|
|
80
|
-
scrollEnabled: props.
|
|
103
|
+
scrollEnabled: props.isScrollable,
|
|
104
|
+
nestedScrollEnabled: props.nestedScrollEnabled,
|
|
105
|
+
onScroll: _onScroll,
|
|
81
106
|
overScrollMode: "never",
|
|
82
107
|
injectedJavaScript: unitScript,
|
|
83
108
|
style: {
|
|
84
|
-
width:
|
|
109
|
+
width: width,
|
|
85
110
|
flex: 1
|
|
86
111
|
},
|
|
87
112
|
source: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","
|
|
1
|
+
{"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","componentCurrentTheme","setComponentCurrentTheme","theme","UnitSDK","getTheme","width","updateUnitScript","data","updateInitializedParams","useListenerToBus","busEventKey","NativeMessage","IS_SCRIPT_FETCHED","action","IS_SDK_INITIALIZED","useEffect","fetchUnitScript","componentParams","params","newHtml","html","replace","HTML_PLACEHOLDER","BODY","getHtmlBody","type","valueOf","presentationMode","SCRIPT_FROM_NATIVE","script","onMessage","e","message","JSON","parse","nativeEvent","UnitMessage","UNIT_REQUEST_REFRESH","details","EventBus","Instance","event","_onScroll","handleScroll","isScrollable","nestedScrollEnabled","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 { UnitSDK } from '../unitSdkManager/UnitSdkManager';\nimport type { WebViewMessage } from '../messages/webMessages';\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n theme?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n nestedScrollEnabled?: 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 [componentCurrentTheme, setComponentCurrentTheme] = useState<string | undefined>(props.theme ?? UnitSDK.getTheme());\n const width = props.width ?? '100%';\n\n const updateUnitScript = (data: { unitScript?: string }) => {\n setUnitScript(data.unitScript);\n };\n\n const updateInitializedParams = () => {\n setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());\n };\n\n useListenerToBus([\n { busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: updateUnitScript },\n { busEventKey: NativeMessage.IS_SDK_INITIALIZED, action: updateInitializedParams },\n ]);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n const componentParams = (props.params || '') + (componentCurrentTheme ? ` theme=\"${componentCurrentTheme}\"` : '');\n let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), componentParams, props.presentationMode));\n newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');\n setSourceHtml(newHtml);\n }, [props.params, unitScript, props.presentationMode, componentCurrentTheme]);\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 nestedScrollEnabled={props.nestedScrollEnabled}\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;;AACA;;;;;;;;AAVA;IA0BYA,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,MAAM,CAACI,qBAAD,EAAwBC,wBAAxB,IAAoD,IAAAL,eAAA,EAA6BJ,KAAK,CAACU,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAA5C,CAA1D;EACA,MAAMC,KAAK,GAAGb,KAAK,CAACa,KAAN,IAAe,MAA7B;;EAEA,MAAMC,gBAAgB,GAAIC,IAAD,IAAmC;IAC1DZ,aAAa,CAACY,IAAI,CAACb,UAAN,CAAb;EACD,CAFD;;EAIA,MAAMc,uBAAuB,GAAG,MAAM;IACpCP,wBAAwB,CAACT,KAAK,CAACU,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAAhB,CAAxB;EACD,CAFD;;EAIA,IAAAK,+BAAA,EAAiB,CACf;IAAEC,WAAW,EAAEC,6BAAA,CAAcC,iBAA7B;IAAgDC,MAAM,EAAEP;EAAxD,CADe,EAEf;IAAEI,WAAW,EAAEC,6BAAA,CAAc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O,IAAP;;EAEjB,MAAM4C,SAAS,GAAID,KAAD,IAAgB;IAChC,IAAIjD,KAAK,CAACmD,YAAV,EAAwB;MACtBnD,KAAK,CAACmD,YAAN,CAAmBF,KAAnB;IACD;;IAED,OAAO,IAAP;EACD,CAND;;EAQA,oBACE,6BAAC,2BAAD;IACE,GAAG,EAAEhD,MADP;IAEE,YAAY,EAAE,KAFhB;IAGE,aAAa,EAAED,KAAK,CAACoD,YAHvB;IAIE,mBAAmB,EAAEpD,KAAK,CAACqD,mBAJ7B;IAKE,QAAQ,EAAEH,SALZ;IAME,cAAc,EAAC,OANjB;IAOE,kBAAkB,EAAEhD,UAPtB;IAQE,KAAK,EAAE;MAAEW,KAAK,EAAEA,KAAT;MAAgByC,IAAI,EAAE;IAAtB,CART;IASE,MAAM,EAAE;MAAE1B,IAAI,EAAEtB;IAAR,CATV;IAUE,SAAS,EAAEgC;EAVb,EADF;AAaD,CA/D2B,CAArB"}
|
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Dimensions, View } from 'react-native';
|
|
3
|
+
import { PageMessage } from '../../messages/webMessages/pageMessage';
|
|
2
4
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
3
5
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
4
6
|
import { getActivityParams } from './UNActivityComponent.utils';
|
|
7
|
+
const DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;
|
|
5
8
|
export const UNActivityComponent = props => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const [defaultHeight, setDefaultHeight] = useState();
|
|
10
|
+
|
|
11
|
+
const handleWebViewMessage = message => {
|
|
12
|
+
if (message.type === PageMessage.PAGE_HEIGHT) {
|
|
13
|
+
const currentHeight = message.details.height;
|
|
14
|
+
currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const renderActivityWebView = () => {
|
|
19
|
+
return /*#__PURE__*/React.createElement(WebComponent, {
|
|
20
|
+
type: WebComponentType.activity,
|
|
21
|
+
presentationMode: PresentationMode.Inherit,
|
|
22
|
+
params: getActivityParams(props),
|
|
23
|
+
onMessage: message => handleWebViewMessage(message),
|
|
24
|
+
nestedScrollEnabled: true,
|
|
25
|
+
theme: props.theme
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (!defaultHeight) {
|
|
30
|
+
return renderActivityWebView();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
34
|
+
style: {
|
|
35
|
+
height: defaultHeight
|
|
36
|
+
}
|
|
37
|
+
}, renderActivityWebView());
|
|
12
38
|
};
|
|
13
39
|
//# 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
|
|
1
|
+
{"version":3,"names":["React","useState","Dimensions","View","PageMessage","PresentationMode","WebComponent","WebComponentType","getActivityParams","DEFAULT_HEIGHT","get","height","UNActivityComponent","props","defaultHeight","setDefaultHeight","handleWebViewMessage","message","type","PAGE_HEIGHT","currentHeight","details","renderActivityWebView","activity","Inherit","theme"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nconst DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n const [defaultHeight, setDefaultHeight] = useState<number>();\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === PageMessage.PAGE_HEIGHT) {\n const currentHeight = (message.details as HeightEvent).height;\n currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);\n }\n };\n\n const renderActivityWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n nestedScrollEnabled={true}\n theme={props.theme}\n />\n );\n };\n\n if (!defaultHeight) {\n return renderActivityWebView();\n }\n\n return (\n <View style={{ height: defaultHeight }}>\n {renderActivityWebView()}\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AAEA,MAAMC,cAAc,GAAGP,UAAU,CAACQ,GAAX,CAAe,QAAf,EAAyBC,MAAzB,GAAkC,GAAzD;AAOA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoCd,QAAQ,EAAlD;;EACA,MAAMe,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBd,WAAW,CAACe,WAAjC,EAA8C;MAC5C,MAAMC,aAAa,GAAIH,OAAO,CAACI,OAAT,CAAiCV,MAAvD;MACAS,aAAa,KAAK,CAAlB,IAAuBL,gBAAgB,CAACN,cAAD,CAAvC;IACD;EACF,CALD;;EAOA,MAAMa,qBAAqB,GAAG,MAAM;IAClC,oBACE,oBAAC,YAAD;MACE,IAAI,EAAEf,gBAAgB,CAACgB,QADzB;MAEE,gBAAgB,EAAElB,gBAAgB,CAACmB,OAFrC;MAGE,MAAM,EAAEhB,iBAAiB,CAACK,KAAD,CAH3B;MAIE,SAAS,EAAGI,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAJ9D;MAKE,mBAAmB,EAAE,IALvB;MAME,KAAK,EAAEJ,KAAK,CAACY;IANf,EADF;EAUD,CAXD;;EAaA,IAAI,CAACX,aAAL,EAAoB;IAClB,OAAOQ,qBAAqB,EAA5B;EACD;;EAED,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEX,MAAM,EAAEG;IAAV;EAAb,GACGQ,qBAAqB,EADxB,CADF;AAKD,CA/BM"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
2
1
|
export const getActivityParams = props => {
|
|
3
2
|
return `
|
|
4
3
|
account-id="${props.accountId}"
|
|
5
4
|
customer-token="${props.customerToken}"
|
|
6
|
-
theme="${props.theme ?? UnitSDK.getTheme()}"
|
|
7
5
|
style="height: 100%"
|
|
8
6
|
`;
|
|
9
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getActivityParams","props","accountId","customerToken"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n style=\"height: 100%\"\n `;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C;AACA,GAJE;AAKD,CANM"}
|
|
@@ -1,23 +1,50 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
3
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
4
|
import { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';
|
|
5
5
|
import { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
|
|
6
|
+
import { PageMessage } from '../../messages/webMessages/pageMessage';
|
|
7
|
+
import { View } from 'react-native';
|
|
6
8
|
export const UNBookPaymentComponent = props => {
|
|
9
|
+
const [height, setHeight] = useState(0);
|
|
10
|
+
const [presentationMode, setPresentationMode] = useState(PresentationMode.Inherit);
|
|
11
|
+
|
|
7
12
|
const handleWebViewMessage = message => {
|
|
8
13
|
if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {
|
|
9
14
|
const response = message.details;
|
|
10
15
|
props.onPaymentCreated(response.data);
|
|
11
16
|
}
|
|
17
|
+
|
|
18
|
+
if (message.type === PageMessage.PAGE_HEIGHT) {
|
|
19
|
+
const currentHeight = message.details.height;
|
|
20
|
+
setHeight(currentHeight);
|
|
21
|
+
|
|
22
|
+
if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {
|
|
23
|
+
setPresentationMode(PresentationMode.Default);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
12
26
|
};
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
const renderBookPaymentWebView = () => {
|
|
29
|
+
return /*#__PURE__*/React.createElement(WebComponent, {
|
|
30
|
+
type: WebComponentType.bookPayment,
|
|
31
|
+
presentationMode: presentationMode,
|
|
32
|
+
params: getBookPaymentParams(props),
|
|
33
|
+
script: getBookPaymentScript(),
|
|
34
|
+
onMessage: message => handleWebViewMessage(message),
|
|
35
|
+
isScrollable: false,
|
|
36
|
+
theme: props.theme
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (presentationMode === PresentationMode.Inherit) {
|
|
41
|
+
return renderBookPaymentWebView();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
45
|
+
style: {
|
|
46
|
+
height: height
|
|
47
|
+
}
|
|
48
|
+
}, renderBookPaymentWebView());
|
|
22
49
|
};
|
|
23
50
|
//# 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","
|
|
1
|
+
{"version":3,"names":["React","useState","WebComponent","WebComponentType","PresentationMode","getBookPaymentParams","getBookPaymentScript","BookPaymentMessage","PageMessage","View","UNBookPaymentComponent","props","height","setHeight","presentationMode","setPresentationMode","Inherit","handleWebViewMessage","message","type","PAYMENT_CREATED","onPaymentCreated","response","details","data","PAGE_HEIGHT","currentHeight","Default","renderBookPaymentWebView","bookPayment","theme"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React, { useState } 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';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { View } from 'react-native';\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 [height, setHeight] = useState<number>(0);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\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 if (message.type === PageMessage.PAGE_HEIGHT) {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n }\n };\n\n const renderBookPaymentWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={presentationMode}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderBookPaymentWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderBookPaymentWebView()}\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;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;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;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AAOY,wBAAwB,EAA/B;EACD;;EAED,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEhB,MAAM,EAAEA;IAAV;EAAb,GACGgB,wBAAwB,EAD3B,CADF;AAKD,CA1CM"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
|
|
2
|
-
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
3
2
|
export const getBookPaymentParams = props => {
|
|
4
3
|
return `
|
|
5
4
|
account-id="${props.accountId}"
|
|
@@ -7,7 +6,6 @@ export const getBookPaymentParams = props => {
|
|
|
7
6
|
is-same-customer="${props.isSameCustomer}"
|
|
8
7
|
counterparty-account-id="${props.counterPartyAccountId}"
|
|
9
8
|
counterparty-name="${props.counterPartyName}"
|
|
10
|
-
theme="${props.theme ?? UnitSDK.getTheme()}"
|
|
11
9
|
style="height: 100%"
|
|
12
10
|
`;
|
|
13
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BookPaymentMessage","
|
|
1
|
+
{"version":3,"names":["BookPaymentMessage","getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","getBookPaymentScript","PAYMENT_CREATED"],"sources":["UNBookPaymentComponent.utils.ts"],"sourcesContent":["import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';\n\nimport { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\n\nexport const getBookPaymentParams = (props: UNBookPaymentComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n is-same-customer=\"${props.isSameCustomer}\"\n counterparty-account-id=\"${props.counterPartyAccountId}\"\n counterparty-name=\"${props.counterPartyName}\"\n style=\"height: 100%\"\n `;\n};\n\nexport const getBookPaymentScript = () => {\n return `\n window.addEventListener(\"${BookPaymentMessage.PAYMENT_CREATED}\", (e) => {\n const response = e.detail\n response.then((data) => {\n postMessageToSDK({ type: \"${BookPaymentMessage.PAYMENT_CREATED}\", details: { data: JSON.stringify(data.data) }})\n }).catch((e) => {\n console.log(e)\n })\n });\n `;\n};\n"],"mappings":"AAEA,SAASA,kBAAT,QAAmC,+CAAnC;AAEA,OAAO,MAAMC,oBAAoB,GAAIC,KAAD,IAAwC;EAC1E,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,wBAAwBF,KAAK,CAACG,cAAe;AAC7C,+BAA+BH,KAAK,CAACI,qBAAsB;AAC3D,yBAAyBJ,KAAK,CAACK,gBAAiB;AAChD;AACA,GAPE;AAQD,CATM;AAWP,OAAO,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BR,kBAAkB,CAACS,eAAgB;AAClE;AACA;AACA,sCAAsCT,kBAAkB,CAACS,eAAgB;AACzE;AACA;AACA;AACA;AACA,GATE;AAUD,CAXM"}
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","WebComponent","WebComponentType","Dimensions","Linking","View","BottomSheet","EventBus","PageMessage","UnitMessage","CardMessage","useListenerToBus","getBottomSheetScript","handleHtmlFullHeight","renderingBottomSheetRequest","resetHtml","getStylesObject","PresentationMode","useAppStateListener","UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","height","setHeight","renderingRequest","setRenderingRequest","shouldEnableWebViewScroll","setShouldEnableWebViewScroll","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","isAppActive","styles","webRef","listenerAction","data","current","setNewHeight","busEventKey","UNIT_REQUEST_RENDERING","action","message","nativePlace","JSON","parse","bottomSheetNewHeight","get","details","onWebMessage","type","PAGE_HEIGHT","setTimeout","CARD_STATUS_CHANGED","Instance","event","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","openURL","undefined","container","slot","CoverInjectedHeight"],"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,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AAEA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,IAA9B,QAA0C,cAA1C;AACA,OAAOC,WAAP,MAAwB,uCAAxB;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAA4EC,WAA5E,QAA+F,yCAA/F;AACA,SAASC,WAAT,QAAoD,wCAApD;AACA,SAASC,gBAAT,QAAiC,2BAAjC;AAEA,SAASC,oBAAT,EAA+BC,oBAA/B,EAAqDC,2BAArD,EAAkFC,SAAlF,QAAmG,g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C;IAIE,MAAM,EAAEpD,oBAAoB,EAJ9B;IAKE,SAAS,EAAEqC,YALb;IAME,yBAAyB,EAAEvB;EAN7B,EAPJ,CAJF,CADF,CADF;AAyBD,CAvHM"}
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","WebComponent","WebComponentType","Dimensions","Linking","View","BottomSheet","EventBus","PageMessage","UnitMessage","CardMessage","useListenerToBus","getBottomSheetScript","handleHtmlFullHeight","renderingBottomSheetRequest","resetHtml","getStylesObject","PresentationMode","useAppStateListener","ScrollState","UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","height","setHeight","renderingRequest","setRenderingRequest","scrollState","setScrollState","onTop","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","isAppActive","styles","webRef","listenerAction","data","current","setNewHeight","busEventKey","UNIT_REQUEST_RENDERING","action","message","nativePlace","JSON","parse","bottomSheetNewHeight","get","details","unScrollable","onWebMessage","type","PAGE_HEIGHT","setTimeout","CARD_STATUS_CHANGED","Instance","event","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","openURL","onScrollWebView","currY","nativeEvent","contentOffset","y","onlyBottomSheet","onlyWebView","handleWebViewScroll","undefined","container","slot","CoverInjectedHeight"],"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":"AAAA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AAEA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,IAA9B,QAA0C,cAA1C;AACA,OAAOC,WAAP,MAAwB,uCAAxB;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAA4EC,WAA5E,QAA+F,yCAA/F;AACA,SAASC,WAAT,QAAoD,wCAApD;AACA,SAASC,gBAAT,QAAiC,2BAAjC;AAEA,SAASC,oBAAT,EAA+BC,oBAA/B,EAAqDC,2BAArD,EAAkFC,SAAlF,QAAmG,gCAAnG;AACA,SAASC,eAAT,QAAgC,iCAAhC;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,mBAAT,QAAoC,iCAApC;AAEA,WAAYC,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W;;AAOZ,OAAO,MAAMC,sBAAsB,GAAG,MAAM;EAC1C,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgDtB,QAAQ,CAAC,KAAD,CAA9D;EACA,MAAM,CAACuB,MAAD,EAASC,SAAT,IAAsBxB,QAAQ,CAAC,CA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EjD,mBAAmB,GAAGmD,SAAH,GAAe,MADnD;IAEE,KAAK,EAAErC,MAAM,CAACsC;EAFhB,gBAIE,oBAAC,WAAD;IACE,MAAM,EAAEpD,mBADV;IAEE,MAAM,EAAEE,MAFV;IAGE,OAAO,EAAE,MAAMD,sBAAsB,CAAC,KAAD,CAHvC;IAIE,MAAM,EAAE,MAAMA,sBAAsB,CAAC,IAAD,CAJtC;IAKE,mBAAmB,EAAE,MAAOiD,mBAAmB,EALjD;IAME,6BAA6B,EAAE5C,WAAW,KAAKR,WAAW,CAACmD;EAN7D,GAQIpC,WAAW,iBACX,oBAAC,YAAD;IACE,GAAG,EAAEE,MADP;IAEE,IAAI,EAAElC,gBAAgB,CAACwE,IAFzB;IAGE,gBAAgB,EAAEzD,gBAAgB,CAAC0D,mBAHrC;IAIE,MAAM,EAAE/D,oBAAoB,EAJ9B;IAKE,SAAS,EAAEwC,YALb;IAME,YAAY,EAAEzB,WAAW,KAAKR,WAAW,CAACmD,WAA5B,IAA2C3C,WAAW,KAAKR,WAAW,CAACU,KANvF;IAOE,YAAY,EAAEmC;EAPhB,EATJ,CAJF,CADF,CADF;AA4BD,CA9IM"}
|
|
@@ -56,10 +56,11 @@ export const UNCardComponent = props => {
|
|
|
56
56
|
type: WebComponentType.card,
|
|
57
57
|
presentationMode: PresentationMode.Default,
|
|
58
58
|
params: getCardParams(props),
|
|
59
|
+
theme: props.theme,
|
|
59
60
|
script: getCardScript(),
|
|
60
61
|
onMessage: message => handleMessage(message),
|
|
61
62
|
width: windowWidth,
|
|
62
|
-
|
|
63
|
+
isScrollable: false
|
|
63
64
|
}));
|
|
64
65
|
};
|
|
65
66
|
//# sourceMappingURL=UNCardComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","Dimensions","View","PageMessage","UnitMessage","EventBus","WebComponent","WebComponentType","useListenerToBus","getCardParams","getCardScript","injectRefreshEventIfNeeded","PresentationMode","CardMessage","UNCardComponent","props","height","setHeight","requestRefreshEvent","setRequestRefreshEvent","windowWidth","get","width","webRef","cardStatusChanged","card","onStatusChanged","requestRefresh","data","busEventKey","CARD_STATUS_CHANGED","action","UNIT_REQUEST_REFRESH","current","cardId","handleMessage","message","type","UNIT_REQUEST_RENDERING","Instance","event","details","PAGE_HEIGHT","Default"],"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":["React","useEffect","useRef","useState","Dimensions","View","PageMessage","UnitMessage","EventBus","WebComponent","WebComponentType","useListenerToBus","getCardParams","getCardScript","injectRefreshEventIfNeeded","PresentationMode","CardMessage","UNCardComponent","props","height","setHeight","requestRefreshEvent","setRequestRefreshEvent","windowWidth","get","width","webRef","cardStatusChanged","card","onStatusChanged","requestRefresh","data","busEventKey","CARD_STATUS_CHANGED","action","UNIT_REQUEST_REFRESH","current","cardId","handleMessage","message","type","UNIT_REQUEST_RENDERING","Instance","event","details","PAGE_HEIGHT","Default","theme"],"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 theme={props.theme}\n script={getCardScript()}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAAqDC,WAArD,QAAwE,yCAAxE;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,SAASC,YAA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jC,QAAQ,CAACkC,QAAT,CAAkBC,KAAlB,CAAwBpC,WAAW,CAACkC,sBAApC,EAA6DF,OAAO,CAACK,OAAT,CAA2Cb,IAAvG;QACA;;MACF,KAAKzB,WAAW,CAACuC,WAAjB;QACEzB,SAAS,CAAEmB,OAAO,CAACK,OAAT,CAAiCzB,MAAlC,CAAT;QACA;IANJ;EAQD,CATD;;EAWA,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEA;IAAF;EAAb,gBACE,oBAAC,YAAD;IACE,GAAG,EAAEO,MADP;IAEE,IAAI,EAAEhB,gBAAgB,CAACkB,IAFzB;IAGE,gBAAgB,EAAEb,gBAAgB,CAAC+B,OAHrC;IAIE,MAAM,EAAElC,aAAa,CAACM,KAAD,CAJvB;IAKE,KAAK,EAAEA,KAAK,CAAC6B,KALf;IAME,MAAM,EAAElC,aAAa,EANvB;IAOE,SAAS,EAAE0B,OAAO,IAAID,aAAa,CAACC,OAAD,CAPrC;IAQE,KAAK,EAAEhB,WART;IASE,YAAY,EAAE;EAThB,EADF,CADF;AAeD,CApDM"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { WebComponentType } from '../../webComponent/WebComponent';
|
|
2
2
|
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
3
|
-
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
4
3
|
export const getCardParams = props => {
|
|
5
4
|
return `
|
|
6
5
|
card-id="${props.cardId}"
|
|
7
6
|
customer-token="${props.customerToken}"
|
|
8
|
-
theme="${props.theme ?? UnitSDK.getTheme()}"
|
|
9
7
|
`;
|
|
10
8
|
};
|
|
11
9
|
export const getCardScript = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebComponentType","UnitMessage","
|
|
1
|
+
{"version":3,"names":["WebComponentType","UnitMessage","getCardParams","props","cardId","customerToken","getCardScript","UNIT_REQUEST_REFRESH","injectRefreshEventIfNeeded","currentWeb","requestRefreshEvent","dependencies","includes","card","valueOf","resourceId","injectJavaScript","JSON","stringify"],"sources":["UNCardComponent.utils.ts"],"sourcesContent":["import type WebView from 'react-native-webview';\nimport type { UNCardComponentProps } from './UNCardComponent';\nimport { WebComponentType } from '../../webComponent/WebComponent';\nimport { RequestRefreshEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\n\nexport const getCardParams = (props: UNCardComponentProps) => {\n return `\n card-id=\"${props.cardId}\"\n customer-token=\"${props.customerToken}\"\n `;\n};\n\nexport const getCardScript = () => {\n return `\n const dispatchRefreshEvent = (details) => {\n const event = new CustomEvent(\"${UnitMessage.UNIT_REQUEST_REFRESH}\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n `;\n};\n\nexport const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null, cardId: string) => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.card.valueOf()) && requestRefreshEvent.resourceId == cardId) {\n currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);\n }\n};\n"],"mappings":"AAEA,SAASA,gBAAT,QAAiC,iCAAjC;AACA,SAA8BC,WAA9B,QAAiD,yCAAjD;AAEA,OAAO,MAAMC,aAAa,GAAIC,KAAD,IAAiC;EAC5D,OAAQ;AACV,eAAeA,KAAK,CAACC,MAAO;AAC5B,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,GAHE;AAID,CALM;AAOP,OAAO,MAAMC,aAAa,GAAG,MAAM;EACjC,OAAQ;AACV;AACA,qCAAqCL,WAAW,CAACM,oBAAqB;AACtE;AACA;AACA,GALE;AAMD,CAPM;AASP,OAAO,MAAMC,0BAA0B,GAAG,CAACC,UAAD,EAA6BC,mBAA7B,EAA8EN,MAA9E,KAAiG;EACzI,IAAIM,mBAAmB,IAAIA,mBAAmB,CAACC,YAApB,CAAiCC,QAAjC,CAA0CZ,gBAAgB,CAACa,IAAjB,CAAsBC,OAAtB,EAA1C,CAAvB,IAAqGJ,mBAAmB,CAACK,UAApB,IAAkCX,MAA3I,EAAmJ;IACjJK,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEO,gBAAZ,CAA8B,yBAAwBC,IAAI,CAACC,SAAL,CAAeR,mBAAf,CAAoC,IAA1F;EACD;AACF,CAJM"}
|