@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.
Files changed (147) hide show
  1. package/README.md +174 -0
  2. package/dist/drawer/create-drawer-navigator.d.ts +30 -0
  3. package/dist/drawer/create-drawer-navigator.d.ts.map +1 -0
  4. package/dist/drawer/create-drawer-navigator.js +36 -0
  5. package/dist/drawer/create-drawer-navigator.js.map +1 -0
  6. package/dist/drawer/drawer-collapsed-context.d.ts +4 -0
  7. package/dist/drawer/drawer-collapsed-context.d.ts.map +1 -0
  8. package/dist/drawer/drawer-collapsed-context.js +4 -0
  9. package/dist/drawer/drawer-collapsed-context.js.map +1 -0
  10. package/dist/drawer/drawer-item-list.d.ts +6 -0
  11. package/dist/drawer/drawer-item-list.d.ts.map +1 -0
  12. package/dist/drawer/drawer-item-list.js +40 -0
  13. package/dist/drawer/drawer-item-list.js.map +1 -0
  14. package/dist/drawer/drawer-router.d.ts +5 -0
  15. package/dist/drawer/drawer-router.d.ts.map +1 -0
  16. package/dist/drawer/drawer-router.js +49 -0
  17. package/dist/drawer/drawer-router.js.map +1 -0
  18. package/dist/drawer/drawer-status.d.ts +4 -0
  19. package/dist/drawer/drawer-status.d.ts.map +1 -0
  20. package/dist/drawer/drawer-status.js +11 -0
  21. package/dist/drawer/drawer-status.js.map +1 -0
  22. package/dist/drawer/drawer-view.d.ts +11 -0
  23. package/dist/drawer/drawer-view.d.ts.map +1 -0
  24. package/dist/drawer/drawer-view.js +67 -0
  25. package/dist/drawer/drawer-view.js.map +1 -0
  26. package/dist/drawer/types.d.ts +80 -0
  27. package/dist/drawer/types.d.ts.map +1 -0
  28. package/dist/drawer/types.js +2 -0
  29. package/dist/drawer/types.js.map +1 -0
  30. package/dist/index.d.ts +15 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +10 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/navigation-container.d.ts +15 -0
  35. package/dist/navigation-container.d.ts.map +1 -0
  36. package/dist/navigation-container.js +11 -0
  37. package/dist/navigation-container.js.map +1 -0
  38. package/dist/shared/header-bar.d.ts +11 -0
  39. package/dist/shared/header-bar.d.ts.map +1 -0
  40. package/dist/shared/header-bar.js +11 -0
  41. package/dist/shared/header-bar.js.map +1 -0
  42. package/dist/shared/routes.d.ts +6 -0
  43. package/dist/shared/routes.d.ts.map +1 -0
  44. package/dist/shared/routes.js +16 -0
  45. package/dist/shared/routes.js.map +1 -0
  46. package/dist/shared/scene-page.d.ts +13 -0
  47. package/dist/shared/scene-page.d.ts.map +1 -0
  48. package/dist/shared/scene-page.js +5 -0
  49. package/dist/shared/scene-page.js.map +1 -0
  50. package/dist/shared/types.d.ts +16 -0
  51. package/dist/shared/types.d.ts.map +1 -0
  52. package/dist/shared/types.js +2 -0
  53. package/dist/shared/types.js.map +1 -0
  54. package/dist/shared/use-loaded-routes.d.ts +3 -0
  55. package/dist/shared/use-loaded-routes.d.ts.map +1 -0
  56. package/dist/shared/use-loaded-routes.js +11 -0
  57. package/dist/shared/use-loaded-routes.js.map +1 -0
  58. package/dist/shared/use-pop-to-top-on-blur.d.ts +10 -0
  59. package/dist/shared/use-pop-to-top-on-blur.d.ts.map +1 -0
  60. package/dist/shared/use-pop-to-top-on-blur.js +27 -0
  61. package/dist/shared/use-pop-to-top-on-blur.js.map +1 -0
  62. package/dist/split-view/create-split-view-navigator.d.ts +33 -0
  63. package/dist/split-view/create-split-view-navigator.d.ts.map +1 -0
  64. package/dist/split-view/create-split-view-navigator.js +20 -0
  65. package/dist/split-view/create-split-view-navigator.js.map +1 -0
  66. package/dist/split-view/split-view-router.d.ts +5 -0
  67. package/dist/split-view/split-view-router.d.ts.map +1 -0
  68. package/dist/split-view/split-view-router.js +42 -0
  69. package/dist/split-view/split-view-router.js.map +1 -0
  70. package/dist/split-view/split-view.d.ts +12 -0
  71. package/dist/split-view/split-view.d.ts.map +1 -0
  72. package/dist/split-view/split-view.js +62 -0
  73. package/dist/split-view/split-view.js.map +1 -0
  74. package/dist/split-view/types.d.ts +43 -0
  75. package/dist/split-view/types.d.ts.map +1 -0
  76. package/dist/split-view/types.js +2 -0
  77. package/dist/split-view/types.js.map +1 -0
  78. package/dist/stack/create-stack-navigator.d.ts +30 -0
  79. package/dist/stack/create-stack-navigator.d.ts.map +1 -0
  80. package/dist/stack/create-stack-navigator.js +16 -0
  81. package/dist/stack/create-stack-navigator.js.map +1 -0
  82. package/dist/stack/stack-pages.d.ts +11 -0
  83. package/dist/stack/stack-pages.d.ts.map +1 -0
  84. package/dist/stack/stack-pages.js +80 -0
  85. package/dist/stack/stack-pages.js.map +1 -0
  86. package/dist/stack/stack-view.d.ts +14 -0
  87. package/dist/stack/stack-view.d.ts.map +1 -0
  88. package/dist/stack/stack-view.js +101 -0
  89. package/dist/stack/stack-view.js.map +1 -0
  90. package/dist/stack/sync-navigation-stack.d.ts +7 -0
  91. package/dist/stack/sync-navigation-stack.d.ts.map +1 -0
  92. package/dist/stack/sync-navigation-stack.js +69 -0
  93. package/dist/stack/sync-navigation-stack.js.map +1 -0
  94. package/dist/stack/types.d.ts +72 -0
  95. package/dist/stack/types.d.ts.map +1 -0
  96. package/dist/stack/types.js +2 -0
  97. package/dist/stack/types.js.map +1 -0
  98. package/dist/static-navigation.d.ts +13 -0
  99. package/dist/static-navigation.d.ts.map +1 -0
  100. package/dist/static-navigation.js +10 -0
  101. package/dist/static-navigation.js.map +1 -0
  102. package/dist/tabs/create-tab-navigator.d.ts +30 -0
  103. package/dist/tabs/create-tab-navigator.d.ts.map +1 -0
  104. package/dist/tabs/create-tab-navigator.js +16 -0
  105. package/dist/tabs/create-tab-navigator.js.map +1 -0
  106. package/dist/tabs/tab-view.d.ts +11 -0
  107. package/dist/tabs/tab-view.d.ts.map +1 -0
  108. package/dist/tabs/tab-view.js +52 -0
  109. package/dist/tabs/tab-view.js.map +1 -0
  110. package/dist/tabs/types.d.ts +67 -0
  111. package/dist/tabs/types.d.ts.map +1 -0
  112. package/dist/tabs/types.js +2 -0
  113. package/dist/tabs/types.js.map +1 -0
  114. package/dist/theme.d.ts +18 -0
  115. package/dist/theme.d.ts.map +1 -0
  116. package/dist/theme.js +15 -0
  117. package/dist/theme.js.map +1 -0
  118. package/package.json +71 -0
  119. package/src/drawer/create-drawer-navigator.tsx +123 -0
  120. package/src/drawer/drawer-collapsed-context.ts +5 -0
  121. package/src/drawer/drawer-item-list.tsx +74 -0
  122. package/src/drawer/drawer-router.ts +90 -0
  123. package/src/drawer/drawer-status.ts +19 -0
  124. package/src/drawer/drawer-view.tsx +171 -0
  125. package/src/drawer/types.ts +142 -0
  126. package/src/index.ts +83 -0
  127. package/src/navigation-container.tsx +35 -0
  128. package/src/shared/header-bar.tsx +34 -0
  129. package/src/shared/routes.ts +25 -0
  130. package/src/shared/scene-page.tsx +27 -0
  131. package/src/shared/types.ts +17 -0
  132. package/src/shared/use-loaded-routes.ts +14 -0
  133. package/src/shared/use-pop-to-top-on-blur.ts +45 -0
  134. package/src/split-view/create-split-view-navigator.tsx +99 -0
  135. package/src/split-view/split-view-router.ts +73 -0
  136. package/src/split-view/split-view.tsx +137 -0
  137. package/src/split-view/types.ts +100 -0
  138. package/src/stack/create-stack-navigator.tsx +80 -0
  139. package/src/stack/stack-pages.ts +140 -0
  140. package/src/stack/stack-view.tsx +202 -0
  141. package/src/stack/sync-navigation-stack.ts +117 -0
  142. package/src/stack/types.ts +131 -0
  143. package/src/static-navigation.tsx +26 -0
  144. package/src/tabs/create-tab-navigator.tsx +69 -0
  145. package/src/tabs/tab-view.tsx +126 -0
  146. package/src/tabs/types.ts +120 -0
  147. package/src/theme.ts +31 -0
@@ -0,0 +1,72 @@
1
+ import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, ParamListBase, RouteProp, StackActionHelpers, StackNavigationState, StackRouterOptions } from "@react-navigation/core";
2
+ import type { ReactNode } from "react";
3
+ import type { HeaderOptions } from "../shared/types.js";
4
+ /** Data carried by the `transitionStart` and `transitionEnd` events. */
5
+ type StackTransitionData = {
6
+ /** Whether the page is hiding (`true`) or showing (`false`). */
7
+ closing: boolean;
8
+ };
9
+ /** Events the stack navigator emits on top of React Navigation's core events. */
10
+ type StackNavigationEventMap = {
11
+ /** A page starts showing or hiding. */
12
+ transitionStart: {
13
+ /** Which direction the page moves in. */
14
+ data: StackTransitionData;
15
+ };
16
+ /** A page finished showing or hiding. */
17
+ transitionEnd: {
18
+ /** Which direction the page moved in. */
19
+ data: StackTransitionData;
20
+ };
21
+ };
22
+ /** The page below the current one, as handed to a custom `header`. */
23
+ type StackHeaderBack = {
24
+ /** Title of the page below. */
25
+ title: string;
26
+ };
27
+ /** Per-screen options of the stack navigator. */
28
+ type StackNavigationOptions = HeaderOptions & {
29
+ /** Renders a custom top bar instead of the default `AdwHeaderBar`. */
30
+ header?: (props: StackHeaderProps) => ReactNode;
31
+ /** Whether the default header bar shows Adwaita's back button; defaults to `true`. */
32
+ headerBackVisible?: boolean;
33
+ /** Whether the user can pop this page with the back button, Escape, Alt+Left or a swipe; defaults to `true`. */
34
+ canPop?: boolean;
35
+ /** Whether pushing and popping this page animates; defaults to `"default"`. */
36
+ animation?: "default" | "none";
37
+ };
38
+ /** Props of the stack navigator beyond the options every navigator shares. */
39
+ type StackNavigationConfig = {
40
+ /** Whether pressing Escape pops the visible page; defaults to `true`. */
41
+ popOnEscape?: boolean;
42
+ };
43
+ /** Navigation object of a stack screen. */
44
+ type StackNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, StackNavigationState<ParamList>, StackNavigationOptions, StackNavigationEventMap> & StackActionHelpers<ParamList>;
45
+ /** Props a stack screen component receives. */
46
+ type StackScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = {
47
+ /** Navigation object of the screen. */
48
+ navigation: StackNavigationProp<ParamList, RouteName, NavigatorID>;
49
+ /** The route the screen renders. */
50
+ route: RouteProp<ParamList, RouteName>;
51
+ };
52
+ /** Arguments of a custom stack `header` renderer. */
53
+ type StackHeaderProps = {
54
+ /** The route whose header is rendered. */
55
+ route: RouteProp<ParamListBase>;
56
+ /** Navigation object of that route. */
57
+ navigation: StackNavigationProp<ParamListBase>;
58
+ /** Resolved options of that route. */
59
+ options: StackNavigationOptions;
60
+ /** The page below this one in the stack, if any. */
61
+ back?: StackHeaderBack;
62
+ };
63
+ /** Navigation helpers of the stack navigator itself. */
64
+ type StackNavigationHelpers = NavigationHelpers<ParamListBase, StackNavigationEventMap> & StackActionHelpers<ParamListBase>;
65
+ /** Descriptor of one stack route. */
66
+ type StackDescriptor = Descriptor<StackNavigationOptions, StackNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
67
+ /** Descriptors of the stack routes, keyed by route key. */
68
+ type StackDescriptorMap = Record<string, StackDescriptor>;
69
+ /** Props of the stack `Navigator` component. */
70
+ type StackNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, StackNavigationState<ParamListBase>, StackNavigationOptions, StackNavigationEventMap, StackNavigationProp<ParamListBase>> & StackRouterOptions & StackNavigationConfig;
71
+ export type { StackDescriptor, StackDescriptorMap, StackHeaderBack, StackHeaderProps, StackNavigationConfig, StackNavigationEventMap, StackNavigationHelpers, StackNavigationOptions, StackNavigationProp, StackNavigatorProps, StackScreenProps, StackTransitionData, };
72
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/stack/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa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,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/stack/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DefaultNavigatorOptions,\n Descriptor,\n NavigationHelpers,\n NavigationProp,\n ParamListBase,\n RouteProp,\n StackActionHelpers,\n StackNavigationState,\n StackRouterOptions,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport type { HeaderOptions } from \"../shared/types.js\";\n\n/** Data carried by the `transitionStart` and `transitionEnd` events. */\ntype StackTransitionData = {\n /** Whether the page is hiding (`true`) or showing (`false`). */\n closing: boolean;\n};\n\n/** Events the stack navigator emits on top of React Navigation's core events. */\ntype StackNavigationEventMap = {\n /** A page starts showing or hiding. */\n transitionStart: {\n /** Which direction the page moves in. */\n data: StackTransitionData;\n };\n /** A page finished showing or hiding. */\n transitionEnd: {\n /** Which direction the page moved in. */\n data: StackTransitionData;\n };\n};\n\n/** The page below the current one, as handed to a custom `header`. */\ntype StackHeaderBack = {\n /** Title of the page below. */\n title: string;\n};\n\n/** Per-screen options of the stack navigator. */\ntype StackNavigationOptions = HeaderOptions & {\n /** Renders a custom top bar instead of the default `AdwHeaderBar`. */\n header?: (props: StackHeaderProps) => ReactNode;\n /** Whether the default header bar shows Adwaita's back button; defaults to `true`. */\n headerBackVisible?: boolean;\n /** Whether the user can pop this page with the back button, Escape, Alt+Left or a swipe; defaults to `true`. */\n canPop?: boolean;\n /** Whether pushing and popping this page animates; defaults to `\"default\"`. */\n animation?: \"default\" | \"none\";\n};\n\n/** Props of the stack navigator beyond the options every navigator shares. */\ntype StackNavigationConfig = {\n /** Whether pressing Escape pops the visible page; defaults to `true`. */\n popOnEscape?: boolean;\n};\n\n/** Navigation object of a stack screen. */\ntype StackNavigationProp<\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 StackNavigationState<ParamList>,\n StackNavigationOptions,\n StackNavigationEventMap\n> & StackActionHelpers<ParamList>;\n\n/** Props a stack screen component receives. */\ntype StackScreenProps<\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: StackNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Arguments of a custom stack `header` renderer. */\ntype StackHeaderProps = {\n /** The route whose header is rendered. */\n route: RouteProp<ParamListBase>;\n /** Navigation object of that route. */\n navigation: StackNavigationProp<ParamListBase>;\n /** Resolved options of that route. */\n options: StackNavigationOptions;\n /** The page below this one in the stack, if any. */\n back?: StackHeaderBack;\n};\n\n/** Navigation helpers of the stack navigator itself. */\ntype StackNavigationHelpers = NavigationHelpers<ParamListBase, StackNavigationEventMap> &\n StackActionHelpers<ParamListBase>;\n\n/** Descriptor of one stack route. */\ntype StackDescriptor = Descriptor<StackNavigationOptions, StackNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;\n/** Descriptors of the stack routes, keyed by route key. */\ntype StackDescriptorMap = Record<string, StackDescriptor>;\n\n/** Props of the stack `Navigator` component. */\ntype StackNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n StackNavigationState<ParamListBase>,\n StackNavigationOptions,\n StackNavigationEventMap,\n StackNavigationProp<ParamListBase>\n> &\nStackRouterOptions &\nStackNavigationConfig;\n\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};\n"]}
@@ -0,0 +1,13 @@
1
+ import type { ComponentType } from "react";
2
+ import { type NavigationContainerProps } from "./navigation-container.js";
3
+ /** Props of the component returned by {@link createStaticNavigation}. */
4
+ type StaticNavigationProps = Omit<NavigationContainerProps, "children">;
5
+ /** The part of a static navigator config {@link createStaticNavigation} consumes. */
6
+ type StaticNavigationTree = {
7
+ /** Returns the component rendering the configured navigator. */
8
+ getComponent: () => ComponentType;
9
+ };
10
+ /** Turns a static navigator config into a root component: a {@link NavigationContainer} around the tree. */
11
+ declare function createStaticNavigation(tree: StaticNavigationTree): ComponentType<StaticNavigationProps>;
12
+ export { createStaticNavigation, type StaticNavigationProps, type StaticNavigationTree };
13
+ //# sourceMappingURL=static-navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-navigation.d.ts","sourceRoot":"","sources":["../src/static-navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AACtD,OAAO,EAAuB,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE/F,yEAAyE;AACzE,KAAK,qBAAqB,GAAG,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;AAExE,qFAAqF;AACrF,KAAK,oBAAoB,GAAG;IACxB,gEAAgE;IAChE,YAAY,EAAE,MAAM,aAAa,CAAC;CACrC,CAAC;AAEF,4GAA4G;AAC5G,iBAAS,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAUhG;AAED,OAAO,EAAE,sBAAsB,EAAE,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { NavigationContainer } from "./navigation-container.js";
3
+ /** Turns a static navigator config into a root component: a {@link NavigationContainer} around the tree. */
4
+ function createStaticNavigation(tree) {
5
+ const Tree = tree.getComponent();
6
+ const StaticNavigation = (props) => (_jsx(NavigationContainer, { ...props, children: _jsx(Tree, {}) }));
7
+ return StaticNavigation;
8
+ }
9
+ export { createStaticNavigation };
10
+ //# sourceMappingURL=static-navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-navigation.js","sourceRoot":"","sources":["../src/static-navigation.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAiC,MAAM,2BAA2B,CAAC;AAW/F,4GAA4G;AAC5G,SAAS,sBAAsB,CAAC,IAA0B;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAEjC,MAAM,gBAAgB,GAAG,CAAC,KAA4B,EAAa,EAAE,CAAC,CAClE,KAAC,mBAAmB,OAAK,KAAK,YAC1B,KAAC,IAAI,KAAG,GACU,CACzB,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC5B,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAyD,CAAC","sourcesContent":["import type { ComponentType, ReactNode } from \"react\";\nimport { NavigationContainer, type NavigationContainerProps } from \"./navigation-container.js\";\n\n/** Props of the component returned by {@link createStaticNavigation}. */\ntype StaticNavigationProps = Omit<NavigationContainerProps, \"children\">;\n\n/** The part of a static navigator config {@link createStaticNavigation} consumes. */\ntype StaticNavigationTree = {\n /** Returns the component rendering the configured navigator. */\n getComponent: () => ComponentType;\n};\n\n/** Turns a static navigator config into a root component: a {@link NavigationContainer} around the tree. */\nfunction createStaticNavigation(tree: StaticNavigationTree): ComponentType<StaticNavigationProps> {\n const Tree = tree.getComponent();\n\n const StaticNavigation = (props: StaticNavigationProps): ReactNode => (\n <NavigationContainer {...props}>\n <Tree />\n </NavigationContainer>\n );\n\n return StaticNavigation;\n}\n\nexport { createStaticNavigation, type StaticNavigationProps, type StaticNavigationTree };\n"]}
@@ -0,0 +1,30 @@
1
+ import type { NavigatorTypeBagBase, ParamListBase, StaticConfig, StaticScreenFactory, TabNavigationState, TypedNavigator } from "@react-navigation/core";
2
+ import type { ReactNode } from "react";
3
+ import type { TabNavigationEventMap, TabNavigationOptions, TabNavigationProp, TabNavigatorProps } from "./types.js";
4
+ /** Type bag describing the tab navigator to React Navigation's typed APIs. */
5
+ type TabTypeBag<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: TabNavigationState<ParamList>;
12
+ /** Per-screen options. */
13
+ ScreenOptions: TabNavigationOptions;
14
+ /** Events the navigator emits. */
15
+ EventMap: TabNavigationEventMap;
16
+ /** Navigation object per route. */
17
+ NavigationList: {
18
+ [RouteName in keyof ParamList]: TabNavigationProp<ParamList, RouteName, NavigatorID>;
19
+ };
20
+ /** The navigator component. */
21
+ Navigator: typeof TabNavigator;
22
+ };
23
+ /** Declares a typed screen of a tab navigator for the static configuration API. */
24
+ declare const createTabScreen: StaticScreenFactory<TabTypeBag>;
25
+ /** Renders the screens of a {@link createTabNavigator} as pages of an `AdwViewStack` with a view switcher. */
26
+ declare function TabNavigator({ tabBarPosition, ...options }: TabNavigatorProps): ReactNode;
27
+ /** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */
28
+ declare function createTabNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = TabTypeBag<ParamList, NavigatorID>, const Config extends StaticConfig<TypeBag> | undefined = undefined>(config?: Config): TypedNavigator<TypeBag, Config>;
29
+ export { createTabNavigator, createTabScreen, TabNavigator, type TabTypeBag };
30
+ //# sourceMappingURL=create-tab-navigator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-tab-navigator.d.ts","sourceRoot":"","sources":["../../src/tabs/create-tab-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,mBAAmB,EAEnB,kBAAk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,OAAO,CAAC,GAAG,SAAS,GAAG,SAAS,EACpE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAElD;AAED,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createNavigatorFactory, createScreenFactory, TabRouter, useNavigationBuilder } from "@react-navigation/core";
3
+ import { TabView } from "./tab-view.js";
4
+ /** Declares a typed screen of a tab navigator for the static configuration API. */
5
+ const createTabScreen = createScreenFactory();
6
+ /** Renders the screens of a {@link createTabNavigator} as pages of an `AdwViewStack` with a view switcher. */
7
+ function TabNavigator({ tabBarPosition, ...options }) {
8
+ const { state, descriptors, navigation, NavigationContent } = useNavigationBuilder(TabRouter, options);
9
+ return (_jsx(NavigationContent, { children: _jsx(TabView, { tabBarPosition: tabBarPosition, state: state, navigation: navigation, descriptors: descriptors }) }));
10
+ }
11
+ /** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */
12
+ function createTabNavigator(config) {
13
+ return createNavigatorFactory(TabNavigator)(config);
14
+ }
15
+ export { createTabNavigator, createTabScreen, TabNavigator };
16
+ //# sourceMappingURL=create-tab-navigator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-tab-navigator.js","sourceRoot":"","sources":["../../src/tabs/create-tab-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEtH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAyBxC,mFAAmF;AACnF,MAAM,eAAe,GAAoC,mBAAmB,EAAc,CAAC;AAE3F,8GAA8G;AAC9G,SAAS,YAAY,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,EAAqB;IACnE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,oBAAoB,CAMhF,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtB,OAAO,CACH,KAAC,iBAAiB,cACd,KAAC,OAAO,IAAC,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAI,GAC3F,CACvB,CAAC;AACN,CAAC;AAED,qFAAqF;AACrF,SAAS,kBAAkB,CAKzB,MAAe;IACb,OAAO,sBAAsB,CAAC,YAAY,CAAC,CAAC,MAAM,CAAoC,CAAC;AAC3F,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAmB,CAAC","sourcesContent":["import type {\n NavigatorTypeBagBase,\n ParamListBase,\n StaticConfig,\n StaticScreenFactory,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n TypedNavigator,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport { createNavigatorFactory, createScreenFactory, TabRouter, useNavigationBuilder } from \"@react-navigation/core\";\nimport type { TabNavigationEventMap, TabNavigationOptions, TabNavigationProp, TabNavigatorProps } from \"./types.js\";\nimport { TabView } from \"./tab-view.js\";\n\n/** Type bag describing the tab navigator to React Navigation's typed APIs. */\ntype TabTypeBag<\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: TabNavigationState<ParamList>;\n /** Per-screen options. */\n ScreenOptions: TabNavigationOptions;\n /** Events the navigator emits. */\n EventMap: TabNavigationEventMap;\n /** Navigation object per route. */\n NavigationList: {\n [RouteName in keyof ParamList]: TabNavigationProp<ParamList, RouteName, NavigatorID>;\n };\n /** The navigator component. */\n Navigator: typeof TabNavigator;\n};\n\n/** Declares a typed screen of a tab navigator for the static configuration API. */\nconst createTabScreen: StaticScreenFactory<TabTypeBag> = createScreenFactory<TabTypeBag>();\n\n/** Renders the screens of a {@link createTabNavigator} as pages of an `AdwViewStack` with a view switcher. */\nfunction TabNavigator({ tabBarPosition, ...options }: TabNavigatorProps): ReactNode {\n const { state, descriptors, navigation, NavigationContent } = useNavigationBuilder<\n TabNavigationState<ParamListBase>,\n TabRouterOptions,\n TabActionHelpers<ParamListBase>,\n TabNavigationOptions,\n TabNavigationEventMap\n >(TabRouter, options);\n\n return (\n <NavigationContent>\n <TabView tabBarPosition={tabBarPosition} state={state} navigation={navigation} descriptors={descriptors} />\n </NavigationContent>\n );\n}\n\n/** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */\nfunction createTabNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = TabTypeBag<ParamList, NavigatorID>,\n const Config extends StaticConfig<TypeBag> | undefined = undefined,\n>(config?: Config): TypedNavigator<TypeBag, Config> {\n return createNavigatorFactory(TabNavigator)(config) as TypedNavigator<TypeBag, Config>;\n}\n\nexport { createTabNavigator, createTabScreen, TabNavigator, type TabTypeBag };\n"]}
@@ -0,0 +1,11 @@
1
+ import type { ParamListBase, TabNavigationState } from "@react-navigation/core";
2
+ import type { ReactNode } from "react";
3
+ import type { TabDescriptorMap, TabNavigationConfig, TabNavigationHelpers } from "./types.js";
4
+ type TabViewProps = TabNavigationConfig & {
5
+ state: TabNavigationState<ParamListBase>;
6
+ navigation: TabNavigationHelpers;
7
+ descriptors: TabDescriptorMap;
8
+ };
9
+ declare const TabView: ({ state, navigation, descriptors, tabBarPosition }: TabViewProps) => ReactNode;
10
+ export { TabView };
11
+ //# sourceMappingURL=tab-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tab-view.d.ts","sourceRoot":"","sources":["../../src/tabs/tab-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAKrD,OAAO,KAAK,EAAiB,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAO7G,KAAK,YAAY,GAAG,mBAAmB,GAAG;IACtC,KAAK,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACzC,UAAU,EAAE,oBAAoB,CAAC;IACjC,WAAW,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAqEF,QAAA,MAAM,OAAO,GAAI,oDAA4D,YAAY,KAAG,SAqC3F,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as Adw from "@gtkx/gi/adw";
3
+ import { AdwToolbarView, AdwViewStack, AdwViewSwitcher, AdwViewSwitcherBar, AdwWindowTitle } from "@gtkx/jsx/adw";
4
+ import { CommonActions } from "@react-navigation/core";
5
+ import { useCallback, useState } from "react";
6
+ import { HeaderBar } from "../shared/header-bar.js";
7
+ import { getFocusedRoute, requireDescriptor } from "../shared/routes.js";
8
+ import { ScenePage } from "../shared/scene-page.js";
9
+ import { useLoadedRoutes } from "../shared/use-loaded-routes.js";
10
+ import { usePopToTopOnBlur } from "../shared/use-pop-to-top-on-blur.js";
11
+ const useTabSelection = (navigation) => useCallback((name) => {
12
+ const current = navigation.getState();
13
+ const focusedKey = getFocusedRoute(current).key;
14
+ const route = current.routes.find((candidate) => candidate.key === name);
15
+ if (route === undefined || route.key === focusedKey) {
16
+ return;
17
+ }
18
+ const event = navigation.emit({ type: "tabPress", target: route.key, canPreventDefault: true });
19
+ if (!event.defaultPrevented) {
20
+ navigation.dispatch({ ...CommonActions.navigate(route.name, route.params), target: current.key });
21
+ }
22
+ }, [navigation]);
23
+ const defaultTabHeader = ({ descriptor, viewSwitcher }) => (_jsx(HeaderBar, { options: descriptor.options, titleWidget: viewSwitcher ?? _jsx(AdwWindowTitle, { title: descriptor.options.title ?? descriptor.route.name }) }));
24
+ const TabHeader = (props) => {
25
+ const { descriptor, viewSwitcher } = props;
26
+ const { route, options, navigation } = descriptor;
27
+ if (options.headerShown === false) {
28
+ return _jsx(_Fragment, { children: viewSwitcher });
29
+ }
30
+ return (_jsx(_Fragment, { children: options.header === undefined
31
+ ? defaultTabHeader(props)
32
+ : options.header({ route, navigation, options, viewSwitcher }) }));
33
+ };
34
+ const TabPage = ({ descriptor, isLoaded }) => {
35
+ const { route, options } = descriptor;
36
+ return (_jsx(ScenePage, { name: route.key, title: options.tabBarLabel ?? options.title ?? route.name, iconName: options.tabBarIcon, badgeNumber: options.tabBarBadge, needsAttention: options.needsAttention, isLoaded: isLoaded || options.lazy === false, render: () => descriptor.render() }));
37
+ };
38
+ const TabView = ({ state, navigation, descriptors, tabBarPosition = "top" }) => {
39
+ const [stack, setStack] = useState(null);
40
+ const focused = getFocusedRoute(state);
41
+ const descriptor = requireDescriptor(descriptors, focused.key);
42
+ const loaded = useLoadedRoutes(focused.key, state.preloadedRouteKeys);
43
+ const onVisibleChildChanged = useTabSelection(navigation);
44
+ const viewSwitcher = stack === null
45
+ ? undefined
46
+ : _jsx(AdwViewSwitcher, { stack: stack, policy: Adw.ViewSwitcherPolicy.WIDE });
47
+ const hasSwitcherBar = tabBarPosition === "bottom" && stack !== null;
48
+ usePopToTopOnBlur(state, descriptors, navigation);
49
+ return (_jsx(AdwToolbarView, { topBar: (_jsx(TabHeader, { descriptor: descriptor, viewSwitcher: tabBarPosition === "top" ? viewSwitcher : undefined })), bottomBar: hasSwitcherBar ? _jsx(AdwViewSwitcherBar, { stack: stack, reveal: true }) : undefined, children: _jsx(AdwViewStack, { ref: setStack, visibleChildName: focused.key, enableTransitions: descriptor.options.animation === "fade", onNotifyVisibleChildName: onVisibleChildChanged, children: state.routes.map((route) => (_jsx(TabPage, { descriptor: requireDescriptor(descriptors, route.key), isLoaded: loaded.has(route.key) }, route.key))) }) }));
50
+ };
51
+ export { TabView };
52
+ //# sourceMappingURL=tab-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tab-view.js","sourceRoot":"","sources":["../../src/tabs/tab-view.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAkBxE,MAAM,eAAe,GAAG,CAAC,UAAgC,EAAmC,EAAE,CAC1F,WAAW,CAAC,CAAC,IAAmB,EAAE,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;IAEzE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QAClD,OAAO;IACX,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAA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AAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAElD,OAAO,CACH,KAAC,cAAc,IACX,MAAM,EAAE,CACJ,KAAC,SAAS,IAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,GAAI,CAC3G,EACD,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,KAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,SAAG,CAAC,CAAC,CAAC,SAAS,YAEnF,KAAC,YAAY,IACT,GAAG,EAAE,QAAQ,EACb,gBAAgB,EAAE,OAAO,CAAC,GAAG,EAC7B,iBAAiB,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS,KAAK,MAAM,EAC1D,wBAAwB,EAAE,qBAAqB,YAE9C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACzB,KAAC,OAAO,IAEJ,UAAU,EAAE,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,EACrD,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAF1B,KAAK,CAAC,GAAG,CAGhB,CACL,CAAC,GACS,GACF,CACpB,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import type { ParamListBase, TabNavigationState } from \"@react-navigation/core\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport { AdwToolbarView, AdwViewStack, AdwViewSwitcher, AdwViewSwitcherBar, AdwWindowTitle } from \"@gtkx/jsx/adw\";\nimport { CommonActions } from \"@react-navigation/core\";\nimport { useCallback, useState } from \"react\";\nimport type { TabDescriptor, TabDescriptorMap, TabNavigationConfig, TabNavigationHelpers } from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { getFocusedRoute, requireDescriptor } from \"../shared/routes.js\";\nimport { ScenePage } from \"../shared/scene-page.js\";\nimport { useLoadedRoutes } from \"../shared/use-loaded-routes.js\";\nimport { usePopToTopOnBlur } from \"../shared/use-pop-to-top-on-blur.js\";\n\ntype TabViewProps = TabNavigationConfig & {\n state: TabNavigationState<ParamListBase>;\n navigation: TabNavigationHelpers;\n descriptors: TabDescriptorMap;\n};\n\ntype TabHeaderProps = {\n descriptor: TabDescriptor;\n viewSwitcher: ReactElement | undefined;\n};\n\ntype TabPageProps = {\n descriptor: TabDescriptor;\n isLoaded: boolean;\n};\n\nconst useTabSelection = (navigation: TabNavigationHelpers): ((name: string | null) => void) =>\n useCallback((name: string | null) => {\n const current = navigation.getState();\n const focusedKey = getFocusedRoute(current).key;\n const route = current.routes.find((candidate) => candidate.key === name);\n\n if (route === undefined || route.key === focusedKey) {\n return;\n }\n\n const event = navigation.emit({ type: \"tabPress\", target: route.key, canPreventDefault: true });\n\n if (!event.defaultPrevented) {\n navigation.dispatch({ ...CommonActions.navigate(route.name, route.params), target: current.key });\n }\n }, [navigation]);\n\nconst defaultTabHeader = ({ descriptor, viewSwitcher }: TabHeaderProps): ReactElement => (\n <HeaderBar\n options={descriptor.options}\n titleWidget={viewSwitcher ?? <AdwWindowTitle title={descriptor.options.title ?? descriptor.route.name} />}\n />\n);\n\nconst TabHeader = (props: TabHeaderProps): ReactNode => {\n const { descriptor, viewSwitcher } = props;\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return <>{viewSwitcher}</>;\n }\n\n return (\n <>\n {options.header === undefined\n ? defaultTabHeader(props)\n : options.header({ route, navigation, options, viewSwitcher })}\n </>\n );\n};\n\nconst TabPage = ({ descriptor, isLoaded }: TabPageProps): ReactNode => {\n const { route, options } = descriptor;\n\n return (\n <ScenePage\n name={route.key}\n title={options.tabBarLabel ?? options.title ?? route.name}\n iconName={options.tabBarIcon}\n badgeNumber={options.tabBarBadge}\n needsAttention={options.needsAttention}\n isLoaded={isLoaded || options.lazy === false}\n render={() => descriptor.render()}\n />\n );\n};\n\nconst TabView = ({ state, navigation, descriptors, tabBarPosition = \"top\" }: TabViewProps): ReactNode => {\n const [stack, setStack] = useState<Adw.ViewStack | null>(null);\n const focused = getFocusedRoute(state);\n const descriptor = requireDescriptor(descriptors, focused.key);\n const loaded = useLoadedRoutes(focused.key, state.preloadedRouteKeys);\n const onVisibleChildChanged = useTabSelection(navigation);\n\n const viewSwitcher = stack === null\n ? undefined\n : <AdwViewSwitcher stack={stack} policy={Adw.ViewSwitcherPolicy.WIDE} />;\n\n const hasSwitcherBar = tabBarPosition === \"bottom\" && stack !== null;\n usePopToTopOnBlur(state, descriptors, navigation);\n\n return (\n <AdwToolbarView\n topBar={(\n <TabHeader descriptor={descriptor} viewSwitcher={tabBarPosition === \"top\" ? viewSwitcher : undefined} />\n )}\n bottomBar={hasSwitcherBar ? <AdwViewSwitcherBar stack={stack} reveal /> : undefined}\n >\n <AdwViewStack\n ref={setStack}\n visibleChildName={focused.key}\n enableTransitions={descriptor.options.animation === \"fade\"}\n onNotifyVisibleChildName={onVisibleChildChanged}\n >\n {state.routes.map((route) => (\n <TabPage\n key={route.key}\n descriptor={requireDescriptor(descriptors, route.key)}\n isLoaded={loaded.has(route.key)}\n />\n ))}\n </AdwViewStack>\n </AdwToolbarView>\n );\n};\n\nexport { TabView };\n"]}
@@ -0,0 +1,67 @@
1
+ import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, ParamListBase, RouteProp, TabActionHelpers, TabNavigationState, TabRouterOptions } from "@react-navigation/core";
2
+ import type { ReactNode } from "react";
3
+ import type { HeaderOptions } from "../shared/types.js";
4
+ /** Events the tab navigator emits on top of React Navigation's core events. */
5
+ type TabNavigationEventMap = {
6
+ /** The user selected a tab in the view switcher. */
7
+ tabPress: {
8
+ /** No payload. */
9
+ data: undefined;
10
+ /** Calling `preventDefault` keeps the current tab. */
11
+ canPreventDefault: true;
12
+ };
13
+ };
14
+ /** Per-screen options of the tab navigator. */
15
+ type TabNavigationOptions = HeaderOptions & {
16
+ /** Renders a custom top bar instead of the default `AdwHeaderBar`. */
17
+ header?: (props: TabHeaderProps) => ReactNode;
18
+ /** Label shown in the view switcher; defaults to `title`, then to the route name. */
19
+ tabBarLabel?: string;
20
+ /** Icon name shown in the view switcher. */
21
+ tabBarIcon?: string;
22
+ /** Badge number shown in the view switcher; `0` hides the badge. */
23
+ tabBarBadge?: number;
24
+ /** Whether the view switcher highlights the tab as needing attention. */
25
+ needsAttention?: boolean;
26
+ /** Whether the screen mounts on first focus instead of at startup; defaults to `true`. */
27
+ lazy?: boolean;
28
+ /** Whether a nested stack pops to its first screen when this tab loses focus; defaults to `false`. */
29
+ popToTopOnBlur?: boolean;
30
+ /** Whether switching to this tab crossfades; defaults to `"none"`. */
31
+ animation?: "fade" | "none";
32
+ };
33
+ /** Props of the tab navigator beyond the options every navigator shares. */
34
+ type TabNavigationConfig = {
35
+ /** Where the view switcher sits: in the header bar or in a bar below the content; defaults to `"top"`. */
36
+ tabBarPosition?: "top" | "bottom";
37
+ };
38
+ /** Navigation object of a tab screen. */
39
+ type TabNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, TabNavigationState<ParamList>, TabNavigationOptions, TabNavigationEventMap> & TabActionHelpers<ParamList>;
40
+ /** Props a tab screen component receives. */
41
+ type TabScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = {
42
+ /** Navigation object of the screen. */
43
+ navigation: TabNavigationProp<ParamList, RouteName, NavigatorID>;
44
+ /** The route the screen renders. */
45
+ route: RouteProp<ParamList, RouteName>;
46
+ };
47
+ /** Arguments of a custom tab `header` renderer. */
48
+ type TabHeaderProps = {
49
+ /** The focused route. */
50
+ route: RouteProp<ParamListBase>;
51
+ /** Navigation object of the focused route. */
52
+ navigation: TabNavigationProp<ParamListBase>;
53
+ /** Resolved options of the focused route. */
54
+ options: TabNavigationOptions;
55
+ /** The view switcher to place in the header when `tabBarPosition` is `"top"`. */
56
+ viewSwitcher: ReactNode;
57
+ };
58
+ /** Navigation helpers of the tab navigator itself. */
59
+ type TabNavigationHelpers = NavigationHelpers<ParamListBase, TabNavigationEventMap> & TabActionHelpers<ParamListBase>;
60
+ /** Descriptor of one tab route. */
61
+ type TabDescriptor = Descriptor<TabNavigationOptions, TabNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
62
+ /** Descriptors of the tab routes, keyed by route key. */
63
+ type TabDescriptorMap = Record<string, TabDescriptor>;
64
+ /** Props of the tab `Navigator` component. */
65
+ type TabNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, TabNavigationState<ParamListBase>, TabNavigationOptions, TabNavigationEventMap, TabNavigationProp<ParamListBase>> & TabRouterOptions & TabNavigationConfig;
66
+ export type { TabDescriptor, TabDescriptorMap, TabHeaderProps, TabNavigationConfig, TabNavigationEventMap, TabNavigationHelpers, TabNavigationOptions, TabNavigationProp, TabNavigatorProps, TabScreenProps, };
67
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tabs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,+EAA+E;AAC/E,KAAK,qBAAqB,GAAG;IACzB,oDAAoD;IACpD,QAAQ,EAAE;QACN,kBAAkB;QAClB,IAAI,EAAE,SAAS,CAAC;QAChB,sDAAsD;QACtD,iBAAiB,EAAE,IAAI,CAAC;KAC3B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AK,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;CAC1C,CAAC;AAEF,mDAAmD;AACnD,KAAK,cAAc,GAAG;IAClB,yBAAyB;IACzB,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IAChC,8CAA8C;IAC9C,UAAU,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAC7C,6CAA6C;IAC7C,OAAO,EAAE,oBAAoB,CAAC;IAC9B,iFAAiF;IACjF,YAAY,EAAE,SAAS,CAAC;CAC3B,CAAC;AAEF,sDAAsD;AACtD,KAAK,oBAAoB,GAAG,iBAAiB,CAAC,aAAa,EAAE,qBAAqB,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;AACtH,mCAAmC;AACnC,KAAK,aAAa,GAAG,UAAU,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;AAClH,yDAAyD;AACzD,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEtD,8CAA8C;AAC9C,KAAK,iBAAiB,GAAG,uBAAuB,CAC5C,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,kBAAkB,CAAC,aAAa,CAAC,EACjC,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAAC,aAAa,CAAC,CACnC,GACD,gBAAgB,GAChB,mBAAmB,CAAC;AAEpB,YAAY,EACR,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tabs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DefaultNavigatorOptions,\n Descriptor,\n NavigationHelpers,\n NavigationProp,\n ParamListBase,\n RouteProp,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport type { HeaderOptions } from \"../shared/types.js\";\n\n/** Events the tab navigator emits on top of React Navigation's core events. */\ntype TabNavigationEventMap = {\n /** The user selected a tab in the view switcher. */\n tabPress: {\n /** No payload. */\n data: undefined;\n /** Calling `preventDefault` keeps the current tab. */\n canPreventDefault: true;\n };\n};\n\n/** Per-screen options of the tab navigator. */\ntype TabNavigationOptions = HeaderOptions & {\n /** Renders a custom top bar instead of the default `AdwHeaderBar`. */\n header?: (props: TabHeaderProps) => ReactNode;\n /** Label shown in the view switcher; defaults to `title`, then to the route name. */\n tabBarLabel?: string;\n /** Icon name shown in the view switcher. */\n tabBarIcon?: string;\n /** Badge number shown in the view switcher; `0` hides the badge. */\n tabBarBadge?: number;\n /** Whether the view switcher highlights the tab as needing attention. */\n needsAttention?: boolean;\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 tab loses focus; defaults to `false`. */\n popToTopOnBlur?: boolean;\n /** Whether switching to this tab crossfades; defaults to `\"none\"`. */\n animation?: \"fade\" | \"none\";\n};\n\n/** Props of the tab navigator beyond the options every navigator shares. */\ntype TabNavigationConfig = {\n /** Where the view switcher sits: in the header bar or in a bar below the content; defaults to `\"top\"`. */\n tabBarPosition?: \"top\" | \"bottom\";\n};\n\n/** Navigation object of a tab screen. */\ntype TabNavigationProp<\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 TabNavigationState<ParamList>,\n TabNavigationOptions,\n TabNavigationEventMap\n> & TabActionHelpers<ParamList>;\n\n/** Props a tab screen component receives. */\ntype TabScreenProps<\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: TabNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Arguments of a custom tab `header` renderer. */\ntype TabHeaderProps = {\n /** The focused route. */\n route: RouteProp<ParamListBase>;\n /** Navigation object of the focused route. */\n navigation: TabNavigationProp<ParamListBase>;\n /** Resolved options of the focused route. */\n options: TabNavigationOptions;\n /** The view switcher to place in the header when `tabBarPosition` is `\"top\"`. */\n viewSwitcher: ReactNode;\n};\n\n/** Navigation helpers of the tab navigator itself. */\ntype TabNavigationHelpers = NavigationHelpers<ParamListBase, TabNavigationEventMap> & TabActionHelpers<ParamListBase>;\n/** Descriptor of one tab route. */\ntype TabDescriptor = Descriptor<TabNavigationOptions, TabNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;\n/** Descriptors of the tab routes, keyed by route key. */\ntype TabDescriptorMap = Record<string, TabDescriptor>;\n\n/** Props of the tab `Navigator` component. */\ntype TabNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n TabNavigationState<ParamListBase>,\n TabNavigationOptions,\n TabNavigationEventMap,\n TabNavigationProp<ParamListBase>\n> &\nTabRouterOptions &\nTabNavigationConfig;\n\nexport type {\n TabDescriptor,\n TabDescriptorMap,\n TabHeaderProps,\n TabNavigationConfig,\n TabNavigationEventMap,\n TabNavigationHelpers,\n TabNavigationOptions,\n TabNavigationProp,\n TabNavigatorProps,\n TabScreenProps,\n};\n"]}
@@ -0,0 +1,18 @@
1
+ /** Style state handed to `useTheme` and to option callbacks as `theme`, mirroring Adwaita's style manager. */
2
+ type AdwaitaTheme = {
3
+ /** Whether the application currently uses the dark color scheme. */
4
+ dark: boolean;
5
+ /** Whether the system requested high-contrast styling. */
6
+ highContrast: boolean;
7
+ };
8
+ declare module "@react-navigation/core" {
9
+ interface Theme extends AdwaitaTheme {
10
+ }
11
+ }
12
+ /** The light Adwaita theme. */
13
+ declare const DefaultTheme: AdwaitaTheme;
14
+ /** The dark Adwaita theme. */
15
+ declare const DarkTheme: AdwaitaTheme;
16
+ declare const useAdwaitaTheme: () => AdwaitaTheme;
17
+ export { type AdwaitaTheme as Theme, DarkTheme, DefaultTheme, useAdwaitaTheme };
18
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAIA,8GAA8G;AAC9G,KAAK,YAAY,GAAG;IAChB,oEAAoE;IACpE,IAAI,EAAE,OAAO,CAAC;IACd,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,OAAO,QAAQ,wBAAwB,CAAC;IAEpC,UAAU,KAAM,SAAQ,YAAY;KAAG;CAC1C;AAED,+BAA+B;AAC/B,QAAA,MAAM,YAAY,EAAE,YAAmD,CAAC;AACxE,8BAA8B;AAC9B,QAAA,MAAM,SAAS,EAAE,YAAkD,CAAC;AAEpE,QAAA,MAAM,eAAe,QAAO,YAM3B,CAAC;AAEF,OAAO,EAAE,KAAK,YAAY,IAAI,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC"}
package/dist/theme.js ADDED
@@ -0,0 +1,15 @@
1
+ import * as Adw from "@gtkx/gi/adw";
2
+ import { useProperty } from "@gtkx/react";
3
+ import { useMemo } from "react";
4
+ /** The light Adwaita theme. */
5
+ const DefaultTheme = { dark: false, highContrast: false };
6
+ /** The dark Adwaita theme. */
7
+ const DarkTheme = { dark: true, highContrast: false };
8
+ const useAdwaitaTheme = () => {
9
+ const manager = Adw.StyleManager.getDefault();
10
+ const isDark = useProperty(manager, "dark") ?? manager.getDark();
11
+ const isHighContrast = useProperty(manager, "highContrast") ?? manager.getHighContrast();
12
+ return useMemo(() => ({ dark: isDark, highContrast: isHighContrast }), [isDark, isHighContrast]);
13
+ };
14
+ export { DarkTheme, DefaultTheme, useAdwaitaTheme };
15
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAehC,+BAA+B;AAC/B,MAAM,YAAY,GAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACxE,8BAA8B;AAC9B,MAAM,SAAS,GAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AAEpE,MAAM,eAAe,GAAG,GAAiB,EAAE;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IACjE,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAEzF,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AACrG,CAAC,CAAC;AAEF,OAAO,EAA8B,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import * as Adw from \"@gtkx/gi/adw\";\nimport { useProperty } from \"@gtkx/react\";\nimport { useMemo } from \"react\";\n\n/** Style state handed to `useTheme` and to option callbacks as `theme`, mirroring Adwaita's style manager. */\ntype AdwaitaTheme = {\n /** Whether the application currently uses the dark color scheme. */\n dark: boolean;\n /** Whether the system requested high-contrast styling. */\n highContrast: boolean;\n};\n\ndeclare module \"@react-navigation/core\" {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Theme extends AdwaitaTheme {}\n}\n\n/** The light Adwaita theme. */\nconst DefaultTheme: AdwaitaTheme = { dark: false, highContrast: false };\n/** The dark Adwaita theme. */\nconst DarkTheme: AdwaitaTheme = { dark: true, highContrast: false };\n\nconst useAdwaitaTheme = (): AdwaitaTheme => {\n const manager = Adw.StyleManager.getDefault();\n const isDark = useProperty(manager, \"dark\") ?? manager.getDark();\n const isHighContrast = useProperty(manager, \"highContrast\") ?? manager.getHighContrast();\n\n return useMemo(() => ({ dark: isDark, highContrast: isHighContrast }), [isDark, isHighContrast]);\n};\n\nexport { type AdwaitaTheme as Theme, DarkTheme, DefaultTheme, useAdwaitaTheme };\n"]}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@gtkx/navigation",
3
+ "version": "0.0.1",
4
+ "description": "React Navigation for GTKX: stack, tab, drawer and master/detail navigators rendered with libadwaita's navigation view, view stack and split views",
5
+ "keywords": [
6
+ "gtkx",
7
+ "gtk",
8
+ "gtk4",
9
+ "adwaita",
10
+ "react",
11
+ "react-navigation",
12
+ "navigation",
13
+ "linux",
14
+ "desktop"
15
+ ],
16
+ "homepage": "https://gtkx.dev",
17
+ "bugs": {
18
+ "url": "https://github.com/gtkx-org/gtkx/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/gtkx-org/gtkx.git",
23
+ "directory": "packages/navigation"
24
+ },
25
+ "license": "MPL-2.0",
26
+ "author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
27
+ "type": "module",
28
+ "exports": {
29
+ "./package.json": "./package.json",
30
+ ".": {
31
+ "source": "./src/index.ts",
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ }
35
+ },
36
+ "sideEffects": false,
37
+ "files": [
38
+ "dist",
39
+ "src"
40
+ ],
41
+ "scripts": {
42
+ "release": "tsx ../../scripts/release-package.ts"
43
+ },
44
+ "nx": {
45
+ "targets": {
46
+ "lint": {
47
+ "options": {
48
+ "cwd": ".",
49
+ "command": "eslint {projectRoot}"
50
+ }
51
+ }
52
+ }
53
+ },
54
+ "engines": {
55
+ "node": ">=24"
56
+ },
57
+ "dependencies": {
58
+ "@gtkx/react": "workspace:*",
59
+ "@react-navigation/core": "^7.21.13",
60
+ "@react-navigation/routers": "^7.6.4"
61
+ },
62
+ "peerDependencies": {
63
+ "react": "^19.2"
64
+ },
65
+ "devDependencies": {
66
+ "@gtkx/config": "workspace:*",
67
+ "@gtkx/testing": "workspace:*",
68
+ "@gtkx/vitest": "workspace:*",
69
+ "vitest": "catalog:"
70
+ }
71
+ }