react-native-unit-components 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +157 -2
- package/lib/commonjs/assets/images/close.png +0 -0
- package/lib/commonjs/assets/images/index.js +16 -0
- package/lib/commonjs/assets/images/index.js.map +1 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +28 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +20 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +39 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +40 -0
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +9 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -0
- package/lib/commonjs/components/{BottomSheet/BottomSheetComponent.js → UNBottomSheetComponent/UNBottomSheetComponent.js} +84 -65
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +23 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +49 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -0
- package/lib/commonjs/components/{Card/CardComponent.js → UNCardComponent/UNCardComponent.js} +42 -46
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +42 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -0
- package/lib/commonjs/components/index.js +34 -8
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/custom.d.js +2 -0
- package/lib/commonjs/custom.d.js.map +1 -0
- package/lib/commonjs/helpers/{BottomSheet.js → BottomSheet/BottomSheet.js} +36 -82
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -0
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js +82 -0
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.styles.js.map +1 -0
- package/lib/commonjs/helpers/EventBus.js +5 -13
- package/lib/commonjs/helpers/EventBus.js.map +1 -1
- package/lib/commonjs/hooks/listenerToBus.js +31 -0
- package/lib/commonjs/hooks/listenerToBus.js.map +1 -0
- package/lib/commonjs/hooks/useAppStateListener.js +34 -0
- package/lib/commonjs/hooks/useAppStateListener.js.map +1 -0
- package/lib/commonjs/index.js +33 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/index.js +13 -0
- package/lib/commonjs/messages/nativeMessages/index.js.map +1 -0
- package/lib/commonjs/messages/webMessages/bookPaymentMessage.js +13 -0
- package/lib/commonjs/messages/webMessages/bookPaymentMessage.js.map +1 -0
- package/lib/commonjs/{webComponent → messages}/webMessages/cardMessage.js +1 -1
- package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/index.js +6 -0
- package/lib/commonjs/messages/webMessages/index.js.map +1 -0
- package/lib/commonjs/{webComponent → messages}/webMessages/pageMessage.js +0 -0
- package/lib/commonjs/{webComponent → messages}/webMessages/pageMessage.js.map +0 -0
- package/lib/commonjs/{webComponent → messages}/webMessages/unitMessages.js +0 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -0
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js +2 -2
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js +52 -0
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyScript.js +78 -0
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -0
- package/lib/commonjs/sharedTypes/bookPayment.types.js +6 -0
- package/lib/commonjs/sharedTypes/bookPayment.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/card.types.js +6 -0
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/index.js +32 -0
- package/lib/commonjs/sharedTypes/index.js.map +1 -0
- package/lib/commonjs/sharedTypes/types.js +2 -0
- package/lib/commonjs/sharedTypes/types.js.map +1 -0
- package/lib/commonjs/styles/variables.js +17 -0
- package/lib/commonjs/styles/variables.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js +54 -0
- package/lib/commonjs/unitSdkManager/UnitSdk.api.js.map +1 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +51 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -0
- package/lib/commonjs/webComponent/WebComponent.js +35 -15
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/html.js +22 -45
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/assets/images/close.png +0 -0
- package/lib/module/assets/images/index.js +2 -0
- package/lib/module/assets/images/index.js.map +1 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +13 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +10 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +23 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +26 -0
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js +2 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +131 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js +13 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.js.map +1 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +29 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js +65 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +24 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -0
- package/lib/module/components/index.js +4 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/custom.d.js +2 -0
- package/lib/module/custom.d.js.map +1 -0
- package/lib/module/helpers/{BottomSheet.js → BottomSheet/BottomSheet.js} +34 -81
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -0
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js +70 -0
- package/lib/module/helpers/BottomSheet/BottomSheet.styles.js.map +1 -0
- package/lib/module/helpers/EventBus.js +4 -11
- package/lib/module/helpers/EventBus.js.map +1 -1
- package/lib/module/hooks/listenerToBus.js +18 -0
- package/lib/module/hooks/listenerToBus.js.map +1 -0
- package/lib/module/hooks/useAppStateListener.js +23 -0
- package/lib/module/hooks/useAppStateListener.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/messages/nativeMessages/index.js +6 -0
- package/lib/module/messages/nativeMessages/index.js.map +1 -0
- package/lib/module/messages/webMessages/bookPaymentMessage.js +6 -0
- package/lib/module/messages/webMessages/bookPaymentMessage.js.map +1 -0
- package/lib/module/messages/webMessages/cardMessage.js +6 -0
- package/lib/module/messages/webMessages/cardMessage.js.map +1 -0
- package/lib/module/messages/webMessages/index.js +2 -0
- package/lib/module/messages/webMessages/index.js.map +1 -0
- package/lib/module/{webComponent → messages}/webMessages/pageMessage.js +0 -0
- package/lib/module/{webComponent → messages}/webMessages/pageMessage.js.map +0 -0
- package/lib/module/{webComponent → messages}/webMessages/unitMessages.js +0 -0
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -0
- package/lib/module/nativeComponenet/NativeComponentExample.js +2 -2
- package/lib/module/nativeComponenet/NativeComponentExample.js.map +1 -1
- package/lib/module/scripts/html/bodyHtml.js +42 -0
- package/lib/module/scripts/html/bodyHtml.js.map +1 -0
- package/lib/module/scripts/html/bodyScript.js +64 -0
- package/lib/module/scripts/html/bodyScript.js.map +1 -0
- package/lib/module/sharedTypes/bookPayment.types.js +2 -0
- package/lib/module/sharedTypes/bookPayment.types.js.map +1 -0
- package/lib/module/sharedTypes/card.types.js +2 -0
- package/lib/module/sharedTypes/card.types.js.map +1 -0
- package/lib/module/sharedTypes/index.js +3 -0
- package/lib/module/sharedTypes/index.js.map +1 -0
- package/lib/module/sharedTypes/types.js +2 -0
- package/lib/module/sharedTypes/types.js.map +1 -0
- package/lib/module/styles/variables.js +10 -0
- package/lib/module/styles/variables.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdk.api.js +37 -0
- package/lib/module/unitSdkManager/UnitSdk.api.js.map +1 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js +38 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -0
- package/lib/module/webComponent/WebComponent.js +34 -14
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/html.js +18 -44
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/assets/images/index.d.ts +1 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +6 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.utils.d.ts +2 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +11 -0
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.d.ts +3 -0
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.d.ts +1 -0
- package/lib/typescript/components/{BottomSheet/BottomSheetComponent.d.ts → UNBottomSheetComponent/UNBottomSheetComponent.d.ts} +0 -0
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.d.ts +9 -0
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts +5 -0
- package/lib/typescript/components/{Card/CardComponent.d.ts → UNCardComponent/UNCardComponent.d.ts} +3 -1
- package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +6 -0
- package/lib/typescript/components/index.d.ts +4 -2
- package/lib/typescript/helpers/{BottomSheet.d.ts → BottomSheet/BottomSheet.d.ts} +1 -0
- package/lib/typescript/helpers/BottomSheet/BottomSheet.styles.d.ts +63 -0
- package/lib/typescript/helpers/EventBus.d.ts +5 -7
- package/lib/typescript/hooks/listenerToBus.d.ts +7 -0
- package/lib/typescript/hooks/useAppStateListener.d.ts +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/messages/nativeMessages/index.d.ts +3 -0
- package/lib/typescript/messages/webMessages/bookPaymentMessage.d.ts +8 -0
- package/lib/typescript/{webComponent → messages}/webMessages/cardMessage.d.ts +3 -2
- package/lib/typescript/messages/webMessages/index.d.ts +11 -0
- package/lib/typescript/{webComponent → messages}/webMessages/pageMessage.d.ts +0 -0
- package/lib/typescript/{webComponent → messages}/webMessages/unitMessages.d.ts +0 -0
- package/lib/typescript/scripts/html/bodyHtml.d.ts +7 -0
- package/lib/typescript/scripts/html/bodyScript.d.ts +11 -0
- package/lib/typescript/sharedTypes/bookPayment.types.d.ts +26 -0
- package/lib/typescript/sharedTypes/card.types.d.ts +56 -0
- package/lib/typescript/sharedTypes/index.d.ts +2 -0
- package/lib/typescript/sharedTypes/types.d.ts +27 -0
- package/lib/typescript/styles/variables.d.ts +9 -0
- package/lib/typescript/unitSdkManager/UnitSdk.api.d.ts +3 -0
- package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +15 -0
- package/lib/typescript/webComponent/WebComponent.d.ts +8 -11
- package/lib/typescript/webComponent/html.d.ts +6 -1
- package/package.json +9 -5
- package/{unit-react-native-components.podspec → react-native-unit-components.podspec} +1 -1
- package/src/assets/images/close.png +0 -0
- package/src/assets/images/index.ts +1 -0
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +21 -0
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +11 -0
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +37 -0
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +29 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.constants.ts +1 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.styles.ts +13 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +136 -0
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +34 -0
- package/src/components/UNCardComponent/UNCardComponent.tsx +73 -0
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +28 -0
- package/src/components/index.ts +4 -2
- package/src/custom.d.ts +5 -0
- package/src/helpers/BottomSheet/BottomSheet.styles.ts +70 -0
- package/src/helpers/{BottomSheet.tsx → BottomSheet/BottomSheet.tsx} +72 -110
- package/src/helpers/EventBus.ts +13 -13
- package/src/hooks/listenerToBus.ts +23 -0
- package/src/hooks/useAppStateListener.ts +25 -0
- package/src/index.tsx +5 -1
- package/src/messages/nativeMessages/index.ts +3 -0
- package/src/messages/webMessages/bookPaymentMessage.ts +12 -0
- package/src/{webComponent → messages}/webMessages/cardMessage.ts +4 -2
- package/src/messages/webMessages/index.ts +21 -0
- package/src/{webComponent → messages}/webMessages/pageMessage.ts +0 -0
- package/src/{webComponent → messages}/webMessages/unitMessages.ts +1 -0
- package/src/nativeComponenet/NativeComponentExample.tsx +2 -2
- package/src/scripts/html/bodyHtml.ts +46 -0
- package/src/scripts/html/bodyScript.ts +67 -0
- package/src/sharedTypes/bookPayment.types.ts +27 -0
- package/src/sharedTypes/card.types.ts +59 -0
- package/src/sharedTypes/index.ts +2 -0
- package/src/sharedTypes/types.ts +35 -0
- package/src/styles/variables.ts +9 -0
- package/src/unitSdkManager/UnitSdk.api.ts +31 -0
- package/src/unitSdkManager/UnitSdkManager.ts +33 -0
- package/src/webComponent/WebComponent.tsx +43 -45
- package/src/webComponent/html.ts +22 -46
- package/lib/commonjs/components/BottomSheet/BottomSheetComponent.js.map +0 -1
- package/lib/commonjs/components/Card/CardComponent.js.map +0 -1
- package/lib/commonjs/helpers/BottomSheet.js.map +0 -1
- package/lib/commonjs/webComponent/webMessages/cardMessage.js.map +0 -1
- package/lib/commonjs/webComponent/webMessages/unitMessages.js.map +0 -1
- package/lib/module/components/BottomSheet/BottomSheetComponent.js +0 -118
- package/lib/module/components/BottomSheet/BottomSheetComponent.js.map +0 -1
- package/lib/module/components/Card/CardComponent.js +0 -75
- package/lib/module/components/Card/CardComponent.js.map +0 -1
- package/lib/module/helpers/BottomSheet.js.map +0 -1
- package/lib/module/webComponent/webMessages/cardMessage.js +0 -6
- package/lib/module/webComponent/webMessages/cardMessage.js.map +0 -1
- package/lib/module/webComponent/webMessages/unitMessages.js.map +0 -1
- package/src/components/BottomSheet/BottomSheetComponent.tsx +0 -113
- package/src/components/Card/CardComponent.tsx +0 -75
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UnitSDK = exports.UNIT_SCRIPT_URL = exports.UNEnvironment = void 0;
|
|
7
|
+
|
|
8
|
+
var _UnitSdk = require("./UnitSdk.api");
|
|
9
|
+
|
|
10
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
|
|
12
|
+
let UNEnvironment;
|
|
13
|
+
exports.UNEnvironment = UNEnvironment;
|
|
14
|
+
|
|
15
|
+
(function (UNEnvironment) {
|
|
16
|
+
UNEnvironment["sandbox"] = "sandbox";
|
|
17
|
+
UNEnvironment["production"] = "production";
|
|
18
|
+
})(UNEnvironment || (exports.UNEnvironment = UNEnvironment = {}));
|
|
19
|
+
|
|
20
|
+
const UNIT_SCRIPT_URL = {
|
|
21
|
+
[UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',
|
|
22
|
+
[UNEnvironment.production]: 'https://ui.unit.co/components.js'
|
|
23
|
+
};
|
|
24
|
+
exports.UNIT_SCRIPT_URL = UNIT_SCRIPT_URL;
|
|
25
|
+
|
|
26
|
+
class UnitSDK {}
|
|
27
|
+
|
|
28
|
+
exports.UnitSDK = UnitSDK;
|
|
29
|
+
|
|
30
|
+
_defineProperty(UnitSDK, "env", void 0);
|
|
31
|
+
|
|
32
|
+
_defineProperty(UnitSDK, "theme", void 0);
|
|
33
|
+
|
|
34
|
+
_defineProperty(UnitSDK, "init", async (env, theme) => {
|
|
35
|
+
try {
|
|
36
|
+
UnitSDK.env = env;
|
|
37
|
+
UnitSDK.theme = theme;
|
|
38
|
+
await (0, _UnitSdk.fetchUnitScript)();
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.log(e);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_defineProperty(UnitSDK, "getEnv", () => {
|
|
45
|
+
return UnitSDK.env;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
_defineProperty(UnitSDK, "getTheme", () => {
|
|
49
|
+
return UnitSDK.theme;
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=UnitSdkManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UNEnvironment","UNIT_SCRIPT_URL","sandbox","production","UnitSDK","env","theme","fetchUnitScript","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import { fetchUnitScript } from './UnitSdk.api';\n\nexport enum UNEnvironment {\n sandbox = 'sandbox',\n production = 'production'\n}\n\nexport const UNIT_SCRIPT_URL = {\n [UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',\n [UNEnvironment.production]: 'https://ui.unit.co/components.js'\n};\nexport class UnitSDK {\n protected static env?: UNEnvironment;\n protected static theme?: string;\n\n public static init = async (env: UNEnvironment, theme: string) => {\n try {\n this.env = env;\n this.theme = theme;\n await fetchUnitScript();\n } catch (e) {\n console.log(e);\n }\n };\n\n public static getEnv = () => {\n return this.env;\n };\n\n public static getTheme = () => {\n return this.theme;\n };\n}\n"],"mappings":";;;;;;;AAAA;;;;IAEYA,a;;;WAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a;;AAKL,MAAMC,eAAe,GAAG;EAC7B,CAACD,aAAa,CAACE,OAAf,GAAyB,oCADI;EAE7B,CAACF,aAAa,CAACG,UAAf,GAA4B;AAFC,CAAxB;;;AAIA,MAAMC,OAAN,CAAc;;;;gBAARA,O;;gBAAAA,O;;gBAAAA,O,UAIU,OAAOC,GAAP,EAA2BC,KAA3B,KAA6C;EAChE,IAAI;IALKF,OAMP,CAAKC,GAAL,GAAWA,GAAX;IANOD,OAOP,CAAKE,KAAL,GAAaA,KAAb;IACA,MAAM,IAAAC,wBAAA,GAAN;EACD,CAJD,CAIE,OAAOC,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;EACD;AACF,C;;gBAZUJ,O,YAcY,MAAM;EAC3B,OAfSA,OAeF,CAAKC,GAAZ;AACD,C;;gBAhBUD,O,cAkBc,MAAM;EAC7B,OAnBSA,OAmBF,CAAKE,KAAZ;AACD,C"}
|
|
@@ -7,15 +7,21 @@ exports.WebComponentType = exports.WebComponent = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
10
|
var _reactNativeWebview = require("react-native-webview");
|
|
13
11
|
|
|
14
|
-
var _EventBus =
|
|
12
|
+
var _EventBus = _interopRequireDefault(require("../helpers/EventBus"));
|
|
13
|
+
|
|
14
|
+
var _html = _interopRequireWildcard(require("./html"));
|
|
15
|
+
|
|
16
|
+
var _unitMessages = require("../messages/webMessages/unitMessages");
|
|
17
|
+
|
|
18
|
+
var _listenerToBus = require("../hooks/listenerToBus");
|
|
15
19
|
|
|
16
|
-
var
|
|
20
|
+
var _bodyHtml = require("../scripts/html/bodyHtml");
|
|
17
21
|
|
|
18
|
-
var
|
|
22
|
+
var _UnitSdk = require("../unitSdkManager/UnitSdk.api");
|
|
23
|
+
|
|
24
|
+
var _nativeMessages = require("../messages/nativeMessages");
|
|
19
25
|
|
|
20
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
27
|
|
|
@@ -28,30 +34,42 @@ exports.WebComponentType = WebComponentType;
|
|
|
28
34
|
|
|
29
35
|
(function (WebComponentType) {
|
|
30
36
|
WebComponentType["card"] = "unit-elements-card";
|
|
37
|
+
WebComponentType["bookPayment"] = "unit-elements-book-payment";
|
|
38
|
+
WebComponentType["activity"] = "unit-elements-activity";
|
|
31
39
|
WebComponentType["slot"] = "unit-elements-sdk-slot";
|
|
32
40
|
})(WebComponentType || (exports.WebComponentType = WebComponentType = {}));
|
|
33
41
|
|
|
34
|
-
const WebComponent = /*#__PURE__*/_react.default.forwardRef((props, webRef)
|
|
42
|
+
const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponent(props, webRef) {
|
|
43
|
+
const [unitScript, setUnitScript] = (0, _react.useState)(_UnitSdk.globalUnitScript);
|
|
35
44
|
const [sourceHtml, setSourceHtml] = (0, _react.useState)(null);
|
|
36
45
|
|
|
37
|
-
const
|
|
46
|
+
const listenerAction = data => {
|
|
47
|
+
setUnitScript(data.unitScript);
|
|
48
|
+
};
|
|
38
49
|
|
|
50
|
+
(0, _listenerToBus.useListenerToBus)([{
|
|
51
|
+
busEventKey: _nativeMessages.NativeMessage.IS_SCRIPT_FETCHED,
|
|
52
|
+
action: listenerAction
|
|
53
|
+
}]);
|
|
39
54
|
(0, _react.useEffect)(() => {
|
|
40
|
-
|
|
55
|
+
if (!unitScript) {
|
|
56
|
+
(0, _UnitSdk.fetchUnitScript)();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
41
59
|
|
|
42
|
-
let newHtml = _html.default.replace(
|
|
60
|
+
let newHtml = _html.default.replace(_html.HTML_PLACEHOLDER.BODY, (0, _bodyHtml.getHtmlBody)(props.type.valueOf(), props.params, props.presentationMode));
|
|
43
61
|
|
|
44
|
-
newHtml = newHtml.replace(
|
|
62
|
+
newHtml = newHtml.replace(_html.HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');
|
|
45
63
|
setSourceHtml(newHtml);
|
|
46
|
-
}, [props.params]);
|
|
64
|
+
}, [props.params, unitScript]);
|
|
47
65
|
|
|
48
66
|
const onMessage = e => {
|
|
49
67
|
const message = JSON.parse(e.nativeEvent.data);
|
|
50
68
|
|
|
51
69
|
if (message.type == _unitMessages.UnitMessage.UNIT_REQUEST_REFRESH && message.details) {
|
|
52
|
-
_EventBus.default.Instance.event(
|
|
70
|
+
_EventBus.default.Instance.event(_unitMessages.UnitMessage.UNIT_REQUEST_REFRESH, message.details);
|
|
53
71
|
} else {
|
|
54
|
-
props.onMessage(message);
|
|
72
|
+
props.onMessage && props.onMessage(message);
|
|
55
73
|
}
|
|
56
74
|
};
|
|
57
75
|
|
|
@@ -59,10 +77,12 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef((props, webRef) => {
|
|
|
59
77
|
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
60
78
|
ref: webRef,
|
|
61
79
|
cacheEnabled: false,
|
|
62
|
-
scrollEnabled:
|
|
80
|
+
scrollEnabled: props.shouldEnableWebViewScroll,
|
|
63
81
|
overScrollMode: "never",
|
|
82
|
+
injectedJavaScript: unitScript,
|
|
64
83
|
style: {
|
|
65
|
-
width:
|
|
84
|
+
width: props.width ?? '100%',
|
|
85
|
+
flex: 1
|
|
66
86
|
},
|
|
67
87
|
source: {
|
|
68
88
|
html: sourceHtml
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","sourceHtml","setSourceHtml","
|
|
1
|
+
{"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","listenerAction","data","useListenerToBus","busEventKey","NativeMessage","IS_SCRIPT_FETCHED","action","useEffect","fetchUnitScript","newHtml","html","replace","HTML_PLACEHOLDER","BODY","getHtmlBody","type","valueOf","params","presentationMode","SCRIPT_FROM_NATIVE","script","onMessage","e","message","JSON","parse","nativeEvent","UnitMessage","UNIT_REQUEST_REFRESH","details","EventBus","Instance","event","shouldEnableWebViewScroll","width","flex"],"sources":["WebComponent.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport type { WebViewMessage } from '../messages/webMessages';\nimport { getHtmlBody, PresentationMode } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { NativeMessage } from '../messages/nativeMessages';\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n width?: number;\n shouldEnableWebViewScroll?: boolean;\n}\n\nexport enum WebComponentType {\n card = 'unit-elements-card',\n bookPayment = 'unit-elements-book-payment',\n activity = 'unit-elements-activity',\n slot = 'unit-elements-sdk-slot'\n}\n\nexport const WebComponent = React.forwardRef<WebView, WebComponentProps>(function WebComponent(props, webRef) {\n const [unitScript, setUnitScript] = useState<string | undefined>(globalUnitScript);\n const [sourceHtml, setSourceHtml] = useState<string | null>(null);\n\n const listenerAction = (data: { unitScript?: string }) => {\n setUnitScript(data.unitScript);\n };\n\n useListenerToBus([{ busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: listenerAction }]);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), props.params, props.presentationMode));\n newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');\n setSourceHtml(newHtml);\n\n }, [props.params, unitScript]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n if (message.type == UnitMessage.UNIT_REQUEST_REFRESH && message.details) {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n } else {\n props.onMessage && props.onMessage(message);\n }\n };\n\n if (!sourceHtml) return null;\n\n return (\n <WebView\n ref={webRef}\n cacheEnabled={false}\n scrollEnabled={props.shouldEnableWebViewScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: props.width ?? '100%', flex: 1 }}\n source={{ html: sourceHtml }}\n onMessage={onMessage} />\n );\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;IAYYA,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,g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oBAA5B,IAAoDL,OAAO,CAACM,OAAhE,EAAyE;MACvEC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBL,yBAAA,CAAYC,oBAApC,EAA0DL,OAAO,CAACM,OAAlE;IACD,CAFD,MAEO;MACLrC,KAAK,CAAC6B,SAAN,IAAmB7B,KAAK,CAAC6B,SAAN,CAAgBE,OAAhB,CAAnB;IACD;EACF,CAPD;;EASA,IAAI,CAACzB,UAAL,EAAiB,OAAO,IAAP;EAEjB,oBACE,6BAAC,2BAAD;IACE,GAAG,EAAEL,MADP;IAEE,YAAY,EAAE,KAFhB;IAGE,aAAa,EAAED,KAAK,CAACyC,yBAHvB;IAIE,cAAc,EAAC,OAJjB;IAKE,kBAAkB,EAAEvC,UALtB;IAME,KAAK,EAAE;MAAEwC,KAAK,EAAE1C,KAAK,CAAC0C,KAAN,IAAe,MAAxB;MAAgCC,IAAI,EAAE;IAAtC,CANT;IAOE,MAAM,EAAE;MAAEzB,IAAI,EAAEZ;IAAR,CAPV;IAQE,SAAS,EAAEuB;EARb,EADF;AAWD,CA5C2B,CAArB"}
|
|
@@ -3,7 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.HTML_PLACEHOLDER = void 0;
|
|
7
|
+
|
|
8
|
+
var _bodyScript = require("../scripts/html/bodyScript");
|
|
9
|
+
|
|
10
|
+
const HTML_PLACEHOLDER = {
|
|
11
|
+
SCRIPT_UNIT: '<SCRIPT_UNIT>',
|
|
12
|
+
BODY: '<BODY_HTML_CODE>',
|
|
13
|
+
SCRIPT_FROM_NATIVE: '<SCRIPT_FROM_NATIVE>'
|
|
14
|
+
};
|
|
15
|
+
exports.HTML_PLACEHOLDER = HTML_PLACEHOLDER;
|
|
7
16
|
const htmlText = `
|
|
8
17
|
<!DOCTYPE html>
|
|
9
18
|
<html lang="en">
|
|
@@ -13,64 +22,32 @@ const htmlText = `
|
|
|
13
22
|
<script>
|
|
14
23
|
window.UnitMobileSDK = true
|
|
15
24
|
</script>
|
|
16
|
-
<script src="https://unit-white-labeled-banking.netlify.app/client-events.js"></script>
|
|
17
25
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
|
|
18
26
|
</html>
|
|
19
27
|
|
|
20
|
-
<body style="margin: 0">
|
|
21
|
-
|
|
28
|
+
<body style="margin: 0;">
|
|
29
|
+
${HTML_PLACEHOLDER.BODY}
|
|
22
30
|
|
|
23
31
|
<script>
|
|
24
|
-
|
|
25
|
-
if ('ReactNativeWebView' in window) {
|
|
26
|
-
const messageString = JSON.stringify(message)
|
|
27
|
-
window['ReactNativeWebView'].postMessage(messageString)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
32
|
+
${_bodyScript.POST_MESSAGE_TO_SDK}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
const height = window.document.documentElement.getBoundingClientRect().height + 36
|
|
34
|
-
postMessageToSDK({ type: "pageHeight", details: { height } })
|
|
35
|
-
})
|
|
36
|
-
}
|
|
34
|
+
${_bodyScript.POST_PAGE_HEIGHT}
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
postMessageToSDK({ type: "pageLoaded" })
|
|
40
|
-
});
|
|
36
|
+
${_bodyScript.LISTENERS.isPageLoaded}
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
postMessageToSDK({ type: "unitRequestRendering", details: { data: JSON.stringify(e.detail) }})
|
|
44
|
-
});
|
|
38
|
+
${_bodyScript.LISTENERS.onLoad}
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
postHeight()
|
|
48
|
-
postMessageToSDK({ type: "unitOnLoad" })
|
|
49
|
-
});
|
|
40
|
+
${_bodyScript.LISTENERS.requestRendering}
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
postMessageToSDK({ type: "unitRequestCloseFlow" })
|
|
53
|
-
});
|
|
42
|
+
${_bodyScript.LISTENERS.requestOpenLink}
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
postMessageToSDK({ type: "unitRequestOpenLink", details: e.detail })
|
|
57
|
-
});
|
|
44
|
+
${_bodyScript.LISTENERS.requestCloseFlow}
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
const response = e.detail
|
|
61
|
-
response.then((data) => {
|
|
62
|
-
postMessageToSDK({ type: "cardStatusChanged", details: { card: JSON.stringify(data.data) }})
|
|
63
|
-
}).catch((e) => {
|
|
64
|
-
console.log(e)
|
|
65
|
-
})
|
|
66
|
-
});
|
|
46
|
+
${_bodyScript.LISTENERS.cardStatusChange}
|
|
67
47
|
|
|
68
|
-
|
|
69
|
-
const event = new CustomEvent("unitRequestRendering",{ detail: JSON.parse(details) })
|
|
70
|
-
window.dispatchEvent(event)
|
|
71
|
-
}
|
|
48
|
+
${_bodyScript.DISPTACH_RENDERING_EVENT}
|
|
72
49
|
|
|
73
|
-
|
|
50
|
+
${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}
|
|
74
51
|
</script>
|
|
75
52
|
</body>
|
|
76
53
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["htmlText"],"sources":["html.ts"],"sourcesContent":["const htmlText = `\n <!DOCTYPE html>\n <html lang=\"en\">\n\n <head lang=\"en\">\n <title>Unit Web SDK Demo</title>\n <script>\n window.UnitMobileSDK = true\n </script>\n <
|
|
1
|
+
{"version":3,"names":["HTML_PLACEHOLDER","SCRIPT_UNIT","BODY","SCRIPT_FROM_NATIVE","htmlText","POST_MESSAGE_TO_SDK","POST_PAGE_HEIGHT","LISTENERS","isPageLoaded","onLoad","requestRendering","requestOpenLink","requestCloseFlow","cardStatusChange","DISPTACH_RENDERING_EVENT"],"sources":["html.ts"],"sourcesContent":["import { DISPTACH_RENDERING_EVENT, LISTENERS, POST_MESSAGE_TO_SDK, POST_PAGE_HEIGHT } from '../scripts/html/bodyScript';\n\nexport const HTML_PLACEHOLDER = {\n SCRIPT_UNIT: '<SCRIPT_UNIT>',\n BODY: '<BODY_HTML_CODE>',\n SCRIPT_FROM_NATIVE: '<SCRIPT_FROM_NATIVE>'\n};\n\nconst htmlText = `\n <!DOCTYPE html>\n <html lang=\"en\">\n\n <head lang=\"en\">\n <title>Unit Web SDK Demo</title>\n <script>\n window.UnitMobileSDK = true\n </script>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=0\">\n </html>\n\n <body style=\"margin: 0;\">\n ${HTML_PLACEHOLDER.BODY}\n\n <script>\n ${POST_MESSAGE_TO_SDK}\n\n ${POST_PAGE_HEIGHT}\n\n ${LISTENERS.isPageLoaded}\n\n ${LISTENERS.onLoad}\n\n ${LISTENERS.requestRendering}\n\n ${LISTENERS.requestOpenLink}\n\n ${LISTENERS.requestCloseFlow}\n\n ${LISTENERS.cardStatusChange}\n\n ${DISPTACH_RENDERING_EVENT}\n\n ${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}\n </script>\n </body>\n`;\n\nexport default htmlText;\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,gBAAgB,GAAG;EAC9BC,WAAW,EAAE,eADiB;EAE9BC,IAAI,EAAE,kBAFwB;EAG9BC,kBAAkB,EAAE;AAHU,CAAzB;;AAMP,MAAMC,QAAQ,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMJ,gBAAgB,CAACE,IAAK;AAC5B;AACA;AACA,QAAQG,+BAAoB;AAC5B;AACA,QAAQC,4BAAiB;AACzB;AACA,QAAQC,qBAAA,CAAUC,YAAa;AAC/B;AACA,QAAQD,qBAAA,CAAUE,MAAO;AACzB;AACA,QAAQF,qBAAA,CAAUG,gBAAiB;AACnC;AACA,QAAQH,qBAAA,CAAUI,eAAgB;AAClC;AACA,QAAQJ,qBAAA,CAAUK,gBAAiB;AACnC;AACA,QAAQL,qBAAA,CAAUM,gBAAiB;AACnC;AACA,QAAQC,oCAAyB;AACjC;AACA,QAAQd,gBAAgB,CAACG,kBAAmB;AAC5C;AACA;AACA,CArCA;eAuCeC,Q"}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","CloseIcon"],"sources":["index.ts"],"sourcesContent":["export { default as CloseIcon } from './close.png';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAApB,QAAqC,aAArC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
3
|
+
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
4
|
+
import { getActivityParams } from './UNActivityComponent.utils';
|
|
5
|
+
export const UNActivityComponent = props => {
|
|
6
|
+
return /*#__PURE__*/React.createElement(WebComponent, {
|
|
7
|
+
type: WebComponentType.activity,
|
|
8
|
+
presentationMode: PresentationMode.Inherit,
|
|
9
|
+
params: getActivityParams(props),
|
|
10
|
+
shouldEnableWebViewScroll: false
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=UNActivityComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","PresentationMode","WebComponent","WebComponentType","getActivityParams","UNActivityComponent","props","activity","Inherit"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n return (\n <WebComponent\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n shouldEnableWebViewScroll={false}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AAQA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,oBACE,oBAAC,YAAD;IACE,IAAI,EAAEH,gBAAgB,CAACI,QADzB;IAEE,gBAAgB,EAAEN,gBAAgB,CAACO,OAFrC;IAGE,MAAM,EAAEJ,iBAAiB,CAACE,KAAD,CAH3B;IAIE,yBAAyB,EAAE;EAJ7B,EADF;AAQD,CATM"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
2
|
+
export const getActivityParams = props => {
|
|
3
|
+
return `
|
|
4
|
+
account-id="${props.accountId}"
|
|
5
|
+
customer-token="${props.customerToken}"
|
|
6
|
+
theme="${props.theme ?? UnitSDK.getTheme()}"
|
|
7
|
+
style="height: 100%"
|
|
8
|
+
`;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=UNActivityComponent.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UnitSDK","getActivityParams","props","accountId","customerToken","theme","getTheme"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\nimport type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n theme=\"${props.theme ?? UnitSDK.getTheme()}\"\n style=\"height: 100%\"\n `;\n};\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,qCAAxB;AAGA,OAAO,MAAMC,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,aAAaF,KAAK,CAACG,KAAN,IAAeL,OAAO,CAACM,QAAR,EAAmB;AAC/C;AACA,GALE;AAMD,CAPM"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
|
+
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
|
+
import { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';
|
|
5
|
+
import { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
|
|
6
|
+
export const UNBookPaymentComponent = props => {
|
|
7
|
+
const handleWebViewMessage = message => {
|
|
8
|
+
if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {
|
|
9
|
+
const response = message.details;
|
|
10
|
+
props.onPaymentCreated(response.data);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return /*#__PURE__*/React.createElement(WebComponent, {
|
|
15
|
+
type: WebComponentType.bookPayment,
|
|
16
|
+
presentationMode: PresentationMode.Inherit,
|
|
17
|
+
params: getBookPaymentParams(props),
|
|
18
|
+
script: getBookPaymentScript(),
|
|
19
|
+
onMessage: message => handleWebViewMessage(message),
|
|
20
|
+
shouldEnableWebViewScroll: false
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=UNBookPaymentComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","WebComponent","WebComponentType","PresentationMode","getBookPaymentParams","getBookPaymentScript","BookPaymentMessage","UNBookPaymentComponent","props","handleWebViewMessage","message","type","PAYMENT_CREATED","onPaymentCreated","response","details","data","bookPayment","Inherit"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { UNBookPaymentData } from '../../sharedTypes';\n\nexport interface UNBookPaymentComponentProps {\n accountId: string;\n customerToken: string;\n isSameCustomer: boolean;\n counterPartyAccountId: string;\n counterPartyName: string;\n theme?: string;\n onPaymentCreated?: (data: UNBookPaymentData) => void;\n}\n\nexport const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {\n const response = message.details as BookPaymentEvent;\n props.onPaymentCreated(response.data);\n }\n };\n\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={PresentationMode.Inherit}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n shouldEnableWebViewScroll={false}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,oBAAT,EAA+BC,oBAA/B,QAA2D,gCAA3D;AAEA,SAA2BC,kBAA3B,QAAqD,+CAArD;AAaA,OAAO,MAAMC,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBL,kBAAkB,CAACM,eAApC,IAAuDJ,KAAK,CAACK,gBAAjE,EAAmF;MACjF,MAAMC,QAAQ,GAAGJ,OAAO,CAACK,OAAzB;MACAP,KAAK,CAACK,gBAAN,CAAuBC,QAAQ,CAACE,IAAhC;IACD;EACF,CALD;;EAOA,oBACE,oBAAC,YAAD;IACE,IAAI,EAAEd,gBAAgB,CAACe,WADzB;IAEE,gBAAgB,EAAEd,gBAAgB,CAACe,OAFrC;IAGE,MAAM,EAAEd,oBAAoB,CAACI,KAAD,CAH9B;IAIE,MAAM,EAAEH,oBAAoB,EAJ9B;IAKE,SAAS,EAAGK,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;IAME,yBAAyB,EAAE;EAN7B,EADF;AAUD,CAlBM"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
|
|
2
|
+
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
3
|
+
export const getBookPaymentParams = props => {
|
|
4
|
+
return `
|
|
5
|
+
account-id="${props.accountId}"
|
|
6
|
+
customer-token="${props.customerToken}"
|
|
7
|
+
is-same-customer="${props.isSameCustomer}"
|
|
8
|
+
counterparty-account-id="${props.counterPartyAccountId}"
|
|
9
|
+
counterparty-name="${props.counterPartyName}"
|
|
10
|
+
theme="${props.theme ?? UnitSDK.getTheme()}"
|
|
11
|
+
style="height: 100%"
|
|
12
|
+
`;
|
|
13
|
+
};
|
|
14
|
+
export const getBookPaymentScript = () => {
|
|
15
|
+
return `
|
|
16
|
+
window.addEventListener("${BookPaymentMessage.PAYMENT_CREATED}", (e) => {
|
|
17
|
+
const response = e.detail
|
|
18
|
+
response.then((data) => {
|
|
19
|
+
postMessageToSDK({ type: "${BookPaymentMessage.PAYMENT_CREATED}", details: { data: JSON.stringify(data.data) }})
|
|
20
|
+
}).catch((e) => {
|
|
21
|
+
console.log(e)
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
`;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=UNBookPaymentComponent.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BookPaymentMessage","UnitSDK","getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","theme","getTheme","getBookPaymentScript","PAYMENT_CREATED"],"sources":["UNBookPaymentComponent.utils.ts"],"sourcesContent":["import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';\n\nimport { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\n\nexport const getBookPaymentParams = (props: UNBookPaymentComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n is-same-customer=\"${props.isSameCustomer}\"\n counterparty-account-id=\"${props.counterPartyAccountId}\"\n counterparty-name=\"${props.counterPartyName}\"\n theme=\"${props.theme ?? UnitSDK.getTheme()}\"\n style=\"height: 100%\"\n `;\n};\n\nexport const getBookPaymentScript = () => {\n return `\n window.addEventListener(\"${BookPaymentMessage.PAYMENT_CREATED}\", (e) => {\n const response = e.detail\n response.then((data) => {\n postMessageToSDK({ type: \"${BookPaymentMessage.PAYMENT_CREATED}\", details: { data: JSON.stringify(data.data) }})\n }).catch((e) => {\n console.log(e)\n })\n });\n `;\n};\n"],"mappings":"AAEA,SAASA,kBAAT,QAAmC,+CAAnC;AACA,SAASC,OAAT,QAAwB,qCAAxB;AAEA,OAAO,MAAMC,oBAAoB,GAAIC,KAAD,IAAwC;EAC1E,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,wBAAwBF,KAAK,CAACG,cAAe;AAC7C,+BAA+BH,KAAK,CAACI,qBAAsB;AAC3D,yBAAyBJ,KAAK,CAACK,gBAAiB;AAChD,aAAaL,KAAK,CAACM,KAAN,IAAeR,OAAO,CAACS,QAAR,EAAmB;AAC/C;AACA,GARE;AASD,CAVM;AAYP,OAAO,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BX,kBAAkB,CAACY,eAAgB;AAClE;AACA;AACA,sCAAsCZ,kBAAkB,CAACY,eAAgB;AACzE;AACA;AACA;AACA;AACA,GATE;AAUD,CAXM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BOTTOM_SHEET_MAX_PRECANTAGE_SIZE"],"sources":["UNBottomSheetComponent.constants.ts"],"sourcesContent":["export const BOTTOM_SHEET_MAX_PRECANTAGE_SIZE = 0.9;\n"],"mappings":"AAAA,OAAO,MAAMA,gCAAgC,GAAG,GAAzC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
|
+
import { Dimensions, Linking, View } from 'react-native';
|
|
4
|
+
import BottomSheet from '../../helpers/BottomSheet/BottomSheet';
|
|
5
|
+
import EventBus from '../../helpers/EventBus';
|
|
6
|
+
import { PageMessage } from '../../messages/webMessages/pageMessage';
|
|
7
|
+
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
8
|
+
import { CardMessage } from '../../messages/webMessages/cardMessage';
|
|
9
|
+
import { useListenerToBus } from '../../hooks/listenerToBus';
|
|
10
|
+
import { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest, resetHtml } from './UNBottomSheetComponent.utils';
|
|
11
|
+
import { getStylesObject } from './UNBottomSheetComponent.styles';
|
|
12
|
+
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
13
|
+
import { useAppStateListener } from '../../hooks/useAppStateListener';
|
|
14
|
+
export const UNBottomSheetComponent = () => {
|
|
15
|
+
const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);
|
|
16
|
+
const [height, setHeight] = useState(0);
|
|
17
|
+
const [renderingRequest, setRenderingRequest] = useState(null);
|
|
18
|
+
const [shouldEnableWebViewScroll, setShouldEnableWebViewScroll] = useState(false);
|
|
19
|
+
const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);
|
|
20
|
+
const [newHeightMessage, setNewHeightMessage] = useState(null);
|
|
21
|
+
const isAppActive = useAppStateListener();
|
|
22
|
+
const styles = getStylesObject();
|
|
23
|
+
const webRef = useRef(null);
|
|
24
|
+
|
|
25
|
+
const listenerAction = data => {
|
|
26
|
+
setRenderingRequest(data);
|
|
27
|
+
setIsBottomSheetActive(true);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!isAppActive) {
|
|
32
|
+
setIsBottomSheetActive(false);
|
|
33
|
+
}
|
|
34
|
+
}, [isAppActive]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!webRef.current) return;
|
|
37
|
+
|
|
38
|
+
if (renderingRequest) {
|
|
39
|
+
renderingBottomSheetRequest(webRef.current, renderingRequest);
|
|
40
|
+
}
|
|
41
|
+
}, [webRef.current, renderingRequest]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!isBottomSheetActive) {
|
|
44
|
+
webRef.current && resetHtml(webRef.current);
|
|
45
|
+
setHeight(0);
|
|
46
|
+
setRenderingRequest(null);
|
|
47
|
+
}
|
|
48
|
+
}, [isBottomSheetActive]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!waitForLoadingNewComponent && newHeightMessage) {
|
|
51
|
+
setWaitForLoadingNewComponent(false);
|
|
52
|
+
setNewHeight(newHeightMessage);
|
|
53
|
+
}
|
|
54
|
+
}, [waitForLoadingNewComponent, newHeightMessage]);
|
|
55
|
+
useListenerToBus([{
|
|
56
|
+
busEventKey: UnitMessage.UNIT_REQUEST_RENDERING,
|
|
57
|
+
action: listenerAction
|
|
58
|
+
}]);
|
|
59
|
+
|
|
60
|
+
const setNewHeight = message => {
|
|
61
|
+
if (renderingRequest) {
|
|
62
|
+
const nativePlace = JSON.parse(renderingRequest).nativePlace;
|
|
63
|
+
|
|
64
|
+
if (nativePlace == 'overFullScreen') {
|
|
65
|
+
const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);
|
|
66
|
+
setHeight(bottomSheetNewHeight);
|
|
67
|
+
setShouldEnableWebViewScroll(true);
|
|
68
|
+
} else {
|
|
69
|
+
setHeight(message.details.height);
|
|
70
|
+
setShouldEnableWebViewScroll(false);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const onWebMessage = message => {
|
|
76
|
+
switch (message.type) {
|
|
77
|
+
case PageMessage.PAGE_HEIGHT:
|
|
78
|
+
renderingRequest && setNewHeightMessage(message);
|
|
79
|
+
break;
|
|
80
|
+
|
|
81
|
+
case UnitMessage.UNIT_REQUEST_RENDERING:
|
|
82
|
+
// eslint-disable-next-line no-case-declarations
|
|
83
|
+
const {
|
|
84
|
+
data
|
|
85
|
+
} = message.details;
|
|
86
|
+
|
|
87
|
+
if (data != renderingRequest) {
|
|
88
|
+
setHeight(0);
|
|
89
|
+
setRenderingRequest(data);
|
|
90
|
+
setWaitForLoadingNewComponent(true);
|
|
91
|
+
setTimeout(() => setWaitForLoadingNewComponent(false), 400);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case CardMessage.CARD_STATUS_CHANGED:
|
|
97
|
+
EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, message.details.card);
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:
|
|
101
|
+
setIsBottomSheetActive(false);
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case UnitMessage.UNIT_REQUEST_OPEN_LINK:
|
|
105
|
+
// eslint-disable-next-line no-case-declarations
|
|
106
|
+
const {
|
|
107
|
+
href
|
|
108
|
+
} = message.details;
|
|
109
|
+
Linking.openURL(href);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
115
|
+
pointerEvents: isBottomSheetActive ? undefined : 'none',
|
|
116
|
+
style: styles.container
|
|
117
|
+
}, /*#__PURE__*/React.createElement(BottomSheet, {
|
|
118
|
+
isOpen: isBottomSheetActive,
|
|
119
|
+
height: height,
|
|
120
|
+
onClose: () => setIsBottomSheetActive(false),
|
|
121
|
+
onOpen: () => setIsBottomSheetActive(true)
|
|
122
|
+
}, isAppActive && /*#__PURE__*/React.createElement(WebComponent, {
|
|
123
|
+
ref: webRef,
|
|
124
|
+
type: WebComponentType.slot,
|
|
125
|
+
presentationMode: PresentationMode.CoverInjectedHeight,
|
|
126
|
+
script: getBottomSheetScript(),
|
|
127
|
+
onMessage: onWebMessage,
|
|
128
|
+
shouldEnableWebViewScroll: shouldEnableWebViewScroll
|
|
129
|
+
}))));
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=UNBottomSheetComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","WebComponent","WebComponentType","Dimensions","Linking","View","BottomSheet","EventBus","PageMessage","UnitMessage","CardMessage","useListenerToBus","getBottomSheetScript","handleHtmlFullHeight","renderingBottomSheetRequest","resetHtml","getStylesObject","PresentationMode","useAppStateListener","UNBottomSheetComponent","isBottomSheetActive","setIsBottomSheetActive","height","setHeight","renderingRequest","setRenderingRequest","shouldEnableWebViewScroll","setShouldEnableWebViewScroll","waitForLoadingNewComponent","setWaitForLoadingNewComponent","newHeightMessage","setNewHeightMessage","isAppActive","styles","webRef","listenerAction","data","current","setNewHeight","busEventKey","UNIT_REQUEST_RENDERING","action","message","nativePlace","JSON","parse","bottomSheetNewHeight","get","details","onWebMessage","type","PAGE_HEIGHT","setTimeout","CARD_STATUS_CHANGED","Instance","event","card","UNIT_REQUEST_CLOSE_FLOW","UNIT_REQUEST_OPEN_LINK","href","openURL","undefined","container","slot","CoverInjectedHeight"],"sources":["UNBottomSheetComponent.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport type WebView from 'react-native-webview';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { Dimensions, Linking, View } from 'react-native';\nimport BottomSheet from '../../helpers/BottomSheet/BottomSheet';\nimport EventBus from '../../helpers/EventBus';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { RequestOpenLinkEvent, RequestRenderingData, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { CardMessage, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getBottomSheetScript, handleHtmlFullHeight, renderingBottomSheetRequest, resetHtml } from './UNBottomSheetComponent.utils';\nimport { getStylesObject } from './UNBottomSheetComponent.styles';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { useAppStateListener } from '../../hooks/useAppStateListener';\n\nexport const UNBottomSheetComponent = () => {\n const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);\n const [height, setHeight] = useState(0);\n\n const [renderingRequest, setRenderingRequest] = useState<string | null>(null);\n const [shouldEnableWebViewScroll, setShouldEnableWebViewScroll] = useState(false);\n\n const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);\n const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null);\n\n const isAppActive = useAppStateListener();\n\n const styles = getStylesObject();\n\n const webRef = useRef<WebView>(null);\n\n const listenerAction = (data: string) => {\n setRenderingRequest(data);\n setIsBottomSheetActive(true);\n };\n\n useEffect(() => {\n if (!isAppActive) {\n setIsBottomSheetActive(false);\n }\n }, [isAppActive]);\n\n useEffect(() => {\n if (!webRef.current) return;\n if (renderingRequest) {\n renderingBottomSheetRequest(webRef.current, renderingRequest);\n }\n }, [webRef.current, renderingRequest]);\n\n useEffect(() => {\n if (!isBottomSheetActive) {\n webRef.current && resetHtml(webRef.current);\n setHeight(0);\n setRenderingRequest(null);\n }\n }, [isBottomSheetActive]);\n\n useEffect(() => {\n if (!waitForLoadingNewComponent && newHeightMessage) {\n setWaitForLoadingNewComponent(false);\n setNewHeight(newHeightMessage);\n }\n }, [waitForLoadingNewComponent, newHeightMessage]);\n\n useListenerToBus([{ busEventKey: UnitMessage.UNIT_REQUEST_RENDERING, action: listenerAction }]);\n\n const setNewHeight = (message: WebViewMessage) => {\n if (renderingRequest) {\n const nativePlace = (JSON.parse(renderingRequest) as RequestRenderingData).nativePlace;\n if (nativePlace == 'overFullScreen') {\n const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);\n setHeight(bottomSheetNewHeight);\n setShouldEnableWebViewScroll(true);\n } else {\n setHeight((message.details as HeightEvent).height);\n setShouldEnableWebViewScroll(false);\n }\n }\n };\n\n const onWebMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case PageMessage.PAGE_HEIGHT:\n renderingRequest && setNewHeightMessage(message);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING:\n // eslint-disable-next-line no-case-declarations\n const { data } = (message.details as RequestRenderingEvent);\n if (data != renderingRequest) {\n setHeight(0);\n setRenderingRequest(data);\n setWaitForLoadingNewComponent(true);\n setTimeout(() => setWaitForLoadingNewComponent(false), 400);\n }\n break;\n case CardMessage.CARD_STATUS_CHANGED:\n EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card);\n break;\n case UnitMessage.UNIT_REQUEST_CLOSE_FLOW:\n setIsBottomSheetActive(false);\n break;\n case UnitMessage.UNIT_REQUEST_OPEN_LINK:\n // eslint-disable-next-line no-case-declarations\n const { href } = (message.details as RequestOpenLinkEvent);\n Linking.openURL(href);\n break;\n }\n };\n\n return (\n <>\n <View\n pointerEvents={isBottomSheetActive ? undefined : 'none'}\n style={styles.container}\n >\n <BottomSheet\n isOpen={isBottomSheetActive}\n height={height}\n onClose={() => setIsBottomSheetActive(false)}\n onOpen={() => setIsBottomSheetActive(true)}\n >\n { isAppActive && (\n <WebComponent\n ref={webRef}\n type={WebComponentType.slot}\n presentationMode={PresentationMode.CoverInjectedHeight}\n script={getBottomSheetScript()}\n onMessage={onWebMessage}\n shouldEnableWebViewScroll={shouldEnableWebViewScroll}\n />)}\n </BottomSheet>\n </View>\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,E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ACE,oBAAC,IAAD;IACE,aAAa,EAAEvC,mBAAmB,GAAGyC,SAAH,GAAe,MADnD;IAEE,KAAK,EAAE5B,MAAM,CAAC6B;EAFhB,gBAIE,oBAAC,WAAD;IACE,MAAM,EAAE1C,mBADV;IAEE,MAAM,EAAEE,MAFV;IAGE,OAAO,EAAE,MAAMD,sBAAsB,CAAC,KAAD,CAHvC;IAIE,MAAM,EAAE,MAAMA,sBAAsB,CAAC,IAAD;EAJtC,GAMIW,WAAW,iBACX,oBAAC,YAAD;IACE,GAAG,EAAEE,MADP;IAEE,IAAI,EAAEhC,gBAAgB,CAAC6D,IAFzB;IAGE,gBAAgB,EAAE9C,gBAAgB,CAAC+C,mBAHrC;IAIE,MAAM,EAAEpD,oBAAoB,EAJ9B;IAKE,SAAS,EAAEqC,YALb;IAME,yBAAyB,EAAEvB;EAN7B,EAPJ,CAJF,CADF,CADF;AAyBD,CAvHM"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
export const getStylesObject = () => {
|
|
3
|
+
return StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
position: 'absolute',
|
|
6
|
+
top: 0,
|
|
7
|
+
bottom: 0,
|
|
8
|
+
left: 0,
|
|
9
|
+
right: 0
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=UNBottomSheetComponent.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","getStylesObject","create","container","position","top","bottom","left","right"],"sources":["UNBottomSheetComponent.styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native';\n\nexport const getStylesObject = () => {\n return StyleSheet.create({\n container: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n }\n });\n};\n"],"mappings":"AAAA,SAASA,UAAT,QAA2B,cAA3B;AAEA,OAAO,MAAMC,eAAe,GAAG,MAAM;EACnC,OAAOD,UAAU,CAACE,MAAX,CAAkB;IACvBC,SAAS,EAAE;MACTC,QAAQ,EAAE,UADD;MAETC,GAAG,EAAE,CAFI;MAGTC,MAAM,EAAE,CAHC;MAITC,IAAI,EAAE,CAJG;MAKTC,KAAK,EAAE;IALE;EADY,CAAlB,CAAP;AASD,CAVM"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
2
|
+
import { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from './UNBottomSheetComponent.constants';
|
|
3
|
+
export const getBottomSheetScript = () => {
|
|
4
|
+
return `
|
|
5
|
+
window.addEventListener("${UnitMessage.UNIT_REQUEST_REFRESH}", (e) => {
|
|
6
|
+
postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_REFRESH}", details: e.detail })
|
|
7
|
+
});
|
|
8
|
+
`;
|
|
9
|
+
};
|
|
10
|
+
export const renderingBottomSheetRequest = (currentWebView, renderingRequest) => {
|
|
11
|
+
currentWebView === null || currentWebView === void 0 ? void 0 : currentWebView.injectJavaScript(`
|
|
12
|
+
document.activeElement && document.activeElement.blur();
|
|
13
|
+
dispatchRenderingEvent('${renderingRequest}');
|
|
14
|
+
`);
|
|
15
|
+
};
|
|
16
|
+
export const resetHtml = currentWebView => {
|
|
17
|
+
currentWebView === null || currentWebView === void 0 ? void 0 : currentWebView.injectJavaScript(`
|
|
18
|
+
document.activeElement && document.activeElement.blur();
|
|
19
|
+
document.getElementById('webViewContainer').style.height = null;
|
|
20
|
+
`);
|
|
21
|
+
};
|
|
22
|
+
export const handleHtmlFullHeight = (currentWebView, windowHeight) => {
|
|
23
|
+
const bottomSheetHeight = windowHeight * BOTTOM_SHEET_MAX_PRECANTAGE_SIZE;
|
|
24
|
+
currentWebView && (currentWebView === null || currentWebView === void 0 ? void 0 : currentWebView.injectJavaScript(`
|
|
25
|
+
document.getElementById('webViewContainer').style.height = '${bottomSheetHeight}px';
|
|
26
|
+
`));
|
|
27
|
+
return bottomSheetHeight;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=UNBottomSheetComponent.utils.js.map
|