react-native-unit-components 1.7.0 → 1.7.1

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.
@@ -28,7 +28,6 @@ exports.AccountAction = AccountAction;
28
28
  })(AccountAction || (exports.AccountAction = AccountAction = {}));
29
29
  const UNAccountComponent = /*#__PURE__*/_react.default.forwardRef(function UNAccountComponent(props, accountRef) {
30
30
  const [height, setHeight] = (0, _react.useState)(0);
31
- const windowWidth = _reactNative.Dimensions.get('window').width;
32
31
  const [requestRefreshEvent, setRequestRefreshEvent] = (0, _react.useState)(null);
33
32
  const webRef = (0, _react.useRef)(null);
34
33
  const handleAccountChanged = account => {
@@ -98,7 +97,8 @@ const UNAccountComponent = /*#__PURE__*/_react.default.forwardRef(function UNAcc
98
97
  };
99
98
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
100
99
  style: {
101
- height
100
+ height,
101
+ width: '100%'
102
102
  }
103
103
  }, /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
104
104
  ref: webRef,
@@ -109,7 +109,6 @@ const UNAccountComponent = /*#__PURE__*/_react.default.forwardRef(function UNAcc
109
109
  theme: props.theme,
110
110
  language: props.language,
111
111
  onMessage: message => handleMessage(message),
112
- width: windowWidth,
113
112
  isScrollable: false
114
113
  }));
115
114
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_pageMessage","_unitMessages","_EventBus","_interopRequireDefault","_WebComponent","_UNAccountComponent","_listenerToBus","_accountMessage","_onLoadMessage","_bottomSheet","_webComponent","_bottomSheetMessage","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AccountAction","exports","UNAccountComponent","React","forwardRef","props","accountRef","height","setHeight","useState","windowWidth","Dimensions","width","requestRefreshEvent","setRequestRefreshEvent","webRef","useRef","handleAccountChanged","account","onAccountChanged","requestRefresh","data","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","console","error","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","action","AccountMessage","UNIT_ACCOUNT_CHANGED","useEffect","injectRefreshEventIfNeeded","current","useImperativeHandle","openActionsMenu","injectOpenActionsMenuScript","openAction","injectRequestAccountActionScript","handleMessage","message","type","UNIT_ON_LOAD","details","UNIT_REQUEST_RENDERING","slotData","componentName","WebComponentType","componentResourceId","accountId","requestRenderingEvent","event","BottomSheetRenderingType","Slot","EventBus","Instance","BottomSheetNativeMessage","START_FLOW","PageMessage","PAGE_HEIGHT","createElement","View","style","WebComponent","ref","presentationMode","PresentationMode","Default","params","getAccountParams","script","getAccountScript","theme","language","onMessage","isScrollable"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent } from '../../webComponent/WebComponent';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectOpenActionsMenuScript, injectRefreshEventIfNeeded, injectRequestAccountActionScript } from './UNAccountComponent.utils';\nimport type { UNError, UNOnLoadResponse, UNOnLoadResponseData } from '../../types/shared';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { UNAccountData } from '../../types/shared/account.types';\nimport { AccountMessage } from '../../messages/webMessages/accountMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport type { UNAccountMenuAction } from '../../types/shared';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\n\nexport interface UNAccountComponentProps {\n // inputs\n accountId?: string;\n customerToken: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideSelectionMenuButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<[UNAccountData]>) => void;\n onAccountChanged?: (account: UNAccountData) => void;\n}\n\nexport interface UNAccountRef {\n openActionsMenu: () => void;\n openAction: (action: UNAccountMenuAction) => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountComponentProps>(function UNAccountComponent(props, accountRef) {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const handleAccountChanged = (account: UNAccountData) => {\n props.onAccountChanged && props.onAccountChanged(account);\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response) {\n // AccountsOnLoadResponse;\n props.onLoad(response[RESPONSE_KEYS.account] as UNOnLoadResponseData<[UNAccountData]>);\n return;\n }\n\n console.error('On Load Error: unexpected response type.');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n useImperativeHandle(accountRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNAccountMenuAction) {\n injectRequestAccountActionScript(webRef.current, action);\n }\n }));\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n language={props.language}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAEA,IAAAO,mBAAA,GAAAP,OAAA;AAEA,IAAAQ,cAAA,GAAAR,OAAA;AAEA,IAAAS,eAAA,GAAAT,OAAA;AACA,IAAAU,cAAA,GAAAV,OAAA;AAEA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,mBAAA,GAAAb,OAAA;AAA4F,SAAAK,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAA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CAAAkB,OAAA,CAAAqF,aAAA,CAACpG,YAAA,CAAAqG,IAAI;IAACC,KAAK,EAAE;MAAE5D;IAAO;EAAE,gBACtB7C,MAAA,CAAAkB,OAAA,CAAAqF,aAAA,CAAC/F,aAAA,CAAAkG,YAAY;IACXC,GAAG,EAAEtD,MAAO;IACZ+B,IAAI,EAAEM,8BAAgB,CAAClC,OAAQ;IAC/BoD,gBAAgB,EAAEC,8BAAgB,CAACC,OAAQ;IAC3CC,MAAM,EAAE,IAAAC,oCAAgB,EAACrE,KAAK,CAAE;IAChCsE,MAAM,EAAE,IAAAC,oCAAgB,GAAG;IAC3BC,KAAK,EAAExE,KAAK,CAACwE,KAAM;IACnBC,QAAQ,EAAEzE,KAAK,CAACyE,QAAS;IACzBC,SAAS,EAAElC,OAAO,IAAID,aAAa,CAACC,OAAO,CAAE;IAC7CjC,KAAK,EAAEF,WAAY;IACnBsE,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC;AAAC/E,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_pageMessage","_unitMessages","_EventBus","_interopRequireDefault","_WebComponent","_UNAccountComponent","_listenerToBus","_accountMessage","_onLoadMessage","_bottomSheet","_webComponent","_bottomSheetMessage","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AccountAction","exports","UNAccountComponent","React","forwardRef","props","accountRef","height","setHeight","useState","requestRefreshEvent","setRequestRefreshEvent","webRef","useRef","handleAccountChanged","account","onAccountChanged","requestRefresh","data","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","console","error","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","action","AccountMessage","UNIT_ACCOUNT_CHANGED","useEffect","injectRefreshEventIfNeeded","current","useImperativeHandle","openActionsMenu","injectOpenActionsMenuScript","openAction","injectRequestAccountActionScript","handleMessage","message","type","UNIT_ON_LOAD","details","UNIT_REQUEST_RENDERING","slotData","componentName","WebComponentType","componentResourceId","accountId","requestRenderingEvent","event","BottomSheetRenderingType","Slot","EventBus","Instance","BottomSheetNativeMessage","START_FLOW","PageMessage","PAGE_HEIGHT","createElement","View","style","width","WebComponent","ref","presentationMode","PresentationMode","Default","params","getAccountParams","script","getAccountScript","theme","language","onMessage","isScrollable"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { 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 } from '../../webComponent/WebComponent';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectOpenActionsMenuScript, injectRefreshEventIfNeeded, injectRequestAccountActionScript } from './UNAccountComponent.utils';\nimport type { UNError, UNOnLoadResponse, UNOnLoadResponseData } from '../../types/shared';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { UNAccountData } from '../../types/shared/account.types';\nimport { AccountMessage } from '../../messages/webMessages/accountMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport type { UNAccountMenuAction } from '../../types/shared';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\n\nexport interface UNAccountComponentProps {\n // inputs\n accountId?: string;\n customerToken: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideSelectionMenuButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<[UNAccountData]>) => void;\n onAccountChanged?: (account: UNAccountData) => void;\n}\n\nexport interface UNAccountRef {\n openActionsMenu: () => void;\n openAction: (action: UNAccountMenuAction) => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountComponentProps>(function UNAccountComponent(props, accountRef) {\n const [height, setHeight] = useState(0);\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const handleAccountChanged = (account: UNAccountData) => {\n props.onAccountChanged && props.onAccountChanged(account);\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response) {\n // AccountsOnLoadResponse;\n props.onLoad(response[RESPONSE_KEYS.account] as UNOnLoadResponseData<[UNAccountData]>);\n return;\n }\n\n console.error('On Load Error: unexpected response type.');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n useImperativeHandle(accountRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNAccountMenuAction) {\n injectRequestAccountActionScript(webRef.current, action);\n }\n }));\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height, width: '100%' }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n language={props.language}\n onMessage={message => handleMessage(message)}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAEA,IAAAO,mBAAA,GAAAP,OAAA;AAEA,IAAAQ,cAAA,GAAAR,OAAA;AAEA,IAAAS,eAAA,GAAAT,OAAA;AACA,IAAAU,cAAA,GAAAV,OAAA;AAEA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,mBAAA,GAAAb,OAAA;AAA4F,SAAAK,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA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;IAC3CC,MAAM,EAAE,IAAAC,oCAAgB,EAACnE,KAAK,CAAE;IAChCoE,MAAM,EAAE,IAAAC,oCAAgB,GAAG;IAC3BC,KAAK,EAAEtE,KAAK,CAACsE,KAAM;IACnBC,QAAQ,EAAEvE,KAAK,CAACuE,QAAS;IACzBC,SAAS,EAAEnC,OAAO,IAAID,aAAa,CAACC,OAAO,CAAE;IAC7CoC,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC;AAAC7E,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
@@ -23,7 +23,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
23
23
  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; }
24
24
  const UNCardComponent = /*#__PURE__*/_react.default.forwardRef(function UNCardComponent(props, cardRef) {
25
25
  const [height, setHeight] = (0, _react.useState)(0);
26
- const windowWidth = _reactNative.Dimensions.get('window').width;
27
26
  const webRef = (0, _react.useRef)(null);
28
27
  (0, _react.useImperativeHandle)(cardRef, () => ({
29
28
  openActionsMenu() {
@@ -109,7 +108,8 @@ const UNCardComponent = /*#__PURE__*/_react.default.forwardRef(function UNCardCo
109
108
  }, [props.pushProvisioningModule]);
110
109
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
111
110
  style: {
112
- height
111
+ height,
112
+ width: '100%'
113
113
  }
114
114
  }, /*#__PURE__*/_react.default.createElement(_WebComponent.WebComponent, {
115
115
  ref: webRef,
@@ -120,7 +120,6 @@ const UNCardComponent = /*#__PURE__*/_react.default.forwardRef(function UNCardCo
120
120
  language: props.language,
121
121
  script: (0, _UNCardComponent.getCardScript)(),
122
122
  onMessage: message => handleMessage(message),
123
- width: windowWidth,
124
123
  isScrollable: false
125
124
  }));
126
125
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_pageMessage","_unitMessages","_EventBus","_interopRequireDefault","_WebComponent","_listenerToBus","_UNCardComponent","_cardMessage","_onLoadMessage","_bottomSheet","_webComponent","_UnitSdkManager","_bottomSheetMessage","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNCardComponent","React","forwardRef","props","cardRef","height","setHeight","useState","windowWidth","Dimensions","width","webRef","useRef","useImperativeHandle","openActionsMenu","injectOpenActionsMenuScript","current","openAction","action","injectRequestCardActionScript","cardStatusChanged","card","onStatusChanged","cardActivated","onCardActivated","requestRefresh","data","injectRefreshEventIfNeeded","cardId","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","console","error","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","CardMessage","CARD_STATUS_CHANGED","CARD_ACTIVATED","handleMessage","message","details","type","UNIT_REQUEST_RENDERING","slotData","componentName","WebComponentType","componentResourceId","requestRenderingEvent","event","BottomSheetRenderingType","Slot","EventBus","Instance","BottomSheetNativeMessage","START_FLOW","PageMessage","PAGE_HEIGHT","UNIT_ON_LOAD","useEffect","UnitSDK","setCustomerToken","customerToken","pushProvisioningModule","setPushProvisioningModule","createElement","View","style","WebComponent","ref","presentationMode","PresentationMode","Default","params","getCardParams","theme","language","script","getCardScript","onMessage","isScrollable","exports"],"sources":["UNCardComponent.tsx"],"sourcesContent":["import React, { useImperativeHandle, useRef, useState, useEffect } 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 } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getCardParams, getCardScript, injectRefreshEventIfNeeded, injectOpenActionsMenuScript, injectRequestCardActionScript } from './UNCardComponent.utils';\nimport type { UNOnLoadResponse, UNCardData, UNError, UNCardMenuAction } from '../../types/shared';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\nimport type { NativeModules } from 'react-native';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\nexport interface UNCardComponentProps {\n // inputs\n cardId: string;\n customerToken: string;\n learnMoreUrl?: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideCardTitle?: boolean;\n hideSensitiveDataButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<UNCardData>) => void\n onStatusChanged?: (card: UNCardData) => void;\n onCardActivated?: (card: UNCardData) => void;\n pushProvisioningModule?: typeof NativeModules;\n}\nexport interface CardRef {\n openActionsMenu: () => void;\n openAction: (action: UNCardMenuAction) => void;\n}\n\nexport const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(function UNCardComponent(props, cardRef) {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const webRef = useRef<WebView>(null);\n\n useImperativeHandle(cardRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNCardMenuAction) {\n injectRequestCardActionScript(webRef.current, action);\n }\n }));\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const cardActivated = (card: UNCardData) => {\n if (props.onCardActivated) {\n props.onCardActivated(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n injectRefreshEventIfNeeded(webRef.current, data, props.cardId);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.card in response) {\n // CardOnLoadResponse\n props.onLoad(response[RESPONSE_KEYS.card] as UNOnLoadResponse<UNCardData>);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged });\n useListenerToBus({ busEventKey: CardMessage.CARD_ACTIVATED, action: cardActivated });\n\n const handleMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.card,\n componentResourceId: props.cardId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n }\n };\n\n useEffect(() => {\n UnitSDK.setCustomerToken(props.customerToken);\n }, [props.customerToken]);\n\n useEffect(() => {\n if (props.pushProvisioningModule) {\n UnitSDK.setPushProvisioningModule(props.pushProvisioningModule);\n }\n }, [props.pushProvisioningModule]);\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 language={props.language}\n script={getCardScript()}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AAEA,IAAAQ,gBAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AAEA,IAAAU,cAAA,GAAAV,OAAA;AACA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,eAAA,GAAAb,OAAA;AACA,IAAAc,mBAAA,GAAAd,OAAA;AAA4F,SAAAK,uBAAAU,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAApB,wBAAAgB,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,G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AAC,CAAC;EAElC,oBACE1G,MAAA,CAAAmB,OAAA,CAAAyF,aAAA,CAACzG,YAAA,CAAA0G,IAAI;IAACC,KAAK,EAAE;MAAElE;IAAO;EAAE,gBACtB5C,MAAA,CAAAmB,OAAA,CAAAyF,aAAA,CAACpG,aAAA,CAAAuG,YAAY;IACXC,GAAG,EAAE9D,MAAO;IACZmC,IAAI,EAAEI,8BAAgB,CAAC7B,IAAK;IAC5BqD,gBAAgB,EAAEC,8BAAgB,CAACC,OAAQ;IAC3CC,MAAM,EAAE,IAAAC,8BAAa,EAAC3E,KAAK,CAAE;IAC7B4E,KAAK,EAAE5E,KAAK,CAAC4E,KAAM;IACnBC,QAAQ,EAAE7E,KAAK,CAAC6E,QAAS;IACzBC,MAAM,EAAE,IAAAC,8BAAa,GAAG;IACxBC,SAAS,EAAEvC,OAAO,IAAID,aAAa,CAACC,OAAO,CAAE;IAC7ClC,KAAK,EAAEF,WAAY;IACnB4E,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC;AAACC,OAAA,CAAArF,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_pageMessage","_unitMessages","_EventBus","_interopRequireDefault","_WebComponent","_listenerToBus","_UNCardComponent","_cardMessage","_onLoadMessage","_bottomSheet","_webComponent","_UnitSdkManager","_bottomSheetMessage","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNCardComponent","React","forwardRef","props","cardRef","height","setHeight","useState","webRef","useRef","useImperativeHandle","openActionsMenu","injectOpenActionsMenuScript","current","openAction","action","injectRequestCardActionScript","cardStatusChanged","card","onStatusChanged","cardActivated","onCardActivated","requestRefresh","data","injectRefreshEventIfNeeded","cardId","handleUnitOnLoad","response","onLoad","RESPONSE_KEYS","errors","console","error","useListenerToBus","busEventKey","UnitMessage","UNIT_REQUEST_REFRESH","CardMessage","CARD_STATUS_CHANGED","CARD_ACTIVATED","handleMessage","message","details","type","UNIT_REQUEST_RENDERING","slotData","componentName","WebComponentType","componentResourceId","requestRenderingEvent","event","BottomSheetRenderingType","Slot","EventBus","Instance","BottomSheetNativeMessage","START_FLOW","PageMessage","PAGE_HEIGHT","UNIT_ON_LOAD","useEffect","UnitSDK","setCustomerToken","customerToken","pushProvisioningModule","setPushProvisioningModule","createElement","View","style","width","WebComponent","ref","presentationMode","PresentationMode","Default","params","getCardParams","theme","language","script","getCardScript","onMessage","isScrollable","exports"],"sources":["UNCardComponent.tsx"],"sourcesContent":["import React, { useImperativeHandle, useRef, useState, useEffect } from 'react';\nimport { 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 } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getCardParams, getCardScript, injectRefreshEventIfNeeded, injectOpenActionsMenuScript, injectRequestCardActionScript } from './UNCardComponent.utils';\nimport type { UNOnLoadResponse, UNCardData, UNError, UNCardMenuAction } from '../../types/shared';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\nimport type { NativeModules } from 'react-native';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\nexport interface UNCardComponentProps {\n // inputs\n cardId: string;\n customerToken: string;\n learnMoreUrl?: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideCardTitle?: boolean;\n hideSensitiveDataButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<UNCardData>) => void\n onStatusChanged?: (card: UNCardData) => void;\n onCardActivated?: (card: UNCardData) => void;\n pushProvisioningModule?: typeof NativeModules;\n}\nexport interface CardRef {\n openActionsMenu: () => void;\n openAction: (action: UNCardMenuAction) => void;\n}\n\nexport const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(function UNCardComponent(props, cardRef) {\n const [height, setHeight] = useState(0);\n\n const webRef = useRef<WebView>(null);\n\n useImperativeHandle(cardRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNCardMenuAction) {\n injectRequestCardActionScript(webRef.current, action);\n }\n }));\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const cardActivated = (card: UNCardData) => {\n if (props.onCardActivated) {\n props.onCardActivated(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n injectRefreshEventIfNeeded(webRef.current, data, props.cardId);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.card in response) {\n // CardOnLoadResponse\n props.onLoad(response[RESPONSE_KEYS.card] as UNOnLoadResponse<UNCardData>);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged });\n useListenerToBus({ busEventKey: CardMessage.CARD_ACTIVATED, action: cardActivated });\n\n const handleMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.card,\n componentResourceId: props.cardId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n }\n };\n\n useEffect(() => {\n UnitSDK.setCustomerToken(props.customerToken);\n }, [props.customerToken]);\n\n useEffect(() => {\n if (props.pushProvisioningModule) {\n UnitSDK.setPushProvisioningModule(props.pushProvisioningModule);\n }\n }, [props.pushProvisioningModule]);\n\n return (\n <View style={{ height, width: '100%' }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.card}\n presentationMode={PresentationMode.Default}\n params={getCardParams(props)}\n theme={props.theme}\n language={props.language}\n script={getCardScript()}\n onMessage={message => handleMessage(message)}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AAEA,IAAAQ,gBAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AAEA,IAAAU,cAAA,GAAAV,OAAA;AACA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,eAAA,GAAAb,OAAA;AACA,IAAAc,mBAAA,GAAAd,OAAA;AAA4F,SAAAK,uBA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AAC4D,aAAa,CAAC;EAC/C,CAAC,EAAE,CAAC5D,KAAK,CAAC4D,aAAa,CAAC,CAAC;EAEzB,IAAAH,gBAAS,EAAC,MAAM;IACd,IAAIzD,KAAK,CAAC6D,sBAAsB,EAAE;MAChCH,uBAAO,CAACI,yBAAyB,CAAC9D,KAAK,CAAC6D,sBAAsB,CAAC;IACjE;EACF,CAAC,EAAE,CAAC7D,KAAK,CAAC6D,sBAAsB,CAAC,CAAC;EAElC,oBACEvG,MAAA,CAAAmB,OAAA,CAAAsF,aAAA,CAACtG,YAAA,CAAAuG,IAAI;IAACC,KAAK,EAAE;MAAE/D,MAAM;MAAEgE,KAAK,EAAE;IAAO;EAAE,gBACrC5G,MAAA,CAAAmB,OAAA,CAAAsF,aAAA,CAACjG,aAAA,CAAAqG,YAAY;IACXC,GAAG,EAAE/D,MAAO;IACZmC,IAAI,EAAEI,8BAAgB,CAAC7B,IAAK;IAC5BsD,gBAAgB,EAAEC,8BAAgB,CAACC,OAAQ;IAC3CC,MAAM,EAAE,IAAAC,8BAAa,EAACzE,KAAK,CAAE;IAC7B0E,KAAK,EAAE1E,KAAK,CAAC0E,KAAM;IACnBC,QAAQ,EAAE3E,KAAK,CAAC2E,QAAS;IACzBC,MAAM,EAAE,IAAAC,8BAAa,GAAG;IACxBC,SAAS,EAAExC,OAAO,IAAID,aAAa,CAACC,OAAO,CAAE;IAC7CyC,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC;AAACC,OAAA,CAAAnF,eAAA,GAAAA,eAAA"}
@@ -30,7 +30,6 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponen
30
30
  const [componentCurrentTheme, setComponentCurrentTheme] = (0, _react.useState)(props.theme ?? _UnitSdkManager.UnitSDK.getTheme());
31
31
  const [componentCurrentLanguage, setComponentCurrentLanguage] = (0, _react.useState)(props.language ?? _UnitSdkManager.UnitSDK.getLanguage());
32
32
  const [baseName, setBaseName] = (0, _react.useState)();
33
- const width = props.width ?? '100%';
34
33
  const updateUnitScript = data => {
35
34
  setUnitScript(data.unitScript);
36
35
  };
@@ -114,7 +113,7 @@ const WebComponent = /*#__PURE__*/_react.default.forwardRef(function WebComponen
114
113
  overScrollMode: "never",
115
114
  injectedJavaScript: unitScript,
116
115
  style: {
117
- width: width,
116
+ width: '100%',
118
117
  flex: 1,
119
118
  opacity: 0.99,
120
119
  backgroundColor: 'transparent'
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_EventBus","_interopRequireDefault","_html","_unitMessages","_listenerToBus","_bodyHtml","_UnitSdk","_UnitSdkManager","_sdkMessage","_WebComponent","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNAppInfo","NativeModules","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","componentCurrentTheme","setComponentCurrentTheme","theme","UnitSDK","getTheme","componentCurrentLanguage","setComponentCurrentLanguage","language","getLanguage","baseName","setBaseName","width","updateUnitScript","data","updateInitializedParams","useListenerToBus","busEventKey","SDKMessage","IS_SCRIPT_FETCHED","action","IS_SDK_INITIALIZED","useEffect","getAppName","Platform","OS","name","getBundleName","replace","error","console","fetchUnitScript","themeParam","languageParam","componentParams","params","newHtml","html","HTML_PLACEHOLDER","BODY","getHtmlBody","type","valueOf","presentationMode","SCRIPT_FROM_NATIVE","script","WINDOW_PARAMS","windowParams","onMessage","e","message","JSON","parse","nativeEvent","UnitMessage","UNIT_REQUEST_REFRESH","details","EventBus","Instance","event","UNIT_REQUEST_DOWNLOAD","handleRequestDownload","UNIT_REQUEST_CLOSE_FLOW","_onScroll","handleScroll","createElement","WebView","ref","originWhitelist","mediaPlaybackRequiresUserAction","allowsInlineMediaPlayback","cacheEnabled","scrollEnabled","isScrollable","nestedScrollEnabled","onScroll","overScrollMode","injectedJavaScript","style","flex","opacity","backgroundColor","source","baseUrl","androidHardwareAccelerationDisabled","exports"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react';\nimport { NativeModules, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage, RequestDownloadEvent } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport { getHtmlBody } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { UnitSDK } from '../unitSdkManager/UnitSdkManager';\nimport type { WebViewMessage } from '../messages/webMessages';\nimport { SDKMessage, SdkScriptFetched } from '../messages/nativeMessages/sdkMessage';\nimport { handleRequestDownload } from './WebComponent.utils';\nimport type { PresentationMode, WebComponentType } from '../types/internal/webComponent.types';\n\nconst { UNAppInfo } = NativeModules;\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n theme?: string;\n language?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n nestedScrollEnabled?: boolean,\n handleScroll?: (event: any) => void,\n width?: number;\n windowParams?: string;\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 [componentCurrentLanguage, setComponentCurrentLanguage] = useState<string | undefined>(props.language ?? UnitSDK.getLanguage());\n const [baseName, setBaseName] = useState<string>();\n const width = props.width ?? '100%';\n\n const updateUnitScript = (data: SdkScriptFetched) => {\n setUnitScript(data.unitScript);\n };\n\n const updateInitializedParams = () => {\n setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());\n setComponentCurrentLanguage(props.language ?? UnitSDK.getLanguage());\n };\n\n useListenerToBus({ busEventKey: SDKMessage.IS_SCRIPT_FETCHED, action: updateUnitScript });\n useListenerToBus({ busEventKey: SDKMessage.IS_SDK_INITIALIZED, action: updateInitializedParams });\n\n useEffect(() => {\n\n const getAppName = async () => {\n // For iOS, we extend the app name from the HTML to display a prettier access request message.\n // On Android, there is no request message sent from HTML.\n try {\n if (Platform.OS == 'ios') {\n const name = await UNAppInfo.getBundleName();\n setBaseName(name.replace(/ /g, '-'));\n } else { // android\n setBaseName('unit');\n }\n } catch (error: any) {\n console.error(error);\n }\n };\n\n getAppName();\n }, []);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n const themeParam = componentCurrentTheme ? ` theme=\"${componentCurrentTheme}\"` : '';\n const languageParam = componentCurrentLanguage ? ` language=\"${componentCurrentLanguage}\"` : '';\n\n const componentParams = (props.params || '') + themeParam + languageParam;\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 newHtml = newHtml.replace(HTML_PLACEHOLDER.WINDOW_PARAMS, props.windowParams || '');\n setSourceHtml(newHtml);\n }, [props.params, unitScript, props.presentationMode, componentCurrentTheme, componentCurrentLanguage, props.script, props.windowParams]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_REFRESH:\n message.details &&\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n break;\n case UnitMessage.UNIT_REQUEST_DOWNLOAD:\n message.details &&\n handleRequestDownload(message.details as RequestDownloadEvent, () => {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_CLOSE_FLOW, {});\n });\n break;\n default:\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 if (!baseName) {\n return null;\n }\n\n return (\n <WebView\n ref={webRef}\n originWhitelist={['*']}\n mediaPlaybackRequiresUserAction={false}\n allowsInlineMediaPlayback={true}\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, opacity: 0.99, backgroundColor: 'transparent' }}\n source={{ html: sourceHtml, baseUrl: `https://${baseName}` }}\n onMessage={onMessage}\n androidHardwareAccelerationDisabled\n />\n );\n});\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,eAAA,GAAAV,OAAA;AAEA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AAA6D,SAAAI,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,W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AACiF,mBAAoB;IAC/CC,QAAQ,EAAEZ,SAAU;IACpBa,cAAc,EAAC,OAAO;IACtBC,kBAAkB,EAAElF,UAAW;IAC/BmF,KAAK,EAAE;MAAElE,KAAK,EAAEA,KAAK;MAAEmE,IAAI,EAAE,CAAC;MAAEC,OAAO,EAAE,IAAI;MAAEC,eAAe,EAAE;IAAc,CAAE;IAChFC,MAAM,EAAE;MAAE7C,IAAI,EAAEtC,UAAU;MAAEoF,OAAO,EAAG,WAAUzE,QAAS;IAAE,CAAE;IAC7DsC,SAAS,EAAEA,SAAU;IACrBoC,mCAAmC;EAAA,EACnC;AAEN,CAAC,CAAC;AAACC,OAAA,CAAA/F,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeWebview","_EventBus","_interopRequireDefault","_html","_unitMessages","_listenerToBus","_bodyHtml","_UnitSdk","_UnitSdkManager","_sdkMessage","_WebComponent","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","UNAppInfo","NativeModules","WebComponent","React","forwardRef","props","webRef","unitScript","setUnitScript","useState","globalUnitScript","sourceHtml","setSourceHtml","componentCurrentTheme","setComponentCurrentTheme","theme","UnitSDK","getTheme","componentCurrentLanguage","setComponentCurrentLanguage","language","getLanguage","baseName","setBaseName","updateUnitScript","data","updateInitializedParams","useListenerToBus","busEventKey","SDKMessage","IS_SCRIPT_FETCHED","action","IS_SDK_INITIALIZED","useEffect","getAppName","Platform","OS","name","getBundleName","replace","error","console","fetchUnitScript","themeParam","languageParam","componentParams","params","newHtml","html","HTML_PLACEHOLDER","BODY","getHtmlBody","type","valueOf","presentationMode","SCRIPT_FROM_NATIVE","script","WINDOW_PARAMS","windowParams","onMessage","e","message","JSON","parse","nativeEvent","UnitMessage","UNIT_REQUEST_REFRESH","details","EventBus","Instance","event","UNIT_REQUEST_DOWNLOAD","handleRequestDownload","UNIT_REQUEST_CLOSE_FLOW","_onScroll","handleScroll","createElement","WebView","ref","originWhitelist","mediaPlaybackRequiresUserAction","allowsInlineMediaPlayback","cacheEnabled","scrollEnabled","isScrollable","nestedScrollEnabled","onScroll","overScrollMode","injectedJavaScript","style","width","flex","opacity","backgroundColor","source","baseUrl","androidHardwareAccelerationDisabled","exports"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react';\nimport { NativeModules, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage, RequestDownloadEvent } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport { getHtmlBody } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { UnitSDK } from '../unitSdkManager/UnitSdkManager';\nimport type { WebViewMessage } from '../messages/webMessages';\nimport { SDKMessage, SdkScriptFetched } from '../messages/nativeMessages/sdkMessage';\nimport { handleRequestDownload } from './WebComponent.utils';\nimport type { PresentationMode, WebComponentType } from '../types/internal/webComponent.types';\n\nconst { UNAppInfo } = NativeModules;\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n theme?: string;\n language?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n nestedScrollEnabled?: boolean,\n handleScroll?: (event: any) => void,\n windowParams?: string;\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 [componentCurrentLanguage, setComponentCurrentLanguage] = useState<string | undefined>(props.language ?? UnitSDK.getLanguage());\n const [baseName, setBaseName] = useState<string>();\n\n const updateUnitScript = (data: SdkScriptFetched) => {\n setUnitScript(data.unitScript);\n };\n\n const updateInitializedParams = () => {\n setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());\n setComponentCurrentLanguage(props.language ?? UnitSDK.getLanguage());\n };\n\n useListenerToBus({ busEventKey: SDKMessage.IS_SCRIPT_FETCHED, action: updateUnitScript });\n useListenerToBus({ busEventKey: SDKMessage.IS_SDK_INITIALIZED, action: updateInitializedParams });\n\n useEffect(() => {\n\n const getAppName = async () => {\n // For iOS, we extend the app name from the HTML to display a prettier access request message.\n // On Android, there is no request message sent from HTML.\n try {\n if (Platform.OS == 'ios') {\n const name = await UNAppInfo.getBundleName();\n setBaseName(name.replace(/ /g, '-'));\n } else { // android\n setBaseName('unit');\n }\n } catch (error: any) {\n console.error(error);\n }\n };\n\n getAppName();\n }, []);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n const themeParam = componentCurrentTheme ? ` theme=\"${componentCurrentTheme}\"` : '';\n const languageParam = componentCurrentLanguage ? ` language=\"${componentCurrentLanguage}\"` : '';\n\n const componentParams = (props.params || '') + themeParam + languageParam;\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 newHtml = newHtml.replace(HTML_PLACEHOLDER.WINDOW_PARAMS, props.windowParams || '');\n setSourceHtml(newHtml);\n }, [props.params, unitScript, props.presentationMode, componentCurrentTheme, componentCurrentLanguage, props.script, props.windowParams]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_REFRESH:\n message.details &&\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n break;\n case UnitMessage.UNIT_REQUEST_DOWNLOAD:\n message.details &&\n handleRequestDownload(message.details as RequestDownloadEvent, () => {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_CLOSE_FLOW, {});\n });\n break;\n default:\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 if (!baseName) {\n return null;\n }\n\n return (\n <WebView\n ref={webRef}\n originWhitelist={['*']}\n mediaPlaybackRequiresUserAction={false}\n allowsInlineMediaPlayback={true}\n cacheEnabled={false}\n scrollEnabled={props.isScrollable}\n nestedScrollEnabled={props.nestedScrollEnabled}\n onScroll={_onScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: '100%', flex: 1, opacity: 0.99, backgroundColor: 'transparent' }}\n source={{ html: sourceHtml, baseUrl: `https://${baseName}` }}\n onMessage={onMessage}\n androidHardwareAccelerationDisabled\n />\n );\n});\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,uBAAA,CAAAC,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,eAAA,GAAAV,OAAA;AAEA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AAA6D,SAAAI,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,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EAAE,KAAM;IACpBC,aAAa,EAAE9E,KAAK,CAAC+E,YAAa;IAClCC,mBAAmB,EAAEhF,KAAK,CAACgF,mBAAoB;IAC/CC,QAAQ,EAAEZ,SAAU;IACpBa,cAAc,EAAC,OAAO;IACtBC,kBAAkB,EAAEjF,UAAW;IAC/BkF,KAAK,EAAE;MAAEC,KAAK,EAAE,MAAM;MAAEC,IAAI,EAAE,CAAC;MAAEC,OAAO,EAAE,IAAI;MAAEC,eAAe,EAAE;IAAc,CAAE;IACjFC,MAAM,EAAE;MAAE9C,IAAI,EAAErC,UAAU;MAAEoF,OAAO,EAAG,WAAUzE,QAAS;IAAE,CAAE;IAC7DqC,SAAS,EAAEA,SAAU;IACrBqC,mCAAmC;EAAA,EACnC;AAEN,CAAC,CAAC;AAACC,OAAA,CAAA/F,YAAA,GAAAA,YAAA"}
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
2
- import { Dimensions, View } from 'react-native';
2
+ import { View } from 'react-native';
3
3
  import { PageMessage } from '../..//messages/webMessages/pageMessage';
4
4
  import { UnitMessage } from '../../messages/webMessages/unitMessages';
5
5
  import EventBus from '../../helpers/EventBus';
@@ -18,7 +18,6 @@ export let AccountAction;
18
18
  })(AccountAction || (AccountAction = {}));
19
19
  export const UNAccountComponent = /*#__PURE__*/React.forwardRef(function UNAccountComponent(props, accountRef) {
20
20
  const [height, setHeight] = useState(0);
21
- const windowWidth = Dimensions.get('window').width;
22
21
  const [requestRefreshEvent, setRequestRefreshEvent] = useState(null);
23
22
  const webRef = useRef(null);
24
23
  const handleAccountChanged = account => {
@@ -88,7 +87,8 @@ export const UNAccountComponent = /*#__PURE__*/React.forwardRef(function UNAccou
88
87
  };
89
88
  return /*#__PURE__*/React.createElement(View, {
90
89
  style: {
91
- height
90
+ height,
91
+ width: '100%'
92
92
  }
93
93
  }, /*#__PURE__*/React.createElement(WebComponent, {
94
94
  ref: webRef,
@@ -99,7 +99,6 @@ export const UNAccountComponent = /*#__PURE__*/React.forwardRef(function UNAccou
99
99
  theme: props.theme,
100
100
  language: props.language,
101
101
  onMessage: message => handleMessage(message),
102
- width: windowWidth,
103
102
  isScrollable: false
104
103
  }));
105
104
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useImperativeHandle","useRef","useState","Dimensions","View","PageMessage","UnitMessage","EventBus","WebComponent","getAccountParams","getAccountScript","injectOpenActionsMenuScript","injectRefreshEventIfNeeded","injectRequestAccountActionScript","useListenerToBus","AccountMessage","RESPONSE_KEYS","BottomSheetRenderingType","PresentationMode","WebComponentType","BottomSheetNativeMessage","AccountAction","UNAccountComponent","forwardRef","props","accountRef","height","setHeight","windowWidth","get","width","requestRefreshEvent","setRequestRefreshEvent","webRef","handleAccountChanged","account","onAccountChanged","requestRefresh","data","handleUnitOnLoad","response","onLoad","errors","console","error","busEventKey","UNIT_REQUEST_REFRESH","action","UNIT_ACCOUNT_CHANGED","current","openActionsMenu","openAction","handleMessage","message","type","UNIT_ON_LOAD","details","UNIT_REQUEST_RENDERING","slotData","componentName","componentResourceId","accountId","requestRenderingEvent","event","Slot","Instance","START_FLOW","PAGE_HEIGHT","createElement","style","ref","presentationMode","Default","params","script","theme","language","onMessage","isScrollable"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { Dimensions, View } from 'react-native';\nimport type WebView from 'react-native-webview';\nimport { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';\nimport { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';\nimport EventBus from '../../helpers/EventBus';\nimport { WebComponent } from '../../webComponent/WebComponent';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectOpenActionsMenuScript, injectRefreshEventIfNeeded, injectRequestAccountActionScript } from './UNAccountComponent.utils';\nimport type { UNError, UNOnLoadResponse, UNOnLoadResponseData } from '../../types/shared';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { UNAccountData } from '../../types/shared/account.types';\nimport { AccountMessage } from '../../messages/webMessages/accountMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport type { UNAccountMenuAction } from '../../types/shared';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\n\nexport interface UNAccountComponentProps {\n // inputs\n accountId?: string;\n customerToken: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideSelectionMenuButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<[UNAccountData]>) => void;\n onAccountChanged?: (account: UNAccountData) => void;\n}\n\nexport interface UNAccountRef {\n openActionsMenu: () => void;\n openAction: (action: UNAccountMenuAction) => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountComponentProps>(function UNAccountComponent(props, accountRef) {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const handleAccountChanged = (account: UNAccountData) => {\n props.onAccountChanged && props.onAccountChanged(account);\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response) {\n // AccountsOnLoadResponse;\n props.onLoad(response[RESPONSE_KEYS.account] as UNOnLoadResponseData<[UNAccountData]>);\n return;\n }\n\n console.error('On Load Error: unexpected response type.');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n useImperativeHandle(accountRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNAccountMenuAction) {\n injectRequestAccountActionScript(webRef.current, action);\n }\n }));\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n language={props.language}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/E,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,SAAsBC,WAAW,QAAQ,yCAAyC;AAClF,SAAqDC,WAAW,QAAQ,yCAAyC;AACjH,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,SAASC,YAAY,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AED,MAAMO,KAAK,GAAG;YACZT,IAAI,EAAErC,wBAAwB,CAAC+C,IAAI;YACnC1B,IAAI,EAAEoB;UACR,CAAkB;UAElBnD,QAAQ,CAAC0D,QAAQ,CAACF,KAAK,CAAC3C,wBAAwB,CAAC8C,UAAU,EAAEH,KAAK,CAAC;UACnE;QACF;MACA,KAAK1D,WAAW,CAAC8D,WAAW;QAC1BxC,SAAS,CAAE0B,OAAO,CAACG,OAAO,CAAiB9B,MAAM,CAAC;QAClD;IAAM;EAEZ,CAAC;EAED,oBACE5B,KAAA,CAAAsE,aAAA,CAAChE,IAAI;IAACiE,KAAK,EAAE;MAAE3C;IAAO;EAAE,gBACtB5B,KAAA,CAAAsE,aAAA,CAAC5D,YAAY;IACX8D,GAAG,EAAErC,MAAO;IACZqB,IAAI,EAAEnC,gBAAgB,CAACgB,OAAQ;IAC/BoC,gBAAgB,EAAErD,gBAAgB,CAACsD,OAAQ;IAC3CC,MAAM,EAAEhE,gBAAgB,CAACe,KAAK,CAAE;IAChCkD,MAAM,EAAEhE,gBAAgB,EAAG;IAC3BiE,KAAK,EAAEnD,KAAK,CAACmD,KAAM;IACnBC,QAAQ,EAAEpD,KAAK,CAACoD,QAAS;IACzBC,SAAS,EAAExB,OAAO,IAAID,aAAa,CAACC,OAAO,CAAE;IAC7CvB,KAAK,EAAEF,WAAY;IACnBkD,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC"}
1
+ {"version":3,"names":["React","useEffect","useImperativeHandle","useRef","useState","View","PageMessage","UnitMessage","EventBus","WebComponent","getAccountParams","getAccountScript","injectOpenActionsMenuScript","injectRefreshEventIfNeeded","injectRequestAccountActionScript","useListenerToBus","AccountMessage","RESPONSE_KEYS","BottomSheetRenderingType","PresentationMode","WebComponentType","BottomSheetNativeMessage","AccountAction","UNAccountComponent","forwardRef","props","accountRef","height","setHeight","requestRefreshEvent","setRequestRefreshEvent","webRef","handleAccountChanged","account","onAccountChanged","requestRefresh","data","handleUnitOnLoad","response","onLoad","errors","console","error","busEventKey","UNIT_REQUEST_REFRESH","action","UNIT_ACCOUNT_CHANGED","current","openActionsMenu","openAction","handleMessage","message","type","UNIT_ON_LOAD","details","UNIT_REQUEST_RENDERING","slotData","componentName","componentResourceId","accountId","requestRenderingEvent","event","Slot","Instance","START_FLOW","PAGE_HEIGHT","createElement","style","width","ref","presentationMode","Default","params","script","theme","language","onMessage","isScrollable"],"sources":["UNAccountComponent.tsx"],"sourcesContent":["import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { 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 } from '../../webComponent/WebComponent';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getAccountParams, getAccountScript, injectOpenActionsMenuScript, injectRefreshEventIfNeeded, injectRequestAccountActionScript } from './UNAccountComponent.utils';\nimport type { UNError, UNOnLoadResponse, UNOnLoadResponseData } from '../../types/shared';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { UNAccountData } from '../../types/shared/account.types';\nimport { AccountMessage } from '../../messages/webMessages/accountMessage';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport type { UNAccountMenuAction } from '../../types/shared';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\n\nexport interface UNAccountComponentProps {\n // inputs\n accountId?: string;\n customerToken: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideSelectionMenuButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<[UNAccountData]>) => void;\n onAccountChanged?: (account: UNAccountData) => void;\n}\n\nexport interface UNAccountRef {\n openActionsMenu: () => void;\n openAction: (action: UNAccountMenuAction) => void;\n}\n\nexport enum AccountAction {\n List = 'account-list',\n Menu = 'account-menu'\n}\n\nexport const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountComponentProps>(function UNAccountComponent(props, accountRef) {\n const [height, setHeight] = useState(0);\n\n const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);\n\n const webRef = useRef<WebView>(null);\n\n const handleAccountChanged = (account: UNAccountData) => {\n props.onAccountChanged && props.onAccountChanged(account);\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n setRequestRefreshEvent(data);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.account in response) {\n // AccountsOnLoadResponse;\n props.onLoad(response[RESPONSE_KEYS.account] as UNOnLoadResponseData<[UNAccountData]>);\n return;\n }\n\n console.error('On Load Error: unexpected response type.');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: AccountMessage.UNIT_ACCOUNT_CHANGED, action: handleAccountChanged });\n\n useEffect(() => {\n injectRefreshEventIfNeeded(webRef.current, requestRefreshEvent);\n }, [requestRefreshEvent]);\n\n useImperativeHandle(accountRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNAccountMenuAction) {\n injectRequestAccountActionScript(webRef.current, action);\n }\n }));\n\n const handleMessage = (message: WebViewMessage) => {\n switch (message.type) {\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.account,\n componentResourceId: props.accountId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n }\n };\n\n return (\n <View style={{ height, width: '100%' }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.account}\n presentationMode={PresentationMode.Default}\n params={getAccountParams(props)}\n script={getAccountScript()}\n theme={props.theme}\n language={props.language}\n onMessage={message => handleMessage(message)}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/E,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAAsBC,WAAW,QAAQ,yCAAyC;AAClF,SAAqDC,WAAW,QAAQ,yCAAyC;AACjH,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,SAASC,YAAY,QAAQ,iCAAiC;AAE9D,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,2BAA2B,EAAEC,0BAA0B,EAAEC,gCAAgC,QAAQ,4BAA4B;AAE1K,SAASC,gBAAgB,QAAQ,2BAA2B;AAE5D,SAASC,cAAc,QAAQ,2CAA2C;AAC1E,SAASC,aAAa,QAAiC,0CAA0C;AAEjG,SAASC,wBAAwB,QAAiD,wCAAwC;AAC1H,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,yCAAyC;AAC5F,SAASC,wBAAwB,QAAQ,kDAAkD;AAuB3F,WAAYC,aAAa;AAGxB,WAHWA,aAAa;EAAbA,aAAa;EAAbA,aAAa;AAAA,GAAbA,aAAa,KAAbA,aAAa;AAKzB,OAAO,MAAMC,kBAAkB,gBAAGvB,KAAK,CAACwB,UAAU,CAAwC,SAASD,kBAAkBA,CAACE,KAAK,EAAEC,UAAU,EA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K,CAAE;IAChCgD,MAAM,EAAE9D,gBAAgB,EAAG;IAC3B+D,KAAK,EAAEjD,KAAK,CAACiD,KAAM;IACnBC,QAAQ,EAAElD,KAAK,CAACkD,QAAS;IACzBC,SAAS,EAAEzB,OAAO,IAAID,aAAa,CAACC,OAAO,CAAE;IAC7C0B,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import React, { useImperativeHandle, useRef, useState, useEffect } from 'react';
2
- import { Dimensions, View } from 'react-native';
2
+ import { View } from 'react-native';
3
3
  import { PageMessage } from '../../messages/webMessages/pageMessage';
4
4
  import { UnitMessage } from '../../messages/webMessages/unitMessages';
5
5
  import EventBus from '../../helpers/EventBus';
@@ -14,7 +14,6 @@ import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
14
14
  import { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';
15
15
  export const UNCardComponent = /*#__PURE__*/React.forwardRef(function UNCardComponent(props, cardRef) {
16
16
  const [height, setHeight] = useState(0);
17
- const windowWidth = Dimensions.get('window').width;
18
17
  const webRef = useRef(null);
19
18
  useImperativeHandle(cardRef, () => ({
20
19
  openActionsMenu() {
@@ -100,7 +99,8 @@ export const UNCardComponent = /*#__PURE__*/React.forwardRef(function UNCardComp
100
99
  }, [props.pushProvisioningModule]);
101
100
  return /*#__PURE__*/React.createElement(View, {
102
101
  style: {
103
- height
102
+ height,
103
+ width: '100%'
104
104
  }
105
105
  }, /*#__PURE__*/React.createElement(WebComponent, {
106
106
  ref: webRef,
@@ -111,7 +111,6 @@ export const UNCardComponent = /*#__PURE__*/React.forwardRef(function UNCardComp
111
111
  language: props.language,
112
112
  script: getCardScript(),
113
113
  onMessage: message => handleMessage(message),
114
- width: windowWidth,
115
114
  isScrollable: false
116
115
  }));
117
116
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","useImperativeHandle","useRef","useState","useEffect","Dimensions","View","PageMessage","UnitMessage","EventBus","WebComponent","useListenerToBus","getCardParams","getCardScript","injectRefreshEventIfNeeded","injectOpenActionsMenuScript","injectRequestCardActionScript","CardMessage","RESPONSE_KEYS","BottomSheetRenderingType","PresentationMode","WebComponentType","UnitSDK","BottomSheetNativeMessage","UNCardComponent","forwardRef","props","cardRef","height","setHeight","windowWidth","get","width","webRef","openActionsMenu","current","openAction","action","cardStatusChanged","card","onStatusChanged","cardActivated","onCardActivated","requestRefresh","data","cardId","handleUnitOnLoad","response","onLoad","errors","console","error","busEventKey","UNIT_REQUEST_REFRESH","CARD_STATUS_CHANGED","CARD_ACTIVATED","handleMessage","message","details","type","UNIT_REQUEST_RENDERING","slotData","componentName","componentResourceId","requestRenderingEvent","event","Slot","Instance","START_FLOW","PAGE_HEIGHT","UNIT_ON_LOAD","setCustomerToken","customerToken","pushProvisioningModule","setPushProvisioningModule","createElement","style","ref","presentationMode","Default","params","theme","language","script","onMessage","isScrollable"],"sources":["UNCardComponent.tsx"],"sourcesContent":["import React, { useImperativeHandle, useRef, useState, useEffect } 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 } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getCardParams, getCardScript, injectRefreshEventIfNeeded, injectOpenActionsMenuScript, injectRequestCardActionScript } from './UNCardComponent.utils';\nimport type { UNOnLoadResponse, UNCardData, UNError, UNCardMenuAction } from '../../types/shared';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\nimport type { NativeModules } from 'react-native';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\nexport interface UNCardComponentProps {\n // inputs\n cardId: string;\n customerToken: string;\n learnMoreUrl?: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideCardTitle?: boolean;\n hideSensitiveDataButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<UNCardData>) => void\n onStatusChanged?: (card: UNCardData) => void;\n onCardActivated?: (card: UNCardData) => void;\n pushProvisioningModule?: typeof NativeModules;\n}\nexport interface CardRef {\n openActionsMenu: () => void;\n openAction: (action: UNCardMenuAction) => void;\n}\n\nexport const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(function UNCardComponent(props, cardRef) {\n const [height, setHeight] = useState(0);\n const windowWidth = Dimensions.get('window').width;\n\n const webRef = useRef<WebView>(null);\n\n useImperativeHandle(cardRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNCardMenuAction) {\n injectRequestCardActionScript(webRef.current, action);\n }\n }));\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const cardActivated = (card: UNCardData) => {\n if (props.onCardActivated) {\n props.onCardActivated(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n injectRefreshEventIfNeeded(webRef.current, data, props.cardId);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.card in response) {\n // CardOnLoadResponse\n props.onLoad(response[RESPONSE_KEYS.card] as UNOnLoadResponse<UNCardData>);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged });\n useListenerToBus({ busEventKey: CardMessage.CARD_ACTIVATED, action: cardActivated });\n\n const handleMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.card,\n componentResourceId: props.cardId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n }\n };\n\n useEffect(() => {\n UnitSDK.setCustomerToken(props.customerToken);\n }, [props.customerToken]);\n\n useEffect(() => {\n if (props.pushProvisioningModule) {\n UnitSDK.setPushProvisioningModule(props.pushProvisioningModule);\n }\n }, [props.pushProvisioningModule]);\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 language={props.language}\n script={getCardScript()}\n onMessage={message => handleMessage(message)}\n width={windowWidth}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAC/E,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,SAAsBC,WAAW,QAAQ,wCAAwC;AACjF,SAAqDC,WAAW,QAAQ,yCAAyC;AACjH,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,SAASC,YAAY,QAAQ,iCAAiC;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,KAAK,EAAEF,WAAY;IACnBuD,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC"}
1
+ {"version":3,"names":["React","useImperativeHandle","useRef","useState","useEffect","View","PageMessage","UnitMessage","EventBus","WebComponent","useListenerToBus","getCardParams","getCardScript","injectRefreshEventIfNeeded","injectOpenActionsMenuScript","injectRequestCardActionScript","CardMessage","RESPONSE_KEYS","BottomSheetRenderingType","PresentationMode","WebComponentType","UnitSDK","BottomSheetNativeMessage","UNCardComponent","forwardRef","props","cardRef","height","setHeight","webRef","openActionsMenu","current","openAction","action","cardStatusChanged","card","onStatusChanged","cardActivated","onCardActivated","requestRefresh","data","cardId","handleUnitOnLoad","response","onLoad","errors","console","error","busEventKey","UNIT_REQUEST_REFRESH","CARD_STATUS_CHANGED","CARD_ACTIVATED","handleMessage","message","details","type","UNIT_REQUEST_RENDERING","slotData","componentName","componentResourceId","requestRenderingEvent","event","Slot","Instance","START_FLOW","PAGE_HEIGHT","UNIT_ON_LOAD","setCustomerToken","customerToken","pushProvisioningModule","setPushProvisioningModule","createElement","style","width","ref","presentationMode","Default","params","theme","language","script","onMessage","isScrollable"],"sources":["UNCardComponent.tsx"],"sourcesContent":["import React, { useImperativeHandle, useRef, useState, useEffect } from 'react';\nimport { 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 } from '../../webComponent/WebComponent';\nimport { useListenerToBus } from '../../hooks/listenerToBus';\nimport type { WebViewMessage } from '../../messages/webMessages';\nimport { getCardParams, getCardScript, injectRefreshEventIfNeeded, injectOpenActionsMenuScript, injectRequestCardActionScript } from './UNCardComponent.utils';\nimport type { UNOnLoadResponse, UNCardData, UNError, UNCardMenuAction } from '../../types/shared';\nimport { CardMessage } from '../../messages/webMessages/cardMessage';\nimport type { NativeModules } from 'react-native';\nimport { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';\nimport { BottomSheetRenderingType, SlotRendering, type BottomSheetSlotData } from '../../types/internal/bottomSheet.types';\nimport { PresentationMode, WebComponentType } from '../../types/internal/webComponent.types';\nimport { UnitSDK } from '../../unitSdkManager/UnitSdkManager';\nimport { BottomSheetNativeMessage } from '../../messages/nativeMessages/bottomSheetMessage';\nexport interface UNCardComponentProps {\n // inputs\n cardId: string;\n customerToken: string;\n learnMoreUrl?: string;\n\n // ui\n theme?: string;\n language?: string;\n hideActionsMenuButton?: boolean;\n hideCardTitle?: boolean;\n hideSensitiveDataButton?: boolean;\n\n // events\n onLoad?: (response: UNOnLoadResponse<UNCardData>) => void\n onStatusChanged?: (card: UNCardData) => void;\n onCardActivated?: (card: UNCardData) => void;\n pushProvisioningModule?: typeof NativeModules;\n}\nexport interface CardRef {\n openActionsMenu: () => void;\n openAction: (action: UNCardMenuAction) => void;\n}\n\nexport const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(function UNCardComponent(props, cardRef) {\n const [height, setHeight] = useState(0);\n\n const webRef = useRef<WebView>(null);\n\n useImperativeHandle(cardRef, () => ({\n openActionsMenu() {\n injectOpenActionsMenuScript(webRef.current);\n },\n openAction(action: UNCardMenuAction) {\n injectRequestCardActionScript(webRef.current, action);\n }\n }));\n\n const cardStatusChanged = (card: UNCardData) => {\n if (props.onStatusChanged) {\n props.onStatusChanged(card);\n }\n };\n\n const cardActivated = (card: UNCardData) => {\n if (props.onCardActivated) {\n props.onCardActivated(card);\n }\n };\n\n const requestRefresh = (data: RequestRefreshEvent) => {\n injectRefreshEventIfNeeded(webRef.current, data, props.cardId);\n };\n\n const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {\n if (!props.onLoad) {\n return;\n }\n\n if (RESPONSE_KEYS.errors in response) {\n props.onLoad(response as UNError);\n return;\n }\n\n if (RESPONSE_KEYS.card in response) {\n // CardOnLoadResponse\n props.onLoad(response[RESPONSE_KEYS.card] as UNOnLoadResponse<UNCardData>);\n return;\n }\n\n console.error('On Load Error: unexpected response type');\n return;\n };\n\n useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });\n useListenerToBus({ busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged });\n useListenerToBus({ busEventKey: CardMessage.CARD_ACTIVATED, action: cardActivated });\n\n const handleMessage = (message: WebViewMessage) => {\n if (!message || !message.details) return;\n\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_RENDERING: {\n const slotData: BottomSheetSlotData = {\n componentName: WebComponentType.card,\n componentResourceId: props.cardId,\n requestRenderingEvent: message.details as RequestRenderingEvent\n };\n\n const event = {\n type: BottomSheetRenderingType.Slot,\n data: slotData\n } as SlotRendering;\n\n EventBus.Instance.event(BottomSheetNativeMessage.START_FLOW, event);\n break;\n }\n case PageMessage.PAGE_HEIGHT:\n setHeight((message.details as HeightEvent).height);\n break;\n case UnitMessage.UNIT_ON_LOAD:\n handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);\n break;\n }\n };\n\n useEffect(() => {\n UnitSDK.setCustomerToken(props.customerToken);\n }, [props.customerToken]);\n\n useEffect(() => {\n if (props.pushProvisioningModule) {\n UnitSDK.setPushProvisioningModule(props.pushProvisioningModule);\n }\n }, [props.pushProvisioningModule]);\n\n return (\n <View style={{ height, width: '100%' }}>\n <WebComponent\n ref={webRef}\n type={WebComponentType.card}\n presentationMode={PresentationMode.Default}\n params={getCardParams(props)}\n theme={props.theme}\n language={props.language}\n script={getCardScript()}\n onMessage={message => handleMessage(message)}\n isScrollable={false}\n />\n </View>\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAC/E,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAAsBC,WAAW,QAAQ,wCAAwC;AACjF,SAAqDC,WA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,OAAO,CAAE;IAC7C6B,YAAY,EAAE;EAAM,EACpB,CACG;AAEX,CAAC,CAAC"}
@@ -20,7 +20,6 @@ export const WebComponent = /*#__PURE__*/React.forwardRef(function WebComponent(
20
20
  const [componentCurrentTheme, setComponentCurrentTheme] = useState(props.theme ?? UnitSDK.getTheme());
21
21
  const [componentCurrentLanguage, setComponentCurrentLanguage] = useState(props.language ?? UnitSDK.getLanguage());
22
22
  const [baseName, setBaseName] = useState();
23
- const width = props.width ?? '100%';
24
23
  const updateUnitScript = data => {
25
24
  setUnitScript(data.unitScript);
26
25
  };
@@ -104,7 +103,7 @@ export const WebComponent = /*#__PURE__*/React.forwardRef(function WebComponent(
104
103
  overScrollMode: "never",
105
104
  injectedJavaScript: unitScript,
106
105
  style: {
107
- width: width,
106
+ width: '100%',
108
107
  flex: 1,
109
108
  opacity: 0.99,
110
109
  backgroundColor: 'transparent'
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useState","NativeModules","Platform","WebView","EventBus","html","HTML_PLACEHOLDER","UnitMessage","useListenerToBus","getHtmlBody","fetchUnitScript","globalUnitScript","UnitSDK","SDKMessage","handleRequestDownload","UNAppInfo","WebComponent","forwardRef","props","webRef","unitScript","setUnitScript","sourceHtml","setSourceHtml","componentCurrentTheme","setComponentCurrentTheme","theme","getTheme","componentCurrentLanguage","setComponentCurrentLanguage","language","getLanguage","baseName","setBaseName","width","updateUnitScript","data","updateInitializedParams","busEventKey","IS_SCRIPT_FETCHED","action","IS_SDK_INITIALIZED","getAppName","OS","name","getBundleName","replace","error","console","themeParam","languageParam","componentParams","params","newHtml","BODY","type","valueOf","presentationMode","SCRIPT_FROM_NATIVE","script","WINDOW_PARAMS","windowParams","onMessage","e","message","JSON","parse","nativeEvent","UNIT_REQUEST_REFRESH","details","Instance","event","UNIT_REQUEST_DOWNLOAD","UNIT_REQUEST_CLOSE_FLOW","_onScroll","handleScroll","createElement","ref","originWhitelist","mediaPlaybackRequiresUserAction","allowsInlineMediaPlayback","cacheEnabled","scrollEnabled","isScrollable","nestedScrollEnabled","onScroll","overScrollMode","injectedJavaScript","style","flex","opacity","backgroundColor","source","baseUrl","androidHardwareAccelerationDisabled"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react';\nimport { NativeModules, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage, RequestDownloadEvent } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport { getHtmlBody } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { UnitSDK } from '../unitSdkManager/UnitSdkManager';\nimport type { WebViewMessage } from '../messages/webMessages';\nimport { SDKMessage, SdkScriptFetched } from '../messages/nativeMessages/sdkMessage';\nimport { handleRequestDownload } from './WebComponent.utils';\nimport type { PresentationMode, WebComponentType } from '../types/internal/webComponent.types';\n\nconst { UNAppInfo } = NativeModules;\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n theme?: string;\n language?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n nestedScrollEnabled?: boolean,\n handleScroll?: (event: any) => void,\n width?: number;\n windowParams?: string;\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 [componentCurrentLanguage, setComponentCurrentLanguage] = useState<string | undefined>(props.language ?? UnitSDK.getLanguage());\n const [baseName, setBaseName] = useState<string>();\n const width = props.width ?? '100%';\n\n const updateUnitScript = (data: SdkScriptFetched) => {\n setUnitScript(data.unitScript);\n };\n\n const updateInitializedParams = () => {\n setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());\n setComponentCurrentLanguage(props.language ?? UnitSDK.getLanguage());\n };\n\n useListenerToBus({ busEventKey: SDKMessage.IS_SCRIPT_FETCHED, action: updateUnitScript });\n useListenerToBus({ busEventKey: SDKMessage.IS_SDK_INITIALIZED, action: updateInitializedParams });\n\n useEffect(() => {\n\n const getAppName = async () => {\n // For iOS, we extend the app name from the HTML to display a prettier access request message.\n // On Android, there is no request message sent from HTML.\n try {\n if (Platform.OS == 'ios') {\n const name = await UNAppInfo.getBundleName();\n setBaseName(name.replace(/ /g, '-'));\n } else { // android\n setBaseName('unit');\n }\n } catch (error: any) {\n console.error(error);\n }\n };\n\n getAppName();\n }, []);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n const themeParam = componentCurrentTheme ? ` theme=\"${componentCurrentTheme}\"` : '';\n const languageParam = componentCurrentLanguage ? ` language=\"${componentCurrentLanguage}\"` : '';\n\n const componentParams = (props.params || '') + themeParam + languageParam;\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 newHtml = newHtml.replace(HTML_PLACEHOLDER.WINDOW_PARAMS, props.windowParams || '');\n setSourceHtml(newHtml);\n }, [props.params, unitScript, props.presentationMode, componentCurrentTheme, componentCurrentLanguage, props.script, props.windowParams]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_REFRESH:\n message.details &&\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n break;\n case UnitMessage.UNIT_REQUEST_DOWNLOAD:\n message.details &&\n handleRequestDownload(message.details as RequestDownloadEvent, () => {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_CLOSE_FLOW, {});\n });\n break;\n default:\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 if (!baseName) {\n return null;\n }\n\n return (\n <WebView\n ref={webRef}\n originWhitelist={['*']}\n mediaPlaybackRequiresUserAction={false}\n allowsInlineMediaPlayback={true}\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, opacity: 0.99, backgroundColor: 'transparent' }}\n source={{ html: sourceHtml, baseUrl: `https://${baseName}` }}\n onMessage={onMessage}\n androidHardwareAccelerationDisabled\n />\n );\n});\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,OAAO,QAA6B,sBAAsB;AACnE,OAAOC,QAAQ,MAAM,qBAAqB;AAC1C,OAAOC,IAAI,IAAIC,gBAAgB,QAAQ,QAAQ;AAC/C,SAA8BC,WAAW,QAA8B,sCAAsC;AAC7G,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,+BAA+B;AACjF,SAASC,OAAO,QAAQ,kCAAkC;AAE1D,SAASC,UAAU,QAA0B,uCAAuC;AACpF,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,MAAM;EAAEC;AAAU,CAAC,GAAGd,aAAa;AAiBnC,OAAO,MAAMe,YAAY,gBAAGlB,KAAK,CAACmB,UAAU,CAA6B,SAASD,YAAYA,CAACE,KAAK,EAAEC,MAAM,EAAE;EAC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iE,YAAa;IAClCC,mBAAmB,EAAElE,KAAK,CAACkE,mBAAoB;IAC/CC,QAAQ,EAAEX,SAAU;IACpBY,cAAc,EAAC,OAAO;IACtBC,kBAAkB,EAAEnE,UAAW;IAC/BoE,KAAK,EAAE;MAAEtD,KAAK,EAAEA,KAAK;MAAEuD,IAAI,EAAE,CAAC;MAAEC,OAAO,EAAE,IAAI;MAAEC,eAAe,EAAE;IAAc,CAAE;IAChFC,MAAM,EAAE;MAAEvF,IAAI,EAAEiB,UAAU;MAAEuE,OAAO,EAAG,WAAU7D,QAAS;IAAE,CAAE;IAC7D8B,SAAS,EAAEA,SAAU;IACrBgC,mCAAmC;EAAA,EACnC;AAEN,CAAC,CAAC"}
1
+ {"version":3,"names":["React","useEffect","useState","NativeModules","Platform","WebView","EventBus","html","HTML_PLACEHOLDER","UnitMessage","useListenerToBus","getHtmlBody","fetchUnitScript","globalUnitScript","UnitSDK","SDKMessage","handleRequestDownload","UNAppInfo","WebComponent","forwardRef","props","webRef","unitScript","setUnitScript","sourceHtml","setSourceHtml","componentCurrentTheme","setComponentCurrentTheme","theme","getTheme","componentCurrentLanguage","setComponentCurrentLanguage","language","getLanguage","baseName","setBaseName","updateUnitScript","data","updateInitializedParams","busEventKey","IS_SCRIPT_FETCHED","action","IS_SDK_INITIALIZED","getAppName","OS","name","getBundleName","replace","error","console","themeParam","languageParam","componentParams","params","newHtml","BODY","type","valueOf","presentationMode","SCRIPT_FROM_NATIVE","script","WINDOW_PARAMS","windowParams","onMessage","e","message","JSON","parse","nativeEvent","UNIT_REQUEST_REFRESH","details","Instance","event","UNIT_REQUEST_DOWNLOAD","UNIT_REQUEST_CLOSE_FLOW","_onScroll","handleScroll","createElement","ref","originWhitelist","mediaPlaybackRequiresUserAction","allowsInlineMediaPlayback","cacheEnabled","scrollEnabled","isScrollable","nestedScrollEnabled","onScroll","overScrollMode","injectedJavaScript","style","width","flex","opacity","backgroundColor","source","baseUrl","androidHardwareAccelerationDisabled"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react';\nimport { NativeModules, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage, RequestDownloadEvent } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport { getHtmlBody } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { UnitSDK } from '../unitSdkManager/UnitSdkManager';\nimport type { WebViewMessage } from '../messages/webMessages';\nimport { SDKMessage, SdkScriptFetched } from '../messages/nativeMessages/sdkMessage';\nimport { handleRequestDownload } from './WebComponent.utils';\nimport type { PresentationMode, WebComponentType } from '../types/internal/webComponent.types';\n\nconst { UNAppInfo } = NativeModules;\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n theme?: string;\n language?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n nestedScrollEnabled?: boolean,\n handleScroll?: (event: any) => void,\n windowParams?: string;\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 [componentCurrentLanguage, setComponentCurrentLanguage] = useState<string | undefined>(props.language ?? UnitSDK.getLanguage());\n const [baseName, setBaseName] = useState<string>();\n\n const updateUnitScript = (data: SdkScriptFetched) => {\n setUnitScript(data.unitScript);\n };\n\n const updateInitializedParams = () => {\n setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());\n setComponentCurrentLanguage(props.language ?? UnitSDK.getLanguage());\n };\n\n useListenerToBus({ busEventKey: SDKMessage.IS_SCRIPT_FETCHED, action: updateUnitScript });\n useListenerToBus({ busEventKey: SDKMessage.IS_SDK_INITIALIZED, action: updateInitializedParams });\n\n useEffect(() => {\n\n const getAppName = async () => {\n // For iOS, we extend the app name from the HTML to display a prettier access request message.\n // On Android, there is no request message sent from HTML.\n try {\n if (Platform.OS == 'ios') {\n const name = await UNAppInfo.getBundleName();\n setBaseName(name.replace(/ /g, '-'));\n } else { // android\n setBaseName('unit');\n }\n } catch (error: any) {\n console.error(error);\n }\n };\n\n getAppName();\n }, []);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n const themeParam = componentCurrentTheme ? ` theme=\"${componentCurrentTheme}\"` : '';\n const languageParam = componentCurrentLanguage ? ` language=\"${componentCurrentLanguage}\"` : '';\n\n const componentParams = (props.params || '') + themeParam + languageParam;\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 newHtml = newHtml.replace(HTML_PLACEHOLDER.WINDOW_PARAMS, props.windowParams || '');\n setSourceHtml(newHtml);\n }, [props.params, unitScript, props.presentationMode, componentCurrentTheme, componentCurrentLanguage, props.script, props.windowParams]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n switch (message.type) {\n case UnitMessage.UNIT_REQUEST_REFRESH:\n message.details &&\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n break;\n case UnitMessage.UNIT_REQUEST_DOWNLOAD:\n message.details &&\n handleRequestDownload(message.details as RequestDownloadEvent, () => {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_CLOSE_FLOW, {});\n });\n break;\n default:\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 if (!baseName) {\n return null;\n }\n\n return (\n <WebView\n ref={webRef}\n originWhitelist={['*']}\n mediaPlaybackRequiresUserAction={false}\n allowsInlineMediaPlayback={true}\n cacheEnabled={false}\n scrollEnabled={props.isScrollable}\n nestedScrollEnabled={props.nestedScrollEnabled}\n onScroll={_onScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: '100%', flex: 1, opacity: 0.99, backgroundColor: 'transparent' }}\n source={{ html: sourceHtml, baseUrl: `https://${baseName}` }}\n onMessage={onMessage}\n androidHardwareAccelerationDisabled\n />\n );\n});\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,OAAO,QAA6B,sBAAsB;AACnE,OAAOC,QAAQ,MAAM,qBAAqB;AAC1C,OAAOC,IAAI,IAAIC,gBAAgB,QAAQ,QAAQ;AAC/C,SAA8BC,WAAW,QAA8B,sCAAsC;AAC7G,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,+BAA+B;AACjF,SAASC,OAAO,QAAQ,kCAAkC;AAE1D,SAASC,UAAU,QAA0B,uCAAuC;AACpF,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,MAAM;EAAEC;AAAU,CAAC,GAAGd,aAAa;AAgBnC,OAAO,MAAMe,YAAY,gBAAGlB,KAAK,CAACmB,UAAU,CAA6B,SAASD,YAAYA,CAACE,KAAK,EAAEC,MAAM,EAAE;EAC5G,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGrB,QAAQ,CAAqBW,gBAAgB,CAAC;EAClF,MAAM,CAACW,UAAU,EAAEC,aAAa,CAAC,GAAGvB,QAAQ,CAAgB,IAA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AEC,OAAO,EAAE,IAAI;MAAEC,eAAe,EAAE;IAAc,CAAE;IACjFC,MAAM,EAAE;MAAEvF,IAAI,EAAEiB,UAAU;MAAEuE,OAAO,EAAG,WAAU7D,QAAS;IAAE,CAAE;IAC7D6B,SAAS,EAAEA,SAAU;IACrBiC,mCAAmC;EAAA,EACnC;AAEN,CAAC,CAAC"}
@@ -13,7 +13,6 @@ export interface WebComponentProps {
13
13
  isScrollable?: boolean;
14
14
  nestedScrollEnabled?: boolean;
15
15
  handleScroll?: (event: any) => void;
16
- width?: number;
17
16
  windowParams?: string;
18
17
  }
19
18
  export declare const WebComponent: React.ForwardRefExoticComponent<WebComponentProps & React.RefAttributes<WebView<{}>>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unit-components",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Unit React Native components",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
2
- import { Dimensions, View } from 'react-native';
2
+ import { View } from 'react-native';
3
3
  import type WebView from 'react-native-webview';
4
4
  import { HeightEvent, PageMessage } from '../..//messages/webMessages/pageMessage';
5
5
  import { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
@@ -45,7 +45,6 @@ export enum AccountAction {
45
45
 
46
46
  export const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountComponentProps>(function UNAccountComponent(props, accountRef) {
47
47
  const [height, setHeight] = useState(0);
48
- const windowWidth = Dimensions.get('window').width;
49
48
 
50
49
  const [requestRefreshEvent, setRequestRefreshEvent] = useState<RequestRefreshEvent | null>(null);
51
50
 
@@ -122,7 +121,7 @@ export const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountCompon
122
121
  };
123
122
 
124
123
  return (
125
- <View style={{ height }}>
124
+ <View style={{ height, width: '100%' }}>
126
125
  <WebComponent
127
126
  ref={webRef}
128
127
  type={WebComponentType.account}
@@ -132,7 +131,6 @@ export const UNAccountComponent = React.forwardRef<UNAccountRef, UNAccountCompon
132
131
  theme={props.theme}
133
132
  language={props.language}
134
133
  onMessage={message => handleMessage(message)}
135
- width={windowWidth}
136
134
  isScrollable={false}
137
135
  />
138
136
  </View>
@@ -1,5 +1,5 @@
1
1
  import React, { useImperativeHandle, useRef, useState, useEffect } from 'react';
2
- import { Dimensions, View } from 'react-native';
2
+ import { View } from 'react-native';
3
3
  import type WebView from 'react-native-webview';
4
4
  import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
5
5
  import { RequestRefreshEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
@@ -42,7 +42,6 @@ export interface CardRef {
42
42
 
43
43
  export const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(function UNCardComponent(props, cardRef) {
44
44
  const [height, setHeight] = useState(0);
45
- const windowWidth = Dimensions.get('window').width;
46
45
 
47
46
  const webRef = useRef<WebView>(null);
48
47
 
@@ -134,7 +133,7 @@ export const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(f
134
133
  }, [props.pushProvisioningModule]);
135
134
 
136
135
  return (
137
- <View style={{ height }}>
136
+ <View style={{ height, width: '100%' }}>
138
137
  <WebComponent
139
138
  ref={webRef}
140
139
  type={WebComponentType.card}
@@ -144,7 +143,6 @@ export const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(f
144
143
  language={props.language}
145
144
  script={getCardScript()}
146
145
  onMessage={message => handleMessage(message)}
147
- width={windowWidth}
148
146
  isScrollable={false}
149
147
  />
150
148
  </View>
@@ -27,7 +27,6 @@ export interface WebComponentProps {
27
27
  isScrollable?: boolean,
28
28
  nestedScrollEnabled?: boolean,
29
29
  handleScroll?: (event: any) => void,
30
- width?: number;
31
30
  windowParams?: string;
32
31
  }
33
32
 
@@ -37,7 +36,6 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
37
36
  const [componentCurrentTheme, setComponentCurrentTheme] = useState<string | undefined>(props.theme ?? UnitSDK.getTheme());
38
37
  const [componentCurrentLanguage, setComponentCurrentLanguage] = useState<string | undefined>(props.language ?? UnitSDK.getLanguage());
39
38
  const [baseName, setBaseName] = useState<string>();
40
- const width = props.width ?? '100%';
41
39
 
42
40
  const updateUnitScript = (data: SdkScriptFetched) => {
43
41
  setUnitScript(data.unitScript);
@@ -131,7 +129,7 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
131
129
  onScroll={_onScroll}
132
130
  overScrollMode="never"
133
131
  injectedJavaScript={unitScript}
134
- style={{ width: width, flex: 1, opacity: 0.99, backgroundColor: 'transparent' }}
132
+ style={{ width: '100%', flex: 1, opacity: 0.99, backgroundColor: 'transparent' }}
135
133
  source={{ html: sourceHtml, baseUrl: `https://${baseName}` }}
136
134
  onMessage={onMessage}
137
135
  androidHardwareAccelerationDisabled