@nihinmedia/medgen-react-native 1.0.12 → 1.0.13
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.
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
exports.originOf = exports.isSameOrigin = exports.decideNavigation = exports.MedGenWebView = void 0;
|
|
7
|
+
exports.useIOSKeyboardOverlap = exports.originOf = exports.isSameOrigin = exports.decideNavigation = exports.MedGenWebView = void 0;
|
|
8
8
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
|
|
@@ -43,6 +43,27 @@ const originOf = u => {
|
|
|
43
43
|
|
|
44
44
|
exports.originOf = originOf;
|
|
45
45
|
|
|
46
|
+
const useIOSKeyboardOverlap = container => {
|
|
47
|
+
const [overlap, setOverlap] = (0, _react.useState)(0);
|
|
48
|
+
(0, _react.useEffect)(() => {
|
|
49
|
+
if (_reactNative.Platform.OS !== "ios") return undefined;
|
|
50
|
+
const change = _reactNative.Keyboard.addListener("keyboardWillChangeFrame", e => {
|
|
51
|
+
const keyboardTop = e.endCoordinates.screenY;
|
|
52
|
+
container.current?.measureInWindow((_x, y, _w, height) => {
|
|
53
|
+
setOverlap(Math.max(0, Math.round(y + height - keyboardTop)));
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
const hide = _reactNative.Keyboard.addListener("keyboardWillHide", () => setOverlap(0));
|
|
57
|
+
return () => {
|
|
58
|
+
change.remove();
|
|
59
|
+
hide.remove();
|
|
60
|
+
};
|
|
61
|
+
}, [ container ]);
|
|
62
|
+
return overlap;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.useIOSKeyboardOverlap = useIOSKeyboardOverlap;
|
|
66
|
+
|
|
46
67
|
const decideNavigation = (url, base, isTopFrame) => {
|
|
47
68
|
if (isSameOrigin(url, base)) return "load";
|
|
48
69
|
if (isTopFrame === false) return "block";
|
|
@@ -88,6 +109,8 @@ exports.isSameOrigin = isSameOrigin;
|
|
|
88
109
|
|
|
89
110
|
const MedGenWebView = ({url: url, handlers: handlers, capabilities: capabilities, onClose: onClose}) => {
|
|
90
111
|
const ref = (0, _react.useRef)(null);
|
|
112
|
+
const frameRef = (0, _react.useRef)(null);
|
|
113
|
+
const keyboardOverlap = useIOSKeyboardOverlap(frameRef);
|
|
91
114
|
const nonce = (0, _react.useMemo)(() => makeNonce(), [ url ]);
|
|
92
115
|
const isMedGenOrigin = (0, _react.useCallback)(target => isSameOrigin(target, (0,
|
|
93
116
|
_client.embedBase)()), []);
|
|
@@ -124,7 +147,12 @@ const MedGenWebView = ({url: url, handlers: handlers, capabilities: capabilities
|
|
|
124
147
|
nonce: nonce
|
|
125
148
|
});
|
|
126
149
|
}, [ isMedGenOrigin, handlers, capabilities, onClose, nonce ]);
|
|
127
|
-
return _react.default.createElement(
|
|
150
|
+
return _react.default.createElement(_reactNative.View, {
|
|
151
|
+
ref: frameRef,
|
|
152
|
+
style: [ styles.web, {
|
|
153
|
+
paddingBottom: keyboardOverlap
|
|
154
|
+
} ]
|
|
155
|
+
}, _react.default.createElement(WebView, {
|
|
128
156
|
ref: ref,
|
|
129
157
|
source: {
|
|
130
158
|
uri: url
|
|
@@ -184,7 +212,7 @@ const MedGenWebView = ({url: url, handlers: handlers, capabilities: capabilities
|
|
|
184
212
|
})),
|
|
185
213
|
bounces: false,
|
|
186
214
|
overScrollMode: "never"
|
|
187
|
-
});
|
|
215
|
+
}));
|
|
188
216
|
};
|
|
189
217
|
|
|
190
218
|
exports.MedGenWebView = MedGenWebView;
|
package/lib/commonjs/client.js
CHANGED
|
@@ -62,7 +62,7 @@ const ASSERTION_TIMEOUT_MS = 1e4;
|
|
|
62
62
|
|
|
63
63
|
const ATTESTATION_TIMEOUT_MS = 15e3;
|
|
64
64
|
|
|
65
|
-
const SDK_VERSION = exports.SDK_VERSION = "1.0.
|
|
65
|
+
const SDK_VERSION = exports.SDK_VERSION = "1.0.13";
|
|
66
66
|
|
|
67
67
|
const DEFAULT_API = {
|
|
68
68
|
development: "https://dev.sugoimed.com",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { useCallback, useMemo, useRef } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import { ActivityIndicator, Linking, StyleSheet, View } from "react-native";
|
|
3
|
+
import { ActivityIndicator, Keyboard, Linking, Platform, StyleSheet, View } from "react-native";
|
|
4
4
|
|
|
5
5
|
import { WebView as RNWebView } from "react-native-webview";
|
|
6
6
|
|
|
@@ -15,6 +15,25 @@ export const originOf = u => {
|
|
|
15
15
|
return m ? m[0].toLowerCase() : "";
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export const useIOSKeyboardOverlap = container => {
|
|
19
|
+
const [overlap, setOverlap] = useState(0);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (Platform.OS !== "ios") return undefined;
|
|
22
|
+
const change = Keyboard.addListener("keyboardWillChangeFrame", e => {
|
|
23
|
+
const keyboardTop = e.endCoordinates.screenY;
|
|
24
|
+
container.current?.measureInWindow((_x, y, _w, height) => {
|
|
25
|
+
setOverlap(Math.max(0, Math.round(y + height - keyboardTop)));
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
const hide = Keyboard.addListener("keyboardWillHide", () => setOverlap(0));
|
|
29
|
+
return () => {
|
|
30
|
+
change.remove();
|
|
31
|
+
hide.remove();
|
|
32
|
+
};
|
|
33
|
+
}, [ container ]);
|
|
34
|
+
return overlap;
|
|
35
|
+
};
|
|
36
|
+
|
|
18
37
|
export const decideNavigation = (url, base, isTopFrame) => {
|
|
19
38
|
if (isSameOrigin(url, base)) return "load";
|
|
20
39
|
if (isTopFrame === false) return "block";
|
|
@@ -56,6 +75,8 @@ export const isSameOrigin = (target, base) => {
|
|
|
56
75
|
|
|
57
76
|
export const MedGenWebView = ({url: url, handlers: handlers, capabilities: capabilities, onClose: onClose}) => {
|
|
58
77
|
const ref = useRef(null);
|
|
78
|
+
const frameRef = useRef(null);
|
|
79
|
+
const keyboardOverlap = useIOSKeyboardOverlap(frameRef);
|
|
59
80
|
const nonce = useMemo(() => makeNonce(), [ url ]);
|
|
60
81
|
const isMedGenOrigin = useCallback(target => isSameOrigin(target, embedBase()), []);
|
|
61
82
|
const onShouldStartLoadWithRequest = useCallback(req => {
|
|
@@ -91,7 +112,12 @@ export const MedGenWebView = ({url: url, handlers: handlers, capabilities: capab
|
|
|
91
112
|
nonce: nonce
|
|
92
113
|
});
|
|
93
114
|
}, [ isMedGenOrigin, handlers, capabilities, onClose, nonce ]);
|
|
94
|
-
return React.createElement(
|
|
115
|
+
return React.createElement(View, {
|
|
116
|
+
ref: frameRef,
|
|
117
|
+
style: [ styles.web, {
|
|
118
|
+
paddingBottom: keyboardOverlap
|
|
119
|
+
} ]
|
|
120
|
+
}, React.createElement(WebView, {
|
|
95
121
|
ref: ref,
|
|
96
122
|
source: {
|
|
97
123
|
uri: url
|
|
@@ -151,7 +177,7 @@ export const MedGenWebView = ({url: url, handlers: handlers, capabilities: capab
|
|
|
151
177
|
})),
|
|
152
178
|
bounces: false,
|
|
153
179
|
overScrollMode: "never"
|
|
154
|
-
});
|
|
180
|
+
}));
|
|
155
181
|
};
|
|
156
182
|
|
|
157
183
|
const styles = StyleSheet.create({
|
package/lib/module/client.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
2
3
|
import { MedGenCapabilities, MedGenNativeHandlers } from './types';
|
|
3
4
|
|
|
4
5
|
export declare const originOf: (u: string) => string;
|
|
5
6
|
|
|
7
|
+
export declare const useIOSKeyboardOverlap: (container: React.RefObject<View>) => number;
|
|
6
8
|
export type NavigationDecision = 'load' | 'external' | 'block';
|
|
7
9
|
export declare const decideNavigation: (url: string, base: string, isTopFrame?: boolean) => NavigationDecision;
|
|
8
10
|
|