@buoy-gg/route-events 7.0.41 → 7.0.43
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/README.md +11 -64
- package/lib/commonjs/RouteObserver.js +1 -54
- package/lib/commonjs/RouteParser.js +1 -314
- package/lib/commonjs/RouteTracker.js +1 -112
- package/lib/commonjs/RouteTracker.web.js +1 -12
- package/lib/commonjs/browserRouteRegistry.js +1 -30
- package/lib/commonjs/browserRoutes.js +1 -96
- package/lib/commonjs/components/NavigationStack.js +2 -572
- package/lib/commonjs/components/ReactNavigationRoutes.js +1 -836
- package/lib/commonjs/components/ReactNavigationRoutes.web.js +1 -12
- package/lib/commonjs/components/RouteEventDetail.js +1 -97
- package/lib/commonjs/components/RouteEventExpandedContent.js +1 -204
- package/lib/commonjs/components/RouteEventItemCompact.js +1 -191
- package/lib/commonjs/components/RouteEventsModalWithTabs.js +1 -734
- package/lib/commonjs/components/RouteEventsTimeline.js +1 -107
- package/lib/commonjs/components/RouteFilterViewV2.js +1 -42
- package/lib/commonjs/components/RoutesSitemap.js +2 -1035
- package/lib/commonjs/expoRouterStore.js +1 -121
- package/lib/commonjs/expoRouterStore.web.js +1 -44
- package/lib/commonjs/hooks/useRouteEvents.js +1 -57
- package/lib/commonjs/index.js +1 -168
- package/lib/commonjs/preset.js +1 -69
- package/lib/commonjs/stores/navigationStackStore.js +1 -45
- package/lib/commonjs/stores/routeEventStore.js +1 -136
- package/lib/commonjs/sync/routeEventsSyncAdapter.js +1 -275
- package/lib/commonjs/useNavigationStack.js +1 -408
- package/lib/commonjs/useNavigationStack.web.js +1 -32
- package/lib/commonjs/useRouteObserver.js +1 -73
- package/lib/commonjs/useRouteObserverReactNavigation.js +1 -109
- package/lib/commonjs/useRouteSitemap.js +1 -255
- package/lib/commonjs/utils/routeTemplate.js +1 -79
- package/lib/commonjs/utils/safeReactNavigation.js +1 -194
- package/lib/commonjs/utils/safeReactNavigation.web.js +1 -36
- package/lib/commonjs/utils/testIDs.js +1 -63
- package/lib/module/RouteObserver.js +1 -49
- package/lib/module/RouteParser.js +1 -309
- package/lib/module/RouteTracker.js +1 -109
- package/lib/module/RouteTracker.web.js +1 -8
- package/lib/module/browserRouteRegistry.js +1 -24
- package/lib/module/browserRoutes.js +1 -92
- package/lib/module/components/NavigationStack.js +2 -568
- package/lib/module/components/ReactNavigationRoutes.js +1 -832
- package/lib/module/components/ReactNavigationRoutes.web.js +1 -3
- package/lib/module/components/RouteEventDetail.js +1 -93
- package/lib/module/components/RouteEventExpandedContent.js +1 -200
- package/lib/module/components/RouteEventItemCompact.js +1 -187
- package/lib/module/components/RouteEventsModalWithTabs.js +1 -731
- package/lib/module/components/RouteEventsTimeline.js +1 -103
- package/lib/module/components/RouteFilterViewV2.js +1 -38
- package/lib/module/components/RoutesSitemap.js +2 -1033
- package/lib/module/expoRouterStore.js +1 -114
- package/lib/module/expoRouterStore.web.js +1 -37
- package/lib/module/hooks/useRouteEvents.js +1 -54
- package/lib/module/index.js +1 -70
- package/lib/module/preset.js +1 -66
- package/lib/module/stores/navigationStackStore.js +1 -41
- package/lib/module/stores/routeEventStore.js +1 -128
- package/lib/module/sync/routeEventsSyncAdapter.js +1 -273
- package/lib/module/useNavigationStack.js +1 -404
- package/lib/module/useNavigationStack.web.js +1 -28
- package/lib/module/useRouteObserver.js +1 -70
- package/lib/module/useRouteObserverReactNavigation.js +1 -106
- package/lib/module/useRouteSitemap.js +1 -250
- package/lib/module/utils/routeTemplate.js +1 -73
- package/lib/module/utils/safeReactNavigation.js +1 -185
- package/lib/module/utils/safeReactNavigation.web.js +1 -27
- package/lib/module/utils/testIDs.js +1 -55
- package/lib/web/index.mjs +4 -5
- package/package.json +6 -11
- package/lib/typescript/RouteObserver.d.ts.map +0 -1
- package/lib/typescript/RouteParser.d.ts.map +0 -1
- package/lib/typescript/RouteTracker.d.ts.map +0 -1
- package/lib/typescript/RouteTracker.web.d.ts.map +0 -1
- package/lib/typescript/browserRouteRegistry.d.ts.map +0 -1
- package/lib/typescript/browserRoutes.d.ts.map +0 -1
- package/lib/typescript/components/NavigationStack.d.ts.map +0 -1
- package/lib/typescript/components/ReactNavigationRoutes.d.ts.map +0 -1
- package/lib/typescript/components/ReactNavigationRoutes.web.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventDetail.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventExpandedContent.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventItemCompact.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventsModalWithTabs.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventsTimeline.d.ts.map +0 -1
- package/lib/typescript/components/RouteFilterViewV2.d.ts.map +0 -1
- package/lib/typescript/components/RoutesSitemap.d.ts.map +0 -1
- package/lib/typescript/expoRouterStore.d.ts.map +0 -1
- package/lib/typescript/expoRouterStore.web.d.ts.map +0 -1
- package/lib/typescript/hooks/useRouteEvents.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/stores/navigationStackStore.d.ts.map +0 -1
- package/lib/typescript/stores/routeEventStore.d.ts.map +0 -1
- package/lib/typescript/sync/routeEventsSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/useNavigationStack.d.ts.map +0 -1
- package/lib/typescript/useNavigationStack.web.d.ts.map +0 -1
- package/lib/typescript/useRouteObserver.d.ts.map +0 -1
- package/lib/typescript/useRouteObserverReactNavigation.d.ts.map +0 -1
- package/lib/typescript/useRouteSitemap.d.ts.map +0 -1
- package/lib/typescript/utils/routeTemplate.d.ts.map +0 -1
- package/lib/typescript/utils/safeReactNavigation.d.ts.map +0 -1
- package/lib/typescript/utils/safeReactNavigation.web.d.ts.map +0 -1
- package/lib/typescript/utils/testIDs.d.ts.map +0 -1
|
@@ -1,569 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";import{useState as N,useMemo as S,useEffect as L}from"react";import{View as n,Text as r,ScrollView as q,TouchableOpacity as D,StyleSheet as K,Alert as T}from"react-native";import{ChevronDown as Q,ChevronRight as X,InlineCopyButton as Y,ProUpgradeModal as Z,buoyColors as F,night as a,useSafeAreaInsets as ee,ToolEmptyState as te,monoFont as d}from"@buoy-gg/shared-ui";import{useIsPro as oe}from"@buoy-gg/license";import{DataViewer as ne}from"@buoy-gg/shared-ui/dataViewer";import{useNavigationStack as ae}from"../useNavigationStack";import{stackItemTestID as re}from"../utils/testIDs";import{jsx as o,jsxs as i}from"react/jsx-runtime";export function NavigationStack({style:I,injectedStack:R,onAction:y,onCopyValueChange:$}){const f=ae();const v=R!=null;const V=ee({minBottom:8});const s=v?R:f.stack;const E=v?true:f.isLoaded;const w=v?null:f.error;const P=S(()=>s.find(t=>t.isFocused)??null,[s]);const g=s.length;const k=g<=1;const j=t=>y?y("navigateToIndex",{index:t}):f.navigateToIndex(t);const H=t=>y?y("popToIndex",{index:t}):f.popToIndex(t);const O=()=>y?y("goBack"):f.goBack();const G=()=>y?y("popToTop"):f.popToTop();const[u,M]=N(null);const[C,m]=N(false);const x=oe();L(()=>{if(C&&x){m(false)}},[C,x]);const z=S(()=>{const t=s.map(l=>({pathname:l.pathname,name:l.name,params:l.params,isFocused:l.isFocused}));return JSON.stringify(t,null,2)},[s]);L(()=>{$?.(z)},[z,$]);const h=S(()=>{if(u!==null&&s[u]){return s[u]}return P},[u,s,P]);const se=S(()=>{return u!==null&&s[u]&&!s[u].isFocused},[u,s]);if(!E){return o(n,{style:[e.container,I],children:o(n,{style:e.loadingContainer,children:o(r,{style:e.loadingText,testID:"buoy-routes-stack-loading",children:"Loading navigation stack..."})})})}if(w){return o(n,{style:[e.container,I],children:i(n,{style:e.errorContainer,testID:"buoy-routes-stack-error",children:[o(r,{style:e.errorText,children:"Error loading stack"}),o(r,{style:e.errorDetail,testID:"buoy-routes-stack-error-detail",children:w.message})]})})}if(s.length===0){return o(n,{style:[e.container,I],children:o(te,{testID:"buoy-routes-stack-empty",otto:"walking",title:"No navigation stack",message:"Navigate to a route to see the stack"})})}const W=(t,l,c,b)=>{if(y){const B=globalThis.window?.confirm;if(!B||B(`${t}
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* NavigationStack - Visual representation of current navigation stack
|
|
5
|
-
*
|
|
6
|
-
* Shows all screens currently mounted in memory, which one is visible,
|
|
7
|
-
* and provides controls to manipulate the stack.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { useState, useMemo, useEffect } from "react";
|
|
11
|
-
import { View, Text, ScrollView, TouchableOpacity, StyleSheet, Alert } from "react-native";
|
|
12
|
-
import { ChevronDown, ChevronRight, InlineCopyButton, ProUpgradeModal, buoyColors, night, useSafeAreaInsets, ToolEmptyState, monoFont } from "@buoy-gg/shared-ui";
|
|
13
|
-
import { useIsPro } from "@buoy-gg/license";
|
|
14
|
-
import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
|
|
15
|
-
import { useNavigationStack } from "../useNavigationStack";
|
|
16
|
-
import { stackItemTestID } from "../utils/testIDs";
|
|
17
|
-
|
|
18
|
-
// ============================================================================
|
|
19
|
-
// Types
|
|
20
|
-
// ============================================================================
|
|
21
|
-
|
|
22
|
-
/** Stack manipulation a host can be asked to perform on the device. */
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
// ============================================================================
|
|
25
|
-
// Main Component
|
|
26
|
-
// ============================================================================
|
|
27
|
-
|
|
28
|
-
export function NavigationStack({
|
|
29
|
-
style,
|
|
30
|
-
injectedStack,
|
|
31
|
-
onAction,
|
|
32
|
-
onCopyValueChange
|
|
33
|
-
}) {
|
|
34
|
-
const hookResult = useNavigationStack();
|
|
35
|
-
const isInjected = injectedStack != null;
|
|
36
|
-
const insets = useSafeAreaInsets({
|
|
37
|
-
minBottom: 8
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Data source: injected (dashboard) or the local navigation container.
|
|
41
|
-
const stack = isInjected ? injectedStack : hookResult.stack;
|
|
42
|
-
const isLoaded = isInjected ? true : hookResult.isLoaded;
|
|
43
|
-
const error = isInjected ? null : hookResult.error;
|
|
44
|
-
const focusedRoute = useMemo(() => stack.find(item => item.isFocused) ?? null, [stack]);
|
|
45
|
-
const stackDepth = stack.length;
|
|
46
|
-
const isAtRoot = stackDepth <= 1;
|
|
47
|
-
|
|
48
|
-
// Action wrappers: delegate to the host when provided, else act locally.
|
|
49
|
-
const navigateToIndex = index => onAction ? onAction("navigateToIndex", {
|
|
50
|
-
index
|
|
51
|
-
}) : hookResult.navigateToIndex(index);
|
|
52
|
-
const popToIndex = index => onAction ? onAction("popToIndex", {
|
|
53
|
-
index
|
|
54
|
-
}) : hookResult.popToIndex(index);
|
|
55
|
-
const goBack = () => onAction ? onAction("goBack") : hookResult.goBack();
|
|
56
|
-
const popToTop = () => onAction ? onAction("popToTop") : hookResult.popToTop();
|
|
57
|
-
const [expandedIndex, setExpandedIndex] = useState(null);
|
|
58
|
-
const [showUpgradeModal, setShowUpgradeModal] = useState(false);
|
|
59
|
-
|
|
60
|
-
// Check Pro status internally
|
|
61
|
-
const isPro = useIsPro();
|
|
62
|
-
|
|
63
|
-
// Auto-close upgrade modal when user becomes Pro
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (showUpgradeModal && isPro) {
|
|
66
|
-
setShowUpgradeModal(false);
|
|
67
|
-
}
|
|
68
|
-
}, [showUpgradeModal, isPro]);
|
|
69
|
-
|
|
70
|
-
// ✅ All hooks must be called BEFORE any conditional returns
|
|
71
|
-
// Prepare stack data for copying
|
|
72
|
-
const stackDataForCopy = useMemo(() => {
|
|
73
|
-
const stackData = stack.map(item => ({
|
|
74
|
-
pathname: item.pathname,
|
|
75
|
-
name: item.name,
|
|
76
|
-
params: item.params,
|
|
77
|
-
isFocused: item.isFocused
|
|
78
|
-
}));
|
|
79
|
-
return JSON.stringify(stackData, null, 2);
|
|
80
|
-
}, [stack]);
|
|
81
|
-
|
|
82
|
-
// Report the copy payload up so the host can render the copy button in the
|
|
83
|
-
// shared navbar.
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
onCopyValueChange?.(stackDataForCopy);
|
|
86
|
-
}, [stackDataForCopy, onCopyValueChange]);
|
|
87
|
-
|
|
88
|
-
// Determine which route actions should operate on
|
|
89
|
-
// If a stack item is expanded, actions target that route
|
|
90
|
-
// Otherwise, actions target the focused (visible) route
|
|
91
|
-
const selectedRoute = useMemo(() => {
|
|
92
|
-
if (expandedIndex !== null && stack[expandedIndex]) {
|
|
93
|
-
return stack[expandedIndex];
|
|
94
|
-
}
|
|
95
|
-
return focusedRoute;
|
|
96
|
-
}, [expandedIndex, stack, focusedRoute]);
|
|
97
|
-
const isNonFocusedSelected = useMemo(() => {
|
|
98
|
-
return expandedIndex !== null && stack[expandedIndex] && !stack[expandedIndex].isFocused;
|
|
99
|
-
}, [expandedIndex, stack]);
|
|
100
|
-
|
|
101
|
-
// Loading state
|
|
102
|
-
if (!isLoaded) {
|
|
103
|
-
return /*#__PURE__*/_jsx(View, {
|
|
104
|
-
style: [styles.container, style],
|
|
105
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
106
|
-
style: styles.loadingContainer,
|
|
107
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
108
|
-
style: styles.loadingText,
|
|
109
|
-
testID: "buoy-routes-stack-loading",
|
|
110
|
-
children: "Loading navigation stack..."
|
|
111
|
-
})
|
|
112
|
-
})
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Error state
|
|
117
|
-
if (error) {
|
|
118
|
-
return /*#__PURE__*/_jsx(View, {
|
|
119
|
-
style: [styles.container, style],
|
|
120
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
121
|
-
style: styles.errorContainer,
|
|
122
|
-
testID: "buoy-routes-stack-error",
|
|
123
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
124
|
-
style: styles.errorText,
|
|
125
|
-
children: "Error loading stack"
|
|
126
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
127
|
-
style: styles.errorDetail,
|
|
128
|
-
testID: "buoy-routes-stack-error-detail",
|
|
129
|
-
children: error.message
|
|
130
|
-
})]
|
|
131
|
-
})
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Empty state
|
|
136
|
-
if (stack.length === 0) {
|
|
137
|
-
return /*#__PURE__*/_jsx(View, {
|
|
138
|
-
style: [styles.container, style],
|
|
139
|
-
children: /*#__PURE__*/_jsx(ToolEmptyState, {
|
|
140
|
-
testID: "buoy-routes-stack-empty",
|
|
141
|
-
otto: "walking",
|
|
142
|
-
title: "No navigation stack",
|
|
143
|
-
message: "Navigate to a route to see the stack"
|
|
144
|
-
})
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Handlers
|
|
149
|
-
// Confirm a destructive action. On device we use the native Alert; when an
|
|
150
|
-
// action delegate is set (dashboard, react-native-web) Alert button presses
|
|
151
|
-
// don't fire, so fall back to window.confirm.
|
|
152
|
-
const confirmDestructive = (title, message, confirmLabel, onConfirm) => {
|
|
153
|
-
if (onAction) {
|
|
154
|
-
const confirmFn = globalThis.window?.confirm;
|
|
155
|
-
if (!confirmFn || confirmFn(`${title}\n\n${message}`)) {
|
|
156
|
-
onConfirm();
|
|
157
|
-
}
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
Alert.alert(title, message, [{
|
|
161
|
-
text: "Cancel",
|
|
162
|
-
style: "cancel"
|
|
163
|
-
}, {
|
|
164
|
-
text: confirmLabel,
|
|
165
|
-
style: "destructive",
|
|
166
|
-
onPress: onConfirm
|
|
167
|
-
}]);
|
|
168
|
-
};
|
|
169
|
-
const handleGoBack = () => {
|
|
170
|
-
// Gate behind Pro
|
|
171
|
-
if (!isPro) {
|
|
172
|
-
setShowUpgradeModal(true);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (isAtRoot) {
|
|
176
|
-
Alert.alert("Cannot Go Back", "Already at the root of the stack");
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
goBack();
|
|
180
|
-
};
|
|
181
|
-
const handlePopToTop = () => {
|
|
182
|
-
// Gate behind Pro
|
|
183
|
-
if (!isPro) {
|
|
184
|
-
setShowUpgradeModal(true);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (isAtRoot) {
|
|
188
|
-
Alert.alert("Already at Top", "Stack only has one screen");
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
confirmDestructive("Pop to Top", "This will remove all screens except the root screen.", "Pop to Top", popToTop);
|
|
192
|
-
};
|
|
193
|
-
const toggleExpand = index => {
|
|
194
|
-
setExpandedIndex(expandedIndex === index ? null : index);
|
|
195
|
-
};
|
|
196
|
-
const handleGo = () => {
|
|
197
|
-
// Gate behind Pro
|
|
198
|
-
if (!isPro) {
|
|
199
|
-
setShowUpgradeModal(true);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (!selectedRoute) return;
|
|
203
|
-
|
|
204
|
-
// If the selected route is already focused, do nothing
|
|
205
|
-
if (selectedRoute.isFocused) {
|
|
206
|
-
Alert.alert("Already There", "This route is already visible");
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Navigate to the selected route
|
|
211
|
-
navigateToIndex(selectedRoute.index);
|
|
212
|
-
};
|
|
213
|
-
const handlePopTo = () => {
|
|
214
|
-
// Gate behind Pro
|
|
215
|
-
if (!isPro) {
|
|
216
|
-
setShowUpgradeModal(true);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (!selectedRoute) return;
|
|
220
|
-
|
|
221
|
-
// If selected route is the focused one, we can't pop to it
|
|
222
|
-
if (selectedRoute.isFocused) {
|
|
223
|
-
Alert.alert("Cannot Pop", "Selected route is already visible");
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// If selected route is at the top of stack, nothing to pop
|
|
228
|
-
if (selectedRoute.index === stackDepth - 1) {
|
|
229
|
-
Alert.alert("Cannot Pop", "No screens above selected route");
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
const screensToRemove = stackDepth - 1 - selectedRoute.index;
|
|
233
|
-
const targetIndex = selectedRoute.index;
|
|
234
|
-
confirmDestructive("Pop to Route", `Remove ${screensToRemove} screen${screensToRemove !== 1 ? "s" : ""} above ${selectedRoute.pathname}?`, "Pop",
|
|
235
|
-
// POP, not navigate. `navigate` only returns to a mounted screen when
|
|
236
|
-
// the name AND the params match, so on any dynamic route — the common
|
|
237
|
-
// case for a stack you would want to unwind — it pushed a fresh copy
|
|
238
|
-
// instead: the dialog promised to remove two screens and the stack came
|
|
239
|
-
// back one deeper, with the route in it twice. `popToIndex` is the
|
|
240
|
-
// action the hook has always exported for this, and the same one the
|
|
241
|
-
// desktop host already dispatches over the socket.
|
|
242
|
-
() => popToIndex(targetIndex));
|
|
243
|
-
};
|
|
244
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
245
|
-
style: [styles.container, style],
|
|
246
|
-
children: [/*#__PURE__*/_jsx(ScrollView, {
|
|
247
|
-
testID: "buoy-routes-stack-scroll",
|
|
248
|
-
style: styles.stackScroll,
|
|
249
|
-
contentContainerStyle: [styles.stackContent, {
|
|
250
|
-
paddingBottom: styles.stackContent.padding + insets.bottom
|
|
251
|
-
}],
|
|
252
|
-
children: [...stack].reverse().map((item, reverseIndex) => {
|
|
253
|
-
const actualIndex = stack.length - 1 - reverseIndex;
|
|
254
|
-
const isExpanded = expandedIndex === actualIndex;
|
|
255
|
-
const hasParams = Object.keys(item.params).length > 0;
|
|
256
|
-
const itemTestID = stackItemTestID(actualIndex);
|
|
257
|
-
return /*#__PURE__*/_jsx(View, {
|
|
258
|
-
style: styles.stackItemWrapper,
|
|
259
|
-
testID: itemTestID,
|
|
260
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
261
|
-
style: [styles.stackItem, isExpanded && styles.stackItemSelected],
|
|
262
|
-
children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
263
|
-
style: styles.stackItemHeader,
|
|
264
|
-
onPress: () => toggleExpand(actualIndex),
|
|
265
|
-
activeOpacity: 0.7,
|
|
266
|
-
testID: `${itemTestID}-toggle`,
|
|
267
|
-
accessibilityRole: "button",
|
|
268
|
-
accessibilityLabel: `${item.pathname}, ${item.isFocused ? "focused" : "mounted"}, position ${actualIndex} of ${stackDepth - 1}`,
|
|
269
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
270
|
-
style: styles.expandIndicator,
|
|
271
|
-
children: isExpanded ? /*#__PURE__*/_jsx(ChevronDown, {
|
|
272
|
-
size: 14,
|
|
273
|
-
color: night.color.textSecondary
|
|
274
|
-
}) : /*#__PURE__*/_jsx(ChevronRight, {
|
|
275
|
-
size: 14,
|
|
276
|
-
color: night.color.textSecondary
|
|
277
|
-
})
|
|
278
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
279
|
-
style: styles.stackItemPath,
|
|
280
|
-
numberOfLines: 1,
|
|
281
|
-
testID: `${itemTestID}-path`,
|
|
282
|
-
children: item.pathname
|
|
283
|
-
}), /*#__PURE__*/_jsx(InlineCopyButton, {
|
|
284
|
-
value: item.pathname,
|
|
285
|
-
buttonStyle: styles.copyRouteButton,
|
|
286
|
-
testID: `${itemTestID}-copy`
|
|
287
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
288
|
-
style: [styles.statusBadge, {
|
|
289
|
-
backgroundColor: item.isFocused ? `${buoyColors.success}15` : "#3B82F615",
|
|
290
|
-
borderColor: item.isFocused ? `${buoyColors.success}40` : "#3B82F640"
|
|
291
|
-
}],
|
|
292
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
293
|
-
style: [styles.statusBadgeText, {
|
|
294
|
-
color: item.isFocused ? buoyColors.success : "#3B82F6"
|
|
295
|
-
}],
|
|
296
|
-
testID: `${itemTestID}-status`,
|
|
297
|
-
children: item.isFocused ? "FOCUSED" : "MOUNTED"
|
|
298
|
-
})
|
|
299
|
-
})]
|
|
300
|
-
}), isExpanded && /*#__PURE__*/_jsxs(View, {
|
|
301
|
-
style: styles.expandedContent,
|
|
302
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
303
|
-
style: styles.detailRow,
|
|
304
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
305
|
-
style: styles.detailLabel,
|
|
306
|
-
children: "Route Name:"
|
|
307
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
308
|
-
style: styles.detailValue,
|
|
309
|
-
testID: `${itemTestID}-name`,
|
|
310
|
-
children: item.name
|
|
311
|
-
})]
|
|
312
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
313
|
-
style: styles.detailRow,
|
|
314
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
315
|
-
style: styles.detailLabel,
|
|
316
|
-
children: "Position:"
|
|
317
|
-
}), /*#__PURE__*/_jsxs(Text, {
|
|
318
|
-
style: styles.detailValue,
|
|
319
|
-
testID: `${itemTestID}-position`,
|
|
320
|
-
children: [actualIndex, " / ", stackDepth - 1]
|
|
321
|
-
})]
|
|
322
|
-
}), hasParams && /*#__PURE__*/_jsx(View, {
|
|
323
|
-
style: styles.dataViewerContainer,
|
|
324
|
-
children: /*#__PURE__*/_jsx(DataViewer, {
|
|
325
|
-
title: "Parameters",
|
|
326
|
-
data: item.params,
|
|
327
|
-
showTypeFilter: false
|
|
328
|
-
})
|
|
329
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
330
|
-
style: styles.actionsRow,
|
|
331
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
332
|
-
style: styles.actionWrapper,
|
|
333
|
-
children: [/*#__PURE__*/_jsx(TouchableOpacity, {
|
|
334
|
-
style: [styles.actionButton, isAtRoot && styles.actionButtonDisabled],
|
|
335
|
-
onPress: handleGoBack,
|
|
336
|
-
disabled: isAtRoot,
|
|
337
|
-
testID: `${itemTestID}-back`,
|
|
338
|
-
accessibilityRole: "button",
|
|
339
|
-
accessibilityLabel: "Go back one screen",
|
|
340
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
341
|
-
style: [styles.actionButtonText, isAtRoot && styles.actionButtonTextDisabled],
|
|
342
|
-
children: "Back"
|
|
343
|
-
})
|
|
344
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
345
|
-
style: styles.helpText,
|
|
346
|
-
children: "Go back one screen"
|
|
347
|
-
})]
|
|
348
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
349
|
-
style: styles.actionWrapper,
|
|
350
|
-
children: [/*#__PURE__*/_jsx(TouchableOpacity, {
|
|
351
|
-
style: [styles.actionButton, item.isFocused && styles.actionButtonDisabled],
|
|
352
|
-
onPress: handleGo,
|
|
353
|
-
disabled: item.isFocused,
|
|
354
|
-
testID: `${itemTestID}-go`,
|
|
355
|
-
accessibilityRole: "button",
|
|
356
|
-
accessibilityLabel: `Navigate to ${item.pathname}`,
|
|
357
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
358
|
-
style: [styles.actionButtonText, item.isFocused && styles.actionButtonTextDisabled],
|
|
359
|
-
children: "Go"
|
|
360
|
-
})
|
|
361
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
362
|
-
style: styles.helpText,
|
|
363
|
-
children: "Navigate to this route"
|
|
364
|
-
})]
|
|
365
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
366
|
-
style: styles.actionWrapper,
|
|
367
|
-
children: [/*#__PURE__*/_jsx(TouchableOpacity, {
|
|
368
|
-
style: [styles.actionButton, (item.isFocused || actualIndex === stackDepth - 1) && styles.actionButtonDisabled],
|
|
369
|
-
onPress: handlePopTo,
|
|
370
|
-
disabled: item.isFocused || actualIndex === stackDepth - 1,
|
|
371
|
-
testID: `${itemTestID}-pop-to`,
|
|
372
|
-
accessibilityRole: "button",
|
|
373
|
-
accessibilityLabel: `Remove screens above ${item.pathname}`,
|
|
374
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
375
|
-
style: [styles.actionButtonText, (item.isFocused || actualIndex === stackDepth - 1) && styles.actionButtonTextDisabled],
|
|
376
|
-
children: "Pop To"
|
|
377
|
-
})
|
|
378
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
379
|
-
style: styles.helpText,
|
|
380
|
-
children: "Remove screens above this"
|
|
381
|
-
})]
|
|
382
|
-
})]
|
|
383
|
-
})]
|
|
384
|
-
})]
|
|
385
|
-
})
|
|
386
|
-
}, `stack-${actualIndex}-${item.key}`);
|
|
387
|
-
})
|
|
388
|
-
}), /*#__PURE__*/_jsx(ProUpgradeModal, {
|
|
389
|
-
visible: showUpgradeModal,
|
|
390
|
-
onClose: () => setShowUpgradeModal(false),
|
|
391
|
-
featureName: "Stack Navigation"
|
|
392
|
-
})]
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// ============================================================================
|
|
397
|
-
// Styles
|
|
398
|
-
// ============================================================================
|
|
399
|
-
|
|
400
|
-
const styles = StyleSheet.create({
|
|
401
|
-
container: {
|
|
402
|
-
flex: 1,
|
|
403
|
-
// Transparent so JsModal's ToolBackground shows through (the modal paints opaque base beneath it).
|
|
404
|
-
backgroundColor: "transparent"
|
|
405
|
-
},
|
|
406
|
-
loadingContainer: {
|
|
407
|
-
flex: 1,
|
|
408
|
-
justifyContent: "center",
|
|
409
|
-
alignItems: "center",
|
|
410
|
-
padding: 32
|
|
411
|
-
},
|
|
412
|
-
loadingText: {
|
|
413
|
-
color: night.color.textSecondary,
|
|
414
|
-
fontSize: 14,
|
|
415
|
-
fontFamily: monoFont
|
|
416
|
-
},
|
|
417
|
-
errorContainer: {
|
|
418
|
-
flex: 1,
|
|
419
|
-
justifyContent: "center",
|
|
420
|
-
alignItems: "center",
|
|
421
|
-
padding: 32
|
|
422
|
-
},
|
|
423
|
-
errorText: {
|
|
424
|
-
color: buoyColors.error,
|
|
425
|
-
fontSize: 16,
|
|
426
|
-
fontWeight: "600",
|
|
427
|
-
fontFamily: monoFont,
|
|
428
|
-
marginBottom: 8
|
|
429
|
-
},
|
|
430
|
-
errorDetail: {
|
|
431
|
-
color: night.color.textSecondary,
|
|
432
|
-
fontSize: 12,
|
|
433
|
-
fontFamily: monoFont,
|
|
434
|
-
textAlign: "center"
|
|
435
|
-
},
|
|
436
|
-
emptyContainer: {
|
|
437
|
-
flex: 1,
|
|
438
|
-
justifyContent: "center",
|
|
439
|
-
alignItems: "center",
|
|
440
|
-
padding: 32
|
|
441
|
-
},
|
|
442
|
-
emptyText: {
|
|
443
|
-
color: night.color.text,
|
|
444
|
-
fontSize: 16,
|
|
445
|
-
fontWeight: "600",
|
|
446
|
-
fontFamily: monoFont,
|
|
447
|
-
marginBottom: 8
|
|
448
|
-
},
|
|
449
|
-
emptySubtext: {
|
|
450
|
-
color: night.color.textSecondary,
|
|
451
|
-
fontSize: 14,
|
|
452
|
-
fontFamily: monoFont,
|
|
453
|
-
textAlign: "center"
|
|
454
|
-
},
|
|
455
|
-
stackScroll: {
|
|
456
|
-
flex: 1
|
|
457
|
-
},
|
|
458
|
-
stackContent: {
|
|
459
|
-
padding: 8
|
|
460
|
-
},
|
|
461
|
-
stackItemWrapper: {
|
|
462
|
-
marginBottom: 6
|
|
463
|
-
},
|
|
464
|
-
stackItem: {
|
|
465
|
-
backgroundColor: night.color.surface,
|
|
466
|
-
borderRadius: 6,
|
|
467
|
-
borderWidth: 1,
|
|
468
|
-
borderColor: night.color.border,
|
|
469
|
-
overflow: "hidden"
|
|
470
|
-
},
|
|
471
|
-
stackItemSelected: {
|
|
472
|
-
borderColor: night.color.accent,
|
|
473
|
-
borderWidth: 2
|
|
474
|
-
},
|
|
475
|
-
stackItemHeader: {
|
|
476
|
-
flexDirection: "row",
|
|
477
|
-
alignItems: "center",
|
|
478
|
-
paddingVertical: 10,
|
|
479
|
-
paddingHorizontal: 12,
|
|
480
|
-
gap: 8
|
|
481
|
-
},
|
|
482
|
-
expandIndicator: {
|
|
483
|
-
width: 20,
|
|
484
|
-
alignItems: "center"
|
|
485
|
-
},
|
|
486
|
-
stackItemPath: {
|
|
487
|
-
fontSize: 13,
|
|
488
|
-
fontWeight: "600",
|
|
489
|
-
color: night.color.text,
|
|
490
|
-
fontFamily: monoFont,
|
|
491
|
-
flex: 1
|
|
492
|
-
},
|
|
493
|
-
copyRouteButton: {
|
|
494
|
-
padding: 4,
|
|
495
|
-
marginLeft: 4
|
|
496
|
-
},
|
|
497
|
-
statusBadge: {
|
|
498
|
-
borderRadius: 4,
|
|
499
|
-
paddingHorizontal: 6,
|
|
500
|
-
paddingVertical: 2,
|
|
501
|
-
borderWidth: 1
|
|
502
|
-
},
|
|
503
|
-
statusBadgeText: {
|
|
504
|
-
fontSize: 10,
|
|
505
|
-
fontWeight: "600",
|
|
506
|
-
fontFamily: monoFont
|
|
507
|
-
},
|
|
508
|
-
expandedContent: {
|
|
509
|
-
paddingHorizontal: 12,
|
|
510
|
-
paddingTop: 8,
|
|
511
|
-
paddingBottom: 12,
|
|
512
|
-
borderTopWidth: 1,
|
|
513
|
-
borderTopColor: night.color.border
|
|
514
|
-
},
|
|
515
|
-
detailRow: {
|
|
516
|
-
marginBottom: 8
|
|
517
|
-
},
|
|
518
|
-
detailLabel: {
|
|
519
|
-
fontSize: 10,
|
|
520
|
-
color: night.color.textSecondary,
|
|
521
|
-
fontFamily: monoFont,
|
|
522
|
-
marginBottom: 2
|
|
523
|
-
},
|
|
524
|
-
detailValue: {
|
|
525
|
-
fontSize: 12,
|
|
526
|
-
color: night.color.text,
|
|
527
|
-
fontFamily: monoFont
|
|
528
|
-
},
|
|
529
|
-
dataViewerContainer: {
|
|
530
|
-
marginTop: 4,
|
|
531
|
-
marginHorizontal: -12,
|
|
532
|
-
marginBottom: 8
|
|
533
|
-
},
|
|
534
|
-
actionsRow: {
|
|
535
|
-
flexDirection: "row",
|
|
536
|
-
gap: 6,
|
|
537
|
-
marginTop: 12
|
|
538
|
-
},
|
|
539
|
-
actionWrapper: {
|
|
540
|
-
flex: 1
|
|
541
|
-
},
|
|
542
|
-
actionButton: {
|
|
543
|
-
backgroundColor: night.color.surfaceElevated,
|
|
544
|
-
paddingVertical: 8,
|
|
545
|
-
paddingHorizontal: 8,
|
|
546
|
-
borderRadius: 6,
|
|
547
|
-
alignItems: "center"
|
|
548
|
-
},
|
|
549
|
-
actionButtonDisabled: {
|
|
550
|
-
opacity: 0.5
|
|
551
|
-
},
|
|
552
|
-
actionButtonText: {
|
|
553
|
-
fontSize: 12,
|
|
554
|
-
fontWeight: "600",
|
|
555
|
-
color: night.color.text,
|
|
556
|
-
fontFamily: monoFont
|
|
557
|
-
},
|
|
558
|
-
actionButtonTextDisabled: {
|
|
559
|
-
color: night.color.textTertiary
|
|
560
|
-
},
|
|
561
|
-
helpText: {
|
|
562
|
-
fontSize: 9,
|
|
563
|
-
color: night.color.textSecondary,
|
|
564
|
-
fontFamily: monoFont,
|
|
565
|
-
textAlign: "center",
|
|
566
|
-
marginTop: 4,
|
|
567
|
-
lineHeight: 12
|
|
568
|
-
}
|
|
569
|
-
});
|
|
3
|
+
${l}`)){b()}return}T.alert(t,l,[{text:"Cancel",style:"cancel"},{text:c,style:"destructive",onPress:b}])};const U=()=>{if(!x){m(true);return}if(k){T.alert("Cannot Go Back","Already at the root of the stack");return}O()};const ie=()=>{if(!x){m(true);return}if(k){T.alert("Already at Top","Stack only has one screen");return}W("Pop to Top","This will remove all screens except the root screen.","Pop to Top",G)};const _=t=>{M(u===t?null:t)};const A=()=>{if(!x){m(true);return}if(!h)return;if(h.isFocused){T.alert("Already There","This route is already visible");return}j(h.index)};const J=()=>{if(!x){m(true);return}if(!h)return;if(h.isFocused){T.alert("Cannot Pop","Selected route is already visible");return}if(h.index===g-1){T.alert("Cannot Pop","No screens above selected route");return}const t=g-1-h.index;const l=h.index;W("Pop to Route",`Remove ${t} screen${t!==1?"s":""} above ${h.pathname}?`,"Pop",()=>H(l))};return i(n,{style:[e.container,I],children:[o(q,{testID:"buoy-routes-stack-scroll",style:e.stackScroll,contentContainerStyle:[e.stackContent,{paddingBottom:e.stackContent.padding+V.bottom}],children:[...s].reverse().map((t,l)=>{const c=s.length-1-l;const b=u===c;const B=Object.keys(t.params).length>0;const p=re(c);return o(n,{style:e.stackItemWrapper,testID:p,children:i(n,{style:[e.stackItem,b&&e.stackItemSelected],children:[i(D,{style:e.stackItemHeader,onPress:()=>_(c),activeOpacity:.7,testID:`${p}-toggle`,accessibilityRole:"button",accessibilityLabel:`${t.pathname}, ${t.isFocused?"focused":"mounted"}, position ${c} of ${g-1}`,children:[o(n,{style:e.expandIndicator,children:b?o(Q,{size:14,color:a.color.textSecondary}):o(X,{size:14,color:a.color.textSecondary})}),o(r,{style:e.stackItemPath,numberOfLines:1,testID:`${p}-path`,children:t.pathname}),o(Y,{value:t.pathname,buttonStyle:e.copyRouteButton,testID:`${p}-copy`}),o(n,{style:[e.statusBadge,{backgroundColor:t.isFocused?`${F.success}15`:"#3B82F615",borderColor:t.isFocused?`${F.success}40`:"#3B82F640"}],children:o(r,{style:[e.statusBadgeText,{color:t.isFocused?F.success:"#3B82F6"}],testID:`${p}-status`,children:t.isFocused?"FOCUSED":"MOUNTED"})})]}),b&&i(n,{style:e.expandedContent,children:[i(n,{style:e.detailRow,children:[o(r,{style:e.detailLabel,children:"Route Name:"}),o(r,{style:e.detailValue,testID:`${p}-name`,children:t.name})]}),i(n,{style:e.detailRow,children:[o(r,{style:e.detailLabel,children:"Position:"}),i(r,{style:e.detailValue,testID:`${p}-position`,children:[c," / ",g-1]})]}),B&&o(n,{style:e.dataViewerContainer,children:o(ne,{title:"Parameters",data:t.params,showTypeFilter:false})}),i(n,{style:e.actionsRow,children:[i(n,{style:e.actionWrapper,children:[o(D,{style:[e.actionButton,k&&e.actionButtonDisabled],onPress:U,disabled:k,testID:`${p}-back`,accessibilityRole:"button",accessibilityLabel:"Go back one screen",children:o(r,{style:[e.actionButtonText,k&&e.actionButtonTextDisabled],children:"Back"})}),o(r,{style:e.helpText,children:"Go back one screen"})]}),i(n,{style:e.actionWrapper,children:[o(D,{style:[e.actionButton,t.isFocused&&e.actionButtonDisabled],onPress:A,disabled:t.isFocused,testID:`${p}-go`,accessibilityRole:"button",accessibilityLabel:`Navigate to ${t.pathname}`,children:o(r,{style:[e.actionButtonText,t.isFocused&&e.actionButtonTextDisabled],children:"Go"})}),o(r,{style:e.helpText,children:"Navigate to this route"})]}),i(n,{style:e.actionWrapper,children:[o(D,{style:[e.actionButton,(t.isFocused||c===g-1)&&e.actionButtonDisabled],onPress:J,disabled:t.isFocused||c===g-1,testID:`${p}-pop-to`,accessibilityRole:"button",accessibilityLabel:`Remove screens above ${t.pathname}`,children:o(r,{style:[e.actionButtonText,(t.isFocused||c===g-1)&&e.actionButtonTextDisabled],children:"Pop To"})}),o(r,{style:e.helpText,children:"Remove screens above this"})]})]})]})]})},`stack-${c}-${t.key}`)})}),o(Z,{visible:C,onClose:()=>m(false),featureName:"Stack Navigation"})]})}const e=K.create({container:{flex:1,backgroundColor:"transparent"},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},loadingText:{color:a.color.textSecondary,fontSize:14,fontFamily:d},errorContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},errorText:{color:F.error,fontSize:16,fontWeight:"600",fontFamily:d,marginBottom:8},errorDetail:{color:a.color.textSecondary,fontSize:12,fontFamily:d,textAlign:"center"},emptyContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyText:{color:a.color.text,fontSize:16,fontWeight:"600",fontFamily:d,marginBottom:8},emptySubtext:{color:a.color.textSecondary,fontSize:14,fontFamily:d,textAlign:"center"},stackScroll:{flex:1},stackContent:{padding:8},stackItemWrapper:{marginBottom:6},stackItem:{backgroundColor:a.color.surface,borderRadius:6,borderWidth:1,borderColor:a.color.border,overflow:"hidden"},stackItemSelected:{borderColor:a.color.accent,borderWidth:2},stackItemHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:12,gap:8},expandIndicator:{width:20,alignItems:"center"},stackItemPath:{fontSize:13,fontWeight:"600",color:a.color.text,fontFamily:d,flex:1},copyRouteButton:{padding:4,marginLeft:4},statusBadge:{borderRadius:4,paddingHorizontal:6,paddingVertical:2,borderWidth:1},statusBadgeText:{fontSize:10,fontWeight:"600",fontFamily:d},expandedContent:{paddingHorizontal:12,paddingTop:8,paddingBottom:12,borderTopWidth:1,borderTopColor:a.color.border},detailRow:{marginBottom:8},detailLabel:{fontSize:10,color:a.color.textSecondary,fontFamily:d,marginBottom:2},detailValue:{fontSize:12,color:a.color.text,fontFamily:d},dataViewerContainer:{marginTop:4,marginHorizontal:-12,marginBottom:8},actionsRow:{flexDirection:"row",gap:6,marginTop:12},actionWrapper:{flex:1},actionButton:{backgroundColor:a.color.surfaceElevated,paddingVertical:8,paddingHorizontal:8,borderRadius:6,alignItems:"center"},actionButtonDisabled:{opacity:.5},actionButtonText:{fontSize:12,fontWeight:"600",color:a.color.text,fontFamily:d},actionButtonTextDisabled:{color:a.color.textTertiary},helpText:{fontSize:9,color:a.color.textSecondary,fontFamily:d,textAlign:"center",marginTop:4,lineHeight:12}});
|