react-native-unit-components 1.0.2 → 1.0.4
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 +75 -6
- package/android/src/main/AndroidManifest.xml +12 -1
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -1
- package/android/src/main/java/com/unitreactnativecomponents/sharepdf/UNSharePDF.kt +75 -0
- package/android/src/main/res/layout/un_black_add_to_googlepay_button.xml +2 -2
- package/android/src/main/res/layout/un_view_google_push_provisioning.xml +1 -13
- package/android/src/main/res/layout/un_white_add_to_googlepay_button.xml +1 -1
- package/android/src/main/res/layout/un_white_add_to_googlepay_button_no_shadow.xml +1 -1
- package/android/src/main/res/xml/file_paths.xml +4 -0
- package/ios/UnitReactNativeComponentsViewManager.m +0 -1
- package/ios/UnitReactNativeComponentsViewManager.swift +6 -2
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +103 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +47 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +28 -4
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +19 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +22 -10
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +4 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +3 -3
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +114 -46
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +4 -8
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +95 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +31 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +64 -7
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +62 -8
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js +20 -0
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +42 -0
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
- package/lib/commonjs/components/index.js +13 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +32 -12
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/commonjs/helpers/EventBus.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/cardMessage.js +36 -0
- package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -0
- package/lib/commonjs/messages/nativeMessages/index.js +0 -8
- package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js +14 -0
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/commonjs/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
- package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyScript.js +22 -5
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/index.js +13 -0
- package/lib/commonjs/sharedTypes/index.js.map +1 -1
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js +6 -0
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/wallet.types.js +22 -0
- package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js +5 -3
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +12 -2
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +20 -8
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.utils.js +41 -0
- package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -0
- package/lib/commonjs/webComponent/html.js +9 -1
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js +74 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +26 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +28 -6
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +21 -10
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +111 -46
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +5 -9
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +68 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +21 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js +64 -9
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +51 -7
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js +10 -0
- package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +28 -0
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.js +30 -13
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +2 -2
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/module/helpers/EventBus.js.map +1 -1
- package/lib/module/messages/nativeMessages/cardMessage.js +27 -0
- package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -0
- package/lib/module/messages/nativeMessages/index.js +1 -6
- package/lib/module/messages/nativeMessages/index.js.map +1 -1
- package/lib/module/messages/nativeMessages/sdkMessage.js +7 -0
- package/lib/module/messages/nativeMessages/sdkMessage.js.map +1 -0
- package/lib/module/messages/webMessages/unitMessages.js +1 -0
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/module/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
- package/lib/module/nativeComponent/UnitAddToWalletButton.js.map +1 -0
- package/lib/module/scripts/html/bodyScript.js +19 -3
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/module/sharedTypes/card.types.js.map +1 -1
- package/lib/module/sharedTypes/index.js +1 -0
- package/lib/module/sharedTypes/index.js.map +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js +2 -0
- package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -0
- package/lib/module/sharedTypes/wallet.types.js +14 -0
- package/lib/module/sharedTypes/wallet.types.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdk.api.js +4 -3
- package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdkManager.js +12 -2
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +18 -7
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/WebComponent.utils.js +27 -0
- package/lib/module/webComponent/WebComponent.utils.js.map +1 -0
- package/lib/module/webComponent/html.js +9 -2
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +12 -0
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +7 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +4 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +9 -2
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +2 -1
- package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.d.ts +6 -0
- package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.d.ts +17 -0
- package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +4 -1
- package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +9 -1
- package/lib/typescript/components/UNCardComponent/networking/common/UNNetworkConstants.d.ts +8 -0
- package/lib/typescript/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.d.ts +2 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/helpers/EventBus.d.ts +3 -3
- package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +28 -0
- package/lib/typescript/messages/nativeMessages/index.d.ts +7 -3
- package/lib/typescript/messages/nativeMessages/sdkMessage.d.ts +8 -0
- package/lib/typescript/messages/webMessages/unitMessages.d.ts +16 -6
- package/lib/typescript/scripts/html/bodyScript.d.ts +4 -1
- package/lib/typescript/sharedTypes/bookPayment.types.d.ts +3 -3
- package/lib/typescript/sharedTypes/card.types.d.ts +6 -6
- package/lib/typescript/sharedTypes/index.d.ts +1 -0
- package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +18 -0
- package/lib/typescript/sharedTypes/wallet.types.d.ts +14 -0
- package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +3 -0
- package/lib/typescript/webComponent/WebComponent.d.ts +2 -1
- package/lib/typescript/webComponent/WebComponent.utils.d.ts +2 -0
- package/package.json +2 -1
- package/src/components/UNAccountComponent/UNAccountComponent.tsx +82 -0
- package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +30 -0
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +28 -5
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +14 -0
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +18 -10
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +3 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -1
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +120 -44
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +7 -10
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.ts +21 -0
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +74 -0
- package/src/components/UNCardComponent/UNCardComponent.tsx +67 -13
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +51 -7
- package/src/components/UNCardComponent/networking/common/UNNetworkConstants.ts +11 -0
- package/src/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.ts +32 -0
- package/src/components/index.ts +1 -0
- package/src/helpers/BottomSheet/BottomSheet.styles.ts +2 -2
- package/src/helpers/BottomSheet/BottomSheet.tsx +28 -12
- package/src/helpers/EventBus.ts +3 -3
- package/src/messages/nativeMessages/cardMessage.ts +37 -0
- package/src/messages/nativeMessages/index.ts +14 -3
- package/src/messages/nativeMessages/sdkMessage.ts +11 -0
- package/src/messages/webMessages/unitMessages.ts +20 -7
- package/src/scripts/html/bodyScript.ts +21 -4
- package/src/sharedTypes/bookPayment.types.ts +3 -3
- package/src/sharedTypes/card.types.ts +6 -6
- package/src/sharedTypes/index.ts +1 -0
- package/src/sharedTypes/onLoadResponse.types.ts +27 -0
- package/src/sharedTypes/wallet.types.ts +17 -0
- package/src/unitSdkManager/UnitSdk.api.ts +3 -2
- package/src/unitSdkManager/UnitSdkManager.ts +11 -2
- package/src/webComponent/WebComponent.tsx +21 -10
- package/src/webComponent/WebComponent.utils.ts +26 -0
- package/src/webComponent/html.ts +9 -2
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
- /package/lib/typescript/nativeComponent/{UNNativeAddToWalletButton.d.ts → UnitAddToWalletButton.d.ts} +0 -0
- /package/src/nativeComponent/{UNNativeAddToWalletButton.tsx → UnitAddToWalletButton.tsx} +0 -0
|
@@ -19,6 +19,8 @@ var _pageMessage = require("../../messages/webMessages/pageMessage");
|
|
|
19
19
|
|
|
20
20
|
var _reactNative = require("react-native");
|
|
21
21
|
|
|
22
|
+
var _unitMessages = require("../../messages/webMessages/unitMessages");
|
|
23
|
+
|
|
22
24
|
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); }
|
|
23
25
|
|
|
24
26
|
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; }
|
|
@@ -28,18 +30,28 @@ const UNBookPaymentComponent = props => {
|
|
|
28
30
|
const [presentationMode, setPresentationMode] = (0, _react.useState)(_bodyHtml.PresentationMode.Inherit);
|
|
29
31
|
|
|
30
32
|
const handleWebViewMessage = message => {
|
|
31
|
-
if (message
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (!message || !message.details) return;
|
|
34
|
+
|
|
35
|
+
switch (message.type) {
|
|
36
|
+
case _bookPaymentMessage.BookPaymentMessage.PAYMENT_CREATED:
|
|
37
|
+
props.onPaymentCreated && props.onPaymentCreated(message.details.data);
|
|
38
|
+
break;
|
|
39
|
+
|
|
40
|
+
case _unitMessages.UnitMessage.UNIT_ON_LOAD:
|
|
41
|
+
props.onLoad && props.onLoad(message.details);
|
|
42
|
+
break;
|
|
43
|
+
|
|
44
|
+
case _pageMessage.PageMessage.PAGE_HEIGHT:
|
|
45
|
+
{
|
|
46
|
+
const currentHeight = message.details.height;
|
|
47
|
+
setHeight(currentHeight);
|
|
35
48
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
if (presentationMode === _bodyHtml.PresentationMode.Inherit && currentHeight === 0) {
|
|
50
|
+
setPresentationMode(_bodyHtml.PresentationMode.Default);
|
|
51
|
+
}
|
|
39
52
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
43
55
|
}
|
|
44
56
|
};
|
|
45
57
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UNBookPaymentComponent","props","height","setHeight","useState","presentationMode","setPresentationMode","PresentationMode","Inherit","handleWebViewMessage","message","type","BookPaymentMessage","PAYMENT_CREATED","onPaymentCreated","
|
|
1
|
+
{"version":3,"names":["UNBookPaymentComponent","props","height","setHeight","useState","presentationMode","setPresentationMode","PresentationMode","Inherit","handleWebViewMessage","message","details","type","BookPaymentMessage","PAYMENT_CREATED","onPaymentCreated","data","UnitMessage","UNIT_ON_LOAD","onLoad","PageMessage","PAGE_HEIGHT","currentHeight","Default","renderBookPaymentWebView","WebComponentType","bookPayment","getBookPaymentParams","getBookPaymentScript","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 { ResponseUnitOnLoadEvent, UNBookPaymentData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { View } from 'react-native';\nimport { UnitMessage } from '../../messages/webMessages/unitMessages';\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 onLoad?: (response: ResponseUnitOnLoadEvent) => 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 || !message.details) return;\n\n switch (message.type) {\n case BookPaymentMessage.PAYMENT_CREATED:\n props.onPaymentCreated && props.onPaymentCreated((message.details as BookPaymentEvent).data);\n break;\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as ResponseUnitOnLoadEvent);\n break;\n case 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 break;\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;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;;;AAaO,MAAMA,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAiB,CAAjB,CAA5B;EACA,MAAM,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0C,IAAAF,eAAA,EAA2BG,0BAAA,CAAiBC,OAA5C,CAAhD;;EAEA,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAI,CAACA,OAAD,IAAY,CAACA,OAAO,CAACC,OAAzB,EAAkC;;IAElC,QAAQD,OAAO,CAACE,IAAhB;MACE,KAAKC,sCAAA,CAAmBC,eAAxB;QACEb,KAAK,CAACc,gBAAN,IAA0Bd,KAAK,CAACc,gBAAN,CAAwBL,OAAO,CAACC,OAAT,CAAsCK,IAA7D,CAA1B;QACA;;MACF,KAAKC,yBAAA,CAAYC,YAAjB;QACEjB,KAAK,CAACkB,MAAN,IAAgBlB,KAAK,CAACkB,MAAN,CAAaT,OAAO,CAACC,OAArB,CAAhB;QACA;;MACF,KAAKS,wBAAA,CAAYC,WAAjB;QAA8B;UAC5B,MAAMC,aAAa,GAAIZ,OAAO,CAACC,OAAT,CAAiCT,MAAvD;UACAC,SAAS,CAACmB,aAAD,CAAT;;UACA,IAAIjB,gBAAgB,KAAKE,0BAAA,CAAiBC,OAAtC,IAAiDc,aAAa,KAAK,CAAvE,EAA0E;YACxEhB,mBAAmB,CAACC,0BAAA,CAAiBgB,OAAlB,CAAnB;UACD;;UACD;QACD;IAdH;EAgBD,CAnBD;;EAqBA,MAAMC,wBAAwB,GAAG,MAAM;IACrC,oBACE,6BAAC,0BAAD;MACE,IAAI,EAAEC,8BAAA,CAAiBC,WADzB;MAEE,gBAAgB,EAAErB,gBAFpB;MAGE,MAAM,EAAE,IAAAsB,4CAAA,EAAqB1B,KAArB,CAHV;MAIE,MAAM,EAAE,IAAA2B,4CAAA,GAJV;MAKE,SAAS,EAAGlB,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;MAME,YAAY,EAAE,KANhB;MAOE,KAAK,EAAET,KAAK,CAAC4B;IAPf,EADF;EAWD,CAZD;;EAcA,IAAIxB,gBAAgB,KAAKE,0BAAA,CAAiBC,OAA1C,EAAmD;IACjD,OAAOgB,wBAAwB,EAA/B;EACD;;EAED,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAEtB,MAAM,EAAEA;IAAV;EAAb,GACGsB,wBAAwB,EAD3B,CADF;AAKD,CAhDM"}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getBookPaymentScript = exports.getBookPaymentParams = void 0;
|
|
7
7
|
|
|
8
|
+
var _bodyScript = require("./../../scripts/html/bodyScript");
|
|
9
|
+
|
|
8
10
|
var _bookPaymentMessage = require("../../messages/webMessages/bookPaymentMessage");
|
|
9
11
|
|
|
10
12
|
const getBookPaymentParams = props => {
|
|
@@ -30,6 +32,8 @@ const getBookPaymentScript = () => {
|
|
|
30
32
|
console.log(e)
|
|
31
33
|
})
|
|
32
34
|
});
|
|
35
|
+
|
|
36
|
+
${_bodyScript.LISTENERS.requestRefresh}
|
|
33
37
|
`;
|
|
34
38
|
};
|
|
35
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","getBookPaymentScript","BookPaymentMessage","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":";;;;;;;
|
|
1
|
+
{"version":3,"names":["getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","getBookPaymentScript","BookPaymentMessage","PAYMENT_CREATED","LISTENERS","requestRefresh"],"sources":["UNBookPaymentComponent.utils.ts"],"sourcesContent":["import { LISTENERS } from './../../scripts/html/bodyScript';\nimport 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 ${LISTENERS.requestRefresh}\n `;\n};\n"],"mappings":";;;;;;;AAAA;;AAGA;;AAEO,MAAMA,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;;;;AAWA,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BC,sCAAA,CAAmBC,eAAgB;AAClE;AACA;AACA,sCAAsCD,sCAAA,CAAmBC,eAAgB;AACzE;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAA,CAAUC,cAAe;AAC/B,GAXE;AAYD,CAbM"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
exports.
|
|
6
|
+
exports.BOTTOM_SHEET_MAX_PERCENTAGE_SIZE = void 0;
|
|
7
|
+
const BOTTOM_SHEET_MAX_PERCENTAGE_SIZE = 0.9;
|
|
8
|
+
exports.BOTTOM_SHEET_MAX_PERCENTAGE_SIZE = BOTTOM_SHEET_MAX_PERCENTAGE_SIZE;
|
|
9
9
|
//# sourceMappingURL=UNBottomSheetComponent.constants.js.map
|
package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BOTTOM_SHEET_MAX_PERCENTAGE_SIZE"],"sources":["UNBottomSheetComponent.constants.ts"],"sourcesContent":["export const BOTTOM_SHEET_MAX_PERCENTAGE_SIZE = 0.9;\n"],"mappings":";;;;;;AAAO,MAAMA,gCAAgC,GAAG,GAAzC"}
|
|
@@ -31,6 +31,12 @@ var _bodyHtml = require("../../scripts/html/bodyHtml");
|
|
|
31
31
|
|
|
32
32
|
var _useAppStateListener = require("../../hooks/useAppStateListener");
|
|
33
33
|
|
|
34
|
+
var _UNAddToWalletBottomSheetItem = require("./components/UNAddToWalletBottomSheetItem");
|
|
35
|
+
|
|
36
|
+
var _UNAccountComponent = require("../UNAccountComponent/UNAccountComponent.utils");
|
|
37
|
+
|
|
38
|
+
var _UNAccountComponent2 = require("../UNAccountComponent/UNAccountComponent");
|
|
39
|
+
|
|
34
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
41
|
|
|
36
42
|
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); }
|
|
@@ -43,45 +49,57 @@ exports.ScrollState = ScrollState;
|
|
|
43
49
|
|
|
44
50
|
(function (ScrollState) {
|
|
45
51
|
ScrollState["onTop"] = "onTop";
|
|
52
|
+
ScrollState["unScrollable"] = "unScrollable";
|
|
46
53
|
ScrollState["onlyWebView"] = "webViewScroll";
|
|
47
54
|
ScrollState["onlyBottomSheet"] = "onlyBottomSheet";
|
|
48
|
-
ScrollState["unScrollable"] = "unScrollable";
|
|
49
55
|
})(ScrollState || (exports.ScrollState = ScrollState = {}));
|
|
50
56
|
|
|
57
|
+
var CustomDialog;
|
|
58
|
+
|
|
59
|
+
(function (CustomDialog) {
|
|
60
|
+
CustomDialog[CustomDialog["addToWallet"] = 0] = "addToWallet";
|
|
61
|
+
})(CustomDialog || (CustomDialog = {}));
|
|
62
|
+
|
|
51
63
|
const UNBottomSheetComponent = () => {
|
|
52
64
|
const [isBottomSheetActive, setIsBottomSheetActive] = (0, _react.useState)(false);
|
|
53
65
|
const [height, setHeight] = (0, _react.useState)(0);
|
|
54
|
-
const [
|
|
66
|
+
const [bottomSheetSlotData, setBottomSheetSlotData] = (0, _react.useState)();
|
|
67
|
+
const [requestRenderingEvent, setRequestRenderingEvent] = (0, _react.useState)();
|
|
55
68
|
const [scrollState, setScrollState] = (0, _react.useState)(ScrollState.onTop);
|
|
56
69
|
const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = (0, _react.useState)(false);
|
|
57
70
|
const [newHeightMessage, setNewHeightMessage] = (0, _react.useState)(null);
|
|
71
|
+
const [customDialog, setCustomDialog] = (0, _react.useState)(null);
|
|
58
72
|
const isAppActive = (0, _useAppStateListener.useAppStateListener)();
|
|
59
73
|
const styles = (0, _UNBottomSheetComponent2.getStylesObject)();
|
|
60
74
|
const webRef = (0, _react.useRef)(null);
|
|
61
75
|
|
|
62
|
-
const
|
|
63
|
-
|
|
76
|
+
const handleRequestRendering = data => {
|
|
77
|
+
setBottomSheetSlotData(data);
|
|
64
78
|
setIsBottomSheetActive(true);
|
|
79
|
+
setRequestRenderingEvent(data.requestRenderingEvent);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleCloseFlow = () => {
|
|
83
|
+
setIsBottomSheetActive(false);
|
|
65
84
|
};
|
|
66
85
|
|
|
67
86
|
(0, _react.useEffect)(() => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
}, [isAppActive]);
|
|
87
|
+
setRequestRenderingEvent(bottomSheetSlotData === null || bottomSheetSlotData === void 0 ? void 0 : bottomSheetSlotData.requestRenderingEvent);
|
|
88
|
+
}, [bottomSheetSlotData]);
|
|
72
89
|
(0, _react.useEffect)(() => {
|
|
73
90
|
if (!webRef.current) return;
|
|
74
91
|
|
|
75
|
-
if (
|
|
76
|
-
(0, _UNBottomSheetComponent.renderingBottomSheetRequest)(webRef.current,
|
|
92
|
+
if (requestRenderingEvent) {
|
|
93
|
+
(0, _UNBottomSheetComponent.renderingBottomSheetRequest)(webRef.current, requestRenderingEvent);
|
|
77
94
|
}
|
|
78
|
-
}, [webRef.current,
|
|
95
|
+
}, [webRef.current, requestRenderingEvent]);
|
|
79
96
|
(0, _react.useEffect)(() => {
|
|
80
97
|
if (!isBottomSheetActive) {
|
|
81
98
|
webRef.current && (0, _UNBottomSheetComponent.resetHtml)(webRef.current);
|
|
82
99
|
setHeight(0);
|
|
83
|
-
|
|
100
|
+
setRequestRenderingEvent(undefined);
|
|
84
101
|
setScrollState(ScrollState.onTop);
|
|
102
|
+
setCustomDialog(null);
|
|
85
103
|
}
|
|
86
104
|
}, [isBottomSheetActive]);
|
|
87
105
|
(0, _react.useEffect)(() => {
|
|
@@ -92,44 +110,81 @@ const UNBottomSheetComponent = () => {
|
|
|
92
110
|
}, [waitForLoadingNewComponent, newHeightMessage]);
|
|
93
111
|
(0, _listenerToBus.useListenerToBus)([{
|
|
94
112
|
busEventKey: _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING,
|
|
95
|
-
action:
|
|
113
|
+
action: handleRequestRendering
|
|
114
|
+
}, {
|
|
115
|
+
busEventKey: _unitMessages.UnitMessage.UNIT_REQUEST_CLOSE_FLOW,
|
|
116
|
+
action: handleCloseFlow
|
|
96
117
|
}]);
|
|
97
118
|
|
|
98
119
|
const setNewHeight = message => {
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
if (!requestRenderingEvent) return;
|
|
121
|
+
|
|
122
|
+
switch (bottomSheetSlotData === null || bottomSheetSlotData === void 0 ? void 0 : bottomSheetSlotData.componentName) {
|
|
123
|
+
case _WebComponent.WebComponentType.account:
|
|
124
|
+
{
|
|
125
|
+
const accountActionType = (0, _UNAccountComponent.getAccountActionType)(requestRenderingEvent);
|
|
126
|
+
setScrollState(accountActionType === _UNAccountComponent2.AccountAction.List ? ScrollState.onTop : ScrollState.unScrollable);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
case _WebComponent.WebComponentType.card:
|
|
131
|
+
{
|
|
132
|
+
if (customDialog === CustomDialog.addToWallet) {
|
|
133
|
+
setScrollState(ScrollState.unScrollable);
|
|
134
|
+
} else {
|
|
135
|
+
setScrollState(ScrollState.onTop);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
default:
|
|
142
|
+
{
|
|
143
|
+
const nativePlace = requestRenderingEvent === null || requestRenderingEvent === void 0 ? void 0 : requestRenderingEvent.data.nativePlace;
|
|
144
|
+
|
|
145
|
+
if (nativePlace == 'overFullScreen') {
|
|
146
|
+
setScrollState(ScrollState.onTop);
|
|
147
|
+
} else {
|
|
148
|
+
setScrollState(ScrollState.unScrollable);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const nativePlace = requestRenderingEvent === null || requestRenderingEvent === void 0 ? void 0 : requestRenderingEvent.data.nativePlace;
|
|
154
|
+
|
|
155
|
+
if (nativePlace == 'overFullScreen') {
|
|
156
|
+
const bottomSheetNewHeight = (0, _UNBottomSheetComponent.handleHtmlFullHeight)(webRef.current, _reactNative.Dimensions.get('window').height);
|
|
157
|
+
setHeight(bottomSheetNewHeight);
|
|
158
|
+
} else {
|
|
159
|
+
setHeight(message.details.height);
|
|
110
160
|
}
|
|
111
161
|
};
|
|
112
162
|
|
|
113
163
|
const onWebMessage = message => {
|
|
114
164
|
switch (message.type) {
|
|
115
165
|
case _pageMessage.PageMessage.PAGE_HEIGHT:
|
|
116
|
-
|
|
166
|
+
requestRenderingEvent && setNewHeightMessage(message);
|
|
117
167
|
break;
|
|
118
168
|
|
|
119
169
|
case _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
data
|
|
123
|
-
} = message.details;
|
|
170
|
+
{
|
|
171
|
+
var _requestRenderingEven;
|
|
124
172
|
|
|
125
|
-
|
|
126
|
-
setHeight(0);
|
|
127
|
-
setRenderingRequest(data);
|
|
128
|
-
setWaitForLoadingNewComponent(true);
|
|
129
|
-
setTimeout(() => setWaitForLoadingNewComponent(false), 400);
|
|
130
|
-
}
|
|
173
|
+
const requestRendering = message.details;
|
|
131
174
|
|
|
132
|
-
|
|
175
|
+
if (requestRendering.data.nativeComponent != (requestRenderingEvent === null || requestRenderingEvent === void 0 ? void 0 : (_requestRenderingEven = requestRenderingEvent.data) === null || _requestRenderingEven === void 0 ? void 0 : _requestRenderingEven.nativeComponent)) {
|
|
176
|
+
if (requestRendering.data.nativeComponent.includes('action=AddToWallet')) {
|
|
177
|
+
setCustomDialog(CustomDialog.addToWallet);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
setHeight(0);
|
|
181
|
+
setRequestRenderingEvent(requestRendering);
|
|
182
|
+
setWaitForLoadingNewComponent(true);
|
|
183
|
+
setTimeout(() => setWaitForLoadingNewComponent(false), 400);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
133
188
|
|
|
134
189
|
case _cardMessage.CardMessage.CARD_STATUS_CHANGED:
|
|
135
190
|
_EventBus.default.Instance.event(_cardMessage.CardMessage.CARD_STATUS_CHANGED, message.details.card);
|
|
@@ -137,7 +192,7 @@ const UNBottomSheetComponent = () => {
|
|
|
137
192
|
break;
|
|
138
193
|
|
|
139
194
|
case _unitMessages.UnitMessage.UNIT_REQUEST_CLOSE_FLOW:
|
|
140
|
-
|
|
195
|
+
handleCloseFlow();
|
|
141
196
|
break;
|
|
142
197
|
|
|
143
198
|
case _unitMessages.UnitMessage.UNIT_REQUEST_OPEN_LINK:
|
|
@@ -170,6 +225,27 @@ const UNBottomSheetComponent = () => {
|
|
|
170
225
|
setScrollState(ScrollState.onlyWebView);
|
|
171
226
|
};
|
|
172
227
|
|
|
228
|
+
const renderBottomSheetItem = () => {
|
|
229
|
+
switch (customDialog) {
|
|
230
|
+
case CustomDialog.addToWallet:
|
|
231
|
+
return /*#__PURE__*/_react.default.createElement(_UNAddToWalletBottomSheetItem.UNAddToWalletBottomSheetItem, {
|
|
232
|
+
renderingRequest: requestRenderingEvent,
|
|
233
|
+
cardId: bottomSheetSlotData === null || bottomSheetSlotData === void 0 ? void 0 : bottomSheetSlotData.componentResourceId
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
default:
|
|
237
|
+
return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
|
|
238
|
+
ref: webRef,
|
|
239
|
+
type: _WebComponent.WebComponentType.slot,
|
|
240
|
+
presentationMode: _bodyHtml.PresentationMode.CoverInjectedHeight,
|
|
241
|
+
script: (0, _UNBottomSheetComponent.getBottomSheetScript)(),
|
|
242
|
+
onMessage: onWebMessage,
|
|
243
|
+
isScrollable: scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop,
|
|
244
|
+
handleScroll: onScrollWebView
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
173
249
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
174
250
|
pointerEvents: isBottomSheetActive ? undefined : 'none',
|
|
175
251
|
style: styles.container
|
|
@@ -180,15 +256,7 @@ const UNBottomSheetComponent = () => {
|
|
|
180
256
|
onOpen: () => setIsBottomSheetActive(true),
|
|
181
257
|
handleWebViewScroll: () => handleWebViewScroll(),
|
|
182
258
|
shouldEnableBottomSheetScroll: scrollState !== ScrollState.onlyWebView
|
|
183
|
-
}, isAppActive &&
|
|
184
|
-
ref: webRef,
|
|
185
|
-
type: _WebComponent.WebComponentType.slot,
|
|
186
|
-
presentationMode: _bodyHtml.PresentationMode.CoverInjectedHeight,
|
|
187
|
-
script: (0, _UNBottomSheetComponent.getBottomSheetScript)(),
|
|
188
|
-
onMessage: onWebMessage,
|
|
189
|
-
isScrollable: scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop,
|
|
190
|
-
handleScroll: onScrollWebView
|
|
191
|
-
}))));
|
|
259
|
+
}, isAppActive && renderBottomSheetItem())));
|
|
192
260
|
};
|
|
193
261
|
|
|
194
262
|
exports.UNBottomSheetComponent = UNBottomSheetComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ScrollState","UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","useState","height","setHeight","renderingRequest","setRenderingRequest","scrollState","setScrollState","onTop","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","isAppActive","useAppStateListener","styles","getStylesObject","webRef","useRef","listenerAction","data","useEffect","current","renderingBottomSheetRequest","resetHtml","setNewHeight","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_RENDERING","action","message","nativePlace","JSON","parse","bottomSheetNewHeight","handleHtmlFullHeight","Dimensions","get","details","unScrollable","onWebMessage","type","PageMessage","PAGE_HEIGHT","setTimeout","CardMessage","CARD_STATUS_CHANGED","EventBus","Instance","event","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","Linking","openURL","onScrollWebView","currY","nativeEvent","contentOffset","y","onlyBottomSheet","onlyWebView","handleWebViewScroll","undefined","container","WebComponentType","slot","PresentationMode","CoverInjectedHeight","getBottomSheetScript"],"sources":["UNBottomSheetComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useRef, useState } from 'react';\nimport type WebView from 'react-native-webview';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { Dimensions, Linking, View } from 'react-native';\nimport BottomSheet from '../../helpers/BottomSheet/BottomSheet';\nimport EventBus from '../../helpers/EventBus';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { RequestOpenLinkEvent, RequestRenderingData, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { CardMessage, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest, resetHtml } from './UNBottomSheetComponent.utils';\nimport { getStylesObject } from './UNBottomSheetComponent.styles';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { useAppStateListener } from '../../hooks/useAppStateListener';\n\nexport enum ScrollState {\n onTop = 'onTop',\n onlyWebView = 'webViewScroll',\n onlyBottomSheet = 'onlyBottomSheet',\n unScrollable = 'unScrollable'\n}\n\nexport const UNBottomSheetComponent = () => {\n const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);\n const [height, setHeight] = useState(0);\n\n const [renderingRequest, setRenderingRequest] = useState<string | null>(null);\n const [scrollState, setScrollState] = useState<ScrollState>(ScrollState.onTop);\n\n const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);\n const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null);\n\n const isAppActive = useAppStateListener();\n\n const styles = getStylesObject();\n\n const webRef = useRef<WebView>(null);\n\n const listenerAction = (data: string) => {\n setRenderingRequest(data);\n setIsBottomSheetActive(true);\n };\n\n useEffect(() => {\n if (!isAppActive) {\n setIsBottomSheetActive(false);\n }\n }, [isAppActive]);\n\n useEffect(() => {\n if (!webRef.current) return;\n if (renderingRequest) {\n renderingBottomSheetRequest(webRef.current, renderingRequest);\n }\n }, [webRef.current, renderingRequest]);\n\n useEffect(() => {\n if (!isBottomSheetActive) {\n webRef.current && resetHtml(webRef.current);\n setHeight(0);\n setRenderingRequest(null);\n setScrollState(ScrollState.onTop);\n }\n }, [isBottomSheetActive]);\n\n useEffect(() => {\n if (!waitForLoadingNewComponent && newHeightMessage) {\n setWaitForLoadingNewComponent(false);\n setNewHeight(newHeightMessage);\n }\n }, [waitForLoadingNewComponent, newHeightMessage]);\n\n useListenerToBus([{ busEventKey: UnitMessage.UNIT_REQUEST_RENDERING, action: listenerAction }]);\n\n const setNewHeight = (message: WebViewMessage) => {\n if (renderingRequest) {\n const nativePlace = (JSON.parse(renderingRequest) as RequestRenderingData).nativePlace;\n if (nativePlace == 'overFullScreen') {\n const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);\n setHeight(bottomSheetNewHeight);\n setScrollState(ScrollState.onTop);\n } else {\n setHeight((message.details as HeightEvent).height);\n setScrollState(ScrollState.unScrollable);\n }\n }\n };\n\n const onWebMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case PageMessage.PAGE_HEIGHT:\n renderingRequest && setNewHeightMessage(message);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING:\n // eslint-disable-next-line no-case-declarations\n const { data } = (message.details as RequestRenderingEvent);\n if (data != renderingRequest) {\n setHeight(0);\n setRenderingRequest(data);\n setWaitForLoadingNewComponent(true);\n setTimeout(() => setWaitForLoadingNewComponent(false), 400);\n }\n break;\n case CardMessage.CARD_STATUS_CHANGED:\n EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card);\n break;\n case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:\n setIsBottomSheetActive(false);\n break;\n case UnitMessage.UNIT_REQUEST_OPEN_LINK:\n // eslint-disable-next-line no-case-declarations\n const { href } = (message.details as RequestOpenLinkEvent);\n Linking.openURL(href);\n break;\n }\n };\n\n const onScrollWebView = (event: any) => {\n if (scrollState === ScrollState.unScrollable) return;\n\n const currY = event.nativeEvent.contentOffset.y;\n\n if (ScrollState.onTop && currY < 5) {\n setScrollState(ScrollState.onlyBottomSheet);\n }\n\n if ( scrollState !== ScrollState.onlyWebView && scrollState === ScrollState.onTop && currY > 5) {\n setScrollState(ScrollState.onlyWebView);\n }\n };\n\n const handleWebViewScroll = () => {\n if (scrollState === ScrollState.unScrollable) return;\n setScrollState(ScrollState.onlyWebView);\n };\n\n return (\n <>\n <View\n pointerEvents={isBottomSheetActive ? undefined : 'none'}\n style={styles.container}\n >\n <BottomSheet\n isOpen={isBottomSheetActive}\n height={height}\n onClose={() => setIsBottomSheetActive(false)}\n onOpen={() => setIsBottomSheetActive(true)}\n handleWebViewScroll={() => handleWebViewScroll()}\n shouldEnableBottomSheetScroll={scrollState !== ScrollState.onlyWebView}\n >\n { isAppActive && (\n <WebComponent\n ref={webRef}\n type={WebComponentType.slot}\n presentationMode={PresentationMode.CoverInjectedHeight}\n script={getBottomSheetScript()}\n onMessage={onWebMessage}\n isScrollable={scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop}\n handleScroll={onScrollWebView}\n />)}\n </BottomSheet>\n </View>\n </>\n );\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;AAfA;IAiBYA,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W;;AAOL,MAAMC,sBAAsB,GAAG,MAAM;EAC1C,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgD,IAAAC,eAAA,EAAS,KAAT,CAAtD;EACA,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAF,eAAA,EAAS,CAAT,CAA5B;EAEA,M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BACE,yEACE,6BAAC,iBAAD;IACE,aAAa,EAAEhE,mBAAmB,GAAGkE,SAAH,GAAe,MADnD;IAEE,KAAK,EAAElD,MAAM,CAACmD;EAFhB,gBAIE,6BAAC,oBAAD;IACE,MAAM,EAAEnE,mBADV;IAEE,MAAM,EAAEG,MAFV;IAGE,OAAO,EAAE,MAAMF,sBAAsB,CAAC,KAAD,CAHvC;IAIE,MAAM,EAAE,MAAMA,sBAAsB,CAAC,IAAD,CAJtC;IAKE,mBAAmB,EAAE,MAAOgE,mBAAmB,EALjD;IAME,6BAA6B,EAAE1D,WAAW,KAAKT,WAAW,CAACkE;EAN7D,GAQIlD,WAAW,iBACX,6BAAC,0BAAD;IACE,GAAG,EAAEI,MADP;IAEE,IAAI,EAAEkD,8BAAA,CAAiBC,IAFzB;IAGE,gBAAgB,EAAEC,0BAAA,CAAiBC,mBAHrC;IAIE,MAAM,EAAE,IAAAC,4CAAA,GAJV;IAKE,SAAS,EAAE9B,YALb;IAME,YAAY,EAAEnC,WAAW,KAAKT,WAAW,CAACkE,WAA5B,IAA2CzD,WAAW,KAAKT,WAAW,CAACW,KANvF;IAOE,YAAY,EAAEiD;EAPhB,EATJ,CAJF,CADF,CADF;AA4BD,CA9IM"}
|
|
1
|
+
{"version":3,"names":["ScrollState","CustomDialog","UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","useState","height","setHeight","bottomSheetSlotData","setBottomSheetSlotData","requestRenderingEvent","setRequestRenderingEvent","scrollState","setScrollState","onTop","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","customDialog","setCustomDialog","isAppActive","useAppStateListener","styles","getStylesObject","webRef","useRef","handleRequestRendering","data","handleCloseFlow","useEffect","current","renderingBottomSheetRequest","resetHtml","undefined","setNewHeight","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_RENDERING","action","UNIT_REQUEST_CLOSE_FLOW","message","componentName","WebComponentType","account","accountActionType","getAccountActionType","AccountAction","List","unScrollable","card","addToWallet","nativePlace","bottomSheetNewHeight","handleHtmlFullHeight","Dimensions","get","details","onWebMessage","type","PageMessage","PAGE_HEIGHT","requestRendering","nativeComponent","includes","setTimeout","CardMessage","CARD_STATUS_CHANGED","EventBus","Instance","event","UNIT_REQUEST_OPEN_LINK","href","Linking","openURL","onScrollWebView","currY","nativeEvent","contentOffset","y","onlyBottomSheet","onlyWebView","handleWebViewScroll","renderBottomSheetItem","componentResourceId","slot","PresentationMode","CoverInjectedHeight","getBottomSheetScript","container"],"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, 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';\nimport { UNAddToWalletBottomSheetItem } from './components/UNAddToWalletBottomSheetItem';\nimport { getAccountActionType } from '../UNAccountComponent/UNAccountComponent.utils';\nimport { AccountAction } from '../UNAccountComponent/UNAccountComponent';\n\nexport enum ScrollState {\n /*\n Web View ScrollState -\n - Initialization:\n 'onTop': for a scrollable webView.\n (onTop means that the webview is onTop of the BottomSheet and we need to recognize the scroll direction).\n Then, it recognize the scroll direction and update the scroll state as needed.\n\n -'unScrollable': for an unscrollable webView\n */\n onTop = 'onTop',\n unScrollable = 'unScrollable',\n\n /*\n These are only for maintain the bottom sheet scrollState (not an initialize scroll state).\n It relates to the current scroll state.\n onlyWebView means that now the scroll is on webview (only).\n onlyBottomSheet means that now the scroll is on bottomSheet (only).\n */\n onlyWebView = 'webViewScroll',\n onlyBottomSheet = 'onlyBottomSheet',\n}\n\nexport type BottomSheetSlotData = {\n // The data that rendered by the web view\n componentName?: WebComponentType,\n componentResourceId?: string,\n requestRenderingEvent: RequestRenderingEvent\n}\n\nenum CustomDialog {\n addToWallet\n}\n\nexport const UNBottomSheetComponent = () => {\n const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);\n const [height, setHeight] = useState(0);\n\n const [bottomSheetSlotData, setBottomSheetSlotData] = useState<BottomSheetSlotData>();\n const [requestRenderingEvent, setRequestRenderingEvent] = useState<RequestRenderingEvent>();\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 [customDialog, setCustomDialog] = useState<CustomDialog | null>(null);\n\n const isAppActive = useAppStateListener();\n\n const styles = getStylesObject();\n\n const webRef = useRef<WebView>(null);\n\n const handleRequestRendering = (data: BottomSheetSlotData) => {\n setBottomSheetSlotData(data);\n setIsBottomSheetActive(true);\n setRequestRenderingEvent(data.requestRenderingEvent);\n };\n\n const handleCloseFlow = () => {\n setIsBottomSheetActive(false);\n };\n\n useEffect(() => {\n setRequestRenderingEvent(bottomSheetSlotData?.requestRenderingEvent);\n }, [bottomSheetSlotData]);\n\n useEffect(() => {\n if (!webRef.current) return;\n if (requestRenderingEvent) {\n renderingBottomSheetRequest(webRef.current, requestRenderingEvent);\n }\n }, [webRef.current, requestRenderingEvent]);\n\n useEffect(() => {\n if (!isBottomSheetActive) {\n webRef.current && resetHtml(webRef.current);\n setHeight(0);\n setRequestRenderingEvent(undefined);\n setScrollState(ScrollState.onTop);\n setCustomDialog(null);\n }\n }, [isBottomSheetActive]);\n\n useEffect(() => {\n if (!waitForLoadingNewComponent && newHeightMessage) {\n setWaitForLoadingNewComponent(false);\n setNewHeight(newHeightMessage);\n }\n }, [waitForLoadingNewComponent, newHeightMessage]);\n\n useListenerToBus([\n { busEventKey: UnitMessage.UNIT_REQUEST_RENDERING, action: handleRequestRendering },\n { busEventKey: UnitMessage.UNIT_REQUEST_CLOSE_FLOW, action: handleCloseFlow }\n ]);\n\n const setNewHeight = (message: WebViewMessage) => {\n if (!requestRenderingEvent) return;\n switch (bottomSheetSlotData?.componentName) {\n case WebComponentType.account: {\n const accountActionType = getAccountActionType(requestRenderingEvent);\n setScrollState(\n accountActionType === AccountAction.List ? ScrollState.onTop : ScrollState.unScrollable\n );\n break;\n }\n case WebComponentType.card: {\n if (customDialog === CustomDialog.addToWallet) {\n setScrollState(ScrollState.unScrollable);\n } else {\n setScrollState(ScrollState.onTop);\n }\n break;\n }\n default: {\n const nativePlace = requestRenderingEvent?.data.nativePlace;\n if (nativePlace == 'overFullScreen') {\n setScrollState(ScrollState.onTop);\n } else {\n setScrollState(ScrollState.unScrollable);\n }\n }\n }\n const nativePlace = requestRenderingEvent?.data.nativePlace;\n if (nativePlace == 'overFullScreen') {\n const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);\n setHeight(bottomSheetNewHeight);\n } else {\n setHeight((message.details as HeightEvent).height);\n }\n };\n\n const onWebMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case PageMessage.PAGE_HEIGHT:\n requestRenderingEvent && setNewHeightMessage(message);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const requestRendering = (message.details as RequestRenderingEvent);\n if (requestRendering.data.nativeComponent != requestRenderingEvent?.data?.nativeComponent) {\n if (requestRendering.data.nativeComponent.includes('action=AddToWallet')) {\n setCustomDialog(CustomDialog.addToWallet);\n }\n\n setHeight(0);\n setRequestRenderingEvent(requestRendering);\n setWaitForLoadingNewComponent(true);\n setTimeout(() => setWaitForLoadingNewComponent(false), 400);\n }\n break;\n }\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 handleCloseFlow();\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 const renderBottomSheetItem = () => {\n switch (customDialog) {\n case CustomDialog.addToWallet:\n return <UNAddToWalletBottomSheetItem renderingRequest={requestRenderingEvent} cardId={bottomSheetSlotData?.componentResourceId} />;\n default:\n return (\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 );\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 handleWebViewScroll={() => handleWebViewScroll()}\n shouldEnableBottomSheetScroll={scrollState !== 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AAKZ,WAAW,CAACc,KANvF;UAOE,YAAY,EAAE8D;QAPhB,EADF;IAJJ;EAgBD,CAjBD;;EAmBA,oBACE,yEACE,6BAAC,iBAAD;IACE,aAAa,EAAEzE,mBAAmB,GAAG+B,SAAH,GAAe,MADnD;IAEE,KAAK,EAAEX,MAAM,CAACmE;EAFhB,gBAIE,6BAAC,oBAAD;IACE,MAAM,EAAEvF,mBADV;IAEE,MAAM,EAAEG,MAFV;IAGE,OAAO,EAAE,MAAMF,sBAAsB,CAAC,KAAD,CAHvC;IAIE,MAAM,EAAE,MAAMA,sBAAsB,CAAC,IAAD,CAJtC;IAKE,mBAAmB,EAAE,MAAM+E,mBAAmB,EALhD;IAME,6BAA6B,EAAEvE,WAAW,KAAKZ,WAAW,CAACkF;EAN7D,GAQG7D,WAAW,IAAI+D,qBAAqB,EARvC,CAJF,CADF,CADF;AAmBD,CA5LM"}
|
|
@@ -5,16 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.resetHtml = exports.renderingBottomSheetRequest = exports.handleHtmlFullHeight = exports.getBottomSheetScript = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _bodyScript = require("./../../scripts/html/bodyScript");
|
|
9
9
|
|
|
10
10
|
var _UNBottomSheetComponent = require("./UNBottomSheetComponent.constants");
|
|
11
11
|
|
|
12
12
|
const getBottomSheetScript = () => {
|
|
13
|
-
return
|
|
14
|
-
window.addEventListener("${_unitMessages.UnitMessage.UNIT_REQUEST_REFRESH}", (e) => {
|
|
15
|
-
postMessageToSDK({ type: "${_unitMessages.UnitMessage.UNIT_REQUEST_REFRESH}", details: e.detail })
|
|
16
|
-
});
|
|
17
|
-
`;
|
|
13
|
+
return _bodyScript.LISTENERS.requestRefresh;
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
exports.getBottomSheetScript = getBottomSheetScript;
|
|
@@ -22,7 +18,7 @@ exports.getBottomSheetScript = getBottomSheetScript;
|
|
|
22
18
|
const renderingBottomSheetRequest = (currentWebView, renderingRequest) => {
|
|
23
19
|
currentWebView === null || currentWebView === void 0 ? void 0 : currentWebView.injectJavaScript(`
|
|
24
20
|
document.activeElement && document.activeElement.blur();
|
|
25
|
-
dispatchRenderingEvent('${renderingRequest}');
|
|
21
|
+
dispatchRenderingEvent('${JSON.stringify(renderingRequest.data)}');
|
|
26
22
|
`);
|
|
27
23
|
};
|
|
28
24
|
|
|
@@ -38,7 +34,7 @@ const resetHtml = currentWebView => {
|
|
|
38
34
|
exports.resetHtml = resetHtml;
|
|
39
35
|
|
|
40
36
|
const handleHtmlFullHeight = (currentWebView, windowHeight) => {
|
|
41
|
-
const bottomSheetHeight = windowHeight * _UNBottomSheetComponent.
|
|
37
|
+
const bottomSheetHeight = windowHeight * _UNBottomSheetComponent.BOTTOM_SHEET_MAX_PERCENTAGE_SIZE;
|
|
42
38
|
currentWebView && (currentWebView === null || currentWebView === void 0 ? void 0 : currentWebView.injectJavaScript(`
|
|
43
39
|
document.getElementById('webViewContainer').style.height = '${bottomSheetHeight}px';
|
|
44
40
|
`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getBottomSheetScript","
|
|
1
|
+
{"version":3,"names":["getBottomSheetScript","LISTENERS","requestRefresh","renderingBottomSheetRequest","currentWebView","renderingRequest","injectJavaScript","JSON","stringify","data","resetHtml","handleHtmlFullHeight","windowHeight","bottomSheetHeight","BOTTOM_SHEET_MAX_PERCENTAGE_SIZE"],"sources":["UNBottomSheetComponent.utils.ts"],"sourcesContent":["import { LISTENERS } from './../../scripts/html/bodyScript';\nimport type WebView from 'react-native-webview';\nimport { BOTTOM_SHEET_MAX_PERCENTAGE_SIZE } from './UNBottomSheetComponent.constants';\nimport type { RequestRenderingEvent } from '../../messages/webMessages/unitMessages';\n\nexport const getBottomSheetScript = () => {\n return LISTENERS.requestRefresh;\n};\n\nexport const renderingBottomSheetRequest = (currentWebView: WebView, renderingRequest: RequestRenderingEvent) => {\n currentWebView?.injectJavaScript(`\n document.activeElement && document.activeElement.blur();\n dispatchRenderingEvent('${JSON.stringify(renderingRequest.data)}');\n `);\n};\n\nexport const resetHtml = (currentWebView: WebView) => {\n currentWebView?.injectJavaScript(`\n document.activeElement && document.activeElement.blur();\n document.getElementById('webViewContainer').style.height = null;\n `);\n};\n\nexport const handleHtmlFullHeight = (currentWebView: WebView | null, windowHeight: number) => {\n const bottomSheetHeight = windowHeight * BOTTOM_SHEET_MAX_PERCENTAGE_SIZE;\n currentWebView && currentWebView?.injectJavaScript(`\n document.getElementById('webViewContainer').style.height = '${bottomSheetHeight}px';\n `);\n\n return bottomSheetHeight;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAGO,MAAMA,oBAAoB,GAAG,MAAM;EACxC,OAAOC,qBAAA,CAAUC,cAAjB;AACD,CAFM;;;;AAIA,MAAMC,2BAA2B,GAAG,CAACC,cAAD,EAA0BC,gBAA1B,KAAsE;EAC/GD,cAAc,SAAd,IAAAA,cAAc,WAAd,YAAAA,cAAc,CAAEE,gBAAhB,CAAkC;AACpC;AACA,8BAA8BC,IAAI,CAACC,SAAL,CAAeH,gBAAgB,CAACI,IAAhC,CAAsC;AACpE,GAHE;AAID,CALM;;;;AAOA,MAAMC,SAAS,GAAIN,cAAD,IAA6B;EACpDA,cAAc,SAAd,IAAAA,cAAc,WAAd,YAAAA,cAAc,CAAEE,gBAAhB,CAAkC;AACpC;AACA;AACA,GAHE;AAID,CALM;;;;AAOA,MAAMK,oBAAoB,GAAG,CAACP,cAAD,EAAiCQ,YAAjC,KAA0D;EAC5F,MAAMC,iBAAiB,GAAGD,YAAY,GAAGE,wDAAzC;EACAV,cAAc,KAAIA,cAAJ,aAAIA,cAAJ,uBAAIA,cAAc,CAAEE,gBAAhB,CAAkC;AACtD,kEAAkEO,iBAAkB;AACpF,GAFoB,CAAJ,CAAd;EAIA,OAAOA,iBAAP;AACD,CAPM"}
|
package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UNAddToWalletBottomSheetItem = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _cardMessage = require("../../../messages/nativeMessages/cardMessage");
|
|
11
|
+
|
|
12
|
+
var _EventBus = _interopRequireDefault(require("../../../helpers/EventBus"));
|
|
13
|
+
|
|
14
|
+
var _bodyHtml = require("../../../scripts/html/bodyHtml");
|
|
15
|
+
|
|
16
|
+
var _WebComponent = require("../../../webComponent/WebComponent");
|
|
17
|
+
|
|
18
|
+
var _UNBottomSheetComponent = require("../UNBottomSheetComponent.utils");
|
|
19
|
+
|
|
20
|
+
var _UNAddToWalletBottomSheetItem = require("./UNAddToWalletBottomSheetItem.styles");
|
|
21
|
+
|
|
22
|
+
var _reactNative = require("react-native");
|
|
23
|
+
|
|
24
|
+
var _listenerToBus = require("../../../hooks/listenerToBus");
|
|
25
|
+
|
|
26
|
+
var _UnitAddToWalletButton = _interopRequireDefault(require("../../../nativeComponent/UnitAddToWalletButton"));
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
|
|
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); }
|
|
31
|
+
|
|
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; }
|
|
33
|
+
|
|
34
|
+
const UNAddToWalletBottomSheetItem = props => {
|
|
35
|
+
const styles = (0, _UNAddToWalletBottomSheetItem.getStylesObject)();
|
|
36
|
+
const webRef = (0, _react.useRef)(null);
|
|
37
|
+
const {
|
|
38
|
+
renderingRequest,
|
|
39
|
+
cardId
|
|
40
|
+
} = props;
|
|
41
|
+
const [addToWalletStatus, setAddToWalletStatus] = (0, _react.useState)(_cardMessage.CardAddToWalletStatus.pending);
|
|
42
|
+
(0, _react.useEffect)(() => {
|
|
43
|
+
if (!cardId) return;
|
|
44
|
+
const event = {
|
|
45
|
+
cardId
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
_EventBus.default.Instance.event(_cardMessage.CardNativeMessage.CARD_GET_ADD_TO_WALLET_STATUS, event);
|
|
49
|
+
}, [cardId]);
|
|
50
|
+
(0, _react.useEffect)(() => {
|
|
51
|
+
if (!webRef.current) return;
|
|
52
|
+
if (addToWalletStatus === _cardMessage.CardAddToWalletStatus.pending) return;
|
|
53
|
+
const isCardInWallet = addToWalletStatus === _cardMessage.CardAddToWalletStatus.addedToWallet;
|
|
54
|
+
webRef.current.injectJavaScript(`window.UnitMobileSDKConfig["isCardInWallet"] = ${isCardInWallet}`);
|
|
55
|
+
|
|
56
|
+
if (renderingRequest) {
|
|
57
|
+
(0, _UNBottomSheetComponent.renderingBottomSheetRequest)(webRef.current, renderingRequest);
|
|
58
|
+
}
|
|
59
|
+
}, [webRef.current, renderingRequest, addToWalletStatus]);
|
|
60
|
+
|
|
61
|
+
const gotCardWalletStatus = data => {
|
|
62
|
+
if (data != null) {
|
|
63
|
+
setAddToWalletStatus(data.status);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
(0, _listenerToBus.useListenerToBus)([{
|
|
68
|
+
busEventKey: _cardMessage.CardNativeMessage.CARD_UPDATE_ADD_TO_WALLET_STATUS,
|
|
69
|
+
action: gotCardWalletStatus
|
|
70
|
+
}]);
|
|
71
|
+
|
|
72
|
+
const handleAddToWalletClicked = () => {
|
|
73
|
+
if (!cardId) return;
|
|
74
|
+
const startPushProvisioningEvent = {
|
|
75
|
+
cardId
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
_EventBus.default.Instance.event(_cardMessage.CardNativeMessage.CARD_START_PUSH_PROVISIONING, startPushProvisioningEvent);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
|
|
82
|
+
ref: webRef,
|
|
83
|
+
type: _WebComponent.WebComponentType.slot,
|
|
84
|
+
presentationMode: _bodyHtml.PresentationMode.CoverInjectedHeight,
|
|
85
|
+
isScrollable: false
|
|
86
|
+
}), addToWalletStatus === _cardMessage.CardAddToWalletStatus.pending && /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
|
|
87
|
+
style: styles.loader
|
|
88
|
+
}), addToWalletStatus === _cardMessage.CardAddToWalletStatus.readyToProvisioning && /*#__PURE__*/_react.default.createElement(_UnitAddToWalletButton.default, {
|
|
89
|
+
style: styles.addToWalletButton,
|
|
90
|
+
onAddToWalletClicked: handleAddToWalletClicked
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
exports.UNAddToWalletBottomSheetItem = UNAddToWalletBottomSheetItem;
|
|
95
|
+
//# sourceMappingURL=UNAddToWalletBottomSheetItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UNAddToWalletBottomSheetItem","props","styles","getStylesObject","webRef","useRef","renderingRequest","cardId","addToWalletStatus","setAddToWalletStatus","useState","CardAddToWalletStatus","pending","useEffect","event","EventBus","Instance","CardNativeMessage","CARD_GET_ADD_TO_WALLET_STATUS","current","isCardInWallet","addedToWallet","injectJavaScript","renderingBottomSheetRequest","gotCardWalletStatus","data","status","useListenerToBus","busEventKey","CARD_UPDATE_ADD_TO_WALLET_STATUS","action","handleAddToWalletClicked","startPushProvisioningEvent","CARD_START_PUSH_PROVISIONING","WebComponentType","slot","PresentationMode","CoverInjectedHeight","loader","readyToProvisioning","addToWalletButton"],"sources":["UNAddToWalletBottomSheetItem.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport type WebView from 'react-native-webview';\nimport { CardAddToWalletStatus, CardAddToWalletStatusEvent, CardGetAddToWalletStatusEvent, CardNativeMessage, CardStartPushProvisioningEvent } from '../../../messages/nativeMessages/cardMessage';\nimport EventBus from '../../../helpers/EventBus';\nimport { PresentationMode } from '../../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../../webComponent/WebComponent';\nimport { renderingBottomSheetRequest } from '../UNBottomSheetComponent.utils';\nimport { getStylesObject } from './UNAddToWalletBottomSheetItem.styles';\nimport { ActivityIndicator } from 'react-native';\nimport { useListenerToBus } from '../../../hooks/listenerToBus';\nimport type { RequestRenderingEvent } from '../../../messages/webMessages/unitMessages';\nimport UnitAddToWalletButtonView from '../../../nativeComponent/UnitAddToWalletButton';\n\nexport interface UNAddToWalletBottomSheetItemProps {\n renderingRequest?: RequestRenderingEvent\n cardId?: string\n}\n\nexport const UNAddToWalletBottomSheetItem = (props: UNAddToWalletBottomSheetItemProps) => {\n const styles = getStylesObject();\n\n const webRef = useRef<WebView>(null);\n\n const { renderingRequest, cardId } = props;\n\n const [addToWalletStatus, setAddToWalletStatus] = useState<CardAddToWalletStatus>(CardAddToWalletStatus.pending);\n\n useEffect(() => {\n if (!cardId) return;\n const event: CardGetAddToWalletStatusEvent = { cardId };\n EventBus.Instance.event(CardNativeMessage.CARD_GET_ADD_TO_WALLET_STATUS, event);\n }, [cardId]);\n\n useEffect(() => {\n if (!webRef.current) return;\n if (addToWalletStatus === CardAddToWalletStatus.pending) return;\n\n const isCardInWallet = addToWalletStatus === CardAddToWalletStatus.addedToWallet;\n webRef.current.injectJavaScript(`window.UnitMobileSDKConfig[\"isCardInWallet\"] = ${isCardInWallet}`);\n\n if (renderingRequest) {\n renderingBottomSheetRequest(webRef.current, renderingRequest);\n }\n }, [webRef.current, renderingRequest, addToWalletStatus]);\n\n const gotCardWalletStatus = (data?: CardAddToWalletStatusEvent) => {\n if (data != null) {\n setAddToWalletStatus(data.status);\n }\n };\n\n useListenerToBus([\n { busEventKey: CardNativeMessage.CARD_UPDATE_ADD_TO_WALLET_STATUS, action: gotCardWalletStatus },\n ]);\n\n const handleAddToWalletClicked = () => {\n if (!cardId) return;\n const startPushProvisioningEvent: CardStartPushProvisioningEvent = { cardId };\n EventBus.Instance.event(CardNativeMessage.CARD_START_PUSH_PROVISIONING, startPushProvisioningEvent);\n };\n\n return (\n <>\n <WebComponent\n ref={webRef}\n type={WebComponentType.slot}\n presentationMode={PresentationMode.CoverInjectedHeight}\n isScrollable={false}\n />\n {addToWalletStatus === CardAddToWalletStatus.pending && <ActivityIndicator style={styles.loader} />}\n {addToWalletStatus === CardAddToWalletStatus.readyToProvisioning && <UnitAddToWalletButtonView style={styles.addToWalletButton} onAddToWalletClicked={handleAddToWalletClicked} />}\n </>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;AAOO,MAAMA,4BAA4B,GAAIC,KAAD,IAA8C;EACxF,MAAMC,MAAM,GAAG,IAAAC,6CAAA,GAAf;EAEA,MAAMC,MAAM,GAAG,IAAAC,aAAA,EAAgB,IAAhB,CAAf;EAEA,MAAM;IAAEC,gBAAF;IAAoBC;EAApB,IAA+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