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.
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +39 -8
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +0 -3
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +41 -10
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -3
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +1 -0
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +0 -3
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/index.js +1 -0
- package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +8 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +17 -4
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +33 -7
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +0 -2
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +36 -9
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -2
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js +1 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +0 -2
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/messages/nativeMessages/index.js +1 -0
- package/lib/module/messages/nativeMessages/index.js.map +1 -1
- package/lib/module/scripts/html/bodyHtml.js +1 -1
- package/lib/module/scripts/html/bodyHtml.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdkManager.js +3 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +15 -4
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/typescript/messages/nativeMessages/index.d.ts +2 -1
- package/lib/typescript/webComponent/WebComponent.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +33 -7
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +0 -2
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +35 -9
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +0 -2
- package/src/components/UNCardComponent/UNCardComponent.tsx +1 -0
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +0 -2
- package/src/messages/nativeMessages/index.ts +2 -1
- package/src/scripts/html/bodyHtml.ts +1 -1
- package/src/unitSdkManager/UnitSdkManager.ts +3 -0
- 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
|
|
40
|
+
const updateUnitScript = (data: { unitScript?: string }) => {
|
|
37
41
|
setUnitScript(data.unitScript);
|
|
38
42
|
};
|
|
39
43
|
|
|
40
|
-
|
|
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
|
-
|
|
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}
|