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
package/README.md CHANGED
@@ -1,2 +1,157 @@
1
- # unit-react-native-components
2
- Unit React Native Components
1
+ # React Native SDK
2
+
3
+ ## Installation
4
+
5
+ Add the react-native-unit-components dependency to your project:
6
+
7
+ With npm:
8
+ ```bash
9
+ $ npm install --save react-native-unit-components
10
+ ```
11
+
12
+ With yarn:
13
+ ```bash
14
+ $ yarn add react-native-unit-components
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Initialize Unit SDK
20
+ Call to `UnitSDK.init` in your root component with the requested environment and your source.
21
+ This also helps us to improve the app performance.
22
+
23
+ The `UNEnvironment` enum should be used.
24
+ ```js
25
+ enum UNEnvironment {
26
+ sandbox,
27
+ production
28
+ }
29
+ ```
30
+ #### Input:
31
+ | Name | Type | Required | Description |
32
+ | --------------- | ---------------------------- | --------- | -------------------------------------------- |
33
+ | env | UNEnvironment | YES | Unit environment. |
34
+ | theme | string | NO | A URL that specifies the UI configuration. |
35
+
36
+ #### Example:
37
+ ```js
38
+ import React, { useEffect } from 'react';
39
+ import { UnitSDK, UNEnvironment } from 'react-native-unit-components';
40
+
41
+ const THEME = 'A URL that specifies the UI configuration';
42
+
43
+ export default function YourRootComponent() {
44
+ useEffect(() => {
45
+ UnitSDK.init(UNEnvironment.production, THEME);
46
+ }, [])
47
+ }
48
+ ```
49
+
50
+ ### Bottom Sheet Component
51
+
52
+ The `UNBottomSheetComponent` is a View that our SDK controls in order to show menus and forms in your application.
53
+ It is mandatory to have one `UNBottomSheetComponent` when our components are visible.
54
+
55
+ The `UNBottomSheetComponent` have an absolute position and should be able to take the full width the height of the screen.
56
+ We recommend to place the `UNBottomSheetComponent` in your root component of your application.
57
+
58
+ #### The structure of your root component might look as follows:
59
+ ```js
60
+ import React, { useEffect } from 'react';
61
+ import { UNBottomSheetComponent } from 'react-native-unit-components';
62
+
63
+ export default function YourRootComponent() {
64
+ return (
65
+ <>
66
+ <YourComponents />
67
+ <UNBottomSheetComponent />
68
+ </>
69
+ );
70
+ }
71
+ ```
72
+
73
+ ### Components
74
+
75
+ #### Card Component
76
+
77
+ ##### UNCardComponent props:
78
+ | Name | Type | Required | Description |
79
+ | --------------- | ---------------------------- | --------- | -------------------------------------------- |
80
+ | customerToken | string | YES | A Unit Customer token. |
81
+ | cardId | string | YES | Unit card id. |
82
+ | theme | string | No | A URL that specifies the UI configuration. |
83
+ | onStatusChanged | (card: UNCardData) => void | No | Callback for card status changes. |
84
+
85
+ ##### Example:
86
+ ```js
87
+ import React from 'react';
88
+ import { UNCardComponent, UNCardData } from 'react-native-unit-components';
89
+
90
+ export default function YourComponent() {
91
+ return (
92
+ <UNCardComponent
93
+ cardId={'632197'}
94
+ customerToken={''}
95
+ onStatusChanged={(card: UNCardData) => { console.log(card) }}
96
+ />
97
+ );
98
+ }
99
+ ```
100
+
101
+ #### Book Payment Component
102
+
103
+ ##### UNBookPaymentComponent props:
104
+ | Name | Type | Required | Description |
105
+ | --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
106
+ | customerToken | string | YES | A Unit Customer token. |
107
+ | accountId | string | YES | Unit account id. The account from which money is being sent. |
108
+ | counterPartyAccountId | string | YES | Unit account id. The account which will receive money. |
109
+ | counterPartyName | string | YES | Name of the counterparty. This is the name that will be displayed in the Book Payment UI during the transfer.|
110
+ | isSameCustomer | boolean | NO | Stating whether both accounts belong to the same customer. Allows fetching additional information about the counterparty account. Default "false" |
111
+ | theme | string | No | A URL that specifies the UI configuration. |
112
+ | onPaymentCreated | (bookPayment: BookPaymentType) => void | NO | Callback for the created bookPayment. |
113
+
114
+
115
+ ##### Example:
116
+ ```js
117
+ import React from 'react';
118
+ import { UNBookPaymentComponent } from 'react-native-unit-components';
119
+
120
+ export default function YourComponent() {
121
+ return (
122
+ <UNBookPaymentComponent
123
+ customerToken={''}
124
+ accountId={'1105561'}
125
+ counterPartyAccountId={'1105562'}
126
+ counterPartyName={'Peter Parker"'}
127
+ isSameCustomer={true}
128
+ onPaymentCreated={(bookPayment: BookPaymentType) => { console.log(bookPayment) }}
129
+ />
130
+ );
131
+ }
132
+ ```
133
+
134
+ #### Activity Component
135
+
136
+ ##### UNActivityComponent props:
137
+ | Name | Type | Required | Description |
138
+ | --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
139
+ | customerToken | string | YES | A Unit Customer token. |
140
+ | accountId | string | No | Unit account id. The account for which the activity will be shown. If not specified: the activity of the customer (all accounts) will be shown |
141
+ | theme | string | No | A URL that specifies the UI configuration. |
142
+
143
+
144
+ ##### Example:
145
+ ```js
146
+ import React from 'react';
147
+ import { UNActivityComponent } from 'react-native-unit-components';
148
+
149
+ export default function YourComponent() {
150
+ return (
151
+ <UNActivityComponent
152
+ customerToken={''}
153
+ accountId={'1105561'}
154
+ />
155
+ );
156
+ }
157
+ ```
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CloseIcon", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _close.default;
10
+ }
11
+ });
12
+
13
+ var _close = _interopRequireDefault(require("./close.png"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as CloseIcon } from './close.png';\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UNActivityComponent = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _bodyHtml = require("../../scripts/html/bodyHtml");
11
+
12
+ var _WebComponent = require("../../webComponent/WebComponent");
13
+
14
+ var _UNActivityComponent = require("./UNActivityComponent.utils");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ const UNActivityComponent = props => {
19
+ return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
20
+ type: _WebComponent.WebComponentType.activity,
21
+ presentationMode: _bodyHtml.PresentationMode.Inherit,
22
+ params: (0, _UNActivityComponent.getActivityParams)(props),
23
+ shouldEnableWebViewScroll: false
24
+ });
25
+ };
26
+
27
+ exports.UNActivityComponent = UNActivityComponent;
28
+ //# sourceMappingURL=UNActivityComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UNActivityComponent","props","WebComponentType","activity","PresentationMode","Inherit","getActivityParams"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n return (\n <WebComponent\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n shouldEnableWebViewScroll={false}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAQO,MAAMA,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,oBACE,6BAAC,0BAAD;IACE,IAAI,EAAEC,8BAAA,CAAiBC,QADzB;IAEE,gBAAgB,EAAEC,0BAAA,CAAiBC,OAFrC;IAGE,MAAM,EAAE,IAAAC,sCAAA,EAAkBL,KAAlB,CAHV;IAIE,yBAAyB,EAAE;EAJ7B,EADF;AAQD,CATM"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getActivityParams = void 0;
7
+
8
+ var _UnitSdkManager = require("../../unitSdkManager/UnitSdkManager");
9
+
10
+ const getActivityParams = props => {
11
+ return `
12
+ account-id="${props.accountId}"
13
+ customer-token="${props.customerToken}"
14
+ theme="${props.theme ?? _UnitSdkManager.UnitSDK.getTheme()}"
15
+ style="height: 100%"
16
+ `;
17
+ };
18
+
19
+ exports.getActivityParams = getActivityParams;
20
+ //# sourceMappingURL=UNActivityComponent.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getActivityParams","props","accountId","customerToken","theme","UnitSDK","getTheme"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\nimport type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n theme=\"${props.theme ?? UnitSDK.getTheme()}\"\n style=\"height: 100%\"\n `;\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,aAAaF,KAAK,CAACG,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAAmB;AAC/C;AACA,GALE;AAMD,CAPM"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UNBookPaymentComponent = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _WebComponent = require("../../webComponent/WebComponent");
11
+
12
+ var _bodyHtml = require("../../scripts/html/bodyHtml");
13
+
14
+ var _UNBookPaymentComponent = require("./UNBookPaymentComponent.utils");
15
+
16
+ var _bookPaymentMessage = require("../../messages/webMessages/bookPaymentMessage");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const UNBookPaymentComponent = props => {
21
+ const handleWebViewMessage = message => {
22
+ if (message.type === _bookPaymentMessage.BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {
23
+ const response = message.details;
24
+ props.onPaymentCreated(response.data);
25
+ }
26
+ };
27
+
28
+ return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
29
+ type: _WebComponent.WebComponentType.bookPayment,
30
+ presentationMode: _bodyHtml.PresentationMode.Inherit,
31
+ params: (0, _UNBookPaymentComponent.getBookPaymentParams)(props),
32
+ script: (0, _UNBookPaymentComponent.getBookPaymentScript)(),
33
+ onMessage: message => handleWebViewMessage(message),
34
+ shouldEnableWebViewScroll: false
35
+ });
36
+ };
37
+
38
+ exports.UNBookPaymentComponent = UNBookPaymentComponent;
39
+ //# sourceMappingURL=UNBookPaymentComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UNBookPaymentComponent","props","handleWebViewMessage","message","type","BookPaymentMessage","PAYMENT_CREATED","onPaymentCreated","response","details","data","WebComponentType","bookPayment","PresentationMode","Inherit","getBookPaymentParams","getBookPaymentScript"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React 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';\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 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\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={PresentationMode.Inherit}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n shouldEnableWebViewScroll={false}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;AAaO,MAAMA,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBC,sCAAA,CAAmBC,eAApC,IAAuDL,KAAK,CAACM,gBAAjE,EAAmF;MACjF,MAAMC,QAAQ,GAAGL,OAAO,CAACM,OAAzB;MACAR,KAAK,CAACM,gBAAN,CAAuBC,QAAQ,CAACE,IAAhC;IACD;EACF,CALD;;EAOA,oBACE,6BAAC,0BAAD;IACE,IAAI,EAAEC,8BAAA,CAAiBC,WADzB;IAEE,gBAAgB,EAAEC,0BAAA,CAAiBC,OAFrC;IAGE,MAAM,EAAE,IAAAC,4CAAA,EAAqBd,KAArB,CAHV;IAIE,MAAM,EAAE,IAAAe,4CAAA,GAJV;IAKE,SAAS,EAAGb,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;IAME,yBAAyB,EAAE;EAN7B,EADF;AAUD,CAlBM"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBookPaymentScript = exports.getBookPaymentParams = void 0;
7
+
8
+ var _bookPaymentMessage = require("../../messages/webMessages/bookPaymentMessage");
9
+
10
+ var _UnitSdkManager = require("../../unitSdkManager/UnitSdkManager");
11
+
12
+ const getBookPaymentParams = props => {
13
+ return `
14
+ account-id="${props.accountId}"
15
+ customer-token="${props.customerToken}"
16
+ is-same-customer="${props.isSameCustomer}"
17
+ counterparty-account-id="${props.counterPartyAccountId}"
18
+ counterparty-name="${props.counterPartyName}"
19
+ theme="${props.theme ?? _UnitSdkManager.UnitSDK.getTheme()}"
20
+ style="height: 100%"
21
+ `;
22
+ };
23
+
24
+ exports.getBookPaymentParams = getBookPaymentParams;
25
+
26
+ const getBookPaymentScript = () => {
27
+ return `
28
+ window.addEventListener("${_bookPaymentMessage.BookPaymentMessage.PAYMENT_CREATED}", (e) => {
29
+ const response = e.detail
30
+ response.then((data) => {
31
+ postMessageToSDK({ type: "${_bookPaymentMessage.BookPaymentMessage.PAYMENT_CREATED}", details: { data: JSON.stringify(data.data) }})
32
+ }).catch((e) => {
33
+ console.log(e)
34
+ })
35
+ });
36
+ `;
37
+ };
38
+
39
+ exports.getBookPaymentScript = getBookPaymentScript;
40
+ //# sourceMappingURL=UNBookPaymentComponent.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","theme","UnitSDK","getTheme","getBookPaymentScript","BookPaymentMessage","PAYMENT_CREATED"],"sources":["UNBookPaymentComponent.utils.ts"],"sourcesContent":["import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';\n\nimport { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\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 theme=\"${props.theme ?? UnitSDK.getTheme()}\"\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;;AACA;;AAEO,MAAMA,oBAAoB,GAAIC,KAAD,IAAwC;EAC1E,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,wBAAwBF,KAAK,CAACG,cAAe;AAC7C,+BAA+BH,KAAK,CAACI,qBAAsB;AAC3D,yBAAyBJ,KAAK,CAACK,gBAAiB;AAChD,aAAaL,KAAK,CAACM,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAAmB;AAC/C;AACA,GARE;AASD,CAVM;;;;AAYA,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BC,sCAAA,CAAmBC,eAAgB;AAClE;AACA;AACA,sCAAsCD,sCAAA,CAAmBC,eAAgB;AACzE;AACA;AACA;AACA;AACA,GATE;AAUD,CAXM"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BOTTOM_SHEET_MAX_PRECANTAGE_SIZE = void 0;
7
+ const BOTTOM_SHEET_MAX_PRECANTAGE_SIZE = 0.9;
8
+ exports.BOTTOM_SHEET_MAX_PRECANTAGE_SIZE = BOTTOM_SHEET_MAX_PRECANTAGE_SIZE;
9
+ //# sourceMappingURL=UNBottomSheetComponent.constants.js.map
@@ -0,0 +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":";;;;;;AAAO,MAAMA,gCAAgC,GAAG,GAAzC"}
@@ -11,15 +11,25 @@ var _WebComponent = require("../../webComponent/WebComponent");
11
11
 
12
12
  var _reactNative = require("react-native");
13
13
 
14
- var _BottomSheet = _interopRequireDefault(require("../../helpers/BottomSheet"));
14
+ var _BottomSheet = _interopRequireDefault(require("../../helpers/BottomSheet/BottomSheet"));
15
15
 
16
- var _EventBus = _interopRequireWildcard(require("../../helpers/EventBus"));
16
+ var _EventBus = _interopRequireDefault(require("../../helpers/EventBus"));
17
17
 
18
- var _pageMessage = require("../../webComponent/webMessages/pageMessage");
18
+ var _pageMessage = require("../../messages/webMessages/pageMessage");
19
19
 
20
- var _unitMessages = require("../../webComponent/webMessages/unitMessages");
20
+ var _unitMessages = require("../../messages/webMessages/unitMessages");
21
21
 
22
- var _cardMessage = require("../../webComponent/webMessages/cardMessage");
22
+ var _cardMessage = require("../../messages/webMessages/cardMessage");
23
+
24
+ var _listenerToBus = require("../../hooks/listenerToBus");
25
+
26
+ var _UNBottomSheetComponent = require("./UNBottomSheetComponent.utils");
27
+
28
+ var _UNBottomSheetComponent2 = require("./UNBottomSheetComponent.styles");
29
+
30
+ var _bodyHtml = require("../../scripts/html/bodyHtml");
31
+
32
+ var _useAppStateListener = require("../../hooks/useAppStateListener");
23
33
 
24
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
35
 
@@ -28,94 +38,74 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
28
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
39
 
30
40
  const UNBottomSheetComponent = () => {
31
- const [isActive, setIsActive] = (0, _react.useState)(false);
41
+ const [isBottomSheetActive, setIsBottomSheetActive] = (0, _react.useState)(false);
32
42
  const [height, setHeight] = (0, _react.useState)(0);
33
43
  const [renderingRequest, setRenderingRequest] = (0, _react.useState)(null);
44
+ const [shouldEnableWebViewScroll, setShouldEnableWebViewScroll] = (0, _react.useState)(false);
34
45
  const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = (0, _react.useState)(false);
35
46
  const [newHeightMessage, setNewHeightMessage] = (0, _react.useState)(null);
47
+ const isAppActive = (0, _useAppStateListener.useAppStateListener)();
48
+ const styles = (0, _UNBottomSheetComponent2.getStylesObject)();
36
49
  const webRef = (0, _react.useRef)(null);
37
50
 
38
- const _listener = data => {
51
+ const listenerAction = data => {
39
52
  setRenderingRequest(data);
40
- setIsActive(true);
53
+ setIsBottomSheetActive(true);
41
54
  };
42
55
 
56
+ (0, _react.useEffect)(() => {
57
+ if (!isAppActive) {
58
+ setIsBottomSheetActive(false);
59
+ }
60
+ }, [isAppActive]);
43
61
  (0, _react.useEffect)(() => {
44
62
  if (!webRef.current) return;
45
63
 
46
64
  if (renderingRequest) {
47
- var _webRef$current;
48
-
49
- (_webRef$current = webRef.current) === null || _webRef$current === void 0 ? void 0 : _webRef$current.injectJavaScript(`dispatchRenderingEvent('${renderingRequest}')`);
65
+ (0, _UNBottomSheetComponent.renderingBottomSheetRequest)(webRef.current, renderingRequest);
50
66
  }
51
67
  }, [webRef.current, renderingRequest]);
52
68
  (0, _react.useEffect)(() => {
53
- if (!isActive) {
69
+ if (!isBottomSheetActive) {
70
+ webRef.current && (0, _UNBottomSheetComponent.resetHtml)(webRef.current);
54
71
  setHeight(0);
55
72
  setRenderingRequest(null);
56
73
  }
57
- }, [isActive]);
74
+ }, [isBottomSheetActive]);
58
75
  (0, _react.useEffect)(() => {
59
76
  if (!waitForLoadingNewComponent && newHeightMessage) {
60
77
  setWaitForLoadingNewComponent(false);
61
78
  setNewHeight(newHeightMessage);
62
79
  }
63
80
  }, [waitForLoadingNewComponent, newHeightMessage]);
64
- (0, _react.useEffect)(() => {
65
- _EventBus.default.Instance.addListener(_EventBus.BusEvent.REQUEST_RENDERING, _listener);
66
-
67
- return () => {
68
- _EventBus.default.Instance.removeListener(_listener);
69
- };
70
- }, []);
71
-
72
- const getBottomSheetScript = () => {
73
- return `
74
- window.addEventListener("unitRequestRefresh", (e) => {
75
- postMessageToSDK({ type: "unitRequestRefresh", details: e.detail })
76
- });
77
- `;
78
- };
81
+ (0, _listenerToBus.useListenerToBus)([{
82
+ busEventKey: _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING,
83
+ action: listenerAction
84
+ }]);
79
85
 
80
86
  const setNewHeight = message => {
81
87
  if (renderingRequest) {
82
88
  const nativePlace = JSON.parse(renderingRequest).nativePlace;
83
89
 
84
90
  if (nativePlace == 'overFullScreen') {
85
- const windowHeight = _reactNative.Dimensions.get('window').height * 0.94;
86
- setHeight(windowHeight);
91
+ const bottomSheetNewHeight = (0, _UNBottomSheetComponent.handleHtmlFullHeight)(webRef.current, _reactNative.Dimensions.get('window').height);
92
+ setHeight(bottomSheetNewHeight);
93
+ setShouldEnableWebViewScroll(true);
87
94
  } else {
88
95
  setHeight(message.details.height);
96
+ setShouldEnableWebViewScroll(false);
89
97
  }
90
98
  }
91
99
  };
92
100
 
93
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
94
- pointerEvents: isActive ? undefined : 'none',
95
- style: {
96
- position: 'absolute',
97
- top: 0,
98
- bottom: 0,
99
- left: 0,
100
- right: 0
101
- }
102
- }, /*#__PURE__*/_react.default.createElement(_BottomSheet.default, {
103
- isOpen: isActive,
104
- onClose: () => setIsActive(false),
105
- onOpen: () => setIsActive(true)
106
- }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
107
- style: {
108
- height,
109
- paddingTop: height === 0 ? 0 : 10
110
- }
111
- }, /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
112
- ref: webRef,
113
- type: _WebComponent.WebComponentType.slot,
114
- script: getBottomSheetScript(),
115
- onMessage: message => {
116
- if (renderingRequest && message.type == _pageMessage.PageMessage.PAGE_HEIGHT) {
117
- setNewHeightMessage(message);
118
- } else if (message.type == _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING) {
101
+ const onWebMessage = message => {
102
+ switch (message.type) {
103
+ case _pageMessage.PageMessage.PAGE_HEIGHT:
104
+ renderingRequest && setNewHeightMessage(message);
105
+ break;
106
+
107
+ case _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING:
108
+ // eslint-disable-next-line no-case-declarations
119
109
  const {
120
110
  data
121
111
  } = message.details;
@@ -126,18 +116,47 @@ const UNBottomSheetComponent = () => {
126
116
  setWaitForLoadingNewComponent(true);
127
117
  setTimeout(() => setWaitForLoadingNewComponent(false), 400);
128
118
  }
129
- } else if (message.type == _cardMessage.CardMessage.CARD_STATUS_CHANGE) {
130
- _EventBus.default.Instance.event(_EventBus.BusEvent.CARD_STATUS_CHANGED, message.details.card);
131
- } else if (message.type == _unitMessages.UnitMessage.UNIT_REQUEST_CLOSE_FLOW) {
132
- setIsActive(false);
133
- } else if (message.type == _unitMessages.UnitMessage.UNIT_REQUEST_OPEN_LINK) {
134
- const href = message.details.href;
119
+
120
+ break;
121
+
122
+ case _cardMessage.CardMessage.CARD_STATUS_CHANGED:
123
+ _EventBus.default.Instance.event(_cardMessage.CardMessage.CARD_STATUS_CHANGED, message.details.card);
124
+
125
+ break;
126
+
127
+ case _unitMessages.UnitMessage.UNIT_REQUEST_CLOSE_FLOW:
128
+ setIsBottomSheetActive(false);
129
+ break;
130
+
131
+ case _unitMessages.UnitMessage.UNIT_REQUEST_OPEN_LINK:
132
+ // eslint-disable-next-line no-case-declarations
133
+ const {
134
+ href
135
+ } = message.details;
135
136
 
136
137
  _reactNative.Linking.openURL(href);
137
- }
138
+
139
+ break;
138
140
  }
139
- })))));
141
+ };
142
+
143
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
144
+ pointerEvents: isBottomSheetActive ? undefined : 'none',
145
+ style: styles.container
146
+ }, /*#__PURE__*/_react.default.createElement(_BottomSheet.default, {
147
+ isOpen: isBottomSheetActive,
148
+ height: height,
149
+ onClose: () => setIsBottomSheetActive(false),
150
+ onOpen: () => setIsBottomSheetActive(true)
151
+ }, isAppActive && /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
152
+ ref: webRef,
153
+ type: _WebComponent.WebComponentType.slot,
154
+ presentationMode: _bodyHtml.PresentationMode.CoverInjectedHeight,
155
+ script: (0, _UNBottomSheetComponent.getBottomSheetScript)(),
156
+ onMessage: onWebMessage,
157
+ shouldEnableWebViewScroll: shouldEnableWebViewScroll
158
+ }))));
140
159
  };
141
160
 
142
161
  exports.UNBottomSheetComponent = UNBottomSheetComponent;
143
- //# sourceMappingURL=BottomSheetComponent.js.map
162
+ //# sourceMappingURL=UNBottomSheetComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","useState","height","setHeight","renderingRequest","setRenderingRequest","shouldEnableWebViewScroll","setShouldEnableWebViewScroll","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","isAppActive","useAppStateListener","styles","getStylesObject","webRef","useRef","listenerAction","data","useEffect","current","renderingBottomSheetRequest","resetHtml","setNewHeight","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_RENDERING","action","message","nativePlace","JSON","parse","bottomSheetNewHeight","handleHtmlFullHeight","Dimensions","get","details","onWebMessage","type","PageMessage","PAGE_HEIGHT","setTimeout","CardMessage","CARD_STATUS_CHANGED","EventBus","Instance","event","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","Linking","openURL","undefined","container","WebComponentType","slot","PresentationMode","CoverInjectedHeight","getBottomSheetScript"],"sources":["UNBottomSheetComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport type WebView from 'react-native-webview';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { Dimensions, Linking, View } from 'react-native';\nimport BottomSheet from '../../helpers/BottomSheet/BottomSheet';\nimport EventBus from '../../helpers/EventBus';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { RequestOpenLinkEvent, RequestRenderingData, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { CardMessage, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest, resetHtml } from './UNBottomSheetComponent.utils';\nimport { getStylesObject } from './UNBottomSheetComponent.styles';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { useAppStateListener } from '../../hooks/useAppStateListener';\n\nexport const UNBottomSheetComponent = () => {\n const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);\n const [height, setHeight] = useState(0);\n\n const [renderingRequest, setRenderingRequest] = useState<string | null>(null);\n const [shouldEnableWebViewScroll, setShouldEnableWebViewScroll] = useState(false);\n\n const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);\n const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null);\n\n const isAppActive = useAppStateListener();\n\n const styles = getStylesObject();\n\n const webRef = useRef<WebView>(null);\n\n const listenerAction = (data: string) => {\n setRenderingRequest(data);\n setIsBottomSheetActive(true);\n };\n\n useEffect(() => {\n if (!isAppActive) {\n setIsBottomSheetActive(false);\n }\n }, [isAppActive]);\n\n useEffect(() => {\n if (!webRef.current) return;\n if (renderingRequest) {\n renderingBottomSheetRequest(webRef.current, renderingRequest);\n }\n }, [webRef.current, renderingRequest]);\n\n useEffect(() => {\n if (!isBottomSheetActive) {\n webRef.current && resetHtml(webRef.current);\n setHeight(0);\n setRenderingRequest(null);\n }\n }, [isBottomSheetActive]);\n\n useEffect(() => {\n if (!waitForLoadingNewComponent && newHeightMessage) {\n setWaitForLoadingNewComponent(false);\n setNewHeight(newHeightMessage);\n }\n }, [waitForLoadingNewComponent, newHeightMessage]);\n\n useListenerToBus([{ busEventKey: UnitMessage.UNIT_REQUEST_RENDERING, action: listenerAction }]);\n\n const setNewHeight = (message: WebViewMessage) => {\n if (renderingRequest) {\n const nativePlace = (JSON.parse(renderingRequest) as RequestRenderingData).nativePlace;\n if (nativePlace == 'overFullScreen') {\n const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);\n setHeight(bottomSheetNewHeight);\n setShouldEnableWebViewScroll(true);\n } else {\n setHeight((message.details as HeightEvent).height);\n setShouldEnableWebViewScroll(false);\n }\n }\n };\n\n const onWebMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case PageMessage.PAGE_HEIGHT:\n renderingRequest && setNewHeightMessage(message);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING:\n // eslint-disable-next-line no-case-declarations\n const { data } = (message.details as RequestRenderingEvent);\n if (data != renderingRequest) {\n setHeight(0);\n setRenderingRequest(data);\n setWaitForLoadingNewComponent(true);\n setTimeout(() => setWaitForLoadingNewComponent(false), 400);\n }\n break;\n case CardMessage.CARD_STATUS_CHANGED:\n EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card);\n break;\n case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:\n setIsBottomSheetActive(false);\n break;\n case UnitMessage.UNIT_REQUEST_OPEN_LINK:\n // eslint-disable-next-line no-case-declarations\n const { href } = (message.details as RequestOpenLinkEvent);\n Linking.openURL(href);\n break;\n }\n };\n\n return (\n <>\n <View\n pointerEvents={isBottomSheetActive ? undefined : 'none'}\n style={styles.container}\n >\n <BottomSheet\n isOpen={isBottomSheetActive}\n height={height}\n onClose={() => setIsBottomSheetActive(false)}\n onOpen={() => setIsBottomSheetActive(true)}\n >\n { isAppActive && (\n <WebComponent\n ref={webRef}\n type={WebComponentType.slot}\n presentationMode={PresentationMode.CoverInjectedHeight}\n script={getBottomSheetScript()}\n onMessage={onWebMessage}\n shouldEnableWebViewScroll={shouldEnableWebViewScroll}\n />)}\n </BottomSheet>\n </View>\n </>\n );\n};\n"],"mappings":"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"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getStylesObject = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ const getStylesObject = () => {
11
+ return _reactNative.StyleSheet.create({
12
+ container: {
13
+ position: 'absolute',
14
+ top: 0,
15
+ bottom: 0,
16
+ left: 0,
17
+ right: 0
18
+ }
19
+ });
20
+ };
21
+
22
+ exports.getStylesObject = getStylesObject;
23
+ //# sourceMappingURL=UNBottomSheetComponent.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getStylesObject","StyleSheet","create","container","position","top","bottom","left","right"],"sources":["UNBottomSheetComponent.styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native';\n\nexport const getStylesObject = () => {\n return StyleSheet.create({\n container: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,eAAe,GAAG,MAAM;EACnC,OAAOC,uBAAA,CAAWC,MAAX,CAAkB;IACvBC,SAAS,EAAE;MACTC,QAAQ,EAAE,UADD;MAETC,GAAG,EAAE,CAFI;MAGTC,MAAM,EAAE,CAHC;MAITC,IAAI,EAAE,CAJG;MAKTC,KAAK,EAAE;IALE;EADY,CAAlB,CAAP;AASD,CAVM"}