@idealyst/navigation 1.0.38 → 1.0.40

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 ADDED
@@ -0,0 +1,517 @@
1
+ # @idealyst/navigation
2
+
3
+ A comprehensive, cross-platform navigation library for React and React Native applications. Built on top of React Navigation (Native) and React Router (Web) with a unified API and theming system.
4
+
5
+ ## Features
6
+
7
+ - 🌐 **Cross-Platform**: Works seamlessly in React and React Native
8
+ - 🧭 **Unified API**: Same navigation code works on web and mobile
9
+ - 🎨 **Theme Integration**: Built-in support for @idealyst/theme system
10
+ - 📱 **Multiple Layout Types**: Stack, Tab, Drawer, and Modal navigation
11
+ - 🎯 **Type-Safe**: Full TypeScript support with route type safety
12
+ - 🏗️ **Layout System**: Flexible layout components for complex UIs
13
+ - 📦 **Ready-to-Use Examples**: Complete router implementations to get started quickly
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ # Using Yarn (recommended)
19
+ yarn add @idealyst/navigation
20
+
21
+ # Using npm
22
+ npm install @idealyst/navigation
23
+ ```
24
+
25
+ ### Peer Dependencies
26
+
27
+ This library requires the following peer dependencies:
28
+
29
+ ```bash
30
+ # Core dependencies
31
+ yarn add @idealyst/components @idealyst/theme react-native-unistyles
32
+
33
+ # For React Native projects
34
+ yarn add @react-navigation/native @react-navigation/native-stack
35
+ yarn add @react-navigation/bottom-tabs @react-navigation/drawer
36
+ yarn add react-native-screens react-native-safe-area-context
37
+ yarn add react-native-gesture-handler react-native-reanimated
38
+
39
+ # For React/Web projects
40
+ yarn add react-router react-router-dom
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ The fastest way to get started is using the pre-built example routers:
46
+
47
+ ### Stack Navigation (Recommended for most apps)
48
+
49
+ ```tsx
50
+ import React from 'react';
51
+ import { NavigatorProvider } from '@idealyst/navigation';
52
+ import { ExampleStackRouter } from '@idealyst/navigation/examples';
53
+
54
+ export default function App() {
55
+ return (
56
+ <NavigatorProvider route={ExampleStackRouter}>
57
+ {/* Your app content will be handled by the router */}
58
+ </NavigatorProvider>
59
+ );
60
+ }
61
+ ```
62
+
63
+ ### Tab Navigation (Great for mobile apps)
64
+
65
+ ```tsx
66
+ import React from 'react';
67
+ import { NavigatorProvider } from '@idealyst/navigation';
68
+ import { ExampleTabRouter } from '@idealyst/navigation/examples';
69
+
70
+ export default function App() {
71
+ return (
72
+ <NavigatorProvider route={ExampleTabRouter}>
73
+ {/* Tab navigation with component examples */}
74
+ </NavigatorProvider>
75
+ );
76
+ }
77
+ ```
78
+
79
+ ### Drawer Navigation (Perfect for desktop/web)
80
+
81
+ ```tsx
82
+ import React from 'react';
83
+ import { NavigatorProvider } from '@idealyst/navigation';
84
+ import { ExampleDrawerRouter } from '@idealyst/navigation/examples';
85
+
86
+ export default function App() {
87
+ return (
88
+ <NavigatorProvider route={ExampleDrawerRouter}>
89
+ {/* Drawer navigation with sidebar */}
90
+ </NavigatorProvider>
91
+ );
92
+ }
93
+ ```
94
+
95
+ ## Core Concepts
96
+
97
+ ### Route Configuration
98
+
99
+ Routes are defined using a declarative configuration object:
100
+
101
+ ```tsx
102
+ import { RouteParam } from '@idealyst/navigation';
103
+
104
+ const AppRouter: RouteParam = {
105
+ path: "/",
106
+ component: HomeScreen,
107
+ layout: {
108
+ type: "stack", // "stack" | "tab" | "drawer" | "modal"
109
+ component: CustomLayout, // Optional custom layout component
110
+ },
111
+ routes: [
112
+ { path: "profile", component: ProfileScreen },
113
+ { path: "settings", component: SettingsScreen },
114
+ {
115
+ path: "products",
116
+ component: ProductsScreen,
117
+ routes: [
118
+ { path: ":id", component: ProductDetailScreen },
119
+ ],
120
+ },
121
+ ],
122
+ };
123
+ ```
124
+
125
+ ### Navigation Context
126
+
127
+ Access navigation functionality from any component:
128
+
129
+ ```tsx
130
+ import { useNavigator } from '@idealyst/navigation';
131
+
132
+ function MyComponent() {
133
+ const navigator = useNavigator();
134
+
135
+ const handleNavigate = () => {
136
+ navigator.navigate({
137
+ path: "/profile",
138
+ vars: { userId: "123" },
139
+ });
140
+ };
141
+
142
+ return (
143
+ <Button onPress={handleNavigate}>
144
+ Go to Profile
145
+ </Button>
146
+ );
147
+ }
148
+ ```
149
+
150
+ ## Layout Types
151
+
152
+ ### Stack Layout
153
+ Linear navigation with a navigation stack.
154
+
155
+ ```tsx
156
+ const stackConfig = {
157
+ type: "stack" as const,
158
+ component: CustomStackLayout, // Optional
159
+ };
160
+ ```
161
+
162
+ **Best for**: Most mobile apps, step-by-step flows, hierarchical navigation
163
+
164
+ ### Tab Layout
165
+ Bottom tabs (mobile) or top tabs (web) navigation.
166
+
167
+ ```tsx
168
+ const tabConfig = {
169
+ type: "tab" as const,
170
+ };
171
+ ```
172
+
173
+ **Best for**: Main app sections, dashboard-style apps, content browsing
174
+
175
+ ### Drawer Layout
176
+ Side drawer navigation, typically for desktop/web.
177
+
178
+ ```tsx
179
+ const drawerConfig = {
180
+ type: "drawer" as const,
181
+ };
182
+ ```
183
+
184
+ **Best for**: Desktop apps, admin panels, content-heavy applications
185
+
186
+ ### Modal Layout
187
+ Overlay modal navigation.
188
+
189
+ ```tsx
190
+ const modalConfig = {
191
+ type: "modal" as const,
192
+ };
193
+ ```
194
+
195
+ **Best for**: Forms, dialogs, temporary content, settings screens
196
+
197
+ ## Layout Components
198
+
199
+ ### GeneralLayout
200
+
201
+ A flexible layout component with header and sidebar support:
202
+
203
+ ```tsx
204
+ import { GeneralLayout } from '@idealyst/navigation';
205
+
206
+ <GeneralLayout
207
+ header={{
208
+ enabled: true,
209
+ height: 60,
210
+ content: <Text>My App Header</Text>,
211
+ }}
212
+ sidebar={{
213
+ enabled: true,
214
+ collapsible: true,
215
+ position: 'left',
216
+ initiallyExpanded: false,
217
+ expandedWidth: 250,
218
+ collapsedWidth: 60,
219
+ content: <NavigationMenu />,
220
+ }}
221
+ >
222
+ {children}
223
+ </GeneralLayout>
224
+ ```
225
+
226
+ #### Header Configuration
227
+ - `enabled`: Show/hide header
228
+ - `height`: Header height in pixels
229
+ - `content`: Header content (React component)
230
+ - `style`: Custom header styles
231
+
232
+ #### Sidebar Configuration
233
+ - `enabled`: Show/hide sidebar
234
+ - `collapsible`: Allow sidebar collapse/expand
235
+ - `position`: 'left' or 'right' placement
236
+ - `initiallyExpanded`: Initial collapsed state
237
+ - `expandedWidth`/`collapsedWidth`: Sidebar widths
238
+ - `content`: Sidebar content (React component)
239
+ - `style`: Custom sidebar styles
240
+
241
+ ## Examples and Quick Start
242
+
243
+ The package includes three complete, production-ready router examples:
244
+
245
+ ### Stack Router Example (`ExampleStackRouter`)
246
+ - **Layout**: Stack navigation with header and collapsible sidebar
247
+ - **Features**: Theme controls, component navigation, responsive design
248
+ - **Use Case**: Desktop/web applications, admin dashboards
249
+ - **Components**: All @idealyst/components examples integrated
250
+
251
+ ### Tab Router Example (`ExampleTabRouter`)
252
+ - **Layout**: Tab navigation with component sections
253
+ - **Features**: Theme controls, organized component browsing
254
+ - **Use Case**: Mobile apps, content exploration
255
+ - **Components**: Each component gets its own tab
256
+
257
+ ### Drawer Router Example (`ExampleDrawerRouter`)
258
+ - **Layout**: Drawer navigation with slide-out menu
259
+ - **Features**: Collapsible navigation, desktop-optimized
260
+ - **Use Case**: Desktop applications, admin interfaces
261
+ - **Components**: Navigation via drawer menu
262
+
263
+ ### Using Examples as Starting Points
264
+
265
+ ```tsx
266
+ // Import any example router
267
+ import { ExampleStackRouter } from '@idealyst/navigation/examples';
268
+
269
+ // Use as-is for quick start
270
+ <NavigatorProvider route={ExampleStackRouter} />
271
+
272
+ // Or customize for your needs
273
+ const MyRouter: RouteParam = {
274
+ ...ExampleStackRouter,
275
+ routes: [
276
+ ...ExampleStackRouter.routes,
277
+ { path: "my-custom-screen", component: MyScreen },
278
+ ],
279
+ };
280
+ ```
281
+
282
+ ## Advanced Usage
283
+
284
+ ### Custom Layout Components
285
+
286
+ Create custom layouts for specific needs:
287
+
288
+ ```tsx
289
+ import { GeneralLayoutProps } from '@idealyst/navigation';
290
+
291
+ const CustomLayout: React.FC<GeneralLayoutProps> = ({ children, ...props }) => {
292
+ return (
293
+ <View style={{ flex: 1 }}>
294
+ <CustomHeader />
295
+ <View style={{ flex: 1, flexDirection: 'row' }}>
296
+ <CustomSidebar />
297
+ <View style={{ flex: 1 }}>
298
+ {children}
299
+ </View>
300
+ </View>
301
+ <CustomFooter />
302
+ </View>
303
+ );
304
+ };
305
+
306
+ // Use in route configuration
307
+ const router: RouteParam = {
308
+ path: "/",
309
+ component: HomeScreen,
310
+ layout: {
311
+ type: "stack",
312
+ component: CustomLayout,
313
+ },
314
+ };
315
+ ```
316
+
317
+ ### Route Parameters and Variables
318
+
319
+ Pass data between screens using route variables:
320
+
321
+ ```tsx
322
+ // Navigate with variables
323
+ navigator.navigate({
324
+ path: "/user/:id",
325
+ vars: { id: "123" },
326
+ });
327
+
328
+ // Access in target component
329
+ function UserScreen() {
330
+ const navigator = useNavigator();
331
+ // Access route variables through navigator context
332
+ }
333
+ ```
334
+
335
+ ### Nested Routes
336
+
337
+ Create complex navigation hierarchies:
338
+
339
+ ```tsx
340
+ const AppRouter: RouteParam = {
341
+ path: "/",
342
+ component: HomeScreen,
343
+ layout: { type: "stack" },
344
+ routes: [
345
+ {
346
+ path: "dashboard",
347
+ component: DashboardScreen,
348
+ layout: { type: "tab" },
349
+ routes: [
350
+ { path: "analytics", component: AnalyticsScreen },
351
+ { path: "reports", component: ReportsScreen },
352
+ {
353
+ path: "settings",
354
+ component: SettingsScreen,
355
+ layout: { type: "modal" },
356
+ routes: [
357
+ { path: "profile", component: ProfileSettingsScreen },
358
+ { path: "preferences", component: PreferencesScreen },
359
+ ],
360
+ },
361
+ ],
362
+ },
363
+ ],
364
+ };
365
+ ```
366
+
367
+ ## Theme Integration
368
+
369
+ The navigation system automatically integrates with @idealyst/theme:
370
+
371
+ ```tsx
372
+ import { UnistylesRuntime } from 'react-native-unistyles';
373
+
374
+ // Theme switching works automatically
375
+ UnistylesRuntime.setTheme('dark');
376
+
377
+ // High contrast themes supported
378
+ UnistylesRuntime.setTheme('lightHighContrast');
379
+ UnistylesRuntime.setTheme('darkHighContrast');
380
+ ```
381
+
382
+ All navigation components and layouts automatically adapt to theme changes.
383
+
384
+ ## TypeScript Support
385
+
386
+ Full type safety for routes and navigation:
387
+
388
+ ```tsx
389
+ // Route configuration is typed
390
+ const router: RouteParam = {
391
+ path: "/users/:id",
392
+ component: UserDetailScreen,
393
+ // TypeScript ensures correct structure
394
+ };
395
+
396
+ // Navigation parameters are typed
397
+ type NavigateParams = {
398
+ path: string;
399
+ vars: Record<string, string>;
400
+ };
401
+ ```
402
+
403
+ ## Platform Differences
404
+
405
+ ### React Native
406
+ - Uses React Navigation under the hood
407
+ - Native navigation performance
408
+ - Platform-specific animations and gestures
409
+ - Hardware back button support
410
+
411
+ ### Web/React
412
+ - Uses React Router under the hood
413
+ - Browser navigation integration
414
+ - URL-based routing
415
+ - Browser back/forward support
416
+
417
+ The unified API ensures your navigation code works identically on both platforms.
418
+
419
+ ## Best Practices
420
+
421
+ 1. **Start with Examples**: Use the provided example routers as starting points
422
+ 2. **Choose Appropriate Layouts**: Stack for mobile, tabs for sections, drawer for desktop
423
+ 3. **Keep Routes Shallow**: Avoid deeply nested route structures
424
+ 4. **Use Type Safety**: Leverage TypeScript for route definitions
425
+ 5. **Test Cross-Platform**: Verify navigation works on both web and mobile
426
+ 6. **Consider Accessibility**: Ensure navigation is keyboard and screen reader accessible
427
+ 7. **Theme Consistency**: Use the integrated theme system for consistent styling
428
+
429
+ ## API Reference
430
+
431
+ ### Components
432
+
433
+ | Component | Description | Use Case |
434
+ |-----------|-------------|----------|
435
+ | `NavigatorProvider` | Root navigation context provider | Wrap your entire app |
436
+ | `GeneralLayout` | Flexible layout with header/sidebar | Custom layout implementations |
437
+
438
+ ### Hooks
439
+
440
+ | Hook | Description | Returns |
441
+ |------|-------------|---------|
442
+ | `useNavigator()` | Access navigation functionality | `{ navigate }` |
443
+
444
+ ### Types
445
+
446
+ | Type | Description |
447
+ |------|-------------|
448
+ | `RouteParam` | Route configuration object |
449
+ | `LayoutType` | Layout type union ('stack' \| 'tab' \| 'drawer' \| 'modal') |
450
+ | `NavigateParams` | Navigation parameters object |
451
+ | `GeneralLayoutProps` | Props for GeneralLayout component |
452
+
453
+ ## Examples Access
454
+
455
+ Import working examples and theme utilities:
456
+
457
+ ```tsx
458
+ // Example routers
459
+ import {
460
+ ExampleStackRouter,
461
+ ExampleTabRouter,
462
+ ExampleDrawerRouter
463
+ } from '@idealyst/navigation/examples';
464
+
465
+ // Theme utilities
466
+ import {
467
+ getNextTheme,
468
+ getThemeDisplayName,
469
+ isHighContrastTheme
470
+ } from '@idealyst/navigation/examples/unistyles';
471
+ ```
472
+
473
+ ## Development
474
+
475
+ ### Building
476
+
477
+ ```bash
478
+ # Build the library
479
+ yarn build
480
+
481
+ # Watch for changes during development
482
+ yarn dev
483
+ ```
484
+
485
+ ### Project Structure
486
+
487
+ ```
488
+ packages/navigation/
489
+ ├── src/
490
+ │ ├── context/ # Navigation context and providers
491
+ │ ├── routing/ # Core routing logic
492
+ │ ├── layouts/ # Layout components
493
+ │ │ └── GeneralLayout/ # Flexible layout with header/sidebar
494
+ │ └── examples/ # Complete router examples
495
+ │ ├── ExampleStackRouter.tsx # Stack navigation example
496
+ │ ├── ExampleTabRouter.tsx # Tab navigation example
497
+ │ ├── ExampleDrawerRouter.tsx # Drawer navigation example
498
+ │ └── unistyles.ts # Theme utilities
499
+ ├── package.json
500
+ └── README.md
501
+ ```
502
+
503
+ ## Contributing
504
+
505
+ 1. Fork the repository
506
+ 2. Create a feature branch
507
+ 3. Follow the existing patterns and TypeScript conventions
508
+ 4. Test on both React and React Native platforms
509
+ 5. Submit a pull request
510
+
511
+ ## License
512
+
513
+ MIT License - see LICENSE file for details.
514
+
515
+ ## Support
516
+
517
+ For issues, questions, or contributions, please visit our [GitHub repository](https://github.com/your-org/idealyst-framework).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/navigation",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "Cross-platform navigation library for React and React Native",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -37,8 +37,8 @@
37
37
  "publish:npm": "npm publish"
38
38
  },
39
39
  "peerDependencies": {
40
- "@idealyst/components": "^1.0.38",
41
- "@idealyst/theme": "^1.0.38",
40
+ "@idealyst/components": "^1.0.40",
41
+ "@idealyst/theme": "^1.0.40",
42
42
  "@react-navigation/bottom-tabs": "^7.0.0",
43
43
  "@react-navigation/drawer": "^7.0.0",
44
44
  "@react-navigation/native": "^7.0.0",
@@ -49,7 +49,7 @@
49
49
  "react-native-reanimated": "*",
50
50
  "react-native-safe-area-context": "*",
51
51
  "react-native-screens": "*",
52
- "react-native-unistyles": "^3.0.4",
52
+ "react-native-unistyles": "^3.0.10",
53
53
  "react-router": "^7.6.3",
54
54
  "react-router-dom": "^7.6.3"
55
55
  },
@@ -59,7 +59,10 @@
59
59
  "typescript": "^5.0.0"
60
60
  },
61
61
  "files": [
62
- "src"
62
+ "src",
63
+ "README.md",
64
+ "CLAUDE.md",
65
+ "LLM-ACCESS-GUIDE.md"
63
66
  ],
64
67
  "keywords": [
65
68
  "react",