@sigmela/router 0.1.3 → 0.2.1

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.
Files changed (52) hide show
  1. package/README.md +177 -833
  2. package/lib/module/Navigation.js +1 -10
  3. package/lib/module/NavigationStack.js +168 -19
  4. package/lib/module/Router.js +1523 -501
  5. package/lib/module/RouterContext.js +1 -1
  6. package/lib/module/ScreenStack/ScreenStack.web.js +388 -117
  7. package/lib/module/ScreenStack/ScreenStackContext.js +21 -0
  8. package/lib/module/ScreenStack/animationHelpers.js +72 -0
  9. package/lib/module/ScreenStackItem/ScreenStackItem.js +2 -1
  10. package/lib/module/ScreenStackItem/ScreenStackItem.web.js +76 -16
  11. package/lib/module/ScreenStackSheetItem/ScreenStackSheetItem.native.js +2 -1
  12. package/lib/module/ScreenStackSheetItem/ScreenStackSheetItem.web.js +1 -1
  13. package/lib/module/SplitView/RenderSplitView.native.js +85 -0
  14. package/lib/module/SplitView/RenderSplitView.web.js +109 -0
  15. package/lib/module/SplitView/SplitView.js +89 -0
  16. package/lib/module/SplitView/SplitViewContext.js +4 -0
  17. package/lib/module/SplitView/index.js +5 -0
  18. package/lib/module/SplitView/useSplitView.js +11 -0
  19. package/lib/module/StackRenderer.js +4 -2
  20. package/lib/module/TabBar/RenderTabBar.native.js +118 -33
  21. package/lib/module/TabBar/RenderTabBar.web.js +52 -47
  22. package/lib/module/TabBar/TabBar.js +116 -3
  23. package/lib/module/TabBar/index.js +4 -1
  24. package/lib/module/TabBar/useTabBarHeight.js +22 -0
  25. package/lib/module/index.js +3 -4
  26. package/lib/module/navigationNode.js +3 -0
  27. package/lib/module/styles.css +693 -28
  28. package/lib/typescript/src/NavigationStack.d.ts +25 -13
  29. package/lib/typescript/src/Router.d.ts +147 -34
  30. package/lib/typescript/src/RouterContext.d.ts +1 -1
  31. package/lib/typescript/src/ScreenStack/ScreenStack.web.d.ts +0 -2
  32. package/lib/typescript/src/ScreenStack/ScreenStackContext.d.ts +31 -0
  33. package/lib/typescript/src/ScreenStack/animationHelpers.d.ts +6 -0
  34. package/lib/typescript/src/ScreenStackItem/ScreenStackItem.types.d.ts +5 -1
  35. package/lib/typescript/src/ScreenStackItem/ScreenStackItem.web.d.ts +1 -1
  36. package/lib/typescript/src/SplitView/RenderSplitView.native.d.ts +8 -0
  37. package/lib/typescript/src/SplitView/RenderSplitView.web.d.ts +8 -0
  38. package/lib/typescript/src/SplitView/SplitView.d.ts +31 -0
  39. package/lib/typescript/src/SplitView/SplitViewContext.d.ts +3 -0
  40. package/lib/typescript/src/SplitView/index.d.ts +5 -0
  41. package/lib/typescript/src/SplitView/useSplitView.d.ts +2 -0
  42. package/lib/typescript/src/StackRenderer.d.ts +2 -1
  43. package/lib/typescript/src/TabBar/TabBar.d.ts +27 -3
  44. package/lib/typescript/src/TabBar/index.d.ts +3 -0
  45. package/lib/typescript/src/TabBar/useTabBarHeight.d.ts +18 -0
  46. package/lib/typescript/src/createController.d.ts +1 -0
  47. package/lib/typescript/src/index.d.ts +4 -3
  48. package/lib/typescript/src/navigationNode.d.ts +41 -0
  49. package/lib/typescript/src/types.d.ts +29 -32
  50. package/package.json +6 -5
  51. package/lib/module/web/TransitionStack.js +0 -227
  52. package/lib/typescript/src/web/TransitionStack.d.ts +0 -21
@@ -1,31 +1,43 @@
1
1
  import type { ScreenOptions } from './types';
2
- import { type ComponentWithController, type MixedComponent } from './createController';
3
- type BuiltRoute = {
4
- routeId: string;
5
- path: string;
6
- match: (path: string) => false | {
7
- params: Record<string, any>;
8
- };
9
- component: React.ComponentType<any>;
10
- controller?: ComponentWithController['controller'];
11
- options?: ScreenOptions;
12
- };
13
- export declare class NavigationStack {
2
+ import { type MixedComponent } from './createController';
3
+ import type { NavigationNode, NodeRoute, NodeChild } from './navigationNode';
4
+ type BuiltRoute = NodeRoute;
5
+ type ChildNode = NodeChild;
6
+ export declare class NavigationStack implements NavigationNode {
14
7
  private readonly stackId;
15
8
  private readonly routes;
9
+ private readonly children;
16
10
  private readonly defaultOptions;
11
+ private readonly debugEnabled;
17
12
  constructor();
18
13
  constructor(id: string);
19
14
  constructor(defaultOptions: ScreenOptions);
20
15
  constructor(id: string, defaultOptions: ScreenOptions);
16
+ constructor(id: string, defaultOptions: ScreenOptions, debug: boolean);
17
+ private log;
21
18
  getId(): string;
22
- addScreen(path: string, mixedComponent: MixedComponent, options?: ScreenOptions): NavigationStack;
19
+ addScreen(pathPattern: string, mixedComponent: MixedComponent | NavigationNode, options?: ScreenOptions): NavigationStack;
23
20
  addModal(path: string, mixedComponent: MixedComponent, options?: ScreenOptions): NavigationStack;
24
21
  addSheet(path: string, mixedComponent: MixedComponent, options?: ScreenOptions): NavigationStack;
22
+ addStack(prefixOrStack: string | NavigationStack, maybeStack?: NavigationStack): NavigationStack;
23
+ getChildren(): ChildNode[];
25
24
  getRoutes(): BuiltRoute[];
26
25
  getFirstRoute(): BuiltRoute | undefined;
27
26
  getDefaultOptions(): ScreenOptions | undefined;
27
+ getNodeRoutes(): BuiltRoute[];
28
+ getNodeChildren(): ChildNode[];
29
+ getRenderer(): React.ComponentType<any>;
30
+ seed?(): {
31
+ routeId: string;
32
+ params?: Record<string, unknown>;
33
+ path: string;
34
+ stackId?: string;
35
+ } | null;
28
36
  private extractComponent;
37
+ private isNavigationNode;
38
+ private buildQueryPattern;
39
+ private computeBaseSpecificity;
40
+ private normalizePrefix;
29
41
  }
30
42
  export {};
31
43
  //# sourceMappingURL=NavigationStack.d.ts.map
@@ -1,87 +1,200 @@
1
- import { NavigationStack } from './NavigationStack';
2
- import { TabBar } from './TabBar/TabBar';
3
- import type { HistoryItem, ScreenOptions, VisibleRoute } from './types';
1
+ import type { NavigationNode } from './navigationNode';
2
+ import type { HistoryItem, ScreenOptions, ActiveRoute, QueryPattern } from './types';
4
3
  type Listener = () => void;
5
4
  export interface RouterConfig {
6
- root: TabBar | NavigationStack;
7
- global?: NavigationStack;
5
+ root: NavigationNode;
8
6
  screenOptions?: ScreenOptions;
7
+ debug?: boolean;
9
8
  }
10
9
  export type RootTransition = ScreenOptions['stackAnimation'];
11
10
  type RouterState = {
12
11
  history: HistoryItem[];
13
- activeTabIndex?: number;
14
12
  };
15
13
  export declare class Router {
16
- tabBar: TabBar | null;
17
- root: NavigationStack | TabBar | null;
18
- global: NavigationStack | null;
14
+ root: NavigationNode | null;
19
15
  private readonly listeners;
20
16
  private readonly registry;
21
17
  private state;
22
18
  private readonly routerScreenOptions;
19
+ private readonly debugEnabled;
23
20
  private sheetDismissers;
24
- private stackSlices;
25
21
  private stackListeners;
26
- private activeTabListeners;
27
22
  private stackById;
28
23
  private routeById;
29
- private visibleRoute;
24
+ private stackActivators;
25
+ private stackHistories;
26
+ private activeRoute;
30
27
  private rootListeners;
31
28
  private rootTransition?;
29
+ private lastBrowserIndex;
30
+ private suppressHistorySyncCount;
31
+ private navigationToken;
32
32
  constructor(config: RouterConfig);
33
+ private log;
33
34
  navigate: (path: string) => void;
34
35
  replace: (path: string, dedupe?: boolean) => void;
36
+ /**
37
+ * Web-only convenience: resets Router navigation state to what a fresh
38
+ * deep-link render would produce for the given URL.
39
+ *
40
+ * This intentionally clears preserved per-tab stacks (useful when tab stacks
41
+ * and browser URL can get out of sync).
42
+ */
43
+ reset: (path: string) => void;
35
44
  registerSheetDismisser: (key: string, dismisser: () => void) => void;
36
45
  unregisterSheetDismisser: (key: string) => void;
37
46
  goBack: () => void;
38
- onTabIndexChange: (index: number) => void;
39
- setActiveTabIndex: (index: number) => void;
40
- ensureTabSeed: (index: number) => void;
41
47
  getState: () => RouterState;
42
48
  subscribe(listener: Listener): () => void;
43
- getStackHistory: (stackId: string) => HistoryItem[];
49
+ getStackHistory: (stackId?: string) => HistoryItem[];
44
50
  subscribeStack: (stackId: string, cb: Listener) => (() => void);
45
- getActiveTabIndex: () => number;
46
- subscribeActiveTab: (cb: Listener) => (() => void);
47
51
  getRootStackId(): string | undefined;
48
52
  getGlobalStackId(): string | undefined;
49
- hasTabBar(): boolean;
50
53
  subscribeRoot(listener: Listener): () => void;
51
54
  private emitRootChange;
52
55
  getRootTransition(): RootTransition | undefined;
53
- setRoot(nextRoot: TabBar | NavigationStack, options?: {
56
+ setRoot(nextRoot: NavigationNode, options?: {
54
57
  transition?: RootTransition;
55
58
  }): void;
56
- getVisibleRoute: () => VisibleRoute;
57
- private recomputeVisibleRoute;
59
+ getActiveRoute: () => ActiveRoute;
60
+ debugGetState(): {
61
+ history: {
62
+ key: string;
63
+ routeId: string;
64
+ stackId: string | undefined;
65
+ path: string | undefined;
66
+ params: Record<string, unknown> | undefined;
67
+ query: Record<string, unknown> | undefined;
68
+ stackPresentation: import("./types").StackPresentationTypes | undefined;
69
+ }[];
70
+ stackSlices: {
71
+ stackId: string;
72
+ items: {
73
+ key: string;
74
+ routeId: string;
75
+ path: string | undefined;
76
+ params: Record<string, unknown> | undefined;
77
+ query: Record<string, unknown> | undefined;
78
+ stackPresentation: import("./types").StackPresentationTypes | undefined;
79
+ }[];
80
+ }[];
81
+ activeRoute: ActiveRoute;
82
+ registry: {
83
+ routeId: string;
84
+ path: string;
85
+ pathnamePattern: string;
86
+ stackId: string | undefined;
87
+ isWildcardPath: boolean;
88
+ baseSpecificity: number;
89
+ queryPattern: QueryPattern | null;
90
+ options: ScreenOptions | undefined;
91
+ }[];
92
+ };
93
+ debugMatchRoute(path: string): {
94
+ input: {
95
+ path: string;
96
+ pathname: string;
97
+ query: Record<string, unknown>;
98
+ };
99
+ matches: {
100
+ routeId: string;
101
+ path: string;
102
+ pathnamePattern: string;
103
+ stackId?: string;
104
+ isWildcardPath: boolean;
105
+ baseSpecificity: number;
106
+ pathMatch: boolean;
107
+ queryMatch: boolean;
108
+ options?: ScreenOptions;
109
+ }[];
110
+ best: {
111
+ routeId: string;
112
+ path: string;
113
+ stackId: string | undefined;
114
+ options: ScreenOptions | undefined;
115
+ } | null;
116
+ };
117
+ debugGetStackInfo(stackId: string): {
118
+ stackId: string;
119
+ historyLength: number;
120
+ items: {
121
+ key: string;
122
+ routeId: string;
123
+ path: string | undefined;
124
+ params: Record<string, unknown> | undefined;
125
+ query: Record<string, unknown> | undefined;
126
+ stackPresentation: import("./types").StackPresentationTypes | undefined;
127
+ }[];
128
+ };
129
+ debugGetAllStacks(): {
130
+ stackId: string;
131
+ historyLength: number;
132
+ items: {
133
+ key: string;
134
+ routeId: string;
135
+ path: string | undefined;
136
+ params: Record<string, unknown> | undefined;
137
+ query: Record<string, unknown> | undefined;
138
+ stackPresentation: import("./types").StackPresentationTypes | undefined;
139
+ }[];
140
+ }[];
141
+ private recomputeActiveRoute;
58
142
  private performNavigation;
59
143
  private createHistoryItem;
144
+ private applyHistoryChange;
145
+ private setState;
146
+ private updateStackHistories;
147
+ private areArraysEqual;
148
+ private syncStateForSameRoute;
149
+ private resolveTargetStackAndRoute;
150
+ private findChildStackRouteForPathname;
151
+ private findRootRouteWithContainer;
152
+ private isRouteInContainer;
153
+ private activateContainerForRoute;
154
+ private findContainerInStack;
155
+ private activateStack;
156
+ private ensureStackHasSeed;
157
+ private updateActiveRouteFromStack;
158
+ private emit;
159
+ private getTopOfStack;
160
+ private findExistingRoute;
161
+ private findExistingRouteByPathname;
60
162
  private buildRegistry;
163
+ private normalizeBasePath;
164
+ private joinPaths;
165
+ private stripBasePath;
166
+ private combinePathWithBase;
167
+ private computeBasePathSpecificity;
168
+ private getAutoSeed;
61
169
  private seedInitialHistory;
62
- private matchRoute;
170
+ private addChildNodeSeedsToItems;
171
+ private addChildNodeSeedsToHistory;
172
+ private matchBaseRoute;
63
173
  private generateKey;
64
174
  private parsePath;
65
- private applyHistoryChange;
66
- private setState;
67
- private emit;
68
- private getTopForTarget;
69
175
  private mergeOptions;
70
176
  private findStackById;
177
+ private areShallowEqual;
178
+ private matchQueryPattern;
71
179
  private isWebEnv;
72
180
  private getCurrentUrl;
73
- private readIndex;
181
+ private readHistoryIndex;
182
+ private getHistoryIndexOrNull;
74
183
  private getHistoryIndex;
75
184
  private ensureHistoryIndex;
185
+ private getRouterPathFromHistory;
186
+ private getReplaceDedupeFromHistory;
187
+ private shouldSyncPathWithUrl;
76
188
  private pushUrl;
77
189
  private replaceUrl;
78
- private patchHistoryOnce;
79
- private lastBrowserIndex;
80
- private pendingReplaceDedupe;
190
+ private replaceUrlSilently;
191
+ private buildUrlFromActiveRoute;
192
+ private patchBrowserHistoryOnce;
81
193
  private setupBrowserHistory;
82
- private popOnce;
83
- private tryPopActiveStack;
84
- private parse;
194
+ private syncUrlAfterInternalPop;
195
+ private popFromActiveStack;
196
+ private buildHistoryFromUrl;
197
+ private reuseKeysFromPreviousHistory;
85
198
  }
86
199
  export {};
87
200
  //# sourceMappingURL=Router.d.ts.map
@@ -11,7 +11,7 @@ export type RouteLocalContextValue = {
11
11
  };
12
12
  export declare const RouteLocalContext: React.Context<RouteLocalContextValue | null>;
13
13
  export declare const useRouter: () => Router;
14
- export declare const useCurrentRoute: () => import("./types").VisibleRoute;
14
+ export declare const useCurrentRoute: () => import("./types").ActiveRoute;
15
15
  export declare function useParams<TParams extends Record<string, unknown> = Record<string, unknown>>(): TParams;
16
16
  export declare function useQueryParams<TQuery extends Record<string, unknown> = Record<string, unknown>>(): TQuery;
17
17
  export declare function useRoute(): RouteLocalContextValue;
@@ -1,9 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
- import { type TransitionStackType } from '../web/TransitionStack';
3
2
  type ScreenStackProps = {
4
3
  children: ReactNode;
5
4
  transitionTime?: number;
6
- type?: TransitionStackType;
7
5
  animated?: boolean;
8
6
  };
9
7
  export declare const ScreenStack: import("react").NamedExoticComponent<ScreenStackProps>;
@@ -0,0 +1,31 @@
1
+ import type { ScreenStackItemPhase } from '../ScreenStackItem/ScreenStackItem.types';
2
+ import type { TransitionStatus } from 'react-transition-state';
3
+ export type PresentationTypeClass = 'push' | 'modal' | 'transparent-modal' | 'contained-modal' | 'contained-transparent-modal' | 'fullscreen-modal' | 'formsheet' | 'pagesheet' | 'sheet';
4
+ export type AnimationType = 'push-enter' | 'push-exit' | 'push-background' | 'pop-enter' | 'pop-exit' | 'pop-background' | 'modal-enter' | 'modal-exit' | 'transparent-modal-enter' | 'transparent-modal-exit' | 'contained-modal-enter' | 'contained-modal-exit' | 'fullscreen-modal-enter' | 'fullscreen-modal-exit' | 'formsheet-enter' | 'formsheet-exit' | 'pagesheet-enter' | 'pagesheet-exit' | 'sheet-enter' | 'sheet-exit' | 'no-animate' | 'none';
5
+ export type ScreenStackItemState = {
6
+ presentationType: PresentationTypeClass;
7
+ animationType: AnimationType;
8
+ phase: ScreenStackItemPhase;
9
+ transitionStatus: TransitionStatus;
10
+ zIndex: number;
11
+ };
12
+ export type ScreenStackItemsContextValue = {
13
+ items: {
14
+ [key: string]: ScreenStackItemState;
15
+ };
16
+ };
17
+ export type ScreenStackAnimatingContextValue = boolean;
18
+ export declare const ScreenStackItemsContext: import("react").Context<ScreenStackItemsContextValue | null>;
19
+ export declare const ScreenStackAnimatingContext: import("react").Context<boolean>;
20
+ export type ScreenStackConfig = {
21
+ /**
22
+ * When false, the first screen pushed after the stack becomes empty will NOT animate
23
+ * (treated as an initial render). Subsequent pushes/pops still animate normally.
24
+ */
25
+ animateFirstScreenAfterEmpty?: boolean;
26
+ };
27
+ export declare const ScreenStackConfigContext: import("react").Context<ScreenStackConfig>;
28
+ export declare const useScreenStackConfig: () => ScreenStackConfig;
29
+ export declare const useScreenStackItemsContext: () => ScreenStackItemsContextValue;
30
+ export declare const useScreenStackAnimatingContext: () => boolean;
31
+ //# sourceMappingURL=ScreenStackContext.d.ts.map
@@ -0,0 +1,6 @@
1
+ import type { StackPresentationTypes } from '../types';
2
+ import type { PresentationTypeClass, AnimationType } from './ScreenStackContext';
3
+ export declare function getPresentationTypeClass(presentation: StackPresentationTypes): PresentationTypeClass;
4
+ export declare function getAnimationTypeForPresentation(presentation: StackPresentationTypes, isEntering: boolean, direction: 'forward' | 'back'): string;
5
+ export declare function computeAnimationType(_key: string, isInStack: boolean, isTop: boolean, direction: 'forward' | 'back', presentation: StackPresentationTypes, isInitialPhase: boolean, animated?: boolean): AnimationType;
6
+ //# sourceMappingURL=animationHelpers.d.ts.map
@@ -1,10 +1,14 @@
1
1
  import type { HistoryItem, NavigationAppearance, ScreenOptions } from '../types';
2
- export type ScreenStackItemPhase = 'active' | 'exiting';
2
+ import type { TransitionStatus } from 'react-transition-state';
3
+ import type { CSSProperties } from 'react';
4
+ export type ScreenStackItemPhase = 'active' | 'inactive' | 'exiting';
3
5
  export interface ScreenStackItemProps {
4
6
  item: HistoryItem;
5
7
  stackId?: string;
6
8
  stackAnimation?: ScreenOptions['stackAnimation'];
7
9
  appearance?: NavigationAppearance;
8
10
  phase?: ScreenStackItemPhase;
11
+ transitionStatus?: TransitionStatus;
12
+ style?: CSSProperties;
9
13
  }
10
14
  //# sourceMappingURL=ScreenStackItem.types.d.ts.map
@@ -1,3 +1,3 @@
1
1
  import type { ScreenStackItemProps } from './ScreenStackItem.types';
2
- export declare const ScreenStackItem: import("react").MemoExoticComponent<({ phase, item, appearance }: ScreenStackItemProps) => import("react/jsx-runtime").JSX.Element>;
2
+ export declare const ScreenStackItem: import("react").MemoExoticComponent<({ item, appearance, style }: ScreenStackItemProps) => import("react/jsx-runtime").JSX.Element | null>;
3
3
  //# sourceMappingURL=ScreenStackItem.web.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { NavigationAppearance } from '../types';
2
+ import type { SplitView } from './SplitView';
3
+ export interface RenderSplitViewProps {
4
+ splitView: SplitView;
5
+ appearance?: NavigationAppearance;
6
+ }
7
+ export declare const RenderSplitView: import("react").NamedExoticComponent<RenderSplitViewProps>;
8
+ //# sourceMappingURL=RenderSplitView.native.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { NavigationAppearance } from '../types';
2
+ import type { SplitView } from './SplitView';
3
+ export interface RenderSplitViewProps {
4
+ splitView: SplitView;
5
+ appearance?: NavigationAppearance;
6
+ }
7
+ export declare const RenderSplitView: import("react").NamedExoticComponent<RenderSplitViewProps>;
8
+ //# sourceMappingURL=RenderSplitView.web.d.ts.map
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import type { NavigationNode, NodeChild, NodeRoute } from '../navigationNode';
3
+ import type { NavigationStack } from '../NavigationStack';
4
+ export type SplitViewOptions = {
5
+ minWidth: number;
6
+ primary: NavigationStack;
7
+ secondary: NavigationStack;
8
+ primaryMaxWidth?: number;
9
+ };
10
+ export declare class SplitView implements NavigationNode {
11
+ private readonly splitViewId;
12
+ readonly primary: NavigationStack;
13
+ readonly secondary: NavigationStack;
14
+ readonly minWidth: number;
15
+ readonly primaryMaxWidth: number;
16
+ constructor(options: SplitViewOptions);
17
+ getId(): string;
18
+ getNodeRoutes(): NodeRoute[];
19
+ getNodeChildren(): NodeChild[];
20
+ getRenderer(): React.ComponentType<any>;
21
+ hasRoute(routeId: string): boolean;
22
+ switchToRoute(_routeId: string): void;
23
+ setActiveChildByRoute(routeId: string): void;
24
+ seed(): {
25
+ routeId: string;
26
+ params?: Record<string, unknown>;
27
+ path: string;
28
+ stackId?: string;
29
+ } | null;
30
+ }
31
+ //# sourceMappingURL=SplitView.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { SplitView } from './SplitView';
2
+ export declare const SplitViewContext: import("react").Context<SplitView | null>;
3
+ //# sourceMappingURL=SplitViewContext.d.ts.map
@@ -0,0 +1,5 @@
1
+ export { SplitView } from './SplitView';
2
+ export type { SplitViewOptions } from './SplitView';
3
+ export { RenderSplitView } from './RenderSplitView';
4
+ export { useSplitView } from './useSplitView';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const useSplitView: () => import("./SplitView").SplitView;
2
+ //# sourceMappingURL=useSplitView.d.ts.map
@@ -1,8 +1,9 @@
1
- import type { NavigationAppearance } from './types';
1
+ import type { HistoryItem, NavigationAppearance } from './types';
2
2
  import { NavigationStack } from './NavigationStack';
3
3
  export interface StackRendererProps {
4
4
  stack: NavigationStack;
5
5
  appearance?: NavigationAppearance;
6
+ history?: HistoryItem[];
6
7
  }
7
8
  export declare const StackRenderer: import("react").NamedExoticComponent<StackRendererProps>;
8
9
  //# sourceMappingURL=StackRenderer.d.ts.map
@@ -3,14 +3,16 @@ import { NavigationStack } from '../NavigationStack';
3
3
  import type { ComponentType } from 'react';
4
4
  import type { TabItem } from '../types';
5
5
  import React from 'react';
6
- type IOSIconShape = {
6
+ import type { NavigationNode, NodeChild, NodeRoute } from '../navigationNode';
7
+ import type { PlatformIcon } from 'react-native-screens';
8
+ type LegacyIOSIconShape = {
7
9
  sfSymbolName: string;
8
10
  } | {
9
11
  imageSource: ImageSourcePropType;
10
12
  } | {
11
13
  templateSource: ImageSourcePropType;
12
14
  };
13
- type ExtendedIcon = ImageSourcePropType | IOSIconShape;
15
+ type ExtendedIcon = ImageSourcePropType | LegacyIOSIconShape | PlatformIcon;
14
16
  export type InternalTabItem = Omit<TabItem, 'icon' | 'selectedIcon'> & {
15
17
  icon?: ExtendedIcon;
16
18
  selectedIcon?: ExtendedIcon;
@@ -21,6 +23,9 @@ export type TabBarProps = {
21
23
  tabs: InternalTabItem[];
22
24
  activeIndex: number;
23
25
  };
26
+ export type TabBarDescriptor = {
27
+ renderer?: ComponentType<TabBarProps>;
28
+ };
24
29
  type TabBarConfig = Omit<InternalTabItem, 'tabKey' | 'key'> & {
25
30
  stack?: NavigationStack;
26
31
  screen?: React.ComponentType<any>;
@@ -31,12 +36,14 @@ type TabBarOptions = {
31
36
  config?: TabBarConfig;
32
37
  initialIndex?: number;
33
38
  };
34
- export declare class TabBar {
39
+ export declare class TabBar implements NavigationNode {
40
+ private readonly tabBarId;
35
41
  screens: Record<string, React.ComponentType<any>>;
36
42
  stacks: Record<string, NavigationStack>;
37
43
  private listeners;
38
44
  private state;
39
45
  constructor(options?: TabBarOptions);
46
+ getId(): string;
40
47
  addTab(tab: Omit<TabBarConfig, 'tabKey'> & {
41
48
  key: string;
42
49
  }): TabBar;
@@ -51,6 +58,23 @@ export declare class TabBar {
51
58
  private setState;
52
59
  private notifyListeners;
53
60
  subscribe(listener: () => void): () => void;
61
+ getTabs(): InternalTabItem[];
62
+ getInitialIndex(): number;
63
+ getActiveChildId(): string | undefined;
64
+ switchToRoute(routeId: string): void;
65
+ hasRoute(routeId: string): boolean;
66
+ setActiveChildByRoute(routeId: string): void;
67
+ getNodeRoutes(): NodeRoute[];
68
+ getNodeChildren(): NodeChild[];
69
+ getRenderer(): React.ComponentType<any>;
70
+ seed(): {
71
+ routeId: string;
72
+ params?: Record<string, unknown>;
73
+ path: string;
74
+ stackId?: string;
75
+ } | null;
76
+ private findTabIndexByRoute;
77
+ private nodeHasRoute;
54
78
  }
55
79
  export {};
56
80
  //# sourceMappingURL=TabBar.d.ts.map
@@ -1,2 +1,5 @@
1
1
  export { RenderTabBar } from './RenderTabBar';
2
+ export { TabBar } from './TabBar';
3
+ export { useTabBar } from './useTabBar';
4
+ export { useTabBarHeight, TAB_BAR_HEIGHT } from './useTabBarHeight';
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The height of the TabBar in pixels
3
+ */
4
+ export declare const TAB_BAR_HEIGHT = 57;
5
+ /**
6
+ * Hook that returns the height of the TabBar
7
+ * @returns {number} The height of the TabBar in pixels
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const TabBarExample = () => {
12
+ * const tabBarHeight = useTabBarHeight();
13
+ * return <div style={{ paddingBottom: tabBarHeight }}>Content</div>;
14
+ * };
15
+ * ```
16
+ */
17
+ export declare const useTabBarHeight: () => number;
18
+ //# sourceMappingURL=useTabBarHeight.d.ts.map
@@ -7,6 +7,7 @@ export type Controller<TParams = Record<string, unknown>, TQuery = Record<string
7
7
  export type ComponentWithController = {
8
8
  controller?: Controller<any, any>;
9
9
  component: React.ComponentType<any>;
10
+ childNode?: import('./navigationNode').NavigationNode;
10
11
  };
11
12
  export type MixedComponent = ComponentWithController | React.ComponentType<any>;
12
13
  export declare function createController<TParams, TQuery = Record<string, unknown>>(controller: Controller<TParams, TQuery>): Controller<TParams, TQuery>;
@@ -1,10 +1,11 @@
1
1
  export { useTabBar } from './TabBar/useTabBar';
2
+ export { useTabBarHeight, TAB_BAR_HEIGHT } from './TabBar/useTabBarHeight';
2
3
  export { TabBar } from './TabBar/TabBar';
3
4
  export type { TabBarProps } from './TabBar/TabBar';
5
+ export { SplitView } from './SplitView/SplitView';
6
+ export type { SplitViewOptions } from './SplitView/SplitView';
7
+ export { useSplitView } from './SplitView/useSplitView';
4
8
  export type { NavigationAppearance } from './types';
5
- /**
6
- * Navigation System
7
- */
8
9
  export { Router } from './Router';
9
10
  export { Navigation } from './Navigation';
10
11
  export { createController } from './createController';
@@ -0,0 +1,41 @@
1
+ import type { ScreenOptions, QueryPattern } from './types';
2
+ import type { Controller } from './createController';
3
+ import type React from 'react';
4
+ export type NodeRoute = {
5
+ routeId: string;
6
+ path: string;
7
+ pathnamePattern: string;
8
+ isWildcardPath: boolean;
9
+ queryPattern: QueryPattern | null;
10
+ baseSpecificity: number;
11
+ matchPath: (path: string) => false | {
12
+ params: Record<string, any>;
13
+ };
14
+ component: React.ComponentType<any>;
15
+ controller?: Controller<any, any>;
16
+ options?: ScreenOptions;
17
+ childNode?: NavigationNode;
18
+ };
19
+ export type NodeChild = {
20
+ prefix: string;
21
+ node: NavigationNode;
22
+ onMatch?: () => void;
23
+ };
24
+ export interface NavigationNode {
25
+ getId(): string;
26
+ getNodeRoutes(): NodeRoute[];
27
+ getNodeChildren(): NodeChild[];
28
+ getRenderer(): React.ComponentType<any>;
29
+ getActiveChildId?: () => string | undefined;
30
+ switchToRoute?: (routeId: string) => void;
31
+ hasRoute?: (routeId: string) => boolean;
32
+ setActiveChildByRoute?: (routeId: string) => void;
33
+ seed?: () => {
34
+ routeId: string;
35
+ params?: Record<string, unknown>;
36
+ path: string;
37
+ stackId?: string;
38
+ } | null;
39
+ getDefaultOptions?: () => ScreenOptions | undefined;
40
+ }
41
+ //# sourceMappingURL=navigationNode.d.ts.map