@getuserfeedback/react-native 1.3.3 → 1.3.5
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.d.ts +2 -7
- package/dist/index.js +14 -178
- package/dist/provider-command-helpers.d.ts +14 -0
- package/dist/provider-command-helpers.js +40 -0
- 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 +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AppEventExternalId, AppEventJsonValue, PublicCommandPayload } from "@getuserfeedback/protocol";
|
|
2
|
-
import type { WebViewCommandEnvelope,
|
|
2
|
+
import type { WebViewCommandEnvelope, WebViewTransportNativeMessage, WebViewTransportWebMessage } from "@getuserfeedback/protocol/webview-transport";
|
|
3
3
|
import type { ConfigureOptions, InitOptions } from "@getuserfeedback/sdk";
|
|
4
4
|
import { type ReactElement, type ReactNode } from "react";
|
|
5
|
+
import { type CommandSettledEvent, type CommandSettledSuccessDetail } from "./provider-command-helpers.js";
|
|
5
6
|
import { WidgetHost, type WidgetHostProps, type WidgetHostSource } from "./widget-host.js";
|
|
6
7
|
export { REACT_NATIVE_SDK_VERSION } from "./version.js";
|
|
7
8
|
export { buildNativeMessageInjectionScript, buildWebViewBridgeScript, } from "./webview-bridge-script.js";
|
|
@@ -29,12 +30,6 @@ type PrerenderOptions = Pick<PrerenderCommand, "hideCloseButton">;
|
|
|
29
30
|
type HostContext = Extract<PublicCommandPayload, {
|
|
30
31
|
kind: "updateHostContext";
|
|
31
32
|
}>["context"];
|
|
32
|
-
type CommandSettledEvent = Extract<WebViewTransportHostEvent, {
|
|
33
|
-
name: "instance:command:settled";
|
|
34
|
-
}>;
|
|
35
|
-
type CommandSettledSuccessDetail = Extract<CommandSettledEvent["detail"], {
|
|
36
|
-
ok: true;
|
|
37
|
-
}>;
|
|
38
33
|
export interface ReactNativeCommandResult {
|
|
39
34
|
envelope: ReactNativeWidgetCommandEnvelope;
|
|
40
35
|
message: ReactNativeWidgetNativeMessage;
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { assertNoSegmentExternalIdsInValueArgument,
|
|
12
|
+
import { assertNoSegmentExternalIdsInValueArgument, CommandSettlementTimeoutError, } from "@getuserfeedback/protocol/host";
|
|
13
13
|
import { parseWebViewTransportNativeMessage } from "@getuserfeedback/protocol/webview-transport";
|
|
14
14
|
import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
15
15
|
import { useResolvedHostViewport } from "./host-viewport.js";
|
|
16
|
+
import { toCommandFlowId, toCommandSettlementError, toRetryWithoutFlowHandle, toSettledFlowHandleId, } from "./provider-command-helpers.js";
|
|
16
17
|
import { applyProviderOverlayFlowState, applyProviderOverlayHandleInvalidated, createDefaultProviderOverlayState, DEFAULT_PROVIDER_OVERLAY_VISIBILITY, updateProviderOverlayReadySequence, } from "./provider-overlay-state.js";
|
|
18
|
+
import { ProviderWidgetHostOverlay, toProviderWidgetHostStyle, toProviderWidgetSheetHostViewport, } from "./provider-widget-host-overlay.js";
|
|
17
19
|
import { REACT_NATIVE_SDK_VERSION } from "./version.js";
|
|
18
20
|
import { WidgetHost, } from "./widget-host.js";
|
|
19
21
|
export { REACT_NATIVE_SDK_VERSION } from "./version.js";
|
|
@@ -29,80 +31,6 @@ const CLIENT_META = {
|
|
|
29
31
|
loader: "sdk",
|
|
30
32
|
transport: "loader",
|
|
31
33
|
};
|
|
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
34
|
const createUniqueId = (prefix) => {
|
|
107
35
|
if (typeof globalThis.crypto !== "undefined" &&
|
|
108
36
|
typeof globalThis.crypto.randomUUID === "function") {
|
|
@@ -150,39 +78,6 @@ function resolveNativeView() {
|
|
|
150
78
|
return FallbackNativeView;
|
|
151
79
|
}
|
|
152
80
|
}
|
|
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
81
|
const toIdentifyCommandPayload = (identifyInput, traitsOrOptions, options) => {
|
|
187
82
|
if (typeof identifyInput === "string") {
|
|
188
83
|
assertNoSegmentExternalIdsInValueArgument({
|
|
@@ -210,44 +105,8 @@ const toIdentifyCommandPayload = (identifyInput, traitsOrOptions, options) => {
|
|
|
210
105
|
options: options !== null && options !== void 0 ? options : traitsOrOptions,
|
|
211
106
|
};
|
|
212
107
|
};
|
|
213
|
-
const isFlowCommand = (command) => command.kind === "open" ||
|
|
214
|
-
command.kind === "prefetch" ||
|
|
215
|
-
command.kind === "prerender";
|
|
216
|
-
const toSettledFlowHandleId = (result) => {
|
|
217
|
-
if (typeof result !== "object" || result === null) {
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
const flowHandleId = result.flowHandleId;
|
|
221
|
-
return typeof flowHandleId === "string" && flowHandleId.trim().length > 0
|
|
222
|
-
? flowHandleId
|
|
223
|
-
: undefined;
|
|
224
|
-
};
|
|
225
|
-
const toCommandFlowId = (command) => {
|
|
226
|
-
if (!isFlowCommand(command)) {
|
|
227
|
-
return undefined;
|
|
228
|
-
}
|
|
229
|
-
return command.flowId;
|
|
230
|
-
};
|
|
231
|
-
const toRetryWithoutFlowHandle = (command) => {
|
|
232
|
-
if (!isFlowCommand(command) || command.flowHandleId === undefined) {
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
return Object.assign(Object.assign({}, command), { flowHandleId: undefined });
|
|
236
|
-
};
|
|
237
|
-
const toCommandSettlementError = (event) => {
|
|
238
|
-
if (event.detail.ok) {
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
return new CommandSettlementError({
|
|
242
|
-
code: event.detail.error.code,
|
|
243
|
-
instanceId: event.detail.instanceId,
|
|
244
|
-
kind: event.detail.kind,
|
|
245
|
-
message: event.detail.error.message,
|
|
246
|
-
requestId: event.detail.requestId,
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
108
|
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
|
|
109
|
+
var _a, _b;
|
|
251
110
|
const NativeView = useMemo(resolveNativeView, []);
|
|
252
111
|
const [instanceId] = useState(() => { var _a; return (_a = normalizeOptionalString(instanceIdProp)) !== null && _a !== void 0 ? _a : createUniqueId("rn"); });
|
|
253
112
|
const [nativeMessages, setNativeMessages] = useState([]);
|
|
@@ -764,23 +623,14 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
764
623
|
widgetHostVisibility.hostSourceVersion === hostSourceVersionRef.current &&
|
|
765
624
|
widgetHostVisibility.sourceKey === ((_a = lastReadyRef.current) === null || _a === void 0 ? void 0 : _a.sourceKey) &&
|
|
766
625
|
widgetHostVisibility.readySequence === ((_b = lastReadyRef.current) === null || _b === void 0 ? void 0 : _b.readySequence);
|
|
767
|
-
const sheetHostViewport =
|
|
626
|
+
const sheetHostViewport = toProviderWidgetSheetHostViewport(hostViewport !== null && hostViewport !== void 0 ? hostViewport : resolvedHostViewport);
|
|
768
627
|
const widgetHostViewport = isWidgetHostVisible
|
|
769
628
|
? sheetHostViewport
|
|
770
629
|
: (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);
|
|
630
|
+
const composedWebViewStyle = toProviderWidgetHostStyle({
|
|
631
|
+
isVisible: isWidgetHostVisible,
|
|
632
|
+
webViewStyle: webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.style,
|
|
633
|
+
});
|
|
784
634
|
const widgetHost = createElement(WidgetHost, {
|
|
785
635
|
hostViewport: widgetHostViewport,
|
|
786
636
|
instanceId,
|
|
@@ -795,25 +645,11 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
795
645
|
});
|
|
796
646
|
return createElement(GetUserFeedbackNativeContext.Provider, {
|
|
797
647
|
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)));
|
|
648
|
+
}, children, createElement(ProviderWidgetHostOverlay, {
|
|
649
|
+
isVisible: isWidgetHostVisible,
|
|
650
|
+
nativeView: NativeView,
|
|
651
|
+
sheetHostViewport,
|
|
652
|
+
}, widgetHost));
|
|
817
653
|
}
|
|
818
654
|
export function useGetUserFeedbackNative() {
|
|
819
655
|
const context = useContext(GetUserFeedbackNativeContext);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommandSettlementError } from "@getuserfeedback/protocol/host";
|
|
2
|
+
import type { WebViewCommandEnvelope, WebViewTransportHostEvent } from "@getuserfeedback/protocol/webview-transport";
|
|
3
|
+
type ReactNativeWidgetCommand = WebViewCommandEnvelope["command"];
|
|
4
|
+
export type CommandSettledEvent = Extract<WebViewTransportHostEvent, {
|
|
5
|
+
name: "instance:command:settled";
|
|
6
|
+
}>;
|
|
7
|
+
export type CommandSettledSuccessDetail = Extract<CommandSettledEvent["detail"], {
|
|
8
|
+
ok: true;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function toSettledFlowHandleId(result: unknown): string | undefined;
|
|
11
|
+
export declare function toCommandFlowId(command: ReactNativeWidgetCommand): string | undefined;
|
|
12
|
+
export declare function toRetryWithoutFlowHandle(command: ReactNativeWidgetCommand): ReactNativeWidgetCommand | null;
|
|
13
|
+
export declare function toCommandSettlementError(event: CommandSettledEvent): CommandSettlementError | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CommandSettlementError } from "@getuserfeedback/protocol/host";
|
|
2
|
+
function isReactNativeFlowCommand(command) {
|
|
3
|
+
return (command.kind === "open" ||
|
|
4
|
+
command.kind === "prefetch" ||
|
|
5
|
+
command.kind === "prerender");
|
|
6
|
+
}
|
|
7
|
+
export function toSettledFlowHandleId(result) {
|
|
8
|
+
if (typeof result !== "object" || result === null) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const flowHandleId = result.flowHandleId;
|
|
12
|
+
return typeof flowHandleId === "string" && flowHandleId.trim().length > 0
|
|
13
|
+
? flowHandleId
|
|
14
|
+
: undefined;
|
|
15
|
+
}
|
|
16
|
+
export function toCommandFlowId(command) {
|
|
17
|
+
if (!isReactNativeFlowCommand(command)) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return command.flowId;
|
|
21
|
+
}
|
|
22
|
+
export function toRetryWithoutFlowHandle(command) {
|
|
23
|
+
if (!isReactNativeFlowCommand(command) ||
|
|
24
|
+
command.flowHandleId === undefined) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return Object.assign(Object.assign({}, command), { flowHandleId: undefined });
|
|
28
|
+
}
|
|
29
|
+
export function toCommandSettlementError(event) {
|
|
30
|
+
if (event.detail.ok) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return new CommandSettlementError({
|
|
34
|
+
code: event.detail.error.code,
|
|
35
|
+
instanceId: event.detail.instanceId,
|
|
36
|
+
kind: event.detail.kind,
|
|
37
|
+
message: event.detail.error.message,
|
|
38
|
+
requestId: event.detail.requestId,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -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.5";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/react-native",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "getuserfeedback React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"getuserfeedback",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"build": "bun scripts/build.ts",
|
|
41
41
|
"typecheck": "tsc -b tsconfig.json",
|
|
42
42
|
"test": "bun test --dots",
|
|
43
|
+
"test:changed": "bun test --changed=${TEST_CHANGED_BASE:-HEAD} --pass-with-no-tests --dots",
|
|
43
44
|
"lint": "ultracite check ."
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@getuserfeedback/protocol": "^1.
|
|
47
|
-
"@getuserfeedback/sdk": "^0.7.
|
|
47
|
+
"@getuserfeedback/protocol": "^1.3.0",
|
|
48
|
+
"@getuserfeedback/sdk": "^0.7.1",
|
|
48
49
|
"robot3": "^1.2.0"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|