react-native-unit-components 1.2.1 → 1.3.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 (137) hide show
  1. package/README.md +133 -13
  2. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
  3. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
  4. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
  5. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
  6. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +25 -3
  7. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  8. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +5 -1
  9. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
  10. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +24 -1
  11. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  12. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +2 -0
  13. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  14. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
  15. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  16. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +3 -0
  17. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  18. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +37 -3
  19. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  20. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +9 -1
  21. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  22. package/lib/commonjs/messages/webMessages/cardMessage.js +1 -0
  23. package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -1
  24. package/lib/commonjs/messages/webMessages/onLoadMessage.js +17 -0
  25. package/lib/commonjs/messages/webMessages/onLoadMessage.js.map +1 -0
  26. package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
  27. package/lib/commonjs/scripts/html/bodyScript.js +23 -1
  28. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
  29. package/lib/commonjs/sharedTypes/account.types.js.map +1 -1
  30. package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -1
  31. package/lib/commonjs/sharedTypes/activity.types.js +6 -0
  32. package/lib/commonjs/sharedTypes/activity.types.js.map +1 -0
  33. package/lib/commonjs/sharedTypes/authorization.types.js +2 -0
  34. package/lib/commonjs/sharedTypes/authorization.types.js.map +1 -0
  35. package/lib/commonjs/sharedTypes/card.types.js +15 -0
  36. package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
  37. package/lib/commonjs/sharedTypes/index.js.map +1 -1
  38. package/lib/commonjs/sharedTypes/onLoadResponse.types.js +0 -4
  39. package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -1
  40. package/lib/commonjs/sharedTypes/transactions.types.js +52 -0
  41. package/lib/commonjs/sharedTypes/transactions.types.js.map +1 -0
  42. package/lib/commonjs/webComponent/WebComponent.js +2 -1
  43. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  44. package/lib/commonjs/webComponent/html.js +6 -0
  45. package/lib/commonjs/webComponent/html.js.map +1 -1
  46. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
  47. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
  48. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
  49. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
  50. package/lib/module/components/UNAccountComponent/UNAccountComponent.js +27 -5
  51. package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  52. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +3 -0
  53. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
  54. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +24 -1
  55. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  56. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +2 -0
  57. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  58. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
  59. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  60. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +3 -0
  61. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  62. package/lib/module/components/UNCardComponent/UNCardComponent.js +39 -5
  63. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  64. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +6 -0
  65. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  66. package/lib/module/messages/webMessages/cardMessage.js +1 -0
  67. package/lib/module/messages/webMessages/cardMessage.js.map +1 -1
  68. package/lib/module/messages/webMessages/onLoadMessage.js +10 -0
  69. package/lib/module/messages/webMessages/onLoadMessage.js.map +1 -0
  70. package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
  71. package/lib/module/scripts/html/bodyScript.js +20 -0
  72. package/lib/module/scripts/html/bodyScript.js.map +1 -1
  73. package/lib/module/sharedTypes/account.types.js.map +1 -1
  74. package/lib/module/sharedTypes/achCredit.types.js.map +1 -1
  75. package/lib/module/sharedTypes/activity.types.js +2 -0
  76. package/lib/module/sharedTypes/activity.types.js.map +1 -0
  77. package/lib/module/sharedTypes/authorization.types.js +2 -0
  78. package/lib/module/sharedTypes/authorization.types.js.map +1 -0
  79. package/lib/module/sharedTypes/card.types.js +13 -1
  80. package/lib/module/sharedTypes/card.types.js.map +1 -1
  81. package/lib/module/sharedTypes/index.js +1 -1
  82. package/lib/module/sharedTypes/index.js.map +1 -1
  83. package/lib/module/sharedTypes/onLoadResponse.types.js +1 -1
  84. package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -1
  85. package/lib/module/sharedTypes/transactions.types.js +44 -0
  86. package/lib/module/sharedTypes/transactions.types.js.map +1 -0
  87. package/lib/module/webComponent/WebComponent.js +2 -1
  88. package/lib/module/webComponent/WebComponent.js.map +1 -1
  89. package/lib/module/webComponent/html.js +7 -1
  90. package/lib/module/webComponent/html.js.map +1 -1
  91. package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.d.ts +2 -2
  92. package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.d.ts +2 -2
  93. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +7 -3
  94. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +1 -0
  95. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +4 -2
  96. package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -2
  97. package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +9 -3
  98. package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +3 -0
  99. package/lib/typescript/messages/webMessages/cardMessage.d.ts +5 -1
  100. package/lib/typescript/messages/webMessages/onLoadMessage.d.ts +30 -0
  101. package/lib/typescript/messages/webMessages/unitMessages.d.ts +2 -2
  102. package/lib/typescript/scripts/html/bodyScript.d.ts +3 -0
  103. package/lib/typescript/sharedTypes/account.types.d.ts +13 -4
  104. package/lib/typescript/sharedTypes/achCredit.types.d.ts +6 -0
  105. package/lib/typescript/sharedTypes/activity.types.d.ts +7 -0
  106. package/lib/typescript/sharedTypes/authorization.types.d.ts +20 -0
  107. package/lib/typescript/sharedTypes/card.types.d.ts +12 -0
  108. package/lib/typescript/sharedTypes/index.d.ts +1 -1
  109. package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +12 -16
  110. package/lib/typescript/sharedTypes/transactions.types.d.ts +80 -0
  111. package/package.json +1 -1
  112. package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +30 -3
  113. package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +30 -3
  114. package/src/components/UNAccountComponent/UNAccountComponent.tsx +40 -9
  115. package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +4 -0
  116. package/src/components/UNActivityComponent/UNActivityComponent.tsx +32 -3
  117. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +2 -0
  118. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +23 -3
  119. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +4 -1
  120. package/src/components/UNCardComponent/UNCardComponent.tsx +49 -7
  121. package/src/components/UNCardComponent/UNCardComponent.utils.ts +9 -0
  122. package/src/messages/webMessages/cardMessage.ts +6 -0
  123. package/src/messages/webMessages/onLoadMessage.ts +45 -0
  124. package/src/messages/webMessages/unitMessages.ts +2 -2
  125. package/src/scripts/html/bodyScript.ts +22 -0
  126. package/src/sharedTypes/account.types.ts +25 -17
  127. package/src/sharedTypes/achCredit.types.ts +7 -0
  128. package/src/sharedTypes/activity.types.ts +8 -0
  129. package/src/sharedTypes/authorization.types.ts +22 -0
  130. package/src/sharedTypes/card.types.ts +13 -0
  131. package/src/sharedTypes/index.ts +1 -1
  132. package/src/sharedTypes/onLoadResponse.types.ts +15 -23
  133. package/src/sharedTypes/transactions.types.ts +84 -0
  134. package/src/webComponent/WebComponent.tsx +3 -1
  135. package/src/webComponent/html.ts +7 -1
  136. package/android/src/main/res/values/themes.xml +0 -16
  137. package/android/src/main/res/values-night/themes.xml +0 -16
package/README.md CHANGED
@@ -79,12 +79,14 @@ export default function YourRootComponent() {
79
79
  | ---------------------- | ---------------------------- | --------- | -------------------------------------------------------- |
80
80
  | customerToken | string | YES | A Unit Customer token. |
81
81
  | cardId | string | YES | Unit card id. |
82
- | theme | string | No | A URL that specifies the UI configuration. |
83
- | hide-actions-menu-button | boolean | No | Hide menu button in case value is true |
84
- | hide-card-title | boolean | No | Hide card title in case value is true |
85
- | hide-sensitive-data-button | boolean | No | Hide sensitive data button in case value is true |
86
- | onStatusChanged | (card: UNCardData) => void | No | Callback for card status changes. |
87
- | pushProvisioningModule | typeof NativeModules | No | A Native Module that implements Visa's push provisioning |
82
+ | theme | string | NO | A URL that specifies the UI configuration. |
83
+ | hide-actions-menu-button | boolean | NO | Hide menu button in case value is true |
84
+ | hide-card-title | boolean | NO | Hide card title in case value is true |
85
+ | hide-sensitive-data-button | boolean | NO | Hide sensitive data button in case value is true |
86
+ | onStatusChanged | (card: UNCardData) => void | NO | Callback for card status changes. |
87
+ | onCardActivated | (card: UNCardData) => void | No | Callback for card activated |
88
+ | pushProvisioningModule | typeof NativeModules | NO | A Native Module that implements Visa's push provisioning |
89
+ | onLoad | (response: UNOnLoadResponse<UNCardData>) => void | No | Callback for a loaded component |
88
90
 
89
91
  ##### Example:
90
92
  ```js
@@ -99,12 +101,55 @@ export default function YourComponent() {
99
101
  cardId={'632197'}
100
102
  customerToken={''}
101
103
  onStatusChanged={(card: UNCardData) => { console.log(card) }}
104
+ onCardActivated={(card: UNCardData) => { console.log(card) }}
102
105
  pushProvisioningModule={PushProvisioningModule}
106
+ onLoad={(response: UNOnLoadResponse<UNCardData>) => { console.log(response) }}
103
107
  />
104
108
  );
105
109
  }
106
110
  ```
107
111
 
112
+ ##### Incoming Events:
113
+ - In some cases, the default menu button won't fit into the design of an application.
114
+ By using the `openActionsMenu()` method, it's possible to open the card actions bottom sheet from a custom button.
115
+
116
+ Important Note: one can use the `openActionsMenu()` only after UNCardComponent is loaded. (can be verified by onLoad callback)
117
+
118
+ - It's also possible to create your own menu and call card actions from it.
119
+ Use `openAction(action: UNCardMenuAction)` method and send inside an action you want to perform.
120
+ Use API Docs in order to understand which actions could be applied for any particular card statuses.
121
+
122
+ #### Example:
123
+ ```js
124
+ import { UNCardComponent, CardRef, UNCardMenuAction } from 'react-native-unit-components';
125
+
126
+ ...
127
+
128
+ const cardRef = useRef<CardRef>(null);
129
+
130
+ ...
131
+
132
+ const openActionsMenu = () => {
133
+ cardRef.current?.openActionsMenu();
134
+ };
135
+
136
+ const openAction = (action: UNCardMenuAction) => {
137
+ cardRef.current?.openAction(action);
138
+ };
139
+
140
+
141
+ ...
142
+
143
+ <UNCardComponent
144
+ ref={cardRef}
145
+ cardId={"4242"}
146
+ customerToken={''}
147
+ />
148
+
149
+ ```
150
+
151
+
152
+
108
153
  ##### Add card to wallet capability - Optional
109
154
 
110
155
  [Complete the add to wallet guide for React Native](https://guides.unit.co/add-to-mobile-wallet#react-native), skipping the [last module access from javascript](https://guides.unit.co/add-to-mobile-wallet#module-access-from-javascript-1), to use this capability.
@@ -154,8 +199,9 @@ export default function YourRootComponent() {
154
199
  | counterPartyAccountId | string | YES | Unit account id. The account which will receive money. |
155
200
  | counterPartyName | string | YES | Name of the counterparty. This is the name that will be displayed in the Book Payment UI during the transfer.|
156
201
  | isSameCustomer | boolean | NO | Stating whether both accounts belong to the same customer. Allows fetching additional information about the counterparty account. Default "false" |
157
- | theme | string | No | A URL that specifies the UI configuration. |
202
+ | theme | string | NO | A URL that specifies the UI configuration. |
158
203
  | onPaymentCreated | (bookPayment: UNBookPaymentData) => void | NO | Callback for the created bookPayment. |
204
+ | onLoad | (response: UNOnLoadResponse<UNAccountData>) => void | NO | Callback for a loaded component
159
205
 
160
206
 
161
207
 
@@ -173,6 +219,7 @@ export default function YourComponent() {
173
219
  counterPartyName={'Peter Parker"'}
174
220
  isSameCustomer={true}
175
221
  onPaymentCreated={(bookPayment: UNBookPaymentData) => { console.log(bookPayment) }}
222
+ onLoad={(response: UNOnLoadResponse<UNBookPaymentData>) => { console.log(response) }}
176
223
  />
177
224
  );
178
225
  }
@@ -184,8 +231,8 @@ export default function YourComponent() {
184
231
  | Name | Type | Required | Description |
185
232
  | --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
186
233
  | customerToken | string | YES | A Unit Customer token. |
187
- | 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 |
188
- | theme | string | No | A URL that specifies the UI configuration. |
234
+ | 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 |
235
+ | theme | string | NO | A URL that specifies the UI configuration. |
189
236
 
190
237
 
191
238
  ##### Example:
@@ -209,8 +256,10 @@ export default function YourComponent() {
209
256
  | Name | Type | Required | Description |
210
257
  | --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
211
258
  | customerToken | string | YES | A Unit Customer token. |
212
- | accountId | string | No | Unit account id. The account to show, when not provided, one of the customer's accounts will be shown. |
213
- | theme | string | No | A URL that specifies the UI configuration. |
259
+ | accountId | string | NO | Unit account id. The account to show, when not provided, one of the customer's accounts will be shown. |
260
+ | theme | string | NO | A URL that specifies the UI configuration. |
261
+ | onAccountChanged | (account: UNAccountData) => Void | NO | Callback for account changes. |
262
+ | onLoad | (response: UNOnLoadResponse<[UNAccountData]>) => void | NO | Callback for a loaded component |
214
263
 
215
264
 
216
265
  ##### Example:
@@ -223,6 +272,8 @@ export default function YourComponent() {
223
272
  <UNAccountComponent
224
273
  customerToken={''}
225
274
  accountId={'1105561'}
275
+ onAccountChanged={(account: UNAccountData) => console.log('Account changed', account)}/>
276
+ onLoad={(response: UNOnLoadResponse<UNAccountData>) => { console.log(response) }}
226
277
  />
227
278
  );
228
279
  }
@@ -238,18 +289,22 @@ export default function YourComponent() {
238
289
  | theme | string | No | A URL that specifies the UI configuration. |
239
290
  | fee | number | NO | Bill your counterparty for his activity. |
240
291
  | is-auto-focus | boolean | NO | Auto-focus the 'add new recipient' button once the component is mounted. Default "false" |
292
+ | onPaymentCreated | (data: UNACHData) => Void | NO | Callback for ACH payment created |
293
+ | onLoad | (response: UNOnLoadResponse<UNACHOnLoadData>) => void | NO | Callback for a loaded component |
294
+
241
295
 
242
296
 
243
297
  ##### Example:
244
298
  ```js
245
299
  import React from 'react';
246
- import { UNACHCreditComponent, UNACHData } from 'react-native-unit-components';
300
+ import { UNACHCreditComponent, UNACHData, UNACHOnLoadData } from 'react-native-unit-components';
247
301
  export default function YourComponent() {
248
302
  return (
249
303
  <UNACHCreditComponent
250
304
  customerToken={''}
251
305
  accountId={'1105561'}
252
306
  onPaymentCreated={(payment: UNACHData) => { console.log(payment) }}
307
+ onLoad={(response: UNOnLoadResponse<UNACHOnLoadData>) => { console.log(response) }}
253
308
  />
254
309
  );
255
310
  }
@@ -308,19 +363,84 @@ Register your app id with Plaid:
308
363
  | theme | string | No | A URL that specifies the UI configuration. |
309
364
  | fee | number | NO | Bill your counterparty for his activity. |
310
365
  | is-auto-focus | boolean | NO | Auto-focus the 'add new recipient' button once the component is mounted. Default "false" |
366
+ | onPaymentCreated | (data: UNACHData) => Void | NO | Callback for ACH payment created |
367
+ | onLoad | (response: UNOnLoadResponse<UNACHOnLoadData>) | NO | Callback for a loaded component |
311
368
 
312
369
 
313
370
  ##### Example:
314
371
  ```js
315
372
  import React from 'react';
316
- import { UNACHDebitComponent, UNACHData } from 'react-native-unit-components';
373
+ import { UNACHDebitComponent, UNACHData, UNACHOnLoadData } from 'react-native-unit-components';
317
374
  export default function YourComponent() {
318
375
  return (
319
376
  <UNACHDebitComponent
320
377
  customerToken={''}
321
378
  accountId={'1105561'}
322
379
  onPaymentCreated={(payment: UNACHData) => { console.log(payment) }}
380
+ onLoad={(response: UNOnLoadResponse<UNACHOnLoadData>) => { console.log(response) }}
323
381
  />
324
382
  );
325
383
  }
326
384
  ```
385
+
386
+
387
+ #### Error Handling
388
+
389
+ By using unitOnLoad callback you can get a Swift.Result about the requested component.
390
+ OnError - you will get an enum UNError that consist of several cases.
391
+
392
+ #### UNError:
393
+
394
+ fields | Description |
395
+ | --------------------- | --------------------------- | ------------------------------------------------------------ |
396
+ errors: UNErrorData[] | Report UNError on errors that happen in loading time |
397
+
398
+
399
+ #### UNErrorData:
400
+ | Name | Type | Description |
401
+ | --------------------- | -------------------------------------------| --------------------------------------------------------------------------- |
402
+ | status | String | A Unit-specific code, uniquely identifying the error type |
403
+ | title | String? | The title of the error type |
404
+ | detail | String? | Additional information about the error. |
405
+ | details | String? | Additional information about the error. |
406
+ | meta | { supportId: String }? | meta.supportId unique error identifier to be used for further investigation |
407
+
408
+ Note: An "error object" MUST contain a title and the HTTP status code members.
409
+
410
+ #### Example:
411
+ ```ts
412
+ import { UNCardComponent, UNCardData, UNOnLoadResponse } from 'react-native-unit-components';
413
+
414
+ ....
415
+
416
+ const handleCardOnLoad = (response: UNOnLoadResponse<UNCardData>) => {
417
+ if ('errors' in response) {
418
+ console.error('ERROR unitOnLoad: ', response.errors);
419
+ return;
420
+ }
421
+
422
+ if ('data' in response) {
423
+ const cardData: UNCardData = response.data;
424
+ console.log('Success, data:', cardData)
425
+ return;
426
+ }
427
+
428
+ return;
429
+ }
430
+
431
+
432
+ ....
433
+
434
+ return (
435
+ ...
436
+
437
+ <UNCardComponent
438
+ cardId={'632197'}
439
+ customerToken={''}
440
+ onLoad={handleCardOnLoad}
441
+ />
442
+
443
+ ...
444
+ )
445
+ ```
446
+
@@ -12,11 +12,34 @@ var _reactNative = require("react-native");
12
12
  var _unitMessages = require("../../messages/webMessages/unitMessages");
13
13
  var _UNACHCreditComponent = require("./UNACHCreditComponent.utils");
14
14
  var _paymentsMessage = require("../../messages/webMessages/paymentsMessage");
15
+ var _onLoadMessage = require("../../messages/webMessages/onLoadMessage");
15
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
17
  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; }
17
18
  const UNACHCreditComponent = props => {
18
19
  const [height, setHeight] = (0, _react.useState)(0);
19
20
  const [presentationMode, setPresentationMode] = (0, _react.useState)(_bodyHtml.PresentationMode.Inherit);
21
+ const handleUnitOnLoad = response => {
22
+ if (!props.onLoad) {
23
+ return;
24
+ }
25
+ if (_onLoadMessage.RESPONSE_KEYS.errors in response) {
26
+ props.onLoad(response);
27
+ return;
28
+ }
29
+ if (_onLoadMessage.RESPONSE_KEYS.account in response && _onLoadMessage.RESPONSE_KEYS.counterpartyAccount in response) {
30
+ // ACHOnLoadResponse;
31
+ const achOnload = {
32
+ data: {
33
+ [_onLoadMessage.RESPONSE_KEYS.account]: response[_onLoadMessage.RESPONSE_KEYS.account].data,
34
+ [_onLoadMessage.RESPONSE_KEYS.counterpartyAccount]: response[_onLoadMessage.RESPONSE_KEYS.counterpartyAccount].data
35
+ }
36
+ };
37
+ props.onLoad(achOnload);
38
+ return;
39
+ }
40
+ console.error('On Load Error: unexpected response type');
41
+ return;
42
+ };
20
43
  const handleWebViewMessage = message => {
21
44
  if (!message || !message.details) return;
22
45
  switch (message.type) {
@@ -27,7 +50,7 @@ const UNACHCreditComponent = props => {
27
50
  break;
28
51
  }
29
52
  case _unitMessages.UnitMessage.UNIT_ON_LOAD:
30
- props.onLoad && props.onLoad(message.details);
53
+ handleUnitOnLoad(message.details);
31
54
  break;
32
55
  case _pageMessage.PageMessage.PAGE_HEIGHT:
33
56
  {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHCreditComponent","_paymentsMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHCreditComponent","props","height","setHeight","useState","presentationMode","setPresentationMode","PresentationMode","Inherit","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achCreditEvent","onPaymentCreated","data","UnitMessage","UNIT_ON_LOAD","onLoad","PageMessage","PAGE_HEIGHT","currentHeight","Default","renderACHCreditWebView","createElement","WebComponent","WebComponentType","achCreditPayment","params","getACHCreditParams","script","getACHCreditScript","onMessage","isScrollable","theme","View","style","exports"],"sources":["UNACHCreditComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { View } from 'react-native';\nimport { UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { getACHCreditParams, getACHCreditScript } from './UNACHCreditComponent.utils';\nimport { PaymentMessage } from '../../messages/webMessages/paymentsMessage';\nimport type { ACHEvent } from '../../messages/webMessages/achCreditMessage';\n\nexport interface UNACHCreditComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n isAutoFocus?: boolean;\n fee?: number;\n onPaymentCreated?: (data: UNACHData) => void;\n onLoad?: (response: UNResponseUnitOnLoadEvent) => void;\n}\n\nexport const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case PaymentMessage.PAYMENT_CREATED: {\n const achCreditEvent = message.details as ACHEvent;\n props.onPaymentCreated && props.onPaymentCreated(achCreditEvent.data as UNACHData);\n break;\n }\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n break;\n }\n }\n };\n\n const renderACHCreditWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.achCreditPayment}\n presentationMode={presentationMode}\n params={getACHCreditParams(props)}\n script={getACHCreditScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderACHCreditWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderACHCreditWebView()}\n </View>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AAA4E,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAc,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,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,CACpB;AAEX,CAAC;AAACc,OAAA,CAAAvC,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHCreditComponent","_paymentsMessage","_onLoadMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHCreditComponent","props","height","setHeight","useState","presentationMode","setPresentationMode","PresentationMode","Inherit","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","account","counterpartyAccount","achOnload","data","console","error","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achCreditEvent","onPaymentCreated","UnitMessage","UNIT_ON_LOAD","PageMessage","PAGE_HEIGHT","currentHeight","Default","renderACHCreditWebView","createElement","WebComponent","WebComponentType","achCreditPayment","params","getACHCreditParams","script","getACHCreditScript","onMessage","isScrollable","theme","View","style","exports"],"sources":["UNACHCreditComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport type { UNOnLoadResponse, UNACHData, UNACHOnLoadData, UNError, UNOnLoadResponseData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { View } from 'react-native';\nimport { UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { getACHCreditParams, getACHCreditScript } from './UNACHCreditComponent.utils';\nimport { PaymentMessage } from '../../messages/webMessages/paymentsMessage';\nimport type { ACHEvent } from '../../messages/webMessages/achCreditMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\n\nexport interface UNACHCreditComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n isAutoFocus?: boolean;\n fee?: number;\n onPaymentCreated?: (data: UNACHData) => void;\n onLoad?: (response: UNOnLoadResponse<UNACHOnLoadData>) => void;\n}\n\nexport const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response && RESPONSE_KEYS.counterpartyAccount in response) {\n // ACHOnLoadResponse;\n const achOnload: UNOnLoadResponseData<UNACHOnLoadData> = {\n data: {\n [RESPONSE_KEYS.account]: response[RESPONSE_KEYS.account].data,\n [RESPONSE_KEYS.counterpartyAccount]: response[RESPONSE_KEYS.counterpartyAccount].data,\n }\n };\n props.onLoad(achOnload);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case PaymentMessage.PAYMENT_CREATED: {\n const achCreditEvent = message.details as ACHEvent;\n props.onPaymentCreated && props.onPaymentCreated(achCreditEvent.data as UNACHData);\n break;\n }\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n break;\n }\n }\n };\n\n const renderACHCreditWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.achCreditPayment}\n presentationMode={presentationMode}\n params={getACHCreditParams(props)}\n script={getACHCreditScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderACHCreditWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderACHCreditWebView()}\n </View>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AAEA,IAAAQ,cAAA,GAAAR,OAAA;AAAkG,SAAAS,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAX,wBAAAe,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAA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aAAA,CAAC9D,YAAA,CAAAyE,IAAI;IAACC,KAAK,EAAE;MAAE7C,MAAM,EAAEA;IAAO;EAAE,GAC7BgC,sBAAsB,EAAE,CACpB;AAEX,CAAC;AAACc,OAAA,CAAAhD,oBAAA,GAAAA,oBAAA"}
@@ -13,6 +13,7 @@ var _unitMessages = require("../../messages/webMessages/unitMessages");
13
13
  var _UNACHDebitComponent = require("./UNACHDebitComponent.utils");
14
14
  var _reactNativePlaidLinkSdk = require("react-native-plaid-link-sdk");
15
15
  var _paymentsMessage = require("../../messages/webMessages/paymentsMessage");
16
+ var _onLoadMessage = require("../../messages/webMessages/onLoadMessage");
16
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
18
  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; }
18
19
  const UNACHDebitComponent = props => {
@@ -33,6 +34,28 @@ const UNACHDebitComponent = props => {
33
34
  const dispatchUnitPlaidResponse = success => {
34
35
  (0, _UNACHDebitComponent.injectUnitPlaidResponse)(webRef.current, success);
35
36
  };
37
+ const handleUnitOnLoad = response => {
38
+ if (!props.onLoad) {
39
+ return;
40
+ }
41
+ if (_onLoadMessage.RESPONSE_KEYS.errors in response) {
42
+ props.onLoad(response);
43
+ return;
44
+ }
45
+ if (_onLoadMessage.RESPONSE_KEYS.account in response && _onLoadMessage.RESPONSE_KEYS.counterpartyAccount in response) {
46
+ // ACHOnLoadResponse;
47
+ const achOnload = {
48
+ data: {
49
+ [_onLoadMessage.RESPONSE_KEYS.account]: response[_onLoadMessage.RESPONSE_KEYS.account].data,
50
+ [_onLoadMessage.RESPONSE_KEYS.counterpartyAccount]: response[_onLoadMessage.RESPONSE_KEYS.counterpartyAccount].data
51
+ }
52
+ };
53
+ props.onLoad(achOnload);
54
+ return;
55
+ }
56
+ console.error('On Load Error: unexpected response type');
57
+ return;
58
+ };
36
59
  const handleWebViewMessage = message => {
37
60
  if (!message || !message.details) return;
38
61
  switch (message.type) {
@@ -43,7 +66,7 @@ const UNACHDebitComponent = props => {
43
66
  break;
44
67
  }
45
68
  case _unitMessages.UnitMessage.UNIT_ON_LOAD:
46
- props.onLoad && props.onLoad(message.details);
69
+ handleUnitOnLoad(message.details);
47
70
  break;
48
71
  case _pageMessage.PageMessage.PAGE_HEIGHT:
49
72
  {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHDebitComponent","_reactNativePlaidLinkSdk","_paymentsMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHDebitComponent","props","height","setHeight","useState","appPackageName","setAppPackageName","linkToken","setLinkToken","webRef","useRef","presentationMode","setPresentationMode","PresentationMode","Inherit","useEffect","setPackageNameForAndroid","Platform","OS","packageName","getAndroidPackageName","dispatchUnitPlaidResponse","success","injectUnitPlaidResponse","current","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achDebitEvent","onPaymentCreated","data","UnitMessage","UNIT_ON_LOAD","onLoad","PageMessage","PAGE_HEIGHT","currentHeight","Default","UNIT_PLAID_TOKEN_CREATED","linkTokenEvent","linkTokenData","attributes","UNIT_REQUEST_EXTERNAL_SDK","externalSdkType","openLink","tokenConfig","noLoadingState","token","onSuccess","onExit","exit","console","log","catch","e","error","renderACHDebitWebView","createElement","WebComponent","ref","WebComponentType","achDebitPayment","params","getACHDebitParams","script","getACHDebitScript","onMessage","isScrollable","theme","View","style","exports"],"sources":["UNACHDebitComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { Platform, View } from 'react-native';\nimport { PlaidLinkTokenData, PlaidTokenCreatedEvent, RequestExternalSdkEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { getACHDebitParams, getACHDebitScript, getAndroidPackageName, injectUnitPlaidResponse } from './UNACHDebitComponent.utils';\n\nimport { LinkSuccess, openLink } from 'react-native-plaid-link-sdk';\nimport type WebView from 'react-native-webview';\n\nimport { PaymentMessage } from '../../messages/webMessages/paymentsMessage';\nimport type { ACHEvent } from '../../messages/webMessages/achCreditMessage';\n\nexport interface UNACHDebitComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n isAutoFocus?: boolean;\n fee?: number;\n onPaymentCreated?: (data: UNACHData) => void;\n onLoad?: (response: UNResponseUnitOnLoadEvent) => void;\n}\n\nexport const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [appPackageName, setAppPackageName] = useState<string>('');\n const [linkToken, setLinkToken] = useState<string>('');\n const webRef = useRef<WebView>(null);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n useEffect(() => {\n const setPackageNameForAndroid = async () => {\n if (Platform.OS === 'android') {\n const packageName = await getAndroidPackageName();\n setAppPackageName(packageName);\n }\n };\n setPackageNameForAndroid();\n }, []);\n\n const dispatchUnitPlaidResponse = (success: LinkSuccess) => {\n injectUnitPlaidResponse(webRef.current, success);\n };\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case PaymentMessage.PAYMENT_CREATED: {\n const achDebitEvent = message.details as ACHEvent;\n props.onPaymentCreated && props.onPaymentCreated(achDebitEvent.data as UNACHData);\n break;\n }\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n break;\n }\n case UnitMessage.UNIT_PLAID_TOKEN_CREATED: {\n const linkTokenEvent = message.details as PlaidTokenCreatedEvent;\n const linkTokenData = linkTokenEvent.linkToken as PlaidLinkTokenData;\n setLinkToken(linkTokenData.attributes.linkToken);\n break;\n }\n\n case UnitMessage.UNIT_REQUEST_EXTERNAL_SDK: {\n const externalSdkType = (message.details as RequestExternalSdkEvent).type;\n if (externalSdkType !== 'plaid') return;\n linkToken && openLink({\n tokenConfig: { noLoadingState: false, token: linkToken},\n onSuccess: (success) => {\n dispatchUnitPlaidResponse(success);\n },\n onExit: exit => { console.log(exit); }\n }).catch(e => {\n console.error(e);\n });\n break;\n }\n }\n };\n\n const renderACHDebitWebView = () => {\n return (\n <WebComponent\n ref={webRef}\n type={WebComponentType.achDebitPayment}\n presentationMode={presentationMode}\n params={getACHDebitParams(props)}\n script={getACHDebitScript(appPackageName)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderACHDebitWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderACHDebitWebView()}\n </View>\n\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AAEA,IAAAO,wBAAA,GAAAP,OAAA;AAGA,IAAAQ,gBAAA,GAAAR,OAAA;AAA4E,SAAAS,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAX,wBAAAe,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,I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AAO,CAACC,GAAG,CAACF,IAAI,CAAC;YAAE;UACvC,CAAC,CAAC,CAACG,KAAK,CAACC,CAAC,IAAI;YACZH,OAAO,CAACI,KAAK,CAACD,CAAC,CAAC;UAClB,CAAC,CAAC;UACF;QACF;IAAC;EAEL,CAAC;EAED,MAAME,qBAAqB,GAAGA,CAAA,KAAM;IAClC,oBACE5F,MAAA,CAAAkB,OAAA,CAAA2E,aAAA,CAAC1F,aAAA,CAAA2F,YAAY;MACXC,GAAG,EAAErD,MAAO;MACZmB,IAAI,EAAEmC,8BAAgB,CAACC,eAAgB;MACvCrD,gBAAgB,EAAEA,gBAAiB;MACnCsD,MAAM,EAAE,IAAAC,sCAAiB,EAACjE,KAAK,CAAE;MACjCkE,MAAM,EAAE,IAAAC,sCAAiB,EAAC/D,cAAc,CAAE;MAC1CgE,SAAS,EAAG3C,OAAuB,IAAKD,oBAAoB,CAACC,OAAO,CAAE;MACtE4C,YAAY,EAAE,KAAM;MACpBC,KAAK,EAAEtE,KAAK,CAACsE;IAAM,EACnB;EAEN,CAAC;EAED,IAAI5D,gBAAgB,KAAKE,0BAAgB,CAACC,OAAO,EAAE;IACjD,OAAO6C,qBAAqB,EAAE;EAChC;EAEA,oBACE5F,MAAA,CAAAkB,OAAA,CAAA2E,aAAA,CAACvF,YAAA,CAAAmG,IAAI;IAACC,KAAK,EAAE;MAAEvE,MAAM,EAAEA;IAAO;EAAE,GAC7ByD,qBAAqB,EAAE,CACnB;AAGX,CAAC;AAACe,OAAA,CAAA1E,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_WebComponent","_bodyHtml","_pageMessage","_reactNative","_unitMessages","_UNACHDebitComponent","_reactNativePlaidLinkSdk","_paymentsMessage","_onLoadMessage","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNACHDebitComponent","props","height","setHeight","useState","appPackageName","setAppPackageName","linkToken","setLinkToken","webRef","useRef","presentationMode","setPresentationMode","PresentationMode","Inherit","useEffect","setPackageNameForAndroid","Platform","OS","packageName","getAndroidPackageName","dispatchUnitPlaidResponse","success","injectUnitPlaidResponse","current","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","account","counterpartyAccount","achOnload","data","console","error","handleWebViewMessage","message","details","type","PaymentMessage","PAYMENT_CREATED","achDebitEvent","onPaymentCreated","UnitMessage","UNIT_ON_LOAD","PageMessage","PAGE_HEIGHT","currentHeight","Default","UNIT_PLAID_TOKEN_CREATED","linkTokenEvent","linkTokenData","attributes","UNIT_REQUEST_EXTERNAL_SDK","externalSdkType","openLink","tokenConfig","noLoadingState","token","onSuccess","onExit","exit","log","catch","e","renderACHDebitWebView","createElement","WebComponent","ref","WebComponentType","achDebitPayment","params","getACHDebitParams","script","getACHDebitScript","onMessage","isScrollable","theme","View","style","exports"],"sources":["UNACHDebitComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport type { UNOnLoadResponse, UNACHData, UNError, UNOnLoadResponseData, UNACHOnLoadData } from '../../sharedTypes';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { Platform, View } from 'react-native';\nimport { PlaidLinkTokenData, PlaidTokenCreatedEvent, RequestExternalSdkEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { getACHDebitParams, getACHDebitScript, getAndroidPackageName, injectUnitPlaidResponse } from './UNACHDebitComponent.utils';\n\nimport { LinkSuccess, openLink } from 'react-native-plaid-link-sdk';\nimport type WebView from 'react-native-webview';\n\nimport { PaymentMessage } from '../../messages/webMessages/paymentsMessage';\nimport type { ACHEvent } from '../../messages/webMessages/achCreditMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\n\nexport interface UNACHDebitComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n isAutoFocus?: boolean;\n fee?: number;\n onPaymentCreated?: (data: UNACHData) => void;\n onLoad?: (response: UNOnLoadResponse<UNACHOnLoadData>) => void;\n}\n\nexport const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {\n const [height, setHeight] = useState<number>(0);\n const [appPackageName, setAppPackageName] = useState<string>('');\n const [linkToken, setLinkToken] = useState<string>('');\n const webRef = useRef<WebView>(null);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\n useEffect(() => {\n const setPackageNameForAndroid = async () => {\n if (Platform.OS === 'android') {\n const packageName = await getAndroidPackageName();\n setAppPackageName(packageName);\n }\n };\n setPackageNameForAndroid();\n }, []);\n\n const dispatchUnitPlaidResponse = (success: LinkSuccess) => {\n injectUnitPlaidResponse(webRef.current, success);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response && RESPONSE_KEYS.counterpartyAccount in response) {\n // ACHOnLoadResponse;\n const achOnload: UNOnLoadResponseData<UNACHOnLoadData> = {\n data: {\n [RESPONSE_KEYS.account]: response[RESPONSE_KEYS.account].data,\n [RESPONSE_KEYS.counterpartyAccount]: response[RESPONSE_KEYS.counterpartyAccount].data,\n }\n };\n props.onLoad(achOnload);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case PaymentMessage.PAYMENT_CREATED: {\n const achDebitEvent = message.details as ACHEvent;\n props.onPaymentCreated && props.onPaymentCreated(achDebitEvent.data as UNACHData);\n break;\n }\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n break;\n }\n case UnitMessage.UNIT_PLAID_TOKEN_CREATED: {\n const linkTokenEvent = message.details as PlaidTokenCreatedEvent;\n const linkTokenData = linkTokenEvent.linkToken as PlaidLinkTokenData;\n setLinkToken(linkTokenData.attributes.linkToken);\n break;\n }\n\n case UnitMessage.UNIT_REQUEST_EXTERNAL_SDK: {\n const externalSdkType = (message.details as RequestExternalSdkEvent).type;\n if (externalSdkType !== 'plaid') return;\n linkToken && openLink({\n tokenConfig: { noLoadingState: false, token: linkToken},\n onSuccess: (success) => {\n dispatchUnitPlaidResponse(success);\n },\n onExit: exit => { console.log(exit); }\n }).catch(e => {\n console.error(e);\n });\n break;\n }\n }\n };\n\n const renderACHDebitWebView = () => {\n return (\n <WebComponent\n ref={webRef}\n type={WebComponentType.achDebitPayment}\n presentationMode={presentationMode}\n params={getACHDebitParams(props)}\n script={getACHDebitScript(appPackageName)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderACHDebitWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderACHDebitWebView()}\n </View>\n\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AAEA,IAAAO,wBAAA,GAAAP,OAAA;AAGA,IAAAQ,gBAAA,GAAAR,OAA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6 +14,7 @@ var _UNAccountComponent = require("./UNAccountComponent.utils");
14
14
  var _bodyHtml = require("../../scripts/html/bodyHtml");
15
15
  var _listenerToBus = require("../../hooks/listenerToBus");
16
16
  var _accountMessage = require("../../messages/webMessages/accountMessage");
17
+ var _onLoadMessage = require("../../messages/webMessages/onLoadMessage");
17
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
20
  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; }
@@ -23,7 +24,7 @@ exports.AccountAction = AccountAction;
23
24
  AccountAction["List"] = "account-list";
24
25
  AccountAction["Menu"] = "account-menu";
25
26
  })(AccountAction || (exports.AccountAction = AccountAction = {}));
26
- const UNAccountComponent = props => {
27
+ const UNAccountComponent = /*#__PURE__*/_react.default.forwardRef(function UNAccountComponent(props, accountRef) {
27
28
  const [height, setHeight] = (0, _react.useState)(0);
28
29
  const windowWidth = _reactNative.Dimensions.get('window').width;
29
30
  const [requestRefreshEvent, setRequestRefreshEvent] = (0, _react.useState)(null);
@@ -34,6 +35,22 @@ const UNAccountComponent = props => {
34
35
  const requestRefresh = data => {
35
36
  setRequestRefreshEvent(data);
36
37
  };
38
+ const handleUnitOnLoad = response => {
39
+ if (!props.onLoad) {
40
+ return;
41
+ }
42
+ if (_onLoadMessage.RESPONSE_KEYS.errors in response) {
43
+ props.onLoad(response);
44
+ return;
45
+ }
46
+ if (_onLoadMessage.RESPONSE_KEYS.account in response) {
47
+ // AccountsOnLoadResponse;
48
+ props.onLoad(response[_onLoadMessage.RESPONSE_KEYS.account]);
49
+ return;
50
+ }
51
+ console.error('On Load Error: unexpected response type.');
52
+ return;
53
+ };
37
54
  (0, _listenerToBus.useListenerToBus)({
38
55
  busEventKey: _unitMessages.UnitMessage.UNIT_REQUEST_REFRESH,
39
56
  action: requestRefresh
@@ -45,10 +62,15 @@ const UNAccountComponent = props => {
45
62
  (0, _react.useEffect)(() => {
46
63
  (0, _UNAccountComponent.injectRefreshEventIfNeeded)(webRef.current, requestRefreshEvent);
47
64
  }, [requestRefreshEvent]);
65
+ (0, _react.useImperativeHandle)(accountRef, () => ({
66
+ openActionsMenu() {
67
+ (0, _UNAccountComponent.injectOpenActionsMenuScript)(webRef.current);
68
+ }
69
+ }));
48
70
  const handleMessage = message => {
49
71
  switch (message.type) {
50
72
  case _unitMessages.UnitMessage.UNIT_ON_LOAD:
51
- props.onLoad && props.onLoad(message.details);
73
+ handleUnitOnLoad(message.details);
52
74
  break;
53
75
  case _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING:
54
76
  {
@@ -80,6 +102,6 @@ const UNAccountComponent = props => {
80
102
  width: windowWidth,
81
103
  isScrollable: false
82
104
  }));
83
- };
105
+ });
84
106
  exports.UNAccountComponent = UNAccountComponent;
85
107
  //# sourceMappingURL=UNAccountComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_pageMessage","_unitMessages","_EventBus","_interopRequireDefault","_WebComponent","_UNAccountComponent","_bodyHtml","_listenerToBus","_accountMessage","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AccountAction","exports","UNAccountComponent","props","height","setHeight","useState","windowWidth","Dimensions","width","requestRefreshEvent","setRequestRefreshEvent","webRef","useRef","handleAccountChanged","account","onAccountChanged","requestRefresh","data","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","action","AccountMessage","UNIT_ACCOUNT_CHANGED","useEffect","injectRefreshEventIfNeeded","current","handleMessage","message","type","UNIT_ON_LOAD","onLoad","details","UNIT_REQUEST_RENDERING","event","componentName","WebComponentType","componentResourceId","accountId","requestRenderingEvent","EventBus","Instance","PageMessage","PAGE_HEIGHT","createElement","View","style","WebComponent","ref","presentationMode","PresentationMode","Default","params","getAccountParams","script","getAccountScript","theme","onMessage","isScrollable"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';\nimport type { UNResponseUnitOnLoadEvent } from '../../sharedTypes';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { UNAccountData } from '../../sharedTypes/account.types';\nimport { AccountMessage } from '../../messages/webMessages/accountMessage';\n\nexport interface UNAccountComponentProps {\n accountId?: string;\n customerToken: string;\n theme?: string;\n onLoad?: (response: UNResponseUnitOnLoadEvent) => void;\n onAccountChanged?: (account: UNAccountData) => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = (props: UNAccountComponentProps) => {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const handleAccountChanged = (account: UNAccountData) => {\n props.onAccountChanged && props.onAccountChanged(account)\n }\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const event: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,O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AE;IAC7CrB,KAAK,EAAEF,WAAY;IACnBqD,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC;AAAC3D,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_pageMessage","_unitMessages","_EventBus","_interopRequireDefault","_WebComponent","_UNAccountComponent","_bodyHtml","_listenerToBus","_accountMessage","_onLoadMessage","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AccountAction","exports","UNAccountComponent","React","forwardRef","props","accountRef","height","setHeight","useState","windowWidth","Dimensions","width","requestRefreshEvent","setRequestRefreshEvent","webRef","useRef","handleAccountChanged","account","onAccountChanged","requestRefresh","data","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","console","error","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","action","AccountMessage","UNIT_ACCOUNT_CHANGED","useEffect","injectRefreshEventIfNeeded","current","useImperativeHandle","openActionsMenu","injectOpenActionsMenuScript","handleMessage","message","type","UNIT_ON_LOAD","details","UNIT_REQUEST_RENDERING","event","componentName","WebComponentType","componentResourceId","accountId","requestRenderingEvent","EventBus","Instance","PageMessage","PAGE_HEIGHT","createElement","View","style","WebComponent","ref","presentationMode","PresentationMode","Default","params","getAccountParams","script","getAccountScript","theme","onMessage","isScrollable"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectOpenActionsMenuScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';\nimport type { UNError, UNOnLoadResponse, UNOnLoadResponseData } from '../../sharedTypes';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { UNAccountData } from '../../sharedTypes/account.types';\nimport { AccountMessage } from '../../messages/webMessages/accountMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\n\nexport interface UNAccountComponentProps {\n accountId?: string;\n customerToken: string;\n theme?: string;\n onLoad?: (response: UNOnLoadResponse<[UNAccountData]>) => void;\n onAccountChanged?: (account: UNAccountData) => void;\n}\n\nexport interface UNAccountRef {\n openActionsMenu: () => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountComponentProps>(function UNAccountComponent(props, accountRef) {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const handleAccountChanged = (account: UNAccountData) => {\n props.onAccountChanged && props.onAccountChanged(account);\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response) {\n // AccountsOnLoadResponse;\n props.onLoad(response[RESPONSE_KEYS.account] as UNOnLoadResponseData<[UNAccountData]>);\n return;\n }\n\n console.error('On Load Error: unexpected response type.');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n useImperativeHandle(accountRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n }\n }));\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const event: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAEA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAGA,IAAAS,cAAA,GAAAT,OAAA;AAEA,IAAAU,eAAA,GAAAV,OAAA;AACA,IAAAW,cAAA,GAAAX,OAAA;AAAkG,SAAAK,uBAAAO,GAAA,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,EAAE/C,MAAO;IACZ6B,IAAI,EAAEM,8BAAgB,CAAChC,OAAQ;IAC/B6C,gBAAgB,EAAEC,0BAAgB,CAACC,OAAQ;IAC3CC,MAAM,EAAE,IAAAC,oCAAgB,EAAC9D,KAAK,CAAE;IAChC+D,MAAM,EAAE,IAAAC,oCAAgB,GAAG;IAC3BC,KAAK,EAAEjE,KAAK,CAACiE,KAAM;IACnBC,SAAS,EAAE5B,OAAO,IAAID,aAAa,CAACC,OAAO,CAAE;IAC7C/B,KAAK,EAAEF,WAAY;IACnB8D,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC;AAACvE,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.injectRefreshEventIfNeeded = exports.getAccountScript = exports.getAccountParams = exports.getAccountActionType = void 0;
6
+ exports.injectRefreshEventIfNeeded = exports.injectOpenActionsMenuScript = exports.getAccountScript = exports.getAccountParams = exports.getAccountActionType = void 0;
7
7
  var _UNAccountComponent = require("./UNAccountComponent");
8
8
  var _unitMessages = require("../../messages/webMessages/unitMessages");
9
9
  var _WebComponent = require("../../webComponent/WebComponent");
@@ -23,6 +23,10 @@ const getAccountScript = () => {
23
23
  `;
24
24
  };
25
25
  exports.getAccountScript = getAccountScript;
26
+ const injectOpenActionsMenuScript = currentWeb => {
27
+ currentWeb === null || currentWeb === void 0 ? void 0 : currentWeb.injectJavaScript(`dispatchOpenActionsMenu('${_WebComponent.WebComponentType.account}')`);
28
+ };
29
+ exports.injectOpenActionsMenuScript = injectOpenActionsMenuScript;
26
30
  const injectRefreshEventIfNeeded = (currentWeb, requestRefreshEvent) => {
27
31
  if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(_WebComponent.WebComponentType.account.valueOf())) {
28
32
  currentWeb === null || currentWeb === void 0 ? void 0 : currentWeb.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
@@ -1 +1 @@
1
- {"version":3,"names":["_UNAccountComponent","require","_unitMessages","_WebComponent","getAccountParams","props","accountId","customerToken","exports","getAccountScript","UnitMessage","UNIT_REQUEST_REFRESH","injectRefreshEventIfNeeded","currentWeb","requestRefreshEvent","dependencies","includes","WebComponentType","account","valueOf","injectJavaScript","JSON","stringify","getAccountActionType","requestRendering","data","nativeComponent","AccountAction","List","Menu"],"sources":["UNAccountComponent.utils.ts"],"sourcesContent":["import { AccountAction, UNAccountComponentProps } from './UNAccountComponent';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport type WebView from 'react-native-webview';\nimport { WebComponentType } from '../../webComponent/WebComponent';\n\nexport const getAccountParams = (props: UNAccountComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n `;\n};\n\nexport const getAccountScript = () => {\n return `\n const dispatchRefreshEvent = (details) => {\n const event = new CustomEvent(\"${UnitMessage.UNIT_REQUEST_REFRESH}\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n `;\n};\n\nexport const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null) => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.account.valueOf())) {\n currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);\n }\n};\n\nexport const getAccountActionType = (requestRendering: RequestRenderingEvent) => {\n return requestRendering.data.nativeComponent.includes(AccountAction.List) ? AccountAction.List : AccountAction.Menu;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAEO,MAAMG,gBAAgB,GAAIC,KAA8B,IAAK;EAClE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,GAAG;AACH,CAAC;AAACC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA;AAEK,MAAMK,gBAAgB,GAAGA,CAAA,KAAM;EACpC,OAAQ;AACV;AACA,qCAAqCC,yBAAW,CAACC,oBAAqB;AACtE;AACA;AACA,GAAG;AACH,CAAC;AAACH,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEK,MAAMG,0BAA0B,GAAGA,CAACC,UAA0B,EAAEC,mBAA+C,KAAK;EACzH,IAAIA,mBAAmB,IAAIA,mBAAmB,CAACC,YAAY,CAACC,QAAQ,CAACC,8BAAgB,CAACC,OAAO,CAACC,OAAO,EAAE,CAAC,EAAE;IACxGN,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,gBAAgB,CAAE,yBAAwBC,IAAI,CAACC,SAAS,CAACR,mBAAmB,CAAE,IAAG,CAAC;EAChG;AACF,CAAC;AAACN,OAAA,CAAAI,0BAAA,GAAAA,0BAAA;AAEK,MAAMW,oBAAoB,GAAIC,gBAAuC,IAAK;EAC/E,OAAOA,gBAAgB,CAACC,IAAI,CAACC,eAAe,CAACV,QAAQ,CAACW,iCAAa,CAACC,IAAI,CAAC,GAAGD,iCAAa,CAACC,IAAI,GAAGD,iCAAa,CAACE,IAAI;AACrH,CAAC;AAACrB,OAAA,CAAAe,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["_UNAccountComponent","require","_unitMessages","_WebComponent","getAccountParams","props","accountId","customerToken","exports","getAccountScript","UnitMessage","UNIT_REQUEST_REFRESH","injectOpenActionsMenuScript","currentWeb","injectJavaScript","WebComponentType","account","injectRefreshEventIfNeeded","requestRefreshEvent","dependencies","includes","valueOf","JSON","stringify","getAccountActionType","requestRendering","data","nativeComponent","AccountAction","List","Menu"],"sources":["UNAccountComponent.utils.ts"],"sourcesContent":["import { AccountAction, UNAccountComponentProps } from './UNAccountComponent';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport type WebView from 'react-native-webview';\nimport { WebComponentType } from '../../webComponent/WebComponent';\n\nexport const getAccountParams = (props: UNAccountComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n `;\n};\n\nexport const getAccountScript = () => {\n return `\n const dispatchRefreshEvent = (details) => {\n const event = new CustomEvent(\"${UnitMessage.UNIT_REQUEST_REFRESH}\",{ detail: JSON.parse(details) })\n window.dispatchEvent(event)\n }\n `;\n};\n\nexport const injectOpenActionsMenuScript = (currentWeb: WebView | null) => {\n currentWeb?.injectJavaScript(`dispatchOpenActionsMenu('${WebComponentType.account}')`);\n};\n\nexport const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null) => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.account.valueOf())) {\n currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);\n }\n};\n\nexport const getAccountActionType = (requestRendering: RequestRenderingEvent) => {\n return requestRendering.data.nativeComponent.includes(AccountAction.List) ? AccountAction.List : AccountAction.Menu;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAEO,MAAMG,gBAAgB,GAAIC,KAA8B,IAAK;EAClE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,GAAG;AACH,CAAC;AAACC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA;AAEK,MAAMK,gBAAgB,GAAGA,CAAA,KAAM;EACpC,OAAQ;AACV;AACA,qCAAqCC,yBAAW,CAACC,oBAAqB;AACtE;AACA;AACA,GAAG;AACH,CAAC;AAACH,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEK,MAAMG,2BAA2B,GAAIC,UAA0B,IAAK;EACzEA,UAAU,aAA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