@idealyst/mcp-server 1.0.87 → 1.0.88
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/ARCHITECTURE.md +313 -0
- package/README.md +292 -104
- package/TYPE-SYSTEM.md +397 -0
- package/dist/index.js +170 -1
- package/examples/components/Accordion.examples.tsx +147 -0
- package/examples/components/ActivityIndicator.examples.tsx +350 -0
- package/examples/components/Alert.examples.tsx +335 -0
- package/examples/components/Avatar.examples.tsx +188 -0
- package/examples/components/Badge.examples.tsx +242 -0
- package/examples/components/Breadcrumb.examples.tsx +303 -0
- package/examples/components/Button.examples.tsx +113 -0
- package/examples/components/Card.examples.tsx +131 -0
- package/examples/components/Checkbox.examples.tsx +195 -0
- package/examples/components/Chip.examples.tsx +87 -0
- package/examples/components/Dialog.examples.tsx +344 -0
- package/examples/components/Divider.examples.tsx +258 -0
- package/examples/components/Icon.examples.tsx +202 -0
- package/examples/components/Input.examples.tsx +205 -0
- package/examples/components/Menu.examples.tsx +321 -0
- package/examples/components/Popover.examples.tsx +439 -0
- package/examples/components/Progress.examples.tsx +340 -0
- package/examples/components/RadioButton.examples.tsx +443 -0
- package/examples/components/Screen.examples.tsx +347 -0
- package/examples/components/Select.examples.tsx +279 -0
- package/examples/components/Skeleton.examples.tsx +278 -0
- package/examples/components/Slider.examples.tsx +249 -0
- package/examples/components/Switch.examples.tsx +94 -0
- package/examples/components/TabBar.examples.tsx +356 -0
- package/examples/components/Text.examples.tsx +177 -0
- package/examples/components/TextArea.examples.tsx +203 -0
- package/examples/components/Tooltip.examples.tsx +318 -0
- package/examples/components/View.examples.tsx +307 -0
- package/package.json +15 -2
- package/scripts/extract-types.ts +71 -0
- package/scripts/type-extractor.ts +286 -0
- package/scripts/validate-examples.ts +142 -0
- package/src/data/components/Icon.ts +1 -1
- package/src/data/components/index.ts +2 -0
- package/src/index.ts +181 -1
- package/src/tools/get-types.ts +169 -0
- package/tsconfig.examples.json +14 -0
- package/dist/data/cli-commands.d.ts +0 -2
- package/dist/data/cli-commands.d.ts.map +0 -1
- package/dist/data/cli-commands.js +0 -100
- package/dist/data/cli-commands.js.map +0 -1
- package/dist/data/components/Accordion.d.ts +0 -15
- package/dist/data/components/Accordion.d.ts.map +0 -1
- package/dist/data/components/Accordion.js +0 -112
- package/dist/data/components/Accordion.js.map +0 -1
- package/dist/data/components/ActivityIndicator.d.ts +0 -15
- package/dist/data/components/ActivityIndicator.d.ts.map +0 -1
- package/dist/data/components/ActivityIndicator.js +0 -82
- package/dist/data/components/ActivityIndicator.js.map +0 -1
- package/dist/data/components/Alert.d.ts +0 -15
- package/dist/data/components/Alert.d.ts.map +0 -1
- package/dist/data/components/Alert.js +0 -132
- package/dist/data/components/Alert.js.map +0 -1
- package/dist/data/components/Avatar.d.ts +0 -15
- package/dist/data/components/Avatar.d.ts.map +0 -1
- package/dist/data/components/Avatar.js +0 -93
- package/dist/data/components/Avatar.js.map +0 -1
- package/dist/data/components/Badge.d.ts +0 -15
- package/dist/data/components/Badge.d.ts.map +0 -1
- package/dist/data/components/Badge.js +0 -64
- package/dist/data/components/Badge.js.map +0 -1
- package/dist/data/components/Breadcrumb.d.ts +0 -15
- package/dist/data/components/Breadcrumb.d.ts.map +0 -1
- package/dist/data/components/Breadcrumb.js +0 -96
- package/dist/data/components/Breadcrumb.js.map +0 -1
- package/dist/data/components/Button.d.ts +0 -15
- package/dist/data/components/Button.d.ts.map +0 -1
- package/dist/data/components/Button.js +0 -87
- package/dist/data/components/Button.js.map +0 -1
- package/dist/data/components/Card.d.ts +0 -15
- package/dist/data/components/Card.d.ts.map +0 -1
- package/dist/data/components/Card.js +0 -67
- package/dist/data/components/Card.js.map +0 -1
- package/dist/data/components/Checkbox.d.ts +0 -15
- package/dist/data/components/Checkbox.d.ts.map +0 -1
- package/dist/data/components/Checkbox.js +0 -118
- package/dist/data/components/Checkbox.js.map +0 -1
- package/dist/data/components/Chip.d.ts +0 -15
- package/dist/data/components/Chip.d.ts.map +0 -1
- package/dist/data/components/Chip.js +0 -76
- package/dist/data/components/Chip.js.map +0 -1
- package/dist/data/components/Dialog.d.ts +0 -15
- package/dist/data/components/Dialog.d.ts.map +0 -1
- package/dist/data/components/Dialog.js +0 -137
- package/dist/data/components/Dialog.js.map +0 -1
- package/dist/data/components/Divider.d.ts +0 -15
- package/dist/data/components/Divider.d.ts.map +0 -1
- package/dist/data/components/Divider.js +0 -71
- package/dist/data/components/Divider.js.map +0 -1
- package/dist/data/components/Icon.d.ts +0 -15
- package/dist/data/components/Icon.d.ts.map +0 -1
- package/dist/data/components/Icon.js +0 -70
- package/dist/data/components/Icon.js.map +0 -1
- package/dist/data/components/Image.d.ts +0 -15
- package/dist/data/components/Image.d.ts.map +0 -1
- package/dist/data/components/Image.js +0 -122
- package/dist/data/components/Image.js.map +0 -1
- package/dist/data/components/Input.d.ts +0 -15
- package/dist/data/components/Input.d.ts.map +0 -1
- package/dist/data/components/Input.js +0 -109
- package/dist/data/components/Input.js.map +0 -1
- package/dist/data/components/List.d.ts +0 -15
- package/dist/data/components/List.d.ts.map +0 -1
- package/dist/data/components/List.js +0 -113
- package/dist/data/components/List.js.map +0 -1
- package/dist/data/components/Menu.d.ts +0 -15
- package/dist/data/components/Menu.d.ts.map +0 -1
- package/dist/data/components/Menu.js +0 -132
- package/dist/data/components/Menu.js.map +0 -1
- package/dist/data/components/Popover.d.ts +0 -15
- package/dist/data/components/Popover.d.ts.map +0 -1
- package/dist/data/components/Popover.js +0 -159
- package/dist/data/components/Popover.js.map +0 -1
- package/dist/data/components/Pressable.d.ts +0 -15
- package/dist/data/components/Pressable.d.ts.map +0 -1
- package/dist/data/components/Pressable.js +0 -125
- package/dist/data/components/Pressable.js.map +0 -1
- package/dist/data/components/Progress.d.ts +0 -15
- package/dist/data/components/Progress.d.ts.map +0 -1
- package/dist/data/components/Progress.js +0 -95
- package/dist/data/components/Progress.js.map +0 -1
- package/dist/data/components/RadioButton.d.ts +0 -15
- package/dist/data/components/RadioButton.d.ts.map +0 -1
- package/dist/data/components/RadioButton.js +0 -140
- package/dist/data/components/RadioButton.js.map +0 -1
- package/dist/data/components/SVGImage.d.ts +0 -15
- package/dist/data/components/SVGImage.d.ts.map +0 -1
- package/dist/data/components/SVGImage.js +0 -112
- package/dist/data/components/SVGImage.js.map +0 -1
- package/dist/data/components/Screen.d.ts +0 -15
- package/dist/data/components/Screen.d.ts.map +0 -1
- package/dist/data/components/Screen.js +0 -99
- package/dist/data/components/Screen.js.map +0 -1
- package/dist/data/components/Select.d.ts +0 -15
- package/dist/data/components/Select.d.ts.map +0 -1
- package/dist/data/components/Select.js +0 -146
- package/dist/data/components/Select.js.map +0 -1
- package/dist/data/components/Skeleton.d.ts +0 -15
- package/dist/data/components/Skeleton.d.ts.map +0 -1
- package/dist/data/components/Skeleton.js +0 -110
- package/dist/data/components/Skeleton.js.map +0 -1
- package/dist/data/components/Slider.d.ts +0 -15
- package/dist/data/components/Slider.d.ts.map +0 -1
- package/dist/data/components/Slider.js +0 -129
- package/dist/data/components/Slider.js.map +0 -1
- package/dist/data/components/Switch.d.ts +0 -15
- package/dist/data/components/Switch.d.ts.map +0 -1
- package/dist/data/components/Switch.js +0 -127
- package/dist/data/components/Switch.js.map +0 -1
- package/dist/data/components/TabBar.d.ts +0 -15
- package/dist/data/components/TabBar.d.ts.map +0 -1
- package/dist/data/components/TabBar.js +0 -145
- package/dist/data/components/TabBar.js.map +0 -1
- package/dist/data/components/Table.d.ts +0 -15
- package/dist/data/components/Table.d.ts.map +0 -1
- package/dist/data/components/Table.js +0 -151
- package/dist/data/components/Table.js.map +0 -1
- package/dist/data/components/Tabs.d.ts +0 -15
- package/dist/data/components/Tabs.d.ts.map +0 -1
- package/dist/data/components/Tabs.js +0 -150
- package/dist/data/components/Tabs.js.map +0 -1
- package/dist/data/components/Text.d.ts +0 -15
- package/dist/data/components/Text.d.ts.map +0 -1
- package/dist/data/components/Text.js +0 -85
- package/dist/data/components/Text.js.map +0 -1
- package/dist/data/components/TextArea.d.ts +0 -15
- package/dist/data/components/TextArea.d.ts.map +0 -1
- package/dist/data/components/TextArea.js +0 -155
- package/dist/data/components/TextArea.js.map +0 -1
- package/dist/data/components/Tooltip.d.ts +0 -15
- package/dist/data/components/Tooltip.d.ts.map +0 -1
- package/dist/data/components/Tooltip.js +0 -105
- package/dist/data/components/Tooltip.js.map +0 -1
- package/dist/data/components/Video.d.ts +0 -15
- package/dist/data/components/Video.d.ts.map +0 -1
- package/dist/data/components/Video.js +0 -168
- package/dist/data/components/Video.js.map +0 -1
- package/dist/data/components/View.d.ts +0 -15
- package/dist/data/components/View.d.ts.map +0 -1
- package/dist/data/components/View.js +0 -126
- package/dist/data/components/View.js.map +0 -1
- package/dist/data/components/index.d.ts +0 -37
- package/dist/data/components/index.d.ts.map +0 -1
- package/dist/data/components/index.js +0 -110
- package/dist/data/components/index.js.map +0 -1
- package/dist/data/framework-guides.d.ts +0 -2
- package/dist/data/framework-guides.d.ts.map +0 -1
- package/dist/data/framework-guides.js +0 -589
- package/dist/data/framework-guides.js.map +0 -1
- package/dist/data/icon-guide.d.ts +0 -2
- package/dist/data/icon-guide.d.ts.map +0 -1
- package/dist/data/icon-guide.js +0 -285
- package/dist/data/icon-guide.js.map +0 -1
- package/dist/data/icons.json +0 -7452
- package/dist/data/navigation-guides.d.ts +0 -2
- package/dist/data/navigation-guides.d.ts.map +0 -1
- package/dist/data/navigation-guides.js +0 -1196
- package/dist/data/navigation-guides.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,1196 +0,0 @@
|
|
|
1
|
-
export const navigationGuides = {
|
|
2
|
-
"idealyst://navigation/overview": `# Navigation System Overview
|
|
3
|
-
|
|
4
|
-
The Idealyst navigation system provides a unified API for both React Native and web applications, handling routing seamlessly across platforms.
|
|
5
|
-
|
|
6
|
-
## Core Concepts
|
|
7
|
-
|
|
8
|
-
### Cross-Platform Routing
|
|
9
|
-
- **Mobile (React Native)**: Uses React Navigation for native navigation patterns
|
|
10
|
-
- **Web**: Uses React Router for browser-based routing
|
|
11
|
-
- **Unified API**: Same code works on both platforms
|
|
12
|
-
|
|
13
|
-
### Route Types
|
|
14
|
-
|
|
15
|
-
There are two fundamental route types:
|
|
16
|
-
|
|
17
|
-
#### 1. Screen Routes
|
|
18
|
-
Renders a component directly to the screen:
|
|
19
|
-
\`\`\`tsx
|
|
20
|
-
{
|
|
21
|
-
path: "profile",
|
|
22
|
-
type: 'screen',
|
|
23
|
-
component: ProfileScreen
|
|
24
|
-
}
|
|
25
|
-
\`\`\`
|
|
26
|
-
|
|
27
|
-
#### 2. Navigator Routes
|
|
28
|
-
Wraps child routes with navigation structure:
|
|
29
|
-
\`\`\`tsx
|
|
30
|
-
{
|
|
31
|
-
path: "/",
|
|
32
|
-
type: 'navigator',
|
|
33
|
-
layout: 'stack', // or 'tab', 'drawer', 'modal'
|
|
34
|
-
routes: [
|
|
35
|
-
{ path: "home", type: 'screen', component: HomeScreen },
|
|
36
|
-
{ path: "settings", type: 'screen', component: SettingsScreen },
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
\`\`\`
|
|
40
|
-
|
|
41
|
-
## Setup
|
|
42
|
-
|
|
43
|
-
### Basic Setup
|
|
44
|
-
|
|
45
|
-
\`\`\`tsx
|
|
46
|
-
import { NavigatorProvider } from '@idealyst/navigation';
|
|
47
|
-
|
|
48
|
-
function App() {
|
|
49
|
-
return (
|
|
50
|
-
<NavigatorProvider route={appRouter}>
|
|
51
|
-
{/* Content managed by router */}
|
|
52
|
-
</NavigatorProvider>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
\`\`\`
|
|
56
|
-
|
|
57
|
-
### Quick Start with Examples
|
|
58
|
-
|
|
59
|
-
Use pre-built example routers for instant working navigation:
|
|
60
|
-
|
|
61
|
-
\`\`\`tsx
|
|
62
|
-
import { ExampleStackRouter } from '@idealyst/navigation/examples';
|
|
63
|
-
|
|
64
|
-
<NavigatorProvider route={ExampleStackRouter} />
|
|
65
|
-
\`\`\`
|
|
66
|
-
|
|
67
|
-
Available example routers:
|
|
68
|
-
- **ExampleStackRouter**: Desktop/web with header and sidebar
|
|
69
|
-
- **ExampleTabRouter**: Mobile with tab navigation
|
|
70
|
-
- **ExampleDrawerRouter**: Desktop with drawer menu
|
|
71
|
-
|
|
72
|
-
## Platform Differences
|
|
73
|
-
|
|
74
|
-
### Mobile (React Native)
|
|
75
|
-
- Stack navigator: Native stack navigation with animations
|
|
76
|
-
- Tab navigator: Bottom tab bar
|
|
77
|
-
- Drawer navigator: Side drawer with gestures
|
|
78
|
-
- Modal navigator: Full-screen modal presentation
|
|
79
|
-
|
|
80
|
-
### Web
|
|
81
|
-
- Stack navigator: Browser history-based routing
|
|
82
|
-
- Tab navigator: Top or side tab navigation
|
|
83
|
-
- All navigators: Use URL paths for routing
|
|
84
|
-
- Custom layouts: Can add headers, sidebars, footers
|
|
85
|
-
|
|
86
|
-
## Key Features
|
|
87
|
-
|
|
88
|
-
1. **Type-Safe Navigation**: Full TypeScript support
|
|
89
|
-
2. **Path Parameters**: \`/user/:id\` support
|
|
90
|
-
3. **Nested Routes**: Unlimited nesting depth
|
|
91
|
-
4. **Custom Layouts**: Web-specific layout components
|
|
92
|
-
5. **Theme Integration**: Works with @idealyst/theme
|
|
93
|
-
6. **Cross-Platform**: Write once, run everywhere
|
|
94
|
-
`,
|
|
95
|
-
"idealyst://navigation/route-configuration": `# Route Configuration
|
|
96
|
-
|
|
97
|
-
Learn how to define and structure routes in your Idealyst application.
|
|
98
|
-
|
|
99
|
-
## Route Definition
|
|
100
|
-
|
|
101
|
-
### Screen Route
|
|
102
|
-
|
|
103
|
-
The simplest route type - renders a component:
|
|
104
|
-
|
|
105
|
-
\`\`\`tsx
|
|
106
|
-
import { RouteParam } from '@idealyst/navigation';
|
|
107
|
-
|
|
108
|
-
const route: RouteParam = {
|
|
109
|
-
path: "profile",
|
|
110
|
-
type: 'screen',
|
|
111
|
-
component: ProfileScreen,
|
|
112
|
-
options: {
|
|
113
|
-
title: "User Profile",
|
|
114
|
-
headerShown: true
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
\`\`\`
|
|
118
|
-
|
|
119
|
-
### Navigator Route
|
|
120
|
-
|
|
121
|
-
A route that contains child routes:
|
|
122
|
-
|
|
123
|
-
\`\`\`tsx
|
|
124
|
-
const route: RouteParam = {
|
|
125
|
-
path: "/",
|
|
126
|
-
type: 'navigator',
|
|
127
|
-
layout: 'stack',
|
|
128
|
-
routes: [
|
|
129
|
-
{ path: "home", type: 'screen', component: HomeScreen },
|
|
130
|
-
{ path: "about", type: 'screen', component: AboutScreen },
|
|
131
|
-
],
|
|
132
|
-
options: {
|
|
133
|
-
headerShown: false
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
\`\`\`
|
|
137
|
-
|
|
138
|
-
## Path Configuration
|
|
139
|
-
|
|
140
|
-
### Basic Paths
|
|
141
|
-
|
|
142
|
-
\`\`\`tsx
|
|
143
|
-
{ path: "home", ... } // Relative: /parent/home
|
|
144
|
-
{ path: "/home", ... } // Absolute: /home
|
|
145
|
-
{ path: "", ... } // Index route
|
|
146
|
-
\`\`\`
|
|
147
|
-
|
|
148
|
-
### Path Parameters
|
|
149
|
-
|
|
150
|
-
\`\`\`tsx
|
|
151
|
-
{
|
|
152
|
-
path: "user/:id",
|
|
153
|
-
type: 'screen',
|
|
154
|
-
component: UserScreen
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Navigate with:
|
|
158
|
-
navigator.navigate({
|
|
159
|
-
path: "/user/:id",
|
|
160
|
-
vars: { id: "123" }
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// Access in component:
|
|
164
|
-
const navigator = useNavigator();
|
|
165
|
-
const userId = navigator.vars.id;
|
|
166
|
-
\`\`\`
|
|
167
|
-
|
|
168
|
-
### Optional Parameters
|
|
169
|
-
|
|
170
|
-
\`\`\`tsx
|
|
171
|
-
{ path: "search/:query?" } // query is optional
|
|
172
|
-
\`\`\`
|
|
173
|
-
|
|
174
|
-
## Screen Options
|
|
175
|
-
|
|
176
|
-
### Common Options
|
|
177
|
-
|
|
178
|
-
\`\`\`tsx
|
|
179
|
-
type ScreenOptions = {
|
|
180
|
-
title?: string; // Screen title
|
|
181
|
-
headerShown?: boolean; // Show/hide header (mobile)
|
|
182
|
-
};
|
|
183
|
-
\`\`\`
|
|
184
|
-
|
|
185
|
-
### Tab-Specific Options
|
|
186
|
-
|
|
187
|
-
For tab navigators:
|
|
188
|
-
|
|
189
|
-
\`\`\`tsx
|
|
190
|
-
type TabBarScreenOptions = {
|
|
191
|
-
tabBarIcon?: (props: {
|
|
192
|
-
focused: boolean;
|
|
193
|
-
color: string;
|
|
194
|
-
size: string | number
|
|
195
|
-
}) => React.ReactElement;
|
|
196
|
-
|
|
197
|
-
tabBarLabel?: string; // Tab label
|
|
198
|
-
tabBarBadge?: string | number; // Badge count
|
|
199
|
-
tabBarVisible?: boolean; // Show/hide tab
|
|
200
|
-
} & ScreenOptions;
|
|
201
|
-
\`\`\`
|
|
202
|
-
|
|
203
|
-
Example:
|
|
204
|
-
\`\`\`tsx
|
|
205
|
-
{
|
|
206
|
-
path: "home",
|
|
207
|
-
type: 'screen',
|
|
208
|
-
component: HomeScreen,
|
|
209
|
-
options: {
|
|
210
|
-
tabBarLabel: "Home",
|
|
211
|
-
tabBarIcon: ({ focused, color }) => (
|
|
212
|
-
<Icon name="home" color={color} />
|
|
213
|
-
),
|
|
214
|
-
tabBarBadge: 5
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
\`\`\`
|
|
218
|
-
|
|
219
|
-
## Navigator Options
|
|
220
|
-
|
|
221
|
-
Options for navigator routes:
|
|
222
|
-
|
|
223
|
-
\`\`\`tsx
|
|
224
|
-
type NavigatorOptions = {
|
|
225
|
-
headerTitle?: React.ComponentType | React.ReactElement | string;
|
|
226
|
-
headerLeft?: React.ComponentType | React.ReactElement;
|
|
227
|
-
headerBackVisible?: boolean;
|
|
228
|
-
headerRight?: React.ComponentType | React.ReactElement;
|
|
229
|
-
headerShown?: boolean;
|
|
230
|
-
};
|
|
231
|
-
\`\`\`
|
|
232
|
-
|
|
233
|
-
Example:
|
|
234
|
-
\`\`\`tsx
|
|
235
|
-
{
|
|
236
|
-
path: "/app",
|
|
237
|
-
type: 'navigator',
|
|
238
|
-
layout: 'stack',
|
|
239
|
-
routes: [...],
|
|
240
|
-
options: {
|
|
241
|
-
headerTitle: "My App",
|
|
242
|
-
headerShown: true,
|
|
243
|
-
headerRight: <UserMenu />
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
\`\`\`
|
|
247
|
-
|
|
248
|
-
## Nested Routes
|
|
249
|
-
|
|
250
|
-
Create hierarchical navigation:
|
|
251
|
-
|
|
252
|
-
\`\`\`tsx
|
|
253
|
-
const appRouter: RouteParam = {
|
|
254
|
-
path: "/",
|
|
255
|
-
type: 'navigator',
|
|
256
|
-
layout: 'stack',
|
|
257
|
-
routes: [
|
|
258
|
-
{
|
|
259
|
-
path: "dashboard",
|
|
260
|
-
type: 'navigator',
|
|
261
|
-
layout: 'tab',
|
|
262
|
-
routes: [
|
|
263
|
-
{ path: "overview", type: 'screen', component: OverviewScreen },
|
|
264
|
-
{ path: "analytics", type: 'screen', component: AnalyticsScreen },
|
|
265
|
-
{ path: "reports", type: 'screen', component: ReportsScreen },
|
|
266
|
-
]
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
path: "settings",
|
|
270
|
-
type: 'screen',
|
|
271
|
-
component: SettingsScreen
|
|
272
|
-
},
|
|
273
|
-
]
|
|
274
|
-
};
|
|
275
|
-
\`\`\`
|
|
276
|
-
|
|
277
|
-
## Full Path Resolution
|
|
278
|
-
|
|
279
|
-
Full paths are automatically computed:
|
|
280
|
-
- \`/dashboard/overview\`
|
|
281
|
-
- \`/dashboard/analytics\`
|
|
282
|
-
- \`/dashboard/reports\`
|
|
283
|
-
- \`/settings\`
|
|
284
|
-
|
|
285
|
-
## Best Practices
|
|
286
|
-
|
|
287
|
-
1. **Use relative paths** for child routes
|
|
288
|
-
2. **Keep nesting shallow** (3 levels max recommended)
|
|
289
|
-
3. **Group related screens** in navigators
|
|
290
|
-
4. **Use meaningful paths** that reflect content
|
|
291
|
-
5. **Define index routes** with empty path
|
|
292
|
-
6. **Set appropriate options** for each screen type
|
|
293
|
-
`,
|
|
294
|
-
"idealyst://navigation/navigator-types": `# Navigator Types
|
|
295
|
-
|
|
296
|
-
Idealyst supports four navigator types: stack, tab, drawer, and modal. Each provides different navigation patterns.
|
|
297
|
-
|
|
298
|
-
## Stack Navigator
|
|
299
|
-
|
|
300
|
-
Linear, hierarchical navigation - the most common pattern.
|
|
301
|
-
|
|
302
|
-
### Configuration
|
|
303
|
-
|
|
304
|
-
\`\`\`tsx
|
|
305
|
-
{
|
|
306
|
-
path: "/app",
|
|
307
|
-
type: 'navigator',
|
|
308
|
-
layout: 'stack',
|
|
309
|
-
routes: [
|
|
310
|
-
{ path: "", type: 'screen', component: HomeScreen },
|
|
311
|
-
{ path: "profile", type: 'screen', component: ProfileScreen },
|
|
312
|
-
{ path: "settings", type: 'screen', component: SettingsScreen },
|
|
313
|
-
]
|
|
314
|
-
}
|
|
315
|
-
\`\`\`
|
|
316
|
-
|
|
317
|
-
### Platform Behavior
|
|
318
|
-
|
|
319
|
-
**Mobile:**
|
|
320
|
-
- Native stack navigation with slide animations
|
|
321
|
-
- Hardware back button support
|
|
322
|
-
- Swipe-to-go-back gesture
|
|
323
|
-
|
|
324
|
-
**Web:**
|
|
325
|
-
- Browser history integration
|
|
326
|
-
- URL updates on navigation
|
|
327
|
-
- Back/forward browser buttons work
|
|
328
|
-
|
|
329
|
-
### Use Cases
|
|
330
|
-
- Main app navigation
|
|
331
|
-
- Detail views
|
|
332
|
-
- Settings flows
|
|
333
|
-
- Onboarding sequences
|
|
334
|
-
|
|
335
|
-
## Tab Navigator
|
|
336
|
-
|
|
337
|
-
Section-based navigation with a tab bar.
|
|
338
|
-
|
|
339
|
-
### Configuration
|
|
340
|
-
|
|
341
|
-
\`\`\`tsx
|
|
342
|
-
{
|
|
343
|
-
path: "/",
|
|
344
|
-
type: 'navigator',
|
|
345
|
-
layout: 'tab',
|
|
346
|
-
routes: [
|
|
347
|
-
{
|
|
348
|
-
path: "home",
|
|
349
|
-
type: 'screen',
|
|
350
|
-
component: HomeScreen,
|
|
351
|
-
options: {
|
|
352
|
-
tabBarLabel: "Home",
|
|
353
|
-
tabBarIcon: ({ color }) => <Icon name="home" color={color} />
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
path: "search",
|
|
358
|
-
type: 'screen',
|
|
359
|
-
component: SearchScreen,
|
|
360
|
-
options: {
|
|
361
|
-
tabBarLabel: "Search",
|
|
362
|
-
tabBarIcon: ({ color }) => <Icon name="search" color={color} />
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
]
|
|
366
|
-
}
|
|
367
|
-
\`\`\`
|
|
368
|
-
|
|
369
|
-
### Platform Behavior
|
|
370
|
-
|
|
371
|
-
**Mobile:**
|
|
372
|
-
- Bottom tab bar
|
|
373
|
-
- Tab icons and labels
|
|
374
|
-
- Badge support
|
|
375
|
-
- Active tab highlighting
|
|
376
|
-
|
|
377
|
-
**Web:**
|
|
378
|
-
- Top or side tabs
|
|
379
|
-
- Can use custom layout component
|
|
380
|
-
- URL-based tab switching
|
|
381
|
-
|
|
382
|
-
### Use Cases
|
|
383
|
-
- Main app sections
|
|
384
|
-
- Content categories
|
|
385
|
-
- Dashboard views
|
|
386
|
-
- Multi-section interfaces
|
|
387
|
-
|
|
388
|
-
## Drawer Navigator
|
|
389
|
-
|
|
390
|
-
Side menu navigation, primarily for desktop/tablet.
|
|
391
|
-
|
|
392
|
-
### Configuration
|
|
393
|
-
|
|
394
|
-
\`\`\`tsx
|
|
395
|
-
{
|
|
396
|
-
path: "/",
|
|
397
|
-
type: 'navigator',
|
|
398
|
-
layout: 'drawer',
|
|
399
|
-
routes: [
|
|
400
|
-
{ path: "dashboard", type: 'screen', component: DashboardScreen },
|
|
401
|
-
{ path: "users", type: 'screen', component: UsersScreen },
|
|
402
|
-
{ path: "settings", type: 'screen', component: SettingsScreen },
|
|
403
|
-
]
|
|
404
|
-
}
|
|
405
|
-
\`\`\`
|
|
406
|
-
|
|
407
|
-
### Platform Behavior
|
|
408
|
-
|
|
409
|
-
**Mobile:**
|
|
410
|
-
- Slide-out drawer
|
|
411
|
-
- Swipe gesture to open
|
|
412
|
-
- Overlay when open
|
|
413
|
-
|
|
414
|
-
**Web:**
|
|
415
|
-
- Sidebar navigation
|
|
416
|
-
- Can be persistent or overlay
|
|
417
|
-
- Responsive behavior
|
|
418
|
-
|
|
419
|
-
### Use Cases
|
|
420
|
-
- Admin panels
|
|
421
|
-
- Desktop applications
|
|
422
|
-
- Content management systems
|
|
423
|
-
- Multi-section apps
|
|
424
|
-
|
|
425
|
-
## Modal Navigator
|
|
426
|
-
|
|
427
|
-
Overlay navigation for temporary screens.
|
|
428
|
-
|
|
429
|
-
### Configuration
|
|
430
|
-
|
|
431
|
-
\`\`\`tsx
|
|
432
|
-
{
|
|
433
|
-
path: "/modals",
|
|
434
|
-
type: 'navigator',
|
|
435
|
-
layout: 'modal',
|
|
436
|
-
routes: [
|
|
437
|
-
{ path: "new-post", type: 'screen', component: NewPostScreen },
|
|
438
|
-
{ path: "edit-profile", type: 'screen', component: EditProfileScreen },
|
|
439
|
-
]
|
|
440
|
-
}
|
|
441
|
-
\`\`\`
|
|
442
|
-
|
|
443
|
-
### Platform Behavior
|
|
444
|
-
|
|
445
|
-
**Mobile:**
|
|
446
|
-
- Full-screen modal presentation
|
|
447
|
-
- Slide-up animation
|
|
448
|
-
- Close gesture support
|
|
449
|
-
|
|
450
|
-
**Web:**
|
|
451
|
-
- Overlay modal
|
|
452
|
-
- Background dimming
|
|
453
|
-
- Click-outside to close
|
|
454
|
-
|
|
455
|
-
### Use Cases
|
|
456
|
-
- Forms and data entry
|
|
457
|
-
- Action confirmations
|
|
458
|
-
- Image viewers
|
|
459
|
-
- Temporary content
|
|
460
|
-
|
|
461
|
-
## Combining Navigator Types
|
|
462
|
-
|
|
463
|
-
Navigators can be nested for complex flows:
|
|
464
|
-
|
|
465
|
-
\`\`\`tsx
|
|
466
|
-
const appRouter: RouteParam = {
|
|
467
|
-
path: "/",
|
|
468
|
-
type: 'navigator',
|
|
469
|
-
layout: 'stack',
|
|
470
|
-
routes: [
|
|
471
|
-
{
|
|
472
|
-
path: "main",
|
|
473
|
-
type: 'navigator',
|
|
474
|
-
layout: 'tab',
|
|
475
|
-
routes: [
|
|
476
|
-
{ path: "feed", type: 'screen', component: FeedScreen },
|
|
477
|
-
{ path: "profile", type: 'screen', component: ProfileScreen },
|
|
478
|
-
]
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
path: "modals",
|
|
482
|
-
type: 'navigator',
|
|
483
|
-
layout: 'modal',
|
|
484
|
-
routes: [
|
|
485
|
-
{ path: "create", type: 'screen', component: CreateScreen },
|
|
486
|
-
]
|
|
487
|
-
}
|
|
488
|
-
]
|
|
489
|
-
};
|
|
490
|
-
\`\`\`
|
|
491
|
-
|
|
492
|
-
## Choosing the Right Navigator
|
|
493
|
-
|
|
494
|
-
| Navigator | Mobile | Desktop | Use Case |
|
|
495
|
-
|-----------|--------|---------|----------|
|
|
496
|
-
| **Stack** | ✅ Primary | ✅ Primary | Hierarchical navigation |
|
|
497
|
-
| **Tab** | ✅ Primary | ✅ Secondary | Section-based navigation |
|
|
498
|
-
| **Drawer** | ⚠️ Secondary | ✅ Primary | Menu-based navigation |
|
|
499
|
-
| **Modal** | ✅ Common | ✅ Common | Temporary overlays |
|
|
500
|
-
|
|
501
|
-
## Best Practices
|
|
502
|
-
|
|
503
|
-
1. **Use stack for most flows** - It's the most universal pattern
|
|
504
|
-
2. **Limit tab count** - 3-5 tabs maximum for mobile
|
|
505
|
-
3. **Reserve drawers for complex apps** - Best on desktop
|
|
506
|
-
4. **Use modals sparingly** - For focused, temporary tasks
|
|
507
|
-
5. **Consider platform** - What works on mobile may not work on web
|
|
508
|
-
6. **Test navigation flow** - Ensure intuitive user experience
|
|
509
|
-
`,
|
|
510
|
-
"idealyst://navigation/custom-layouts": `# Custom Layouts (Web Only)
|
|
511
|
-
|
|
512
|
-
On web, navigators can use custom layout components to add headers, sidebars, and other UI around route content.
|
|
513
|
-
|
|
514
|
-
## GeneralLayout Component
|
|
515
|
-
|
|
516
|
-
The built-in \`GeneralLayout\` provides header and sidebar functionality:
|
|
517
|
-
|
|
518
|
-
### Basic Usage
|
|
519
|
-
|
|
520
|
-
\`\`\`tsx
|
|
521
|
-
import { GeneralLayout } from '@idealyst/navigation';
|
|
522
|
-
|
|
523
|
-
<GeneralLayout
|
|
524
|
-
header={{
|
|
525
|
-
enabled: true,
|
|
526
|
-
content: <Text>My App</Text>,
|
|
527
|
-
}}
|
|
528
|
-
sidebar={{
|
|
529
|
-
enabled: true,
|
|
530
|
-
content: <NavigationMenu />,
|
|
531
|
-
}}
|
|
532
|
-
>
|
|
533
|
-
{children}
|
|
534
|
-
</GeneralLayout>
|
|
535
|
-
\`\`\`
|
|
536
|
-
|
|
537
|
-
### Header Configuration
|
|
538
|
-
|
|
539
|
-
\`\`\`tsx
|
|
540
|
-
type HeaderConfig = {
|
|
541
|
-
enabled: boolean; // Show/hide header
|
|
542
|
-
height?: number; // Header height (default: 64)
|
|
543
|
-
content?: React.ReactNode; // Header content
|
|
544
|
-
style?: ViewStyle; // Custom styles
|
|
545
|
-
};
|
|
546
|
-
\`\`\`
|
|
547
|
-
|
|
548
|
-
Example:
|
|
549
|
-
\`\`\`tsx
|
|
550
|
-
header={{
|
|
551
|
-
enabled: true,
|
|
552
|
-
height: 80,
|
|
553
|
-
content: (
|
|
554
|
-
<View style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 16 }}>
|
|
555
|
-
<Text size="large" weight="bold">Dashboard</Text>
|
|
556
|
-
<UserMenu />
|
|
557
|
-
</View>
|
|
558
|
-
)
|
|
559
|
-
}}
|
|
560
|
-
\`\`\`
|
|
561
|
-
|
|
562
|
-
### Sidebar Configuration
|
|
563
|
-
|
|
564
|
-
\`\`\`tsx
|
|
565
|
-
type SidebarConfig = {
|
|
566
|
-
enabled: boolean; // Show/hide sidebar
|
|
567
|
-
collapsible?: boolean; // Allow collapse/expand
|
|
568
|
-
position?: 'left' | 'right'; // Sidebar position
|
|
569
|
-
initiallyExpanded?: boolean; // Initial state
|
|
570
|
-
expandedWidth?: number; // Width when expanded (default: 240)
|
|
571
|
-
collapsedWidth?: number; // Width when collapsed (default: 64)
|
|
572
|
-
content?: React.ReactNode; // Sidebar content
|
|
573
|
-
style?: ViewStyle; // Custom styles
|
|
574
|
-
};
|
|
575
|
-
\`\`\`
|
|
576
|
-
|
|
577
|
-
Example:
|
|
578
|
-
\`\`\`tsx
|
|
579
|
-
sidebar={{
|
|
580
|
-
enabled: true,
|
|
581
|
-
collapsible: true,
|
|
582
|
-
position: 'left',
|
|
583
|
-
initiallyExpanded: true,
|
|
584
|
-
expandedWidth: 280,
|
|
585
|
-
collapsedWidth: 72,
|
|
586
|
-
content: <NavigationSidebar />
|
|
587
|
-
}}
|
|
588
|
-
\`\`\`
|
|
589
|
-
|
|
590
|
-
## Using Layouts with Navigators
|
|
591
|
-
|
|
592
|
-
### Stack Navigator with Layout
|
|
593
|
-
|
|
594
|
-
\`\`\`tsx
|
|
595
|
-
import { CustomStackLayout } from './layouts/CustomStackLayout';
|
|
596
|
-
|
|
597
|
-
const router: NavigatorParam = {
|
|
598
|
-
path: "/",
|
|
599
|
-
type: 'navigator',
|
|
600
|
-
layout: 'stack',
|
|
601
|
-
layoutComponent: CustomStackLayout, // Web only!
|
|
602
|
-
routes: [
|
|
603
|
-
{ path: "", type: 'screen', component: HomeScreen },
|
|
604
|
-
{ path: "about", type: 'screen', component: AboutScreen },
|
|
605
|
-
]
|
|
606
|
-
};
|
|
607
|
-
\`\`\`
|
|
608
|
-
|
|
609
|
-
### Tab Navigator with Layout
|
|
610
|
-
|
|
611
|
-
\`\`\`tsx
|
|
612
|
-
import { CustomTabLayout } from './layouts/CustomTabLayout';
|
|
613
|
-
|
|
614
|
-
const router: NavigatorParam = {
|
|
615
|
-
path: "/",
|
|
616
|
-
type: 'navigator',
|
|
617
|
-
layout: 'tab',
|
|
618
|
-
layoutComponent: CustomTabLayout, // Web only!
|
|
619
|
-
routes: [
|
|
620
|
-
{ path: "feed", type: 'screen', component: FeedScreen },
|
|
621
|
-
{ path: "profile", type: 'screen', component: ProfileScreen },
|
|
622
|
-
]
|
|
623
|
-
};
|
|
624
|
-
\`\`\`
|
|
625
|
-
|
|
626
|
-
## Creating Custom Layouts
|
|
627
|
-
|
|
628
|
-
### Stack Layout Component
|
|
629
|
-
|
|
630
|
-
\`\`\`tsx
|
|
631
|
-
import { GeneralLayout } from '@idealyst/navigation';
|
|
632
|
-
import type { StackLayoutProps } from '@idealyst/navigation';
|
|
633
|
-
|
|
634
|
-
export const CustomStackLayout: React.FC<StackLayoutProps> = ({
|
|
635
|
-
children,
|
|
636
|
-
options,
|
|
637
|
-
routes,
|
|
638
|
-
currentPath
|
|
639
|
-
}) => {
|
|
640
|
-
return (
|
|
641
|
-
<GeneralLayout
|
|
642
|
-
header={{
|
|
643
|
-
enabled: true,
|
|
644
|
-
content: (
|
|
645
|
-
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
646
|
-
<Text>{options?.headerTitle || 'My App'}</Text>
|
|
647
|
-
{options?.headerRight}
|
|
648
|
-
</View>
|
|
649
|
-
)
|
|
650
|
-
}}
|
|
651
|
-
sidebar={{
|
|
652
|
-
enabled: true,
|
|
653
|
-
collapsible: true,
|
|
654
|
-
content: (
|
|
655
|
-
<NavigationMenu routes={routes} currentPath={currentPath} />
|
|
656
|
-
)
|
|
657
|
-
}}
|
|
658
|
-
>
|
|
659
|
-
{children}
|
|
660
|
-
</GeneralLayout>
|
|
661
|
-
);
|
|
662
|
-
};
|
|
663
|
-
\`\`\`
|
|
664
|
-
|
|
665
|
-
### Tab Layout Component
|
|
666
|
-
|
|
667
|
-
\`\`\`tsx
|
|
668
|
-
import type { TabLayoutProps } from '@idealyst/navigation';
|
|
669
|
-
|
|
670
|
-
export const CustomTabLayout: React.FC<TabLayoutProps> = ({
|
|
671
|
-
children,
|
|
672
|
-
routes,
|
|
673
|
-
currentPath
|
|
674
|
-
}) => {
|
|
675
|
-
const navigator = useNavigator();
|
|
676
|
-
|
|
677
|
-
return (
|
|
678
|
-
<View style={{ flex: 1 }}>
|
|
679
|
-
{/* Custom tab bar */}
|
|
680
|
-
<View style={{ flexDirection: 'row', borderBottom: '1px solid #ccc' }}>
|
|
681
|
-
{routes.map(route => (
|
|
682
|
-
<Pressable
|
|
683
|
-
key={route.path}
|
|
684
|
-
onPress={() => navigator.navigate({ path: route.fullPath, vars: {} })}
|
|
685
|
-
style={{
|
|
686
|
-
padding: 16,
|
|
687
|
-
borderBottom: currentPath === route.fullPath ? '2px solid blue' : 'none'
|
|
688
|
-
}}
|
|
689
|
-
>
|
|
690
|
-
<Text>{route.options?.tabBarLabel || route.path}</Text>
|
|
691
|
-
</Pressable>
|
|
692
|
-
))}
|
|
693
|
-
</View>
|
|
694
|
-
|
|
695
|
-
{/* Content */}
|
|
696
|
-
<View style={{ flex: 1 }}>
|
|
697
|
-
{children}
|
|
698
|
-
</View>
|
|
699
|
-
</View>
|
|
700
|
-
);
|
|
701
|
-
};
|
|
702
|
-
\`\`\`
|
|
703
|
-
|
|
704
|
-
## Layout Props Reference
|
|
705
|
-
|
|
706
|
-
### StackLayoutProps
|
|
707
|
-
|
|
708
|
-
\`\`\`tsx
|
|
709
|
-
type StackLayoutProps = {
|
|
710
|
-
options?: NavigatorOptions; // Navigator options
|
|
711
|
-
routes: RouteWithFullPath[]; // All routes with full paths
|
|
712
|
-
currentPath: string; // Current active path
|
|
713
|
-
children?: React.ReactNode; // Route content
|
|
714
|
-
};
|
|
715
|
-
\`\`\`
|
|
716
|
-
|
|
717
|
-
### TabLayoutProps
|
|
718
|
-
|
|
719
|
-
\`\`\`tsx
|
|
720
|
-
type TabLayoutProps = {
|
|
721
|
-
options?: NavigatorOptions; // Navigator options
|
|
722
|
-
routes: RouteWithFullPath<TabBarScreenOptions>[]; // Tab routes
|
|
723
|
-
currentPath: string; // Current active path
|
|
724
|
-
children?: React.ReactNode; // Route content
|
|
725
|
-
};
|
|
726
|
-
\`\`\`
|
|
727
|
-
|
|
728
|
-
## Real-World Examples
|
|
729
|
-
|
|
730
|
-
### Dashboard Layout
|
|
731
|
-
|
|
732
|
-
\`\`\`tsx
|
|
733
|
-
export const DashboardLayout: React.FC<StackLayoutProps> = ({
|
|
734
|
-
children,
|
|
735
|
-
routes,
|
|
736
|
-
currentPath
|
|
737
|
-
}) => {
|
|
738
|
-
return (
|
|
739
|
-
<GeneralLayout
|
|
740
|
-
header={{
|
|
741
|
-
enabled: true,
|
|
742
|
-
height: 72,
|
|
743
|
-
content: (
|
|
744
|
-
<View style={{
|
|
745
|
-
flexDirection: 'row',
|
|
746
|
-
justifyContent: 'space-between',
|
|
747
|
-
alignItems: 'center',
|
|
748
|
-
padding: 16
|
|
749
|
-
}}>
|
|
750
|
-
<Text size="xlarge" weight="bold">Dashboard</Text>
|
|
751
|
-
<View style={{ flexDirection: 'row', gap: 16 }}>
|
|
752
|
-
<NotificationBell />
|
|
753
|
-
<UserAvatar />
|
|
754
|
-
</View>
|
|
755
|
-
</View>
|
|
756
|
-
)
|
|
757
|
-
}}
|
|
758
|
-
sidebar={{
|
|
759
|
-
enabled: true,
|
|
760
|
-
collapsible: true,
|
|
761
|
-
position: 'left',
|
|
762
|
-
expandedWidth: 260,
|
|
763
|
-
content: <DashboardSidebar routes={routes} currentPath={currentPath} />
|
|
764
|
-
}}
|
|
765
|
-
>
|
|
766
|
-
{children}
|
|
767
|
-
</GeneralLayout>
|
|
768
|
-
);
|
|
769
|
-
};
|
|
770
|
-
\`\`\`
|
|
771
|
-
|
|
772
|
-
### Admin Panel Layout
|
|
773
|
-
|
|
774
|
-
\`\`\`tsx
|
|
775
|
-
export const AdminLayout: React.FC<StackLayoutProps> = ({ children }) => {
|
|
776
|
-
return (
|
|
777
|
-
<GeneralLayout
|
|
778
|
-
header={{
|
|
779
|
-
enabled: true,
|
|
780
|
-
content: <AdminHeader />,
|
|
781
|
-
style: { backgroundColor: '#1a1a1a', color: '#fff' }
|
|
782
|
-
}}
|
|
783
|
-
sidebar={{
|
|
784
|
-
enabled: true,
|
|
785
|
-
collapsible: true,
|
|
786
|
-
position: 'left',
|
|
787
|
-
initiallyExpanded: true,
|
|
788
|
-
content: <AdminNavigationMenu />,
|
|
789
|
-
style: { backgroundColor: '#2a2a2a' }
|
|
790
|
-
}}
|
|
791
|
-
>
|
|
792
|
-
<View style={{ padding: 24 }}>
|
|
793
|
-
{children}
|
|
794
|
-
</View>
|
|
795
|
-
</GeneralLayout>
|
|
796
|
-
);
|
|
797
|
-
};
|
|
798
|
-
\`\`\`
|
|
799
|
-
|
|
800
|
-
## Best Practices
|
|
801
|
-
|
|
802
|
-
1. **Use GeneralLayout as base** - Don't reinvent header/sidebar logic
|
|
803
|
-
2. **Keep layouts simple** - Complex logic belongs in screens
|
|
804
|
-
3. **Make responsive** - Consider different screen sizes
|
|
805
|
-
4. **Theme-aware** - Use theme colors and spacing
|
|
806
|
-
5. **Accessible** - Ensure keyboard and screen reader support
|
|
807
|
-
6. **Performance** - Memoize layout components when possible
|
|
808
|
-
7. **Consistent** - Use same layout for similar sections
|
|
809
|
-
|
|
810
|
-
## Platform Considerations
|
|
811
|
-
|
|
812
|
-
- **Web only**: Layout components only apply to web
|
|
813
|
-
- **Mobile**: Uses native navigation components
|
|
814
|
-
- **Conditional rendering**: Check platform if needed
|
|
815
|
-
- **Testing**: Test both platforms separately
|
|
816
|
-
`,
|
|
817
|
-
"idealyst://navigation/use-navigator": `# useNavigator Hook
|
|
818
|
-
|
|
819
|
-
The \`useNavigator\` hook provides navigation functionality and route information within your components.
|
|
820
|
-
|
|
821
|
-
## Basic Usage
|
|
822
|
-
|
|
823
|
-
\`\`\`tsx
|
|
824
|
-
import { useNavigator } from '@idealyst/navigation';
|
|
825
|
-
|
|
826
|
-
function MyComponent() {
|
|
827
|
-
const navigator = useNavigator();
|
|
828
|
-
|
|
829
|
-
return (
|
|
830
|
-
<Button onPress={() => navigator.navigate({ path: '/profile', vars: {} })}>
|
|
831
|
-
Go to Profile
|
|
832
|
-
</Button>
|
|
833
|
-
);
|
|
834
|
-
}
|
|
835
|
-
\`\`\`
|
|
836
|
-
|
|
837
|
-
## API Reference
|
|
838
|
-
|
|
839
|
-
### navigator.navigate()
|
|
840
|
-
|
|
841
|
-
Navigate to a route:
|
|
842
|
-
|
|
843
|
-
\`\`\`tsx
|
|
844
|
-
navigator.navigate({
|
|
845
|
-
path: string;
|
|
846
|
-
vars: Record<string, string>;
|
|
847
|
-
});
|
|
848
|
-
\`\`\`
|
|
849
|
-
|
|
850
|
-
Examples:
|
|
851
|
-
\`\`\`tsx
|
|
852
|
-
// Simple navigation
|
|
853
|
-
navigator.navigate({ path: '/home', vars: {} });
|
|
854
|
-
|
|
855
|
-
// With path parameters
|
|
856
|
-
navigator.navigate({
|
|
857
|
-
path: '/user/:id',
|
|
858
|
-
vars: { id: '123' }
|
|
859
|
-
});
|
|
860
|
-
|
|
861
|
-
// With query parameters
|
|
862
|
-
navigator.navigate({
|
|
863
|
-
path: '/search',
|
|
864
|
-
vars: { q: 'react', category: 'tutorial' }
|
|
865
|
-
});
|
|
866
|
-
\`\`\`
|
|
867
|
-
|
|
868
|
-
### navigator.vars
|
|
869
|
-
|
|
870
|
-
Access current route variables:
|
|
871
|
-
|
|
872
|
-
\`\`\`tsx
|
|
873
|
-
const navigator = useNavigator();
|
|
874
|
-
const userId = navigator.vars.id; // Path param
|
|
875
|
-
const searchQuery = navigator.vars.q; // Query param
|
|
876
|
-
\`\`\`
|
|
877
|
-
|
|
878
|
-
### navigator.currentPath
|
|
879
|
-
|
|
880
|
-
Get the current route path:
|
|
881
|
-
|
|
882
|
-
\`\`\`tsx
|
|
883
|
-
const navigator = useNavigator();
|
|
884
|
-
const path = navigator.currentPath;
|
|
885
|
-
|
|
886
|
-
console.log(path); // "/user/123"
|
|
887
|
-
\`\`\`
|
|
888
|
-
|
|
889
|
-
### navigator.goBack()
|
|
890
|
-
|
|
891
|
-
Navigate to previous screen (mobile only):
|
|
892
|
-
|
|
893
|
-
\`\`\`tsx
|
|
894
|
-
<Button onPress={() => navigator.goBack()}>
|
|
895
|
-
Go Back
|
|
896
|
-
</Button>
|
|
897
|
-
\`\`\`
|
|
898
|
-
|
|
899
|
-
**Note**: On web, use browser back button or navigator.navigate() to specific routes.
|
|
900
|
-
|
|
901
|
-
## Path Parameters
|
|
902
|
-
|
|
903
|
-
### Defining Parameters
|
|
904
|
-
|
|
905
|
-
In route configuration:
|
|
906
|
-
\`\`\`tsx
|
|
907
|
-
{
|
|
908
|
-
path: "user/:id",
|
|
909
|
-
type: 'screen',
|
|
910
|
-
component: UserScreen
|
|
911
|
-
}
|
|
912
|
-
\`\`\`
|
|
913
|
-
|
|
914
|
-
### Accessing Parameters
|
|
915
|
-
|
|
916
|
-
In the screen component:
|
|
917
|
-
\`\`\`tsx
|
|
918
|
-
function UserScreen() {
|
|
919
|
-
const navigator = useNavigator();
|
|
920
|
-
const userId = navigator.vars.id;
|
|
921
|
-
|
|
922
|
-
return <Text>User ID: {userId}</Text>;
|
|
923
|
-
}
|
|
924
|
-
\`\`\`
|
|
925
|
-
|
|
926
|
-
### Multiple Parameters
|
|
927
|
-
|
|
928
|
-
\`\`\`tsx
|
|
929
|
-
// Route: "post/:postId/comment/:commentId"
|
|
930
|
-
|
|
931
|
-
// Navigate:
|
|
932
|
-
navigator.navigate({
|
|
933
|
-
path: '/post/:postId/comment/:commentId',
|
|
934
|
-
vars: { postId: '42', commentId: '7' }
|
|
935
|
-
});
|
|
936
|
-
|
|
937
|
-
// Access:
|
|
938
|
-
const postId = navigator.vars.postId;
|
|
939
|
-
const commentId = navigator.vars.commentId;
|
|
940
|
-
\`\`\`
|
|
941
|
-
|
|
942
|
-
## Query Parameters
|
|
943
|
-
|
|
944
|
-
### Passing Query Params
|
|
945
|
-
|
|
946
|
-
\`\`\`tsx
|
|
947
|
-
navigator.navigate({
|
|
948
|
-
path: '/search',
|
|
949
|
-
vars: {
|
|
950
|
-
q: 'typescript',
|
|
951
|
-
category: 'tutorial',
|
|
952
|
-
sort: 'recent'
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
// Results in: /search?q=typescript&category=tutorial&sort=recent
|
|
957
|
-
\`\`\`
|
|
958
|
-
|
|
959
|
-
### Reading Query Params
|
|
960
|
-
|
|
961
|
-
\`\`\`tsx
|
|
962
|
-
function SearchScreen() {
|
|
963
|
-
const navigator = useNavigator();
|
|
964
|
-
|
|
965
|
-
const query = navigator.vars.q;
|
|
966
|
-
const category = navigator.vars.category;
|
|
967
|
-
const sort = navigator.vars.sort;
|
|
968
|
-
|
|
969
|
-
// Use params...
|
|
970
|
-
}
|
|
971
|
-
\`\`\`
|
|
972
|
-
|
|
973
|
-
## Navigation Patterns
|
|
974
|
-
|
|
975
|
-
### Programmatic Navigation
|
|
976
|
-
|
|
977
|
-
Navigate based on conditions:
|
|
978
|
-
|
|
979
|
-
\`\`\`tsx
|
|
980
|
-
function LoginScreen() {
|
|
981
|
-
const navigator = useNavigator();
|
|
982
|
-
|
|
983
|
-
const handleLogin = async () => {
|
|
984
|
-
const success = await login(credentials);
|
|
985
|
-
|
|
986
|
-
if (success) {
|
|
987
|
-
navigator.navigate({ path: '/dashboard', vars: {} });
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
return <Button onPress={handleLogin}>Login</Button>;
|
|
992
|
-
}
|
|
993
|
-
\`\`\`
|
|
994
|
-
|
|
995
|
-
### Navigation with Data
|
|
996
|
-
|
|
997
|
-
Pass data through navigation:
|
|
998
|
-
|
|
999
|
-
\`\`\`tsx
|
|
1000
|
-
// List screen
|
|
1001
|
-
<Button onPress={() => {
|
|
1002
|
-
navigator.navigate({
|
|
1003
|
-
path: '/product/:id',
|
|
1004
|
-
vars: { id: product.id }
|
|
1005
|
-
});
|
|
1006
|
-
}}>
|
|
1007
|
-
View Product
|
|
1008
|
-
</Button>
|
|
1009
|
-
|
|
1010
|
-
// Detail screen
|
|
1011
|
-
function ProductScreen() {
|
|
1012
|
-
const navigator = useNavigator();
|
|
1013
|
-
const productId = navigator.vars.id;
|
|
1014
|
-
|
|
1015
|
-
const product = useProduct(productId);
|
|
1016
|
-
// Render product...
|
|
1017
|
-
}
|
|
1018
|
-
\`\`\`
|
|
1019
|
-
|
|
1020
|
-
### Conditional Navigation
|
|
1021
|
-
|
|
1022
|
-
Navigate based on user state:
|
|
1023
|
-
|
|
1024
|
-
\`\`\`tsx
|
|
1025
|
-
function ProtectedScreen() {
|
|
1026
|
-
const navigator = useNavigator();
|
|
1027
|
-
const { user } = useAuth();
|
|
1028
|
-
|
|
1029
|
-
useEffect(() => {
|
|
1030
|
-
if (!user) {
|
|
1031
|
-
navigator.navigate({ path: '/login', vars: {} });
|
|
1032
|
-
}
|
|
1033
|
-
}, [user]);
|
|
1034
|
-
|
|
1035
|
-
return user ? <Content /> : null;
|
|
1036
|
-
}
|
|
1037
|
-
\`\`\`
|
|
1038
|
-
|
|
1039
|
-
## Advanced Usage
|
|
1040
|
-
|
|
1041
|
-
### Navigation Guards
|
|
1042
|
-
|
|
1043
|
-
\`\`\`tsx
|
|
1044
|
-
function useAuthGuard() {
|
|
1045
|
-
const navigator = useNavigator();
|
|
1046
|
-
const { isAuthenticated } = useAuth();
|
|
1047
|
-
|
|
1048
|
-
useEffect(() => {
|
|
1049
|
-
if (!isAuthenticated && navigator.currentPath !== '/login') {
|
|
1050
|
-
navigator.navigate({ path: '/login', vars: {} });
|
|
1051
|
-
}
|
|
1052
|
-
}, [isAuthenticated, navigator.currentPath]);
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
function App() {
|
|
1056
|
-
useAuthGuard();
|
|
1057
|
-
return <AppContent />;
|
|
1058
|
-
}
|
|
1059
|
-
\`\`\`
|
|
1060
|
-
|
|
1061
|
-
### Deep Linking
|
|
1062
|
-
|
|
1063
|
-
Handle deep links:
|
|
1064
|
-
|
|
1065
|
-
\`\`\`tsx
|
|
1066
|
-
useEffect(() => {
|
|
1067
|
-
const handleDeepLink = (url: string) => {
|
|
1068
|
-
// Parse URL and navigate
|
|
1069
|
-
const path = parseDeepLink(url);
|
|
1070
|
-
navigator.navigate({ path, vars: {} });
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
|
-
// Add deep link listener
|
|
1074
|
-
const subscription = Linking.addEventListener('url', ({ url }) => {
|
|
1075
|
-
handleDeepLink(url);
|
|
1076
|
-
});
|
|
1077
|
-
|
|
1078
|
-
return () => subscription.remove();
|
|
1079
|
-
}, []);
|
|
1080
|
-
\`\`\`
|
|
1081
|
-
|
|
1082
|
-
### Navigation History
|
|
1083
|
-
|
|
1084
|
-
Track navigation history:
|
|
1085
|
-
|
|
1086
|
-
\`\`\`tsx
|
|
1087
|
-
function useNavigationHistory() {
|
|
1088
|
-
const navigator = useNavigator();
|
|
1089
|
-
const [history, setHistory] = useState<string[]>([]);
|
|
1090
|
-
|
|
1091
|
-
useEffect(() => {
|
|
1092
|
-
setHistory(prev => [...prev, navigator.currentPath]);
|
|
1093
|
-
}, [navigator.currentPath]);
|
|
1094
|
-
|
|
1095
|
-
return history;
|
|
1096
|
-
}
|
|
1097
|
-
\`\`\`
|
|
1098
|
-
|
|
1099
|
-
## TypeScript Support
|
|
1100
|
-
|
|
1101
|
-
Type-safe navigation:
|
|
1102
|
-
|
|
1103
|
-
\`\`\`tsx
|
|
1104
|
-
type NavigateParams = {
|
|
1105
|
-
path: string;
|
|
1106
|
-
vars: Record<string, string>;
|
|
1107
|
-
};
|
|
1108
|
-
|
|
1109
|
-
// Strongly typed vars
|
|
1110
|
-
type UserRouteVars = {
|
|
1111
|
-
id: string;
|
|
1112
|
-
tab?: 'posts' | 'comments' | 'likes';
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
// Usage
|
|
1116
|
-
navigator.navigate({
|
|
1117
|
-
path: '/user/:id',
|
|
1118
|
-
vars: { id: '123', tab: 'posts' } as UserRouteVars
|
|
1119
|
-
});
|
|
1120
|
-
\`\`\`
|
|
1121
|
-
|
|
1122
|
-
## Platform Differences
|
|
1123
|
-
|
|
1124
|
-
### React Native
|
|
1125
|
-
- \`goBack()\` uses native navigation stack
|
|
1126
|
-
- Hardware back button supported
|
|
1127
|
-
- Gesture-based navigation
|
|
1128
|
-
|
|
1129
|
-
### Web
|
|
1130
|
-
- Browser back/forward buttons work
|
|
1131
|
-
- URL updates automatically
|
|
1132
|
-
- Bookmarkable URLs
|
|
1133
|
-
- \`goBack()\` uses browser history
|
|
1134
|
-
|
|
1135
|
-
## Best Practices
|
|
1136
|
-
|
|
1137
|
-
1. **Always provide vars** - Even if empty: \`{}\`
|
|
1138
|
-
2. **Type your routes** - Use TypeScript for safety
|
|
1139
|
-
3. **Handle errors** - Check if navigation succeeded
|
|
1140
|
-
4. **Avoid navigation in render** - Use effects or handlers
|
|
1141
|
-
5. **Clean up listeners** - Remove event listeners on unmount
|
|
1142
|
-
6. **Test navigation flow** - Verify all paths work
|
|
1143
|
-
7. **Use path params for IDs** - Not query params
|
|
1144
|
-
8. **Use query params for filters** - Not path params
|
|
1145
|
-
|
|
1146
|
-
## Common Patterns
|
|
1147
|
-
|
|
1148
|
-
### Back Navigation
|
|
1149
|
-
|
|
1150
|
-
\`\`\`tsx
|
|
1151
|
-
<Button
|
|
1152
|
-
icon="arrow-left"
|
|
1153
|
-
onPress={() => navigator.goBack()}
|
|
1154
|
-
>
|
|
1155
|
-
Back
|
|
1156
|
-
</Button>
|
|
1157
|
-
\`\`\`
|
|
1158
|
-
|
|
1159
|
-
### Tab Navigation
|
|
1160
|
-
|
|
1161
|
-
\`\`\`tsx
|
|
1162
|
-
const tabs = ['feed', 'search', 'profile'];
|
|
1163
|
-
|
|
1164
|
-
<View>
|
|
1165
|
-
{tabs.map(tab => (
|
|
1166
|
-
<Button
|
|
1167
|
-
key={tab}
|
|
1168
|
-
onPress={() => navigator.navigate({ path: \`/\${tab}\`, vars: {} })}
|
|
1169
|
-
variant={navigator.currentPath === \`/\${tab}\` ? 'contained' : 'outlined'}
|
|
1170
|
-
>
|
|
1171
|
-
{tab}
|
|
1172
|
-
</Button>
|
|
1173
|
-
))}
|
|
1174
|
-
</View>
|
|
1175
|
-
\`\`\`
|
|
1176
|
-
|
|
1177
|
-
### Modal Navigation
|
|
1178
|
-
|
|
1179
|
-
\`\`\`tsx
|
|
1180
|
-
<Button onPress={() => {
|
|
1181
|
-
navigator.navigate({
|
|
1182
|
-
path: '/modal/create-post',
|
|
1183
|
-
vars: {}
|
|
1184
|
-
});
|
|
1185
|
-
}}>
|
|
1186
|
-
Create Post
|
|
1187
|
-
</Button>
|
|
1188
|
-
|
|
1189
|
-
// In modal:
|
|
1190
|
-
<Button onPress={() => navigator.goBack()}>
|
|
1191
|
-
Close
|
|
1192
|
-
</Button>
|
|
1193
|
-
\`\`\`
|
|
1194
|
-
`,
|
|
1195
|
-
};
|
|
1196
|
-
//# sourceMappingURL=navigation-guides.js.map
|