react-native-unit-components 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +39 -8
  2. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  3. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +0 -3
  4. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  5. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +41 -10
  6. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  7. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -3
  8. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  9. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +1 -0
  10. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  11. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +0 -3
  12. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  13. package/lib/commonjs/messages/nativeMessages/index.js +1 -0
  14. package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
  15. package/lib/commonjs/scripts/html/bodyHtml.js +1 -1
  16. package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
  17. package/lib/commonjs/unitSdkManager/UnitSdkManager.js +8 -0
  18. package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
  19. package/lib/commonjs/webComponent/WebComponent.js +17 -4
  20. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  21. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +33 -7
  22. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  23. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +0 -2
  24. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  25. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +36 -9
  26. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  27. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -2
  28. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  29. package/lib/module/components/UNCardComponent/UNCardComponent.js +1 -0
  30. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  31. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +0 -2
  32. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  33. package/lib/module/messages/nativeMessages/index.js +1 -0
  34. package/lib/module/messages/nativeMessages/index.js.map +1 -1
  35. package/lib/module/scripts/html/bodyHtml.js +1 -1
  36. package/lib/module/scripts/html/bodyHtml.js.map +1 -1
  37. package/lib/module/unitSdkManager/UnitSdkManager.js +3 -0
  38. package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
  39. package/lib/module/webComponent/WebComponent.js +15 -4
  40. package/lib/module/webComponent/WebComponent.js.map +1 -1
  41. package/lib/typescript/messages/nativeMessages/index.d.ts +2 -1
  42. package/lib/typescript/webComponent/WebComponent.d.ts +2 -0
  43. package/package.json +1 -1
  44. package/src/components/UNActivityComponent/UNActivityComponent.tsx +33 -7
  45. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +0 -2
  46. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +35 -9
  47. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +0 -2
  48. package/src/components/UNCardComponent/UNCardComponent.tsx +1 -0
  49. package/src/components/UNCardComponent/UNCardComponent.utils.ts +0 -2
  50. package/src/messages/nativeMessages/index.ts +2 -1
  51. package/src/scripts/html/bodyHtml.ts +1 -1
  52. package/src/unitSdkManager/UnitSdkManager.ts +3 -0
  53. package/src/webComponent/WebComponent.tsx +17 -5
@@ -5,7 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UNActivityComponent = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _pageMessage = require("../../messages/webMessages/pageMessage");
9
13
 
10
14
  var _bodyHtml = require("../../scripts/html/bodyHtml");
11
15
 
@@ -13,15 +17,42 @@ var _WebComponent = require("../../webComponent/WebComponent");
13
17
 
14
18
  var _UNActivityComponent = require("./UNActivityComponent.utils");
15
19
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ 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); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ const DEFAULT_HEIGHT = _reactNative.Dimensions.get('window').height * 0.5;
17
25
 
18
26
  const UNActivityComponent = props => {
19
- return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
20
- type: _WebComponent.WebComponentType.activity,
21
- presentationMode: _bodyHtml.PresentationMode.Inherit,
22
- params: (0, _UNActivityComponent.getActivityParams)(props),
23
- isScrollable: false
24
- });
27
+ const [defaultHeight, setDefaultHeight] = (0, _react.useState)();
28
+
29
+ const handleWebViewMessage = message => {
30
+ if (message.type === _pageMessage.PageMessage.PAGE_HEIGHT) {
31
+ const currentHeight = message.details.height;
32
+ currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);
33
+ }
34
+ };
35
+
36
+ const renderActivityWebView = () => {
37
+ return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
38
+ type: _WebComponent.WebComponentType.activity,
39
+ presentationMode: _bodyHtml.PresentationMode.Inherit,
40
+ params: (0, _UNActivityComponent.getActivityParams)(props),
41
+ onMessage: message => handleWebViewMessage(message),
42
+ nestedScrollEnabled: true,
43
+ theme: props.theme
44
+ });
45
+ };
46
+
47
+ if (!defaultHeight) {
48
+ return renderActivityWebView();
49
+ }
50
+
51
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
52
+ style: {
53
+ height: defaultHeight
54
+ }
55
+ }, renderActivityWebView());
25
56
  };
26
57
 
27
58
  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 <WebComponent\n type={WebComponentType.activity}\n presentationMode={PresentationMode.Inherit}\n params={getActivityParams(props)}\n isScrollable={false}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAQO,MAAMA,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,oBACE,6BAAC,0BAAD;IACE,IAAI,EAAEC,8BAAA,CAAiBC,QADzB;IAEE,gBAAgB,EAAEC,0BAAA,CAAiBC,OAFrC;IAGE,MAAM,EAAE,IAAAC,sCAAA,EAAkBL,KAAlB,CAHV;IAIE,YAAY,EAAE;EAJhB,EADF;AAQD,CATM"}
1
+ {"version":3,"names":["DEFAULT_HEIGHT","Dimensions","get","height","UNActivityComponent","props","defaultHeight","setDefaultHeight","useState","handleWebViewMessage","message","type","PageMessage","PAGE_HEIGHT","currentHeight","details","renderActivityWebView","WebComponentType","activity","PresentationMode","Inherit","getActivityParams","theme"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nconst DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n const [defaultHeight, setDefaultHeight] = useState<number>();\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === PageMessage.PAGE_HEIGHT) {\n const currentHeight = (message.details as HeightEvent).height;\n currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);\n }\n };\n\n const renderActivityWebView = () => {\n return (\n <WebComponent\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 />\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;;AAEA;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,cAAc,GAAGC,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBC,MAAzB,GAAkC,GAAzD;;AAOO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAC,eAAA,GAA1C;;EACA,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBC,wBAAA,CAAYC,WAAjC,EAA8C;MAC5C,MAAMC,aAAa,GAAIJ,OAAO,CAACK,OAAT,CAAiCZ,MAAvD;MACAW,aAAa,KAAK,CAAlB,IAAuBP,gBAAgB,CAACP,cAAD,CAAvC;IACD;EACF,CALD;;EAOA,MAAMgB,qBAAqB,GAAG,MAAM;IAClC,oBACE,6BAAC,0BAAD;MACE,IAAI,EAAEC,8BAAA,CAAiBC,QADzB;MAEE,gBAAgB,EAAEC,0BAAA,CAAiBC,OAFrC;MAGE,MAAM,EAAE,IAAAC,sCAAA,EAAkBhB,KAAlB,CAHV;MAIE,SAAS,EAAGK,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAJ9D;MAKE,mBAAmB,EAAE,IALvB;MAME,KAAK,EAAEL,KAAK,CAACiB;IANf,EADF;EAUD,CAXD;;EAaA,IAAI,CAAChB,aAAL,EAAoB;IAClB,OAAOU,qBAAqB,EAA5B;EACD;;EAED,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAEb,MAAM,EAAEG;IAAV;EAAb,GACGU,qBAAqB,EADxB,CADF;AAKD,CA/BM"}
@@ -5,13 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getActivityParams = void 0;
7
7
 
8
- var _UnitSdkManager = require("../../unitSdkManager/UnitSdkManager");
9
-
10
8
  const getActivityParams = props => {
11
9
  return `
12
10
  account-id="${props.accountId}"
13
11
  customer-token="${props.customerToken}"
14
- theme="${props.theme ?? _UnitSdkManager.UnitSDK.getTheme()}"
15
12
  style="height: 100%"
16
13
  `;
17
14
  };
@@ -1 +1 @@
1
- {"version":3,"names":["getActivityParams","props","accountId","customerToken","theme","UnitSDK","getTheme"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\nimport type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n theme=\"${props.theme ?? UnitSDK.getTheme()}\"\n style=\"height: 100%\"\n `;\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,aAAaF,KAAK,CAACG,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAAmB;AAC/C;AACA,GALE;AAMD,CAPM"}
1
+ {"version":3,"names":["getActivityParams","props","accountId","customerToken"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n style=\"height: 100%\"\n `;\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C;AACA,GAJE;AAKD,CANM"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UNBookPaymentComponent = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _WebComponent = require("../../webComponent/WebComponent");
11
11
 
@@ -15,24 +15,55 @@ var _UNBookPaymentComponent = require("./UNBookPaymentComponent.utils");
15
15
 
16
16
  var _bookPaymentMessage = require("../../messages/webMessages/bookPaymentMessage");
17
17
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ var _pageMessage = require("../../messages/webMessages/pageMessage");
19
+
20
+ var _reactNative = require("react-native");
21
+
22
+ 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); }
23
+
24
+ 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; }
19
25
 
20
26
  const UNBookPaymentComponent = props => {
27
+ const [height, setHeight] = (0, _react.useState)(0);
28
+ const [presentationMode, setPresentationMode] = (0, _react.useState)(_bodyHtml.PresentationMode.Inherit);
29
+
21
30
  const handleWebViewMessage = message => {
22
31
  if (message.type === _bookPaymentMessage.BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {
23
32
  const response = message.details;
24
33
  props.onPaymentCreated(response.data);
25
34
  }
35
+
36
+ if (message.type === _pageMessage.PageMessage.PAGE_HEIGHT) {
37
+ const currentHeight = message.details.height;
38
+ setHeight(currentHeight);
39
+
40
+ if (presentationMode === _bodyHtml.PresentationMode.Inherit && currentHeight === 0) {
41
+ setPresentationMode(_bodyHtml.PresentationMode.Default);
42
+ }
43
+ }
44
+ };
45
+
46
+ const renderBookPaymentWebView = () => {
47
+ return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
48
+ type: _WebComponent.WebComponentType.bookPayment,
49
+ presentationMode: presentationMode,
50
+ params: (0, _UNBookPaymentComponent.getBookPaymentParams)(props),
51
+ script: (0, _UNBookPaymentComponent.getBookPaymentScript)(),
52
+ onMessage: message => handleWebViewMessage(message),
53
+ isScrollable: false,
54
+ theme: props.theme
55
+ });
26
56
  };
27
57
 
28
- return /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
29
- type: _WebComponent.WebComponentType.bookPayment,
30
- presentationMode: _bodyHtml.PresentationMode.Inherit,
31
- params: (0, _UNBookPaymentComponent.getBookPaymentParams)(props),
32
- script: (0, _UNBookPaymentComponent.getBookPaymentScript)(),
33
- onMessage: message => handleWebViewMessage(message),
34
- isScrollable: false
35
- });
58
+ if (presentationMode === _bodyHtml.PresentationMode.Inherit) {
59
+ return renderBookPaymentWebView();
60
+ }
61
+
62
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
63
+ style: {
64
+ height: height
65
+ }
66
+ }, renderBookPaymentWebView());
36
67
  };
37
68
 
38
69
  exports.UNBookPaymentComponent = UNBookPaymentComponent;
@@ -1 +1 @@
1
- {"version":3,"names":["UNBookPaymentComponent","props","handleWebViewMessage","message","type","BookPaymentMessage","PAYMENT_CREATED","onPaymentCreated","response","details","data","WebComponentType","bookPayment","PresentationMode","Inherit","getBookPaymentParams","getBookPaymentScript"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React from 'react';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport type { UNBookPaymentData } from '../../sharedTypes';\n\nexport interface UNBookPaymentComponentProps {\n accountId: string;\n customerToken: string;\n isSameCustomer: boolean;\n counterPartyAccountId: string;\n counterPartyName: string;\n theme?: string;\n onPaymentCreated?: (data: UNBookPaymentData) => void;\n}\n\nexport const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {\n const response = message.details as BookPaymentEvent;\n props.onPaymentCreated(response.data);\n }\n };\n\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={PresentationMode.Inherit}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;AAaO,MAAMA,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBC,sCAAA,CAAmBC,eAApC,IAAuDL,KAAK,CAACM,gBAAjE,EAAmF;MACjF,MAAMC,QAAQ,GAAGL,OAAO,CAACM,OAAzB;MACAR,KAAK,CAACM,gBAAN,CAAuBC,QAAQ,CAACE,IAAhC;IACD;EACF,CALD;;EAOA,oBACE,6BAAC,0BAAD;IACE,IAAI,EAAEC,8BAAA,CAAiBC,WADzB;IAEE,gBAAgB,EAAEC,0BAAA,CAAiBC,OAFrC;IAGE,MAAM,EAAE,IAAAC,4CAAA,EAAqBd,KAArB,CAHV;IAIE,MAAM,EAAE,IAAAe,4CAAA,GAJV;IAKE,SAAS,EAAGb,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;IAME,YAAY,EAAE;EANhB,EADF;AAUD,CAlBM"}
1
+ {"version":3,"names":["UNBookPaymentComponent","props","height","setHeight","useState","presentationMode","setPresentationMode","PresentationMode","Inherit","handleWebViewMessage","message","type","BookPaymentMessage","PAYMENT_CREATED","onPaymentCreated","response","details","data","PageMessage","PAGE_HEIGHT","currentHeight","Default","renderBookPaymentWebView","WebComponentType","bookPayment","getBookPaymentParams","getBookPaymentScript","theme"],"sources":["UNBookPaymentComponent.tsx"],"sourcesContent":["import React, { useState } 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';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { View } from 'react-native';\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 [height, setHeight] = useState<number>(0);\n const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);\n\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 if (message.type === PageMessage.PAGE_HEIGHT) {\n const currentHeight = (message.details as HeightEvent).height;\n setHeight(currentHeight);\n if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {\n setPresentationMode(PresentationMode.Default);\n }\n }\n };\n\n const renderBookPaymentWebView = () => {\n return (\n <WebComponent\n type={WebComponentType.bookPayment}\n presentationMode={presentationMode}\n params={getBookPaymentParams(props)}\n script={getBookPaymentScript()}\n onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}\n isScrollable={false}\n theme={props.theme}\n />\n );\n };\n\n if (presentationMode === PresentationMode.Inherit) {\n return renderBookPaymentWebView();\n }\n\n return (\n <View style={{ height: height }}>\n {renderBookPaymentWebView()}\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;AAYO,MAAMA,sBAAsB,GAAIC,KAAD,IAAwC;EAC5E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAiB,CAAjB,CAA5B;EACA,MAAM,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0C,IAAAF,eAAA,EAA2BG,0BAAA,CAAiBC,OAA5C,CAAhD;;EAEA,MAAMC,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBC,sCAAA,CAAmBC,eAApC,IAAuDZ,KAAK,CAACa,gBAAjE,EAAmF;MACjF,MAAMC,QAAQ,GAAGL,OAAO,CAACM,OAAzB;MACAf,KAAK,CAACa,gBAAN,CAAuBC,QAAQ,CAACE,IAAhC;IACD;;IAED,IAAIP,OAAO,CAACC,IAAR,KAAiBO,wBAAA,CAAYC,WAAjC,EAA8C;MAC5C,MAAMC,aAAa,GAAIV,OAAO,CAACM,OAAT,CAAiCd,MAAvD;MACAC,SAAS,CAACiB,aAAD,CAAT;;MACA,IAAIf,gBAAgB,KAAKE,0BAAA,CAAiBC,OAAtC,IAAiDY,aAAa,KAAK,CAAvE,EAA0E;QACxEd,mBAAmB,CAACC,0BAAA,CAAiBc,OAAlB,CAAnB;MACD;IACF;EACF,CAbD;;EAeA,MAAMC,wBAAwB,GAAG,MAAM;IACrC,oBACE,6BAAC,0BAAD;MACE,IAAI,EAAEC,8BAAA,CAAiBC,WADzB;MAEE,gBAAgB,EAAEnB,gBAFpB;MAGE,MAAM,EAAE,IAAAoB,4CAAA,EAAqBxB,KAArB,CAHV;MAIE,MAAM,EAAE,IAAAyB,4CAAA,GAJV;MAKE,SAAS,EAAGhB,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAL9D;MAME,YAAY,EAAE,KANhB;MAOE,KAAK,EAAET,KAAK,CAAC0B;IAPf,EADF;EAWD,CAZD;;EAcA,IAAItB,gBAAgB,KAAKE,0BAAA,CAAiBC,OAA1C,EAAmD;IACjD,OAAOc,wBAAwB,EAA/B;EACD;;EAED,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAEpB,MAAM,EAAEA;IAAV;EAAb,GACGoB,wBAAwB,EAD3B,CADF;AAKD,CA1CM"}
@@ -7,8 +7,6 @@ exports.getBookPaymentScript = exports.getBookPaymentParams = void 0;
7
7
 
8
8
  var _bookPaymentMessage = require("../../messages/webMessages/bookPaymentMessage");
9
9
 
10
- var _UnitSdkManager = require("../../unitSdkManager/UnitSdkManager");
11
-
12
10
  const getBookPaymentParams = props => {
13
11
  return `
14
12
  account-id="${props.accountId}"
@@ -16,7 +14,6 @@ const getBookPaymentParams = props => {
16
14
  is-same-customer="${props.isSameCustomer}"
17
15
  counterparty-account-id="${props.counterPartyAccountId}"
18
16
  counterparty-name="${props.counterPartyName}"
19
- theme="${props.theme ?? _UnitSdkManager.UnitSDK.getTheme()}"
20
17
  style="height: 100%"
21
18
  `;
22
19
  };
@@ -1 +1 @@
1
- {"version":3,"names":["getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","theme","UnitSDK","getTheme","getBookPaymentScript","BookPaymentMessage","PAYMENT_CREATED"],"sources":["UNBookPaymentComponent.utils.ts"],"sourcesContent":["import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';\n\nimport { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\n\nexport const getBookPaymentParams = (props: UNBookPaymentComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n is-same-customer=\"${props.isSameCustomer}\"\n counterparty-account-id=\"${props.counterPartyAccountId}\"\n counterparty-name=\"${props.counterPartyName}\"\n theme=\"${props.theme ?? UnitSDK.getTheme()}\"\n style=\"height: 100%\"\n `;\n};\n\nexport const getBookPaymentScript = () => {\n return `\n window.addEventListener(\"${BookPaymentMessage.PAYMENT_CREATED}\", (e) => {\n const response = e.detail\n response.then((data) => {\n postMessageToSDK({ type: \"${BookPaymentMessage.PAYMENT_CREATED}\", details: { data: JSON.stringify(data.data) }})\n }).catch((e) => {\n console.log(e)\n })\n });\n `;\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AAEO,MAAMA,oBAAoB,GAAIC,KAAD,IAAwC;EAC1E,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,wBAAwBF,KAAK,CAACG,cAAe;AAC7C,+BAA+BH,KAAK,CAACI,qBAAsB;AAC3D,yBAAyBJ,KAAK,CAACK,gBAAiB;AAChD,aAAaL,KAAK,CAACM,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAAmB;AAC/C;AACA,GARE;AASD,CAVM;;;;AAYA,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BC,sCAAA,CAAmBC,eAAgB;AAClE;AACA;AACA,sCAAsCD,sCAAA,CAAmBC,eAAgB;AACzE;AACA;AACA;AACA;AACA,GATE;AAUD,CAXM"}
1
+ {"version":3,"names":["getBookPaymentParams","props","accountId","customerToken","isSameCustomer","counterPartyAccountId","counterPartyName","getBookPaymentScript","BookPaymentMessage","PAYMENT_CREATED"],"sources":["UNBookPaymentComponent.utils.ts"],"sourcesContent":["import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';\n\nimport { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';\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 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;;AAEO,MAAMA,oBAAoB,GAAIC,KAAD,IAAwC;EAC1E,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,wBAAwBF,KAAK,CAACG,cAAe;AAC7C,+BAA+BH,KAAK,CAACI,qBAAsB;AAC3D,yBAAyBJ,KAAK,CAACK,gBAAiB;AAChD;AACA,GAPE;AAQD,CATM;;;;AAWA,MAAMC,oBAAoB,GAAG,MAAM;EACxC,OAAQ;AACV,+BAA+BC,sCAAA,CAAmBC,eAAgB;AAClE;AACA;AACA,sCAAsCD,sCAAA,CAAmBC,eAAgB;AACzE;AACA;AACA;AACA;AACA,GATE;AAUD,CAXM"}
@@ -82,6 +82,7 @@ const UNCardComponent = props => {
82
82
  type: _WebComponent.WebComponentType.card,
83
83
  presentationMode: _bodyHtml.PresentationMode.Default,
84
84
  params: (0, _UNCardComponent.getCardParams)(props),
85
+ theme: props.theme,
85
86
  script: (0, _UNCardComponent.getCardScript)(),
86
87
  onMessage: message => handleMessage(message),
87
88
  width: windowWidth,
@@ -1 +1 @@
1
- {"version":3,"names":["UNCardComponent","props","height","setHeight","useState","requestRefreshEvent","setRequestRefreshEvent","windowWidth","Dimensions","get","width","webRef","useRef","cardStatusChanged","card","onStatusChanged","requestRefresh","data","useListenerToBus","busEventKey","CardMessage","CARD_STATUS_CHANGED","action","UnitMessage","UNIT_REQUEST_REFRESH","useEffect","injectRefreshEventIfNeeded","current","cardId","handleMessage","message","type","UNIT_REQUEST_RENDERING","EventBus","Instance","event","details","PageMessage","PAGE_HEIGHT","WebComponentType","PresentationMode","Default","getCardParams","getCardScript"],"sources":["UNCardComponent.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 { getCardParams, getCardScript, injectRefreshEventIfNeeded } from './UNCardComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { UNCardData } from '../../sharedTypes';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\n\nexport interface UNCardComponentProps {\n cardId: string;\n customerToken: string;\n theme?: string;\n onStatusChanged?: (card: UNCardData) => void;\n}\n\nexport const UNCardComponent = (props: UNCardComponentProps) => {\n const [height, setHeight] = useState(0);\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n const windowWidth = Dimensions.get('window').width;\n\n const webRef = useRef<WebView>(null);\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n useListenerToBus([\n { busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged },\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent, props.cardId);\n }, [requestRefreshEvent]);\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING:\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, (message.details as RequestRenderingEvent).data);\n break;\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.card}\n presentationMode={PresentationMode.Default}\n params={getCardParams(props)}\n script={getCardScript()}\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;;AAEA;;;;;;;;AASO,MAAMA,eAAe,GAAIC,KAAD,IAAiC;EAC9D,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAS,CAAT,CAA5B;EACA,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgD,IAAAF,eAAA,EAAqC,IAArC,CAAtD;;EACA,MAAMG,WAAW,GAAGC,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBC,KAA7C;;EAEA,MAAMC,MAAM,GAAG,IAAAC,aAAA,EAAgB,IAAhB,CAAf;;EAEA,MAAMC,iBAAiB,GAAIC,IAAD,IAAsB;IAC9C,IAAIb,KAAK,CAACc,eAAV,EAA2B;MACzBd,KAAK,CAACc,eAAN,CAAsBD,IAAtB;IACD;EACF,CAJD;;EAMA,MAAME,cAAc,GAAIC,IAAD,IAA+B;IACpDX,sBAAsB,CAACW,IAAD,CAAtB;EACD,CAFD;;EAIA,IAAAC,+BAAA,EAAiB,CACf;IAAEC,WAAW,EAAEC,wBAAA,CAAYC,mBAA3B;IAAgDC,MAAM,EAAET;EAAxD,CADe,EAEf;IAAEM,WAAW,EAAEI,yBAAA,CAAYC,oBAA3B;IAAiDF,MAAM,EAAEN;EAAzD,CAFe,CAAjB;EAKA,IAAAS,gBAAA,EAAU,MAAM;IACd,IAAAC,2CAAA,EAA2Bf,MAAM,CAACgB,OAAlC,EAA2CtB,mBAA3C,EAAgEJ,KAAK,CAAC2B,MAAtE;EACD,CAFD,EAEG,CAACvB,mBAAD,CAFH;;EAIA,MAAMwB,aAAa,GAAIC,OAAD,IAA6B;IACjD,QAAQA,OAAO,CAACC,IAAhB;MACE,KAAKR,yBAAA,CAAYS,sBAAjB;QACEC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBZ,yBAAA,CAAYS,sBAApC,EAA6DF,OAAO,CAACM,OAAT,CAA2CnB,IAAvG;;QACA;;MACF,KAAKoB,wBAAA,CAAYC,WAAjB;QACEnC,SAAS,CAAE2B,OAAO,CAACM,OAAT,CAAiClC,MAAlC,CAAT;QACA;IANJ;EAQD,CATD;;EAWA,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAEA;IAAF;EAAb,gBACE,6BAAC,0BAAD;IACE,GAAG,EAAES,MADP;IAEE,IAAI,EAAE4B,8BAAA,CAAiBzB,IAFzB;IAGE,gBAAgB,EAAE0B,0BAAA,CAAiBC,OAHrC;IAIE,MAAM,EAAE,IAAAC,8BAAA,EAAczC,KAAd,CAJV;IAKE,MAAM,EAAE,IAAA0C,8BAAA,GALV;IAME,SAAS,EAAEb,OAAO,IAAID,aAAa,CAACC,OAAD,CANrC;IAOE,KAAK,EAAEvB,WAPT;IAQE,YAAY,EAAE;EARhB,EADF,CADF;AAcD,CAnDM"}
1
+ {"version":3,"names":["UNCardComponent","props","height","setHeight","useState","requestRefreshEvent","setRequestRefreshEvent","windowWidth","Dimensions","get","width","webRef","useRef","cardStatusChanged","card","onStatusChanged","requestRefresh","data","useListenerToBus","busEventKey","CardMessage","CARD_STATUS_CHANGED","action","UnitMessage","UNIT_REQUEST_REFRESH","useEffect","injectRefreshEventIfNeeded","current","cardId","handleMessage","message","type","UNIT_REQUEST_RENDERING","EventBus","Instance","event","details","PageMessage","PAGE_HEIGHT","WebComponentType","PresentationMode","Default","getCardParams","theme","getCardScript"],"sources":["UNCardComponent.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 { getCardParams, getCardScript, injectRefreshEventIfNeeded } from './UNCardComponent.utils';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport type { UNCardData } from '../../sharedTypes';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\n\nexport interface UNCardComponentProps {\n cardId: string;\n customerToken: string;\n theme?: string;\n onStatusChanged?: (card: UNCardData) => void;\n}\n\nexport const UNCardComponent = (props: UNCardComponentProps) => {\n const [height, setHeight] = useState(0);\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n const windowWidth = Dimensions.get('window').width;\n\n const webRef = useRef<WebView>(null);\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n useListenerToBus([\n { busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged },\n { busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh },\n ]);\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent, props.cardId);\n }, [requestRefreshEvent]);\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING:\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_RENDERING, (message.details as RequestRenderingEvent).data);\n break;\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.card}\n presentationMode={PresentationMode.Default}\n params={getCardParams(props)}\n theme={props.theme}\n script={getCardScript()}\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;;AAEA;;;;;;;;AASO,MAAMA,eAAe,GAAIC,KAAD,IAAiC;EAC9D,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAS,CAAT,CAA5B;EACA,MAAM,CAACC,mBAAD,EAAsBC,sBAAtB,IAAgD,IAAAF,eAAA,EAAqC,IAArC,CAAtD;;EACA,MAAMG,WAAW,GAAGC,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBC,KAA7C;;EAEA,MAAMC,MAAM,GAAG,IAAAC,aAAA,EAAgB,IAAhB,CAAf;;EAEA,MAAMC,iBAAiB,GAAIC,IAAD,IAAsB;IAC9C,IAAIb,KAAK,CAACc,eAAV,EAA2B;MACzBd,KAAK,CAACc,eAAN,CAAsBD,IAAtB;IACD;EACF,CAJD;;EAMA,MAAME,cAAc,GAAIC,IAAD,IAA+B;IACpDX,sBAAsB,CAACW,IAAD,CAAtB;EACD,CAFD;;EAIA,IAAAC,+BAAA,EAAiB,CACf;IAAEC,WAAW,EAAEC,wBAAA,CAAYC,mBAA3B;IAAgDC,MAAM,EAAET;EAAxD,CADe,EAEf;IAAEM,WAAW,EAAEI,yBAAA,CAAYC,oBAA3B;IAAiDF,MAAM,EAAEN;EAAzD,CAFe,CAAjB;EAKA,IAAAS,gBAAA,EAAU,MAAM;IACd,IAAAC,2CAAA,EAA2Bf,MAAM,CAACgB,OAAlC,EAA2CtB,mBAA3C,EAAgEJ,KAAK,CAAC2B,MAAtE;EACD,CAFD,EAEG,CAACvB,mBAAD,CAFH;;EAIA,MAAMwB,aAAa,GAAIC,OAAD,IAA6B;IACjD,QAAQA,OAAO,CAACC,IAAhB;MACE,KAAKR,yBAAA,CAAYS,sBAAjB;QACEC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBZ,yBAAA,CAAYS,sBAApC,EAA6DF,OAAO,CAACM,OAAT,CAA2CnB,IAAvG;;QACA;;MACF,KAAKoB,wBAAA,CAAYC,WAAjB;QACEnC,SAAS,CAAE2B,OAAO,CAACM,OAAT,CAAiClC,MAAlC,CAAT;QACA;IANJ;EAQD,CATD;;EAWA,oBACE,6BAAC,iBAAD;IAAM,KAAK,EAAE;MAAEA;IAAF;EAAb,gBACE,6BAAC,0BAAD;IACE,GAAG,EAAES,MADP;IAEE,IAAI,EAAE4B,8BAAA,CAAiBzB,IAFzB;IAGE,gBAAgB,EAAE0B,0BAAA,CAAiBC,OAHrC;IAIE,MAAM,EAAE,IAAAC,8BAAA,EAAczC,KAAd,CAJV;IAKE,KAAK,EAAEA,KAAK,CAAC0C,KALf;IAME,MAAM,EAAE,IAAAC,8BAAA,GANV;IAOE,SAAS,EAAEd,OAAO,IAAID,aAAa,CAACC,OAAD,CAPrC;IAQE,KAAK,EAAEvB,WART;IASE,YAAY,EAAE;EAThB,EADF,CADF;AAeD,CApDM"}
@@ -9,13 +9,10 @@ var _WebComponent = require("../../webComponent/WebComponent");
9
9
 
10
10
  var _unitMessages = require("../../messages/webMessages/unitMessages");
11
11
 
12
- var _UnitSdkManager = require("../../unitSdkManager/UnitSdkManager");
13
-
14
12
  const getCardParams = props => {
15
13
  return `
16
14
  card-id="${props.cardId}"
17
15
  customer-token="${props.customerToken}"
18
- theme="${props.theme ?? _UnitSdkManager.UnitSDK.getTheme()}"
19
16
  `;
20
17
  };
21
18
 
@@ -1 +1 @@
1
- {"version":3,"names":["getCardParams","props","cardId","customerToken","theme","UnitSDK","getTheme","getCardScript","UnitMessage","UNIT_REQUEST_REFRESH","injectRefreshEventIfNeeded","currentWeb","requestRefreshEvent","dependencies","includes","WebComponentType","card","valueOf","resourceId","injectJavaScript","JSON","stringify"],"sources":["UNCardComponent.utils.ts"],"sourcesContent":["import type WebView from 'react-native-webview';\nimport type { UNCardComponentProps } from './UNCardComponent';\nimport { WebComponentType } from '../../webComponent/WebComponent';\nimport { RequestRefreshEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\n\nexport const getCardParams = (props: UNCardComponentProps) => {\n return `\n card-id=\"${props.cardId}\"\n customer-token=\"${props.customerToken}\"\n theme=\"${props.theme ?? UnitSDK.getTheme()}\"\n `;\n};\n\nexport const getCardScript = () => {\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, cardId: string) => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.card.valueOf()) && requestRefreshEvent.resourceId == cardId) {\n currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);\n }\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAEO,MAAMA,aAAa,GAAIC,KAAD,IAAiC;EAC5D,OAAQ;AACV,eAAeA,KAAK,CAACC,MAAO;AAC5B,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,aAAaF,KAAK,CAACG,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAAmB;AAC/C,GAJE;AAKD,CANM;;;;AAQA,MAAMC,aAAa,GAAG,MAAM;EACjC,OAAQ;AACV;AACA,qCAAqCC,yBAAA,CAAYC,oBAAqB;AACtE;AACA;AACA,GALE;AAMD,CAPM;;;;AASA,MAAMC,0BAA0B,GAAG,CAACC,UAAD,EAA6BC,mBAA7B,EAA8EV,MAA9E,KAAiG;EACzI,IAAIU,mBAAmB,IAAIA,mBAAmB,CAACC,YAApB,CAAiCC,QAAjC,CAA0CC,8BAAA,CAAiBC,IAAjB,CAAsBC,OAAtB,EAA1C,CAAvB,IAAqGL,mBAAmB,CAACM,UAApB,IAAkChB,MAA3I,EAAmJ;IACjJS,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEQ,gBAAZ,CAA8B,yBAAwBC,IAAI,CAACC,SAAL,CAAeT,mBAAf,CAAoC,IAA1F;EACD;AACF,CAJM"}
1
+ {"version":3,"names":["getCardParams","props","cardId","customerToken","getCardScript","UnitMessage","UNIT_REQUEST_REFRESH","injectRefreshEventIfNeeded","currentWeb","requestRefreshEvent","dependencies","includes","WebComponentType","card","valueOf","resourceId","injectJavaScript","JSON","stringify"],"sources":["UNCardComponent.utils.ts"],"sourcesContent":["import type WebView from 'react-native-webview';\nimport type { UNCardComponentProps } from './UNCardComponent';\nimport { WebComponentType } from '../../webComponent/WebComponent';\nimport { RequestRefreshEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\n\nexport const getCardParams = (props: UNCardComponentProps) => {\n return `\n card-id=\"${props.cardId}\"\n customer-token=\"${props.customerToken}\"\n `;\n};\n\nexport const getCardScript = () => {\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, cardId: string) => {\n if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.card.valueOf()) && requestRefreshEvent.resourceId == cardId) {\n currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);\n }\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AAEO,MAAMA,aAAa,GAAIC,KAAD,IAAiC;EAC5D,OAAQ;AACV,eAAeA,KAAK,CAACC,MAAO;AAC5B,sBAAsBD,KAAK,CAACE,aAAc;AAC1C,GAHE;AAID,CALM;;;;AAOA,MAAMC,aAAa,GAAG,MAAM;EACjC,OAAQ;AACV;AACA,qCAAqCC,yBAAA,CAAYC,oBAAqB;AACtE;AACA;AACA,GALE;AAMD,CAPM;;;;AASA,MAAMC,0BAA0B,GAAG,CAACC,UAAD,EAA6BC,mBAA7B,EAA8EP,MAA9E,KAAiG;EACzI,IAAIO,mBAAmB,IAAIA,mBAAmB,CAACC,YAApB,CAAiCC,QAAjC,CAA0CC,8BAAA,CAAiBC,IAAjB,CAAsBC,OAAtB,EAA1C,CAAvB,IAAqGL,mBAAmB,CAACM,UAApB,IAAkCb,MAA3I,EAAmJ;IACjJM,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEQ,gBAAZ,CAA8B,yBAAwBC,IAAI,CAACC,SAAL,CAAeT,mBAAf,CAAoC,IAA1F;EACD;AACF,CAJM"}
@@ -9,5 +9,6 @@ exports.NativeMessage = NativeMessage;
9
9
 
10
10
  (function (NativeMessage) {
11
11
  NativeMessage["IS_SCRIPT_FETCHED"] = "isScriptFetched";
12
+ NativeMessage["IS_SDK_INITIALIZED"] = "isSdkInitialized";
12
13
  })(NativeMessage || (exports.NativeMessage = NativeMessage = {}));
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeMessage"],"sources":["index.ts"],"sourcesContent":["export enum NativeMessage {\n IS_SCRIPT_FETCHED = 'isScriptFetched'\n}\n"],"mappings":";;;;;;IAAYA,a;;;WAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a"}
1
+ {"version":3,"names":["NativeMessage"],"sources":["index.ts"],"sourcesContent":["export enum NativeMessage {\n IS_SCRIPT_FETCHED = 'isScriptFetched',\n IS_SDK_INITIALIZED = 'isSdkInitialized'\n}\n"],"mappings":";;;;;;IAAYA,a;;;WAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a"}
@@ -16,7 +16,7 @@ exports.PresentationMode = PresentationMode;
16
16
  })(PresentationMode || (exports.PresentationMode = PresentationMode = {}));
17
17
 
18
18
  const getHtmlBody = (unitComponent, unitComponentProps, presentationMode) => {
19
- const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;
19
+ const currentComponent = `<${unitComponent} ${unitComponentProps || ''} }> </${unitComponent}>`;
20
20
 
21
21
  switch (presentationMode) {
22
22
  case PresentationMode.CoverInjectedHeight:
@@ -1 +1 @@
1
- {"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAG,kBAAlB;;IAEKC,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAcL,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,OAAMD,aAAc,GAA3F;;EAEA,QAAQE,gBAAR;IACE,KAAKJ,gBAAgB,CAACM,mBAAtB;MACE,OAAOC,gCAAgC,CAACF,gBAAD,CAAvC;;IACF,KAAKL,gBAAgB,CAACQ,OAAtB;MACE,OAAOC,0BAA0B,CAACJ,gBAAD,CAAjC;;IACF;MACE,OAAOA,gBAAP;EANJ;AAQD,CAXM;;;;AAaP,MAAME,gCAAgC,GAAIG,iBAAD,IAA+B;EACtE,OAAQ;AACV,cAAcX,SAAU;AACxB;AACA,UAAUW,iBAAkB;AAC5B;AACA;AACA,GANE;AAOD,CARD;;AAUA,MAAMD,0BAA0B,GAAIC,iBAAD,IAA+B;EAChE,OAAQ;AACV;AACA,QAAQA,iBAAkB;AAC1B;AACA,GAJE;AAKD,CAND"}
1
+ {"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''} }> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAG,kBAAlB;;IAEKC,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAcL,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,SAAQD,aAAc,GAA7F;;EAEA,QAAQE,gBAAR;IACE,KAAKJ,gBAAgB,CAACM,mBAAtB;MACE,OAAOC,gCAAgC,CAACF,gBAAD,CAAvC;;IACF,KAAKL,gBAAgB,CAACQ,OAAtB;MACE,OAAOC,0BAA0B,CAACJ,gBAAD,CAAjC;;IACF;MACE,OAAOA,gBAAP;EANJ;AAQD,CAXM;;;;AAaP,MAAME,gCAAgC,GAAIG,iBAAD,IAA+B;EACtE,OAAQ;AACV,cAAcX,SAAU;AACxB;AACA,UAAUW,iBAAkB;AAC5B;AACA;AACA,GANE;AAOD,CARD;;AAUA,MAAMD,0BAA0B,GAAIC,iBAAD,IAA+B;EAChE,OAAQ;AACV;AACA,QAAQA,iBAAkB;AAC1B;AACA,GAJE;AAKD,CAND"}
@@ -5,8 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UnitSDK = exports.UNIT_SCRIPT_URL = exports.UNEnvironment = void 0;
7
7
 
8
+ var _EventBus = _interopRequireDefault(require("../helpers/EventBus"));
9
+
10
+ var _nativeMessages = require("../messages/nativeMessages");
11
+
8
12
  var _UnitSdk = require("./UnitSdk.api");
9
13
 
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
10
16
  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
17
 
12
18
  let UNEnvironment;
@@ -36,6 +42,8 @@ _defineProperty(UnitSDK, "init", async (env, theme) => {
36
42
  UnitSDK.env = env;
37
43
  UnitSDK.theme = theme;
38
44
  await (0, _UnitSdk.fetchUnitScript)();
45
+
46
+ _EventBus.default.Instance.event(_nativeMessages.NativeMessage.IS_SDK_INITIALIZED, {});
39
47
  } catch (e) {
40
48
  console.log(e);
41
49
  }
@@ -1 +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,KAA8C;EACjE,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"}
1
+ {"version":3,"names":["UNEnvironment","UNIT_SCRIPT_URL","sandbox","production","UnitSDK","env","theme","fetchUnitScript","EventBus","Instance","event","NativeMessage","IS_SDK_INITIALIZED","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import EventBus from '../helpers/EventBus';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport { 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 EventBus.Instance.event(NativeMessage.IS_SDK_INITIALIZED, { });\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;;AACA;;AACA;;;;;;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,KAA8C;EACjE,IAAI;IALKF,OAMP,CAAKC,GAAL,GAAWA,GAAX;IANOD,OAOP,CAAKE,KAAL,GAAaA,KAAb;IACA,MAAM,IAAAC,wBAAA,GAAN;;IACAC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBC,6BAAA,CAAcC,kBAAtC,EAA0D,EAA1D;EACD,CALD,CAKE,OAAOC,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;EACD;AACF,C;;gBAbUT,O,YAeY,MAAM;EAC3B,OAhBSA,OAgBF,CAAKC,GAAZ;AACD,C;;gBAjBUD,O,cAmBc,MAAM;EAC7B,OApBSA,OAoBF,CAAKE,KAAZ;AACD,C"}
@@ -23,6 +23,8 @@ var _UnitSdk = require("../unitSdkManager/UnitSdk.api");
23
23
 
24
24
  var _nativeMessages = require("../messages/nativeMessages");
25
25
 
26
+ var _UnitSdkManager = require("../unitSdkManager/UnitSdkManager");
27
+
26
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
29
 
28
30
  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); }
@@ -43,15 +45,23 @@ exports.WebComponentType = WebComponentType;
43
45
  const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponent(props, webRef) {
44
46
  const [unitScript, setUnitScript] = (0, _react.useState)(_UnitSdk.globalUnitScript);
45
47
  const [sourceHtml, setSourceHtml] = (0, _react.useState)(null);
48
+ const [componentCurrentTheme, setComponentCurrentTheme] = (0, _react.useState)(props.theme ?? _UnitSdkManager.UnitSDK.getTheme());
46
49
  const width = props.width ?? '100%';
47
50
 
48
- const listenerAction = data => {
51
+ const updateUnitScript = data => {
49
52
  setUnitScript(data.unitScript);
50
53
  };
51
54
 
55
+ const updateInitializedParams = () => {
56
+ setComponentCurrentTheme(props.theme ?? _UnitSdkManager.UnitSDK.getTheme());
57
+ };
58
+
52
59
  (0, _listenerToBus.useListenerToBus)([{
53
60
  busEventKey: _nativeMessages.NativeMessage.IS_SCRIPT_FETCHED,
54
- action: listenerAction
61
+ action: updateUnitScript
62
+ }, {
63
+ busEventKey: _nativeMessages.NativeMessage.IS_SDK_INITIALIZED,
64
+ action: updateInitializedParams
55
65
  }]);
56
66
  (0, _react.useEffect)(() => {
57
67
  if (!unitScript) {
@@ -59,11 +69,13 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponen
59
69
  return;
60
70
  }
61
71
 
62
- let newHtml = _html.default.replace(_html.HTML_PLACEHOLDER.BODY, (0, _bodyHtml.getHtmlBody)(props.type.valueOf(), props.params, props.presentationMode));
72
+ const componentParams = (props.params || '') + (componentCurrentTheme ? ` theme="${componentCurrentTheme}"` : '');
73
+
74
+ let newHtml = _html.default.replace(_html.HTML_PLACEHOLDER.BODY, (0, _bodyHtml.getHtmlBody)(props.type.valueOf(), componentParams, props.presentationMode));
63
75
 
64
76
  newHtml = newHtml.replace(_html.HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');
65
77
  setSourceHtml(newHtml);
66
- }, [props.params, unitScript]);
78
+ }, [props.params, unitScript, props.presentationMode, componentCurrentTheme]);
67
79
 
68
80
  const onMessage = e => {
69
81
  const message = JSON.parse(e.nativeEvent.data);
@@ -89,6 +101,7 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponen
89
101
  ref: webRef,
90
102
  cacheEnabled: false,
91
103
  scrollEnabled: props.isScrollable,
104
+ nestedScrollEnabled: props.nestedScrollEnabled,
92
105
  onScroll: _onScroll,
93
106
  overScrollMode: "never",
94
107
  injectedJavaScript: unitScript,
@@ -1 +1 @@
1
- {"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","width","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","_onScroll","handleScroll","isScrollable","flex"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport 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 { getHtmlBody, PresentationMode } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport type { WebViewMessage } from '../messages/webMessages';\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n handleScroll?: (event: any) => void,\n width?: number;\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 const width = props.width ?? '100%';\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 const _onScroll = (event: any) => {\n if (props.handleScroll) {\n props.handleScroll(event);\n }\n\n return null;\n };\n\n return (\n <WebView\n ref={webRef}\n cacheEnabled={false}\n scrollEnabled={props.isScrollable}\n onScroll={_onScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: width, flex: 1 }}\n source={{ html: sourceHtml }}\n onMessage={onMessage} />\n );\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AATA;IAuBYA,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAOL,MAAMC,YAAY,gBAAGC,cAAA,CAAMC,UAAN,CAA6C,SAASF,YAAT,CAAsBG,KAAtB,EAA6BC,MAA7B,EAAqC;EAC5G,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,IAAAC,eAAA,EAA6BC,yBAA7B,CAApC;EACA,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,IAAAH,eAAA,EAAwB,IAAxB,CAApC;EACA,MAAMI,KAAK,GAAGR,KAAK,CAACQ,KAAN,IAAe,MAA7B;;EAEA,MAAMC,cAAc,GAAIC,IAAD,IAAmC;IACxDP,aAAa,CAACO,IAAI,CAACR,UAAN,CAAb;EACD,CAFD;;EAIA,IAAAS,+BAAA,EAAiB,CAAC;IAAEC,WAAW,EAAEC,6BAAA,CAAcC,iBAA7B;IAAgDC,MAAM,EAAEN;EAAxD,CAAD,CAAjB;EAEA,IAAAO,gBAAA,EAAU,MAAM;IACd,IAAI,CAACd,UAAL,EAAiB;MACf,IAAAe,wBAAA;MACA;IACD;;IAED,IAAIC,OAAO,GAAGC,aAAA,CAAKC,OAAL,CAAaC,sBAAA,CAAiBC,IAA9B,EAAoC,IAAAC,qBAAA,EAAYvB,KAAK,CAACwB,IAAN,CAAWC,OAAX,EAAZ,EAAkCzB,KAAK,CAAC0B,MAAxC,EAAgD1B,KAAK,CAAC2B,gBAAtD,CAApC,CAAd;;IACAT,OAAO,GAAGA,OAAO,CAACE,OAAR,CAAgBC,sBAAA,CAAiBO,kBAAjC,EAAqD5B,KAAK,CAAC6B,MAAN,IAAgB,EAArE,CAAV;IACAtB,aAAa,CAACW,OAAD,CAAb;EAED,CAVD,EAUG,CAAClB,KAAK,CAAC0B,MAAP,EAAexB,UAAf,CAVH;;EAYA,MAAM4B,SAAS,GAAIC,CAAD,IAA4B;IAC5C,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAL,CAAWH,CAAC,CAACI,WAAF,CAAczB,IAAzB,CAAhB;;IACA,IAAIsB,OAAO,CAACR,IAAR,IAAgBY,yBAAA,CAAYC,oBAA5B,IAAoDL,OAAO,CAACM,OAAhE,EAAyE;MACvEC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBL,yBAAA,CAAYC,oBAApC,EAA0DL,OAAO,CAACM,OAAlE;IACD,CAFD,MAEO;MACLtC,KAAK,CAAC8B,SAAN,IAAmB9B,KAAK,CAAC8B,SAAN,CAAgBE,OAAhB,CAAnB;IACD;EACF,CAPD;;EASA,IAAI,CAAC1B,UAAL,EAAiB,OAAO,IAAP;;EAEjB,MAAMoC,SAAS,GAAID,KAAD,IAAgB;IAChC,IAAIzC,KAAK,CAAC2C,YAAV,EAAwB;MACtB3C,KAAK,CAAC2C,YAAN,CAAmBF,KAAnB;IACD;;IAED,OAAO,IAAP;EACD,CAND;;EAQA,oBACE,6BAAC,2BAAD;IACE,GAAG,EAAExC,MADP;IAEE,YAAY,EAAE,KAFhB;IAGE,aAAa,EAAED,KAAK,CAAC4C,YAHvB;IAIE,QAAQ,EAAEF,SAJZ;IAKE,cAAc,EAAC,OALjB;IAME,kBAAkB,EAAExC,UANtB;IAOE,KAAK,EAAE;MAAEM,KAAK,EAAEA,KAAT;MAAgBqC,IAAI,EAAE;IAAtB,CAPT;IAQE,MAAM,EAAE;MAAE1B,IAAI,EAAEb;IAAR,CARV;IASE,SAAS,EAAEwB;EATb,EADF;AAYD,CAtD2B,CAArB"}
1
+ {"version":3,"names":["WebComponentType","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","componentCurrentTheme","setComponentCurrentTheme","theme","UnitSDK","getTheme","width","updateUnitScript","data","updateInitializedParams","useListenerToBus","busEventKey","NativeMessage","IS_SCRIPT_FETCHED","action","IS_SDK_INITIALIZED","useEffect","fetchUnitScript","componentParams","params","newHtml","html","replace","HTML_PLACEHOLDER","BODY","getHtmlBody","type","valueOf","presentationMode","SCRIPT_FROM_NATIVE","script","onMessage","e","message","JSON","parse","nativeEvent","UnitMessage","UNIT_REQUEST_REFRESH","details","EventBus","Instance","event","_onScroll","handleScroll","isScrollable","nestedScrollEnabled","flex"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport 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 { getHtmlBody, PresentationMode } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport { UnitSDK } from '../unitSdkManager/UnitSdkManager';\nimport type { WebViewMessage } from '../messages/webMessages';\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n theme?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n nestedScrollEnabled?: boolean,\n handleScroll?: (event: any) => void,\n width?: number;\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 const [componentCurrentTheme, setComponentCurrentTheme] = useState<string | undefined>(props.theme ?? UnitSDK.getTheme());\n const width = props.width ?? '100%';\n\n const updateUnitScript = (data: { unitScript?: string }) => {\n setUnitScript(data.unitScript);\n };\n\n const updateInitializedParams = () => {\n setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());\n };\n\n useListenerToBus([\n { busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: updateUnitScript },\n { busEventKey: NativeMessage.IS_SDK_INITIALIZED, action: updateInitializedParams },\n ]);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n const componentParams = (props.params || '') + (componentCurrentTheme ? ` theme=\"${componentCurrentTheme}\"` : '');\n let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), componentParams, props.presentationMode));\n newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');\n setSourceHtml(newHtml);\n }, [props.params, unitScript, props.presentationMode, componentCurrentTheme]);\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 const _onScroll = (event: any) => {\n if (props.handleScroll) {\n props.handleScroll(event);\n }\n\n return null;\n };\n\n return (\n <WebView\n ref={webRef}\n cacheEnabled={false}\n scrollEnabled={props.isScrollable}\n nestedScrollEnabled={props.nestedScrollEnabled}\n onScroll={_onScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: width, flex: 1 }}\n source={{ html: sourceHtml }}\n onMessage={onMessage} />\n );\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAVA;IA0BYA,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AAOL,MAAMC,YAAY,gBAAGC,cAAA,CAAMC,UAAN,CAA6C,SAASF,YAAT,CAAsBG,KAAtB,EAA6BC,MAA7B,EAAqC;EAC5G,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,IAAAC,eAAA,EAA6BC,yBAA7B,CAApC;EACA,MAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,IAAAH,eAAA,EAAwB,IAAxB,CAApC;EACA,MAAM,CAACI,qBAAD,EAAwBC,wBAAxB,IAAoD,IAAAL,eAAA,EAA6BJ,KAAK,CAACU,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAA5C,CAA1D;EACA,MAAMC,KAAK,GAAGb,KAAK,CAACa,KAAN,IAAe,MAA7B;;EAEA,MAAMC,gBAAgB,GAAIC,IAAD,IAAmC;IAC1DZ,aAAa,CAACY,IAAI,CAACb,UAAN,CAAb;EACD,CAFD;;EAIA,MAAMc,uBAAuB,GAAG,MAAM;IACpCP,wBAAwB,CAACT,KAAK,CAACU,KAAN,IAAeC,uBAAA,CAAQC,QAAR,EAAhB,CAAxB;EACD,CAFD;;EAIA,IAAAK,+BAAA,EAAiB,CACf;IAAEC,WAAW,EAAEC,6BAAA,CAAcC,iBAA7B;IAAgDC,MAAM,EAAEP;EAAxD,CADe,EAEf;IAAEI,WAAW,EAAEC,6BAAA,CAAcG,kBAA7B;IAAiDD,MAAM,EAAEL;EAAzD,CAFe,CAAjB;EAKA,IAAAO,gBAAA,EAAU,MAAM;IACd,IAAI,CAACrB,UAAL,EAAiB;MACf,IAAAsB,wBAAA;MACA;IACD;;IAED,MAAMC,eAAe,GAAG,CAACzB,KAAK,CAAC0B,MAAN,IAAgB,EAAjB,KAAwBlB,qBAAqB,GAAI,WAAUA,qBAAsB,GAApC,GAAyC,EAAtF,CAAxB;;IACA,IAAImB,OAAO,GAAGC,aAAA,CAAKC,OAAL,CAAaC,sBAAA,CAAiBC,IAA9B,EAAoC,IAAAC,qBAAA,EAAYhC,KAAK,CAACiC,IAAN,CAAWC,OAAX,EAAZ,EAAkCT,eAAlC,EAAmDzB,KAAK,CAACmC,gBAAzD,CAApC,CAAd;;IACAR,OAAO,GAAGA,OAAO,CAACE,OAAR,CAAgBC,sBAAA,CAAiBM,kBAAjC,EAAqDpC,KAAK,CAACqC,MAAN,IAAgB,EAArE,CAAV;IACA9B,aAAa,CAACoB,OAAD,CAAb;EACD,CAVD,EAUG,CAAC3B,KAAK,CAAC0B,MAAP,EAAexB,UAAf,EAA2BF,KAAK,CAACmC,gBAAjC,EAAmD3B,qBAAnD,CAVH;;EAYA,MAAM8B,SAAS,GAAIC,CAAD,IAA4B;IAC5C,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAL,CAAWH,CAAC,CAACI,WAAF,CAAc5B,IAAzB,CAAhB;;IACA,IAAIyB,OAAO,CAACP,IAAR,IAAgBW,yBAAA,CAAYC,oBAA5B,IAAoDL,OAAO,CAACM,OAAhE,EAAyE;MACvEC,iBAAA,CAASC,QAAT,CAAkBC,KAAlB,CAAwBL,yBAAA,CAAYC,oBAApC,EAA0DL,OAAO,CAACM,OAAlE;IACD,CAFD,MAEO;MACL9C,KAAK,CAACsC,SAAN,IAAmBtC,KAAK,CAACsC,SAAN,CAAgBE,OAAhB,CAAnB;IACD;EACF,CAPD;;EASA,IAAI,CAAClC,UAAL,EAAiB,OAAO,IAAP;;EAEjB,MAAM4C,SAAS,GAAID,KAAD,IAAgB;IAChC,IAAIjD,KAAK,CAACmD,YAAV,EAAwB;MACtBnD,KAAK,CAACmD,YAAN,CAAmBF,KAAnB;IACD;;IAED,OAAO,IAAP;EACD,CAND;;EAQA,oBACE,6BAAC,2BAAD;IACE,GAAG,EAAEhD,MADP;IAEE,YAAY,EAAE,KAFhB;IAGE,aAAa,EAAED,KAAK,CAACoD,YAHvB;IAIE,mBAAmB,EAAEpD,KAAK,CAACqD,mBAJ7B;IAKE,QAAQ,EAAEH,SALZ;IAME,cAAc,EAAC,OANjB;IAOE,kBAAkB,EAAEhD,UAPtB;IAQE,KAAK,EAAE;MAAEW,KAAK,EAAEA,KAAT;MAAgByC,IAAI,EAAE;IAAtB,CART;IASE,MAAM,EAAE;MAAE1B,IAAI,EAAEtB;IAAR,CATV;IAUE,SAAS,EAAEgC;EAVb,EADF;AAaD,CA/D2B,CAArB"}
@@ -1,13 +1,39 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
+ import { Dimensions, View } from 'react-native';
3
+ import { PageMessage } from '../../messages/webMessages/pageMessage';
2
4
  import { PresentationMode } from '../../scripts/html/bodyHtml';
3
5
  import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
4
6
  import { getActivityParams } from './UNActivityComponent.utils';
7
+ const DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;
5
8
  export const UNActivityComponent = props => {
6
- return /*#__PURE__*/React.createElement(WebComponent, {
7
- type: WebComponentType.activity,
8
- presentationMode: PresentationMode.Inherit,
9
- params: getActivityParams(props),
10
- isScrollable: false
11
- });
9
+ const [defaultHeight, setDefaultHeight] = useState();
10
+
11
+ const handleWebViewMessage = message => {
12
+ if (message.type === PageMessage.PAGE_HEIGHT) {
13
+ const currentHeight = message.details.height;
14
+ currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);
15
+ }
16
+ };
17
+
18
+ const renderActivityWebView = () => {
19
+ return /*#__PURE__*/React.createElement(WebComponent, {
20
+ type: WebComponentType.activity,
21
+ presentationMode: PresentationMode.Inherit,
22
+ params: getActivityParams(props),
23
+ onMessage: message => handleWebViewMessage(message),
24
+ nestedScrollEnabled: true,
25
+ theme: props.theme
26
+ });
27
+ };
28
+
29
+ if (!defaultHeight) {
30
+ return renderActivityWebView();
31
+ }
32
+
33
+ return /*#__PURE__*/React.createElement(View, {
34
+ style: {
35
+ height: defaultHeight
36
+ }
37
+ }, renderActivityWebView());
12
38
  };
13
39
  //# sourceMappingURL=UNActivityComponent.js.map
@@ -1 +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 isScrollable={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,YAAY,EAAE;EAJhB,EADF;AAQD,CATM"}
1
+ {"version":3,"names":["React","useState","Dimensions","View","PageMessage","PresentationMode","WebComponent","WebComponentType","getActivityParams","DEFAULT_HEIGHT","get","height","UNActivityComponent","props","defaultHeight","setDefaultHeight","handleWebViewMessage","message","type","PAGE_HEIGHT","currentHeight","details","renderActivityWebView","activity","Inherit","theme"],"sources":["UNActivityComponent.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';\nimport { PresentationMode } from '../../scripts/html/bodyHtml';\nimport { WebComponent, WebComponentType } from '../../webComponent/WebComponent';\nimport { getActivityParams } from './UNActivityComponent.utils';\n\nconst DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;\nexport interface UNActivityComponentProps {\n accountId: string;\n customerToken: string;\n theme?: string;\n}\n\nexport const UNActivityComponent = (props: UNActivityComponentProps) => {\n const [defaultHeight, setDefaultHeight] = useState<number>();\n const handleWebViewMessage = (message: WebViewMessage) => {\n if (message.type === PageMessage.PAGE_HEIGHT) {\n const currentHeight = (message.details as HeightEvent).height;\n currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);\n }\n };\n\n const renderActivityWebView = () => {\n return (\n <WebComponent\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 />\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,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAEA,SAAsBC,WAAtB,QAAyC,wCAAzC;AACA,SAASC,gBAAT,QAAiC,6BAAjC;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,iCAA/C;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AAEA,MAAMC,cAAc,GAAGP,UAAU,CAACQ,GAAX,CAAe,QAAf,EAAyBC,MAAzB,GAAkC,GAAzD;AAOA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoCd,QAAQ,EAAlD;;EACA,MAAMe,oBAAoB,GAAIC,OAAD,IAA6B;IACxD,IAAIA,OAAO,CAACC,IAAR,KAAiBd,WAAW,CAACe,WAAjC,EAA8C;MAC5C,MAAMC,aAAa,GAAIH,OAAO,CAACI,OAAT,CAAiCV,MAAvD;MACAS,aAAa,KAAK,CAAlB,IAAuBL,gBAAgB,CAACN,cAAD,CAAvC;IACD;EACF,CALD;;EAOA,MAAMa,qBAAqB,GAAG,MAAM;IAClC,oBACE,oBAAC,YAAD;MACE,IAAI,EAAEf,gBAAgB,CAACgB,QADzB;MAEE,gBAAgB,EAAElB,gBAAgB,CAACmB,OAFrC;MAGE,MAAM,EAAEhB,iBAAiB,CAACK,KAAD,CAH3B;MAIE,SAAS,EAAGI,OAAD,IAA6BD,oBAAoB,CAACC,OAAD,CAJ9D;MAKE,mBAAmB,EAAE,IALvB;MAME,KAAK,EAAEJ,KAAK,CAACY;IANf,EADF;EAUD,CAXD;;EAaA,IAAI,CAACX,aAAL,EAAoB;IAClB,OAAOQ,qBAAqB,EAA5B;EACD;;EAED,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEX,MAAM,EAAEG;IAAV;EAAb,GACGQ,qBAAqB,EADxB,CADF;AAKD,CA/BM"}
@@ -1,9 +1,7 @@
1
- import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
2
1
  export const getActivityParams = props => {
3
2
  return `
4
3
  account-id="${props.accountId}"
5
4
  customer-token="${props.customerToken}"
6
- theme="${props.theme ?? UnitSDK.getTheme()}"
7
5
  style="height: 100%"
8
6
  `;
9
7
  };
@@ -1 +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"}
1
+ {"version":3,"names":["getActivityParams","props","accountId","customerToken"],"sources":["UNActivityComponent.utils.ts"],"sourcesContent":["import type { UNActivityComponentProps } from './UNActivityComponent';\n\nexport const getActivityParams = (props: UNActivityComponentProps) => {\n return `\n account-id=\"${props.accountId}\"\n customer-token=\"${props.customerToken}\"\n style=\"height: 100%\"\n `;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,iBAAiB,GAAIC,KAAD,IAAqC;EACpE,OAAQ;AACV,kBAAkBA,KAAK,CAACC,SAAU;AAClC,sBAAsBD,KAAK,CAACE,aAAc;AAC1C;AACA,GAJE;AAKD,CANM"}