react-native-unit-components 0.1.0 → 1.0.0

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 (241) hide show
  1. package/README.md +157 -2
  2. package/lib/commonjs/assets/images/close.png +0 -0
  3. package/lib/commonjs/assets/images/index.js +16 -0
  4. package/lib/commonjs/assets/images/index.js.map +1 -0
  5. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +28 -0
  6. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -0
  7. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +20 -0
  8. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -0
  9. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +39 -0
  10. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -0
  11. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +40 -0
  12. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -0
  13. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +9 -0
  14. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -0
  15. package/lib/commonjs/components/{BottomSheet/BottomSheetComponent.js → UNBottomSheetComponent/UNBottomSheetComponent.js} +84 -65
  16. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -0
  17. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +23 -0
  18. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -0
  19. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +49 -0
  20. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -0
  21. package/lib/commonjs/components/{Card/CardComponent.js → UNCardComponent/UNCardComponent.js} +42 -46
  22. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -0
  23. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +42 -0
  24. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -0
  25. package/lib/commonjs/components/index.js +34 -8
  26. package/lib/commonjs/components/index.js.map +1 -1
  27. package/lib/commonjs/custom.d.js +2 -0
  28. package/lib/commonjs/custom.d.js.map +1 -0
  29. package/lib/commonjs/helpers/{BottomSheet.js → BottomSheet/BottomSheet.js} +36 -82
  30. package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -0
  31. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +82 -0
  32. package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -0
  33. package/lib/commonjs/helpers/EventBus.js +5 -13
  34. package/lib/commonjs/helpers/EventBus.js.map +1 -1
  35. package/lib/commonjs/hooks/listenerToBus.js +31 -0
  36. package/lib/commonjs/hooks/listenerToBus.js.map +1 -0
  37. package/lib/commonjs/hooks/useAppStateListener.js +34 -0
  38. package/lib/commonjs/hooks/useAppStateListener.js.map +1 -0
  39. package/lib/commonjs/index.js +33 -0
  40. package/lib/commonjs/index.js.map +1 -1
  41. package/lib/commonjs/messages/nativeMessages/index.js +13 -0
  42. package/lib/commonjs/messages/nativeMessages/index.js.map +1 -0
  43. package/lib/commonjs/messages/webMessages/bookPaymentMessage.js +13 -0
  44. package/lib/commonjs/messages/webMessages/bookPaymentMessage.js.map +1 -0
  45. package/lib/commonjs/{webComponent → messages}/webMessages/cardMessage.js +1 -1
  46. package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -0
  47. package/lib/commonjs/messages/webMessages/index.js +6 -0
  48. package/lib/commonjs/messages/webMessages/index.js.map +1 -0
  49. package/lib/commonjs/{webComponent → messages}/webMessages/pageMessage.js +0 -0
  50. package/lib/commonjs/{webComponent → messages}/webMessages/pageMessage.js.map +0 -0
  51. package/lib/commonjs/{webComponent → messages}/webMessages/unitMessages.js +0 -0
  52. package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -0
  53. package/lib/commonjs/nativeComponenet/NativeComponentExample.js +2 -2
  54. package/lib/commonjs/nativeComponenet/NativeComponentExample.js.map +1 -1
  55. package/lib/commonjs/scripts/html/bodyHtml.js +52 -0
  56. package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -0
  57. package/lib/commonjs/scripts/html/bodyScript.js +78 -0
  58. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -0
  59. package/lib/commonjs/sharedTypes/bookPayment.types.js +6 -0
  60. package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -0
  61. package/lib/commonjs/sharedTypes/card.types.js +6 -0
  62. package/lib/commonjs/sharedTypes/card.types.js.map +1 -0
  63. package/lib/commonjs/sharedTypes/index.js +32 -0
  64. package/lib/commonjs/sharedTypes/index.js.map +1 -0
  65. package/lib/commonjs/sharedTypes/types.js +2 -0
  66. package/lib/commonjs/sharedTypes/types.js.map +1 -0
  67. package/lib/commonjs/styles/variables.js +17 -0
  68. package/lib/commonjs/styles/variables.js.map +1 -0
  69. package/lib/commonjs/unitSdkManager/UnitSdk.api.js +54 -0
  70. package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -0
  71. package/lib/commonjs/unitSdkManager/UnitSdkManager.js +51 -0
  72. package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -0
  73. package/lib/commonjs/webComponent/WebComponent.js +35 -15
  74. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  75. package/lib/commonjs/webComponent/html.js +22 -45
  76. package/lib/commonjs/webComponent/html.js.map +1 -1
  77. package/lib/module/assets/images/close.png +0 -0
  78. package/lib/module/assets/images/index.js +2 -0
  79. package/lib/module/assets/images/index.js.map +1 -0
  80. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +13 -0
  81. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -0
  82. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -0
  83. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -0
  84. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +23 -0
  85. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -0
  86. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +26 -0
  87. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -0
  88. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +2 -0
  89. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -0
  90. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +131 -0
  91. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -0
  92. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +13 -0
  93. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -0
  94. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +29 -0
  95. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -0
  96. package/lib/module/components/UNCardComponent/UNCardComponent.js +65 -0
  97. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -0
  98. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +24 -0
  99. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -0
  100. package/lib/module/components/index.js +4 -2
  101. package/lib/module/components/index.js.map +1 -1
  102. package/lib/module/custom.d.js +2 -0
  103. package/lib/module/custom.d.js.map +1 -0
  104. package/lib/module/helpers/{BottomSheet.js → BottomSheet/BottomSheet.js} +34 -81
  105. package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -0
  106. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +70 -0
  107. package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -0
  108. package/lib/module/helpers/EventBus.js +4 -11
  109. package/lib/module/helpers/EventBus.js.map +1 -1
  110. package/lib/module/hooks/listenerToBus.js +18 -0
  111. package/lib/module/hooks/listenerToBus.js.map +1 -0
  112. package/lib/module/hooks/useAppStateListener.js +23 -0
  113. package/lib/module/hooks/useAppStateListener.js.map +1 -0
  114. package/lib/module/index.js +2 -0
  115. package/lib/module/index.js.map +1 -1
  116. package/lib/module/messages/nativeMessages/index.js +6 -0
  117. package/lib/module/messages/nativeMessages/index.js.map +1 -0
  118. package/lib/module/messages/webMessages/bookPaymentMessage.js +6 -0
  119. package/lib/module/messages/webMessages/bookPaymentMessage.js.map +1 -0
  120. package/lib/module/messages/webMessages/cardMessage.js +6 -0
  121. package/lib/module/messages/webMessages/cardMessage.js.map +1 -0
  122. package/lib/module/messages/webMessages/index.js +2 -0
  123. package/lib/module/messages/webMessages/index.js.map +1 -0
  124. package/lib/module/{webComponent → messages}/webMessages/pageMessage.js +0 -0
  125. package/lib/module/{webComponent → messages}/webMessages/pageMessage.js.map +0 -0
  126. package/lib/module/{webComponent → messages}/webMessages/unitMessages.js +0 -0
  127. package/lib/module/messages/webMessages/unitMessages.js.map +1 -0
  128. package/lib/module/nativeComponenet/NativeComponentExample.js +2 -2
  129. package/lib/module/nativeComponenet/NativeComponentExample.js.map +1 -1
  130. package/lib/module/scripts/html/bodyHtml.js +42 -0
  131. package/lib/module/scripts/html/bodyHtml.js.map +1 -0
  132. package/lib/module/scripts/html/bodyScript.js +64 -0
  133. package/lib/module/scripts/html/bodyScript.js.map +1 -0
  134. package/lib/module/sharedTypes/bookPayment.types.js +2 -0
  135. package/lib/module/sharedTypes/bookPayment.types.js.map +1 -0
  136. package/lib/module/sharedTypes/card.types.js +2 -0
  137. package/lib/module/sharedTypes/card.types.js.map +1 -0
  138. package/lib/module/sharedTypes/index.js +3 -0
  139. package/lib/module/sharedTypes/index.js.map +1 -0
  140. package/lib/module/sharedTypes/types.js +2 -0
  141. package/lib/module/sharedTypes/types.js.map +1 -0
  142. package/lib/module/styles/variables.js +10 -0
  143. package/lib/module/styles/variables.js.map +1 -0
  144. package/lib/module/unitSdkManager/UnitSdk.api.js +37 -0
  145. package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -0
  146. package/lib/module/unitSdkManager/UnitSdkManager.js +38 -0
  147. package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -0
  148. package/lib/module/webComponent/WebComponent.js +34 -14
  149. package/lib/module/webComponent/WebComponent.js.map +1 -1
  150. package/lib/module/webComponent/html.js +18 -44
  151. package/lib/module/webComponent/html.js.map +1 -1
  152. package/lib/typescript/assets/images/index.d.ts +1 -0
  153. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +6 -0
  154. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +2 -0
  155. package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +11 -0
  156. package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.d.ts +3 -0
  157. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -0
  158. package/lib/typescript/components/{BottomSheet/BottomSheetComponent.d.ts → UNBottomSheetComponent/UNBottomSheetComponent.d.ts} +0 -0
  159. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.d.ts +9 -0
  160. package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +5 -0
  161. package/lib/typescript/components/{Card/CardComponent.d.ts → UNCardComponent/UNCardComponent.d.ts} +3 -1
  162. package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +6 -0
  163. package/lib/typescript/components/index.d.ts +4 -2
  164. package/lib/typescript/helpers/{BottomSheet.d.ts → BottomSheet/BottomSheet.d.ts} +1 -0
  165. package/lib/typescript/helpers/BottomSheet/BottomSheet.styles.d.ts +63 -0
  166. package/lib/typescript/helpers/EventBus.d.ts +5 -7
  167. package/lib/typescript/hooks/listenerToBus.d.ts +7 -0
  168. package/lib/typescript/hooks/useAppStateListener.d.ts +1 -0
  169. package/lib/typescript/index.d.ts +2 -0
  170. package/lib/typescript/messages/nativeMessages/index.d.ts +3 -0
  171. package/lib/typescript/messages/webMessages/bookPaymentMessage.d.ts +8 -0
  172. package/lib/typescript/{webComponent → messages}/webMessages/cardMessage.d.ts +3 -2
  173. package/lib/typescript/messages/webMessages/index.d.ts +11 -0
  174. package/lib/typescript/{webComponent → messages}/webMessages/pageMessage.d.ts +0 -0
  175. package/lib/typescript/{webComponent → messages}/webMessages/unitMessages.d.ts +0 -0
  176. package/lib/typescript/scripts/html/bodyHtml.d.ts +7 -0
  177. package/lib/typescript/scripts/html/bodyScript.d.ts +11 -0
  178. package/lib/typescript/sharedTypes/bookPayment.types.d.ts +26 -0
  179. package/lib/typescript/sharedTypes/card.types.d.ts +56 -0
  180. package/lib/typescript/sharedTypes/index.d.ts +2 -0
  181. package/lib/typescript/sharedTypes/types.d.ts +27 -0
  182. package/lib/typescript/styles/variables.d.ts +9 -0
  183. package/lib/typescript/unitSdkManager/UnitSdk.api.d.ts +3 -0
  184. package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +15 -0
  185. package/lib/typescript/webComponent/WebComponent.d.ts +8 -11
  186. package/lib/typescript/webComponent/html.d.ts +6 -1
  187. package/package.json +9 -5
  188. package/{unit-react-native-components.podspec → react-native-unit-components.podspec} +1 -1
  189. package/src/assets/images/close.png +0 -0
  190. package/src/assets/images/index.ts +1 -0
  191. package/src/components/UNActivityComponent/UNActivityComponent.tsx +21 -0
  192. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +11 -0
  193. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +37 -0
  194. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +29 -0
  195. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -0
  196. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.ts +13 -0
  197. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +136 -0
  198. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +34 -0
  199. package/src/components/UNCardComponent/UNCardComponent.tsx +73 -0
  200. package/src/components/UNCardComponent/UNCardComponent.utils.ts +28 -0
  201. package/src/components/index.ts +4 -2
  202. package/src/custom.d.ts +5 -0
  203. package/src/helpers/BottomSheet/BottomSheet.styles.ts +70 -0
  204. package/src/helpers/{BottomSheet.tsx → BottomSheet/BottomSheet.tsx} +72 -110
  205. package/src/helpers/EventBus.ts +13 -13
  206. package/src/hooks/listenerToBus.ts +23 -0
  207. package/src/hooks/useAppStateListener.ts +25 -0
  208. package/src/index.tsx +5 -1
  209. package/src/messages/nativeMessages/index.ts +3 -0
  210. package/src/messages/webMessages/bookPaymentMessage.ts +12 -0
  211. package/src/{webComponent → messages}/webMessages/cardMessage.ts +4 -2
  212. package/src/messages/webMessages/index.ts +21 -0
  213. package/src/{webComponent → messages}/webMessages/pageMessage.ts +0 -0
  214. package/src/{webComponent → messages}/webMessages/unitMessages.ts +1 -0
  215. package/src/nativeComponenet/NativeComponentExample.tsx +2 -2
  216. package/src/scripts/html/bodyHtml.ts +46 -0
  217. package/src/scripts/html/bodyScript.ts +67 -0
  218. package/src/sharedTypes/bookPayment.types.ts +27 -0
  219. package/src/sharedTypes/card.types.ts +59 -0
  220. package/src/sharedTypes/index.ts +2 -0
  221. package/src/sharedTypes/types.ts +35 -0
  222. package/src/styles/variables.ts +9 -0
  223. package/src/unitSdkManager/UnitSdk.api.ts +31 -0
  224. package/src/unitSdkManager/UnitSdkManager.ts +33 -0
  225. package/src/webComponent/WebComponent.tsx +43 -45
  226. package/src/webComponent/html.ts +22 -46
  227. package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js.map +0 -1
  228. package/lib/commonjs/components/Card/CardComponent.js.map +0 -1
  229. package/lib/commonjs/helpers/BottomSheet.js.map +0 -1
  230. package/lib/commonjs/webComponent/webMessages/cardMessage.js.map +0 -1
  231. package/lib/commonjs/webComponent/webMessages/unitMessages.js.map +0 -1
  232. package/lib/module/components/BottomSheet/BottomSheetComponent.js +0 -118
  233. package/lib/module/components/BottomSheet/BottomSheetComponent.js.map +0 -1
  234. package/lib/module/components/Card/CardComponent.js +0 -75
  235. package/lib/module/components/Card/CardComponent.js.map +0 -1
  236. package/lib/module/helpers/BottomSheet.js.map +0 -1
  237. package/lib/module/webComponent/webMessages/cardMessage.js +0 -6
  238. package/lib/module/webComponent/webMessages/cardMessage.js.map +0 -1
  239. package/lib/module/webComponent/webMessages/unitMessages.js.map +0 -1
  240. package/src/components/BottomSheet/BottomSheetComponent.tsx +0 -113
  241. package/src/components/Card/CardComponent.tsx +0 -75
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import type { BookPaymentEvent, BookPaymentMessage } from './bookPaymentMessage';\nimport type { CardEvent, CardMessage } from './cardMessage';\nimport type { PageEvent, PageMessage } from './pageMessage';\nimport type { UnitEvent, UnitMessage } from './unitMessages';\n\nexport type WebViewMessageType =\n | PageMessage\n | CardMessage\n | UnitMessage\n | BookPaymentMessage\n\ntype WebViewEvent =\n | PageEvent\n | UnitEvent\n | CardEvent\n | BookPaymentEvent\n\nexport interface WebViewMessage {\n type: WebViewMessageType,\n details?: WebViewEvent\n}\n"],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnitMessage"],"sources":["unitMessages.ts"],"sourcesContent":["export enum UnitMessage {\n UNIT_REQUEST_RENDERING = 'unitRequestRendering',\n UNIT_REQUEST_REFRESH = 'unitRequestRefresh',\n UNIT_REQUEST_CLOSE_FLOW = 'unitRequestCloseFlow',\n UNIT_REQUEST_OPEN_LINK = 'unitRequestOpenLink',\n UNIT_ON_LOAD = 'unitOnLoad'\n}\n\nexport interface RequestRenderingData {\n nativePlace: string;\n nativeComponent: string;\n}\n\nexport interface RequestRenderingEvent {\n data: string;\n}\n\nexport interface RequestRefreshEvent {\n refEvent: string;\n dependencies: string[];\n resourceId: string;\n}\n\nexport interface RequestOpenLinkEvent {\n href: string;\n target: string\n}\n\nexport type UnitEvent =\n | RequestRenderingEvent\n | RequestRefreshEvent\n | RequestOpenLinkEvent\n"],"mappings":"AAAA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W"}
@@ -1,6 +1,6 @@
1
1
  import { requireNativeComponent, UIManager, Platform } from 'react-native';
2
- const LINKING_ERROR = `The package 'unit-react-native-components' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
- ios: "- You have run 'pod install'\n",
2
+ const LINKING_ERROR = 'The package \'react-native-unit-components\' doesn\'t seem to be linked. Make sure: \n\n' + Platform.select({
3
+ ios: '- You have run \'pod install\'\n',
4
4
  default: ''
5
5
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
6
6
  const ComponentName = 'UnitReactNativeComponentsView';
@@ -1 +1 @@
1
- {"version":3,"names":["requireNativeComponent","UIManager","Platform","LINKING_ERROR","select","ios","default","ComponentName","UnitReactNativeComponentsView","getViewManagerConfig","Error"],"sources":["NativeComponentExample.tsx"],"sourcesContent":["import {\n requireNativeComponent,\n UIManager,\n Platform,\n ViewStyle,\n} from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'unit-react-native-components' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype UnitReactNativeComponentsProps = {\n color: string;\n style: ViewStyle;\n};\n\nconst ComponentName = 'UnitReactNativeComponentsView';\n\nexport const UnitReactNativeComponentsView =\n UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<UnitReactNativeComponentsProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n"],"mappings":"AAAA,SACEA,sBADF,EAEEC,SAFF,EAGEC,QAHF,QAKO,cALP;AAOA,MAAMC,aAAa,GAChB,uFAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAWA,MAAMC,aAAa,GAAG,+BAAtB;AAEA,OAAO,MAAMC,6BAA6B,GACxCP,SAAS,CAACQ,oBAAV,CAA+BF,aAA/B,KAAiD,IAAjD,GACIP,sBAAsB,CAAiCO,aAAjC,CAD1B,GAEI,MAAM;EACN,MAAM,IAAIG,KAAJ,CAAUP,aAAV,CAAN;AACD,CALE"}
1
+ {"version":3,"names":["requireNativeComponent","UIManager","Platform","LINKING_ERROR","select","ios","default","ComponentName","UnitReactNativeComponentsView","getViewManagerConfig","Error"],"sources":["NativeComponentExample.tsx"],"sourcesContent":["import {\n requireNativeComponent,\n UIManager,\n Platform,\n ViewStyle,\n} from 'react-native';\n\nconst LINKING_ERROR =\n 'The package \\'react-native-unit-components\\' doesn\\'t seem to be linked. Make sure: \\n\\n' +\n Platform.select({ ios: '- You have run \\'pod install\\'\\n', default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype UnitReactNativeComponentsProps = {\n color: string;\n style: ViewStyle;\n};\n\nconst ComponentName = 'UnitReactNativeComponentsView';\n\nexport const UnitReactNativeComponentsView =\n UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<UnitReactNativeComponentsProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n"],"mappings":"AAAA,SACEA,sBADF,EAEEC,SAFF,EAGEC,QAHF,QAKO,cALP;AAOA,MAAMC,aAAa,GACjB,6FACAD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,kCAAP;EAA2CC,OAAO,EAAE;AAApD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAWA,MAAMC,aAAa,GAAG,+BAAtB;AAEA,OAAO,MAAMC,6BAA6B,GACxCP,SAAS,CAACQ,oBAAV,CAA+BF,aAA/B,KAAiD,IAAjD,GACIP,sBAAsB,CAAiCO,aAAjC,CAD1B,GAEI,MAAM;EACN,MAAM,IAAIG,KAAJ,CAAUP,aAAV,CAAN;AACD,CALE"}
@@ -0,0 +1,42 @@
1
+ export const webViewId = 'webViewContainer';
2
+ export let PresentationMode;
3
+
4
+ (function (PresentationMode) {
5
+ PresentationMode["CoverInjectedHeight"] = "coverInjectedHeight";
6
+ PresentationMode["Inherit"] = "inherit";
7
+ PresentationMode["Default"] = "deafult";
8
+ })(PresentationMode || (PresentationMode = {}));
9
+
10
+ export const getHtmlBody = (unitComponent, unitComponentProps, presentationMode) => {
11
+ const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;
12
+
13
+ switch (presentationMode) {
14
+ case PresentationMode.CoverInjectedHeight:
15
+ return getCoverInjectedHeightBodyScript(currentComponent);
16
+
17
+ case PresentationMode.Inherit:
18
+ return getInheritParentSizeScript(currentComponent);
19
+
20
+ default:
21
+ return currentComponent;
22
+ }
23
+ };
24
+
25
+ const getCoverInjectedHeightBodyScript = currentUnitScript => {
26
+ return `
27
+ <div id=${webViewId}>
28
+ <div style="height: 100%; display: block; padding: 1px;">
29
+ ${currentUnitScript}
30
+ </div>
31
+ </div>
32
+ `;
33
+ };
34
+
35
+ const getInheritParentSizeScript = currentUnitScript => {
36
+ return `
37
+ <div style="height: 100vh">
38
+ ${currentUnitScript}
39
+ </div>
40
+ `;
41
+ };
42
+ //# sourceMappingURL=bodyHtml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG,kBAAlB;AAEP,WAAYC,gBAAZ;;WAAYA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,KAAAA,gB;;AAcZ,OAAO,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,OAAMD,aAAc,GAA3F;;EAEA,QAAQE,gBAAR;IACE,KAAKJ,gBAAgB,CAACM,mBAAtB;MACE,OAAOC,gCAAgC,CAACF,gBAAD,CAAvC;;IACF,KAAKL,gBAAgB,CAACQ,OAAtB;MACE,OAAOC,0BAA0B,CAACJ,gBAAD,CAAjC;;IACF;MACE,OAAOA,gBAAP;EANJ;AAQD,CAXM;;AAaP,MAAME,gCAAgC,GAAIG,iBAAD,IAA+B;EACtE,OAAQ;AACV,cAAcX,SAAU;AACxB;AACA,UAAUW,iBAAkB;AAC5B;AACA;AACA,GANE;AAOD,CARD;;AAUA,MAAMD,0BAA0B,GAAIC,iBAAD,IAA+B;EAChE,OAAQ;AACV;AACA,QAAQA,iBAAkB;AAC1B;AACA,GAJE;AAKD,CAND"}
@@ -0,0 +1,64 @@
1
+ import { CardMessage } from '../../messages/webMessages/cardMessage';
2
+ import { PageMessage } from '../../messages/webMessages/pageMessage';
3
+ import { UnitMessage } from '../../messages/webMessages/unitMessages';
4
+ export const POST_MESSAGE_TO_SDK = `
5
+ const postMessageToSDK = (message) => {
6
+ if ('ReactNativeWebView' in window) {
7
+ const messageString = JSON.stringify(message)
8
+ window['ReactNativeWebView'].postMessage(messageString)
9
+ }
10
+ }
11
+ `;
12
+ export const POST_PAGE_HEIGHT = `
13
+ const postHeight = () => {
14
+ setTimeout(() => {
15
+ const height = window.document.documentElement.getBoundingClientRect().height
16
+ postMessageToSDK({ type: "${PageMessage.PAGE_HEIGHT}", details: { height } })
17
+ })
18
+ }
19
+ `;
20
+ export const LISTENERS = {
21
+ isPageLoaded: `
22
+ window.addEventListener('DOMContentLoaded', e => {
23
+ postMessageToSDK({ type: "${PageMessage.PAGE_LOADED}" })
24
+ });
25
+ `,
26
+ requestRendering: `
27
+ window.addEventListener("${UnitMessage.UNIT_REQUEST_RENDERING}", (e) => {
28
+ postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_RENDERING}", details: { data: JSON.stringify(e.detail) }})
29
+ });
30
+ `,
31
+ onLoad: `
32
+ window.addEventListener("${UnitMessage.UNIT_ON_LOAD}", (e) => {
33
+ postHeight()
34
+ postMessageToSDK({ type: "${UnitMessage.UNIT_ON_LOAD}" })
35
+ });
36
+ `,
37
+ requestCloseFlow: `
38
+ window.addEventListener("${UnitMessage.UNIT_REQUEST_CLOSE_FLOW}", (e) => {
39
+ postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_CLOSE_FLOW}" })
40
+ });
41
+ `,
42
+ requestOpenLink: `
43
+ window.addEventListener("${UnitMessage.UNIT_REQUEST_OPEN_LINK}", (e) => {
44
+ postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_OPEN_LINK}", details: e.detail })
45
+ });
46
+ `,
47
+ cardStatusChange: `
48
+ window.addEventListener("${CardMessage.CARD_STATUS_CHANGED}", (e) => {
49
+ const response = e.detail
50
+ response.then((data) => {
51
+ postMessageToSDK({ type: "${CardMessage.CARD_STATUS_CHANGED}", details: { card: JSON.stringify(data.data) }})
52
+ }).catch((e) => {
53
+ console.log(e)
54
+ })
55
+ });
56
+ `
57
+ };
58
+ export const DISPTACH_RENDERING_EVENT = `
59
+ const dispatchRenderingEvent = (details) => {
60
+ const event = new CustomEvent("${UnitMessage.UNIT_REQUEST_RENDERING}",{ detail: JSON.parse(details) })
61
+ window.dispatchEvent(event)
62
+ }
63
+ `;
64
+ //# sourceMappingURL=bodyScript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CardMessage","PageMessage","UnitMessage","POST_MESSAGE_TO_SDK","POST_PAGE_HEIGHT","PAGE_HEIGHT","LISTENERS","isPageLoaded","PAGE_LOADED","requestRendering","UNIT_REQUEST_RENDERING","onLoad","UNIT_ON_LOAD","requestCloseFlow","UNIT_REQUEST_CLOSE_FLOW","requestOpenLink","UNIT_REQUEST_OPEN_LINK","cardStatusChange","CARD_STATUS_CHANGED","DISPTACH_RENDERING_EVENT"],"sources":["bodyScript.ts"],"sourcesContent":["import { CardMessage } from '../../messages/webMessages/cardMessage';\nimport { PageMessage } from '../../messages/webMessages/pageMessage';\nimport { UnitMessage } from '../../messages/webMessages/unitMessages';\n\nexport const POST_MESSAGE_TO_SDK = `\n const postMessageToSDK = (message) => {\n if ('ReactNativeWebView' in window) {\n const messageString = JSON.stringify(message)\n window['ReactNativeWebView'].postMessage(messageString)\n }\n }\n`;\n\nexport const POST_PAGE_HEIGHT = `\n const postHeight = () => {\n setTimeout(() => {\n const height = window.document.documentElement.getBoundingClientRect().height\n postMessageToSDK({ type: \"${PageMessage.PAGE_HEIGHT}\", details: { height } })\n })\n }\n`;\n\nexport const LISTENERS = {\n isPageLoaded:`\n window.addEventListener('DOMContentLoaded', e => {\n postMessageToSDK({ type: \"${PageMessage.PAGE_LOADED}\" })\n });\n `,\n requestRendering: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_RENDERING}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_RENDERING}\", details: { data: JSON.stringify(e.detail) }})\n });\n `,\n onLoad: `\n window.addEventListener(\"${UnitMessage.UNIT_ON_LOAD}\", (e) => {\n postHeight()\n postMessageToSDK({ type: \"${UnitMessage.UNIT_ON_LOAD}\" })\n });\n `,\n requestCloseFlow: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_CLOSE_FLOW}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_CLOSE_FLOW}\" })\n });\n `,\n requestOpenLink: `\n window.addEventListener(\"${UnitMessage.UNIT_REQUEST_OPEN_LINK}\", (e) => {\n postMessageToSDK({ type: \"${UnitMessage.UNIT_REQUEST_OPEN_LINK}\", details: e.detail })\n });\n `,\n cardStatusChange: `\n window.addEventListener(\"${CardMessage.CARD_STATUS_CHANGED}\", (e) => {\n const response = e.detail\n response.then((data) => {\n postMessageToSDK({ type: \"${CardMessage.CARD_STATUS_CHANGED}\", details: { card: JSON.stringify(data.data) }})\n }).catch((e) => {\n console.log(e)\n })\n });\n `\n};\n\nexport const DISPTACH_RENDERING_EVENT = `\n const dispatchRenderingEvent = (details) => {\n const event = new CustomEvent(\"${UnitMessage.UNIT_REQUEST_RENDERING}\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n`;\n"],"mappings":"AAAA,SAASA,WAAT,QAA4B,wCAA5B;AACA,SAASC,WAAT,QAA4B,wCAA5B;AACA,SAASC,WAAT,QAA4B,yCAA5B;AAEA,OAAO,MAAMC,mBAAmB,GAAI;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,CAPO;AASP,OAAO,MAAMC,gBAAgB,GAAI;AACjC;AACA;AACA;AACA,kCAAkCH,WAAW,CAACI,WAAY;AAC1D;AACA;AACA,CAPO;AASP,OAAO,MAAMC,SAAS,GAAG;EACvBC,YAAY,EAAE;AAChB;AACA,kCAAkCN,WAAW,CAACO,WAAY;AAC1D;AACA,GALyB;EAMvBC,gBAAgB,EAAG;AACrB,+BAA+BP,WAAW,CAACQ,sBAAuB;AAClE,kCAAkCR,WAAW,CAACQ,sBAAuB;AACrE;AACA,GAVyB;EAWvBC,MAAM,EAAG;AACX,+BAA+BT,WAAW,CAACU,YAAa;AACxD;AACA,kCAAkCV,WAAW,CAACU,YAAa;AAC3D;AACA,GAhByB;EAiBvBC,gBAAgB,EAAG;AACrB,+BAA+BX,WAAW,CAACY,uBAAwB;AACnE,kCAAkCZ,WAAW,CAACY,uBAAwB;AACtE;AACA,GArByB;EAsBvBC,eAAe,EAAG;AACpB,+BAA+Bb,WAAW,CAACc,sBAAuB;AAClE,kCAAkCd,WAAW,CAACc,sBAAuB;AACrE;AACA,GA1ByB;EA2BvBC,gBAAgB,EAAG;AACrB,+BAA+BjB,WAAW,CAACkB,mBAAoB;AAC/D;AACA;AACA,oCAAoClB,WAAW,CAACkB,mBAAoB;AACpE;AACA;AACA;AACA;AACA;AApCyB,CAAlB;AAuCP,OAAO,MAAMC,wBAAwB,GAAI;AACzC;AACA,qCAAqCjB,WAAW,CAACQ,sBAAuB;AACxE;AACA;AACA,CALO"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bookPayment.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["bookPayment.types.ts"],"sourcesContent":["import type { Tags, Relationship } from \"./types\"\n\ntype BookPaymentStatus = \"Sent\" | \"Rejected\"\n\nexport type UNBookPaymentData = {\n type: \"bookPayment\",\n id: string,\n attributes: {\n createdAt: string | Date,\n status: BookPaymentStatus,\n reason: string,\n direction: 'Debit' | 'Credit',\n description: string,\n transactionSummaryOverride?: string,\n amount: string,\n tags: Tags,\n },\n relationships: {\n account: Relationship,\n customer?: Relationship,\n customers?: Relationship,\n counterpartyAccount: Relationship,\n counterpartyCustomer: Relationship,\n transaction: Relationship,\n recurringPayment: Relationship\n }\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=card.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["card.types.ts"],"sourcesContent":["import type { Address, FullName, Limits, Relationship, Tags } from \"./types\"\n\nexport type UNCardData = IndividualDebitCard | BusinessDebitCard\n\ntype CardStatus = \"Active\" | \"Inactive\" | \"Stolen\" | \"Lost\" | \"Frozen\" | \"ClosedByCustomer\" | \"SuspectedFraud\"\n\ntype IndividualDebitCard = {\n id: string,\n type: \"individualDebitCard\" | \"individualVirtualDebitCard\",\n attributes: {\n createdAt: string,\n last4Digits: string,\n expirationDate: string,\n status: CardStatus,\n shippingAddress?: Address, /* not exists in virtual card */\n updatedAt?: string,\n design?: string,\n additionalEmbossedText?: string,\n idempotencyKey?: string,\n tags?: Tags,\n limits?: Limits,\n printOnlyBusinessName?: boolean\n },\n relationships: {\n account: Relationship,\n customer: Relationship\n }\n}\n\ntype BusinessDebitCard = {\n id: string,\n type: \"businessDebitCard\" | \"businessVirtualDebitCard\",\n attributes: {\n fullName: FullName,\n dateOfBirth: string,\n address: Address,\n shippingAddress?: Address,\n phone: string,\n email: string,\n createdAt: string,\n last4Digits: string,\n expirationDate: string,\n status: CardStatus,\n updatedAt?: string,\n ssn?: string,\n passport?: string,\n nationality?: string,\n design?: string,\n additionalEmbossedText?: string,\n idempotencyKey?: string,\n tags?: Record<string, string>\n limits?: Limits,\n printOnlyBusinessName?: boolean\n },\n relationships: {\n account: Relationship,\n customer: Relationship\n }\n}\n"],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './bookPayment.types';
2
+ export * from './card.types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './bookPayment.types';\nexport * from './card.types';\n"],"mappings":"AAAA,cAAc,qBAAd;AACA,cAAc,cAAd"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type Address = {\n street: string,\n street2?: string,\n city: string,\n state: string,\n postalCode: string,\n country: string\n}\n\nexport type Limits = {\n dailyWithdrawal?: string | number,\n dailyPurchase?: string | number,\n monthlyWithdrawal?: string | number,\n monthlyPurchase?: string | number,\n}\n\ntype Data = {\n type: string,\n id: string\n}\n\nexport type Relationship = {\n data:\n | null\n | []\n | Data\n | Data[]\n}\n\nexport type FullName = {\n first: string,\n last: string\n}\n\nexport type Tags = Record<string, string> // TODO: specify Tag type\n"],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export const VARIABLES = {
2
+ COLORS: {
3
+ WHITE: '#ffffff',
4
+ BLACK: '#000000',
5
+ BLUE: '#005fF0',
6
+ GREY: '#bbbbbb',
7
+ SILVER_FLAKE: '#D5DDE0'
8
+ }
9
+ };
10
+ //# sourceMappingURL=variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VARIABLES","COLORS","WHITE","BLACK","BLUE","GREY","SILVER_FLAKE"],"sources":["variables.ts"],"sourcesContent":["export const VARIABLES = {\n COLORS: {\n WHITE: '#ffffff',\n BLACK: '#000000',\n BLUE: '#005fF0',\n GREY: '#bbbbbb',\n SILVER_FLAKE: '#D5DDE0'\n }\n};\n"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG;EACvBC,MAAM,EAAE;IACNC,KAAK,EAAE,SADD;IAENC,KAAK,EAAE,SAFD;IAGNC,IAAI,EAAE,SAHA;IAINC,IAAI,EAAE,SAJA;IAKNC,YAAY,EAAE;EALR;AADe,CAAlB"}
@@ -0,0 +1,37 @@
1
+ import EventBus from '../helpers/EventBus';
2
+ import { NativeMessage } from '../messages/nativeMessages';
3
+ import { UnitSDK, UNIT_SCRIPT_URL } from './UnitSdkManager';
4
+ let isLoadingScript = false;
5
+ /** globalUnitScript is exported ONLY to our project components **/
6
+
7
+ export let globalUnitScript = '';
8
+ export const fetchUnitScript = async () => {
9
+ const env = UnitSDK.getEnv();
10
+
11
+ if (isLoadingScript || globalUnitScript || !env) {
12
+ // init function is called and success OR in progress
13
+ return null;
14
+ }
15
+
16
+ isLoadingScript = true;
17
+
18
+ try {
19
+ const unitScriptRes = await fetch(UNIT_SCRIPT_URL[env]);
20
+ const unitScript = await unitScriptRes.text();
21
+
22
+ if (unitScript) {
23
+ EventBus.Instance.event(NativeMessage.IS_SCRIPT_FETCHED, {
24
+ unitScript
25
+ });
26
+ globalUnitScript = unitScript;
27
+ }
28
+
29
+ return null;
30
+ } catch (e) {
31
+ console.log(e);
32
+ return null;
33
+ } finally {
34
+ isLoadingScript = false;
35
+ }
36
+ };
37
+ //# sourceMappingURL=UnitSdk.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EventBus","NativeMessage","UnitSDK","UNIT_SCRIPT_URL","isLoadingScript","globalUnitScript","fetchUnitScript","env","getEnv","unitScriptRes","fetch","unitScript","text","Instance","event","IS_SCRIPT_FETCHED","e","console","log"],"sources":["UnitSdk.api.ts"],"sourcesContent":["import EventBus from '../helpers/EventBus';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport { UnitSDK, UNIT_SCRIPT_URL } from './UnitSdkManager';\n\nlet isLoadingScript = false;\n\n/** globalUnitScript is exported ONLY to our project components **/\nexport let globalUnitScript = '';\n\nexport const fetchUnitScript = async () => {\n const env = UnitSDK.getEnv();\n if (isLoadingScript || globalUnitScript || !env) {\n // init function is called and success OR in progress\n return null;\n }\n isLoadingScript = true;\n try {\n const unitScriptRes = await fetch(UNIT_SCRIPT_URL[env]);\n const unitScript = await unitScriptRes.text();\n if (unitScript) {\n EventBus.Instance.event(NativeMessage.IS_SCRIPT_FETCHED, { unitScript });\n globalUnitScript = unitScript;\n }\n return null;\n } catch (e) {\n console.log(e);\n return null;\n } finally {\n isLoadingScript = false;\n }\n};\n"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,qBAArB;AACA,SAASC,aAAT,QAA8B,4BAA9B;AACA,SAASC,OAAT,EAAkBC,eAAlB,QAAyC,kBAAzC;AAEA,IAAIC,eAAe,GAAG,KAAtB;AAEA;;AACA,OAAO,IAAIC,gBAAgB,GAAG,EAAvB;AAEP,OAAO,MAAMC,eAAe,GAAG,YAAY;EACzC,MAAMC,GAAG,GAAGL,OAAO,CAACM,MAAR,EAAZ;;EACA,IAAIJ,eAAe,IAAIC,gBAAnB,IAAuC,CAACE,GAA5C,EAAiD;IAC/C;IACA,OAAO,IAAP;EACD;;EACDH,eAAe,GAAG,IAAlB;;EACA,IAAI;IACF,MAAMK,aAAa,GAAG,MAAMC,KAAK,CAACP,eAAe,CAACI,GAAD,CAAhB,CAAjC;IACA,MAAMI,UAAU,GAAG,MAAMF,aAAa,CAACG,IAAd,EAAzB;;IACA,IAAID,UAAJ,EAAgB;MACdX,QAAQ,CAACa,QAAT,CAAkBC,KAAlB,CAAwBb,aAAa,CAACc,iBAAtC,EAAyD;QAAEJ;MAAF,CAAzD;MACAN,gBAAgB,GAAGM,UAAnB;IACD;;IACD,OAAO,IAAP;EACD,CARD,CAQE,OAAOK,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;IACA,OAAO,IAAP;EACD,CAXD,SAWU;IACRZ,eAAe,GAAG,KAAlB;EACD;AACF,CArBM"}
@@ -0,0 +1,38 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { fetchUnitScript } from './UnitSdk.api';
4
+ export let UNEnvironment;
5
+
6
+ (function (UNEnvironment) {
7
+ UNEnvironment["sandbox"] = "sandbox";
8
+ UNEnvironment["production"] = "production";
9
+ })(UNEnvironment || (UNEnvironment = {}));
10
+
11
+ export const UNIT_SCRIPT_URL = {
12
+ [UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',
13
+ [UNEnvironment.production]: 'https://ui.unit.co/components.js'
14
+ };
15
+ export class UnitSDK {}
16
+
17
+ _defineProperty(UnitSDK, "env", void 0);
18
+
19
+ _defineProperty(UnitSDK, "theme", void 0);
20
+
21
+ _defineProperty(UnitSDK, "init", async (env, theme) => {
22
+ try {
23
+ UnitSDK.env = env;
24
+ UnitSDK.theme = theme;
25
+ await fetchUnitScript();
26
+ } catch (e) {
27
+ console.log(e);
28
+ }
29
+ });
30
+
31
+ _defineProperty(UnitSDK, "getEnv", () => {
32
+ return UnitSDK.env;
33
+ });
34
+
35
+ _defineProperty(UnitSDK, "getTheme", () => {
36
+ return UnitSDK.theme;
37
+ });
38
+ //# sourceMappingURL=UnitSdkManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fetchUnitScript","UNEnvironment","UNIT_SCRIPT_URL","sandbox","production","UnitSDK","env","theme","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import { fetchUnitScript } from './UnitSdk.api';\n\nexport enum UNEnvironment {\n sandbox = 'sandbox',\n production = 'production'\n}\n\nexport const UNIT_SCRIPT_URL = {\n [UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',\n [UNEnvironment.production]: 'https://ui.unit.co/components.js'\n};\nexport class UnitSDK {\n protected static env?: UNEnvironment;\n protected static theme?: string;\n\n public static init = async (env: UNEnvironment, theme: string) => {\n try {\n this.env = env;\n this.theme = theme;\n await fetchUnitScript();\n } catch (e) {\n console.log(e);\n }\n };\n\n public static getEnv = () => {\n return this.env;\n };\n\n public static getTheme = () => {\n return this.theme;\n };\n}\n"],"mappings":";;AAAA,SAASA,eAAT,QAAgC,eAAhC;AAEA,WAAYC,aAAZ;;WAAYA,a;EAAAA,a;EAAAA,a;GAAAA,a,KAAAA,a;;AAKZ,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACD,aAAa,CAACE,OAAf,GAAyB,oCADI;EAE7B,CAACF,aAAa,CAACG,UAAf,GAA4B;AAFC,CAAxB;AAIP,OAAO,MAAMC,OAAN,CAAc;;gBAARA,O;;gBAAAA,O;;gBAAAA,O,UAIU,OAAOC,GAAP,EAA2BC,KAA3B,KAA6C;EAChE,IAAI;IALKF,OAMP,CAAKC,GAAL,GAAWA,GAAX;IANOD,OAOP,CAAKE,KAAL,GAAaA,KAAb;IACA,MAAMP,eAAe,EAArB;EACD,CAJD,CAIE,OAAOQ,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;EACD;AACF,C;;gBAZUH,O,YAcY,MAAM;EAC3B,OAfSA,OAeF,CAAKC,GAAZ;AACD,C;;gBAhBUD,O,cAkBc,MAAM;EAC7B,OAnBSA,OAmBF,CAAKE,KAAZ;AACD,C"}
@@ -1,33 +1,51 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { Dimensions } from 'react-native';
3
2
  import { WebView } from 'react-native-webview';
4
- import EventBus, { BusEvent } from '../helpers/EventBus';
5
- import html from './html';
6
- import { UnitMessage } from './webMessages/unitMessages';
3
+ import EventBus from '../helpers/EventBus';
4
+ import html, { HTML_PLACEHOLDER } from './html';
5
+ import { UnitMessage } from '../messages/webMessages/unitMessages';
6
+ import { useListenerToBus } from '../hooks/listenerToBus';
7
+ import { getHtmlBody } from '../scripts/html/bodyHtml';
8
+ import { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';
9
+ import { NativeMessage } from '../messages/nativeMessages';
7
10
  export let WebComponentType;
8
11
 
9
12
  (function (WebComponentType) {
10
13
  WebComponentType["card"] = "unit-elements-card";
14
+ WebComponentType["bookPayment"] = "unit-elements-book-payment";
15
+ WebComponentType["activity"] = "unit-elements-activity";
11
16
  WebComponentType["slot"] = "unit-elements-sdk-slot";
12
17
  })(WebComponentType || (WebComponentType = {}));
13
18
 
14
- export const WebComponent = /*#__PURE__*/React.forwardRef((props, webRef) => {
19
+ export const WebComponent = /*#__PURE__*/React.forwardRef(function WebComponent(props, webRef) {
20
+ const [unitScript, setUnitScript] = useState(globalUnitScript);
15
21
  const [sourceHtml, setSourceHtml] = useState(null);
16
- const windowWidth = Dimensions.get('window').width;
22
+
23
+ const listenerAction = data => {
24
+ setUnitScript(data.unitScript);
25
+ };
26
+
27
+ useListenerToBus([{
28
+ busEventKey: NativeMessage.IS_SCRIPT_FETCHED,
29
+ action: listenerAction
30
+ }]);
17
31
  useEffect(() => {
18
- const component = props.type.valueOf();
19
- let newHtml = html.replace('<COMPONENT>', `<${component} ${props.params || ''}> </${component}>`);
20
- newHtml = newHtml.replace('<SCRIPT_FROM_NATIVE>', props.script || '');
32
+ if (!unitScript) {
33
+ fetchUnitScript();
34
+ return;
35
+ }
36
+
37
+ let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), props.params, props.presentationMode));
38
+ newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');
21
39
  setSourceHtml(newHtml);
22
- }, [props.params]);
40
+ }, [props.params, unitScript]);
23
41
 
24
42
  const onMessage = e => {
25
43
  const message = JSON.parse(e.nativeEvent.data);
26
44
 
27
45
  if (message.type == UnitMessage.UNIT_REQUEST_REFRESH && message.details) {
28
- EventBus.Instance.event(BusEvent.REQUEST_REFRESH, message.details);
46
+ EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details);
29
47
  } else {
30
- props.onMessage(message);
48
+ props.onMessage && props.onMessage(message);
31
49
  }
32
50
  };
33
51
 
@@ -35,10 +53,12 @@ export const WebComponent = /*#__PURE__*/React.forwardRef((props, webRef) => {
35
53
  return /*#__PURE__*/React.createElement(WebView, {
36
54
  ref: webRef,
37
55
  cacheEnabled: false,
38
- scrollEnabled: false,
56
+ scrollEnabled: props.shouldEnableWebViewScroll,
39
57
  overScrollMode: "never",
58
+ injectedJavaScript: unitScript,
40
59
  style: {
41
- width: windowWidth
60
+ width: props.width ?? '100%',
61
+ flex: 1
42
62
  },
43
63
  source: {
44
64
  html: sourceHtml
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useState","Dimensions","WebView","EventBus","BusEvent","html","UnitMessage","WebComponentType","WebComponent","forwardRef","props","webRef","sourceHtml","setSourceHtml","windowWidth","get","width","component","type","valueOf","newHtml","replace","params","script","onMessage","e","message","JSON","parse","nativeEvent","data","UNIT_REQUEST_REFRESH","details","Instance","event","REQUEST_REFRESH"],"sources":["WebComponent.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Dimensions } from 'react-native';\nimport {\n WebView,\n WebViewMessageEvent\n} from 'react-native-webview'\nimport EventBus, { BusEvent } from '../helpers/EventBus';\n\nimport html from './html';\nimport type { CardEvent, CardMessage } from './webMessages/cardMessage';\nimport type { PageEvent, PageMessage } from './webMessages/pageMessage';\nimport { RequestRefreshEvent, UnitEvent, UnitMessage } from './webMessages/unitMessages';\n\nexport type WebViewMessageType =\n | PageMessage\n | CardMessage\n | UnitMessage\n\ntype WebViewEvent =\n | PageEvent\n | UnitEvent\n | CardEvent\n\nexport interface WebViewMessage {\n type: WebViewMessageType,\n details?: WebViewEvent\n}\n\nexport interface WebComponentProps {\n type: WebComponentType;\n params?: string;\n onMessage: (message: WebViewMessage) => void;\n script?: string;\n}\n\nexport enum WebComponentType {\n card = 'unit-elements-card',\n slot = 'unit-elements-sdk-slot'\n}\n\nexport const WebComponent = React.forwardRef<WebView, WebComponentProps>((props, webRef) => {\n const [sourceHtml, setSourceHtml] = useState<string | null>(null)\n\n const windowWidth = Dimensions.get('window').width;\n\n useEffect(() => {\n const component: string = props.type.valueOf()\n let newHtml = html.replace('<COMPONENT>', `<${component} ${props.params || ''}> </${component}>`)\n newHtml = newHtml.replace('<SCRIPT_FROM_NATIVE>', props.script || '')\n setSourceHtml(newHtml)\n }, [props.params])\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage\n\n if (message.type == UnitMessage.UNIT_REQUEST_REFRESH && message.details) {\n EventBus.Instance.event(BusEvent.REQUEST_REFRESH, message.details as RequestRefreshEvent)\n } else {\n props.onMessage(message)\n }\n }\n\n if (!sourceHtml) return null\n\n return (\n <WebView\n ref={webRef}\n cacheEnabled={false}\n scrollEnabled={false}\n overScrollMode=\"never\"\n style={{ width: windowWidth }}\n source={{ html: sourceHtml }}\n onMessage={onMessage} />\n )\n})\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SACEC,OADF,QAGO,sBAHP;AAIA,OAAOC,QAAP,IAAmBC,QAAnB,QAAmC,qBAAnC;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAGA,SAAyCC,WAAzC,QAA4D,4BAA5D;AAwBA,WAAYC,gBAAZ;;WAAYA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,KAAAA,gB;;AAKZ,OAAO,MAAMC,YAAY,gBAAGV,KAAK,CAACW,UAAN,CAA6C,CAACC,KAAD,EAAQC,MAAR,KAAmB;EAC1F,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8Bb,QAAQ,CAAgB,IAAhB,CAA5C;EAEA,MAAMc,WAAW,GAAGb,UAAU,CAACc,GAAX,CAAe,QAAf,EAAyBC,KAA7C;EAEAjB,SAAS,CAAC,MAAM;IACd,MAAMkB,SAAiB,GAAGP,KAAK,CAACQ,IAAN,CAAWC,OAAX,EAA1B;IACA,IAAIC,OAAO,GAAGf,IAAI,CAACgB,OAAL,CAAa,aAAb,EAA6B,IAAGJ,SAAU,IAAGP,KAAK,CAACY,MAAN,IAAgB,EAAG,OAAML,SAAU,GAAhF,CAAd;IACAG,OAAO,GAAGA,OAAO,CAACC,OAAR,CAAgB,sBAAhB,EAAwCX,KAAK,CAACa,MAAN,IAAgB,EAAxD,CAAV;IACAV,aAAa,CAACO,OAAD,CAAb;EACD,CALQ,EAKN,CAACV,KAAK,CAACY,MAAP,CALM,CAAT;;EAOA,MAAME,SAAS,GAAIC,CAAD,IAA4B;IAC5C,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAL,CAAWH,CAAC,CAACI,WAAF,CAAcC,IAAzB,CAAhB;;IAEA,IAAIJ,OAAO,CAACR,IAAR,IAAgBZ,WAAW,CAACyB,oBAA5B,IAAoDL,OAAO,CAACM,OAAhE,EAAyE;MACvE7B,QAAQ,CAAC8B,QAAT,CAAkBC,KAAlB,CAAwB9B,QAAQ,CAAC+B,eAAjC,EAAkDT,OAAO,CAACM,OAA1D;IACD,CAFD,MAEO;MACLtB,KAAK,CAACc,SAAN,CAAgBE,OAAhB;IACD;EACF,CARD;;EAUA,IAAI,CAACd,UAAL,EAAiB,OAAO,IAAP;EAEjB,oBACE,oBAAC,OAAD;IACE,GAAG,EAAED,MADP;IAEE,YAAY,EAAE,KAFhB;IAGE,aAAa,EAAE,KAHjB;IAIE,cAAc,EAAC,OAJjB;IAKE,KAAK,EAAE;MAAEK,KAAK,EAAEF;IAAT,CALT;IAME,MAAM,EAAE;MAAET,IAAI,EAAEO;IAAR,CANV;IAOE,SAAS,EAAEY;EAPb,EADF;AAUD,CAlC2B,CAArB"}
1
+ {"version":3,"names":["React","useEffect","useState","WebView","EventBus","html","HTML_PLACEHOLDER","UnitMessage","useListenerToBus","getHtmlBody","fetchUnitScript","globalUnitScript","NativeMessage","WebComponentType","WebComponent","forwardRef","props","webRef","unitScript","setUnitScript","sourceHtml","setSourceHtml","listenerAction","data","busEventKey","IS_SCRIPT_FETCHED","action","newHtml","replace","BODY","type","valueOf","params","presentationMode","SCRIPT_FROM_NATIVE","script","onMessage","e","message","JSON","parse","nativeEvent","UNIT_REQUEST_REFRESH","details","Instance","event","shouldEnableWebViewScroll","width","flex"],"sources":["WebComponent.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport type { WebViewMessage } from '../messages/webMessages';\nimport { getHtmlBody, PresentationMode } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { NativeMessage } from '../messages/nativeMessages';\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n width?: number;\n shouldEnableWebViewScroll?: boolean;\n}\n\nexport enum WebComponentType {\n card = 'unit-elements-card',\n bookPayment = 'unit-elements-book-payment',\n activity = 'unit-elements-activity',\n slot = 'unit-elements-sdk-slot'\n}\n\nexport const WebComponent = React.forwardRef<WebView, WebComponentProps>(function WebComponent(props, webRef) {\n const [unitScript, setUnitScript] = useState<string | undefined>(globalUnitScript);\n const [sourceHtml, setSourceHtml] = useState<string | null>(null);\n\n const listenerAction = (data: { unitScript?: string }) => {\n setUnitScript(data.unitScript);\n };\n\n useListenerToBus([{ busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: listenerAction }]);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), props.params, props.presentationMode));\n newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');\n setSourceHtml(newHtml);\n\n }, [props.params, unitScript]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n if (message.type == UnitMessage.UNIT_REQUEST_REFRESH && message.details) {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n } else {\n props.onMessage && props.onMessage(message);\n }\n };\n\n if (!sourceHtml) return null;\n\n return (\n <WebView\n ref={webRef}\n cacheEnabled={false}\n scrollEnabled={props.shouldEnableWebViewScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: props.width ?? '100%', flex: 1 }}\n source={{ html: sourceHtml }}\n onMessage={onMessage} />\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AACA,SAASC,OAAT,QAA6C,sBAA7C;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,IAAP,IAAeC,gBAAf,QAAuC,QAAvC;AACA,SAA8BC,WAA9B,QAAiD,sCAAjD;AACA,SAASC,gBAAT,QAAiC,wBAAjC;AAEA,SAASC,WAAT,QAA8C,0BAA9C;AACA,SAASC,eAAT,EAA0BC,gBAA1B,QAAkD,+BAAlD;AACA,SAASC,aAAT,QAA8B,4BAA9B;AAYA,WAAYC,gBAAZ;;WAAYA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,KAAAA,gB;;AAOZ,OAAO,MAAMC,YAAY,gBAAGd,KAAK,CAACe,UAAN,CAA6C,SAASD,YAAT,CAAsBE,KAAtB,EAA6BC,MAA7B,EAAqC;EAC5G,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8BjB,QAAQ,CAAqBS,gBAArB,CAA5C;EACA,MAAM,CAACS,UAAD,EAAaC,aAAb,IAA8BnB,QAAQ,CAAgB,IAAhB,CAA5C;;EAEA,MAAMoB,cAAc,GAAIC,IAAD,IAAmC;IACxDJ,aAAa,CAACI,IAAI,CAACL,UAAN,CAAb;EACD,CAFD;;EAIAV,gBAAgB,CAAC,CAAC;IAAEgB,WAAW,EAAEZ,aAAa,CAACa,iBAA7B;IAAgDC,MAAM,EAAEJ;EAAxD,CAAD,CAAD,CAAhB;EAEArB,SAAS,CAAC,MAAM;IACd,IAAI,CAACiB,UAAL,EAAiB;MACfR,eAAe;MACf;IACD;;IAED,IAAIiB,OAAO,GAAGtB,IAAI,CAACuB,OAAL,CAAatB,gBAAgB,CAACuB,IAA9B,EAAoCpB,WAAW,CAACO,KAAK,CAACc,IAAN,CAAWC,OAAX,EAAD,EAAuBf,KAAK,CAACgB,MAA7B,EAAqChB,KAAK,CAACiB,gBAA3C,CAA/C,CAAd;IACAN,OAAO,GAAGA,OAAO,CAACC,OAAR,CAAgBtB,gBAAgB,CAAC4B,kBAAjC,EAAqDlB,KAAK,CAACmB,MAAN,IAAgB,EAArE,CAAV;IACAd,aAAa,CAACM,OAAD,CAAb;EAED,CAVQ,EAUN,CAACX,KAAK,CAACgB,MAAP,EAAed,UAAf,CAVM,CAAT;;EAYA,MAAMkB,SAAS,GAAIC,CAAD,IAA4B;IAC5C,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAL,CAAWH,CAAC,CAACI,WAAF,CAAclB,IAAzB,CAAhB;;IACA,IAAIe,OAAO,CAACR,IAAR,IAAgBvB,WAAW,CAACmC,oBAA5B,IAAoDJ,OAAO,CAACK,OAAhE,EAAyE;MACvEvC,QAAQ,CAACwC,QAAT,CAAkBC,KAAlB,CAAwBtC,WAAW,CAACmC,oBAApC,EAA0DJ,OAAO,CAACK,OAAlE;IACD,CAFD,MAEO;MACL3B,KAAK,CAACoB,SAAN,IAAmBpB,KAAK,CAACoB,SAAN,CAAgBE,OAAhB,CAAnB;IACD;EACF,CAPD;;EASA,IAAI,CAAClB,UAAL,EAAiB,OAAO,IAAP;EAEjB,oBACE,oBAAC,OAAD;IACE,GAAG,EAAEH,MADP;IAEE,YAAY,EAAE,KAFhB;IAGE,aAAa,EAAED,KAAK,CAAC8B,yBAHvB;IAIE,cAAc,EAAC,OAJjB;IAKE,kBAAkB,EAAE5B,UALtB;IAME,KAAK,EAAE;MAAE6B,KAAK,EAAE/B,KAAK,CAAC+B,KAAN,IAAe,MAAxB;MAAgCC,IAAI,EAAE;IAAtC,CANT;IAOE,MAAM,EAAE;MAAE3C,IAAI,EAAEe;IAAR,CAPV;IAQE,SAAS,EAAEgB;EARb,EADF;AAWD,CA5C2B,CAArB"}
@@ -1,3 +1,9 @@
1
+ import { DISPTACH_RENDERING_EVENT, LISTENERS, POST_MESSAGE_TO_SDK, POST_PAGE_HEIGHT } from '../scripts/html/bodyScript';
2
+ export const HTML_PLACEHOLDER = {
3
+ SCRIPT_UNIT: '<SCRIPT_UNIT>',
4
+ BODY: '<BODY_HTML_CODE>',
5
+ SCRIPT_FROM_NATIVE: '<SCRIPT_FROM_NATIVE>'
6
+ };
1
7
  const htmlText = `
2
8
  <!DOCTYPE html>
3
9
  <html lang="en">
@@ -7,64 +13,32 @@ const htmlText = `
7
13
  <script>
8
14
  window.UnitMobileSDK = true
9
15
  </script>
10
- <script src="https://unit-white-labeled-banking.netlify.app/client-events.js"></script>
11
16
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
12
17
  </html>
13
18
 
14
- <body style="margin: 0">
15
- <COMPONENT>
19
+ <body style="margin: 0;">
20
+ ${HTML_PLACEHOLDER.BODY}
16
21
 
17
22
  <script>
18
- const postMessageToSDK = (message) => {
19
- if ('ReactNativeWebView' in window) {
20
- const messageString = JSON.stringify(message)
21
- window['ReactNativeWebView'].postMessage(messageString)
22
- }
23
- }
23
+ ${POST_MESSAGE_TO_SDK}
24
24
 
25
- const postHeight = () => {
26
- setTimeout(() => {
27
- const height = window.document.documentElement.getBoundingClientRect().height + 36
28
- postMessageToSDK({ type: "pageHeight", details: { height } })
29
- })
30
- }
25
+ ${POST_PAGE_HEIGHT}
31
26
 
32
- window.addEventListener('DOMContentLoaded', e => {
33
- postMessageToSDK({ type: "pageLoaded" })
34
- });
27
+ ${LISTENERS.isPageLoaded}
35
28
 
36
- window.addEventListener("unitRequestRendering", (e) => {
37
- postMessageToSDK({ type: "unitRequestRendering", details: { data: JSON.stringify(e.detail) }})
38
- });
29
+ ${LISTENERS.onLoad}
39
30
 
40
- window.addEventListener("unitOnLoad", (e) => {
41
- postHeight()
42
- postMessageToSDK({ type: "unitOnLoad" })
43
- });
31
+ ${LISTENERS.requestRendering}
44
32
 
45
- window.addEventListener("unitRequestCloseFlow", (e) => {
46
- postMessageToSDK({ type: "unitRequestCloseFlow" })
47
- });
33
+ ${LISTENERS.requestOpenLink}
48
34
 
49
- window.addEventListener("unitRequestOpenLink", (e) => {
50
- postMessageToSDK({ type: "unitRequestOpenLink", details: e.detail })
51
- });
35
+ ${LISTENERS.requestCloseFlow}
52
36
 
53
- window.addEventListener("unitCardStatusChanged", (e) => {
54
- const response = e.detail
55
- response.then((data) => {
56
- postMessageToSDK({ type: "cardStatusChanged", details: { card: JSON.stringify(data.data) }})
57
- }).catch((e) => {
58
- console.log(e)
59
- })
60
- });
37
+ ${LISTENERS.cardStatusChange}
61
38
 
62
- const dispatchRenderingEvent = (details) => {
63
- const event = new CustomEvent("unitRequestRendering",{ detail: JSON.parse(details) })
64
- window.dispatchEvent(event)
65
- }
39
+ ${DISPTACH_RENDERING_EVENT}
66
40
 
67
- <SCRIPT_FROM_NATIVE>
41
+ ${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}
68
42
  </script>
69
43
  </body>
70
44
  `;
@@ -1 +1 @@
1
- {"version":3,"names":["htmlText"],"sources":["html.ts"],"sourcesContent":["const 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 <script src=\"https://unit-white-labeled-banking.netlify.app/client-events.js\"></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 <COMPONENT>\n\n <script>\n const postMessageToSDK = (message) => {\n if ('ReactNativeWebView' in window) {\n const messageString = JSON.stringify(message)\n window['ReactNativeWebView'].postMessage(messageString)\n }\n }\n\n const postHeight = () => {\n setTimeout(() => {\n const height = window.document.documentElement.getBoundingClientRect().height + 36\n postMessageToSDK({ type: \"pageHeight\", details: { height } })\n })\n }\n\n window.addEventListener('DOMContentLoaded', e => {\n postMessageToSDK({ type: \"pageLoaded\" })\n });\n\n window.addEventListener(\"unitRequestRendering\", (e) => {\n postMessageToSDK({ type: \"unitRequestRendering\", details: { data: JSON.stringify(e.detail) }})\n });\n\n window.addEventListener(\"unitOnLoad\", (e) => {\n postHeight()\n postMessageToSDK({ type: \"unitOnLoad\" })\n });\n\n window.addEventListener(\"unitRequestCloseFlow\", (e) => {\n postMessageToSDK({ type: \"unitRequestCloseFlow\" })\n });\n\n window.addEventListener(\"unitRequestOpenLink\", (e) => {\n postMessageToSDK({ type: \"unitRequestOpenLink\", details: e.detail })\n });\n\n window.addEventListener(\"unitCardStatusChanged\", (e) => {\n const response = e.detail\n response.then((data) => {\n postMessageToSDK({ type: \"cardStatusChanged\", details: { card: JSON.stringify(data.data) }})\n }).catch((e) => {\n console.log(e)\n })\n });\n\n const dispatchRenderingEvent = (details) => {\n const event = new CustomEvent(\"unitRequestRendering\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n\n <SCRIPT_FROM_NATIVE>\n </script>\n </body>\n`\n\nexport default htmlText\n"],"mappings":"AAAA,MAAMA,QAAQ,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CArEA;AAuEA,eAAeA,QAAf"}
1
+ {"version":3,"names":["DISPTACH_RENDERING_EVENT","LISTENERS","POST_MESSAGE_TO_SDK","POST_PAGE_HEIGHT","HTML_PLACEHOLDER","SCRIPT_UNIT","BODY","SCRIPT_FROM_NATIVE","htmlText","isPageLoaded","onLoad","requestRendering","requestOpenLink","requestCloseFlow","cardStatusChange"],"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,SAASA,wBAAT,EAAmCC,SAAnC,EAA8CC,mBAA9C,EAAmEC,gBAAnE,QAA2F,4BAA3F;AAEA,OAAO,MAAMC,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,QAAQJ,mBAAoB;AAC5B;AACA,QAAQC,gBAAiB;AACzB;AACA,QAAQF,SAAS,CAACQ,YAAa;AAC/B;AACA,QAAQR,SAAS,CAACS,MAAO;AACzB;AACA,QAAQT,SAAS,CAACU,gBAAiB;AACnC;AACA,QAAQV,SAAS,CAACW,eAAgB;AAClC;AACA,QAAQX,SAAS,CAACY,gBAAiB;AACnC;AACA,QAAQZ,SAAS,CAACa,gBAAiB;AACnC;AACA,QAAQd,wBAAyB;AACjC;AACA,QAAQI,gBAAgB,CAACG,kBAAmB;AAC5C;AACA;AACA,CArCA;AAuCA,eAAeC,QAAf"}
@@ -0,0 +1 @@
1
+ export { default as CloseIcon } from './close.png';
@@ -0,0 +1,6 @@
1
+ export interface UNActivityComponentProps {
2
+ accountId: string;
3
+ customerToken: string;
4
+ theme?: string;
5
+ }
6
+ export declare const UNActivityComponent: (props: UNActivityComponentProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { UNActivityComponentProps } from './UNActivityComponent';
2
+ export declare const getActivityParams: (props: UNActivityComponentProps) => string;
@@ -0,0 +1,11 @@
1
+ import type { UNBookPaymentData } from '../../sharedTypes';
2
+ export interface UNBookPaymentComponentProps {
3
+ accountId: string;
4
+ customerToken: string;
5
+ isSameCustomer: boolean;
6
+ counterPartyAccountId: string;
7
+ counterPartyName: string;
8
+ theme?: string;
9
+ onPaymentCreated?: (data: UNBookPaymentData) => void;
10
+ }
11
+ export declare const UNBookPaymentComponent: (props: UNBookPaymentComponentProps) => JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';
2
+ export declare const getBookPaymentParams: (props: UNBookPaymentComponentProps) => string;
3
+ export declare const getBookPaymentScript: () => string;
@@ -0,0 +1 @@
1
+ export declare const BOTTOM_SHEET_MAX_PRECANTAGE_SIZE = 0.9;
@@ -0,0 +1,9 @@
1
+ export declare const getStylesObject: () => {
2
+ container: {
3
+ position: "absolute";
4
+ top: number;
5
+ bottom: number;
6
+ left: number;
7
+ right: number;
8
+ };
9
+ };
@@ -0,0 +1,5 @@
1
+ import type WebView from 'react-native-webview';
2
+ export declare const getBottomSheetScript: () => string;
3
+ export declare const renderingBottomSheetRequest: (currentWebView: WebView, renderingRequest: string) => void;
4
+ export declare const resetHtml: (currentWebView: WebView) => void;
5
+ export declare const handleHtmlFullHeight: (currentWebView: WebView | null, windowHeight: number) => number;
@@ -1,6 +1,8 @@
1
+ import type { UNCardData } from '../../sharedTypes';
1
2
  export interface UNCardComponentProps {
2
3
  cardId: string;
3
4
  customerToken: string;
4
- onStatusChanged?: (card: any) => void;
5
+ theme?: string;
6
+ onStatusChanged?: (card: UNCardData) => void;
5
7
  }
6
8
  export declare const UNCardComponent: (props: UNCardComponentProps) => JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type WebView from 'react-native-webview';
2
+ import type { UNCardComponentProps } from './UNCardComponent';
3
+ import { RequestRefreshEvent } from '../../messages/webMessages/unitMessages';
4
+ export declare const getCardParams: (props: UNCardComponentProps) => string;
5
+ export declare const getCardScript: () => string;
6
+ export declare const injectRefreshEventIfNeeded: (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null, cardId: string) => void;
@@ -1,2 +1,4 @@
1
- export * from './Card/CardComponent';
2
- export * from './BottomSheet/BottomSheetComponent';
1
+ export * from './UNCardComponent/UNCardComponent';
2
+ export * from './UNBottomSheetComponent/UNBottomSheetComponent';
3
+ export * from './UNBookPaymentComponent/UNBookPaymentComponent';
4
+ export * from './UNActivityComponent/UNActivityComponent';