react-native-unit-components 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +39 -8
  2. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  3. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +0 -3
  4. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  5. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +41 -10
  6. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  7. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -3
  8. package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  9. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +1 -0
  10. package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
  11. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +0 -3
  12. package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  13. package/lib/commonjs/messages/nativeMessages/index.js +1 -0
  14. package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
  15. package/lib/commonjs/scripts/html/bodyHtml.js +1 -1
  16. package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
  17. package/lib/commonjs/unitSdkManager/UnitSdkManager.js +8 -0
  18. package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
  19. package/lib/commonjs/webComponent/WebComponent.js +17 -4
  20. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  21. package/lib/module/components/UNActivityComponent/UNActivityComponent.js +33 -7
  22. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  23. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +0 -2
  24. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  25. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +36 -9
  26. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
  27. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -2
  28. package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
  29. package/lib/module/components/UNCardComponent/UNCardComponent.js +1 -0
  30. package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
  31. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +0 -2
  32. package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
  33. package/lib/module/messages/nativeMessages/index.js +1 -0
  34. package/lib/module/messages/nativeMessages/index.js.map +1 -1
  35. package/lib/module/scripts/html/bodyHtml.js +1 -1
  36. package/lib/module/scripts/html/bodyHtml.js.map +1 -1
  37. package/lib/module/unitSdkManager/UnitSdkManager.js +3 -0
  38. package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
  39. package/lib/module/webComponent/WebComponent.js +15 -4
  40. package/lib/module/webComponent/WebComponent.js.map +1 -1
  41. package/lib/typescript/messages/nativeMessages/index.d.ts +2 -1
  42. package/lib/typescript/webComponent/WebComponent.d.ts +2 -0
  43. package/package.json +1 -1
  44. package/src/components/UNActivityComponent/UNActivityComponent.tsx +33 -7
  45. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +0 -2
  46. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +35 -9
  47. package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +0 -2
  48. package/src/components/UNCardComponent/UNCardComponent.tsx +1 -0
  49. package/src/components/UNCardComponent/UNCardComponent.utils.ts +0 -2
  50. package/src/messages/nativeMessages/index.ts +2 -1
  51. package/src/scripts/html/bodyHtml.ts +1 -1
  52. package/src/unitSdkManager/UnitSdkManager.ts +3 -0
  53. package/src/webComponent/WebComponent.tsx +17 -5
@@ -8,15 +8,18 @@ import { useListenerToBus } from '../hooks/listenerToBus';
8
8
  import { getHtmlBody, PresentationMode } from '../scripts/html/bodyHtml';
9
9
  import { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';
10
10
  import { NativeMessage } from '../messages/nativeMessages';
11
+ import { UnitSDK } from '../unitSdkManager/UnitSdkManager';
11
12
  import type { WebViewMessage } from '../messages/webMessages';
12
13
 
13
14
  export interface WebComponentProps {
14
15
  type: WebComponentType;
15
16
  presentationMode?: PresentationMode,
16
17
  params?: string;
18
+ theme?: string;
17
19
  onMessage?: (message: WebViewMessage) => void;
18
20
  script?: string;
19
21
  isScrollable?: boolean,
22
+ nestedScrollEnabled?: boolean,
20
23
  handleScroll?: (event: any) => void,
21
24
  width?: number;
22
25
  }
@@ -31,13 +34,21 @@ export enum WebComponentType {
31
34
  export const WebComponent = React.forwardRef<WebView, WebComponentProps>(function WebComponent(props, webRef) {
32
35
  const [unitScript, setUnitScript] = useState<string | undefined>(globalUnitScript);
33
36
  const [sourceHtml, setSourceHtml] = useState<string | null>(null);
37
+ const [componentCurrentTheme, setComponentCurrentTheme] = useState<string | undefined>(props.theme ?? UnitSDK.getTheme());
34
38
  const width = props.width ?? '100%';
35
39
 
36
- const listenerAction = (data: { unitScript?: string }) => {
40
+ const updateUnitScript = (data: { unitScript?: string }) => {
37
41
  setUnitScript(data.unitScript);
38
42
  };
39
43
 
40
- useListenerToBus([{ busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: listenerAction }]);
44
+ const updateInitializedParams = () => {
45
+ setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());
46
+ };
47
+
48
+ useListenerToBus([
49
+ { busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: updateUnitScript },
50
+ { busEventKey: NativeMessage.IS_SDK_INITIALIZED, action: updateInitializedParams },
51
+ ]);
41
52
 
42
53
  useEffect(() => {
43
54
  if (!unitScript) {
@@ -45,11 +56,11 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
45
56
  return;
46
57
  }
47
58
 
48
- let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), props.params, props.presentationMode));
59
+ const componentParams = (props.params || '') + (componentCurrentTheme ? ` theme="${componentCurrentTheme}"` : '');
60
+ let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), componentParams, props.presentationMode));
49
61
  newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');
50
62
  setSourceHtml(newHtml);
51
-
52
- }, [props.params, unitScript]);
63
+ }, [props.params, unitScript, props.presentationMode, componentCurrentTheme]);
53
64
 
54
65
  const onMessage = (e: WebViewMessageEvent) => {
55
66
  const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;
@@ -75,6 +86,7 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
75
86
  ref={webRef}
76
87
  cacheEnabled={false}
77
88
  scrollEnabled={props.isScrollable}
89
+ nestedScrollEnabled={props.nestedScrollEnabled}
78
90
  onScroll={_onScroll}
79
91
  overScrollMode="never"
80
92
  injectedJavaScript={unitScript}