react-native-unit-components 1.2.0 → 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 (141) hide show
  1. package/README.md +133 -13
  2. package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  3. package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  4. package/ios/UnitReactNativeComponents.xcodeproj/project.xcworkspace/xcuserdata/alonshprung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  5. package/ios/UnitReactNativeComponents.xcodeproj/xcuserdata/alonshprung.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  6. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
  7. package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
  8. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
  9. package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
  10. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +25 -3
  11. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  12. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +5 -1
  13. package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
  14. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +24 -1
  15. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  16. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +2 -0
  17. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  18. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
  19. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  20. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +3 -0
  21. package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  22. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +37 -3
  23. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  24. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +9 -1
  25. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  26. package/lib/commonjs/messages/webMessages/cardMessage.js +1 -0
  27. package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -1
  28. package/lib/commonjs/messages/webMessages/onLoadMessage.js +17 -0
  29. package/lib/commonjs/messages/webMessages/onLoadMessage.js.map +1 -0
  30. package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
  31. package/lib/commonjs/scripts/html/bodyScript.js +23 -1
  32. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
  33. package/lib/commonjs/sharedTypes/account.types.js.map +1 -1
  34. package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -1
  35. package/lib/commonjs/sharedTypes/activity.types.js +6 -0
  36. package/lib/commonjs/sharedTypes/activity.types.js.map +1 -0
  37. package/lib/commonjs/sharedTypes/authorization.types.js +2 -0
  38. package/lib/commonjs/sharedTypes/authorization.types.js.map +1 -0
  39. package/lib/commonjs/sharedTypes/card.types.js +15 -0
  40. package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
  41. package/lib/commonjs/sharedTypes/index.js.map +1 -1
  42. package/lib/commonjs/sharedTypes/onLoadResponse.types.js +0 -4
  43. package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -1
  44. package/lib/commonjs/sharedTypes/transactions.types.js +52 -0
  45. package/lib/commonjs/sharedTypes/transactions.types.js.map +1 -0
  46. package/lib/commonjs/webComponent/WebComponent.js +4 -2
  47. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  48. package/lib/commonjs/webComponent/html.js +6 -0
  49. package/lib/commonjs/webComponent/html.js.map +1 -1
  50. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
  51. package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
  52. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
  53. package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
  54. package/lib/module/components/UNAccountComponent/UNAccountComponent.js +27 -5
  55. package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
  56. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +3 -0
  57. package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
  58. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +24 -1
  59. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  60. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +2 -0
  61. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  62. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
  63. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  64. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +3 -0
  65. package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
  66. package/lib/module/components/UNCardComponent/UNCardComponent.js +39 -5
  67. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  68. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +6 -0
  69. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  70. package/lib/module/messages/webMessages/cardMessage.js +1 -0
  71. package/lib/module/messages/webMessages/cardMessage.js.map +1 -1
  72. package/lib/module/messages/webMessages/onLoadMessage.js +10 -0
  73. package/lib/module/messages/webMessages/onLoadMessage.js.map +1 -0
  74. package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
  75. package/lib/module/scripts/html/bodyScript.js +20 -0
  76. package/lib/module/scripts/html/bodyScript.js.map +1 -1
  77. package/lib/module/sharedTypes/account.types.js.map +1 -1
  78. package/lib/module/sharedTypes/achCredit.types.js.map +1 -1
  79. package/lib/module/sharedTypes/activity.types.js +2 -0
  80. package/lib/module/sharedTypes/activity.types.js.map +1 -0
  81. package/lib/module/sharedTypes/authorization.types.js +2 -0
  82. package/lib/module/sharedTypes/authorization.types.js.map +1 -0
  83. package/lib/module/sharedTypes/card.types.js +13 -1
  84. package/lib/module/sharedTypes/card.types.js.map +1 -1
  85. package/lib/module/sharedTypes/index.js +1 -1
  86. package/lib/module/sharedTypes/index.js.map +1 -1
  87. package/lib/module/sharedTypes/onLoadResponse.types.js +1 -1
  88. package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -1
  89. package/lib/module/sharedTypes/transactions.types.js +44 -0
  90. package/lib/module/sharedTypes/transactions.types.js.map +1 -0
  91. package/lib/module/webComponent/WebComponent.js +4 -2
  92. package/lib/module/webComponent/WebComponent.js.map +1 -1
  93. package/lib/module/webComponent/html.js +7 -1
  94. package/lib/module/webComponent/html.js.map +1 -1
  95. package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.d.ts +2 -2
  96. package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.d.ts +2 -2
  97. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +7 -3
  98. package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +1 -0
  99. package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +4 -2
  100. package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -2
  101. package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +9 -3
  102. package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +3 -0
  103. package/lib/typescript/messages/webMessages/cardMessage.d.ts +5 -1
  104. package/lib/typescript/messages/webMessages/onLoadMessage.d.ts +30 -0
  105. package/lib/typescript/messages/webMessages/unitMessages.d.ts +2 -2
  106. package/lib/typescript/scripts/html/bodyScript.d.ts +3 -0
  107. package/lib/typescript/sharedTypes/account.types.d.ts +13 -4
  108. package/lib/typescript/sharedTypes/achCredit.types.d.ts +6 -0
  109. package/lib/typescript/sharedTypes/activity.types.d.ts +7 -0
  110. package/lib/typescript/sharedTypes/authorization.types.d.ts +20 -0
  111. package/lib/typescript/sharedTypes/card.types.d.ts +12 -0
  112. package/lib/typescript/sharedTypes/index.d.ts +1 -1
  113. package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +12 -16
  114. package/lib/typescript/sharedTypes/transactions.types.d.ts +80 -0
  115. package/package.json +1 -1
  116. package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +30 -3
  117. package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +30 -3
  118. package/src/components/UNAccountComponent/UNAccountComponent.tsx +40 -9
  119. package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +4 -0
  120. package/src/components/UNActivityComponent/UNActivityComponent.tsx +32 -3
  121. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +2 -0
  122. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +23 -3
  123. package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +4 -1
  124. package/src/components/UNCardComponent/UNCardComponent.tsx +49 -7
  125. package/src/components/UNCardComponent/UNCardComponent.utils.ts +9 -0
  126. package/src/messages/webMessages/cardMessage.ts +6 -0
  127. package/src/messages/webMessages/onLoadMessage.ts +45 -0
  128. package/src/messages/webMessages/unitMessages.ts +2 -2
  129. package/src/scripts/html/bodyScript.ts +22 -0
  130. package/src/sharedTypes/account.types.ts +25 -17
  131. package/src/sharedTypes/achCredit.types.ts +7 -0
  132. package/src/sharedTypes/activity.types.ts +8 -0
  133. package/src/sharedTypes/authorization.types.ts +22 -0
  134. package/src/sharedTypes/card.types.ts +13 -0
  135. package/src/sharedTypes/index.ts +1 -1
  136. package/src/sharedTypes/onLoadResponse.types.ts +15 -23
  137. package/src/sharedTypes/transactions.types.ts +84 -0
  138. package/src/webComponent/WebComponent.tsx +4 -2
  139. package/src/webComponent/html.ts +7 -1
  140. package/android/src/main/res/values/themes.xml +0 -16
  141. package/android/src/main/res/values-night/themes.xml +0 -16
@@ -0,0 +1,30 @@
1
+ import type { UNAccountData, UNCounterpartyAccountData, UNCardData, UNError, UNOnLoadResponseData } from '../../sharedTypes';
2
+ import type { UNAuthorizationData } from '../../sharedTypes/authorization.types';
3
+ import type { UNTransactionData } from '../../sharedTypes/transactions.types';
4
+ export declare enum RESPONSE_KEYS {
5
+ errors = "errors",
6
+ card = "cardResult",
7
+ account = "accountResult",
8
+ counterpartyAccount = "counterpartyResult",
9
+ transactions = "transactionsResult",
10
+ authorization = "authorizationResult"
11
+ }
12
+ export type CardOnLoadResponse = {
13
+ [RESPONSE_KEYS.card]: UNOnLoadResponseData<UNCardData>;
14
+ };
15
+ export type AccountOnLoadResponse = {
16
+ [RESPONSE_KEYS.account]: UNOnLoadResponseData<UNAccountData>;
17
+ };
18
+ export type AccountsOnLoadResponse = {
19
+ [RESPONSE_KEYS.account]: UNOnLoadResponseData<[UNAccountData]>;
20
+ };
21
+ export type ACHOnLoadResponse = {
22
+ [RESPONSE_KEYS.account]: UNOnLoadResponseData<UNAccountData>;
23
+ [RESPONSE_KEYS.counterpartyAccount]: UNOnLoadResponseData<[UNCounterpartyAccountData]>;
24
+ };
25
+ export type ActivityOnLoadResponse = {
26
+ [RESPONSE_KEYS.authorization]: UNOnLoadResponseData<UNAuthorizationData>;
27
+ [RESPONSE_KEYS.transactions]: UNOnLoadResponseData<UNTransactionData>;
28
+ };
29
+ export type UnitOnLoadResponseSuccessData = CardOnLoadResponse | ACHOnLoadResponse | AccountsOnLoadResponse | AccountOnLoadResponse | ActivityOnLoadResponse;
30
+ export type UnitOnLoadResponseEvent = UNError | UnitOnLoadResponseSuccessData;
@@ -1,4 +1,4 @@
1
- import type { UNResponseUnitOnLoadEvent } from '../../sharedTypes';
1
+ import type { UnitOnLoadResponseEvent } from './onLoadMessage';
2
2
  export declare enum UnitMessage {
3
3
  UNIT_REQUEST_RENDERING = "unitRequestRendering",
4
4
  UNIT_REQUEST_REFRESH = "unitRequestRefresh",
@@ -48,5 +48,5 @@ interface PlaidLinkTokenAttributes {
48
48
  export interface RequestExternalSdkEvent {
49
49
  type: string;
50
50
  }
51
- export type UnitEvent = RequestRenderingEvent | RequestRefreshEvent | RequestOpenLinkEvent | UNResponseUnitOnLoadEvent | RequestDownloadEvent | PlaidTokenCreatedEvent | RequestExternalSdkEvent;
51
+ export type UnitEvent = RequestRenderingEvent | RequestRefreshEvent | RequestOpenLinkEvent | UnitOnLoadResponseEvent | RequestDownloadEvent | PlaidTokenCreatedEvent | RequestExternalSdkEvent;
52
52
  export {};
@@ -8,6 +8,7 @@ export declare const LISTENERS: {
8
8
  requestCloseFlow: string;
9
9
  requestOpenLink: string;
10
10
  unitRequestDownload: string;
11
+ cardActivated: string;
11
12
  cardStatusChange: string;
12
13
  unitRequestExternalSdk: string;
13
14
  unitPaymentCreated: string;
@@ -16,3 +17,5 @@ export declare const LISTENERS: {
16
17
  export declare const DISPATCH_RENDERING_EVENT: string;
17
18
  export declare const DISPATCH_REQUEST_REFRESH: string;
18
19
  export declare const DISPATCH_PLAID_RESPONSE: string;
20
+ export declare const DISPATCH_OPEN_ACTIONS_MENU = "\n const dispatchOpenActionsMenu = (componentName) => {\n document.querySelector(componentName).dispatchEvent(new CustomEvent(\"unitRequestOpenActionsMenu\"))\n }\n";
21
+ export declare const DISPATCH_REQUEST_CARD_ACTION = "\n const dispatchRequestCardAction = (action) => {\n document.querySelector(\"unit-elements-card\").dispatchEvent(new CustomEvent(\"unitRequestCardAction\", {detail: {action: action}}))\n }\n";
@@ -1,5 +1,14 @@
1
1
  import type { UNRelationship, UNTags } from './types';
2
2
  export type UNAccountData = UNDepositAccount | UNBatchAccount | UNCreditAccount;
3
+ export type UNCounterpartyAccountData = {
4
+ id: string;
5
+ attributes: {
6
+ name: string;
7
+ tags?: {
8
+ [key: string]: string;
9
+ };
10
+ };
11
+ };
3
12
  declare enum UNAccountStatus {
4
13
  Open = "Open",
5
14
  Closed = "Closed",
@@ -21,7 +30,7 @@ export declare enum UNFraudReason {
21
30
  }
22
31
  export type UNDepositAccount = {
23
32
  id: string;
24
- type: "depositAccount";
33
+ type: 'depositAccount';
25
34
  attributes: {
26
35
  createdAt: string;
27
36
  updatedAt?: string;
@@ -56,7 +65,7 @@ export type UNDepositAccount = {
56
65
  };
57
66
  export type UNBatchAccount = {
58
67
  id: string;
59
- type: "batchAccount";
68
+ type: 'batchAccount';
60
69
  attributes: {
61
70
  createdAt: Date;
62
71
  updatedAt?: Date;
@@ -70,7 +79,7 @@ export type UNBatchAccount = {
70
79
  reserve: number;
71
80
  available: number;
72
81
  currency: string;
73
- status: "Open" | "Closed";
82
+ status: 'Open' | 'Closed';
74
83
  closeReason?: string;
75
84
  fraudReason?: UNFraudReason;
76
85
  closeReasonText?: string;
@@ -85,7 +94,7 @@ export type UNBatchAccount = {
85
94
  };
86
95
  export type UNCreditAccount = {
87
96
  id: string;
88
- type: "creditAccount";
97
+ type: 'creditAccount';
89
98
  attributes: {
90
99
  createdAt: Date;
91
100
  updatedAt?: Date;
@@ -1,5 +1,11 @@
1
+ import type { RESPONSE_KEYS } from '../messages/webMessages/onLoadMessage';
2
+ import type { UNAccountData, UNCounterpartyAccountData } from './account.types';
1
3
  import type { UNAchCounterparty, UNCounterpartyVerificationMethod, UNPaymentStatus } from './payments.types';
2
4
  import type { UNTags, UNRelationship } from './types';
5
+ export type UNACHOnLoadData = {
6
+ [RESPONSE_KEYS.account]: UNAccountData;
7
+ [RESPONSE_KEYS.counterpartyAccount]: [UNCounterpartyAccountData];
8
+ };
3
9
  export type UNACHData = {
4
10
  type: 'achPayment';
5
11
  id: string;
@@ -0,0 +1,7 @@
1
+ import type { RESPONSE_KEYS } from '../messages/webMessages/onLoadMessage';
2
+ import type { UNAuthorizationData } from './authorization.types';
3
+ import type { UNTransactionData } from './transactions.types';
4
+ export type UNActivityOnLoadData = {
5
+ [RESPONSE_KEYS.authorization]: UNAuthorizationData;
6
+ [RESPONSE_KEYS.transactions]: UNTransactionData;
7
+ };
@@ -0,0 +1,20 @@
1
+ export type UNAuthorizationData = {
2
+ type: string;
3
+ id: string;
4
+ attributes: UNAuthorizationDetails;
5
+ };
6
+ export type UNAuthorizationDetails = {
7
+ cardNetwork: string;
8
+ createdAt: Date;
9
+ amount: string;
10
+ merchant?: UNAuthorizationMerchant;
11
+ cardLast4Digits: string;
12
+ recurring: boolean;
13
+ summary: string;
14
+ };
15
+ export type UNAuthorizationMerchant = {
16
+ name: string;
17
+ type: string;
18
+ category: string;
19
+ location?: string;
20
+ };
@@ -53,4 +53,16 @@ export type UNBusinessDebitCard = {
53
53
  customer: UNRelationship;
54
54
  };
55
55
  };
56
+ export declare enum UNCardMenuAction {
57
+ Freeze = "Freeze",
58
+ ManagePin = "ManagePin",
59
+ Replace = "Replace",
60
+ Report = "Report",
61
+ Close = "Close",
62
+ Activate = "Activate",
63
+ Unfreeze = "Unfreeze",
64
+ ChangePin = "ChangePin",
65
+ SetPin = "SetPin",
66
+ AddToWallet = "AddToWallet"
67
+ }
56
68
  export {};
@@ -3,4 +3,4 @@ export * from './card.types';
3
3
  export * from './onLoadResponse.types';
4
4
  export * from './achCredit.types';
5
5
  export * from './payments.types';
6
- export * from "./account.types";
6
+ export * from './account.types';
@@ -1,18 +1,14 @@
1
- import type { UNCardData } from '../sharedTypes';
2
- export type UNSuccessResponseUnitOnLoad = {
3
- data: UNCardData | Object;
4
- included: [Object];
5
- errors: null;
1
+ export type UNOnLoadResponseData<T> = {
2
+ data: T;
6
3
  };
7
- export type UNErrorResponseUnitOnLoad = {
8
- errors: [
9
- {
10
- status: string;
11
- title: string;
12
- detail?: string;
13
- details?: string;
14
- meta?: Record<string, string>;
15
- }
16
- ];
4
+ export type UNError = {
5
+ errors: UNErrorData[];
17
6
  };
18
- export type UNResponseUnitOnLoadEvent = UNSuccessResponseUnitOnLoad | UNErrorResponseUnitOnLoad;
7
+ export type UNErrorData = {
8
+ status: string;
9
+ title: string;
10
+ detail?: string;
11
+ details?: string;
12
+ meta?: Record<string, string>;
13
+ };
14
+ export type UNOnLoadResponse<T> = UNOnLoadResponseData<T> | UNError;
@@ -0,0 +1,80 @@
1
+ export type UNTransactionData = {
2
+ type: UNTransactionType;
3
+ id: string;
4
+ attributes: UNATransactionAttributes;
5
+ relationships: UNTransactionRelationships;
6
+ };
7
+ export type UNATransactionAttributes = {
8
+ createdAt: Date;
9
+ amount: string;
10
+ direction?: UNDirection;
11
+ balance?: string;
12
+ summary?: string;
13
+ companyName?: string;
14
+ counterpartyName?: string;
15
+ counterpartyRoutingNumber?: string;
16
+ reason?: string;
17
+ };
18
+ export type UNTransactionRelationships = {
19
+ customer?: {
20
+ data: {
21
+ type: string;
22
+ id: number;
23
+ };
24
+ };
25
+ customers?: {
26
+ data: [
27
+ {
28
+ type: 'customer';
29
+ id: string;
30
+ }
31
+ ];
32
+ };
33
+ org?: {
34
+ data: {
35
+ type: string;
36
+ id: number;
37
+ };
38
+ };
39
+ };
40
+ export declare enum UNDirection {
41
+ Debit = "Debit",
42
+ Credit = "Credit"
43
+ }
44
+ export declare enum UNTransactionType {
45
+ ATM = "atmTransaction",
46
+ Adjustment = "adjustmentTransaction",
47
+ BillPay = "billPayTransaction",
48
+ Book = "bookTransaction",
49
+ Card = "cardTransaction",
50
+ CardReversal = "cardReverTransactionTypessalTransaction",
51
+ Chargeback = "chargebackTransaction",
52
+ CheckDeposit = "checkDepositTransaction",
53
+ DishonoredACH = "dishonoredAchTransaction",
54
+ Dispute = "disputeTransaction",
55
+ DisputeSettlement = "disputeSettlementTransaction",
56
+ Fee = "feeTransaction",
57
+ InterchangeShare = "interchangeShareTransaction",
58
+ Interest = "interestTransaction",
59
+ InterestShare = "interestShareTransaction",
60
+ NegativeBalanceCoverage = "negativeBalanceCoverageTransaction",
61
+ OriginatedACH = "originatedAchTransaction",
62
+ PaymentAdvance = "paymentAdvanceTransaction",
63
+ PaymentCanceled = "paymentCanceledTransaction",
64
+ Purchase = "purchaseTransaction",
65
+ ReceivedACH = "receivedAchTransaction",
66
+ Release = "releaseTransaction",
67
+ RepaidPaymentAdvance = "repaidPaymentAdvanceTransaction",
68
+ ReturnedACH = "returnedAchTransaction",
69
+ ReturnedCheckDeposit = "returnedCheckDepositTransaction",
70
+ ReturnedReceivedACH = "returnedReceivedAchTransaction",
71
+ Reward = "rewardTransaction",
72
+ Settlement = "settlementTransaction",
73
+ SponsoredInterest = "sponsoredInterestTransaction",
74
+ Wire = "wireTransaction",
75
+ AccountLowBalanceClosure = "accountLowBalanceClosureTransaction",
76
+ CashDeposit = "cashDepositTransaction",
77
+ BankRepayment = "bankRepaymentTransaction",
78
+ CustomerRepayment = "CustomerRepaymentTransaction",
79
+ CustomerRepaymentReturned = "CustomerRepaymentReturnedTransaction"
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unit-components",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Unit React Native components",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -2,13 +2,14 @@ import React, { useState } from 'react';
2
2
  import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
3
3
  import { PresentationMode } from '../../scripts/html/bodyHtml';
4
4
  import type { WebViewMessage } from '../../messages/webMessages';
5
- import type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';
5
+ import type { UNOnLoadResponse, UNACHData, UNACHOnLoadData, UNError, UNOnLoadResponseData } from '../../sharedTypes';
6
6
  import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
7
7
  import { View } from 'react-native';
8
8
  import { UnitMessage } from '../../messages/webMessages/unitMessages';
9
9
  import { getACHCreditParams, getACHCreditScript } from './UNACHCreditComponent.utils';
10
10
  import { PaymentMessage } from '../../messages/webMessages/paymentsMessage';
11
11
  import type { ACHEvent } from '../../messages/webMessages/achCreditMessage';
12
+ import { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';
12
13
 
13
14
  export interface UNACHCreditComponentProps {
14
15
  accountId: string;
@@ -17,13 +18,39 @@ export interface UNACHCreditComponentProps {
17
18
  isAutoFocus?: boolean;
18
19
  fee?: number;
19
20
  onPaymentCreated?: (data: UNACHData) => void;
20
- onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
21
+ onLoad?: (response: UNOnLoadResponse<UNACHOnLoadData>) => void;
21
22
  }
22
23
 
23
24
  export const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {
24
25
  const [height, setHeight] = useState<number>(0);
25
26
  const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);
26
27
 
28
+ const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {
29
+ if (!props.onLoad) {
30
+ return;
31
+ }
32
+
33
+ if (RESPONSE_KEYS.errors in response) {
34
+ props.onLoad(response as UNError);
35
+ return;
36
+ }
37
+
38
+ if (RESPONSE_KEYS.account in response && RESPONSE_KEYS.counterpartyAccount in response) {
39
+ // ACHOnLoadResponse;
40
+ const achOnload: UNOnLoadResponseData<UNACHOnLoadData> = {
41
+ data: {
42
+ [RESPONSE_KEYS.account]: response[RESPONSE_KEYS.account].data,
43
+ [RESPONSE_KEYS.counterpartyAccount]: response[RESPONSE_KEYS.counterpartyAccount].data,
44
+ }
45
+ };
46
+ props.onLoad(achOnload);
47
+ return;
48
+ }
49
+
50
+ console.error('On Load Error: unexpected response type');
51
+ return;
52
+ };
53
+
27
54
  const handleWebViewMessage = (message: WebViewMessage) => {
28
55
  if (!message || !message.details) return;
29
56
 
@@ -34,7 +61,7 @@ export const UNACHCreditComponent = (props: UNACHCreditComponentProps) => {
34
61
  break;
35
62
  }
36
63
  case UnitMessage.UNIT_ON_LOAD:
37
- props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
64
+ handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);
38
65
  break;
39
66
  case PageMessage.PAGE_HEIGHT: {
40
67
  const currentHeight = (message.details as HeightEvent).height;
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
3
3
  import { PresentationMode } from '../../scripts/html/bodyHtml';
4
4
  import type { WebViewMessage } from '../../messages/webMessages';
5
- import type { UNResponseUnitOnLoadEvent, UNACHData } from '../../sharedTypes';
5
+ import type { UNOnLoadResponse, UNACHData, UNError, UNOnLoadResponseData, UNACHOnLoadData } from '../../sharedTypes';
6
6
  import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
7
7
  import { Platform, View } from 'react-native';
8
8
  import { PlaidLinkTokenData, PlaidTokenCreatedEvent, RequestExternalSdkEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
@@ -13,6 +13,7 @@ import type WebView from 'react-native-webview';
13
13
 
14
14
  import { PaymentMessage } from '../../messages/webMessages/paymentsMessage';
15
15
  import type { ACHEvent } from '../../messages/webMessages/achCreditMessage';
16
+ import { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';
16
17
 
17
18
  export interface UNACHDebitComponentProps {
18
19
  accountId: string;
@@ -21,7 +22,7 @@ export interface UNACHDebitComponentProps {
21
22
  isAutoFocus?: boolean;
22
23
  fee?: number;
23
24
  onPaymentCreated?: (data: UNACHData) => void;
24
- onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
25
+ onLoad?: (response: UNOnLoadResponse<UNACHOnLoadData>) => void;
25
26
  }
26
27
 
27
28
  export const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {
@@ -45,6 +46,32 @@ export const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {
45
46
  injectUnitPlaidResponse(webRef.current, success);
46
47
  };
47
48
 
49
+ const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {
50
+ if (!props.onLoad) {
51
+ return;
52
+ }
53
+
54
+ if (RESPONSE_KEYS.errors in response) {
55
+ props.onLoad(response as UNError);
56
+ return;
57
+ }
58
+
59
+ if (RESPONSE_KEYS.account in response && RESPONSE_KEYS.counterpartyAccount in response) {
60
+ // ACHOnLoadResponse;
61
+ const achOnload: UNOnLoadResponseData<UNACHOnLoadData> = {
62
+ data: {
63
+ [RESPONSE_KEYS.account]: response[RESPONSE_KEYS.account].data,
64
+ [RESPONSE_KEYS.counterpartyAccount]: response[RESPONSE_KEYS.counterpartyAccount].data,
65
+ }
66
+ };
67
+ props.onLoad(achOnload);
68
+ return;
69
+ }
70
+
71
+ console.error('On Load Error: unexpected response type');
72
+ return;
73
+ };
74
+
48
75
  const handleWebViewMessage = (message: WebViewMessage) => {
49
76
  if (!message || !message.details) return;
50
77
 
@@ -55,7 +82,7 @@ export const UNACHDebitComponent = (props: UNACHDebitComponentProps) => {
55
82
  break;
56
83
  }
57
84
  case UnitMessage.UNIT_ON_LOAD:
58
- props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
85
+ handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);
59
86
  break;
60
87
  case PageMessage.PAGE_HEIGHT: {
61
88
  const currentHeight = (message.details as HeightEvent).height;
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
2
2
  import { Dimensions, View } from 'react-native';
3
3
  import type WebView from 'react-native-webview';
4
4
  import { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';
@@ -6,28 +6,33 @@ import { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../m
6
6
  import EventBus from '../../helpers/EventBus';
7
7
  import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
8
8
  import type { WebViewMessage } from '../../messages/webMessages';
9
- import { getAccountParams, getAccountScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';
9
+ import { getAccountParams, getAccountScript, injectOpenActionsMenuScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';
10
10
  import { PresentationMode } from '../../scripts/html/bodyHtml';
11
11
  import type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';
12
- import type { UNResponseUnitOnLoadEvent } from '../../sharedTypes';
12
+ import type { UNError, UNOnLoadResponse, UNOnLoadResponseData } from '../../sharedTypes';
13
13
  import { useListenerToBus } from '../../hooks/listenerToBus';
14
14
  import type { UNAccountData } from '../../sharedTypes/account.types';
15
15
  import { AccountMessage } from '../../messages/webMessages/accountMessage';
16
+ import { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';
16
17
 
17
18
  export interface UNAccountComponentProps {
18
19
  accountId?: string;
19
20
  customerToken: string;
20
21
  theme?: string;
21
- onLoad?: (response: UNResponseUnitOnLoadEvent) => void;
22
+ onLoad?: (response: UNOnLoadResponse<[UNAccountData]>) => void;
22
23
  onAccountChanged?: (account: UNAccountData) => void;
23
24
  }
24
25
 
26
+ export interface UNAccountRef {
27
+ openActionsMenu: () => void;
28
+ }
29
+
25
30
  export enum AccountAction {
26
31
  List = 'account-list',
27
32
  Menu = 'account-menu'
28
33
  }
29
34
 
30
- export const UNAccountComponent = (props: UNAccountComponentProps) => {
35
+ export const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountComponentProps>(function UNAccountComponent(props, accountRef) {
31
36
  const [height, setHeight] = useState(0);
32
37
  const windowWidth = Dimensions.get('window').width;
33
38
 
@@ -36,13 +41,33 @@ export const UNAccountComponent = (props: UNAccountComponentProps) => {
36
41
  const webRef = useRef<WebView>(null);
37
42
 
38
43
  const handleAccountChanged = (account: UNAccountData) => {
39
- props.onAccountChanged && props.onAccountChanged(account)
40
- }
44
+ props.onAccountChanged && props.onAccountChanged(account);
45
+ };
41
46
 
42
47
  const requestRefresh = (data: RequestRefreshEvent) => {
43
48
  setRequestRefreshEvent(data);
44
49
  };
45
50
 
51
+ const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {
52
+ if (!props.onLoad) {
53
+ return;
54
+ }
55
+
56
+ if (RESPONSE_KEYS.errors in response) {
57
+ props.onLoad(response as UNError);
58
+ return;
59
+ }
60
+
61
+ if (RESPONSE_KEYS.account in response) {
62
+ // AccountsOnLoadResponse;
63
+ props.onLoad(response[RESPONSE_KEYS.account] as UNOnLoadResponseData<[UNAccountData]>);
64
+ return;
65
+ }
66
+
67
+ console.error('On Load Error: unexpected response type.');
68
+ return;
69
+ };
70
+
46
71
  useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });
47
72
  useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });
48
73
 
@@ -50,10 +75,16 @@ export const UNAccountComponent = (props: UNAccountComponentProps) => {
50
75
  injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);
51
76
  }, [requestRefreshEvent]);
52
77
 
78
+ useImperativeHandle(accountRef, () => ({
79
+ openActionsMenu() {
80
+ injectOpenActionsMenuScript(webRef.current);
81
+ }
82
+ }));
83
+
53
84
  const handleMessage = (message: WebViewMessage) => {
54
85
  switch (message.type) {
55
86
  case UnitMessage.UNIT_ON_LOAD:
56
- props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
87
+ handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);
57
88
  break;
58
89
  case UnitMessage.UNIT_REQUEST_RENDERING: {
59
90
  const event: BottomSheetSlotData = {
@@ -85,4 +116,4 @@ export const UNAccountComponent = (props: UNAccountComponentProps) => {
85
116
  />
86
117
  </View>
87
118
  );
88
- };
119
+ });
@@ -19,6 +19,10 @@ export const getAccountScript = () => {
19
19
  `;
20
20
  };
21
21
 
22
+ export const injectOpenActionsMenuScript = (currentWeb: WebView | null) => {
23
+ currentWeb?.injectJavaScript(`dispatchOpenActionsMenu('${WebComponentType.account}')`);
24
+ };
25
+
22
26
  export const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null) => {
23
27
  if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.account.valueOf())) {
24
28
  currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
@@ -5,19 +5,22 @@ import { useListenerToBus } from '../../hooks/listenerToBus';
5
5
  import type { WebViewMessage } from '../../messages/webMessages';
6
6
  import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
7
7
  import { PresentationMode } from '../../scripts/html/bodyHtml';
8
- import type { UNResponseUnitOnLoadEvent } from '../../sharedTypes';
8
+ import type { UNError, UNOnLoadResponse, UNOnLoadResponseData } from '../../sharedTypes';
9
9
  import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
10
10
  import { getActivityParams, getActivityScript, injectRefreshEventIfNeeded } from './UNActivityComponent.utils';
11
11
  import type WebView from 'react-native-webview';
12
12
  import type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';
13
13
  import EventBus from '../../helpers/EventBus';
14
+ import type { UNActivityOnLoadData } from '../../sharedTypes/activity.types';
15
+ import { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';
14
16
 
15
17
  const DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;
16
18
  export interface UNActivityComponentProps {
17
19
  accountId: string;
18
20
  customerToken: string;
19
21
  theme?: string;
20
- onLoad?: (response: UNResponseUnitOnLoadEvent) => void
22
+ onLoad?: (response: UNOnLoadResponse<UNActivityOnLoadData>) => void;
23
+ queryFilter?: string
21
24
  }
22
25
 
23
26
  export const UNActivityComponent = (props: UNActivityComponentProps) => {
@@ -30,6 +33,32 @@ export const UNActivityComponent = (props: UNActivityComponentProps) => {
30
33
 
31
34
  useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });
32
35
 
36
+ const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {
37
+ if (!props.onLoad) {
38
+ return;
39
+ }
40
+
41
+ if (RESPONSE_KEYS.errors in response) {
42
+ props.onLoad(response as UNError);
43
+ return;
44
+ }
45
+
46
+ if (RESPONSE_KEYS.authorization in response && RESPONSE_KEYS.transactions in response) {
47
+ // ActivityOnLoadResponse;
48
+ const activityOnLoad: UNOnLoadResponseData<UNActivityOnLoadData> = {
49
+ data: {
50
+ [RESPONSE_KEYS.authorization]: response[RESPONSE_KEYS.authorization].data,
51
+ [RESPONSE_KEYS.transactions]: response[RESPONSE_KEYS.transactions].data
52
+ }
53
+ };
54
+ props.onLoad(activityOnLoad);
55
+ return;
56
+ }
57
+
58
+ console.error('On Load Error: unexpected response type');
59
+ return;
60
+ };
61
+
33
62
  const handleWebViewMessage = (message: WebViewMessage) => {
34
63
  switch (message.type) {
35
64
  case UnitMessage.UNIT_REQUEST_RENDERING: {
@@ -42,7 +71,7 @@ export const UNActivityComponent = (props: UNActivityComponentProps) => {
42
71
  break;
43
72
  }
44
73
  case UnitMessage.UNIT_ON_LOAD:
45
- props.onLoad && props.onLoad(message.details as UNResponseUnitOnLoadEvent);
74
+ handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);
46
75
  break;
47
76
  case PageMessage.PAGE_HEIGHT: {
48
77
  const currentHeight = (message.details as HeightEvent).height;
@@ -5,9 +5,11 @@ import { DISPATCH_REQUEST_REFRESH } from './../../scripts/html/bodyScript';
5
5
  import type { UNActivityComponentProps } from './UNActivityComponent';
6
6
 
7
7
  export const getActivityParams = (props: UNActivityComponentProps) => {
8
+ const queryFilterParam = props.queryFilter ? `query-filter="${props.queryFilter}"` : '';
8
9
  return `
9
10
  account-id="${props.accountId}"
10
11
  customer-token="${props.customerToken}"
12
+ ${queryFilterParam}
11
13
  style="height: 100%"
12
14
  `;
13
15
  };