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.
Files changed (213) hide show
  1. package/README.md +75 -6
  2. package/android/src/main/AndroidManifest.xml +12 -1
  3. package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -1
  4. package/android/src/main/java/com/unitreactnativecomponents/sharepdf/UNSharePDF.kt +75 -0
  5. package/android/src/main/res/layout/un_black_add_to_googlepay_button.xml +2 -2
  6. package/android/src/main/res/layout/un_view_google_push_provisioning.xml +1 -13
  7. package/android/src/main/res/layout/un_white_add_to_googlepay_button.xml +1 -1
  8. package/android/src/main/res/layout/un_white_add_to_googlepay_button_no_shadow.xml +1 -1
  9. package/android/src/main/res/xml/file_paths.xml +4 -0
  10. package/ios/UnitReactNativeComponentsViewManager.m +0 -1
  11. package/ios/UnitReactNativeComponentsViewManager.swift +6 -2
  12. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +103 -0
  13. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
  14. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +47 -0
  15. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
  16. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +28 -4
  17. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  18. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +19 -1
  19. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  20. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +22 -10
  21. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  22. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +4 -0
  23. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  24. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +3 -3
  25. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
  26. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +114 -46
  27. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  28. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +4 -8
  29. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
  30. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +95 -0
  31. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
  32. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +31 -0
  33. package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
  34. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +64 -7
  35. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  36. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +62 -8
  37. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  38. package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js +20 -0
  39. package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
  40. package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +42 -0
  41. package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
  42. package/lib/commonjs/components/index.js +13 -0
  43. package/lib/commonjs/components/index.js.map +1 -1
  44. package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +32 -12
  45. package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
  46. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +1 -1
  47. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
  48. package/lib/commonjs/helpers/EventBus.js.map +1 -1
  49. package/lib/commonjs/messages/nativeMessages/cardMessage.js +36 -0
  50. package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -0
  51. package/lib/commonjs/messages/nativeMessages/index.js +0 -8
  52. package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
  53. package/lib/commonjs/messages/nativeMessages/sdkMessage.js +14 -0
  54. package/lib/commonjs/messages/nativeMessages/sdkMessage.js.map +1 -0
  55. package/lib/commonjs/messages/webMessages/unitMessages.js +1 -0
  56. package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
  57. package/lib/commonjs/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
  58. package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js.map +1 -0
  59. package/lib/commonjs/scripts/html/bodyScript.js +22 -5
  60. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
  61. package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
  62. package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
  63. package/lib/commonjs/sharedTypes/index.js +13 -0
  64. package/lib/commonjs/sharedTypes/index.js.map +1 -1
  65. package/lib/commonjs/sharedTypes/onLoadResponse.types.js +6 -0
  66. package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -0
  67. package/lib/commonjs/sharedTypes/wallet.types.js +22 -0
  68. package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -0
  69. package/lib/commonjs/unitSdkManager/UnitSdk.api.js +5 -3
  70. package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -1
  71. package/lib/commonjs/unitSdkManager/UnitSdkManager.js +12 -2
  72. package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
  73. package/lib/commonjs/webComponent/WebComponent.js +20 -8
  74. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  75. package/lib/commonjs/webComponent/WebComponent.utils.js +41 -0
  76. package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -0
  77. package/lib/commonjs/webComponent/html.js +9 -1
  78. package/lib/commonjs/webComponent/html.js.map +1 -1
  79. package/lib/module/components/UNAccountComponent/UNAccountComponent.js +74 -0
  80. package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
  81. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +26 -0
  82. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
  83. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +28 -6
  84. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  85. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -0
  86. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  87. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +21 -10
  88. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  89. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -0
  90. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  91. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +1 -1
  92. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
  93. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +111 -46
  94. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  95. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +5 -9
  96. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
  97. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +68 -0
  98. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
  99. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +21 -0
  100. package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
  101. package/lib/module/components/UNCardComponent/UNCardComponent.js +64 -9
  102. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  103. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +51 -7
  104. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  105. package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js +10 -0
  106. package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
  107. package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +28 -0
  108. package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
  109. package/lib/module/components/index.js +1 -0
  110. package/lib/module/components/index.js.map +1 -1
  111. package/lib/module/helpers/BottomSheet/BottomSheet.js +30 -13
  112. package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
  113. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +2 -2
  114. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
  115. package/lib/module/helpers/EventBus.js.map +1 -1
  116. package/lib/module/messages/nativeMessages/cardMessage.js +27 -0
  117. package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -0
  118. package/lib/module/messages/nativeMessages/index.js +1 -6
  119. package/lib/module/messages/nativeMessages/index.js.map +1 -1
  120. package/lib/module/messages/nativeMessages/sdkMessage.js +7 -0
  121. package/lib/module/messages/nativeMessages/sdkMessage.js.map +1 -0
  122. package/lib/module/messages/webMessages/unitMessages.js +1 -0
  123. package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
  124. package/lib/module/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
  125. package/lib/module/nativeComponent/UnitAddToWalletButton.js.map +1 -0
  126. package/lib/module/scripts/html/bodyScript.js +19 -3
  127. package/lib/module/scripts/html/bodyScript.js.map +1 -1
  128. package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
  129. package/lib/module/sharedTypes/card.types.js.map +1 -1
  130. package/lib/module/sharedTypes/index.js +1 -0
  131. package/lib/module/sharedTypes/index.js.map +1 -1
  132. package/lib/module/sharedTypes/onLoadResponse.types.js +2 -0
  133. package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -0
  134. package/lib/module/sharedTypes/wallet.types.js +14 -0
  135. package/lib/module/sharedTypes/wallet.types.js.map +1 -0
  136. package/lib/module/unitSdkManager/UnitSdk.api.js +4 -3
  137. package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -1
  138. package/lib/module/unitSdkManager/UnitSdkManager.js +12 -2
  139. package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
  140. package/lib/module/webComponent/WebComponent.js +18 -7
  141. package/lib/module/webComponent/WebComponent.js.map +1 -1
  142. package/lib/module/webComponent/WebComponent.utils.js +27 -0
  143. package/lib/module/webComponent/WebComponent.utils.js.map +1 -0
  144. package/lib/module/webComponent/html.js +9 -2
  145. package/lib/module/webComponent/html.js.map +1 -1
  146. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +12 -0
  147. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +7 -0
  148. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -0
  149. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +4 -0
  150. package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -1
  151. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -1
  152. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +9 -2
  153. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +2 -1
  154. package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.d.ts +6 -0
  155. package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.d.ts +17 -0
  156. package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +4 -1
  157. package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +9 -1
  158. package/lib/typescript/components/UNCardComponent/networking/common/UNNetworkConstants.d.ts +8 -0
  159. package/lib/typescript/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.d.ts +2 -0
  160. package/lib/typescript/components/index.d.ts +1 -0
  161. package/lib/typescript/helpers/EventBus.d.ts +3 -3
  162. package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +28 -0
  163. package/lib/typescript/messages/nativeMessages/index.d.ts +7 -3
  164. package/lib/typescript/messages/nativeMessages/sdkMessage.d.ts +8 -0
  165. package/lib/typescript/messages/webMessages/unitMessages.d.ts +16 -6
  166. package/lib/typescript/scripts/html/bodyScript.d.ts +4 -1
  167. package/lib/typescript/sharedTypes/bookPayment.types.d.ts +3 -3
  168. package/lib/typescript/sharedTypes/card.types.d.ts +6 -6
  169. package/lib/typescript/sharedTypes/index.d.ts +1 -0
  170. package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +18 -0
  171. package/lib/typescript/sharedTypes/wallet.types.d.ts +14 -0
  172. package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +3 -0
  173. package/lib/typescript/webComponent/WebComponent.d.ts +2 -1
  174. package/lib/typescript/webComponent/WebComponent.utils.d.ts +2 -0
  175. package/package.json +2 -1
  176. package/src/components/UNAccountComponent/UNAccountComponent.tsx +82 -0
  177. package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +30 -0
  178. package/src/components/UNActivityComponent/UNActivityComponent.tsx +28 -5
  179. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +14 -0
  180. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +18 -10
  181. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +3 -0
  182. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -1
  183. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +120 -44
  184. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +7 -10
  185. package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.ts +21 -0
  186. package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +74 -0
  187. package/src/components/UNCardComponent/UNCardComponent.tsx +67 -13
  188. package/src/components/UNCardComponent/UNCardComponent.utils.ts +51 -7
  189. package/src/components/UNCardComponent/networking/common/UNNetworkConstants.ts +11 -0
  190. package/src/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.ts +32 -0
  191. package/src/components/index.ts +1 -0
  192. package/src/helpers/BottomSheet/BottomSheet.styles.ts +2 -2
  193. package/src/helpers/BottomSheet/BottomSheet.tsx +28 -12
  194. package/src/helpers/EventBus.ts +3 -3
  195. package/src/messages/nativeMessages/cardMessage.ts +37 -0
  196. package/src/messages/nativeMessages/index.ts +14 -3
  197. package/src/messages/nativeMessages/sdkMessage.ts +11 -0
  198. package/src/messages/webMessages/unitMessages.ts +20 -7
  199. package/src/scripts/html/bodyScript.ts +21 -4
  200. package/src/sharedTypes/bookPayment.types.ts +3 -3
  201. package/src/sharedTypes/card.types.ts +6 -6
  202. package/src/sharedTypes/index.ts +1 -0
  203. package/src/sharedTypes/onLoadResponse.types.ts +27 -0
  204. package/src/sharedTypes/wallet.types.ts +17 -0
  205. package/src/unitSdkManager/UnitSdk.api.ts +3 -2
  206. package/src/unitSdkManager/UnitSdkManager.ts +11 -2
  207. package/src/webComponent/WebComponent.tsx +21 -10
  208. package/src/webComponent/WebComponent.utils.ts +26 -0
  209. package/src/webComponent/html.ts +9 -2
  210. package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
  211. package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
  212. /package/lib/typescript/nativeComponent/{UNNativeAddToWalletButton.d.ts → UnitAddToWalletButton.d.ts} +0 -0
  213. /package/src/nativeComponent/{UNNativeAddToWalletButton.tsx → UnitAddToWalletButton.tsx} +0 -0
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = exports.HTML_PLACEHOLDER = void 0;
7
7
 
8
+ var _reactNative = require("react-native");
9
+
8
10
  var _bodyScript = require("../scripts/html/bodyScript");
9
11
 
10
12
  const HTML_PLACEHOLDER = {
@@ -21,6 +23,10 @@ const htmlText = `
21
23
  <title>Unit Web SDK Demo</title>
22
24
  <script>
23
25
  window.UnitMobileSDK = true
26
+ window.UnitMobileSDKConfig = {
27
+ os: "${_reactNative.Platform.OS}",
28
+ walletName: "${_reactNative.Platform.OS === 'ios' ? 'Apple' : 'Google'}"
29
+ }
24
30
  </script>
25
31
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
26
32
  </html>
@@ -37,6 +43,8 @@ const htmlText = `
37
43
 
38
44
  ${_bodyScript.LISTENERS.onLoad}
39
45
 
46
+ ${_bodyScript.LISTENERS.unitRequestDownload}
47
+
40
48
  ${_bodyScript.LISTENERS.requestRendering}
41
49
 
42
50
  ${_bodyScript.LISTENERS.requestOpenLink}
@@ -45,7 +53,7 @@ const htmlText = `
45
53
 
46
54
  ${_bodyScript.LISTENERS.cardStatusChange}
47
55
 
48
- ${_bodyScript.DISPTACH_RENDERING_EVENT}
56
+ ${_bodyScript.DISPATCH_RENDERING_EVENT}
49
57
 
50
58
  ${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}
51
59
  </script>
@@ -1 +1 @@
1
- {"version":3,"names":["HTML_PLACEHOLDER","SCRIPT_UNIT","BODY","SCRIPT_FROM_NATIVE","htmlText","POST_MESSAGE_TO_SDK","POST_PAGE_HEIGHT","LISTENERS","isPageLoaded","onLoad","requestRendering","requestOpenLink","requestCloseFlow","cardStatusChange","DISPTACH_RENDERING_EVENT"],"sources":["html.ts"],"sourcesContent":["import { DISPTACH_RENDERING_EVENT, LISTENERS, POST_MESSAGE_TO_SDK, POST_PAGE_HEIGHT } from '../scripts/html/bodyScript';\n\nexport const HTML_PLACEHOLDER = {\n SCRIPT_UNIT: '<SCRIPT_UNIT>',\n BODY: '<BODY_HTML_CODE>',\n SCRIPT_FROM_NATIVE: '<SCRIPT_FROM_NATIVE>'\n};\n\nconst htmlText = `\n <!DOCTYPE html>\n <html lang=\"en\">\n\n <head lang=\"en\">\n <title>Unit Web SDK Demo</title>\n <script>\n window.UnitMobileSDK = true\n </script>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=0\">\n </html>\n\n <body style=\"margin: 0;\">\n ${HTML_PLACEHOLDER.BODY}\n\n <script>\n ${POST_MESSAGE_TO_SDK}\n\n ${POST_PAGE_HEIGHT}\n\n ${LISTENERS.isPageLoaded}\n\n ${LISTENERS.onLoad}\n\n ${LISTENERS.requestRendering}\n\n ${LISTENERS.requestOpenLink}\n\n ${LISTENERS.requestCloseFlow}\n\n ${LISTENERS.cardStatusChange}\n\n ${DISPTACH_RENDERING_EVENT}\n\n ${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}\n </script>\n </body>\n`;\n\nexport default htmlText;\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,gBAAgB,GAAG;EAC9BC,WAAW,EAAE,eADiB;EAE9BC,IAAI,EAAE,kBAFwB;EAG9BC,kBAAkB,EAAE;AAHU,CAAzB;;AAMP,MAAMC,QAAQ,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMJ,gBAAgB,CAACE,IAAK;AAC5B;AACA;AACA,QAAQG,+BAAoB;AAC5B;AACA,QAAQC,4BAAiB;AACzB;AACA,QAAQC,qBAAA,CAAUC,YAAa;AAC/B;AACA,QAAQD,qBAAA,CAAUE,MAAO;AACzB;AACA,QAAQF,qBAAA,CAAUG,gBAAiB;AACnC;AACA,QAAQH,qBAAA,CAAUI,eAAgB;AAClC;AACA,QAAQJ,qBAAA,CAAUK,gBAAiB;AACnC;AACA,QAAQL,qBAAA,CAAUM,gBAAiB;AACnC;AACA,QAAQC,oCAAyB;AACjC;AACA,QAAQd,gBAAgB,CAACG,kBAAmB;AAC5C;AACA;AACA,CArCA;eAuCeC,Q"}
1
+ {"version":3,"names":["HTML_PLACEHOLDER","SCRIPT_UNIT","BODY","SCRIPT_FROM_NATIVE","htmlText","Platform","OS","POST_MESSAGE_TO_SDK","POST_PAGE_HEIGHT","LISTENERS","isPageLoaded","onLoad","unitRequestDownload","requestRendering","requestOpenLink","requestCloseFlow","cardStatusChange","DISPATCH_RENDERING_EVENT"],"sources":["html.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport { DISPATCH_RENDERING_EVENT, LISTENERS, POST_MESSAGE_TO_SDK, POST_PAGE_HEIGHT } from '../scripts/html/bodyScript';\n\nexport const HTML_PLACEHOLDER = {\n SCRIPT_UNIT: '<SCRIPT_UNIT>',\n BODY: '<BODY_HTML_CODE>',\n SCRIPT_FROM_NATIVE: '<SCRIPT_FROM_NATIVE>'\n};\n\nconst htmlText = `\n <!DOCTYPE html>\n <html lang=\"en\">\n\n <head lang=\"en\">\n <title>Unit Web SDK Demo</title>\n <script>\n window.UnitMobileSDK = true\n window.UnitMobileSDKConfig = {\n os: \"${Platform.OS}\",\n walletName: \"${Platform.OS === 'ios' ? 'Apple' : 'Google'}\"\n }\n </script>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=0\">\n </html>\n\n <body style=\"margin: 0;\">\n ${HTML_PLACEHOLDER.BODY}\n\n <script>\n ${POST_MESSAGE_TO_SDK}\n\n ${POST_PAGE_HEIGHT}\n\n ${LISTENERS.isPageLoaded}\n\n ${LISTENERS.onLoad}\n\n ${LISTENERS.unitRequestDownload}\n\n ${LISTENERS.requestRendering}\n\n ${LISTENERS.requestOpenLink}\n\n ${LISTENERS.requestCloseFlow}\n\n ${LISTENERS.cardStatusChange}\n\n ${DISPATCH_RENDERING_EVENT}\n\n ${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}\n </script>\n </body>\n`;\n\nexport default htmlText;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,gBAAgB,GAAG;EAC9BC,WAAW,EAAE,eADiB;EAE9BC,IAAI,EAAE,kBAFwB;EAG9BC,kBAAkB,EAAE;AAHU,CAAzB;;AAMP,MAAMC,QAAQ,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,qBAAA,CAASC,EAAG;AAC3B,uBAAuBD,qBAAA,CAASC,EAAT,KAAgB,KAAhB,GAAwB,OAAxB,GAAkC,QAAS;AAClE;AACA;AACA;AACA;AACA;AACA;AACA,MAAMN,gBAAgB,CAACE,IAAK;AAC5B;AACA;AACA,QAAQK,+BAAoB;AAC5B;AACA,QAAQC,4BAAiB;AACzB;AACA,QAAQC,qBAAA,CAAUC,YAAa;AAC/B;AACA,QAAQD,qBAAA,CAAUE,MAAO;AACzB;AACA,QAAQF,qBAAA,CAAUG,mBAAoB;AACtC;AACA,QAAQH,qBAAA,CAAUI,gBAAiB;AACnC;AACA,QAAQJ,qBAAA,CAAUK,eAAgB;AAClC;AACA,QAAQL,qBAAA,CAAUM,gBAAiB;AACnC;AACA,QAAQN,qBAAA,CAAUO,gBAAiB;AACnC;AACA,QAAQC,oCAAyB;AACjC;AACA,QAAQjB,gBAAgB,CAACG,kBAAmB;AAC5C;AACA;AACA,CA3CA;eA6CeC,Q"}
@@ -0,0 +1,74 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { Dimensions, View } from 'react-native';
3
+ import { PageMessage } from '../..//messages/webMessages/pageMessage';
4
+ import { UnitMessage } from '../../messages/webMessages/unitMessages';
5
+ import EventBus from '../../helpers/EventBus';
6
+ import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
7
+ import { useListenerToBus } from '../../hooks/listenerToBus';
8
+ import { getAccountParams, getAccountScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';
9
+ import { PresentationMode } from '../../scripts/html/bodyHtml';
10
+ export let AccountAction;
11
+
12
+ (function (AccountAction) {
13
+ AccountAction["List"] = "account-list";
14
+ AccountAction["Menu"] = "account-menu";
15
+ })(AccountAction || (AccountAction = {}));
16
+
17
+ export const UNAccountComponent = props => {
18
+ const [height, setHeight] = useState(0);
19
+ const windowWidth = Dimensions.get('window').width;
20
+ const [requestRefreshEvent, setRequestRefreshEvent] = useState(null);
21
+ const webRef = useRef(null);
22
+
23
+ const requestRefresh = data => {
24
+ setRequestRefreshEvent(data);
25
+ };
26
+
27
+ useListenerToBus([{
28
+ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH,
29
+ action: requestRefresh
30
+ }]);
31
+ useEffect(() => {
32
+ injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);
33
+ }, [requestRefreshEvent]);
34
+
35
+ const handleMessage = message => {
36
+ switch (message.type) {
37
+ case UnitMessage.UNIT_ON_LOAD:
38
+ props.onLoad && props.onLoad(message.details);
39
+ break;
40
+
41
+ case UnitMessage.UNIT_REQUEST_RENDERING:
42
+ {
43
+ const event = {
44
+ componentName: WebComponentType.account,
45
+ componentResourceId: props.accountId,
46
+ requestRenderingEvent: message.details
47
+ };
48
+ EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, event);
49
+ break;
50
+ }
51
+
52
+ case PageMessage.PAGE_HEIGHT:
53
+ setHeight(message.details.height);
54
+ break;
55
+ }
56
+ };
57
+
58
+ return /*#__PURE__*/React.createElement(View, {
59
+ style: {
60
+ height
61
+ }
62
+ }, /*#__PURE__*/React.createElement(WebComponent, {
63
+ ref: webRef,
64
+ type: WebComponentType.account,
65
+ presentationMode: PresentationMode.Default,
66
+ params: getAccountParams(props),
67
+ script: getAccountScript(),
68
+ theme: props.theme,
69
+ onMessage: message => handleMessage(message),
70
+ width: windowWidth,
71
+ isScrollable: false
72
+ }));
73
+ };
74
+ //# sourceMappingURL=UNAccountComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useRef","useState","Dimensions","View","PageMessage","UnitMessage","EventBus","WebComponent","WebComponentType","useListenerToBus","getAccountParams","getAccountScript","injectRefreshEventIfNeeded","PresentationMode","AccountAction","UNAccountComponent","props","height","setHeight","windowWidth","get","width","requestRefreshEvent","setRequestRefreshEvent","webRef","requestRefresh","data","busEventKey","UNIT_REQUEST_REFRESH","action","current","handleMessage","message","type","UNIT_ON_LOAD","onLoad","details","UNIT_REQUEST_RENDERING","event","componentName","account","componentResourceId","accountId","requestRenderingEvent","Instance","PAGE_HEIGHT","Default","theme"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';\nimport type { ResponseUnitOnLoadEvent } from '../../sharedTypes';\n\nexport interface UNAccountComponentProps {\n accountId?: string;\n customerToken: string;\n theme?: string;\n onLoad?: (response: ResponseUnitOnLoadEvent) => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = (props: UNAccountComponentProps) => {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n useListenerToBus([\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as ResponseUnitOnLoadEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const event: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAEA,SAAsBC,WAAtB,QAAyC,yCAAzC;AACA,SAAqDC,WAArD,QAAwE,yCAAxE;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,gBAAT,QAAiC,2BAAjC;AAEA,SAASC,gBAAT,EAA2BC,gBAA3B,EAA6CC,0BAA7C,QAA+E,4BAA/E;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AAWA,WAAYC,aAAZ;;WAAYA,a;EAAAA,a;EAAAA,a;GAAAA,a,KAAAA,a;;AAKZ,OAAO,MAAMC,kBAAkB,GAAIC,KAAD,IAAoC;EACpE,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBjB,QAAQ,CAAC,CAAD,CAApC;EACA,MAAMkB,WAAW,GAAGjB,UAAU,CAACkB,GAAX,CAAe,QAAf,EAAyBC,KAA7C;EAEA,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgDtB,QAAQ,CAA6B,IAA7B,CAA9D;EAEA,MAAMuB,MAAM,GAAGxB,MAAM,CAAU,IAAV,CAArB;;EAEA,MAAMyB,cAAc,GAAIC,IAAD,IAA+B;IACpDH,sBAAsB,CAACG,IAAD,CAAtB;EACD,CAFD;;EAIAjB,gBAAgB,CAAC,CACf;IAAEkB,WAAW,EAAEtB,WAAW,CAACuB,oBAA3B;IAAiDC,MAAM,EAAEJ;EAAzD,CADe,CAAD,CAAhB;EAIA1B,SAAS,CAAC,MAAM;IACda,0BAA0B,CAACY,MAAM,CAACM,OAAR,EAAiBR,mBAAjB,CAA1B;EACD,CAFQ,EAEN,CAACA,mBAAD,CAFM,CAAT;;EAIA,MAAMS,aAAa,GAAIC,OAAD,IAA6B;IACjD,QAAQA,OAAO,CAACC,IAAhB;MACE,KAAK5B,WAAW,CAAC6B,YAAjB;QACElB,KAAK,CAACmB,MAAN,IAAgBnB,KAAK,CAACmB,MAAN,CAAaH,OAAO,CAACI,OAArB,CAAhB;QACA;;MACF,KAAK/B,WAAW,CAACgC,sBAAjB;QAAyC;UACvC,MAAMC,KAA0B,GAAG;YACjCC,aAAa,EAAE/B,gBAAgB,CAACgC,OADC;YAEjCC,mBAAmB,EAAEzB,KAAK,CAAC0B,SAFM;YAGjCC,qBAAqB,EAAEX,OAAO,CAACI;UAHE,CAAnC;UAKA9B,QAAQ,CAACsC,QAAT,CAAkBN,KAAlB,CAAwBjC,WAAW,CAACgC,sBAApC,EAA4DC,KAA5D;UACA;QACD;;MACD,KAAKlC,WAAW,CAACyC,WAAjB;QACE3B,SAAS,CAAEc,OAAO,CAACI,OAAT,CAAiCnB,MAAlC,CAAT;QACA;IAfJ;EAiBD,CAlBD;;EAoBA,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEA;IAAF;EAAb,gBACE,oBAAC,YAAD;IACE,GAAG,EAAEO,MADP;IAEE,IAAI,EAAEhB,gBAAgB,CAACgC,OAFzB;IAGE,gBAAgB,EAAE3B,gBAAgB,CAACiC,OAHrC;IAIE,MAAM,EAAEpC,gBAAgB,CAACM,KAAD,CAJ1B;IAKE,MAAM,EAAEL,gBAAgB,EAL1B;IAME,KAAK,EAAEK,KAAK,CAAC+B,KANf;IAOE,SAAS,EAAEf,OAAO,IAAID,aAAa,CAACC,OAAD,CAPrC;IAQE,KAAK,EAAEb,WART;IASE,YAAY,EAAE;EAThB,EADF,CADF;AAeD,CAvDM"}
@@ -0,0 +1,26 @@
1
+ import { AccountAction } from './UNAccountComponent';
2
+ import { UnitMessage } from '../../messages/webMessages/unitMessages';
3
+ import { WebComponentType } from '../../webComponent/WebComponent';
4
+ export const getAccountParams = props => {
5
+ return `
6
+ account-id="${props.accountId}"
7
+ customer-token="${props.customerToken}"
8
+ `;
9
+ };
10
+ export const getAccountScript = () => {
11
+ return `
12
+ const dispatchRefreshEvent = (details) => {
13
+ const event = new CustomEvent("${UnitMessage.UNIT_REQUEST_REFRESH}",{ detail: JSON.parse(details) })
14
+ window.dispatchEvent(event)
15
+ }
16
+ `;
17
+ };
18
+ export const injectRefreshEventIfNeeded = (currentWeb, requestRefreshEvent) => {
19
+ if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.account.valueOf())) {
20
+ currentWeb === null || currentWeb === void 0 ? void 0 : currentWeb.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
21
+ }
22
+ };
23
+ export const getAccountActionType = requestRendering => {
24
+ return requestRendering.data.nativeComponent.includes(AccountAction.List) ? AccountAction.List : AccountAction.Menu;
25
+ };
26
+ //# sourceMappingURL=UNAccountComponent.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AccountAction","UnitMessage","WebComponentType","getAccountParams","props","accountId","customerToken","getAccountScript","UNIT_REQUEST_REFRESH","injectRefreshEventIfNeeded","currentWeb","requestRefreshEvent","dependencies","includes","account","valueOf","injectJavaScript","JSON","stringify","getAccountActionType","requestRendering","data","nativeComponent","List","Menu"],"sources":["UNAccountComponent.utils.ts"],"sourcesContent":["import { AccountAction, UNAccountComponentProps } from './UNAccountComponent';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport type WebView from 'react-native-webview';\nimport { WebComponentType } from '../../webComponent/WebComponent';\n\nexport const getAccountParams = (props: UNAccountComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n `;\n};\n\nexport const getAccountScript = () => {\n return `\n const dispatchRefreshEvent = (details) => {\n const event = new CustomEvent(\"${UnitMessage.UNIT_REQUEST_REFRESH}\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n `;\n};\n\nexport const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null) => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.account.valueOf())) {\n currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);\n }\n};\n\nexport const getAccountActionType = (requestRendering: RequestRenderingEvent) => {\n return requestRendering.data.nativeComponent.includes(AccountAction.List) ? AccountAction.List : AccountAction.Menu;\n};\n"],"mappings":"AAAA,SAASA,aAAT,QAAuD,sBAAvD;AACA,SAAqDC,WAArD,QAAwE,yCAAxE;AAEA,SAASC,gBAAT,QAAiC,iCAAjC;AAEA,OAAO,MAAMC,gBAAgB,GAAIC,KAAD,IAAoC;EAClE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,GAHE;AAID,CALM;AAOP,OAAO,MAAMC,gBAAgB,GAAG,MAAM;EACpC,OAAQ;AACV;AACA,qCAAqCN,WAAW,CAACO,oBAAqB;AACtE;AACA;AACA,GALE;AAMD,CAPM;AASP,OAAO,MAAMC,0BAA0B,GAAG,CAACC,UAAD,EAA6BC,mBAA7B,KAAiF;EACzH,IAAIA,mBAAmB,IAAIA,mBAAmB,CAACC,YAApB,CAAiCC,QAAjC,CAA0CX,gBAAgB,CAACY,OAAjB,CAAyBC,OAAzB,EAA1C,CAA3B,EAA0G;IACxGL,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEM,gBAAZ,CAA8B,yBAAwBC,IAAI,CAACC,SAAL,CAAeP,mBAAf,CAAoC,IAA1F;EACD;AACF,CAJM;AAMP,OAAO,MAAMQ,oBAAoB,GAAIC,gBAAD,IAA6C;EAC/E,OAAOA,gBAAgB,CAACC,IAAjB,CAAsBC,eAAtB,CAAsCT,QAAtC,CAA+Cb,aAAa,CAACuB,IAA7D,IAAqEvB,aAAa,CAACuB,IAAnF,GAA0FvB,aAAa,CAACwB,IAA/G;AACD,CAFM"}
@@ -1,28 +1,50 @@
1
- import React, { useState } from 'react';
1
+ import React, { useRef, useState } from 'react';
2
2
  import { Dimensions, View } from 'react-native';
3
+ import { UnitMessage } from '../../messages/webMessages/unitMessages';
4
+ import { useListenerToBus } from '../../hooks/listenerToBus';
3
5
  import { PageMessage } from '../../messages/webMessages/pageMessage';
4
6
  import { PresentationMode } from '../../scripts/html/bodyHtml';
5
7
  import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
6
- import { getActivityParams } from './UNActivityComponent.utils';
8
+ import { getActivityParams, getActivityScript, injectRefreshEventIfNeeded } from './UNActivityComponent.utils';
7
9
  const DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;
8
10
  export const UNActivityComponent = props => {
11
+ const webRef = useRef(null);
9
12
  const [defaultHeight, setDefaultHeight] = useState();
10
13
 
14
+ const requestRefresh = data => {
15
+ injectRefreshEventIfNeeded(webRef.current, data);
16
+ };
17
+
18
+ useListenerToBus([{
19
+ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH,
20
+ action: requestRefresh
21
+ }]);
22
+
11
23
  const handleWebViewMessage = message => {
12
- if (message.type === PageMessage.PAGE_HEIGHT) {
13
- const currentHeight = message.details.height;
14
- currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);
24
+ switch (message.type) {
25
+ case UnitMessage.UNIT_ON_LOAD:
26
+ props.onLoad && props.onLoad(message.details);
27
+ break;
28
+
29
+ case PageMessage.PAGE_HEIGHT:
30
+ {
31
+ const currentHeight = message.details.height;
32
+ currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);
33
+ break;
34
+ }
15
35
  }
16
36
  };
17
37
 
18
38
  const renderActivityWebView = () => {
19
39
  return /*#__PURE__*/React.createElement(WebComponent, {
40
+ ref: webRef,
20
41
  type: WebComponentType.activity,
21
42
  presentationMode: PresentationMode.Inherit,
22
43
  params: getActivityParams(props),
23
44
  onMessage: message => handleWebViewMessage(message),
24
45
  nestedScrollEnabled: true,
25
- theme: props.theme
46
+ theme: props.theme,
47
+ script: getActivityScript()
26
48
  });
27
49
  };
28
50
 
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","Dimensions","View","PageMessage","PresentationMode","WebComponent","WebComponentType","getActivityParams","DEFAULT_HEIGHT","get","height","UNActivityComponent","props","defaultHeight","setDefaultHeight","handleWebViewMessage","message","type","PAGE_HEIGHT","currentHeight","details","renderActivityWebView","activity","Inherit","theme"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nconst DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n const [defaultHeight, setDefaultHeight] = useState<number>();\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === PageMessage.PAGE_HEIGHT) {\n const currentHeight = (message.details as HeightEvent).height;\n currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);\n }\n };\n\n const renderActivityWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n nestedScrollEnabled={true}\n theme={props.theme}\n />\n );\n };\n\n if (!defaultHeight) {\n return renderActivityWebView();\n }\n\n return (\n <View style={{ height: defaultHeight }}>\n {renderActivityWebView()}\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AAEA,MAAMC,cAAc,GAAGP,UAAU,CAACQ,GAAX,CAAe,QAAf,EAAyBC,MAAzB,GAAkC,GAAzD;AAOA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoCd,QAAQ,EAAlD;;EACA,MAAMe,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBd,WAAW,CAACe,WAAjC,EAA8C;MAC5C,MAAMC,aAAa,GAAIH,OAAO,CAACI,OAAT,CAAiCV,MAAvD;MACAS,aAAa,KAAK,CAAlB,IAAuBL,gBAAgB,CAACN,cAAD,CAAvC;IACD;EACF,CALD;;EAOA,MAAMa,qBAAqB,GAAG,MAAM;IAClC,oBACE,oBAAC,YAAD;MACE,IAAI,EAAEf,gBAAgB,CAACgB,QADzB;MAEE,gBAAgB,EAAElB,gBAAgB,CAACmB,OAFrC;MAGE,MAAM,EAAEhB,iBAAiB,CAACK,KAAD,CAH3B;MAIE,SAAS,EAAGI,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAJ9D;MAKE,mBAAmB,EAAE,IALvB;MAME,KAAK,EAAEJ,KAAK,CAACY;IANf,EADF;EAUD,CAXD;;EAaA,IAAI,CAACX,aAAL,EAAoB;IAClB,OAAOQ,qBAAqB,EAA5B;EACD;;EAED,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEX,MAAM,EAAEG;IAAV;EAAb,GACGQ,qBAAqB,EADxB,CADF;AAKD,CA/BM"}
1
+ {"version":3,"names":["React","useRef","useState","Dimensions","View","UnitMessage","useListenerToBus","PageMessage","PresentationMode","WebComponent","WebComponentType","getActivityParams","getActivityScript","injectRefreshEventIfNeeded","DEFAULT_HEIGHT","get","height","UNActivityComponent","props","webRef","defaultHeight","setDefaultHeight","requestRefresh","data","current","busEventKey","UNIT_REQUEST_REFRESH","action","handleWebViewMessage","message","type","UNIT_ON_LOAD","onLoad","details","PAGE_HEIGHT","currentHeight","renderActivityWebView","activity","Inherit","theme"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport { RequestRefreshEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { ResponseUnitOnLoadEvent } from '../../sharedTypes';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams, getActivityScript, injectRefreshEventIfNeeded } from './UNActivityComponent.utils';\nimport type WebView from 'react-native-webview';\n\nconst DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n onLoad?: (response: ResponseUnitOnLoadEvent) => void\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n const webRef = useRef<WebView>(null);\n const [defaultHeight, setDefaultHeight] = useState<number>();\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n injectRefreshEventIfNeeded(webRef.current, data);\n };\n\n useListenerToBus([\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n switch (message.type) {\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 currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);\n break;\n }\n }\n };\n\n const renderActivityWebView = () => {\n return (\n <WebComponent\n ref={webRef}\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n nestedScrollEnabled={true}\n theme={props.theme}\n script={getActivityScript()}\n />\n );\n };\n\n if (!defaultHeight) {\n return renderActivityWebView();\n }\n\n return (\n <View style={{ height: defaultHeight }}>\n {renderActivityWebView()}\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,QAAxB,QAAwC,OAAxC;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AACA,SAA8BC,WAA9B,QAAiD,yCAAjD;AACA,SAASC,gBAAT,QAAiC,2BAAjC;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AAEA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,iBAAT,EAA4BC,iBAA5B,EAA+CC,0BAA/C,QAAiF,6BAAjF;AAGA,MAAMC,cAAc,GAAGX,UAAU,CAACY,GAAX,CAAe,QAAf,EAAyBC,MAAzB,GAAkC,GAAzD;AAQA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAMC,MAAM,GAAGlB,MAAM,CAAU,IAAV,CAArB;EACA,MAAM,CAACmB,aAAD,EAAgBC,gBAAhB,IAAoCnB,QAAQ,EAAlD;;EAEA,MAAMoB,cAAc,GAAIC,IAAD,IAA+B;IACpDV,0BAA0B,CAACM,MAAM,CAACK,OAAR,EAAiBD,IAAjB,CAA1B;EACD,CAFD;;EAIAjB,gBAAgB,CAAC,CACf;IAAEmB,WAAW,EAAEpB,WAAW,CAACqB,oBAA3B;IAAiDC,MAAM,EAAEL;EAAzD,CADe,CAAD,CAAhB;;EAIA,MAAMM,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,QAAQA,OAAO,CAACC,IAAhB;MACE,KAAKzB,WAAW,CAAC0B,YAAjB;QACEb,KAAK,CAACc,MAAN,IAAgBd,KAAK,CAACc,MAAN,CAAaH,OAAO,CAACI,OAArB,CAAhB;QACA;;MACF,KAAK1B,WAAW,CAAC2B,WAAjB;QAA8B;UAC5B,MAAMC,aAAa,GAAIN,OAAO,CAACI,OAAT,CAAiCjB,MAAvD;UACAmB,aAAa,KAAK,CAAlB,IAAuBd,gBAAgB,CAACP,cAAD,CAAvC;UACA;QACD;IARH;EAUD,CAXD;;EAaA,MAAMsB,qBAAqB,GAAG,MAAM;IAClC,oBACE,oBAAC,YAAD;MACE,GAAG,EAAEjB,MADP;MAEE,IAAI,EAAET,gBAAgB,CAAC2B,QAFzB;MAGE,gBAAgB,EAAE7B,gBAAgB,CAAC8B,OAHrC;MAIE,MAAM,EAAE3B,iBAAiB,CAACO,KAAD,CAJ3B;MAKE,SAAS,EAAGW,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;MAME,mBAAmB,EAAE,IANvB;MAOE,KAAK,EAAEX,KAAK,CAACqB,KAPf;MAQE,MAAM,EAAE3B,iBAAiB;IAR3B,EADF;EAYD,CAbD;;EAeA,IAAI,CAACQ,aAAL,EAAoB;IAClB,OAAOgB,qBAAqB,EAA5B;EACD;;EAED,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEpB,MAAM,EAAEI;IAAV;EAAb,GACGgB,qBAAqB,EADxB,CADF;AAKD,CAjDM"}
@@ -1,3 +1,5 @@
1
+ import { WebComponentType } from './../../webComponent/WebComponent';
2
+ import { DISPATCH_REQUEST_REFRESH } from './../../scripts/html/bodyScript';
1
3
  export const getActivityParams = props => {
2
4
  return `
3
5
  account-id="${props.accountId}"
@@ -5,4 +7,12 @@ export const getActivityParams = props => {
5
7
  style="height: 100%"
6
8
  `;
7
9
  };
10
+ export const getActivityScript = () => {
11
+ return DISPATCH_REQUEST_REFRESH;
12
+ };
13
+ export const injectRefreshEventIfNeeded = (currentWeb, requestRefreshEvent) => {
14
+ if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.activity.valueOf())) {
15
+ currentWeb === null || currentWeb === void 0 ? void 0 : currentWeb.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
16
+ }
17
+ };
8
18
  //# sourceMappingURL=UNActivityComponent.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getActivityParams","props","accountId","customerToken"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n style=\"height: 100%\"\n `;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C;AACA,GAJE;AAKD,CANM"}
1
+ {"version":3,"names":["WebComponentType","DISPATCH_REQUEST_REFRESH","getActivityParams","props","accountId","customerToken","getActivityScript","injectRefreshEventIfNeeded","currentWeb","requestRefreshEvent","dependencies","includes","activity","valueOf","injectJavaScript","JSON","stringify"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import { WebComponentType } from './../../webComponent/WebComponent';\nimport type { RequestRefreshEvent } from './../../messages/webMessages/unitMessages';\nimport type { WebView } from 'react-native-webview';\nimport { DISPATCH_REQUEST_REFRESH } from './../../scripts/html/bodyScript';\nimport type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n style=\"height: 100%\"\n `;\n};\n\nexport const getActivityScript = () => {\n return DISPATCH_REQUEST_REFRESH;\n};\n\nexport const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null) => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.activity.valueOf())) {\n currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);\n }\n};\n"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,mCAAjC;AAGA,SAASC,wBAAT,QAAyC,iCAAzC;AAGA,OAAO,MAAMC,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C;AACA,GAJE;AAKD,CANM;AAQP,OAAO,MAAMC,iBAAiB,GAAG,MAAM;EACrC,OAAOL,wBAAP;AACD,CAFM;AAIP,OAAO,MAAMM,0BAA0B,GAAG,CAACC,UAAD,EAA6BC,mBAA7B,KAAiF;EACzH,IAAIA,mBAAmB,IAAIA,mBAAmB,CAACC,YAApB,CAAiCC,QAAjC,CAA0CX,gBAAgB,CAACY,QAAjB,CAA0BC,OAA1B,EAA1C,CAA3B,EAA2G;IACzGL,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEM,gBAAZ,CAA8B,yBAAwBC,IAAI,CAACC,SAAL,CAAeP,mBAAf,CAAoC,IAA1F;EACD;AACF,CAJM"}
@@ -5,23 +5,34 @@ import { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentCompo
5
5
  import { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
6
6
  import { PageMessage } from '../../messages/webMessages/pageMessage';
7
7
  import { View } from 'react-native';
8
+ import { UnitMessage } from '../../messages/webMessages/unitMessages';
8
9
  export const UNBookPaymentComponent = props => {
9
10
  const [height, setHeight] = useState(0);
10
11
  const [presentationMode, setPresentationMode] = useState(PresentationMode.Inherit);
11
12
 
12
13
  const handleWebViewMessage = message => {
13
- if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {
14
- const response = message.details;
15
- props.onPaymentCreated(response.data);
16
- }
14
+ if (!message || !message.details) return;
15
+
16
+ switch (message.type) {
17
+ case BookPaymentMessage.PAYMENT_CREATED:
18
+ props.onPaymentCreated && props.onPaymentCreated(message.details.data);
19
+ break;
20
+
21
+ case UnitMessage.UNIT_ON_LOAD:
22
+ props.onLoad && props.onLoad(message.details);
23
+ break;
24
+
25
+ case PageMessage.PAGE_HEIGHT:
26
+ {
27
+ const currentHeight = message.details.height;
28
+ setHeight(currentHeight);
17
29
 
18
- if (message.type === PageMessage.PAGE_HEIGHT) {
19
- const currentHeight = message.details.height;
20
- setHeight(currentHeight);
30
+ if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {
31
+ setPresentationMode(PresentationMode.Default);
32
+ }
21
33
 
22
- if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {
23
- setPresentationMode(PresentationMode.Default);
24
- }
34
+ break;
35
+ }
25
36
  }
26
37
  };
27
38
 
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","WebComponent","WebComponentType","PresentationMode","getBookPaymentParams","getBookPaymentScript","BookPaymentMessage","PageMessage","View","UNBookPaymentComponent","props","height","setHeight","presentationMode","setPresentationMode","Inherit","handleWebViewMessage","message","type","PAYMENT_CREATED","onPaymentCreated","response","details","data","PAGE_HEIGHT","currentHeight","Default","renderBookPaymentWebView","bookPayment","theme"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { UNBookPaymentData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { View } from 'react-native';\n\nexport interface UNBookPaymentComponentProps {\n accountId: string;\n customerToken: string;\n isSameCustomer: boolean;\n counterPartyAccountId: string;\n counterPartyName: string;\n theme?: string;\n onPaymentCreated?: (data: UNBookPaymentData) => void;\n}\n\nexport const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {\n const response = message.details as BookPaymentEvent;\n props.onPaymentCreated(response.data);\n }\n\n if (message.type === PageMessage.PAGE_HEIGHT) {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n }\n };\n\n const renderBookPaymentWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={presentationMode}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderBookPaymentWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderBookPaymentWebView()}\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,oBAAT,EAA+BC,oBAA/B,QAA2D,gCAA3D;AAEA,SAA2BC,kBAA3B,QAAqD,+CAArD;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAASC,IAAT,QAAqB,cAArB;AAYA,OAAO,MAAMC,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBZ,QAAQ,CAAS,CAAT,CAApC;EACA,MAAM,CAACa,gBAAD,EAAmBC,mBAAnB,IAA0Cd,QAAQ,CAAmBG,gBAAgB,CAACY,OAApC,CAAxD;;EAEA,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBZ,kBAAkB,CAACa,eAApC,IAAuDT,KAAK,CAACU,gBAAjE,EAAmF;MACjF,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,OAAzB;MACAZ,KAAK,CAACU,gBAAN,CAAuBC,QAAQ,CAACE,IAAhC;IACD;;IAED,IAAIN,OAAO,CAACC,IAAR,KAAiBX,WAAW,CAACiB,WAAjC,EAA8C;MAC5C,MAAMC,aAAa,GAAIR,OAAO,CAACK,OAAT,CAAiCX,MAAvD;MACAC,SAAS,CAACa,aAAD,CAAT;;MACA,IAAIZ,gBAAgB,KAAKV,gBAAgB,CAACY,OAAtC,IAAiDU,aAAa,KAAK,CAAvE,EAA0E;QACxEX,mBAAmB,CAACX,gBAAgB,CAACuB,OAAlB,CAAnB;MACD;IACF;EACF,CAbD;;EAeA,MAAMC,wBAAwB,GAAG,MAAM;IACrC,oBACE,oBAAC,YAAD;MACE,IAAI,EAAEzB,gBAAgB,CAAC0B,WADzB;MAEE,gBAAgB,EAAEf,gBAFpB;MAGE,MAAM,EAAET,oBAAoB,CAACM,KAAD,CAH9B;MAIE,MAAM,EAAEL,oBAAoB,EAJ9B;MAKE,SAAS,EAAGY,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;MAME,YAAY,EAAE,KANhB;MAOE,KAAK,EAAEP,KAAK,CAACmB;IAPf,EADF;EAWD,CAZD;;EAcA,IAAIhB,gBAAgB,KAAKV,gBAAgB,CAACY,OAA1C,EAAmD;IACjD,OAAOY,wBAAwB,EAA/B;EACD;;EAED,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEhB,MAAM,EAAEA;IAAV;EAAb,GACGgB,wBAAwB,EAD3B,CADF;AAKD,CA1CM"}
1
+ {"version":3,"names":["React","useState","WebComponent","WebComponentType","PresentationMode","getBookPaymentParams","getBookPaymentScript","BookPaymentMessage","PageMessage","View","UnitMessage","UNBookPaymentComponent","props","height","setHeight","presentationMode","setPresentationMode","Inherit","handleWebViewMessage","message","details","type","PAYMENT_CREATED","onPaymentCreated","data","UNIT_ON_LOAD","onLoad","PAGE_HEIGHT","currentHeight","Default","renderBookPaymentWebView","bookPayment","theme"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { 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,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,oBAAT,EAA+BC,oBAA/B,QAA2D,gCAA3D;AAEA,SAA2BC,kBAA3B,QAAqD,+CAArD;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,SAASC,WAAT,QAA4B,yCAA5B;AAaA,OAAO,MAAMC,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBb,QAAQ,CAAS,CAAT,CAApC;EACA,MAAM,CAACc,gBAAD,EAAmBC,mBAAnB,IAA0Cf,QAAQ,CAAmBG,gBAAgB,CAACa,OAApC,CAAxD;;EAEA,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAI,CAACA,OAAD,IAAY,CAACA,OAAO,CAACC,OAAzB,EAAkC;;IAElC,QAAQD,OAAO,CAACE,IAAhB;MACE,KAAKd,kBAAkB,CAACe,eAAxB;QACEV,KAAK,CAACW,gBAAN,IAA0BX,KAAK,CAACW,gBAAN,CAAwBJ,OAAO,CAACC,OAAT,CAAsCI,IAA7D,CAA1B;QACA;;MACF,KAAKd,WAAW,CAACe,YAAjB;QACEb,KAAK,CAACc,MAAN,IAAgBd,KAAK,CAACc,MAAN,CAAaP,OAAO,CAACC,OAArB,CAAhB;QACA;;MACF,KAAKZ,WAAW,CAACmB,WAAjB;QAA8B;UAC5B,MAAMC,aAAa,GAAIT,OAAO,CAACC,OAAT,CAAiCP,MAAvD;UACAC,SAAS,CAACc,aAAD,CAAT;;UACA,IAAIb,gBAAgB,KAAKX,gBAAgB,CAACa,OAAtC,IAAiDW,aAAa,KAAK,CAAvE,EAA0E;YACxEZ,mBAAmB,CAACZ,gBAAgB,CAACyB,OAAlB,CAAnB;UACD;;UACD;QACD;IAdH;EAgBD,CAnBD;;EAqBA,MAAMC,wBAAwB,GAAG,MAAM;IACrC,oBACE,oBAAC,YAAD;MACE,IAAI,EAAE3B,gBAAgB,CAAC4B,WADzB;MAEE,gBAAgB,EAAEhB,gBAFpB;MAGE,MAAM,EAAEV,oBAAoB,CAACO,KAAD,CAH9B;MAIE,MAAM,EAAEN,oBAAoB,EAJ9B;MAKE,SAAS,EAAGa,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;MAME,YAAY,EAAE,KANhB;MAOE,KAAK,EAAEP,KAAK,CAACoB;IAPf,EADF;EAWD,CAZD;;EAcA,IAAIjB,gBAAgB,KAAKX,gBAAgB,CAACa,OAA1C,EAAmD;IACjD,OAAOa,wBAAwB,EAA/B;EACD;;EAED,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEjB,MAAM,EAAEA;IAAV;EAAb,GACGiB,wBAAwB,EAD3B,CADF;AAKD,CAhDM"}
@@ -1,3 +1,4 @@
1
+ import { LISTENERS } from './../../scripts/html/bodyScript';
1
2
  import { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
2
3
  export const getBookPaymentParams = props => {
3
4
  return `
@@ -19,6 +20,8 @@ export const getBookPaymentScript = () => {
19
20
  console.log(e)
20
21
  })
21
22
  });
23
+
24
+ ${LISTENERS.requestRefresh}
22
25
  `;
23
26
  };
24
27
  //# sourceMappingURL=UNBookPaymentComponent.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BookPaymentMessage","getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","getBookPaymentScript","PAYMENT_CREATED"],"sources":["UNBookPaymentComponent.utils.ts"],"sourcesContent":["import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';\n\nimport { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\n\nexport const getBookPaymentParams = (props: UNBookPaymentComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n is-same-customer=\"${props.isSameCustomer}\"\n counterparty-account-id=\"${props.counterPartyAccountId}\"\n counterparty-name=\"${props.counterPartyName}\"\n style=\"height: 100%\"\n `;\n};\n\nexport const getBookPaymentScript = () => {\n return `\n window.addEventListener(\"${BookPaymentMessage.PAYMENT_CREATED}\", (e) => {\n const response = e.detail\n response.then((data) => {\n postMessageToSDK({ type: \"${BookPaymentMessage.PAYMENT_CREATED}\", details: { data: JSON.stringify(data.data) }})\n }).catch((e) => {\n console.log(e)\n })\n });\n `;\n};\n"],"mappings":"AAEA,SAASA,kBAAT,QAAmC,+CAAnC;AAEA,OAAO,MAAMC,oBAAoB,GAAIC,KAAD,IAAwC;EAC1E,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,wBAAwBF,KAAK,CAACG,cAAe;AAC7C,+BAA+BH,KAAK,CAACI,qBAAsB;AAC3D,yBAAyBJ,KAAK,CAACK,gBAAiB;AAChD;AACA,GAPE;AAQD,CATM;AAWP,OAAO,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BR,kBAAkB,CAACS,eAAgB;AAClE;AACA;AACA,sCAAsCT,kBAAkB,CAACS,eAAgB;AACzE;AACA;AACA;AACA;AACA,GATE;AAUD,CAXM"}
1
+ {"version":3,"names":["LISTENERS","BookPaymentMessage","getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","getBookPaymentScript","PAYMENT_CREATED","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,SAASA,SAAT,QAA0B,iCAA1B;AAGA,SAASC,kBAAT,QAAmC,+CAAnC;AAEA,OAAO,MAAMC,oBAAoB,GAAIC,KAAD,IAAwC;EAC1E,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,wBAAwBF,KAAK,CAACG,cAAe;AAC7C,+BAA+BH,KAAK,CAACI,qBAAsB;AAC3D,yBAAyBJ,KAAK,CAACK,gBAAiB;AAChD;AACA,GAPE;AAQD,CATM;AAWP,OAAO,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BR,kBAAkB,CAACS,eAAgB;AAClE;AACA;AACA,sCAAsCT,kBAAkB,CAACS,eAAgB;AACzE;AACA;AACA;AACA;AACA;AACA,MAAMV,SAAS,CAACW,cAAe;AAC/B,GAXE;AAYD,CAbM"}
@@ -1,2 +1,2 @@
1
- export const BOTTOM_SHEET_MAX_PRECANTAGE_SIZE = 0.9;
1
+ export const BOTTOM_SHEET_MAX_PERCENTAGE_SIZE = 0.9;
2
2
  //# sourceMappingURL=UNBottomSheetComponent.constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BOTTOM_SHEET_MAX_PRECANTAGE_SIZE"],"sources":["UNBottomSheetComponent.constants.ts"],"sourcesContent":["export const BOTTOM_SHEET_MAX_PRECANTAGE_SIZE = 0.9;\n"],"mappings":"AAAA,OAAO,MAAMA,gCAAgC,GAAG,GAAzC"}
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":"AAAA,OAAO,MAAMA,gCAAgC,GAAG,GAAzC"}
@@ -12,49 +12,64 @@ import { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest
12
12
  import { getStylesObject } from './UNBottomSheetComponent.styles';
13
13
  import { PresentationMode } from '../../scripts/html/bodyHtml';
14
14
  import { useAppStateListener } from '../../hooks/useAppStateListener';
15
+ import { UNAddToWalletBottomSheetItem } from './components/UNAddToWalletBottomSheetItem';
16
+ import { getAccountActionType } from '../UNAccountComponent/UNAccountComponent.utils';
17
+ import { AccountAction } from '../UNAccountComponent/UNAccountComponent';
15
18
  export let ScrollState;
16
19
 
17
20
  (function (ScrollState) {
18
21
  ScrollState["onTop"] = "onTop";
22
+ ScrollState["unScrollable"] = "unScrollable";
19
23
  ScrollState["onlyWebView"] = "webViewScroll";
20
24
  ScrollState["onlyBottomSheet"] = "onlyBottomSheet";
21
- ScrollState["unScrollable"] = "unScrollable";
22
25
  })(ScrollState || (ScrollState = {}));
23
26
 
27
+ var CustomDialog;
28
+
29
+ (function (CustomDialog) {
30
+ CustomDialog[CustomDialog["addToWallet"] = 0] = "addToWallet";
31
+ })(CustomDialog || (CustomDialog = {}));
32
+
24
33
  export const UNBottomSheetComponent = () => {
25
34
  const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);
26
35
  const [height, setHeight] = useState(0);
27
- const [renderingRequest, setRenderingRequest] = useState(null);
36
+ const [bottomSheetSlotData, setBottomSheetSlotData] = useState();
37
+ const [requestRenderingEvent, setRequestRenderingEvent] = useState();
28
38
  const [scrollState, setScrollState] = useState(ScrollState.onTop);
29
39
  const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);
30
40
  const [newHeightMessage, setNewHeightMessage] = useState(null);
41
+ const [customDialog, setCustomDialog] = useState(null);
31
42
  const isAppActive = useAppStateListener();
32
43
  const styles = getStylesObject();
33
44
  const webRef = useRef(null);
34
45
 
35
- const listenerAction = data => {
36
- setRenderingRequest(data);
46
+ const handleRequestRendering = data => {
47
+ setBottomSheetSlotData(data);
37
48
  setIsBottomSheetActive(true);
49
+ setRequestRenderingEvent(data.requestRenderingEvent);
50
+ };
51
+
52
+ const handleCloseFlow = () => {
53
+ setIsBottomSheetActive(false);
38
54
  };
39
55
 
40
56
  useEffect(() => {
41
- if (!isAppActive) {
42
- setIsBottomSheetActive(false);
43
- }
44
- }, [isAppActive]);
57
+ setRequestRenderingEvent(bottomSheetSlotData === null || bottomSheetSlotData === void 0 ? void 0 : bottomSheetSlotData.requestRenderingEvent);
58
+ }, [bottomSheetSlotData]);
45
59
  useEffect(() => {
46
60
  if (!webRef.current) return;
47
61
 
48
- if (renderingRequest) {
49
- renderingBottomSheetRequest(webRef.current, renderingRequest);
62
+ if (requestRenderingEvent) {
63
+ renderingBottomSheetRequest(webRef.current, requestRenderingEvent);
50
64
  }
51
- }, [webRef.current, renderingRequest]);
65
+ }, [webRef.current, requestRenderingEvent]);
52
66
  useEffect(() => {
53
67
  if (!isBottomSheetActive) {
54
68
  webRef.current && resetHtml(webRef.current);
55
69
  setHeight(0);
56
- setRenderingRequest(null);
70
+ setRequestRenderingEvent(undefined);
57
71
  setScrollState(ScrollState.onTop);
72
+ setCustomDialog(null);
58
73
  }
59
74
  }, [isBottomSheetActive]);
60
75
  useEffect(() => {
@@ -65,51 +80,88 @@ export const UNBottomSheetComponent = () => {
65
80
  }, [waitForLoadingNewComponent, newHeightMessage]);
66
81
  useListenerToBus([{
67
82
  busEventKey: UnitMessage.UNIT_REQUEST_RENDERING,
68
- action: listenerAction
83
+ action: handleRequestRendering
84
+ }, {
85
+ busEventKey: UnitMessage.UNIT_REQUEST_CLOSE_FLOW,
86
+ action: handleCloseFlow
69
87
  }]);
70
88
 
71
89
  const setNewHeight = message => {
72
- if (renderingRequest) {
73
- const nativePlace = JSON.parse(renderingRequest).nativePlace;
74
-
75
- if (nativePlace == 'overFullScreen') {
76
- const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);
77
- setHeight(bottomSheetNewHeight);
78
- setScrollState(ScrollState.onTop);
79
- } else {
80
- setHeight(message.details.height);
81
- setScrollState(ScrollState.unScrollable);
82
- }
90
+ if (!requestRenderingEvent) return;
91
+
92
+ switch (bottomSheetSlotData === null || bottomSheetSlotData === void 0 ? void 0 : bottomSheetSlotData.componentName) {
93
+ case WebComponentType.account:
94
+ {
95
+ const accountActionType = getAccountActionType(requestRenderingEvent);
96
+ setScrollState(accountActionType === AccountAction.List ? ScrollState.onTop : ScrollState.unScrollable);
97
+ break;
98
+ }
99
+
100
+ case WebComponentType.card:
101
+ {
102
+ if (customDialog === CustomDialog.addToWallet) {
103
+ setScrollState(ScrollState.unScrollable);
104
+ } else {
105
+ setScrollState(ScrollState.onTop);
106
+ }
107
+
108
+ break;
109
+ }
110
+
111
+ default:
112
+ {
113
+ const nativePlace = requestRenderingEvent === null || requestRenderingEvent === void 0 ? void 0 : requestRenderingEvent.data.nativePlace;
114
+
115
+ if (nativePlace == 'overFullScreen') {
116
+ setScrollState(ScrollState.onTop);
117
+ } else {
118
+ setScrollState(ScrollState.unScrollable);
119
+ }
120
+ }
121
+ }
122
+
123
+ const nativePlace = requestRenderingEvent === null || requestRenderingEvent === void 0 ? void 0 : requestRenderingEvent.data.nativePlace;
124
+
125
+ if (nativePlace == 'overFullScreen') {
126
+ const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);
127
+ setHeight(bottomSheetNewHeight);
128
+ } else {
129
+ setHeight(message.details.height);
83
130
  }
84
131
  };
85
132
 
86
133
  const onWebMessage = message => {
87
134
  switch (message.type) {
88
135
  case PageMessage.PAGE_HEIGHT:
89
- renderingRequest && setNewHeightMessage(message);
136
+ requestRenderingEvent && setNewHeightMessage(message);
90
137
  break;
91
138
 
92
139
  case UnitMessage.UNIT_REQUEST_RENDERING:
93
- // eslint-disable-next-line no-case-declarations
94
- const {
95
- data
96
- } = message.details;
140
+ {
141
+ var _requestRenderingEven;
97
142
 
98
- if (data != renderingRequest) {
99
- setHeight(0);
100
- setRenderingRequest(data);
101
- setWaitForLoadingNewComponent(true);
102
- setTimeout(() => setWaitForLoadingNewComponent(false), 400);
103
- }
143
+ const requestRendering = message.details;
104
144
 
105
- break;
145
+ if (requestRendering.data.nativeComponent != (requestRenderingEvent === null || requestRenderingEvent === void 0 ? void 0 : (_requestRenderingEven = requestRenderingEvent.data) === null || _requestRenderingEven === void 0 ? void 0 : _requestRenderingEven.nativeComponent)) {
146
+ if (requestRendering.data.nativeComponent.includes('action=AddToWallet')) {
147
+ setCustomDialog(CustomDialog.addToWallet);
148
+ }
149
+
150
+ setHeight(0);
151
+ setRequestRenderingEvent(requestRendering);
152
+ setWaitForLoadingNewComponent(true);
153
+ setTimeout(() => setWaitForLoadingNewComponent(false), 400);
154
+ }
155
+
156
+ break;
157
+ }
106
158
 
107
159
  case CardMessage.CARD_STATUS_CHANGED:
108
160
  EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, message.details.card);
109
161
  break;
110
162
 
111
163
  case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:
112
- setIsBottomSheetActive(false);
164
+ handleCloseFlow();
113
165
  break;
114
166
 
115
167
  case UnitMessage.UNIT_REQUEST_OPEN_LINK:
@@ -140,6 +192,27 @@ export const UNBottomSheetComponent = () => {
140
192
  setScrollState(ScrollState.onlyWebView);
141
193
  };
142
194
 
195
+ const renderBottomSheetItem = () => {
196
+ switch (customDialog) {
197
+ case CustomDialog.addToWallet:
198
+ return /*#__PURE__*/React.createElement(UNAddToWalletBottomSheetItem, {
199
+ renderingRequest: requestRenderingEvent,
200
+ cardId: bottomSheetSlotData === null || bottomSheetSlotData === void 0 ? void 0 : bottomSheetSlotData.componentResourceId
201
+ });
202
+
203
+ default:
204
+ return /*#__PURE__*/React.createElement(WebComponent, {
205
+ ref: webRef,
206
+ type: WebComponentType.slot,
207
+ presentationMode: PresentationMode.CoverInjectedHeight,
208
+ script: getBottomSheetScript(),
209
+ onMessage: onWebMessage,
210
+ isScrollable: scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop,
211
+ handleScroll: onScrollWebView
212
+ });
213
+ }
214
+ };
215
+
143
216
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
144
217
  pointerEvents: isBottomSheetActive ? undefined : 'none',
145
218
  style: styles.container
@@ -150,14 +223,6 @@ export const UNBottomSheetComponent = () => {
150
223
  onOpen: () => setIsBottomSheetActive(true),
151
224
  handleWebViewScroll: () => handleWebViewScroll(),
152
225
  shouldEnableBottomSheetScroll: scrollState !== ScrollState.onlyWebView
153
- }, isAppActive && /*#__PURE__*/React.createElement(WebComponent, {
154
- ref: webRef,
155
- type: WebComponentType.slot,
156
- presentationMode: PresentationMode.CoverInjectedHeight,
157
- script: getBottomSheetScript(),
158
- onMessage: onWebMessage,
159
- isScrollable: scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop,
160
- handleScroll: onScrollWebView
161
- }))));
226
+ }, isAppActive && renderBottomSheetItem())));
162
227
  };
163
228
  //# sourceMappingURL=UNBottomSheetComponent.js.map