react-native-unit-components 0.1.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/README.md +157 -2
- 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/assets/images/close.png +0 -0
- package/lib/commonjs/assets/images/index.js +16 -0
- package/lib/commonjs/assets/images/index.js.map +1 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +28 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +20 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +39 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +40 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +9 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +195 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +23 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +49 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -0
- package/lib/commonjs/components/{Card/CardComponent.js → UNCardComponent/UNCardComponent.js} +42 -46
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +42 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -0
- package/lib/commonjs/components/index.js +34 -8
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/custom.d.js +2 -0
- package/lib/commonjs/custom.d.js.map +1 -0
- package/lib/commonjs/helpers/{BottomSheet.js → BottomSheet/BottomSheet.js} +38 -83
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -0
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +82 -0
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -0
- package/lib/commonjs/helpers/EventBus.js +5 -13
- package/lib/commonjs/helpers/EventBus.js.map +1 -1
- package/lib/commonjs/hooks/listenerToBus.js +31 -0
- package/lib/commonjs/hooks/listenerToBus.js.map +1 -0
- package/lib/commonjs/hooks/useAppStateListener.js +34 -0
- package/lib/commonjs/hooks/useAppStateListener.js.map +1 -0
- package/lib/commonjs/index.js +33 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/index.js +13 -0
- package/lib/commonjs/messages/nativeMessages/index.js.map +1 -0
- package/lib/commonjs/messages/webMessages/bookPaymentMessage.js +13 -0
- package/lib/commonjs/messages/webMessages/bookPaymentMessage.js.map +1 -0
- package/lib/commonjs/{webComponent → messages}/webMessages/cardMessage.js +1 -1
- package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/index.js +6 -0
- package/lib/commonjs/messages/webMessages/index.js.map +1 -0
- package/lib/commonjs/{webComponent → messages}/webMessages/pageMessage.js +0 -0
- package/lib/commonjs/messages/webMessages/pageMessage.js.map +1 -0
- package/lib/commonjs/{webComponent → messages}/webMessages/unitMessages.js +0 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -0
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js +13 -0
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyHtml.js +52 -0
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyScript.js +78 -0
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -0
- package/lib/commonjs/sharedTypes/bookPayment.types.js +6 -0
- package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/card.types.js +6 -0
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/index.js +32 -0
- package/lib/commonjs/sharedTypes/index.js.map +1 -0
- package/lib/commonjs/sharedTypes/types.js +2 -0
- package/lib/commonjs/sharedTypes/types.js.map +1 -0
- package/lib/commonjs/styles/variables.js +17 -0
- package/lib/commonjs/styles/variables.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js +54 -0
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +51 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -0
- package/lib/commonjs/webComponent/WebComponent.js +47 -15
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/html.js +22 -45
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/assets/images/close.png +0 -0
- package/lib/module/assets/images/index.js +2 -0
- package/lib/module/assets/images/index.js.map +1 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +13 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +23 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +26 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +2 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +163 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +13 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +29 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js +65 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +24 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -0
- package/lib/module/components/index.js +4 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/custom.d.js +2 -0
- package/lib/module/custom.d.js.map +1 -0
- package/lib/module/helpers/{BottomSheet.js → BottomSheet/BottomSheet.js} +36 -82
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -0
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +70 -0
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -0
- package/lib/module/helpers/EventBus.js +4 -11
- package/lib/module/helpers/EventBus.js.map +1 -1
- package/lib/module/hooks/listenerToBus.js +18 -0
- package/lib/module/hooks/listenerToBus.js.map +1 -0
- package/lib/module/hooks/useAppStateListener.js +23 -0
- package/lib/module/hooks/useAppStateListener.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/messages/nativeMessages/index.js +6 -0
- package/lib/module/messages/nativeMessages/index.js.map +1 -0
- package/lib/module/messages/webMessages/bookPaymentMessage.js +6 -0
- package/lib/module/messages/webMessages/bookPaymentMessage.js.map +1 -0
- package/lib/module/messages/webMessages/cardMessage.js +6 -0
- package/lib/module/messages/webMessages/cardMessage.js.map +1 -0
- package/lib/module/messages/webMessages/index.js +2 -0
- package/lib/module/messages/webMessages/index.js.map +1 -0
- package/lib/module/{webComponent → messages}/webMessages/pageMessage.js +0 -0
- package/lib/module/messages/webMessages/pageMessage.js.map +1 -0
- package/lib/module/{webComponent → messages}/webMessages/unitMessages.js +0 -0
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -0
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js +4 -0
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +1 -0
- package/lib/module/scripts/html/bodyHtml.js +42 -0
- package/lib/module/scripts/html/bodyHtml.js.map +1 -0
- package/lib/module/scripts/html/bodyScript.js +64 -0
- package/lib/module/scripts/html/bodyScript.js.map +1 -0
- package/lib/module/sharedTypes/bookPayment.types.js +2 -0
- package/lib/module/sharedTypes/bookPayment.types.js.map +1 -0
- package/lib/module/sharedTypes/card.types.js +2 -0
- package/lib/module/sharedTypes/card.types.js.map +1 -0
- package/lib/module/sharedTypes/index.js +3 -0
- package/lib/module/sharedTypes/index.js.map +1 -0
- package/lib/module/sharedTypes/types.js +2 -0
- package/lib/module/sharedTypes/types.js.map +1 -0
- package/lib/module/styles/variables.js +10 -0
- package/lib/module/styles/variables.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdk.api.js +37 -0
- package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js +38 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -0
- package/lib/module/webComponent/WebComponent.js +46 -14
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/html.js +18 -44
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/assets/images/index.d.ts +1 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +6 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +2 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +11 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.d.ts +3 -0
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -0
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +7 -0
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.d.ts +9 -0
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +5 -0
- package/lib/typescript/components/{Card/CardComponent.d.ts → UNCardComponent/UNCardComponent.d.ts} +3 -1
- package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +6 -0
- package/lib/typescript/components/index.d.ts +4 -2
- package/lib/typescript/helpers/{BottomSheet.d.ts → BottomSheet/BottomSheet.d.ts} +3 -0
- package/lib/typescript/helpers/BottomSheet/BottomSheet.styles.d.ts +63 -0
- package/lib/typescript/helpers/EventBus.d.ts +5 -7
- package/lib/typescript/hooks/listenerToBus.d.ts +7 -0
- package/lib/typescript/hooks/useAppStateListener.d.ts +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/messages/nativeMessages/index.d.ts +3 -0
- package/lib/typescript/messages/webMessages/bookPaymentMessage.d.ts +8 -0
- package/lib/typescript/{webComponent → messages}/webMessages/cardMessage.d.ts +3 -2
- package/lib/typescript/messages/webMessages/index.d.ts +11 -0
- package/lib/typescript/{webComponent → messages}/webMessages/pageMessage.d.ts +0 -0
- package/lib/typescript/{webComponent → messages}/webMessages/unitMessages.d.ts +0 -0
- package/lib/typescript/nativeComponent/UNNativeAddToWalletButton.d.ts +6 -0
- package/lib/typescript/scripts/html/bodyHtml.d.ts +7 -0
- package/lib/typescript/scripts/html/bodyScript.d.ts +11 -0
- package/lib/typescript/sharedTypes/bookPayment.types.d.ts +26 -0
- package/lib/typescript/sharedTypes/card.types.d.ts +56 -0
- package/lib/typescript/sharedTypes/index.d.ts +2 -0
- package/lib/typescript/sharedTypes/types.d.ts +27 -0
- package/lib/typescript/styles/variables.d.ts +9 -0
- package/lib/typescript/unitSdkManager/UnitSdk.api.d.ts +3 -0
- package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +15 -0
- package/lib/typescript/webComponent/WebComponent.d.ts +9 -11
- package/lib/typescript/webComponent/html.d.ts +6 -1
- package/package.json +9 -5
- package/{unit-react-native-components.podspec → react-native-unit-components.podspec} +1 -1
- package/src/assets/images/close.png +0 -0
- package/src/assets/images/index.ts +1 -0
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +21 -0
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +11 -0
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +37 -0
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +29 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.ts +13 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +167 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +34 -0
- package/src/components/UNCardComponent/UNCardComponent.tsx +73 -0
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +28 -0
- package/src/components/index.ts +4 -2
- package/src/custom.d.ts +5 -0
- package/src/helpers/BottomSheet/BottomSheet.styles.ts +70 -0
- package/src/helpers/{BottomSheet.tsx → BottomSheet/BottomSheet.tsx} +74 -110
- package/src/helpers/EventBus.ts +13 -13
- package/src/hooks/listenerToBus.ts +23 -0
- package/src/hooks/useAppStateListener.ts +25 -0
- package/src/index.tsx +5 -1
- package/src/messages/nativeMessages/index.ts +3 -0
- package/src/messages/webMessages/bookPaymentMessage.ts +12 -0
- package/src/{webComponent → messages}/webMessages/cardMessage.ts +4 -2
- package/src/messages/webMessages/index.ts +21 -0
- package/src/{webComponent → messages}/webMessages/pageMessage.ts +1 -1
- package/src/{webComponent → messages}/webMessages/unitMessages.ts +1 -0
- package/src/nativeComponent/UNNativeAddToWalletButton.tsx +12 -0
- package/src/scripts/html/bodyHtml.ts +46 -0
- package/src/scripts/html/bodyScript.ts +67 -0
- package/src/sharedTypes/bookPayment.types.ts +27 -0
- package/src/sharedTypes/card.types.ts +59 -0
- package/src/sharedTypes/index.ts +2 -0
- package/src/sharedTypes/types.ts +35 -0
- package/src/styles/variables.ts +9 -0
- package/src/unitSdkManager/UnitSdk.api.ts +31 -0
- package/src/unitSdkManager/UnitSdkManager.ts +33 -0
- package/src/webComponent/WebComponent.tsx +55 -45
- package/src/webComponent/html.ts +22 -46
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsViewManager.kt +0 -19
- package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js +0 -143
- package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js.map +0 -1
- package/lib/commonjs/components/Card/CardComponent.js.map +0 -1
- package/lib/commonjs/helpers/BottomSheet.js.map +0 -1
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js +0 -19
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js.map +0 -1
- package/lib/commonjs/webComponent/webMessages/cardMessage.js.map +0 -1
- package/lib/commonjs/webComponent/webMessages/pageMessage.js.map +0 -1
- package/lib/commonjs/webComponent/webMessages/unitMessages.js.map +0 -1
- package/lib/module/components/BottomSheet/BottomSheetComponent.js +0 -118
- package/lib/module/components/BottomSheet/BottomSheetComponent.js.map +0 -1
- package/lib/module/components/Card/CardComponent.js +0 -75
- package/lib/module/components/Card/CardComponent.js.map +0 -1
- package/lib/module/helpers/BottomSheet.js.map +0 -1
- package/lib/module/nativeComponenet/NativeComponentExample.js +0 -10
- package/lib/module/nativeComponenet/NativeComponentExample.js.map +0 -1
- package/lib/module/webComponent/webMessages/cardMessage.js +0 -6
- package/lib/module/webComponent/webMessages/cardMessage.js.map +0 -1
- package/lib/module/webComponent/webMessages/pageMessage.js.map +0 -1
- package/lib/module/webComponent/webMessages/unitMessages.js.map +0 -1
- package/lib/typescript/components/BottomSheet/BottomSheetComponent.d.ts +0 -1
- package/lib/typescript/nativeComponenet/NativeComponentExample.d.ts +0 -7
- package/src/components/BottomSheet/BottomSheetComponent.tsx +0 -113
- package/src/components/Card/CardComponent.tsx +0 -75
- package/src/nativeComponenet/NativeComponentExample.tsx +0 -26
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","ComponentName","UnitReactNativeComponentsView","UIManager","getViewManagerConfig","requireNativeComponent","Error"],"sources":["NativeComponentExample.tsx"],"sourcesContent":["import {\n requireNativeComponent,\n UIManager,\n Platform,\n ViewStyle,\n} from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'unit-react-native-components' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype UnitReactNativeComponentsProps = {\n color: string;\n style: ViewStyle;\n};\n\nconst ComponentName = 'UnitReactNativeComponentsView';\n\nexport const UnitReactNativeComponentsView =\n UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<UnitReactNativeComponentsProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n"],"mappings":";;;;;;;AAAA;;AAOA,MAAMA,aAAa,GAChB,uFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAWA,MAAMC,aAAa,GAAG,+BAAtB;AAEO,MAAMC,6BAA6B,GACxCC,sBAAA,CAAUC,oBAAV,CAA+BH,aAA/B,KAAiD,IAAjD,GACI,IAAAI,mCAAA,EAAuDJ,aAAvD,CADJ,GAEI,MAAM;EACN,MAAM,IAAIK,KAAJ,CAAUV,aAAV,CAAN;AACD,CALE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CardMessage"],"sources":["cardMessage.ts"],"sourcesContent":["export enum CardMessage {\n CARD_STATUS_CHANGE = 'cardStatusChanged'\n}\n\nexport interface CardStatusChangedEvent {\n card: any;\n}\n\nexport type CardEvent =\n | CardStatusChangedEvent\n"],"mappings":";;;;;;IAAYA,W;;;WAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["UnitMessage"],"sources":["unitMessages.ts"],"sourcesContent":["export enum UnitMessage {\n UNIT_REQUEST_RENDERING = 'unitRequestRendering',\n UNIT_REQUEST_REFRESH = 'unitRequestRefresh',\n UNIT_REQUEST_CLOSE_FLOW = 'unitRequestCloseFlow',\n UNIT_REQUEST_OPEN_LINK = 'unitRequestOpenLink',\n UNIT_ON_LOAD = 'unitOnLoad'\n}\n\nexport interface RequestRenderingData {\n nativePlace: string;\n nativeComponent: string;\n}\nexport interface RequestRenderingEvent {\n data: string;\n}\n\nexport interface RequestRefreshEvent {\n refEvent: string;\n dependencies: string[];\n resourceId: string;\n}\n\nexport interface RequestOpenLinkEvent {\n href: string;\n target: string\n}\n\nexport type UnitEvent =\n | RequestRenderingEvent\n | RequestRefreshEvent\n | RequestOpenLinkEvent\n"],"mappings":";;;;;;IAAYA,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { WebComponent, WebComponentType } from "../../webComponent/WebComponent";
|
|
3
|
-
import { Dimensions, Linking, View } from "react-native";
|
|
4
|
-
import BottomSheet from "../../helpers/BottomSheet";
|
|
5
|
-
import EventBus, { BusEvent } from "../../helpers/EventBus";
|
|
6
|
-
import { PageMessage } from "../../webComponent/webMessages/pageMessage";
|
|
7
|
-
import { UnitMessage } from "../../webComponent/webMessages/unitMessages";
|
|
8
|
-
import { CardMessage } from "../../webComponent/webMessages/cardMessage";
|
|
9
|
-
export const UNBottomSheetComponent = () => {
|
|
10
|
-
const [isActive, setIsActive] = useState(false);
|
|
11
|
-
const [height, setHeight] = useState(0);
|
|
12
|
-
const [renderingRequest, setRenderingRequest] = useState(null);
|
|
13
|
-
const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);
|
|
14
|
-
const [newHeightMessage, setNewHeightMessage] = useState(null);
|
|
15
|
-
const webRef = useRef(null);
|
|
16
|
-
|
|
17
|
-
const _listener = data => {
|
|
18
|
-
setRenderingRequest(data);
|
|
19
|
-
setIsActive(true);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (!webRef.current) return;
|
|
24
|
-
|
|
25
|
-
if (renderingRequest) {
|
|
26
|
-
var _webRef$current;
|
|
27
|
-
|
|
28
|
-
(_webRef$current = webRef.current) === null || _webRef$current === void 0 ? void 0 : _webRef$current.injectJavaScript(`dispatchRenderingEvent('${renderingRequest}')`);
|
|
29
|
-
}
|
|
30
|
-
}, [webRef.current, renderingRequest]);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (!isActive) {
|
|
33
|
-
setHeight(0);
|
|
34
|
-
setRenderingRequest(null);
|
|
35
|
-
}
|
|
36
|
-
}, [isActive]);
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (!waitForLoadingNewComponent && newHeightMessage) {
|
|
39
|
-
setWaitForLoadingNewComponent(false);
|
|
40
|
-
setNewHeight(newHeightMessage);
|
|
41
|
-
}
|
|
42
|
-
}, [waitForLoadingNewComponent, newHeightMessage]);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
EventBus.Instance.addListener(BusEvent.REQUEST_RENDERING, _listener);
|
|
45
|
-
return () => {
|
|
46
|
-
EventBus.Instance.removeListener(_listener);
|
|
47
|
-
};
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
const getBottomSheetScript = () => {
|
|
51
|
-
return `
|
|
52
|
-
window.addEventListener("unitRequestRefresh", (e) => {
|
|
53
|
-
postMessageToSDK({ type: "unitRequestRefresh", details: e.detail })
|
|
54
|
-
});
|
|
55
|
-
`;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const setNewHeight = message => {
|
|
59
|
-
if (renderingRequest) {
|
|
60
|
-
const nativePlace = JSON.parse(renderingRequest).nativePlace;
|
|
61
|
-
|
|
62
|
-
if (nativePlace == 'overFullScreen') {
|
|
63
|
-
const windowHeight = Dimensions.get('window').height * 0.94;
|
|
64
|
-
setHeight(windowHeight);
|
|
65
|
-
} else {
|
|
66
|
-
setHeight(message.details.height);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
72
|
-
pointerEvents: isActive ? undefined : 'none',
|
|
73
|
-
style: {
|
|
74
|
-
position: 'absolute',
|
|
75
|
-
top: 0,
|
|
76
|
-
bottom: 0,
|
|
77
|
-
left: 0,
|
|
78
|
-
right: 0
|
|
79
|
-
}
|
|
80
|
-
}, /*#__PURE__*/React.createElement(BottomSheet, {
|
|
81
|
-
isOpen: isActive,
|
|
82
|
-
onClose: () => setIsActive(false),
|
|
83
|
-
onOpen: () => setIsActive(true)
|
|
84
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
85
|
-
style: {
|
|
86
|
-
height,
|
|
87
|
-
paddingTop: height === 0 ? 0 : 10
|
|
88
|
-
}
|
|
89
|
-
}, /*#__PURE__*/React.createElement(WebComponent, {
|
|
90
|
-
ref: webRef,
|
|
91
|
-
type: WebComponentType.slot,
|
|
92
|
-
script: getBottomSheetScript(),
|
|
93
|
-
onMessage: message => {
|
|
94
|
-
if (renderingRequest && message.type == PageMessage.PAGE_HEIGHT) {
|
|
95
|
-
setNewHeightMessage(message);
|
|
96
|
-
} else if (message.type == UnitMessage.UNIT_REQUEST_RENDERING) {
|
|
97
|
-
const {
|
|
98
|
-
data
|
|
99
|
-
} = message.details;
|
|
100
|
-
|
|
101
|
-
if (data != renderingRequest) {
|
|
102
|
-
setHeight(0);
|
|
103
|
-
setRenderingRequest(data);
|
|
104
|
-
setWaitForLoadingNewComponent(true);
|
|
105
|
-
setTimeout(() => setWaitForLoadingNewComponent(false), 400);
|
|
106
|
-
}
|
|
107
|
-
} else if (message.type == CardMessage.CARD_STATUS_CHANGE) {
|
|
108
|
-
EventBus.Instance.event(BusEvent.CARD_STATUS_CHANGED, message.details.card);
|
|
109
|
-
} else if (message.type == UnitMessage.UNIT_REQUEST_CLOSE_FLOW) {
|
|
110
|
-
setIsActive(false);
|
|
111
|
-
} else if (message.type == UnitMessage.UNIT_REQUEST_OPEN_LINK) {
|
|
112
|
-
const href = message.details.href;
|
|
113
|
-
Linking.openURL(href);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
})))));
|
|
117
|
-
};
|
|
118
|
-
//# sourceMappingURL=BottomSheetComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","WebComponent","WebComponentType","Dimensions","Linking","View","BottomSheet","EventBus","BusEvent","PageMessage","UnitMessage","CardMessage","UNBottomSheetComponent","isActive","setIsActive","height","setHeight","renderingRequest","setRenderingRequest","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","webRef","_listener","data","current","injectJavaScript","setNewHeight","Instance","addListener","REQUEST_RENDERING","removeListener","getBottomSheetScript","message","nativePlace","JSON","parse","windowHeight","get","details","undefined","position","top","bottom","left","right","paddingTop","slot","type","PAGE_HEIGHT","UNIT_REQUEST_RENDERING","setTimeout","CARD_STATUS_CHANGE","event","CARD_STATUS_CHANGED","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","openURL"],"sources":["BottomSheetComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\"\nimport type WebView from \"react-native-webview\"\nimport { WebComponent, WebComponentType, WebViewMessage } from \"../../webComponent/WebComponent\"\nimport { Dimensions, Linking, View } from \"react-native\"\nimport BottomSheet from \"../../helpers/BottomSheet\"\nimport EventBus, { BusEvent } from \"../../helpers/EventBus\"\nimport { HeightEvent, PageMessage } from \"../../webComponent/webMessages/pageMessage\"\nimport { RequestOpenLinkEvent, RequestRenderingData, RequestRenderingEvent, UnitMessage } from \"../../webComponent/webMessages/unitMessages\"\nimport { CardMessage, CardStatusChangedEvent } from \"../../webComponent/webMessages/cardMessage\"\n\nexport const UNBottomSheetComponent = () => {\n const [isActive, setIsActive] = useState(false)\n const [height, setHeight] = useState(0)\n\n const [renderingRequest, setRenderingRequest] = useState<string | null>(null)\n\n const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false)\n const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null)\n\n const webRef = useRef<WebView>(null)\n\n const _listener = (data: string) => {\n setRenderingRequest(data)\n setIsActive(true)\n }\n\n useEffect(() => {\n if (!webRef.current) return\n if (renderingRequest) {\n webRef.current?.injectJavaScript(`dispatchRenderingEvent('${renderingRequest}')`)\n }\n }, [webRef.current, renderingRequest])\n\n useEffect(() => {\n if (!isActive) {\n setHeight(0)\n setRenderingRequest(null)\n }\n }, [isActive])\n\n useEffect(() => {\n if (!waitForLoadingNewComponent && newHeightMessage) {\n setWaitForLoadingNewComponent(false)\n setNewHeight(newHeightMessage)\n }\n }, [waitForLoadingNewComponent, newHeightMessage])\n\n useEffect(() => {\n EventBus.Instance.addListener(BusEvent.REQUEST_RENDERING, _listener)\n\n return (() => {\n EventBus.Instance.removeListener(_listener)\n })\n }, [])\n\n const getBottomSheetScript = () => {\n return `\n window.addEventListener(\"unitRequestRefresh\", (e) => {\n postMessageToSDK({ type: \"unitRequestRefresh\", details: e.detail })\n });\n `\n }\n\n const setNewHeight = (message: WebViewMessage) => {\n if (renderingRequest) {\n const nativePlace = (JSON.parse(renderingRequest) as RequestRenderingData).nativePlace;\n if (nativePlace == 'overFullScreen') {\n const windowHeight = Dimensions.get('window').height * 0.94;\n setHeight(windowHeight)\n } else {\n setHeight((message.details as HeightEvent).height)\n }\n }\n }\n\n return (\n <>\n <View\n pointerEvents={isActive ? undefined : 'none'}\n style={{ position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }}\n >\n <BottomSheet\n isOpen={isActive}\n onClose={() => setIsActive(false)}\n onOpen={() => setIsActive(true)}\n >\n <View style={{ height, paddingTop: height === 0 ? 0 : 10 }}>\n <WebComponent ref={webRef} type={WebComponentType.slot} script={getBottomSheetScript()} onMessage={message => {\n if (renderingRequest && message.type == PageMessage.PAGE_HEIGHT) {\n setNewHeightMessage(message)\n } else if (message.type == UnitMessage.UNIT_REQUEST_RENDERING) {\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 } else if (message.type == CardMessage.CARD_STATUS_CHANGE) {\n EventBus.Instance.event(BusEvent.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card)\n } else if (message.type == UnitMessage.UNIT_REQUEST_CLOSE_FLOW) {\n setIsActive(false)\n } else if (message.type == UnitMessage.UNIT_REQUEST_OPEN_LINK) {\n const href = (message.details as RequestOpenLinkEvent).href\n Linking.openURL(href)\n }\n }} />\n </View>\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+D,iCAA/D;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,IAA9B,QAA0C,cAA1C;AACA,OAAOC,WAAP,MAAwB,2BAAxB;AACA,OAAOC,QAAP,IAAmBC,QAAnB,QAAmC,wBAAnC;AACA,SAAsBC,WAAtB,QAAyC,4CAAzC;AACA,SAA4EC,WAA5E,QAA+F,6CAA/F;AACA,SAASC,WAAT,QAAoD,4CAApD;AAEA,OAAO,MAAMC,sBAAsB,GAAG,MAAM;EAC1C,MAAM,CAACC,QAAD,EAAWC,WAAX,IAA0Bd,QAAQ,CAAC,KAAD,CAAxC;EACA,MAAM,CAACe,MAAD,EAASC,SAAT,IAAsBhB,QAAQ,CAAC,CAAD,CAApC;EAEA,MAAM,CAACiB,gBAAD,EAAmBC,mBAAnB,IAA0ClB,QAAQ,CAAgB,IAAhB,CAAxD;EAEA,MAAM,CAACmB,0BAAD,EAA6BC,6BAA7B,IAA8DpB,QAAQ,CAAC,KAAD,CAA5E;EACA,MAAM,CAACqB,gBAAD,EAAmBC,mBAAnB,IAA0CtB,QAAQ,CAAwB,IAAxB,CAAxD;EAEA,MAAMuB,MAAM,GAAGxB,MAAM,CAAU,IAAV,CAArB;;EAEA,MAAMyB,SAAS,GAAIC,IAAD,IAAkB;IAClCP,mBAAmB,CAACO,IAAD,CAAnB;IACAX,WAAW,CAAC,IA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A7B;UACAgC,UAAU,CAAC,MAAMhC,6BAA6B,CAAC,KAAD,CAApC,EAA6C,GAA7C,CAAV;QACD;MACF,CARM,MAQA,IAAIc,OAAO,CAACe,IAAR,IAAgBtC,WAAW,CAAC0C,kBAAhC,EAAoD;QACzD9C,QAAQ,CAACsB,QAAT,CAAkByB,KAAlB,CAAwB9C,QAAQ,CAAC+C,mBAAjC,EAAuDrB,OAAO,CAACM,OAAT,CAA4CgB,IAAlG;MACD,CAFM,MAEA,IAAItB,OAAO,CAACe,IAAR,IAAgBvC,WAAW,CAAC+C,uBAAhC,EAAyD;QAC9D3C,WAAW,CAAC,KAAD,CAAX;MACD,CAFM,MAEA,IAAIoB,OAAO,CAACe,IAAR,IAAgBvC,WAAW,CAACgD,sBAAhC,EAAwD;QAC7D,MAAMC,IAAI,GAAIzB,OAAO,CAACM,OAAT,CAA0CmB,IAAvD;QACAvD,OAAO,CAACwD,OAAR,CAAgBD,IAAhB;MACD;IACF;EAnBD,EADF,CALF,CAJF,CADF,CADF;AAqCD,CAtGM"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
import { PageMessage } from "../../webComponent/webMessages/pageMessage";
|
|
4
|
-
import { UnitMessage } from "../../webComponent/webMessages/unitMessages";
|
|
5
|
-
import EventBus, { BusEvent } from "../../helpers/EventBus";
|
|
6
|
-
import { WebComponent, WebComponentType } from "../../webComponent/WebComponent";
|
|
7
|
-
export const UNCardComponent = props => {
|
|
8
|
-
const [height, setHeight] = useState(0);
|
|
9
|
-
const [requestRefreshEvent, setRequestRefreshEvent] = useState(null);
|
|
10
|
-
const webRef = useRef(null);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
EventBus.Instance.addListener(BusEvent.CARD_STATUS_CHANGED, _cardStatusChanged);
|
|
13
|
-
EventBus.Instance.addListener(BusEvent.REQUEST_REFRESH, _requestRefresh);
|
|
14
|
-
return () => {
|
|
15
|
-
EventBus.Instance.removeListener(_cardStatusChanged);
|
|
16
|
-
EventBus.Instance.removeListener(_requestRefresh);
|
|
17
|
-
};
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
|
-
const _cardStatusChanged = card => {
|
|
21
|
-
if (props.onStatusChanged) {
|
|
22
|
-
props.onStatusChanged(card);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const _requestRefresh = data => {
|
|
27
|
-
setRequestRefreshEvent(data);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.card.valueOf()) && requestRefreshEvent.resourceId == props.cardId) {
|
|
32
|
-
var _webRef$current;
|
|
33
|
-
|
|
34
|
-
(_webRef$current = webRef.current) === null || _webRef$current === void 0 ? void 0 : _webRef$current.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
|
|
35
|
-
}
|
|
36
|
-
}, [requestRefreshEvent]);
|
|
37
|
-
|
|
38
|
-
const getCardParams = () => {
|
|
39
|
-
return `
|
|
40
|
-
cardId="${props.cardId}"
|
|
41
|
-
customerToken="${props.customerToken}"
|
|
42
|
-
src="https://d1xlopvhx2cz8k.cloudfront.net/resources/outlay.json"
|
|
43
|
-
`;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const getCardScript = () => {
|
|
47
|
-
return `
|
|
48
|
-
const dispatchRefreshEvent = (details) => {
|
|
49
|
-
const event = new CustomEvent("unitRequestRefresh",{ detail: JSON.parse(details) })
|
|
50
|
-
window.dispatchEvent(event)
|
|
51
|
-
}
|
|
52
|
-
`;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
56
|
-
style: {
|
|
57
|
-
height
|
|
58
|
-
}
|
|
59
|
-
}, /*#__PURE__*/React.createElement(WebComponent, {
|
|
60
|
-
ref: webRef,
|
|
61
|
-
type: WebComponentType.card,
|
|
62
|
-
params: getCardParams(),
|
|
63
|
-
script: getCardScript(),
|
|
64
|
-
onMessage: message => {
|
|
65
|
-
if (message.type === UnitMessage.UNIT_REQUEST_RENDERING) {
|
|
66
|
-
EventBus.Instance.event(BusEvent.REQUEST_RENDERING, message.details.data);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (message.type == PageMessage.PAGE_HEIGHT) {
|
|
70
|
-
setHeight(message.details.height);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}));
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=CardComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","View","PageMessage","UnitMessage","EventBus","BusEvent","WebComponent","WebComponentType","UNCardComponent","props","height","setHeight","requestRefreshEvent","setRequestRefreshEvent","webRef","Instance","addListener","CARD_STATUS_CHANGED","_cardStatusChanged","REQUEST_REFRESH","_requestRefresh","removeListener","card","onStatusChanged","data","dependencies","includes","valueOf","resourceId","cardId","current","injectJavaScript","JSON","stringify","getCardParams","customerToken","getCardScript","message","type","UNIT_REQUEST_RENDERING","event","REQUEST_RENDERING","details","PAGE_HEIGHT"],"sources":["CardComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\"\nimport { View } from \"react-native\";\nimport type WebView from \"react-native-webview\";\nimport { HeightEvent, PageMessage } from \"../../webComponent/webMessages/pageMessage\";\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from \"../../webComponent/webMessages/unitMessages\";\nimport EventBus, { BusEvent } from \"../../helpers/EventBus\"\nimport { WebComponent, WebComponentType } from \"../../webComponent/WebComponent\"\n\nexport interface UNCardComponentProps {\n cardId: string;\n customerToken: string;\n onStatusChanged?: (card: any) => void; // TODO - UNCard\n}\n\nexport const UNCardComponent = (props: UNCardComponentProps) => {\n const [height, setHeight] = useState(0)\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null)\n\n const webRef = useRef<WebView>(null)\n\n useEffect(() => {\n EventBus.Instance.addListener(BusEvent.CARD_STATUS_CHANGED, _cardStatusChanged)\n EventBus.Instance.addListener(BusEvent.REQUEST_REFRESH, _requestRefresh)\n return (() => {\n EventBus.Instance.removeListener(_cardStatusChanged)\n EventBus.Instance.removeListener(_requestRefresh)\n })\n }, [])\n\n const _cardStatusChanged = (card: any) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card)\n }\n }\n\n const _requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data)\n }\n\n useEffect(() => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.card.valueOf()) && requestRefreshEvent.resourceId == props.cardId) {\n webRef.current?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`)\n }\n }, [requestRefreshEvent])\n\n const getCardParams = () => {\n return `\n cardId=\"${props.cardId}\"\n customerToken=\"${props.customerToken}\"\n src=\"https://d1xlopvhx2cz8k.cloudfront.net/resources/outlay.json\"\n `\n }\n\n const getCardScript = () => {\n return `\n const dispatchRefreshEvent = (details) => {\n const event = new CustomEvent(\"unitRequestRefresh\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n `\n }\n\n return (\n <View style={{ height }}>\n <WebComponent ref={webRef} type={WebComponentType.card} params={getCardParams()} script={getCardScript()} onMessage={message => {\n if (message.type === UnitMessage.UNIT_REQUEST_RENDERING) {\n EventBus.Instance.event(BusEvent.REQUEST_RENDERING, (message.details as RequestRenderingEvent).data)\n }\n if (message.type == PageMessage.PAGE_HEIGHT) {\n setHeight((message.details as HeightEvent).height)\n }\n }} />\n </View>\n )\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAAsBC,WAAtB,QAAyC,4CAAzC;AACA,SAAqDC,W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BAAhB,CAAkC,yBAAwBC,IAAI,CAACC,SAAL,CAAerB,mBAAf,CAAoC,IAA9F;IACD;EACF,CAJQ,EAIN,CAACA,mBAAD,CAJM,CAAT;;EAMA,MAAMsB,aAAa,GAAG,MAAM;IAC1B,OAAQ;AACZ,gBAAgBzB,KAAK,CAACoB,MAAO;AAC7B,uBAAuBpB,KAAK,CAAC0B,aAAc;AAC3C;AACA,KAJI;EAKD,CAND;;EAQA,MAAMC,aAAa,GAAG,MAAM;IAC1B,OAAQ;AACZ;AACA;AACA;AACA;AACA,KALI;EAMD,CAPD;;EASA,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAE1B;IAAF;EAAb,gBACE,oBAAC,YAAD;IAAc,GAAG,EAAEI,MAAnB;IAA2B,IAAI,EAAEP,gBAAgB,CAACe,IAAlD;IAAwD,MAAM,EAAEY,aAAa,EAA7E;IAAiF,MAAM,EAAEE,aAAa,EAAtG;IAA0G,SAAS,EAAEC,OAAO,IAAI;MAC9H,IAAIA,OAAO,CAACC,IAAR,KAAiBnC,WAAW,CAACoC,sBAAjC,EAAyD;QACvDnC,QAAQ,CAACW,QAAT,CAAkByB,KAAlB,CAAwBnC,QAAQ,CAACoC,iBAAjC,EAAqDJ,OAAO,CAACK,OAAT,CAA2ClB,IAA/F;MACD;;MACD,IAAIa,OAAO,CAACC,IAAR,IAAgBpC,WAAW,CAACyC,WAAhC,EAA6C;QAC3ChC,SAAS,CAAE0B,OAAO,CAACK,OAAT,CAAiChC,MAAlC,CAAT;MACD;IACF;EAPD,EADF,CADF;AAYD,CA5DM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","Animated","BackHandler","Dimensions","Easing","PanResponder","StyleSheet","TouchableOpacity","View","PropTypes","BottomSheet","props","panelHeightValue","Value","sliderMaxHeight","current","fadeAnim","isPanelOpened","setIsPanelOpened","isOpen","contentHeight","setContentHeight","undefined","currentHeight","setCurrentHeight","dy","setDy","_parentPanResponder","create","onMoveShouldSetPanResponderCapture","_","gestureState","Math","abs","onPanResponderMove","expandToMaxHeightEnabled","setValue","onPanResponderRelease","collapse","setToContentHeight","expand","fadeIn","_dismiss","addEventListener","_onBackPress","id","addListener","e","value","removeEventListener","removeListener","timing","toValue","duration","useNativeDriver","start","fadeOut","onClose","animationDuration","easing","quad","_setSize","newContentHeight","nativeEvent","layout","height","children","position","top","bottom","right","left","backgroundColor","flex","opacity","panHandlers","styles","container","transform","translateY","outerContent","lineContainer","line","innerContent","propTypes","oneOfType","node","bool","number","animation","func","onOpen","defaultProps","get","marginTop","paddingHorizontal","shadowColor","shadowOffset","width","shadowOpacity","shadowRadius","elevation","borderTopLeftRadius","borderTopRightRadius","alignItems","borderRadius"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState } from 'react';\nimport {\n Animated,\n BackHandler,\n Dimensions,\n Easing,\n // Keyboard,\n LayoutChangeEvent,\n PanResponder,\n StyleSheet,\n TouchableOpacity,\n View,\n} from 'react-native';\nimport PropTypes from 'prop-types';\n\nexport interface BottomSheetProps {\n isOpen: boolean\n children: ReactNode\n sliderMaxHeight: number\n onOpen: () => void\n onClose: () => void\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\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 Math.abs(gestureState.dy) > 10\n },\n onPanResponderMove(_, gestureState) {\n if (currentHeight + gestureState.dy < 0) return\n if (!props.expandToMaxHeightEnabled && 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 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 (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 (currentHeight > (sliderMaxHeight - contentHeight!)) {\n _dismiss()\n return\n }\n\n setToContentHeight(contentHeight!)\n\n // Animated.timing(panelHeightValue, {\n // duration: animationDuration,\n // easing: Easing.quad,\n // toValue: sliderMaxHeight - contentHeight!,\n // useNativeDriver: false,\n // }).start(() => {\n // const isPanelOpenedNewValue = !isPanelOpened\n // setIsPanelOpened(isPanelOpenedNewValue)\n // if (isPanelOpenedNewValue) {\n // // onOpen();\n // } else {\n // // onClose();\n // Keyboard.dismiss();\n // }\n // });\n };\n\n const _onBackPress = () => {\n isPanelOpened && collapse();\n return isPanelOpened;\n };\n\n const _setSize = (e: LayoutChangeEvent) => {\n let newContentHeight = e.nativeEvent.layout.height\n if (newContentHeight !== 0) newContentHeight += 42;\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 })\n fadeOut()\n }\n\n const {\n sliderMaxHeight,\n children,\n } = props;\n\n return (\n <>\n <TouchableOpacity\n style={{ position: 'absolute', top: 0, bottom: 0, right: 0, left: 0 }} activeOpacity={1}\n onPress={_dismiss}\n >\n <Animated.View\n style={{ backgroundColor: 'black', flex: 1, opacity: fadeAnim }}\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 activeOpacity={1}>\n <View style={styles.lineContainer}>\n <View style={styles.line} />\n </View>\n </TouchableOpacity>\n <View\n onLayout={_setSize}\n style={[styles.innerContent]}\n >\n {children}\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 * 0.95,\n animationDuration: 200,\n onOpen: () => null,\n onClose: () => null,\n expandToMaxHeightEnabled: false\n};\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n marginTop: 60,\n paddingHorizontal: 12,\n shadowColor: '#000000',\n shadowOffset: {\n width: 0,\n height: 6,\n },\n shadowOpacity: 0.37,\n shadowRadius: 7.49,\n elevation: 12,\n borderTopLeftRadius: 15,\n borderTopRightRadius: 15,\n backgroundColor: '#ffffff',\n },\n lineContainer: {\n borderTopLeftRadius: 30,\n borderTopRightRadius: 30,\n alignItems: 'center'\n },\n line: {\n width: 35,\n height: 4,\n borderRadius: 2,\n marginTop: 18,\n backgroundColor: '#D5DDE0',\n },\n outerContent: {\n flex: -1,\n },\n innerContent: {\n flex: -1,\n },\n});\n\nexport default BottomSheet;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAA2BC,SAA3B,EAAsCC,MAAtC,EAA8CC,QAA9C,QAA8D,OAA9D;AACA,SACEC,QADF,EAEEC,WAFF,EAGEC,UAHF,EAIEC,MAJF,EAOEC,YAPF,EAQEC,UARF,EASEC,gBATF,EAUEC,IAVF,QAWO,cAXP;AAYA,OAAOC,SAAP,MAAsB,YAAtB;;AAYA,MAAMC,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAMC,gBAAgB,GAAGb,MAAM,CAAC,IAAIE,QAAQ,CAACY,KAAb,CAAmBF,KAAK,CAACG,eAAzB,CAAD,CAAN,CAAkDC,OAA3E;EACA,MAAMC,QAAQ,GAAGjB,MAAM,CAAC,IAAIE,QAAQ,CAACY,KAAb,CAAmB,CAAnB,CAAD,CAAN,CAA8BE,OAA/C;EAEA,MAAM,CAACE,aAAD,EAAgBC,gBAAhB,IAAoClB,QAAQ,CAACW,KAAK,CAACQ,MAAP,CAAlD;EACA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoCrB,QAAQ,CAAqBsB,SAArB,CAAlD;EAEA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoCxB,QAAQ,C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EAAE,CAHV;IAIJX,SAAS,EAAE,EAJP;IAKJtB,eAAe,EAAE;EALb,CAtByB;EA6B/BQ,YAAY,EAAE;IACZP,IAAI,EAAE,CAAC;EADK,CA7BiB;EAgC/BU,YAAY,EAAE;IACZV,IAAI,EAAE,CAAC;EADK;AAhCiB,CAAlB,CAAf;AAqCA,eAAe/D,WAAf"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { requireNativeComponent, UIManager, Platform } from 'react-native';
|
|
2
|
-
const LINKING_ERROR = `The package 'unit-react-native-components' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
-
ios: "- You have run 'pod install'\n",
|
|
4
|
-
default: ''
|
|
5
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
6
|
-
const ComponentName = 'UnitReactNativeComponentsView';
|
|
7
|
-
export const UnitReactNativeComponentsView = UIManager.getViewManagerConfig(ComponentName) != null ? requireNativeComponent(ComponentName) : () => {
|
|
8
|
-
throw new Error(LINKING_ERROR);
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=NativeComponentExample.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["requireNativeComponent","UIManager","Platform","LINKING_ERROR","select","ios","default","ComponentName","UnitReactNativeComponentsView","getViewManagerConfig","Error"],"sources":["NativeComponentExample.tsx"],"sourcesContent":["import {\n requireNativeComponent,\n UIManager,\n Platform,\n ViewStyle,\n} from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'unit-react-native-components' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype UnitReactNativeComponentsProps = {\n color: string;\n style: ViewStyle;\n};\n\nconst ComponentName = 'UnitReactNativeComponentsView';\n\nexport const UnitReactNativeComponentsView =\n UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<UnitReactNativeComponentsProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n"],"mappings":"AAAA,SACEA,sBADF,EAEEC,SAFF,EAGEC,QAHF,QAKO,cALP;AAOA,MAAMC,aAAa,GAChB,uFAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAWA,MAAMC,aAAa,GAAG,+BAAtB;AAEA,OAAO,MAAMC,6BAA6B,GACxCP,SAAS,CAACQ,oBAAV,CAA+BF,aAA/B,KAAiD,IAAjD,GACIP,sBAAsB,CAAiCO,aAAjC,CAD1B,GAEI,MAAM;EACN,MAAM,IAAIG,KAAJ,CAAUP,aAAV,CAAN;AACD,CALE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CardMessage"],"sources":["cardMessage.ts"],"sourcesContent":["export enum CardMessage {\n CARD_STATUS_CHANGE = 'cardStatusChanged'\n}\n\nexport interface CardStatusChangedEvent {\n card: any;\n}\n\nexport type CardEvent =\n | CardStatusChangedEvent\n"],"mappings":"AAAA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W;GAAAA,W,KAAAA,W"}
|
|
@@ -1 +0,0 @@
|
|
|
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":"AAAA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["UnitMessage"],"sources":["unitMessages.ts"],"sourcesContent":["export enum UnitMessage {\n UNIT_REQUEST_RENDERING = 'unitRequestRendering',\n UNIT_REQUEST_REFRESH = 'unitRequestRefresh',\n UNIT_REQUEST_CLOSE_FLOW = 'unitRequestCloseFlow',\n UNIT_REQUEST_OPEN_LINK = 'unitRequestOpenLink',\n UNIT_ON_LOAD = 'unitOnLoad'\n}\n\nexport interface RequestRenderingData {\n nativePlace: string;\n nativeComponent: string;\n}\nexport interface RequestRenderingEvent {\n data: string;\n}\n\nexport interface RequestRefreshEvent {\n refEvent: string;\n dependencies: string[];\n resourceId: string;\n}\n\nexport interface RequestOpenLinkEvent {\n href: string;\n target: string\n}\n\nexport type UnitEvent =\n | RequestRenderingEvent\n | RequestRefreshEvent\n | RequestOpenLinkEvent\n"],"mappings":"AAAA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const UNBottomSheetComponent: () => JSX.Element;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ViewStyle } from 'react-native';
|
|
2
|
-
declare type UnitReactNativeComponentsProps = {
|
|
3
|
-
color: string;
|
|
4
|
-
style: ViewStyle;
|
|
5
|
-
};
|
|
6
|
-
export declare const UnitReactNativeComponentsView: import("react-native").HostComponent<UnitReactNativeComponentsProps> | (() => never);
|
|
7
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react"
|
|
2
|
-
import type WebView from "react-native-webview"
|
|
3
|
-
import { WebComponent, WebComponentType, WebViewMessage } from "../../webComponent/WebComponent"
|
|
4
|
-
import { Dimensions, Linking, View } from "react-native"
|
|
5
|
-
import BottomSheet from "../../helpers/BottomSheet"
|
|
6
|
-
import EventBus, { BusEvent } from "../../helpers/EventBus"
|
|
7
|
-
import { HeightEvent, PageMessage } from "../../webComponent/webMessages/pageMessage"
|
|
8
|
-
import { RequestOpenLinkEvent, RequestRenderingData, RequestRenderingEvent, UnitMessage } from "../../webComponent/webMessages/unitMessages"
|
|
9
|
-
import { CardMessage, CardStatusChangedEvent } from "../../webComponent/webMessages/cardMessage"
|
|
10
|
-
|
|
11
|
-
export const UNBottomSheetComponent = () => {
|
|
12
|
-
const [isActive, setIsActive] = useState(false)
|
|
13
|
-
const [height, setHeight] = useState(0)
|
|
14
|
-
|
|
15
|
-
const [renderingRequest, setRenderingRequest] = useState<string | null>(null)
|
|
16
|
-
|
|
17
|
-
const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false)
|
|
18
|
-
const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null)
|
|
19
|
-
|
|
20
|
-
const webRef = useRef<WebView>(null)
|
|
21
|
-
|
|
22
|
-
const _listener = (data: string) => {
|
|
23
|
-
setRenderingRequest(data)
|
|
24
|
-
setIsActive(true)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!webRef.current) return
|
|
29
|
-
if (renderingRequest) {
|
|
30
|
-
webRef.current?.injectJavaScript(`dispatchRenderingEvent('${renderingRequest}')`)
|
|
31
|
-
}
|
|
32
|
-
}, [webRef.current, renderingRequest])
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!isActive) {
|
|
36
|
-
setHeight(0)
|
|
37
|
-
setRenderingRequest(null)
|
|
38
|
-
}
|
|
39
|
-
}, [isActive])
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (!waitForLoadingNewComponent && newHeightMessage) {
|
|
43
|
-
setWaitForLoadingNewComponent(false)
|
|
44
|
-
setNewHeight(newHeightMessage)
|
|
45
|
-
}
|
|
46
|
-
}, [waitForLoadingNewComponent, newHeightMessage])
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
EventBus.Instance.addListener(BusEvent.REQUEST_RENDERING, _listener)
|
|
50
|
-
|
|
51
|
-
return (() => {
|
|
52
|
-
EventBus.Instance.removeListener(_listener)
|
|
53
|
-
})
|
|
54
|
-
}, [])
|
|
55
|
-
|
|
56
|
-
const getBottomSheetScript = () => {
|
|
57
|
-
return `
|
|
58
|
-
window.addEventListener("unitRequestRefresh", (e) => {
|
|
59
|
-
postMessageToSDK({ type: "unitRequestRefresh", details: e.detail })
|
|
60
|
-
});
|
|
61
|
-
`
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const setNewHeight = (message: WebViewMessage) => {
|
|
65
|
-
if (renderingRequest) {
|
|
66
|
-
const nativePlace = (JSON.parse(renderingRequest) as RequestRenderingData).nativePlace;
|
|
67
|
-
if (nativePlace == 'overFullScreen') {
|
|
68
|
-
const windowHeight = Dimensions.get('window').height * 0.94;
|
|
69
|
-
setHeight(windowHeight)
|
|
70
|
-
} else {
|
|
71
|
-
setHeight((message.details as HeightEvent).height)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<>
|
|
78
|
-
<View
|
|
79
|
-
pointerEvents={isActive ? undefined : 'none'}
|
|
80
|
-
style={{ position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }}
|
|
81
|
-
>
|
|
82
|
-
<BottomSheet
|
|
83
|
-
isOpen={isActive}
|
|
84
|
-
onClose={() => setIsActive(false)}
|
|
85
|
-
onOpen={() => setIsActive(true)}
|
|
86
|
-
>
|
|
87
|
-
<View style={{ height, paddingTop: height === 0 ? 0 : 10 }}>
|
|
88
|
-
<WebComponent ref={webRef} type={WebComponentType.slot} script={getBottomSheetScript()} onMessage={message => {
|
|
89
|
-
if (renderingRequest && message.type == PageMessage.PAGE_HEIGHT) {
|
|
90
|
-
setNewHeightMessage(message)
|
|
91
|
-
} else if (message.type == UnitMessage.UNIT_REQUEST_RENDERING) {
|
|
92
|
-
const { data } = (message.details! as RequestRenderingEvent)
|
|
93
|
-
if (data != renderingRequest) {
|
|
94
|
-
setHeight(0)
|
|
95
|
-
setRenderingRequest(data)
|
|
96
|
-
setWaitForLoadingNewComponent(true)
|
|
97
|
-
setTimeout(() => setWaitForLoadingNewComponent(false), 400)
|
|
98
|
-
}
|
|
99
|
-
} else if (message.type == CardMessage.CARD_STATUS_CHANGE) {
|
|
100
|
-
EventBus.Instance.event(BusEvent.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card)
|
|
101
|
-
} else if (message.type == UnitMessage.UNIT_REQUEST_CLOSE_FLOW) {
|
|
102
|
-
setIsActive(false)
|
|
103
|
-
} else if (message.type == UnitMessage.UNIT_REQUEST_OPEN_LINK) {
|
|
104
|
-
const href = (message.details as RequestOpenLinkEvent).href
|
|
105
|
-
Linking.openURL(href)
|
|
106
|
-
}
|
|
107
|
-
}} />
|
|
108
|
-
</View>
|
|
109
|
-
</BottomSheet>
|
|
110
|
-
</View>
|
|
111
|
-
</>
|
|
112
|
-
)
|
|
113
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react"
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
import type WebView from "react-native-webview";
|
|
4
|
-
import { HeightEvent, PageMessage } from "../../webComponent/webMessages/pageMessage";
|
|
5
|
-
import { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from "../../webComponent/webMessages/unitMessages";
|
|
6
|
-
import EventBus, { BusEvent } from "../../helpers/EventBus"
|
|
7
|
-
import { WebComponent, WebComponentType } from "../../webComponent/WebComponent"
|
|
8
|
-
|
|
9
|
-
export interface UNCardComponentProps {
|
|
10
|
-
cardId: string;
|
|
11
|
-
customerToken: string;
|
|
12
|
-
onStatusChanged?: (card: any) => void; // TODO - UNCard
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const UNCardComponent = (props: UNCardComponentProps) => {
|
|
16
|
-
const [height, setHeight] = useState(0)
|
|
17
|
-
const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null)
|
|
18
|
-
|
|
19
|
-
const webRef = useRef<WebView>(null)
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
EventBus.Instance.addListener(BusEvent.CARD_STATUS_CHANGED, _cardStatusChanged)
|
|
23
|
-
EventBus.Instance.addListener(BusEvent.REQUEST_REFRESH, _requestRefresh)
|
|
24
|
-
return (() => {
|
|
25
|
-
EventBus.Instance.removeListener(_cardStatusChanged)
|
|
26
|
-
EventBus.Instance.removeListener(_requestRefresh)
|
|
27
|
-
})
|
|
28
|
-
}, [])
|
|
29
|
-
|
|
30
|
-
const _cardStatusChanged = (card: any) => {
|
|
31
|
-
if (props.onStatusChanged) {
|
|
32
|
-
props.onStatusChanged(card)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const _requestRefresh = (data: RequestRefreshEvent) => {
|
|
37
|
-
setRequestRefreshEvent(data)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.card.valueOf()) && requestRefreshEvent.resourceId == props.cardId) {
|
|
42
|
-
webRef.current?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`)
|
|
43
|
-
}
|
|
44
|
-
}, [requestRefreshEvent])
|
|
45
|
-
|
|
46
|
-
const getCardParams = () => {
|
|
47
|
-
return `
|
|
48
|
-
cardId="${props.cardId}"
|
|
49
|
-
customerToken="${props.customerToken}"
|
|
50
|
-
src="https://d1xlopvhx2cz8k.cloudfront.net/resources/outlay.json"
|
|
51
|
-
`
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const getCardScript = () => {
|
|
55
|
-
return `
|
|
56
|
-
const dispatchRefreshEvent = (details) => {
|
|
57
|
-
const event = new CustomEvent("unitRequestRefresh",{ detail: JSON.parse(details) })
|
|
58
|
-
window.dispatchEvent(event)
|
|
59
|
-
}
|
|
60
|
-
`
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<View style={{ height }}>
|
|
65
|
-
<WebComponent ref={webRef} type={WebComponentType.card} params={getCardParams()} script={getCardScript()} onMessage={message => {
|
|
66
|
-
if (message.type === UnitMessage.UNIT_REQUEST_RENDERING) {
|
|
67
|
-
EventBus.Instance.event(BusEvent.REQUEST_RENDERING, (message.details as RequestRenderingEvent).data)
|
|
68
|
-
}
|
|
69
|
-
if (message.type == PageMessage.PAGE_HEIGHT) {
|
|
70
|
-
setHeight((message.details as HeightEvent).height)
|
|
71
|
-
}
|
|
72
|
-
}} />
|
|
73
|
-
</View>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
requireNativeComponent,
|
|
3
|
-
UIManager,
|
|
4
|
-
Platform,
|
|
5
|
-
ViewStyle,
|
|
6
|
-
} from 'react-native';
|
|
7
|
-
|
|
8
|
-
const LINKING_ERROR =
|
|
9
|
-
`The package 'unit-react-native-components' doesn't seem to be linked. Make sure: \n\n` +
|
|
10
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
11
|
-
'- You rebuilt the app after installing the package\n' +
|
|
12
|
-
'- You are not using Expo managed workflow\n';
|
|
13
|
-
|
|
14
|
-
type UnitReactNativeComponentsProps = {
|
|
15
|
-
color: string;
|
|
16
|
-
style: ViewStyle;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const ComponentName = 'UnitReactNativeComponentsView';
|
|
20
|
-
|
|
21
|
-
export const UnitReactNativeComponentsView =
|
|
22
|
-
UIManager.getViewManagerConfig(ComponentName) != null
|
|
23
|
-
? requireNativeComponent<UnitReactNativeComponentsProps>(ComponentName)
|
|
24
|
-
: () => {
|
|
25
|
-
throw new Error(LINKING_ERROR);
|
|
26
|
-
};
|