react-native-unit-components 1.0.1 → 1.0.3
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.
- package/README.md +75 -6
- package/android/src/main/AndroidManifest.xml +12 -1
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -1
- package/android/src/main/java/com/unitreactnativecomponents/sharepdf/UNSharePDF.kt +75 -0
- package/android/src/main/res/layout/un_black_add_to_googlepay_button.xml +2 -2
- package/android/src/main/res/layout/un_view_google_push_provisioning.xml +1 -13
- package/android/src/main/res/layout/un_white_add_to_googlepay_button.xml +1 -1
- package/android/src/main/res/layout/un_white_add_to_googlepay_button_no_shadow.xml +1 -1
- package/android/src/main/res/xml/file_paths.xml +4 -0
- package/ios/UnitReactNativeComponentsViewManager.m +0 -1
- package/ios/UnitReactNativeComponentsViewManager.swift +6 -2
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +103 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +47 -0
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +63 -8
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +18 -3
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +56 -13
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +4 -3
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +3 -3
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +114 -46
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +4 -8
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +95 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +31 -0
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +65 -7
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +56 -10
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js +20 -0
- package/lib/commonjs/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +44 -0
- package/lib/commonjs/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
- package/lib/commonjs/components/index.js +13 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +32 -12
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/commonjs/helpers/EventBus.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/cardMessage.js +36 -0
- package/lib/commonjs/messages/nativeMessages/cardMessage.js.map +1 -0
- package/lib/commonjs/messages/nativeMessages/index.js +0 -7
- package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js +14 -0
- package/lib/commonjs/messages/nativeMessages/sdkMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/commonjs/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
- package/lib/commonjs/nativeComponent/UnitAddToWalletButton.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyHtml.js +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyScript.js +22 -5
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/index.js +13 -0
- package/lib/commonjs/sharedTypes/index.js.map +1 -1
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js +6 -0
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/wallet.types.js +22 -0
- package/lib/commonjs/sharedTypes/wallet.types.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js +5 -3
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +18 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +35 -10
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.utils.js +41 -0
- package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -0
- package/lib/commonjs/webComponent/html.js +9 -1
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js +74 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +26 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +56 -8
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -2
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +50 -12
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +3 -2
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +111 -46
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +5 -9
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js +68 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js +21 -0
- package/lib/module/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.js.map +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js +65 -9
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +48 -9
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js +10 -0
- package/lib/module/components/UNCardComponent/networking/common/UNNetworkConstants.js.map +1 -0
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js +29 -0
- package/lib/module/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.js +30 -13
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +2 -2
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -1
- package/lib/module/helpers/EventBus.js.map +1 -1
- package/lib/module/messages/nativeMessages/cardMessage.js +27 -0
- package/lib/module/messages/nativeMessages/cardMessage.js.map +1 -0
- package/lib/module/messages/nativeMessages/index.js +1 -5
- package/lib/module/messages/nativeMessages/index.js.map +1 -1
- package/lib/module/messages/nativeMessages/sdkMessage.js +7 -0
- package/lib/module/messages/nativeMessages/sdkMessage.js.map +1 -0
- package/lib/module/messages/webMessages/unitMessages.js +1 -0
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/module/nativeComponent/{UNNativeAddToWalletButton.js → UnitAddToWalletButton.js} +1 -1
- package/lib/module/nativeComponent/UnitAddToWalletButton.js.map +1 -0
- package/lib/module/scripts/html/bodyHtml.js +1 -1
- package/lib/module/scripts/html/bodyHtml.js.map +1 -1
- package/lib/module/scripts/html/bodyScript.js +19 -3
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/sharedTypes/bookPayment.types.js.map +1 -1
- package/lib/module/sharedTypes/card.types.js.map +1 -1
- package/lib/module/sharedTypes/index.js +1 -0
- package/lib/module/sharedTypes/index.js.map +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js +2 -0
- package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -0
- package/lib/module/sharedTypes/wallet.types.js +14 -0
- package/lib/module/sharedTypes/wallet.types.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdk.api.js +4 -3
- package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdkManager.js +13 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +32 -10
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/WebComponent.utils.js +27 -0
- package/lib/module/webComponent/WebComponent.utils.js.map +1 -0
- package/lib/module/webComponent/html.js +9 -2
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +12 -0
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +7 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +2 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +4 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +9 -2
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +2 -1
- package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.d.ts +6 -0
- package/lib/typescript/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.d.ts +17 -0
- package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +4 -1
- package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +9 -1
- package/lib/typescript/components/UNCardComponent/networking/common/UNNetworkConstants.d.ts +8 -0
- package/lib/typescript/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.d.ts +1 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/helpers/EventBus.d.ts +3 -3
- package/lib/typescript/messages/nativeMessages/cardMessage.d.ts +28 -0
- package/lib/typescript/messages/nativeMessages/index.d.ts +7 -2
- package/lib/typescript/messages/nativeMessages/sdkMessage.d.ts +8 -0
- package/lib/typescript/messages/webMessages/unitMessages.d.ts +16 -6
- package/lib/typescript/scripts/html/bodyScript.d.ts +4 -1
- package/lib/typescript/sharedTypes/bookPayment.types.d.ts +3 -3
- package/lib/typescript/sharedTypes/card.types.d.ts +6 -6
- package/lib/typescript/sharedTypes/index.d.ts +1 -0
- package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +18 -0
- package/lib/typescript/sharedTypes/wallet.types.d.ts +14 -0
- package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +3 -0
- package/lib/typescript/webComponent/WebComponent.d.ts +4 -1
- package/lib/typescript/webComponent/WebComponent.utils.d.ts +2 -0
- package/package.json +2 -1
- package/src/components/UNAccountComponent/UNAccountComponent.tsx +82 -0
- package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +30 -0
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +57 -8
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +14 -2
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +47 -13
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +3 -2
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -1
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +120 -44
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +7 -10
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.styles.ts +21 -0
- package/src/components/UNBottomSheetComponent/components/UNAddToWalletBottomSheetItem.tsx +74 -0
- package/src/components/UNCardComponent/UNCardComponent.tsx +68 -13
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +47 -9
- package/src/components/UNCardComponent/networking/common/UNNetworkConstants.ts +11 -0
- package/src/components/UNCardComponent/networking/requests/UNWalletPayloadRequest.ts +34 -0
- package/src/components/index.ts +1 -0
- package/src/helpers/BottomSheet/BottomSheet.styles.ts +2 -2
- package/src/helpers/BottomSheet/BottomSheet.tsx +28 -12
- package/src/helpers/EventBus.ts +3 -3
- package/src/messages/nativeMessages/cardMessage.ts +37 -0
- package/src/messages/nativeMessages/index.ts +14 -2
- package/src/messages/nativeMessages/sdkMessage.ts +11 -0
- package/src/messages/webMessages/unitMessages.ts +20 -7
- package/src/scripts/html/bodyHtml.ts +1 -1
- package/src/scripts/html/bodyScript.ts +21 -4
- package/src/sharedTypes/bookPayment.types.ts +3 -3
- package/src/sharedTypes/card.types.ts +6 -6
- package/src/sharedTypes/index.ts +1 -0
- package/src/sharedTypes/onLoadResponse.types.ts +27 -0
- package/src/sharedTypes/wallet.types.ts +17 -0
- package/src/unitSdkManager/UnitSdk.api.ts +3 -2
- package/src/unitSdkManager/UnitSdkManager.ts +12 -0
- package/src/webComponent/WebComponent.tsx +35 -12
- package/src/webComponent/WebComponent.utils.ts +26 -0
- package/src/webComponent/html.ts +9 -2
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +0 -1
- /package/lib/typescript/nativeComponent/{UNNativeAddToWalletButton.d.ts → UnitAddToWalletButton.d.ts} +0 -0
- /package/src/nativeComponent/{UNNativeAddToWalletButton.tsx → UnitAddToWalletButton.tsx} +0 -0
package/README.md
CHANGED
|
@@ -75,17 +75,20 @@ export default function YourRootComponent() {
|
|
|
75
75
|
#### Card Component
|
|
76
76
|
|
|
77
77
|
##### UNCardComponent props:
|
|
78
|
-
| Name
|
|
79
|
-
|
|
|
80
|
-
| customerToken
|
|
81
|
-
| cardId
|
|
82
|
-
| theme
|
|
83
|
-
| onStatusChanged
|
|
78
|
+
| Name | Type | Required | Description |
|
|
79
|
+
| ---------------------- | ---------------------------- | --------- | -------------------------------------------------------- |
|
|
80
|
+
| customerToken | string | YES | A Unit Customer token. |
|
|
81
|
+
| cardId | string | YES | Unit card id. |
|
|
82
|
+
| theme | string | No | A URL that specifies the UI configuration. |
|
|
83
|
+
| onStatusChanged | (card: UNCardData) => void | No | Callback for card status changes. |
|
|
84
|
+
| pushProvisioningModule | typeof NativeModules | No | A Native Module that implements Visa's push provisioning |
|
|
84
85
|
|
|
85
86
|
##### Example:
|
|
86
87
|
```js
|
|
87
88
|
import React from 'react';
|
|
88
89
|
import { UNCardComponent, UNCardData } from 'react-native-unit-components';
|
|
90
|
+
import { NativeModules } from 'react-native';
|
|
91
|
+
const { PushProvisioningModule } = NativeModules;
|
|
89
92
|
|
|
90
93
|
export default function YourComponent() {
|
|
91
94
|
return (
|
|
@@ -93,11 +96,51 @@ export default function YourComponent() {
|
|
|
93
96
|
cardId={'632197'}
|
|
94
97
|
customerToken={''}
|
|
95
98
|
onStatusChanged={(card: UNCardData) => { console.log(card) }}
|
|
99
|
+
pushProvisioningModule={PushProvisioningModule}
|
|
96
100
|
/>
|
|
97
101
|
);
|
|
98
102
|
}
|
|
99
103
|
```
|
|
100
104
|
|
|
105
|
+
##### Add card to wallet capability - Optional
|
|
106
|
+
|
|
107
|
+
[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.
|
|
108
|
+
|
|
109
|
+
Call `UnitSDK.setSignedNonce` with the signedNonce response you obtained from the `launchInitialize` method of the `PushProvisioningModule` in Javascript.
|
|
110
|
+
|
|
111
|
+
Then pass the `PushProvisioningModule` as a prop to [Unit's Card Component](#card-component). This will let the SDK get wallets and start card provisioning for you once the native add to wallet button was pressed.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
###### Input:
|
|
115
|
+
| Name | Type | Required | Description |
|
|
116
|
+
| --------------- | ---------------------------- | --------- | -------------------------------------------- |
|
|
117
|
+
| signedNonce | string | YES | A signed nonce obtained from Visa. |
|
|
118
|
+
|
|
119
|
+
###### Example:
|
|
120
|
+
```js
|
|
121
|
+
import React from "react";
|
|
122
|
+
import { UnitSDK } from "react-native-unit-components";
|
|
123
|
+
import { NativeModules } from 'react-native';
|
|
124
|
+
const { PushProvisioningModule } = NativeModules;
|
|
125
|
+
|
|
126
|
+
export default function YourRootComponent() {
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
const launchInitialize = async () => {
|
|
129
|
+
try {
|
|
130
|
+
// To call the module method to use SDK method initialize
|
|
131
|
+
const response = await PushProvisioningModule.launchInitialize();
|
|
132
|
+
const signedNonce = JSON.parse(response).signedNonce;
|
|
133
|
+
UnitSDK.setSignedNonce(signedNonce);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
// Manage errors
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
launchInitialize();
|
|
140
|
+
}, []);
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
101
144
|
#### Book Payment Component
|
|
102
145
|
|
|
103
146
|
##### UNBookPaymentComponent props:
|
|
@@ -112,6 +155,7 @@ export default function YourComponent() {
|
|
|
112
155
|
| onPaymentCreated | (bookPayment: BookPaymentType) => void | NO | Callback for the created bookPayment. |
|
|
113
156
|
|
|
114
157
|
|
|
158
|
+
|
|
115
159
|
##### Example:
|
|
116
160
|
```js
|
|
117
161
|
import React from 'react';
|
|
@@ -155,3 +199,28 @@ export default function YourComponent() {
|
|
|
155
199
|
);
|
|
156
200
|
}
|
|
157
201
|
```
|
|
202
|
+
|
|
203
|
+
#### Account Component
|
|
204
|
+
|
|
205
|
+
##### UNAccountComponent props:
|
|
206
|
+
| Name | Type | Required | Description |
|
|
207
|
+
| --------------------- | -------------------------------------- | --------- | ---------------------------------------------- |
|
|
208
|
+
| customerToken | string | YES | A Unit Customer token. |
|
|
209
|
+
| accountId | string | No | Unit account id. The account to show, when not provided, one of the customer's accounts will be shown. |
|
|
210
|
+
| theme | string | No | A URL that specifies the UI configuration. |
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
##### Example:
|
|
214
|
+
```js
|
|
215
|
+
import React from 'react';
|
|
216
|
+
import { UNAccountComponent } from 'react-native-unit-components';
|
|
217
|
+
|
|
218
|
+
export default function YourComponent() {
|
|
219
|
+
return (
|
|
220
|
+
<UNAccountComponent
|
|
221
|
+
customerToken={''}
|
|
222
|
+
accountId={'1105561'}
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
```
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
2
|
package="com.unitreactnativecomponents">
|
|
3
|
-
|
|
3
|
+
<application>
|
|
4
|
+
<provider
|
|
5
|
+
android:name="androidx.core.content.FileProvider"
|
|
6
|
+
android:authorities="${applicationId}.provider"
|
|
7
|
+
android:exported="false"
|
|
8
|
+
android:grantUriPermissions="true">
|
|
9
|
+
<meta-data
|
|
10
|
+
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
11
|
+
android:resource="@xml/file_paths">
|
|
12
|
+
</meta-data>
|
|
13
|
+
</provider>
|
|
14
|
+
</application>
|
|
4
15
|
</manifest>
|
package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt
CHANGED
|
@@ -3,11 +3,12 @@ import com.facebook.react.ReactPackage
|
|
|
3
3
|
import com.facebook.react.bridge.NativeModule
|
|
4
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
5
|
import com.facebook.react.uimanager.ViewManager
|
|
6
|
+
import com.unitreactnativecomponents.sharepdf.UNShareFile
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class UnitReactNativeComponentsPackage : ReactPackage {
|
|
9
10
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
-
return
|
|
11
|
+
return listOf(UNShareFile(reactContext))
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package com.unitreactnativecomponents.sharepdf
|
|
2
|
+
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import android.net.Uri
|
|
5
|
+
import android.util.Base64
|
|
6
|
+
import androidx.core.content.FileProvider
|
|
7
|
+
import com.facebook.react.bridge.Promise
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod
|
|
11
|
+
import java.io.File
|
|
12
|
+
import java.io.FileOutputStream
|
|
13
|
+
import java.io.IOException
|
|
14
|
+
|
|
15
|
+
class UNShareFile(var reactContext: ReactApplicationContext) :
|
|
16
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
17
|
+
@ReactMethod
|
|
18
|
+
fun share(base64pdf: String, filename: String, promise: Promise) {
|
|
19
|
+
try {
|
|
20
|
+
cleanSharedFiles()
|
|
21
|
+
val pdfFile = writeFile(base64pdf, filename)
|
|
22
|
+
shareFile(pdfFile)
|
|
23
|
+
promise.resolve(true)
|
|
24
|
+
} catch (e: IOException) {
|
|
25
|
+
promise.reject(e)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private fun cleanSharedFiles() {
|
|
30
|
+
val directoryPath = directoryPath
|
|
31
|
+
if (directoryPath.isDirectory) {
|
|
32
|
+
for (file in directoryPath.list()) {
|
|
33
|
+
File(directoryPath, file).delete()
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Throws(IOException::class)
|
|
39
|
+
private fun writeFile(base64pdf: String, filename: String): File {
|
|
40
|
+
val directoryPath = directoryPath
|
|
41
|
+
directoryPath.mkdir()
|
|
42
|
+
val newFilePath = File(directoryPath.path, filename)
|
|
43
|
+
val pdfAsBytes = Base64.decode(base64pdf, Base64.DEFAULT)
|
|
44
|
+
FileOutputStream(newFilePath, false).use { os ->
|
|
45
|
+
os.write(pdfAsBytes)
|
|
46
|
+
os.flush()
|
|
47
|
+
}
|
|
48
|
+
return newFilePath
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private fun shareFile(file: File) {
|
|
52
|
+
val outputFileUri: Uri =
|
|
53
|
+
FileProvider.getUriForFile(reactContext, reactContext.packageName + ".provider", file)
|
|
54
|
+
val intentShareFile = Intent(Intent.ACTION_SEND)
|
|
55
|
+
intentShareFile.type = TYPE_PDF
|
|
56
|
+
intentShareFile.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
57
|
+
intentShareFile.putExtra(Intent.EXTRA_STREAM, outputFileUri)
|
|
58
|
+
intentShareFile.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
59
|
+
val currentActivity = currentActivity
|
|
60
|
+
currentActivity!!.startActivity(Intent.createChooser(intentShareFile, ""))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override fun getName(): String {
|
|
64
|
+
return REACT_CLASS
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private val directoryPath: File
|
|
68
|
+
private get() = File(reactContext.currentActivity!!.filesDir, PDF_CACHE_DIR)
|
|
69
|
+
|
|
70
|
+
companion object {
|
|
71
|
+
private const val REACT_CLASS = "RNShareFile"
|
|
72
|
+
private const val TYPE_PDF: String = "application/pdf"
|
|
73
|
+
private const val PDF_CACHE_DIR = "pdf_documents_for_sharing"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
android:clickable="true"
|
|
4
4
|
android:focusable="true"
|
|
5
5
|
android:layout_width="match_parent"
|
|
6
|
-
android:layout_height="
|
|
6
|
+
android:layout_height="match_parent"
|
|
7
7
|
android:background="@drawable/un_black_googlepay_button_no_shadow_background"
|
|
8
8
|
android:padding="2sp"
|
|
9
9
|
android:contentDescription="@string/add_to_googlepay_button_content_description">
|
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
android:duplicateParentState="true"
|
|
30
30
|
android:scaleType="fitXY"
|
|
31
31
|
android:src="@drawable/un_black_googlepay_button_overlay" />
|
|
32
|
-
</RelativeLayout>
|
|
32
|
+
</RelativeLayout>
|
|
@@ -8,36 +8,24 @@
|
|
|
8
8
|
android:id="@+id/google_view_push_provisioning_layout"
|
|
9
9
|
android:layout_width="match_parent"
|
|
10
10
|
android:layout_height="match_parent"
|
|
11
|
-
android:layout_margin="10dp"
|
|
12
|
-
tools:layout_editor_absoluteX="149dp"
|
|
13
|
-
tools:layout_editor_absoluteY="-120dp"
|
|
14
11
|
>
|
|
15
12
|
|
|
16
13
|
<include
|
|
17
14
|
android:id="@+id/white_add_to_googlepay_button_no_shadow"
|
|
18
15
|
layout="@layout/un_white_add_to_googlepay_button_no_shadow"
|
|
19
|
-
android:layout_width="200dp"
|
|
20
|
-
android:layout_height="52dp"
|
|
21
|
-
android:layout_centerHorizontal="true"
|
|
22
16
|
android:visibility="invisible"
|
|
23
17
|
/>
|
|
24
18
|
|
|
25
19
|
<include
|
|
26
20
|
android:id="@+id/black_add_to_googlepay_button"
|
|
27
21
|
layout="@layout/un_black_add_to_googlepay_button"
|
|
28
|
-
android:layout_width="200dp"
|
|
29
|
-
android:layout_height="52dp"
|
|
30
|
-
android:layout_centerHorizontal="true"
|
|
31
22
|
android:visibility="invisible"
|
|
32
|
-
|
|
23
|
+
/>
|
|
33
24
|
|
|
34
25
|
|
|
35
26
|
<include
|
|
36
27
|
android:id="@+id/white_add_to_googlepay_button"
|
|
37
28
|
layout="@layout/un_white_add_to_googlepay_button"
|
|
38
|
-
android:layout_width="200dp"
|
|
39
|
-
android:layout_height="52dp"
|
|
40
|
-
android:layout_centerHorizontal="true"
|
|
41
29
|
android:visibility="invisible" />
|
|
42
30
|
|
|
43
31
|
</RelativeLayout>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
android:clickable="true"
|
|
4
4
|
android:focusable="true"
|
|
5
5
|
android:layout_width="match_parent"
|
|
6
|
-
android:layout_height="
|
|
6
|
+
android:layout_height="match_parent"
|
|
7
7
|
android:background="@drawable/un_googlepay_button_background"
|
|
8
8
|
android:padding="4sp"
|
|
9
9
|
android:contentDescription="@string/add_to_googlepay_button_content_description">
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
android:clickable="true"
|
|
4
4
|
android:focusable="true"
|
|
5
5
|
android:layout_width="match_parent"
|
|
6
|
-
android:layout_height="
|
|
6
|
+
android:layout_height="match_parent"
|
|
7
7
|
android:background="@drawable/un_googlepay_button_no_shadow_background"
|
|
8
8
|
android:padding="2sp"
|
|
9
9
|
android:contentDescription="@string/add_to_googlepay_button_content_description">
|
|
@@ -38,8 +38,12 @@ class UnitAddToWalletButtonView : UIView {
|
|
|
38
38
|
|
|
39
39
|
func center(addPassButton: PKAddPassButton) {
|
|
40
40
|
addPassButton.translatesAutoresizingMaskIntoConstraints = false
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
NSLayoutConstraint.activate([
|
|
42
|
+
addPassButton.leadingAnchor.constraint(equalTo: self.leadingAnchor),
|
|
43
|
+
addPassButton.trailingAnchor.constraint(equalTo: self.trailingAnchor),
|
|
44
|
+
addPassButton.topAnchor.constraint(equalTo: self.topAnchor),
|
|
45
|
+
addPassButton.bottomAnchor.constraint(equalTo: self.bottomAnchor)
|
|
46
|
+
])
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UNAccountComponent = exports.AccountAction = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _pageMessage = require("../..//messages/webMessages/pageMessage");
|
|
13
|
+
|
|
14
|
+
var _unitMessages = require("../../messages/webMessages/unitMessages");
|
|
15
|
+
|
|
16
|
+
var _EventBus = _interopRequireDefault(require("../../helpers/EventBus"));
|
|
17
|
+
|
|
18
|
+
var _WebComponent = require("../../webComponent/WebComponent");
|
|
19
|
+
|
|
20
|
+
var _listenerToBus = require("../../hooks/listenerToBus");
|
|
21
|
+
|
|
22
|
+
var _UNAccountComponent = require("./UNAccountComponent.utils");
|
|
23
|
+
|
|
24
|
+
var _bodyHtml = require("../../scripts/html/bodyHtml");
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
let AccountAction;
|
|
33
|
+
exports.AccountAction = AccountAction;
|
|
34
|
+
|
|
35
|
+
(function (AccountAction) {
|
|
36
|
+
AccountAction["List"] = "account-list";
|
|
37
|
+
AccountAction["Menu"] = "account-menu";
|
|
38
|
+
})(AccountAction || (exports.AccountAction = AccountAction = {}));
|
|
39
|
+
|
|
40
|
+
const UNAccountComponent = props => {
|
|
41
|
+
const [height, setHeight] = (0, _react.useState)(0);
|
|
42
|
+
|
|
43
|
+
const windowWidth = _reactNative.Dimensions.get('window').width;
|
|
44
|
+
|
|
45
|
+
const [requestRefreshEvent, setRequestRefreshEvent] = (0, _react.useState)(null);
|
|
46
|
+
const webRef = (0, _react.useRef)(null);
|
|
47
|
+
|
|
48
|
+
const requestRefresh = data => {
|
|
49
|
+
setRequestRefreshEvent(data);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
(0, _listenerToBus.useListenerToBus)([{
|
|
53
|
+
busEventKey: _unitMessages.UnitMessage.UNIT_REQUEST_REFRESH,
|
|
54
|
+
action: requestRefresh
|
|
55
|
+
}]);
|
|
56
|
+
(0, _react.useEffect)(() => {
|
|
57
|
+
(0, _UNAccountComponent.injectRefreshEventIfNeeded)(webRef.current, requestRefreshEvent);
|
|
58
|
+
}, [requestRefreshEvent]);
|
|
59
|
+
|
|
60
|
+
const handleMessage = message => {
|
|
61
|
+
switch (message.type) {
|
|
62
|
+
case _unitMessages.UnitMessage.UNIT_ON_LOAD:
|
|
63
|
+
props.onLoad && props.onLoad(message.details);
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case _unitMessages.UnitMessage.UNIT_REQUEST_RENDERING:
|
|
67
|
+
{
|
|
68
|
+
const event = {
|
|
69
|
+
componentName: _WebComponent.WebComponentType.account,
|
|
70
|
+
componentResourceId: props.accountId,
|
|
71
|
+
requestRenderingEvent: message.details
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
_EventBus.default.Instance.event(_unitMessages.UnitMessage.UNIT_REQUEST_RENDERING, event);
|
|
75
|
+
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
case _pageMessage.PageMessage.PAGE_HEIGHT:
|
|
80
|
+
setHeight(message.details.height);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
86
|
+
style: {
|
|
87
|
+
height
|
|
88
|
+
}
|
|
89
|
+
}, /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
|
|
90
|
+
ref: webRef,
|
|
91
|
+
type: _WebComponent.WebComponentType.account,
|
|
92
|
+
presentationMode: _bodyHtml.PresentationMode.Default,
|
|
93
|
+
params: (0, _UNAccountComponent.getAccountParams)(props),
|
|
94
|
+
script: (0, _UNAccountComponent.getAccountScript)(),
|
|
95
|
+
theme: props.theme,
|
|
96
|
+
onMessage: message => handleMessage(message),
|
|
97
|
+
width: windowWidth,
|
|
98
|
+
isScrollable: false
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.UNAccountComponent = UNAccountComponent;
|
|
103
|
+
//# sourceMappingURL=UNAccountComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AccountAction","UNAccountComponent","props","height","setHeight","useState","windowWidth","Dimensions","get","width","requestRefreshEvent","setRequestRefreshEvent","webRef","useRef","requestRefresh","data","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","action","useEffect","injectRefreshEventIfNeeded","current","handleMessage","message","type","UNIT_ON_LOAD","onLoad","details","UNIT_REQUEST_RENDERING","event","componentName","WebComponentType","account","componentResourceId","accountId","requestRenderingEvent","EventBus","Instance","PageMessage","PAGE_HEIGHT","PresentationMode","Default","getAccountParams","getAccountScript","theme"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectRefreshEventIfNeeded } from './UNAccountComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';\nimport type { ResponseUnitOnLoadEvent } from '../../sharedTypes';\n\nexport interface UNAccountComponentProps {\n accountId?: string;\n customerToken: string;\n theme?: string;\n onLoad?: (response: ResponseUnitOnLoadEvent) => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = (props: UNAccountComponentProps) => {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n useListenerToBus([\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as ResponseUnitOnLoadEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const event: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;IAWYA,a;;;WAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a;;AAKL,MAAMC,kBAAkB,GAAIC,KAAD,IAAoC;EACpE,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAS,CAAT,CAA5B;;EACA,MAAMC,WAAW,GAAGC,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBC,KAA7C;;EAEA,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgD,IAAAN,eAAA,EAAqC,IAArC,CAAtD;EAEA,MAAMO,MAAM,GAAG,IAAAC,aAAA,EAAgB,IAAhB,CAAf;;EAEA,MAAMC,cAAc,GAAIC,IAAD,IAA+B;IACpDJ,sBAAsB,CAACI,IAAD,CAAtB;EACD,CAFD;;EAIA,IAAAC,+BAAA,EAAiB,CACf;IAAEC,WAAW,EAAEC,yBAAA,CAAYC,oBAA3B;IAAiDC,MAAM,EAAEN;EAAzD,CADe,CAAjB;EAIA,IAAAO,gBAAA,EAAU,MAAM;IACd,IAAAC,8CAAA,EAA2BV,MAAM,CAACW,OAAlC,EAA2Cb,mBAA3C;EACD,CAFD,EAEG,CAACA,mBAAD,CAFH;;EAIA,MAAMc,aAAa,GAAIC,OAAD,IAA6B;IACjD,QAAQA,OAAO,CAACC,IAAhB;MACE,KAAKR,yBAAA,CAAYS,YAAjB;QACEzB,KAAK,CAAC0B,MAAN,IAAgB1B,KAAK,CAAC0B,MAAN,CAAaH,OAAO,CAACI,OAArB,CAAhB;QACA;;MACF,KAAKX,yBAAA,CAAYY,sBAAjB;QAAyC;UACvC,MAAMC,KAA0B,GAAG;YACjCC,aAAa,EAAEC,8BAAA,CAAiBC,OADC;YAEjCC,mBAAmB,EAAEjC,KAAK,CAACkC,SAFM;YAGjCC,qBAAqB,EAAEZ,OAAO,CAACI;UAHE,CAAnC;;UAKAS,iBAAA,CAASC,QAAT,CAAkBR,KAAlB,CAAwBb,yBAAA,CAAYY,sBAApC,EAA4DC,KAA5D;;UACA;QACD;;MACD,KAAKS,wBAAA,CAAYC,WAAjB;QACErC,SAAS,CAAEqB,OAAO,CAACI,OAAT,CAAiC1B,MAAlC,CAAT;QACA;IAfJ;EAiBD,CAlBD;;EAoBA,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAEA;IAAF;EAAb,gBACE,6BAAC,0BAAD;IACE,GAAG,EAAES,MADP;IAEE,IAAI,EAAEqB,8BAAA,CAAiBC,OAFzB;IAGE,gBAAgB,EAAEQ,0BAAA,CAAiBC,OAHrC;IAIE,MAAM,EAAE,IAAAC,oCAAA,EAAiB1C,KAAjB,CAJV;IAKE,MAAM,EAAE,IAAA2C,oCAAA,GALV;IAME,KAAK,EAAE3C,KAAK,CAAC4C,KANf;IAOE,SAAS,EAAErB,OAAO,IAAID,aAAa,CAACC,OAAD,CAPrC;IAQE,KAAK,EAAEnB,WART;IASE,YAAY,EAAE;EAThB,EADF,CADF;AAeD,CAvDM"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.injectRefreshEventIfNeeded = exports.getAccountScript = exports.getAccountParams = exports.getAccountActionType = void 0;
|
|
7
|
+
|
|
8
|
+
var _UNAccountComponent = require("./UNAccountComponent");
|
|
9
|
+
|
|
10
|
+
var _unitMessages = require("../../messages/webMessages/unitMessages");
|
|
11
|
+
|
|
12
|
+
var _WebComponent = require("../../webComponent/WebComponent");
|
|
13
|
+
|
|
14
|
+
const getAccountParams = props => {
|
|
15
|
+
return `
|
|
16
|
+
account-id="${props.accountId}"
|
|
17
|
+
customer-token="${props.customerToken}"
|
|
18
|
+
`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.getAccountParams = getAccountParams;
|
|
22
|
+
|
|
23
|
+
const getAccountScript = () => {
|
|
24
|
+
return `
|
|
25
|
+
const dispatchRefreshEvent = (details) => {
|
|
26
|
+
const event = new CustomEvent("${_unitMessages.UnitMessage.UNIT_REQUEST_REFRESH}",{ detail: JSON.parse(details) })
|
|
27
|
+
window.dispatchEvent(event)
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.getAccountScript = getAccountScript;
|
|
33
|
+
|
|
34
|
+
const injectRefreshEventIfNeeded = (currentWeb, requestRefreshEvent) => {
|
|
35
|
+
if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(_WebComponent.WebComponentType.account.valueOf())) {
|
|
36
|
+
currentWeb === null || currentWeb === void 0 ? void 0 : currentWeb.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.injectRefreshEventIfNeeded = injectRefreshEventIfNeeded;
|
|
41
|
+
|
|
42
|
+
const getAccountActionType = requestRendering => {
|
|
43
|
+
return requestRendering.data.nativeComponent.includes(_UNAccountComponent.AccountAction.List) ? _UNAccountComponent.AccountAction.List : _UNAccountComponent.AccountAction.Menu;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.getAccountActionType = getAccountActionType;
|
|
47
|
+
//# sourceMappingURL=UNAccountComponent.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getAccountParams","props","accountId","customerToken","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;;AACA;;AAEA;;AAEO,MAAMA,gBAAgB,GAAIC,KAAD,IAAoC;EAClE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,GAHE;AAID,CALM;;;;AAOA,MAAMC,gBAAgB,GAAG,MAAM;EACpC,OAAQ;AACV;AACA,qCAAqCC,yBAAA,CAAYC,oBAAqB;AACtE;AACA;AACA,GALE;AAMD,CAPM;;;;AASA,MAAMC,0BAA0B,GAAG,CAACC,UAAD,EAA6BC,mBAA7B,KAAiF;EACzH,IAAIA,mBAAmB,IAAIA,mBAAmB,CAACC,YAApB,CAAiCC,QAAjC,CAA0CC,8BAAA,CAAiBC,OAAjB,CAAyBC,OAAzB,EAA1C,CAA3B,EAA0G;IACxGN,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEO,gBAAZ,CAA8B,yBAAwBC,IAAI,CAACC,SAAL,CAAeR,mBAAf,CAAoC,IAA1F;EACD;AACF,CAJM;;;;AAMA,MAAMS,oBAAoB,GAAIC,gBAAD,IAA6C;EAC/E,OAAOA,gBAAgB,CAACC,IAAjB,CAAsBC,eAAtB,CAAsCV,QAAtC,CAA+CW,iCAAA,CAAcC,IAA7D,IAAqED,iCAAA,CAAcC,IAAnF,GAA0FD,iCAAA,CAAcE,IAA/G;AACD,CAFM"}
|
|
@@ -5,7 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UNActivityComponent = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _unitMessages = require("../../messages/webMessages/unitMessages");
|
|
13
|
+
|
|
14
|
+
var _listenerToBus = require("../../hooks/listenerToBus");
|
|
15
|
+
|
|
16
|
+
var _pageMessage = require("../../messages/webMessages/pageMessage");
|
|
9
17
|
|
|
10
18
|
var _bodyHtml = require("../../scripts/html/bodyHtml");
|
|
11
19
|
|
|
@@ -13,15 +21,62 @@ var _WebComponent = require("../../webComponent/WebComponent");
|
|
|
13
21
|
|
|
14
22
|
var _UNActivityComponent = require("./UNActivityComponent.utils");
|
|
15
23
|
|
|
16
|
-
function
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
const DEFAULT_HEIGHT = _reactNative.Dimensions.get('window').height * 0.5;
|
|
17
29
|
|
|
18
30
|
const UNActivityComponent = props => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
31
|
+
const webRef = (0, _react.useRef)(null);
|
|
32
|
+
const [defaultHeight, setDefaultHeight] = (0, _react.useState)();
|
|
33
|
+
|
|
34
|
+
const requestRefresh = data => {
|
|
35
|
+
(0, _UNActivityComponent.injectRefreshEventIfNeeded)(webRef.current, data);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
(0, _listenerToBus.useListenerToBus)([{
|
|
39
|
+
busEventKey: _unitMessages.UnitMessage.UNIT_REQUEST_REFRESH,
|
|
40
|
+
action: requestRefresh
|
|
41
|
+
}]);
|
|
42
|
+
|
|
43
|
+
const handleWebViewMessage = message => {
|
|
44
|
+
switch (message.type) {
|
|
45
|
+
case _unitMessages.UnitMessage.UNIT_ON_LOAD:
|
|
46
|
+
props.onLoad && props.onLoad(message.details);
|
|
47
|
+
break;
|
|
48
|
+
|
|
49
|
+
case _pageMessage.PageMessage.PAGE_HEIGHT:
|
|
50
|
+
{
|
|
51
|
+
const currentHeight = message.details.height;
|
|
52
|
+
currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const renderActivityWebView = () => {
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
|
|
60
|
+
ref: webRef,
|
|
61
|
+
type: _WebComponent.WebComponentType.activity,
|
|
62
|
+
presentationMode: _bodyHtml.PresentationMode.Inherit,
|
|
63
|
+
params: (0, _UNActivityComponent.getActivityParams)(props),
|
|
64
|
+
onMessage: message => handleWebViewMessage(message),
|
|
65
|
+
nestedScrollEnabled: true,
|
|
66
|
+
theme: props.theme,
|
|
67
|
+
script: (0, _UNActivityComponent.getActivityScript)()
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (!defaultHeight) {
|
|
72
|
+
return renderActivityWebView();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
76
|
+
style: {
|
|
77
|
+
height: defaultHeight
|
|
78
|
+
}
|
|
79
|
+
}, renderActivityWebView());
|
|
25
80
|
};
|
|
26
81
|
|
|
27
82
|
exports.UNActivityComponent = UNActivityComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UNActivityComponent","props","WebComponentType","activity","PresentationMode","Inherit","getActivityParams"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n return (\n
|
|
1
|
+
{"version":3,"names":["DEFAULT_HEIGHT","Dimensions","get","height","UNActivityComponent","props","webRef","useRef","defaultHeight","setDefaultHeight","useState","requestRefresh","data","injectRefreshEventIfNeeded","current","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","action","handleWebViewMessage","message","type","UNIT_ON_LOAD","onLoad","details","PageMessage","PAGE_HEIGHT","currentHeight","renderActivityWebView","WebComponentType","activity","PresentationMode","Inherit","getActivityParams","theme","getActivityScript"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport { RequestRefreshEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { ResponseUnitOnLoadEvent } from '../../sharedTypes';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams, getActivityScript, injectRefreshEventIfNeeded } from './UNActivityComponent.utils';\nimport type WebView from 'react-native-webview';\n\nconst DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n onLoad?: (response: ResponseUnitOnLoadEvent) => void\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n const webRef = useRef<WebView>(null);\n const [defaultHeight, setDefaultHeight] = useState<number>();\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n injectRefreshEventIfNeeded(webRef.current, data);\n };\n\n useListenerToBus([\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n const handleWebViewMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n props.onLoad && props.onLoad(message.details as ResponseUnitOnLoadEvent);\n break;\n case PageMessage.PAGE_HEIGHT: {\n const currentHeight = (message.details as HeightEvent).height;\n currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);\n break;\n }\n }\n };\n\n const renderActivityWebView = () => {\n return (\n <WebComponent\n ref={webRef}\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n nestedScrollEnabled={true}\n theme={props.theme}\n script={getActivityScript()}\n />\n );\n };\n\n if (!defaultHeight) {\n return renderActivityWebView();\n }\n\n return (\n <View style={{ height: defaultHeight }}>\n {renderActivityWebView()}\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;AAGA,MAAMA,cAAc,GAAGC,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBC,MAAzB,GAAkC,GAAzD;;AAQO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAMC,MAAM,GAAG,IAAAC,aAAA,EAAgB,IAAhB,CAAf;EACA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAC,eAAA,GAA1C;;EAEA,MAAMC,cAAc,GAAIC,IAAD,IAA+B;IACpD,IAAAC,+CAAA,EAA2BP,MAAM,CAACQ,OAAlC,EAA2CF,IAA3C;EACD,CAFD;;EAIA,IAAAG,+BAAA,EAAiB,CACf;IAAEC,WAAW,EAAEC,yBAAA,CAAYC,oBAA3B;IAAiDC,MAAM,EAAER;EAAzD,CADe,CAAjB;;EAIA,MAAMS,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,QAAQA,OAAO,CAACC,IAAhB;MACE,KAAKL,yBAAA,CAAYM,YAAjB;QACElB,KAAK,CAACmB,MAAN,IAAgBnB,KAAK,CAACmB,MAAN,CAAaH,OAAO,CAACI,OAArB,CAAhB;QACA;;MACF,KAAKC,wBAAA,CAAYC,WAAjB;QAA8B;UAC5B,MAAMC,aAAa,GAAIP,OAAO,CAACI,OAAT,CAAiCtB,MAAvD;UACAyB,aAAa,KAAK,CAAlB,IAAuBnB,gBAAgB,CAACT,cAAD,CAAvC;UACA;QACD;IARH;EAUD,CAXD;;EAaA,MAAM6B,qBAAqB,GAAG,MAAM;IAClC,oBACE,6BAAC,0BAAD;MACE,GAAG,EAAEvB,MADP;MAEE,IAAI,EAAEwB,8BAAA,CAAiBC,QAFzB;MAGE,gBAAgB,EAAEC,0BAAA,CAAiBC,OAHrC;MAIE,MAAM,EAAE,IAAAC,sCAAA,EAAkB7B,KAAlB,CAJV;MAKE,SAAS,EAAGgB,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;MAME,mBAAmB,EAAE,IANvB;MAOE,KAAK,EAAEhB,KAAK,CAAC8B,KAPf;MAQE,MAAM,EAAE,IAAAC,sCAAA;IARV,EADF;EAYD,CAbD;;EAeA,IAAI,CAAC5B,aAAL,EAAoB;IAClB,OAAOqB,qBAAqB,EAA5B;EACD;;EAED,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAE1B,MAAM,EAAEK;IAAV;EAAb,GACGqB,qBAAqB,EADxB,CADF;AAKD,CAjDM"}
|
|
@@ -3,18 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getActivityParams = void 0;
|
|
6
|
+
exports.injectRefreshEventIfNeeded = exports.getActivityScript = exports.getActivityParams = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _WebComponent = require("./../../webComponent/WebComponent");
|
|
9
|
+
|
|
10
|
+
var _bodyScript = require("./../../scripts/html/bodyScript");
|
|
9
11
|
|
|
10
12
|
const getActivityParams = props => {
|
|
11
13
|
return `
|
|
12
14
|
account-id="${props.accountId}"
|
|
13
15
|
customer-token="${props.customerToken}"
|
|
14
|
-
theme="${props.theme ?? _UnitSdkManager.UnitSDK.getTheme()}"
|
|
15
16
|
style="height: 100%"
|
|
16
17
|
`;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
exports.getActivityParams = getActivityParams;
|
|
21
|
+
|
|
22
|
+
const getActivityScript = () => {
|
|
23
|
+
return _bodyScript.DISPATCH_REQUEST_REFRESH;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.getActivityScript = getActivityScript;
|
|
27
|
+
|
|
28
|
+
const injectRefreshEventIfNeeded = (currentWeb, requestRefreshEvent) => {
|
|
29
|
+
if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(_WebComponent.WebComponentType.activity.valueOf())) {
|
|
30
|
+
currentWeb === null || currentWeb === void 0 ? void 0 : currentWeb.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.injectRefreshEventIfNeeded = injectRefreshEventIfNeeded;
|
|
20
35
|
//# sourceMappingURL=UNActivityComponent.utils.js.map
|