@getuserfeedback/react-native 1.3.3 → 1.3.4
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/dist/index.js +12 -141
- package/dist/provider-widget-host-overlay.d.ts +15 -0
- package/dist/provider-widget-host-overlay.js +135 -0
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { parseWebViewTransportNativeMessage } from "@getuserfeedback/protocol/we
|
|
|
14
14
|
import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
15
15
|
import { useResolvedHostViewport } from "./host-viewport.js";
|
|
16
16
|
import { applyProviderOverlayFlowState, applyProviderOverlayHandleInvalidated, createDefaultProviderOverlayState, DEFAULT_PROVIDER_OVERLAY_VISIBILITY, updateProviderOverlayReadySequence, } from "./provider-overlay-state.js";
|
|
17
|
+
import { ProviderWidgetHostOverlay, toProviderWidgetHostStyle, toProviderWidgetSheetHostViewport, } from "./provider-widget-host-overlay.js";
|
|
17
18
|
import { REACT_NATIVE_SDK_VERSION } from "./version.js";
|
|
18
19
|
import { WidgetHost, } from "./widget-host.js";
|
|
19
20
|
export { REACT_NATIVE_SDK_VERSION } from "./version.js";
|
|
@@ -29,80 +30,6 @@ const CLIENT_META = {
|
|
|
29
30
|
loader: "sdk",
|
|
30
31
|
transport: "loader",
|
|
31
32
|
};
|
|
32
|
-
const HIDDEN_WIDGET_HOST_STYLE = {
|
|
33
|
-
height: 1,
|
|
34
|
-
left: -1,
|
|
35
|
-
opacity: 0,
|
|
36
|
-
position: "absolute",
|
|
37
|
-
top: -1,
|
|
38
|
-
width: 1,
|
|
39
|
-
};
|
|
40
|
-
const WIDGET_SHEET_OVERLAY_STYLE = {
|
|
41
|
-
bottom: 0,
|
|
42
|
-
left: 0,
|
|
43
|
-
position: "absolute",
|
|
44
|
-
right: 0,
|
|
45
|
-
top: 0,
|
|
46
|
-
zIndex: 2147483647,
|
|
47
|
-
};
|
|
48
|
-
const WIDGET_SHEET_BACKDROP_STYLE = {
|
|
49
|
-
backgroundColor: "rgba(15, 23, 42, 0.36)",
|
|
50
|
-
bottom: 0,
|
|
51
|
-
left: 0,
|
|
52
|
-
position: "absolute",
|
|
53
|
-
right: 0,
|
|
54
|
-
top: 0,
|
|
55
|
-
};
|
|
56
|
-
const WIDGET_SHEET_STYLE = {
|
|
57
|
-
backgroundColor: "#ffffff",
|
|
58
|
-
borderTopLeftRadius: 24,
|
|
59
|
-
borderTopRightRadius: 24,
|
|
60
|
-
bottom: 0,
|
|
61
|
-
left: 0,
|
|
62
|
-
overflow: "hidden",
|
|
63
|
-
position: "absolute",
|
|
64
|
-
right: 0,
|
|
65
|
-
shadowColor: "#000000",
|
|
66
|
-
shadowOffset: { height: -4, width: 0 },
|
|
67
|
-
shadowOpacity: 0.16,
|
|
68
|
-
shadowRadius: 18,
|
|
69
|
-
elevation: 18,
|
|
70
|
-
};
|
|
71
|
-
const VISIBLE_WIDGET_HOST_STYLE = {
|
|
72
|
-
flex: 1,
|
|
73
|
-
};
|
|
74
|
-
const VISIBLE_WIDGET_HOST_LAYOUT_STYLE_KEYS = new Set([
|
|
75
|
-
"alignSelf",
|
|
76
|
-
"bottom",
|
|
77
|
-
"display",
|
|
78
|
-
"end",
|
|
79
|
-
"flex",
|
|
80
|
-
"flexBasis",
|
|
81
|
-
"flexGrow",
|
|
82
|
-
"flexShrink",
|
|
83
|
-
"height",
|
|
84
|
-
"left",
|
|
85
|
-
"margin",
|
|
86
|
-
"marginBottom",
|
|
87
|
-
"marginEnd",
|
|
88
|
-
"marginHorizontal",
|
|
89
|
-
"marginLeft",
|
|
90
|
-
"marginRight",
|
|
91
|
-
"marginStart",
|
|
92
|
-
"marginTop",
|
|
93
|
-
"marginVertical",
|
|
94
|
-
"maxHeight",
|
|
95
|
-
"maxWidth",
|
|
96
|
-
"minHeight",
|
|
97
|
-
"minWidth",
|
|
98
|
-
"position",
|
|
99
|
-
"right",
|
|
100
|
-
"start",
|
|
101
|
-
"top",
|
|
102
|
-
"width",
|
|
103
|
-
]);
|
|
104
|
-
const DEFAULT_WIDGET_SHEET_HEIGHT_RATIO = 0.86;
|
|
105
|
-
const DEFAULT_WIDGET_SHEET_MIN_HEIGHT = 320;
|
|
106
33
|
const createUniqueId = (prefix) => {
|
|
107
34
|
if (typeof globalThis.crypto !== "undefined" &&
|
|
108
35
|
typeof globalThis.crypto.randomUUID === "function") {
|
|
@@ -150,39 +77,6 @@ function resolveNativeView() {
|
|
|
150
77
|
return FallbackNativeView;
|
|
151
78
|
}
|
|
152
79
|
}
|
|
153
|
-
function toSheetHostViewport(viewport) {
|
|
154
|
-
if (!viewport) {
|
|
155
|
-
return undefined;
|
|
156
|
-
}
|
|
157
|
-
const desiredHeight = Math.max(DEFAULT_WIDGET_SHEET_MIN_HEIGHT, Math.round(viewport.height * DEFAULT_WIDGET_SHEET_HEIGHT_RATIO));
|
|
158
|
-
return {
|
|
159
|
-
width: viewport.width,
|
|
160
|
-
height: Math.min(viewport.height, desiredHeight),
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function toVisibleWidgetHostPresentationStyle(style) {
|
|
164
|
-
if (style === undefined || style === null) {
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
if (Array.isArray(style)) {
|
|
168
|
-
const styles = style
|
|
169
|
-
.map(toVisibleWidgetHostPresentationStyle)
|
|
170
|
-
.filter((entry) => entry !== undefined && entry !== null);
|
|
171
|
-
return styles.length > 0 ? styles : undefined;
|
|
172
|
-
}
|
|
173
|
-
if (typeof style !== "object") {
|
|
174
|
-
return style;
|
|
175
|
-
}
|
|
176
|
-
const presentationStyle = {};
|
|
177
|
-
for (const [key, value] of Object.entries(style)) {
|
|
178
|
-
if (!VISIBLE_WIDGET_HOST_LAYOUT_STYLE_KEYS.has(key)) {
|
|
179
|
-
presentationStyle[key] = value;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return Object.keys(presentationStyle).length > 0
|
|
183
|
-
? presentationStyle
|
|
184
|
-
: undefined;
|
|
185
|
-
}
|
|
186
80
|
const toIdentifyCommandPayload = (identifyInput, traitsOrOptions, options) => {
|
|
187
81
|
if (typeof identifyInput === "string") {
|
|
188
82
|
assertNoSegmentExternalIdsInValueArgument({
|
|
@@ -247,7 +141,7 @@ const toCommandSettlementError = (event) => {
|
|
|
247
141
|
});
|
|
248
142
|
};
|
|
249
143
|
export function GetUserFeedbackProvider({ autoInit = true, children, commandTimeoutMs = DEFAULT_COMMAND_TIMEOUT_MS, configureOptions, hostViewport, instanceId: instanceIdProp, initOptions, loaderUrl, onCommandError, onInvalidWebMessage, onWebMessage, source, webViewComponent, webViewProps, }) {
|
|
250
|
-
var _a, _b
|
|
144
|
+
var _a, _b;
|
|
251
145
|
const NativeView = useMemo(resolveNativeView, []);
|
|
252
146
|
const [instanceId] = useState(() => { var _a; return (_a = normalizeOptionalString(instanceIdProp)) !== null && _a !== void 0 ? _a : createUniqueId("rn"); });
|
|
253
147
|
const [nativeMessages, setNativeMessages] = useState([]);
|
|
@@ -764,23 +658,14 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
764
658
|
widgetHostVisibility.hostSourceVersion === hostSourceVersionRef.current &&
|
|
765
659
|
widgetHostVisibility.sourceKey === ((_a = lastReadyRef.current) === null || _a === void 0 ? void 0 : _a.sourceKey) &&
|
|
766
660
|
widgetHostVisibility.readySequence === ((_b = lastReadyRef.current) === null || _b === void 0 ? void 0 : _b.readySequence);
|
|
767
|
-
const sheetHostViewport =
|
|
661
|
+
const sheetHostViewport = toProviderWidgetSheetHostViewport(hostViewport !== null && hostViewport !== void 0 ? hostViewport : resolvedHostViewport);
|
|
768
662
|
const widgetHostViewport = isWidgetHostVisible
|
|
769
663
|
? sheetHostViewport
|
|
770
664
|
: (hostViewport !== null && hostViewport !== void 0 ? hostViewport : resolvedHostViewport);
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
: HIDDEN_WIDGET_HOST_STYLE;
|
|
776
|
-
const visiblePresentationStyle = isWidgetHostVisible
|
|
777
|
-
? toVisibleWidgetHostPresentationStyle(webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.style)
|
|
778
|
-
: undefined;
|
|
779
|
-
const composedWebViewStyle = isWidgetHostVisible
|
|
780
|
-
? visiblePresentationStyle !== undefined
|
|
781
|
-
? [visiblePresentationStyle, widgetHostStyle]
|
|
782
|
-
: widgetHostStyle
|
|
783
|
-
: ((_c = webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.style) !== null && _c !== void 0 ? _c : widgetHostStyle);
|
|
665
|
+
const composedWebViewStyle = toProviderWidgetHostStyle({
|
|
666
|
+
isVisible: isWidgetHostVisible,
|
|
667
|
+
webViewStyle: webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.style,
|
|
668
|
+
});
|
|
784
669
|
const widgetHost = createElement(WidgetHost, {
|
|
785
670
|
hostViewport: widgetHostViewport,
|
|
786
671
|
instanceId,
|
|
@@ -795,25 +680,11 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
795
680
|
});
|
|
796
681
|
return createElement(GetUserFeedbackNativeContext.Provider, {
|
|
797
682
|
value: contextValue,
|
|
798
|
-
}, children, createElement(
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
testID: "gx-widget-host-overlay",
|
|
804
|
-
}, createElement(NativeView, {
|
|
805
|
-
pointerEvents: isWidgetHostVisible ? "auto" : "none",
|
|
806
|
-
style: isWidgetHostVisible
|
|
807
|
-
? WIDGET_SHEET_BACKDROP_STYLE
|
|
808
|
-
: HIDDEN_WIDGET_HOST_STYLE,
|
|
809
|
-
testID: "gx-widget-host-backdrop",
|
|
810
|
-
}), createElement(NativeView, {
|
|
811
|
-
pointerEvents: isWidgetHostVisible ? "auto" : "none",
|
|
812
|
-
style: isWidgetHostVisible
|
|
813
|
-
? widgetSheetStyle
|
|
814
|
-
: HIDDEN_WIDGET_HOST_STYLE,
|
|
815
|
-
testID: "gx-widget-host-sheet",
|
|
816
|
-
}, widgetHost)));
|
|
683
|
+
}, children, createElement(ProviderWidgetHostOverlay, {
|
|
684
|
+
isVisible: isWidgetHostVisible,
|
|
685
|
+
nativeView: NativeView,
|
|
686
|
+
sheetHostViewport,
|
|
687
|
+
}, widgetHost));
|
|
817
688
|
}
|
|
818
689
|
export function useGetUserFeedbackNative() {
|
|
819
690
|
const context = useContext(GetUserFeedbackNativeContext);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ComponentType, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { WidgetHostProps } from "./widget-host.js";
|
|
3
|
+
type NativeViewComponent = ComponentType<Record<string, unknown>>;
|
|
4
|
+
export declare function toProviderWidgetSheetHostViewport(viewport: WidgetHostProps["hostViewport"]): WidgetHostProps["hostViewport"];
|
|
5
|
+
export declare function toProviderWidgetHostStyle({ isVisible, webViewStyle, }: {
|
|
6
|
+
isVisible: boolean;
|
|
7
|
+
webViewStyle: unknown;
|
|
8
|
+
}): unknown;
|
|
9
|
+
export declare function ProviderWidgetHostOverlay({ children, isVisible, nativeView, sheetHostViewport, }: {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
isVisible: boolean;
|
|
12
|
+
nativeView: NativeViewComponent;
|
|
13
|
+
sheetHostViewport: WidgetHostProps["hostViewport"];
|
|
14
|
+
}): ReactElement;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { createElement, } from "react";
|
|
2
|
+
const HIDDEN_WIDGET_HOST_STYLE = {
|
|
3
|
+
height: 1,
|
|
4
|
+
left: -1,
|
|
5
|
+
opacity: 0,
|
|
6
|
+
position: "absolute",
|
|
7
|
+
top: -1,
|
|
8
|
+
width: 1,
|
|
9
|
+
};
|
|
10
|
+
const WIDGET_SHEET_OVERLAY_STYLE = {
|
|
11
|
+
bottom: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
position: "absolute",
|
|
14
|
+
right: 0,
|
|
15
|
+
top: 0,
|
|
16
|
+
zIndex: 2147483647,
|
|
17
|
+
};
|
|
18
|
+
const WIDGET_SHEET_BACKDROP_STYLE = {
|
|
19
|
+
backgroundColor: "rgba(15, 23, 42, 0.36)",
|
|
20
|
+
bottom: 0,
|
|
21
|
+
left: 0,
|
|
22
|
+
position: "absolute",
|
|
23
|
+
right: 0,
|
|
24
|
+
top: 0,
|
|
25
|
+
};
|
|
26
|
+
const WIDGET_SHEET_STYLE = {
|
|
27
|
+
backgroundColor: "#ffffff",
|
|
28
|
+
borderTopLeftRadius: 24,
|
|
29
|
+
borderTopRightRadius: 24,
|
|
30
|
+
bottom: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
overflow: "hidden",
|
|
33
|
+
position: "absolute",
|
|
34
|
+
right: 0,
|
|
35
|
+
shadowColor: "#000000",
|
|
36
|
+
shadowOffset: { height: -4, width: 0 },
|
|
37
|
+
shadowOpacity: 0.16,
|
|
38
|
+
shadowRadius: 18,
|
|
39
|
+
elevation: 18,
|
|
40
|
+
};
|
|
41
|
+
const VISIBLE_WIDGET_HOST_STYLE = {
|
|
42
|
+
flex: 1,
|
|
43
|
+
};
|
|
44
|
+
const VISIBLE_WIDGET_HOST_LAYOUT_STYLE_KEYS = new Set([
|
|
45
|
+
"alignSelf",
|
|
46
|
+
"bottom",
|
|
47
|
+
"display",
|
|
48
|
+
"end",
|
|
49
|
+
"flex",
|
|
50
|
+
"flexBasis",
|
|
51
|
+
"flexGrow",
|
|
52
|
+
"flexShrink",
|
|
53
|
+
"height",
|
|
54
|
+
"left",
|
|
55
|
+
"margin",
|
|
56
|
+
"marginBottom",
|
|
57
|
+
"marginEnd",
|
|
58
|
+
"marginHorizontal",
|
|
59
|
+
"marginLeft",
|
|
60
|
+
"marginRight",
|
|
61
|
+
"marginStart",
|
|
62
|
+
"marginTop",
|
|
63
|
+
"marginVertical",
|
|
64
|
+
"maxHeight",
|
|
65
|
+
"maxWidth",
|
|
66
|
+
"minHeight",
|
|
67
|
+
"minWidth",
|
|
68
|
+
"position",
|
|
69
|
+
"right",
|
|
70
|
+
"start",
|
|
71
|
+
"top",
|
|
72
|
+
"width",
|
|
73
|
+
]);
|
|
74
|
+
const DEFAULT_WIDGET_SHEET_HEIGHT_RATIO = 0.86;
|
|
75
|
+
const DEFAULT_WIDGET_SHEET_MIN_HEIGHT = 320;
|
|
76
|
+
export function toProviderWidgetSheetHostViewport(viewport) {
|
|
77
|
+
if (!viewport) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const desiredHeight = Math.max(DEFAULT_WIDGET_SHEET_MIN_HEIGHT, Math.round(viewport.height * DEFAULT_WIDGET_SHEET_HEIGHT_RATIO));
|
|
81
|
+
return {
|
|
82
|
+
width: viewport.width,
|
|
83
|
+
height: Math.min(viewport.height, desiredHeight),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function toVisibleWidgetHostPresentationStyle(style) {
|
|
87
|
+
if (style === undefined || style === null) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(style)) {
|
|
91
|
+
const styles = style
|
|
92
|
+
.map(toVisibleWidgetHostPresentationStyle)
|
|
93
|
+
.filter((entry) => entry !== undefined && entry !== null);
|
|
94
|
+
return styles.length > 0 ? styles : undefined;
|
|
95
|
+
}
|
|
96
|
+
if (typeof style !== "object") {
|
|
97
|
+
return style;
|
|
98
|
+
}
|
|
99
|
+
const presentationStyle = {};
|
|
100
|
+
for (const [key, value] of Object.entries(style)) {
|
|
101
|
+
if (!VISIBLE_WIDGET_HOST_LAYOUT_STYLE_KEYS.has(key)) {
|
|
102
|
+
presentationStyle[key] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return Object.keys(presentationStyle).length > 0
|
|
106
|
+
? presentationStyle
|
|
107
|
+
: undefined;
|
|
108
|
+
}
|
|
109
|
+
export function toProviderWidgetHostStyle({ isVisible, webViewStyle, }) {
|
|
110
|
+
if (!isVisible) {
|
|
111
|
+
return webViewStyle !== null && webViewStyle !== void 0 ? webViewStyle : HIDDEN_WIDGET_HOST_STYLE;
|
|
112
|
+
}
|
|
113
|
+
const visiblePresentationStyle = toVisibleWidgetHostPresentationStyle(webViewStyle);
|
|
114
|
+
return visiblePresentationStyle !== undefined
|
|
115
|
+
? [visiblePresentationStyle, VISIBLE_WIDGET_HOST_STYLE]
|
|
116
|
+
: VISIBLE_WIDGET_HOST_STYLE;
|
|
117
|
+
}
|
|
118
|
+
export function ProviderWidgetHostOverlay({ children, isVisible, nativeView, sheetHostViewport, }) {
|
|
119
|
+
const widgetSheetStyle = sheetHostViewport
|
|
120
|
+
? Object.assign(Object.assign({}, WIDGET_SHEET_STYLE), { height: sheetHostViewport.height }) : Object.assign(Object.assign({}, WIDGET_SHEET_STYLE), { height: "86%" });
|
|
121
|
+
const pointerEvents = isVisible ? "auto" : "none";
|
|
122
|
+
return createElement(nativeView, {
|
|
123
|
+
pointerEvents,
|
|
124
|
+
style: isVisible ? WIDGET_SHEET_OVERLAY_STYLE : HIDDEN_WIDGET_HOST_STYLE,
|
|
125
|
+
testID: "gx-widget-host-overlay",
|
|
126
|
+
}, createElement(nativeView, {
|
|
127
|
+
pointerEvents,
|
|
128
|
+
style: isVisible ? WIDGET_SHEET_BACKDROP_STYLE : HIDDEN_WIDGET_HOST_STYLE,
|
|
129
|
+
testID: "gx-widget-host-backdrop",
|
|
130
|
+
}), createElement(nativeView, {
|
|
131
|
+
pointerEvents,
|
|
132
|
+
style: isVisible ? widgetSheetStyle : HIDDEN_WIDGET_HOST_STYLE,
|
|
133
|
+
testID: "gx-widget-host-sheet",
|
|
134
|
+
}, children));
|
|
135
|
+
}
|
package/dist/version.js
CHANGED
|
@@ -3,4 +3,4 @@ const reactNativeSdkVersion = typeof __GX_REACT_NATIVE_SDK_VERSION__ === "string
|
|
|
3
3
|
: "";
|
|
4
4
|
// Build scripts patch this fallback to the package version for published artifacts.
|
|
5
5
|
// Source-linked workspace usage keeps the local fallback.
|
|
6
|
-
export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "1.3.
|
|
6
|
+
export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "1.3.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/react-native",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "getuserfeedback React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"getuserfeedback",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"lint": "ultracite check ."
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@getuserfeedback/protocol": "^1.
|
|
47
|
-
"@getuserfeedback/sdk": "^0.7.
|
|
46
|
+
"@getuserfeedback/protocol": "^1.3.0",
|
|
47
|
+
"@getuserfeedback/sdk": "^0.7.1",
|
|
48
48
|
"robot3": "^1.2.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|