@gtkx/navigation 0.0.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.
- package/README.md +174 -0
- package/dist/drawer/create-drawer-navigator.d.ts +30 -0
- package/dist/drawer/create-drawer-navigator.d.ts.map +1 -0
- package/dist/drawer/create-drawer-navigator.js +36 -0
- package/dist/drawer/create-drawer-navigator.js.map +1 -0
- package/dist/drawer/drawer-collapsed-context.d.ts +4 -0
- package/dist/drawer/drawer-collapsed-context.d.ts.map +1 -0
- package/dist/drawer/drawer-collapsed-context.js +4 -0
- package/dist/drawer/drawer-collapsed-context.js.map +1 -0
- package/dist/drawer/drawer-item-list.d.ts +6 -0
- package/dist/drawer/drawer-item-list.d.ts.map +1 -0
- package/dist/drawer/drawer-item-list.js +40 -0
- package/dist/drawer/drawer-item-list.js.map +1 -0
- package/dist/drawer/drawer-router.d.ts +5 -0
- package/dist/drawer/drawer-router.d.ts.map +1 -0
- package/dist/drawer/drawer-router.js +49 -0
- package/dist/drawer/drawer-router.js.map +1 -0
- package/dist/drawer/drawer-status.d.ts +4 -0
- package/dist/drawer/drawer-status.d.ts.map +1 -0
- package/dist/drawer/drawer-status.js +11 -0
- package/dist/drawer/drawer-status.js.map +1 -0
- package/dist/drawer/drawer-view.d.ts +11 -0
- package/dist/drawer/drawer-view.d.ts.map +1 -0
- package/dist/drawer/drawer-view.js +67 -0
- package/dist/drawer/drawer-view.js.map +1 -0
- package/dist/drawer/types.d.ts +80 -0
- package/dist/drawer/types.d.ts.map +1 -0
- package/dist/drawer/types.js +2 -0
- package/dist/drawer/types.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation-container.d.ts +15 -0
- package/dist/navigation-container.d.ts.map +1 -0
- package/dist/navigation-container.js +11 -0
- package/dist/navigation-container.js.map +1 -0
- package/dist/shared/header-bar.d.ts +11 -0
- package/dist/shared/header-bar.d.ts.map +1 -0
- package/dist/shared/header-bar.js +11 -0
- package/dist/shared/header-bar.js.map +1 -0
- package/dist/shared/routes.d.ts +6 -0
- package/dist/shared/routes.d.ts.map +1 -0
- package/dist/shared/routes.js +16 -0
- package/dist/shared/routes.js.map +1 -0
- package/dist/shared/scene-page.d.ts +13 -0
- package/dist/shared/scene-page.d.ts.map +1 -0
- package/dist/shared/scene-page.js +5 -0
- package/dist/shared/scene-page.js.map +1 -0
- package/dist/shared/types.d.ts +16 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +2 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/use-loaded-routes.d.ts +3 -0
- package/dist/shared/use-loaded-routes.d.ts.map +1 -0
- package/dist/shared/use-loaded-routes.js +11 -0
- package/dist/shared/use-loaded-routes.js.map +1 -0
- package/dist/shared/use-pop-to-top-on-blur.d.ts +10 -0
- package/dist/shared/use-pop-to-top-on-blur.d.ts.map +1 -0
- package/dist/shared/use-pop-to-top-on-blur.js +27 -0
- package/dist/shared/use-pop-to-top-on-blur.js.map +1 -0
- package/dist/split-view/create-split-view-navigator.d.ts +33 -0
- package/dist/split-view/create-split-view-navigator.d.ts.map +1 -0
- package/dist/split-view/create-split-view-navigator.js +20 -0
- package/dist/split-view/create-split-view-navigator.js.map +1 -0
- package/dist/split-view/split-view-router.d.ts +5 -0
- package/dist/split-view/split-view-router.d.ts.map +1 -0
- package/dist/split-view/split-view-router.js +42 -0
- package/dist/split-view/split-view-router.js.map +1 -0
- package/dist/split-view/split-view.d.ts +12 -0
- package/dist/split-view/split-view.d.ts.map +1 -0
- package/dist/split-view/split-view.js +62 -0
- package/dist/split-view/split-view.js.map +1 -0
- package/dist/split-view/types.d.ts +43 -0
- package/dist/split-view/types.d.ts.map +1 -0
- package/dist/split-view/types.js +2 -0
- package/dist/split-view/types.js.map +1 -0
- package/dist/stack/create-stack-navigator.d.ts +30 -0
- package/dist/stack/create-stack-navigator.d.ts.map +1 -0
- package/dist/stack/create-stack-navigator.js +16 -0
- package/dist/stack/create-stack-navigator.js.map +1 -0
- package/dist/stack/stack-pages.d.ts +11 -0
- package/dist/stack/stack-pages.d.ts.map +1 -0
- package/dist/stack/stack-pages.js +80 -0
- package/dist/stack/stack-pages.js.map +1 -0
- package/dist/stack/stack-view.d.ts +14 -0
- package/dist/stack/stack-view.d.ts.map +1 -0
- package/dist/stack/stack-view.js +101 -0
- package/dist/stack/stack-view.js.map +1 -0
- package/dist/stack/sync-navigation-stack.d.ts +7 -0
- package/dist/stack/sync-navigation-stack.d.ts.map +1 -0
- package/dist/stack/sync-navigation-stack.js +69 -0
- package/dist/stack/sync-navigation-stack.js.map +1 -0
- package/dist/stack/types.d.ts +72 -0
- package/dist/stack/types.d.ts.map +1 -0
- package/dist/stack/types.js +2 -0
- package/dist/stack/types.js.map +1 -0
- package/dist/static-navigation.d.ts +13 -0
- package/dist/static-navigation.d.ts.map +1 -0
- package/dist/static-navigation.js +10 -0
- package/dist/static-navigation.js.map +1 -0
- package/dist/tabs/create-tab-navigator.d.ts +30 -0
- package/dist/tabs/create-tab-navigator.d.ts.map +1 -0
- package/dist/tabs/create-tab-navigator.js +16 -0
- package/dist/tabs/create-tab-navigator.js.map +1 -0
- package/dist/tabs/tab-view.d.ts +11 -0
- package/dist/tabs/tab-view.d.ts.map +1 -0
- package/dist/tabs/tab-view.js +52 -0
- package/dist/tabs/tab-view.js.map +1 -0
- package/dist/tabs/types.d.ts +67 -0
- package/dist/tabs/types.d.ts.map +1 -0
- package/dist/tabs/types.js +2 -0
- package/dist/tabs/types.js.map +1 -0
- package/dist/theme.d.ts +18 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +15 -0
- package/dist/theme.js.map +1 -0
- package/package.json +71 -0
- package/src/drawer/create-drawer-navigator.tsx +123 -0
- package/src/drawer/drawer-collapsed-context.ts +5 -0
- package/src/drawer/drawer-item-list.tsx +74 -0
- package/src/drawer/drawer-router.ts +90 -0
- package/src/drawer/drawer-status.ts +19 -0
- package/src/drawer/drawer-view.tsx +171 -0
- package/src/drawer/types.ts +142 -0
- package/src/index.ts +83 -0
- package/src/navigation-container.tsx +35 -0
- package/src/shared/header-bar.tsx +34 -0
- package/src/shared/routes.ts +25 -0
- package/src/shared/scene-page.tsx +27 -0
- package/src/shared/types.ts +17 -0
- package/src/shared/use-loaded-routes.ts +14 -0
- package/src/shared/use-pop-to-top-on-blur.ts +45 -0
- package/src/split-view/create-split-view-navigator.tsx +99 -0
- package/src/split-view/split-view-router.ts +73 -0
- package/src/split-view/split-view.tsx +137 -0
- package/src/split-view/types.ts +100 -0
- package/src/stack/create-stack-navigator.tsx +80 -0
- package/src/stack/stack-pages.ts +140 -0
- package/src/stack/stack-view.tsx +202 -0
- package/src/stack/sync-navigation-stack.ts +117 -0
- package/src/stack/types.ts +131 -0
- package/src/static-navigation.tsx +26 -0
- package/src/tabs/create-tab-navigator.tsx +69 -0
- package/src/tabs/tab-view.tsx +126 -0
- package/src/tabs/types.ts +120 -0
- package/src/theme.ts +31 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { DefaultNavigatorOptions, Descriptor, DrawerActionHelpers, DrawerNavigationState, DrawerRouterOptions, NavigationHelpers, NavigationProp, ParamListBase, RouteProp } from "@react-navigation/core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { HeaderOptions } from "../shared/types.js";
|
|
4
|
+
/** Events the drawer navigator emits on top of React Navigation's core events. */
|
|
5
|
+
type DrawerNavigationEventMap = {
|
|
6
|
+
/** The user activated an item in the sidebar. */
|
|
7
|
+
drawerItemPress: {
|
|
8
|
+
/** No payload. */
|
|
9
|
+
data: undefined;
|
|
10
|
+
/** Calling `preventDefault` keeps the current screen. */
|
|
11
|
+
canPreventDefault: true;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/** Per-screen options of the drawer navigator. */
|
|
15
|
+
type DrawerNavigationOptions = HeaderOptions & {
|
|
16
|
+
/** Renders a custom top bar instead of the default `AdwHeaderBar`. */
|
|
17
|
+
header?: (props: DrawerHeaderProps) => ReactNode;
|
|
18
|
+
/** Label shown in the sidebar; defaults to `title`, then to the route name. */
|
|
19
|
+
drawerLabel?: string;
|
|
20
|
+
/** Icon name shown next to the sidebar label. */
|
|
21
|
+
drawerIcon?: string;
|
|
22
|
+
/** Whether the screen mounts on first focus instead of at startup; defaults to `true`. */
|
|
23
|
+
lazy?: boolean;
|
|
24
|
+
/** Whether a nested stack pops to its first screen when this screen loses focus; defaults to `false`. */
|
|
25
|
+
popToTopOnBlur?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** Navigation object of a drawer screen. */
|
|
28
|
+
type DrawerNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, DrawerNavigationState<ParamList>, DrawerNavigationOptions, DrawerNavigationEventMap> & DrawerActionHelpers<ParamList>;
|
|
29
|
+
/** Props a drawer screen component receives. */
|
|
30
|
+
type DrawerScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = {
|
|
31
|
+
/** Navigation object of the screen. */
|
|
32
|
+
navigation: DrawerNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
33
|
+
/** The route the screen renders. */
|
|
34
|
+
route: RouteProp<ParamList, RouteName>;
|
|
35
|
+
};
|
|
36
|
+
/** Arguments of a custom drawer `header` renderer. */
|
|
37
|
+
type DrawerHeaderProps = {
|
|
38
|
+
/** The focused route. */
|
|
39
|
+
route: RouteProp<ParamListBase>;
|
|
40
|
+
/** Navigation object of the focused route. */
|
|
41
|
+
navigation: DrawerNavigationProp<ParamListBase>;
|
|
42
|
+
/** Resolved options of the focused route. */
|
|
43
|
+
options: DrawerNavigationOptions;
|
|
44
|
+
};
|
|
45
|
+
/** Navigation helpers of the drawer navigator itself. */
|
|
46
|
+
type DrawerNavigationHelpers = NavigationHelpers<ParamListBase, DrawerNavigationEventMap> & DrawerActionHelpers<ParamListBase>;
|
|
47
|
+
/** Descriptor of one drawer route. */
|
|
48
|
+
type DrawerDescriptor = Descriptor<DrawerNavigationOptions, DrawerNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
|
|
49
|
+
/** Descriptors of the drawer routes, keyed by route key. */
|
|
50
|
+
type DrawerDescriptorMap = Record<string, DrawerDescriptor>;
|
|
51
|
+
/** Arguments of a custom `drawerContent` renderer and props of {@link DrawerItemList}. */
|
|
52
|
+
type DrawerContentProps = {
|
|
53
|
+
/** State of the drawer navigator. */
|
|
54
|
+
state: DrawerNavigationState<ParamListBase>;
|
|
55
|
+
/** Navigation helpers of the drawer navigator. */
|
|
56
|
+
navigation: DrawerNavigationHelpers;
|
|
57
|
+
/** Descriptors of the drawer routes. */
|
|
58
|
+
descriptors: DrawerDescriptorMap;
|
|
59
|
+
};
|
|
60
|
+
/** Props of the drawer navigator beyond the options every navigator shares. */
|
|
61
|
+
type DrawerNavigationConfig = {
|
|
62
|
+
/** Renders the sidebar; defaults to a header bar above a {@link DrawerItemList}. */
|
|
63
|
+
drawerContent?: (props: DrawerContentProps) => ReactNode;
|
|
64
|
+
/** Whether the sidebar overlays the content instead of sitting beside it; defaults to `false`. */
|
|
65
|
+
collapsed?: boolean;
|
|
66
|
+
/** Which side the sidebar sits on; defaults to `"start"`. */
|
|
67
|
+
sidebarPosition?: "start" | "end";
|
|
68
|
+
/** Whether collapsing and uncollapsing leave the sidebar's visibility alone; defaults to `false`. */
|
|
69
|
+
pinSidebar?: boolean;
|
|
70
|
+
/** Minimum sidebar width, in the unit libadwaita uses for the split view. */
|
|
71
|
+
minSidebarWidth?: number;
|
|
72
|
+
/** Maximum sidebar width, in the unit libadwaita uses for the split view. */
|
|
73
|
+
maxSidebarWidth?: number;
|
|
74
|
+
/** Preferred sidebar width as a fraction of the total width. */
|
|
75
|
+
sidebarWidthFraction?: number;
|
|
76
|
+
};
|
|
77
|
+
/** Props of the drawer `Navigator` component. */
|
|
78
|
+
type DrawerNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, DrawerNavigationState<ParamListBase>, DrawerNavigationOptions, DrawerNavigationEventMap, DrawerNavigationProp<ParamListBase>> & DrawerRouterOptions & DrawerNavigationConfig;
|
|
79
|
+
export type { DrawerContentProps, DrawerDescriptor, DrawerDescriptorMap, DrawerHeaderProps, DrawerNavigationConfig, DrawerNavigationEventMap, DrawerNavigationHelpers, DrawerNavigationOptions, DrawerNavigationProp, DrawerNavigatorProps, DrawerScreenProps, };
|
|
80
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/drawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,uBAAuB,EACvB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,SAAS,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,kFAAkF;AAClF,KAAK,wBAAwB,GAAG;IAC5B,iDAAiD;IACjD,eAAe,EAAE;QACb,kBAAkB;QAClB,IAAI,EAAE,SAAS,CAAC;QAChB,yDAAyD;QACzD,iBAAiB,EAAE,IAAI,CAAC;KAC3B,CAAC;CACL,CAAC;AAEF,kDAAkD;AAClD,KAAK,uBAAuB,GAAG,aAAa,GAAG;IAC3C,sEAAsE;IACtE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC;IACjD,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,IAAI,CAAC,EAAE,OAAO,CAAC;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","sourcesContent":["import type {\n DefaultNavigatorOptions,\n Descriptor,\n DrawerActionHelpers,\n DrawerNavigationState,\n DrawerRouterOptions,\n NavigationHelpers,\n NavigationProp,\n ParamListBase,\n RouteProp,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport type { HeaderOptions } from \"../shared/types.js\";\n\n/** Events the drawer navigator emits on top of React Navigation's core events. */\ntype DrawerNavigationEventMap = {\n /** The user activated an item in the sidebar. */\n drawerItemPress: {\n /** No payload. */\n data: undefined;\n /** Calling `preventDefault` keeps the current screen. */\n canPreventDefault: true;\n };\n};\n\n/** Per-screen options of the drawer navigator. */\ntype DrawerNavigationOptions = HeaderOptions & {\n /** Renders a custom top bar instead of the default `AdwHeaderBar`. */\n header?: (props: DrawerHeaderProps) => ReactNode;\n /** Label shown in the sidebar; defaults to `title`, then to the route name. */\n drawerLabel?: string;\n /** Icon name shown next to the sidebar label. */\n drawerIcon?: string;\n /** Whether the screen mounts on first focus instead of at startup; defaults to `true`. */\n lazy?: boolean;\n /** Whether a nested stack pops to its first screen when this screen loses focus; defaults to `false`. */\n popToTopOnBlur?: boolean;\n};\n\n/** Navigation object of a drawer screen. */\ntype DrawerNavigationProp<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = NavigationProp<\n ParamList,\n RouteName,\n NavigatorID,\n DrawerNavigationState<ParamList>,\n DrawerNavigationOptions,\n DrawerNavigationEventMap\n> & DrawerActionHelpers<ParamList>;\n\n/** Props a drawer screen component receives. */\ntype DrawerScreenProps<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = {\n /** Navigation object of the screen. */\n navigation: DrawerNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Arguments of a custom drawer `header` renderer. */\ntype DrawerHeaderProps = {\n /** The focused route. */\n route: RouteProp<ParamListBase>;\n /** Navigation object of the focused route. */\n navigation: DrawerNavigationProp<ParamListBase>;\n /** Resolved options of the focused route. */\n options: DrawerNavigationOptions;\n};\n\n/** Navigation helpers of the drawer navigator itself. */\ntype DrawerNavigationHelpers = NavigationHelpers<ParamListBase, DrawerNavigationEventMap> &\n DrawerActionHelpers<ParamListBase>;\n\n/** Descriptor of one drawer route. */\ntype DrawerDescriptor = Descriptor<\n DrawerNavigationOptions,\n DrawerNavigationProp<ParamListBase>,\n RouteProp<ParamListBase>\n>;\n\n/** Descriptors of the drawer routes, keyed by route key. */\ntype DrawerDescriptorMap = Record<string, DrawerDescriptor>;\n\n/** Arguments of a custom `drawerContent` renderer and props of {@link DrawerItemList}. */\ntype DrawerContentProps = {\n /** State of the drawer navigator. */\n state: DrawerNavigationState<ParamListBase>;\n /** Navigation helpers of the drawer navigator. */\n navigation: DrawerNavigationHelpers;\n /** Descriptors of the drawer routes. */\n descriptors: DrawerDescriptorMap;\n};\n\n/** Props of the drawer navigator beyond the options every navigator shares. */\ntype DrawerNavigationConfig = {\n /** Renders the sidebar; defaults to a header bar above a {@link DrawerItemList}. */\n drawerContent?: (props: DrawerContentProps) => ReactNode;\n /** Whether the sidebar overlays the content instead of sitting beside it; defaults to `false`. */\n collapsed?: boolean;\n /** Which side the sidebar sits on; defaults to `\"start\"`. */\n sidebarPosition?: \"start\" | \"end\";\n /** Whether collapsing and uncollapsing leave the sidebar's visibility alone; defaults to `false`. */\n pinSidebar?: boolean;\n /** Minimum sidebar width, in the unit libadwaita uses for the split view. */\n minSidebarWidth?: number;\n /** Maximum sidebar width, in the unit libadwaita uses for the split view. */\n maxSidebarWidth?: number;\n /** Preferred sidebar width as a fraction of the total width. */\n sidebarWidthFraction?: number;\n};\n\n/** Props of the drawer `Navigator` component. */\ntype DrawerNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n DrawerNavigationState<ParamListBase>,\n DrawerNavigationOptions,\n DrawerNavigationEventMap,\n DrawerNavigationProp<ParamListBase>\n> &\nDrawerRouterOptions &\nDrawerNavigationConfig;\n\nexport type {\n DrawerContentProps,\n DrawerDescriptor,\n DrawerDescriptorMap,\n DrawerHeaderProps,\n DrawerNavigationConfig,\n DrawerNavigationEventMap,\n DrawerNavigationHelpers,\n DrawerNavigationOptions,\n DrawerNavigationProp,\n DrawerNavigatorProps,\n DrawerScreenProps,\n};\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { createDrawerNavigator, createDrawerScreen, DrawerNavigator, type DrawerTypeBag, } from "./drawer/create-drawer-navigator.js";
|
|
2
|
+
export { DrawerItemList } from "./drawer/drawer-item-list.js";
|
|
3
|
+
export type { DrawerContentProps, DrawerDescriptor, DrawerDescriptorMap, DrawerHeaderProps, DrawerNavigationConfig, DrawerNavigationEventMap, DrawerNavigationHelpers, DrawerNavigationOptions, DrawerNavigationProp, DrawerNavigatorProps, DrawerScreenProps, } from "./drawer/types.js";
|
|
4
|
+
export { NavigationContainer, type NavigationContainerComponent, type NavigationContainerProps, } from "./navigation-container.js";
|
|
5
|
+
export type { HeaderOptions } from "./shared/types.js";
|
|
6
|
+
export { createSplitViewNavigator, createSplitViewScreen, SplitViewNavigator, type SplitViewTypeBag, } from "./split-view/create-split-view-navigator.js";
|
|
7
|
+
export type { SplitViewDescriptor, SplitViewDescriptorMap, SplitViewNavigationConfig, SplitViewNavigationEventMap, SplitViewNavigationHelpers, SplitViewNavigationOptions, SplitViewNavigationProp, SplitViewNavigatorProps, SplitViewScreenProps, } from "./split-view/types.js";
|
|
8
|
+
export { createStackNavigator, createStackScreen, StackNavigator, type StackTypeBag, } from "./stack/create-stack-navigator.js";
|
|
9
|
+
export type { StackDescriptor, StackDescriptorMap, StackHeaderBack, StackHeaderProps, StackNavigationConfig, StackNavigationEventMap, StackNavigationHelpers, StackNavigationOptions, StackNavigationProp, StackNavigatorProps, StackScreenProps, StackTransitionData, } from "./stack/types.js";
|
|
10
|
+
export { createStaticNavigation, type StaticNavigationProps, type StaticNavigationTree, } from "./static-navigation.js";
|
|
11
|
+
export { createTabNavigator, createTabScreen, TabNavigator, type TabTypeBag } from "./tabs/create-tab-navigator.js";
|
|
12
|
+
export type { TabDescriptor, TabDescriptorMap, TabHeaderProps, TabNavigationConfig, TabNavigationEventMap, TabNavigationHelpers, TabNavigationOptions, TabNavigationProp, TabNavigatorProps, TabScreenProps, } from "./tabs/types.js";
|
|
13
|
+
export { DarkTheme, DefaultTheme, type Theme } from "./theme.js";
|
|
14
|
+
export * from "@react-navigation/core";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,KAAK,aAAa,GACrB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EACR,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,mBAAmB,EACnB,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,GAChC,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACH,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,gBAAgB,GACxB,MAAM,6CAA6C,CAAC;AACrD,YAAY,EACR,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,KAAK,YAAY,GACpB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACR,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACpH,YAAY,EACR,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACjE,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { createDrawerNavigator, createDrawerScreen, DrawerNavigator, } from "./drawer/create-drawer-navigator.js";
|
|
2
|
+
export { DrawerItemList } from "./drawer/drawer-item-list.js";
|
|
3
|
+
export { NavigationContainer, } from "./navigation-container.js";
|
|
4
|
+
export { createSplitViewNavigator, createSplitViewScreen, SplitViewNavigator, } from "./split-view/create-split-view-navigator.js";
|
|
5
|
+
export { createStackNavigator, createStackScreen, StackNavigator, } from "./stack/create-stack-navigator.js";
|
|
6
|
+
export { createStaticNavigation, } from "./static-navigation.js";
|
|
7
|
+
export { createTabNavigator, createTabScreen, TabNavigator } from "./tabs/create-tab-navigator.js";
|
|
8
|
+
export { DarkTheme, DefaultTheme } from "./theme.js";
|
|
9
|
+
export * from "@react-navigation/core";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAElB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAc9D,OAAO,EACH,mBAAmB,GAGtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACH,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GAErB,MAAM,6CAA6C,CAAC;AAYrD,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GAEjB,MAAM,mCAAmC,CAAC;AAe3C,OAAO,EACH,sBAAsB,GAGzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAmB,MAAM,gCAAgC,CAAC;AAapH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AACjE,cAAc,wBAAwB,CAAC","sourcesContent":["export {\n createDrawerNavigator,\n createDrawerScreen,\n DrawerNavigator,\n type DrawerTypeBag,\n} from \"./drawer/create-drawer-navigator.js\";\nexport { DrawerItemList } from \"./drawer/drawer-item-list.js\";\nexport type {\n DrawerContentProps,\n DrawerDescriptor,\n DrawerDescriptorMap,\n DrawerHeaderProps,\n DrawerNavigationConfig,\n DrawerNavigationEventMap,\n DrawerNavigationHelpers,\n DrawerNavigationOptions,\n DrawerNavigationProp,\n DrawerNavigatorProps,\n DrawerScreenProps,\n} from \"./drawer/types.js\";\nexport {\n NavigationContainer,\n type NavigationContainerComponent,\n type NavigationContainerProps,\n} from \"./navigation-container.js\";\nexport type { HeaderOptions } from \"./shared/types.js\";\nexport {\n createSplitViewNavigator,\n createSplitViewScreen,\n SplitViewNavigator,\n type SplitViewTypeBag,\n} from \"./split-view/create-split-view-navigator.js\";\nexport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationEventMap,\n SplitViewNavigationHelpers,\n SplitViewNavigationOptions,\n SplitViewNavigationProp,\n SplitViewNavigatorProps,\n SplitViewScreenProps,\n} from \"./split-view/types.js\";\nexport {\n createStackNavigator,\n createStackScreen,\n StackNavigator,\n type StackTypeBag,\n} from \"./stack/create-stack-navigator.js\";\nexport type {\n StackDescriptor,\n StackDescriptorMap,\n StackHeaderBack,\n StackHeaderProps,\n StackNavigationConfig,\n StackNavigationEventMap,\n StackNavigationHelpers,\n StackNavigationOptions,\n StackNavigationProp,\n StackNavigatorProps,\n StackScreenProps,\n StackTransitionData,\n} from \"./stack/types.js\";\nexport {\n createStaticNavigation,\n type StaticNavigationProps,\n type StaticNavigationTree,\n} from \"./static-navigation.js\";\nexport { createTabNavigator, createTabScreen, TabNavigator, type TabTypeBag } from \"./tabs/create-tab-navigator.js\";\nexport type {\n TabDescriptor,\n TabDescriptorMap,\n TabHeaderProps,\n TabNavigationConfig,\n TabNavigationEventMap,\n TabNavigationHelpers,\n TabNavigationOptions,\n TabNavigationProp,\n TabNavigatorProps,\n TabScreenProps,\n} from \"./tabs/types.js\";\nexport { DarkTheme, DefaultTheme, type Theme } from \"./theme.js\";\nexport * from \"@react-navigation/core\";\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NavigationContainerProps as CoreContainerProps, NavigationContainerRef } from "@react-navigation/core";
|
|
2
|
+
import type { ReactNode, Ref } from "react";
|
|
3
|
+
/** Props of {@link NavigationContainer}. */
|
|
4
|
+
type NavigationContainerProps<ParamList extends object = ReactNavigation.RootParamList> = Omit<CoreContainerProps, "navigationInChildEnabled" | "theme"> & {
|
|
5
|
+
/** Theme handed to `useTheme` and option callbacks; defaults to the live Adwaita style state. */
|
|
6
|
+
theme?: ReactNavigation.Theme;
|
|
7
|
+
/** Receives the container's imperative navigation API. */
|
|
8
|
+
ref?: Ref<NavigationContainerRef<ParamList>>;
|
|
9
|
+
};
|
|
10
|
+
/** The {@link NavigationContainer} component, generic over the root param list. */
|
|
11
|
+
type NavigationContainerComponent = <ParamList extends object = ReactNavigation.RootParamList>(props: NavigationContainerProps<ParamList>) => ReactNode;
|
|
12
|
+
/** Hosts the navigation tree: render it once at the root, around the navigators. */
|
|
13
|
+
declare const NavigationContainer: NavigationContainerComponent;
|
|
14
|
+
export { NavigationContainer, type NavigationContainerComponent, type NavigationContainerProps };
|
|
15
|
+
//# sourceMappingURL=navigation-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-container.d.ts","sourceRoot":"","sources":["../src/navigation-container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,wBAAwB,IAAI,kBAAkB,EAC9C,sBAAsB,EAEzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAI5C,4CAA4C;AAC5C,KAAK,wBAAwB,CAAC,SAAS,SAAS,MAAM,GAAG,eAAe,CAAC,aAAa,IAAI,IAAI,CAC1F,kBAAkB,EAClB,0BAA0B,GAAG,OAAO,CACvC,GAAG;IACA,iGAAiG;IACjG,KAAK,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC;IAC9B,0DAA0D;IAC1D,GAAG,CAAC,EAAE,GAAG,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,mFAAmF;AACnF,KAAK,4BAA4B,GAAG,CAAC,SAAS,SAAS,MAAM,GAAG,eAAe,CAAC,aAAa,EACzF,KAAK,EAAE,wBAAwB,CAAC,SAAS,CAAC,KACzC,SAAS,CAAC;AAEf,oFAAoF;AACpF,QAAA,MAAM,mBAAmB,EAAE,4BAAuF,CAAC;AAQnH,OAAO,EAAE,mBAAmB,EAAE,KAAK,4BAA4B,EAAE,KAAK,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BaseNavigationContainer } from "@react-navigation/core";
|
|
3
|
+
import { useAdwaitaTheme } from "./theme.js";
|
|
4
|
+
/** Hosts the navigation tree: render it once at the root, around the navigators. */
|
|
5
|
+
const NavigationContainer = NavigationContainerInner;
|
|
6
|
+
function NavigationContainerInner({ ref, theme, ...rest }) {
|
|
7
|
+
const adwaitaTheme = useAdwaitaTheme();
|
|
8
|
+
return _jsx(BaseNavigationContainer, { ...rest, ref: ref, theme: theme ?? adwaitaTheme });
|
|
9
|
+
}
|
|
10
|
+
export { NavigationContainer };
|
|
11
|
+
//# sourceMappingURL=navigation-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-container.js","sourceRoot":"","sources":["../src/navigation-container.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkB7C,oFAAoF;AACpF,MAAM,mBAAmB,GAAiC,wBAAwD,CAAC;AAEnH,SAAS,wBAAwB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,EAA2C;IAC9F,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,OAAO,KAAC,uBAAuB,OAAK,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,IAAI,YAAY,GAAI,CAAC;AACzF,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAoE,CAAC","sourcesContent":["import type {\n NavigationContainerProps as CoreContainerProps,\n NavigationContainerRef,\n ParamListBase,\n} from \"@react-navigation/core\";\nimport type { ReactNode, Ref } from \"react\";\nimport { BaseNavigationContainer } from \"@react-navigation/core\";\nimport { useAdwaitaTheme } from \"./theme.js\";\n\n/** Props of {@link NavigationContainer}. */\ntype NavigationContainerProps<ParamList extends object = ReactNavigation.RootParamList> = Omit<\n CoreContainerProps,\n \"navigationInChildEnabled\" | \"theme\"\n> & {\n /** Theme handed to `useTheme` and option callbacks; defaults to the live Adwaita style state. */\n theme?: ReactNavigation.Theme;\n /** Receives the container's imperative navigation API. */\n ref?: Ref<NavigationContainerRef<ParamList>>;\n};\n\n/** The {@link NavigationContainer} component, generic over the root param list. */\ntype NavigationContainerComponent = <ParamList extends object = ReactNavigation.RootParamList>(\n props: NavigationContainerProps<ParamList>,\n) => ReactNode;\n\n/** Hosts the navigation tree: render it once at the root, around the navigators. */\nconst NavigationContainer: NavigationContainerComponent = NavigationContainerInner as NavigationContainerComponent;\n\nfunction NavigationContainerInner({ ref, theme, ...rest }: NavigationContainerProps<ParamListBase>): ReactNode {\n const adwaitaTheme = useAdwaitaTheme();\n\n return <BaseNavigationContainer {...rest} ref={ref} theme={theme ?? adwaitaTheme} />;\n}\n\nexport { NavigationContainer, type NavigationContainerComponent, type NavigationContainerProps };\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { HeaderOptions } from "./types.js";
|
|
3
|
+
type HeaderBarProps = {
|
|
4
|
+
options: HeaderOptions;
|
|
5
|
+
titleWidget?: ReactElement;
|
|
6
|
+
start?: ReactNode;
|
|
7
|
+
showBackButton?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const HeaderBar: ({ options, titleWidget, start, showBackButton }: HeaderBarProps) => ReactNode;
|
|
10
|
+
export { HeaderBar };
|
|
11
|
+
//# sourceMappingURL=header-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-bar.d.ts","sourceRoot":"","sources":["../../src/shared/header-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,KAAK,cAAc,GAAG;IAClB,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAUF,QAAA,MAAM,SAAS,GAAI,iDAAiD,cAAc,KAAG,SAYpF,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AdwHeaderBar, AdwWindowTitle } from "@gtkx/jsx/adw";
|
|
3
|
+
const resolveTitleWidget = (options, fallback) => {
|
|
4
|
+
if (typeof options.headerTitle === "string") {
|
|
5
|
+
return _jsx(AdwWindowTitle, { title: options.headerTitle });
|
|
6
|
+
}
|
|
7
|
+
return options.headerTitle ?? fallback;
|
|
8
|
+
};
|
|
9
|
+
const HeaderBar = ({ options, titleWidget, start, showBackButton }) => (_jsx(AdwHeaderBar, { showBackButton: showBackButton ?? true, titleWidget: resolveTitleWidget(options, titleWidget), start: (_jsxs(_Fragment, { children: [start, options.headerStart] })), end: options.headerEnd }));
|
|
10
|
+
export { HeaderBar };
|
|
11
|
+
//# sourceMappingURL=header-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-bar.js","sourceRoot":"","sources":["../../src/shared/header-bar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAU7D,MAAM,kBAAkB,GAAG,CAAC,OAAsB,EAAE,QAAkC,EAA4B,EAAE;IAChH,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,OAAO,CAAC,WAAW,GAAI,CAAC;IAC1D,CAAC;IAED,OAAO,OAAO,CAAC,WAAW,IAAI,QAAQ,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAkB,EAAa,EAAE,CAAC,CAC9F,KAAC,YAAY,IACT,cAAc,EAAE,cAAc,IAAI,IAAI,EACtC,WAAW,EAAE,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,EACrD,KAAK,EAAE,CACH,8BACK,KAAK,EACL,OAAO,CAAC,WAAW,IACrB,CACN,EACD,GAAG,EAAE,OAAO,CAAC,SAAS,GACxB,CACL,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { ReactElement, ReactNode } from \"react\";\nimport { AdwHeaderBar, AdwWindowTitle } from \"@gtkx/jsx/adw\";\nimport type { HeaderOptions } from \"./types.js\";\n\ntype HeaderBarProps = {\n options: HeaderOptions;\n titleWidget?: ReactElement;\n start?: ReactNode;\n showBackButton?: boolean;\n};\n\nconst resolveTitleWidget = (options: HeaderOptions, fallback: ReactElement | undefined): ReactElement | undefined => {\n if (typeof options.headerTitle === \"string\") {\n return <AdwWindowTitle title={options.headerTitle} />;\n }\n\n return options.headerTitle ?? fallback;\n};\n\nconst HeaderBar = ({ options, titleWidget, start, showBackButton }: HeaderBarProps): ReactNode => (\n <AdwHeaderBar\n showBackButton={showBackButton ?? true}\n titleWidget={resolveTitleWidget(options, titleWidget)}\n start={(\n <>\n {start}\n {options.headerStart}\n </>\n )}\n end={options.headerEnd}\n />\n);\n\nexport { HeaderBar };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NavigationState } from "@react-navigation/core";
|
|
2
|
+
type FocusedRoute<State extends NavigationState> = State["routes"][number];
|
|
3
|
+
declare const getFocusedRoute: <State extends NavigationState>(state: State) => FocusedRoute<State>;
|
|
4
|
+
declare const requireDescriptor: <Descriptor>(descriptors: Record<string, Descriptor>, key: string) => Descriptor;
|
|
5
|
+
export { getFocusedRoute, requireDescriptor };
|
|
6
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/shared/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,KAAK,YAAY,CAAC,KAAK,SAAS,eAAe,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E,QAAA,MAAM,eAAe,GAAI,KAAK,SAAS,eAAe,EAAE,OAAO,KAAK,KAAG,YAAY,CAAC,KAAK,CAQxF,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,UAAU,EAAE,aAAa,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,KAAK,MAAM,KAAG,UAQ7F,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const getFocusedRoute = (state) => {
|
|
2
|
+
const route = state.routes[state.index];
|
|
3
|
+
if (route === undefined) {
|
|
4
|
+
throw new Error(`Navigation state has no route at index ${String(state.index)}`);
|
|
5
|
+
}
|
|
6
|
+
return route;
|
|
7
|
+
};
|
|
8
|
+
const requireDescriptor = (descriptors, key) => {
|
|
9
|
+
const descriptor = descriptors[key];
|
|
10
|
+
if (descriptor === undefined) {
|
|
11
|
+
throw new Error(`No descriptor for route "${key}"`);
|
|
12
|
+
}
|
|
13
|
+
return descriptor;
|
|
14
|
+
};
|
|
15
|
+
export { getFocusedRoute, requireDescriptor };
|
|
16
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/shared/routes.ts"],"names":[],"mappings":"AAIA,MAAM,eAAe,GAAG,CAAgC,KAAY,EAAuB,EAAE;IACzF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAExC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,0CAA0C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAa,WAAuC,EAAE,GAAW,EAAc,EAAE;IACvG,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,GAAG,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { NavigationState } from \"@react-navigation/core\";\n\ntype FocusedRoute<State extends NavigationState> = State[\"routes\"][number];\n\nconst getFocusedRoute = <State extends NavigationState>(state: State): FocusedRoute<State> => {\n const route = state.routes[state.index];\n\n if (route === undefined) {\n throw new Error(`Navigation state has no route at index ${String(state.index)}`);\n }\n\n return route;\n};\n\nconst requireDescriptor = <Descriptor>(descriptors: Record<string, Descriptor>, key: string): Descriptor => {\n const descriptor = descriptors[key];\n\n if (descriptor === undefined) {\n throw new Error(`No descriptor for route \"${key}\"`);\n }\n\n return descriptor;\n};\n\nexport { getFocusedRoute, requireDescriptor };\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
type ScenePageProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string;
|
|
5
|
+
iconName?: string;
|
|
6
|
+
badgeNumber?: number;
|
|
7
|
+
needsAttention?: boolean;
|
|
8
|
+
isLoaded: boolean;
|
|
9
|
+
render: () => ReactElement;
|
|
10
|
+
};
|
|
11
|
+
declare const ScenePage: ({ name, title, isLoaded, render, ...page }: ScenePageProps) => ReactNode;
|
|
12
|
+
export { ScenePage };
|
|
13
|
+
//# sourceMappingURL=scene-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-page.d.ts","sourceRoot":"","sources":["../../src/shared/scene-page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrD,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,YAAY,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,SAAS,GAAI,4CAA4C,cAAc,KAAG,SAW/E,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AdwBin, AdwViewStackPage } from "@gtkx/jsx/adw";
|
|
3
|
+
const ScenePage = ({ name, title, isLoaded, render, ...page }) => (_jsx(AdwViewStackPage, { name: name, title: title, iconName: page.iconName, badgeNumber: page.badgeNumber, needsAttention: page.needsAttention, useUnderline: false, children: _jsx(AdwBin, { children: isLoaded ? render() : null }) }));
|
|
4
|
+
export { ScenePage };
|
|
5
|
+
//# sourceMappingURL=scene-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-page.js","sourceRoot":"","sources":["../../src/shared/scene-page.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAYzD,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAkB,EAAa,EAAE,CAAC,CACzF,KAAC,gBAAgB,IACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,YAAY,EAAE,KAAK,YAEnB,KAAC,MAAM,cAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,GAAU,GAC9B,CACtB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { ReactElement, ReactNode } from \"react\";\nimport { AdwBin, AdwViewStackPage } from \"@gtkx/jsx/adw\";\n\ntype ScenePageProps = {\n name: string;\n title: string;\n iconName?: string;\n badgeNumber?: number;\n needsAttention?: boolean;\n isLoaded: boolean;\n render: () => ReactElement;\n};\n\nconst ScenePage = ({ name, title, isLoaded, render, ...page }: ScenePageProps): ReactNode => (\n <AdwViewStackPage\n name={name}\n title={title}\n iconName={page.iconName}\n badgeNumber={page.badgeNumber}\n needsAttention={page.needsAttention}\n useUnderline={false}\n >\n <AdwBin>{isLoaded ? render() : null}</AdwBin>\n </AdwViewStackPage>\n);\n\nexport { ScenePage };\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
/** Header options shared by every navigator. */
|
|
3
|
+
type HeaderOptions = {
|
|
4
|
+
/** Title of the screen, shown in the header bar; defaults to the route name. */
|
|
5
|
+
title?: string;
|
|
6
|
+
/** Whether to render a header bar above the screen; defaults to `true`. */
|
|
7
|
+
headerShown?: boolean;
|
|
8
|
+
/** Replaces the header bar title: a string becomes an `AdwWindowTitle`, an element is used as the title widget. */
|
|
9
|
+
headerTitle?: string | ReactElement;
|
|
10
|
+
/** Widgets packed at the start of the header bar. */
|
|
11
|
+
headerStart?: ReactNode;
|
|
12
|
+
/** Widgets packed at the end of the header bar. */
|
|
13
|
+
headerEnd?: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export type { HeaderOptions };
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,gDAAgD;AAChD,KAAK,aAAa,GAAG;IACjB,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mHAAmH;IACnH,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACpC,qDAAqD;IACrD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from \"react\";\n\n/** Header options shared by every navigator. */\ntype HeaderOptions = {\n /** Title of the screen, shown in the header bar; defaults to the route name. */\n title?: string;\n /** Whether to render a header bar above the screen; defaults to `true`. */\n headerShown?: boolean;\n /** Replaces the header bar title: a string becomes an `AdwWindowTitle`, an element is used as the title widget. */\n headerTitle?: string | ReactElement;\n /** Widgets packed at the start of the header bar. */\n headerStart?: ReactNode;\n /** Widgets packed at the end of the header bar. */\n headerEnd?: ReactNode;\n};\n\nexport type { HeaderOptions };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-loaded-routes.d.ts","sourceRoot":"","sources":["../../src/shared/use-loaded-routes.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,eAAe,GAAI,YAAY,MAAM,EAAE,eAAe,SAAS,MAAM,EAAE,KAAG,WAAW,CAAC,MAAM,CASjG,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
const useLoadedRoutes = (focusedKey, preloadedKeys) => {
|
|
3
|
+
const [loaded, setLoaded] = useState(() => new Set([focusedKey]));
|
|
4
|
+
const pending = [focusedKey, ...preloadedKeys].filter((key) => !loaded.has(key));
|
|
5
|
+
if (pending.length > 0) {
|
|
6
|
+
setLoaded(new Set([...loaded, ...pending]));
|
|
7
|
+
}
|
|
8
|
+
return loaded;
|
|
9
|
+
};
|
|
10
|
+
export { useLoadedRoutes };
|
|
11
|
+
//# sourceMappingURL=use-loaded-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-loaded-routes.js","sourceRoot":"","sources":["../../src/shared/use-loaded-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,aAAgC,EAAuB,EAAE;IAClG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAsB,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACvF,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,GAAG,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAEjF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { useState } from \"react\";\n\nconst useLoadedRoutes = (focusedKey: string, preloadedKeys: readonly string[]): ReadonlySet<string> => {\n const [loaded, setLoaded] = useState<ReadonlySet<string>>(() => new Set([focusedKey]));\n const pending = [focusedKey, ...preloadedKeys].filter((key) => !loaded.has(key));\n\n if (pending.length > 0) {\n setLoaded(new Set([...loaded, ...pending]));\n }\n\n return loaded;\n};\n\nexport { useLoadedRoutes };\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NavigationHelpers, NavigationState, ParamListBase } from "@react-navigation/core";
|
|
2
|
+
type BlurOptions = {
|
|
3
|
+
popToTopOnBlur?: boolean;
|
|
4
|
+
};
|
|
5
|
+
type BlurDescriptors = Record<string, {
|
|
6
|
+
options: BlurOptions;
|
|
7
|
+
}>;
|
|
8
|
+
declare const usePopToTopOnBlur: (state: NavigationState, descriptors: BlurDescriptors, navigation: NavigationHelpers<ParamListBase>) => void;
|
|
9
|
+
export { usePopToTopOnBlur };
|
|
10
|
+
//# sourceMappingURL=use-pop-to-top-on-blur.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pop-to-top-on-blur.d.ts","sourceRoot":"","sources":["../../src/shared/use-pop-to-top-on-blur.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIhG,KAAK,WAAW,GAAG;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAChD,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AAehE,QAAA,MAAM,iBAAiB,GACnB,OAAO,eAAe,EACtB,aAAa,eAAe,EAC5B,YAAY,iBAAiB,CAAC,aAAa,CAAC,KAC7C,IAkBF,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StackActions } from "@react-navigation/core";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
const nestedStackKey = (state, routeKey) => {
|
|
4
|
+
const nested = state.routes.find((route) => route.key === routeKey)?.state;
|
|
5
|
+
if (nested?.type === "stack" && typeof nested.key === "string") {
|
|
6
|
+
return nested.key;
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
const popToTopTarget = (state, descriptors, blurredKey) => descriptors[blurredKey]?.options.popToTopOnBlur === true ? nestedStackKey(state, blurredKey) : null;
|
|
11
|
+
const usePopToTopOnBlur = (state, descriptors, navigation) => {
|
|
12
|
+
const focusedKey = state.routes[state.index]?.key;
|
|
13
|
+
const previousKeyRef = useRef(focusedKey);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const previousKey = previousKeyRef.current;
|
|
16
|
+
previousKeyRef.current = focusedKey;
|
|
17
|
+
if (previousKey === undefined || previousKey === focusedKey) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const target = popToTopTarget(state, descriptors, previousKey);
|
|
21
|
+
if (target !== null) {
|
|
22
|
+
navigation.dispatch({ ...StackActions.popToTop(), target });
|
|
23
|
+
}
|
|
24
|
+
}, [focusedKey, descriptors, navigation, state]);
|
|
25
|
+
};
|
|
26
|
+
export { usePopToTopOnBlur };
|
|
27
|
+
//# sourceMappingURL=use-pop-to-top-on-blur.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pop-to-top-on-blur.js","sourceRoot":"","sources":["../../src/shared/use-pop-to-top-on-blur.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM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AE,GAAG,YAAY,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;IACL,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { NavigationHelpers, NavigationState, ParamListBase } from \"@react-navigation/core\";\nimport { StackActions } from \"@react-navigation/core\";\nimport { useEffect, useRef } from \"react\";\n\ntype BlurOptions = { popToTopOnBlur?: boolean };\ntype BlurDescriptors = Record<string, { options: BlurOptions }>;\n\nconst nestedStackKey = (state: NavigationState, routeKey: string): string | null => {\n const nested = state.routes.find((route) => route.key === routeKey)?.state;\n\n if (nested?.type === \"stack\" && typeof nested.key === \"string\") {\n return nested.key;\n }\n\n return null;\n};\n\nconst popToTopTarget = (state: NavigationState, descriptors: BlurDescriptors, blurredKey: string): string | null =>\n descriptors[blurredKey]?.options.popToTopOnBlur === true ? nestedStackKey(state, blurredKey) : null;\n\nconst usePopToTopOnBlur = (\n state: NavigationState,\n descriptors: BlurDescriptors,\n navigation: NavigationHelpers<ParamListBase>,\n): void => {\n const focusedKey = state.routes[state.index]?.key;\n const previousKeyRef = useRef(focusedKey);\n\n useEffect(() => {\n const previousKey = previousKeyRef.current;\n previousKeyRef.current = focusedKey;\n\n if (previousKey === undefined || previousKey === focusedKey) {\n return;\n }\n\n const target = popToTopTarget(state, descriptors, previousKey);\n\n if (target !== null) {\n navigation.dispatch({ ...StackActions.popToTop(), target });\n }\n }, [focusedKey, descriptors, navigation, state]);\n};\n\nexport { usePopToTopOnBlur };\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { NavigatorTypeBagBase, ParamListBase, StackNavigationState, StaticConfig, StaticScreenFactory, TypedNavigator } from "@react-navigation/core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { SplitViewNavigationEventMap, SplitViewNavigationOptions, SplitViewNavigationProp, SplitViewNavigatorProps } from "./types.js";
|
|
4
|
+
/** Type bag describing the split view navigator to React Navigation's typed APIs. */
|
|
5
|
+
type SplitViewTypeBag<ParamList extends ParamListBase = ParamListBase, NavigatorID extends string | undefined = string | undefined> = {
|
|
6
|
+
/** Route names and their params. */
|
|
7
|
+
ParamList: ParamList;
|
|
8
|
+
/** Optional navigator id. */
|
|
9
|
+
NavigatorID: NavigatorID;
|
|
10
|
+
/** Shape of the navigator state. */
|
|
11
|
+
State: StackNavigationState<ParamList>;
|
|
12
|
+
/** Per-screen options. */
|
|
13
|
+
ScreenOptions: SplitViewNavigationOptions;
|
|
14
|
+
/** Events the navigator emits. */
|
|
15
|
+
EventMap: SplitViewNavigationEventMap;
|
|
16
|
+
/** Navigation object per route. */
|
|
17
|
+
NavigationList: {
|
|
18
|
+
[RouteName in keyof ParamList]: SplitViewNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
19
|
+
};
|
|
20
|
+
/** The navigator component. */
|
|
21
|
+
Navigator: typeof SplitViewNavigator;
|
|
22
|
+
};
|
|
23
|
+
/** Declares a typed screen of a split view navigator for the static configuration API. */
|
|
24
|
+
declare const createSplitViewScreen: StaticScreenFactory<SplitViewTypeBag>;
|
|
25
|
+
/** Renders the screens of a {@link createSplitViewNavigator} in an `AdwNavigationSplitView`. */
|
|
26
|
+
declare function SplitViewNavigator({ collapsed, contentPlaceholder, sidebarPosition, minSidebarWidth, maxSidebarWidth, sidebarWidthFraction, popOnEscape, ...options }: SplitViewNavigatorProps): ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar
|
|
29
|
+
* pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.
|
|
30
|
+
*/
|
|
31
|
+
declare function createSplitViewNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = SplitViewTypeBag<ParamList, NavigatorID>, const Config extends StaticConfig<TypeBag> | undefined = undefined>(config?: Config): TypedNavigator<TypeBag, Config>;
|
|
32
|
+
export { createSplitViewNavigator, createSplitViewScreen, SplitViewNavigator, type SplitViewTypeBag };
|
|
33
|
+
//# sourceMappingURL=create-split-view-navigator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-split-view-navigator.d.ts","sourceRoot":"","sources":["../../src/split-view/create-split-view-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EAEb,oBAAoB,EAEpB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACR,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EAC1B,MAAM,YAAY,CAAC;AAIpB,qFAAqF;AACrF,KAAK,gBAAgB,CACjB,SAAS,SAAS,aAAa,GAAG,aAAa,EAC/C,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3D;IACA,oCAAoC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,6BAA6B;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,oCAAoC;IACpC,KAAK,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACvC,0BAA0B;IAC1B,aAAa,EAAE,0BAA0B,CAAC;IAC1C,kCAAkC;IAClC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,mCAAmC;IACnC,cAAc,EAAE;SACX,SAAS,IAAI,MAAM,SAAS,GAAG,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;KAC7F,CAAC;IACF,+BAA+B;IAC/B,SAAS,EAAE,OAAO,kBAAkB,CAAC;CACxC,CAAC;AAEF,0FAA0F;AAC1F,QAAA,MAAM,qBAAqB,EAAE,mBAAmB,CAAC,gBAAgB,CAA2C,CAAC;AAE7G,gGAAgG;AAChG,iBAAS,kBAAkB,CAAC,EACxB,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,GAAG,OAAO,EACb,EAAE,uBAAuB,GAAG,SAAS,CA0BrC;AAED;;;GAGG;AACH,iBAAS,wBAAwB,CAC7B,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,EACrF,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,SAAS,EACpE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAElD;AAED,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createNavigatorFactory, createScreenFactory, useNavigationBuilder } from "@react-navigation/core";
|
|
3
|
+
import { splitViewRouter } from "./split-view-router.js";
|
|
4
|
+
import { SplitView } from "./split-view.js";
|
|
5
|
+
/** Declares a typed screen of a split view navigator for the static configuration API. */
|
|
6
|
+
const createSplitViewScreen = createScreenFactory();
|
|
7
|
+
/** Renders the screens of a {@link createSplitViewNavigator} in an `AdwNavigationSplitView`. */
|
|
8
|
+
function SplitViewNavigator({ collapsed, contentPlaceholder, sidebarPosition, minSidebarWidth, maxSidebarWidth, sidebarWidthFraction, popOnEscape, ...options }) {
|
|
9
|
+
const { state, describe, descriptors, navigation, NavigationContent } = useNavigationBuilder(splitViewRouter, options);
|
|
10
|
+
return (_jsx(NavigationContent, { children: _jsx(SplitView, { state: state, navigation: navigation, descriptors: descriptors, describe: describe, collapsed: collapsed, contentPlaceholder: contentPlaceholder, sidebarPosition: sidebarPosition, minSidebarWidth: minSidebarWidth, maxSidebarWidth: maxSidebarWidth, sidebarWidthFraction: sidebarWidthFraction, popOnEscape: popOnEscape }) }));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar
|
|
14
|
+
* pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.
|
|
15
|
+
*/
|
|
16
|
+
function createSplitViewNavigator(config) {
|
|
17
|
+
return createNavigatorFactory(SplitViewNavigator)(config);
|
|
18
|
+
}
|
|
19
|
+
export { createSplitViewNavigator, createSplitViewScreen, SplitViewNavigator };
|
|
20
|
+
//# sourceMappingURL=create-split-view-navigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-split-view-navigator.js","sourceRoot":"","sources":["../../src/split-view/create-split-view-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO3G,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAyB5C,0FAA0F;AAC1F,MAAM,qBAAqB,GAA0C,mBAAmB,EAAoB,CAAC;AAE7G,gGAAgG;AAChG,SAAS,kBAAkB,CAAC,EACxB,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,GAAG,OAAO,EACY;IACtB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,oBAAoB,CAM1F,eAAe,EAAE,OAAO,CAAC,CAAC;IAE5B,OAAO,CACH,KAAC,iBAAiB,cACd,KAAC,SAAS,IACN,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,GAC1B,GACc,CACvB,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAS,wBAAwB,CAK/B,MAAe;IACb,OAAO,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAoC,CAAC;AACjG,CAAC;AAED,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,kBAAkB,EAAyB,CAAC","sourcesContent":["import type {\n NavigatorTypeBagBase,\n ParamListBase,\n StackActionHelpers,\n StackNavigationState,\n StackRouterOptions,\n StaticConfig,\n StaticScreenFactory,\n TypedNavigator,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport { createNavigatorFactory, createScreenFactory, useNavigationBuilder } from \"@react-navigation/core\";\nimport type {\n SplitViewNavigationEventMap,\n SplitViewNavigationOptions,\n SplitViewNavigationProp,\n SplitViewNavigatorProps,\n} from \"./types.js\";\nimport { splitViewRouter } from \"./split-view-router.js\";\nimport { SplitView } from \"./split-view.js\";\n\n/** Type bag describing the split view navigator to React Navigation's typed APIs. */\ntype SplitViewTypeBag<\n ParamList extends ParamListBase = ParamListBase,\n NavigatorID extends string | undefined = string | undefined,\n> = {\n /** Route names and their params. */\n ParamList: ParamList;\n /** Optional navigator id. */\n NavigatorID: NavigatorID;\n /** Shape of the navigator state. */\n State: StackNavigationState<ParamList>;\n /** Per-screen options. */\n ScreenOptions: SplitViewNavigationOptions;\n /** Events the navigator emits. */\n EventMap: SplitViewNavigationEventMap;\n /** Navigation object per route. */\n NavigationList: {\n [RouteName in keyof ParamList]: SplitViewNavigationProp<ParamList, RouteName, NavigatorID>;\n };\n /** The navigator component. */\n Navigator: typeof SplitViewNavigator;\n};\n\n/** Declares a typed screen of a split view navigator for the static configuration API. */\nconst createSplitViewScreen: StaticScreenFactory<SplitViewTypeBag> = createScreenFactory<SplitViewTypeBag>();\n\n/** Renders the screens of a {@link createSplitViewNavigator} in an `AdwNavigationSplitView`. */\nfunction SplitViewNavigator({\n collapsed,\n contentPlaceholder,\n sidebarPosition,\n minSidebarWidth,\n maxSidebarWidth,\n sidebarWidthFraction,\n popOnEscape,\n ...options\n}: SplitViewNavigatorProps): ReactNode {\n const { state, describe, descriptors, navigation, NavigationContent } = useNavigationBuilder<\n StackNavigationState<ParamListBase>,\n StackRouterOptions,\n StackActionHelpers<ParamListBase>,\n SplitViewNavigationOptions,\n SplitViewNavigationEventMap\n >(splitViewRouter, options);\n\n return (\n <NavigationContent>\n <SplitView\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n collapsed={collapsed}\n contentPlaceholder={contentPlaceholder}\n sidebarPosition={sidebarPosition}\n minSidebarWidth={minSidebarWidth}\n maxSidebarWidth={maxSidebarWidth}\n sidebarWidthFraction={sidebarWidthFraction}\n popOnEscape={popOnEscape}\n />\n </NavigationContent>\n );\n}\n\n/**\n * Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar\n * pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.\n */\nfunction createSplitViewNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = SplitViewTypeBag<ParamList, NavigatorID>,\n const Config extends StaticConfig<TypeBag> | undefined = undefined,\n>(config?: Config): TypedNavigator<TypeBag, Config> {\n return createNavigatorFactory(SplitViewNavigator)(config) as TypedNavigator<TypeBag, Config>;\n}\n\nexport { createSplitViewNavigator, createSplitViewScreen, SplitViewNavigator, type SplitViewTypeBag };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-view-router.d.ts","sourceRoot":"","sources":["../../src/split-view/split-view-router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAIxD,KAAK,kBAAkB,GAAG,OAAO,WAAW,CAAC;AAgE7C,QAAA,MAAM,eAAe,EAAE,kBACqD,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StackRouter } from "@react-navigation/routers";
|
|
2
|
+
const sidebarName = (config) => config.routeNames[0];
|
|
3
|
+
const buildSidebarRoute = (slot, config, name) => {
|
|
4
|
+
slot.serial += 1;
|
|
5
|
+
return { key: `${name}-sidebar-${String(slot.serial)}`, name, params: config.routeParamList[name] };
|
|
6
|
+
};
|
|
7
|
+
const resolveSidebarRoute = (slot, state, config) => {
|
|
8
|
+
const name = sidebarName(config) ?? "";
|
|
9
|
+
const existing = state.routes.find((route) => route.name === name);
|
|
10
|
+
const cached = slot.route?.name === name ? slot.route : undefined;
|
|
11
|
+
return existing ?? cached ?? buildSidebarRoute(slot, config, name);
|
|
12
|
+
};
|
|
13
|
+
const pinSidebar = (slot, state, config) => {
|
|
14
|
+
const name = sidebarName(config);
|
|
15
|
+
if (name === undefined || state.routes[0]?.name === name) {
|
|
16
|
+
slot.route = state.routes[0];
|
|
17
|
+
return state;
|
|
18
|
+
}
|
|
19
|
+
const sidebar = resolveSidebarRoute(slot, state, config);
|
|
20
|
+
const routes = [sidebar, ...state.routes.filter((route) => route.name !== name)];
|
|
21
|
+
const focusedKey = state.routes[state.index]?.key;
|
|
22
|
+
const index = routes.findIndex((route) => route.key === focusedKey);
|
|
23
|
+
slot.route = sidebar;
|
|
24
|
+
return { ...state, routes, index: index === -1 ? routes.length - 1 : index };
|
|
25
|
+
};
|
|
26
|
+
const asSelection = (action) => {
|
|
27
|
+
if (action.type !== "NAVIGATE" || action.payload.pop !== undefined) {
|
|
28
|
+
return action;
|
|
29
|
+
}
|
|
30
|
+
return { ...action, payload: { ...action.payload, pop: true } };
|
|
31
|
+
};
|
|
32
|
+
const pinActionResult = (slot, result, config) => result?.stale === false ? pinSidebar(slot, result, config) : result;
|
|
33
|
+
const withPinnedSidebar = (router, slot) => ({
|
|
34
|
+
...router,
|
|
35
|
+
getInitialState: (config) => pinSidebar(slot, router.getInitialState(config), config),
|
|
36
|
+
getRehydratedState: (state, config) => pinSidebar(slot, router.getRehydratedState(state, config), config),
|
|
37
|
+
getStateForRouteNamesChange: (state, config) => pinSidebar(slot, router.getStateForRouteNamesChange(state, config), config),
|
|
38
|
+
getStateForAction: (state, action, config) => pinActionResult(slot, router.getStateForAction(state, asSelection(action), config), config),
|
|
39
|
+
});
|
|
40
|
+
const splitViewRouter = (options) => withPinnedSidebar(StackRouter(options), { route: undefined, serial: 0 });
|
|
41
|
+
export { splitViewRouter };
|
|
42
|
+
//# sourceMappingURL=split-view-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-view-router.js","sourceRoot":"","sources":["../../src/split-view/split-view-router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AASxD,MAAM,WAAW,GAAG,CAAC,MAA2B,EAAsB,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAE9F,MAAM,iBAAiB,GAAG,CAAC,IAAiB,EAAE,MAA2B,EAAE,IAAY,EAAc,EAAE;IACnG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IAEjB,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,YAAY,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;AACxG,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAiB,EAAE,KAAiB,EAAE,MAA2B,EAAc,EAAE;IAC1G,MAAM,IAAI,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AC,2BAA2B,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAC/E,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CACzC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;CAClG,CAAC,CAAC;AAEH,MAAM,eAAe,GAAuB,CAAC,OAAO,EAAE,EAAE,CACpD,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { ParamListBase, RouterConfigOptions, StackNavigationState } from \"@react-navigation/core\";\nimport { StackRouter } from \"@react-navigation/routers\";\n\ntype StackState = StackNavigationState<ParamListBase>;\ntype StackRoute = StackState[\"routes\"][number];\ntype StackRouterFactory = typeof StackRouter;\ntype StackRouterInstance = ReturnType<StackRouterFactory>;\ntype SidebarSlot = { route: StackRoute | undefined; serial: number };\ntype RouterAction = Parameters<StackRouterInstance[\"getStateForAction\"]>[1];\n\nconst sidebarName = (config: RouterConfigOptions): string | undefined => config.routeNames[0];\n\nconst buildSidebarRoute = (slot: SidebarSlot, config: RouterConfigOptions, name: string): StackRoute => {\n slot.serial += 1;\n\n return { key: `${name}-sidebar-${String(slot.serial)}`, name, params: config.routeParamList[name] };\n};\n\nconst resolveSidebarRoute = (slot: SidebarSlot, state: StackState, config: RouterConfigOptions): StackRoute => {\n const name = sidebarName(config) ?? \"\";\n const existing = state.routes.find((route) => route.name === name);\n const cached = slot.route?.name === name ? slot.route : undefined;\n\n return existing ?? cached ?? buildSidebarRoute(slot, config, name);\n};\n\nconst pinSidebar = (slot: SidebarSlot, state: StackState, config: RouterConfigOptions): StackState => {\n const name = sidebarName(config);\n\n if (name === undefined || state.routes[0]?.name === name) {\n slot.route = state.routes[0];\n\n return state;\n }\n\n const sidebar = resolveSidebarRoute(slot, state, config);\n const routes = [sidebar, ...state.routes.filter((route) => route.name !== name)];\n const focusedKey = state.routes[state.index]?.key;\n const index = routes.findIndex((route) => route.key === focusedKey);\n slot.route = sidebar;\n\n return { ...state, routes, index: index === -1 ? routes.length - 1 : index };\n};\n\nconst asSelection = (action: RouterAction): RouterAction => {\n if (action.type !== \"NAVIGATE\" || action.payload.pop !== undefined) {\n return action;\n }\n\n return { ...action, payload: { ...action.payload, pop: true } };\n};\n\nconst pinActionResult = (\n slot: SidebarSlot,\n result: ReturnType<StackRouterInstance[\"getStateForAction\"]>,\n config: RouterConfigOptions,\n): ReturnType<StackRouterInstance[\"getStateForAction\"]> =>\n result?.stale === false ? pinSidebar(slot, result, config) : result;\n\nconst withPinnedSidebar = (router: StackRouterInstance, slot: SidebarSlot): StackRouterInstance => ({\n ...router,\n getInitialState: (config) => pinSidebar(slot, router.getInitialState(config), config),\n getRehydratedState: (state, config) => pinSidebar(slot, router.getRehydratedState(state, config), config),\n getStateForRouteNamesChange: (state, config) =>\n pinSidebar(slot, router.getStateForRouteNamesChange(state, config), config),\n getStateForAction: (state, action, config) =>\n pinActionResult(slot, router.getStateForAction(state, asSelection(action), config), config),\n});\n\nconst splitViewRouter: StackRouterFactory = (options) =>\n withPinnedSidebar(StackRouter(options), { route: undefined, serial: 0 });\n\nexport { splitViewRouter };\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ParamListBase, RouteProp, StackNavigationState } from "@react-navigation/core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { SplitViewDescriptor, SplitViewDescriptorMap, SplitViewNavigationConfig, SplitViewNavigationHelpers } from "./types.js";
|
|
4
|
+
type SplitViewProps = SplitViewNavigationConfig & {
|
|
5
|
+
state: StackNavigationState<ParamListBase>;
|
|
6
|
+
navigation: SplitViewNavigationHelpers;
|
|
7
|
+
descriptors: SplitViewDescriptorMap;
|
|
8
|
+
describe: (route: RouteProp<ParamListBase>, isPlaceholder: boolean) => SplitViewDescriptor;
|
|
9
|
+
};
|
|
10
|
+
declare const SplitView: (props: SplitViewProps) => ReactNode;
|
|
11
|
+
export { SplitView };
|
|
12
|
+
//# sourceMappingURL=split-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-view.d.ts","sourceRoot":"","sources":["../../src/split-view/split-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EACR,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC7B,MAAM,YAAY,CAAC;AAOpB,KAAK,cAAc,GAAG,yBAAyB,GAAG;IAC9C,KAAK,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC3C,UAAU,EAAE,0BAA0B,CAAC;IACvC,WAAW,EAAE,sBAAsB,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,EAAE,aAAa,EAAE,OAAO,KAAK,mBAAmB,CAAC;CAC9F,CAAC;AAsEF,QAAA,MAAM,SAAS,GAAI,OAAO,cAAc,KAAG,SAsC1C,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|