@getuserfeedback/react-native 1.3.11 → 1.3.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.
package/dist/index.js
CHANGED
|
@@ -76,22 +76,16 @@ const FallbackNativeView = (_a) => {
|
|
|
76
76
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
77
77
|
return createElement("div", props, children);
|
|
78
78
|
};
|
|
79
|
-
const FallbackNativePressable = FallbackNativeView;
|
|
80
|
-
const FallbackNativeText = FallbackNativeView;
|
|
81
79
|
function resolveReactNativeComponents() {
|
|
82
|
-
var _a
|
|
80
|
+
var _a;
|
|
83
81
|
try {
|
|
84
82
|
const reactNativeModule = require("react-native");
|
|
85
83
|
return {
|
|
86
|
-
|
|
87
|
-
Text: (_b = reactNativeModule.Text) !== null && _b !== void 0 ? _b : FallbackNativeText,
|
|
88
|
-
View: (_c = reactNativeModule.View) !== null && _c !== void 0 ? _c : FallbackNativeView,
|
|
84
|
+
View: (_a = reactNativeModule.View) !== null && _a !== void 0 ? _a : FallbackNativeView,
|
|
89
85
|
};
|
|
90
86
|
}
|
|
91
|
-
catch (
|
|
87
|
+
catch (_b) {
|
|
92
88
|
return {
|
|
93
|
-
Pressable: FallbackNativePressable,
|
|
94
|
-
Text: FallbackNativeText,
|
|
95
89
|
View: FallbackNativeView,
|
|
96
90
|
};
|
|
97
91
|
}
|
|
@@ -125,7 +119,7 @@ const toIdentifyCommandPayload = (identifyInput, traitsOrOptions, options) => {
|
|
|
125
119
|
};
|
|
126
120
|
export function GetUserFeedbackProvider({ autoInit = true, children, commandTimeoutMs = DEFAULT_COMMAND_TIMEOUT_MS, configureOptions, hostViewport, instanceId: instanceIdProp, initOptions, loaderUrl, onCommandError, onInvalidWebMessage, onWebMessage, source, webViewComponent, webViewProps, }) {
|
|
127
121
|
var _a, _b;
|
|
128
|
-
const {
|
|
122
|
+
const { View: NativeView } = useMemo(resolveReactNativeComponents, []);
|
|
129
123
|
const [instanceId] = useState(() => { var _a; return (_a = normalizeOptionalString(instanceIdProp)) !== null && _a !== void 0 ? _a : createUniqueId("rn"); });
|
|
130
124
|
const [nativeMessages, setNativeMessages] = useState([]);
|
|
131
125
|
const [widgetHostVisibility, setWidgetHostVisibility] = useState(HIDDEN_PROVIDER_WIDGET_HOST_VISIBILITY);
|
|
@@ -428,6 +422,7 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
428
422
|
}
|
|
429
423
|
const isVisible = detail.isOpen || detail.isLoading;
|
|
430
424
|
setWidgetHostVisibility({
|
|
425
|
+
flowHeight: detail.height,
|
|
431
426
|
flowHandleId: detail.flowHandleId,
|
|
432
427
|
hostSourceVersion: hostSourceVersionRef.current,
|
|
433
428
|
isVisible,
|
|
@@ -582,14 +577,16 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
582
577
|
}
|
|
583
578
|
enqueueStartupCommands();
|
|
584
579
|
}, [enqueueStartupCommands, startupOptionsKey]);
|
|
580
|
+
const providerHostViewport = hostViewport !== null && hostViewport !== void 0 ? hostViewport : resolvedHostViewport;
|
|
581
|
+
const sheetHostViewport = toProviderWidgetSheetHostViewport(providerHostViewport, {
|
|
582
|
+
height: widgetHostVisibility.flowHeight,
|
|
583
|
+
});
|
|
585
584
|
const isWidgetHostVisible = widgetHostVisibility.isVisible &&
|
|
585
|
+
sheetHostViewport !== undefined &&
|
|
586
586
|
widgetHostVisibility.hostSourceVersion === hostSourceVersionRef.current &&
|
|
587
587
|
widgetHostVisibility.sourceKey === ((_a = lastReadyRef.current) === null || _a === void 0 ? void 0 : _a.sourceKey) &&
|
|
588
588
|
widgetHostVisibility.readySequence === ((_b = lastReadyRef.current) === null || _b === void 0 ? void 0 : _b.readySequence);
|
|
589
|
-
const
|
|
590
|
-
const widgetHostViewport = isWidgetHostVisible
|
|
591
|
-
? sheetHostViewport
|
|
592
|
-
: (hostViewport !== null && hostViewport !== void 0 ? hostViewport : resolvedHostViewport);
|
|
589
|
+
const widgetHostViewport = providerHostViewport;
|
|
593
590
|
const composedWebViewStyle = toProviderWidgetHostStyle({
|
|
594
591
|
isVisible: isWidgetHostVisible,
|
|
595
592
|
webViewStyle: webViewProps === null || webViewProps === void 0 ? void 0 : webViewProps.style,
|
|
@@ -606,7 +603,7 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
606
603
|
webViewComponent,
|
|
607
604
|
webViewProps: Object.assign(Object.assign({}, webViewProps), { pointerEvents: isWidgetHostVisible ? "auto" : "none", style: composedWebViewStyle }),
|
|
608
605
|
});
|
|
609
|
-
const
|
|
606
|
+
const handleWidgetHostDismiss = useCallback(() => {
|
|
610
607
|
enqueueCommand(Object.assign({ kind: "close" }, (widgetHostVisibility.flowHandleId === undefined
|
|
611
608
|
? {}
|
|
612
609
|
: { flowHandleId: widgetHostVisibility.flowHandleId }))).catch(reportCommandError);
|
|
@@ -615,11 +612,8 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
|
|
|
615
612
|
value: contextValue,
|
|
616
613
|
}, children, createElement(ProviderWidgetHostOverlay, {
|
|
617
614
|
isVisible: isWidgetHostVisible,
|
|
618
|
-
isCloseVisible: true,
|
|
619
|
-
nativePressable: NativePressable,
|
|
620
|
-
nativeText: NativeText,
|
|
621
615
|
nativeView: NativeView,
|
|
622
|
-
|
|
616
|
+
onRequestDismiss: handleWidgetHostDismiss,
|
|
623
617
|
sheetHostViewport,
|
|
624
618
|
}, widgetHost));
|
|
625
619
|
}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { type ComponentType, type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import type { WidgetHostProps } from "./widget-host.js";
|
|
3
3
|
type NativeViewComponent = ComponentType<Record<string, unknown>>;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare function toProviderWidgetSheetHostViewport(viewport: WidgetHostProps["hostViewport"], flowSize?: {
|
|
5
|
+
height?: number;
|
|
6
|
+
}): WidgetHostProps["hostViewport"];
|
|
7
7
|
export declare function toProviderWidgetHostStyle({ isVisible, webViewStyle, }: {
|
|
8
8
|
isVisible: boolean;
|
|
9
9
|
webViewStyle: unknown;
|
|
10
10
|
}): unknown;
|
|
11
|
-
export declare function ProviderWidgetHostOverlay({ children, isVisible,
|
|
11
|
+
export declare function ProviderWidgetHostOverlay({ children, isVisible, nativeView, onRequestDismiss, sheetHostViewport, }: {
|
|
12
12
|
children?: ReactNode;
|
|
13
|
-
isCloseVisible: boolean;
|
|
14
13
|
isVisible: boolean;
|
|
15
|
-
nativePressable: NativePressableComponent;
|
|
16
|
-
nativeText: NativeTextComponent;
|
|
17
14
|
nativeView: NativeViewComponent;
|
|
18
|
-
|
|
15
|
+
onRequestDismiss: () => void;
|
|
19
16
|
sheetHostViewport: WidgetHostProps["hostViewport"];
|
|
20
17
|
}): ReactElement;
|
|
21
18
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement, } from "react";
|
|
1
|
+
import { createElement, useCallback, useRef, } from "react";
|
|
2
2
|
const HIDDEN_WIDGET_HOST_STYLE = {
|
|
3
|
-
|
|
4
|
-
left:
|
|
3
|
+
bottom: 0,
|
|
4
|
+
left: 0,
|
|
5
5
|
opacity: 0,
|
|
6
6
|
position: "absolute",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
right: 0,
|
|
8
|
+
top: 0,
|
|
9
9
|
};
|
|
10
10
|
const WIDGET_SHEET_OVERLAY_STYLE = {
|
|
11
11
|
bottom: 0,
|
|
@@ -38,22 +38,21 @@ const WIDGET_SHEET_STYLE = {
|
|
|
38
38
|
shadowRadius: 18,
|
|
39
39
|
elevation: 18,
|
|
40
40
|
};
|
|
41
|
-
const
|
|
41
|
+
const WIDGET_SHEET_DRAG_HANDLE_TOUCH_STYLE = {
|
|
42
42
|
alignItems: "center",
|
|
43
|
-
|
|
44
|
-
borderRadius: 18,
|
|
45
|
-
height: 36,
|
|
43
|
+
height: 32,
|
|
46
44
|
justifyContent: "center",
|
|
45
|
+
left: 0,
|
|
47
46
|
position: "absolute",
|
|
48
|
-
right:
|
|
49
|
-
top:
|
|
50
|
-
width: 72,
|
|
47
|
+
right: 0,
|
|
48
|
+
top: 0,
|
|
51
49
|
zIndex: 1,
|
|
52
50
|
};
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const WIDGET_SHEET_DRAG_HANDLE_INDICATOR_STYLE = {
|
|
52
|
+
backgroundColor: "rgba(15, 23, 42, 0.28)",
|
|
53
|
+
borderRadius: 2,
|
|
54
|
+
height: 4,
|
|
55
|
+
width: 36,
|
|
57
56
|
};
|
|
58
57
|
const VISIBLE_WIDGET_HOST_STYLE = {
|
|
59
58
|
flex: 1,
|
|
@@ -88,16 +87,29 @@ const VISIBLE_WIDGET_HOST_LAYOUT_STYLE_KEYS = new Set([
|
|
|
88
87
|
"top",
|
|
89
88
|
"width",
|
|
90
89
|
]);
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
90
|
+
const LOADER_FLOATING_CONTAINER_MIN_HEIGHT = 120;
|
|
91
|
+
const WIDGET_SHEET_SWIPE_DISMISS_DISTANCE = 64;
|
|
92
|
+
function toResponderPageY(event) {
|
|
93
|
+
var _a;
|
|
94
|
+
const value = (_a = event === null || event === void 0 ? void 0 : event.nativeEvent) === null || _a === void 0 ? void 0 : _a.pageY;
|
|
95
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
96
|
+
? value
|
|
97
|
+
: undefined;
|
|
98
|
+
}
|
|
99
|
+
export function toProviderWidgetSheetHostViewport(viewport, flowSize) {
|
|
94
100
|
if (!viewport) {
|
|
95
101
|
return undefined;
|
|
96
102
|
}
|
|
97
|
-
const
|
|
103
|
+
const measuredHeight = typeof (flowSize === null || flowSize === void 0 ? void 0 : flowSize.height) === "number" &&
|
|
104
|
+
Number.isFinite(flowSize.height) &&
|
|
105
|
+
flowSize.height > 0
|
|
106
|
+
? flowSize.height
|
|
107
|
+
: undefined;
|
|
98
108
|
return {
|
|
99
109
|
width: viewport.width,
|
|
100
|
-
height: Math.min(viewport.height,
|
|
110
|
+
height: Math.min(viewport.height, measuredHeight === undefined
|
|
111
|
+
? LOADER_FLOATING_CONTAINER_MIN_HEIGHT
|
|
112
|
+
: Math.max(LOADER_FLOATING_CONTAINER_MIN_HEIGHT, Math.ceil(measuredHeight))),
|
|
101
113
|
};
|
|
102
114
|
}
|
|
103
115
|
function toVisibleWidgetHostPresentationStyle(style) {
|
|
@@ -132,31 +144,52 @@ export function toProviderWidgetHostStyle({ isVisible, webViewStyle, }) {
|
|
|
132
144
|
? [visiblePresentationStyle, VISIBLE_WIDGET_HOST_STYLE]
|
|
133
145
|
: VISIBLE_WIDGET_HOST_STYLE;
|
|
134
146
|
}
|
|
135
|
-
export function ProviderWidgetHostOverlay({ children, isVisible,
|
|
147
|
+
export function ProviderWidgetHostOverlay({ children, isVisible, nativeView, onRequestDismiss, sheetHostViewport, }) {
|
|
148
|
+
const dragStartYRef = useRef(undefined);
|
|
149
|
+
const handleDragGrant = useCallback((event) => {
|
|
150
|
+
dragStartYRef.current = toResponderPageY(event);
|
|
151
|
+
}, []);
|
|
152
|
+
const handleDragRelease = useCallback((event) => {
|
|
153
|
+
const startY = dragStartYRef.current;
|
|
154
|
+
dragStartYRef.current = undefined;
|
|
155
|
+
const endY = toResponderPageY(event);
|
|
156
|
+
if (startY === undefined ||
|
|
157
|
+
endY === undefined ||
|
|
158
|
+
endY - startY < WIDGET_SHEET_SWIPE_DISMISS_DISTANCE) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
onRequestDismiss();
|
|
162
|
+
}, [onRequestDismiss]);
|
|
136
163
|
const widgetSheetStyle = sheetHostViewport
|
|
137
|
-
? Object.assign(Object.assign({}, WIDGET_SHEET_STYLE), { height: sheetHostViewport.height }) :
|
|
138
|
-
const
|
|
164
|
+
? Object.assign(Object.assign({}, WIDGET_SHEET_STYLE), { height: sheetHostViewport.height }) : HIDDEN_WIDGET_HOST_STYLE;
|
|
165
|
+
const isSheetVisible = isVisible && sheetHostViewport !== undefined;
|
|
166
|
+
const pointerEvents = isSheetVisible ? "auto" : "none";
|
|
139
167
|
return createElement(nativeView, {
|
|
140
168
|
pointerEvents,
|
|
141
|
-
style:
|
|
169
|
+
style: isSheetVisible
|
|
170
|
+
? WIDGET_SHEET_OVERLAY_STYLE
|
|
171
|
+
: HIDDEN_WIDGET_HOST_STYLE,
|
|
142
172
|
testID: "gx-widget-host-overlay",
|
|
143
173
|
}, createElement(nativeView, {
|
|
144
174
|
pointerEvents,
|
|
145
|
-
style:
|
|
175
|
+
style: isSheetVisible
|
|
176
|
+
? WIDGET_SHEET_BACKDROP_STYLE
|
|
177
|
+
: HIDDEN_WIDGET_HOST_STYLE,
|
|
146
178
|
testID: "gx-widget-host-backdrop",
|
|
147
179
|
}), createElement(nativeView, {
|
|
148
180
|
pointerEvents,
|
|
149
|
-
style:
|
|
181
|
+
style: isSheetVisible ? widgetSheetStyle : HIDDEN_WIDGET_HOST_STYLE,
|
|
150
182
|
testID: "gx-widget-host-sheet",
|
|
151
|
-
}, children,
|
|
152
|
-
? createElement(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
style:
|
|
157
|
-
testID: "gx-widget-host-
|
|
158
|
-
}, createElement(
|
|
159
|
-
style:
|
|
160
|
-
|
|
183
|
+
}, children, isSheetVisible
|
|
184
|
+
? createElement(nativeView, {
|
|
185
|
+
onResponderGrant: handleDragGrant,
|
|
186
|
+
onResponderRelease: handleDragRelease,
|
|
187
|
+
onStartShouldSetResponder: () => true,
|
|
188
|
+
style: WIDGET_SHEET_DRAG_HANDLE_TOUCH_STYLE,
|
|
189
|
+
testID: "gx-widget-host-drag-handle",
|
|
190
|
+
}, createElement(nativeView, {
|
|
191
|
+
style: WIDGET_SHEET_DRAG_HANDLE_INDICATOR_STYLE,
|
|
192
|
+
testID: "gx-widget-host-drag-handle-indicator",
|
|
193
|
+
}))
|
|
161
194
|
: null));
|
|
162
195
|
}
|
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.13";
|
|
@@ -248,13 +248,6 @@ export function buildWebViewBridgeScript(input) {
|
|
|
248
248
|
for (var index = 0; index < hostEventNames.length; index += 1) {
|
|
249
249
|
(function (name) {
|
|
250
250
|
window.addEventListener("${HOST_EVENT_PREFIX}" + name, function (event) {
|
|
251
|
-
if (
|
|
252
|
-
name === "instance:open:requested" &&
|
|
253
|
-
event &&
|
|
254
|
-
typeof event.preventDefault === "function"
|
|
255
|
-
) {
|
|
256
|
-
event.preventDefault();
|
|
257
|
-
}
|
|
258
251
|
postMessage({
|
|
259
252
|
kind: "hostEvent",
|
|
260
253
|
event: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/react-native",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"description": "getuserfeedback React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"getuserfeedback",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"lint": "ultracite check ."
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@getuserfeedback/protocol": "^1.
|
|
48
|
-
"@getuserfeedback/sdk": "^0.7.
|
|
47
|
+
"@getuserfeedback/protocol": "^1.6.1",
|
|
48
|
+
"@getuserfeedback/sdk": "^0.7.6",
|
|
49
49
|
"robot3": "^1.2.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|