@gtkx/navigation 2.0.0-beta.10 → 2.0.0-beta.12
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 +8 -168
- package/dist/drawer/create-drawer-navigator.d.ts.map +1 -1
- package/dist/drawer/create-drawer-navigator.js +2 -2
- package/dist/drawer/create-drawer-navigator.js.map +1 -1
- package/dist/drawer/drawer-item-list.d.ts.map +1 -1
- package/dist/drawer/drawer-item-list.js +5 -3
- package/dist/drawer/drawer-item-list.js.map +1 -1
- package/dist/drawer/drawer-router.d.ts.map +1 -1
- package/dist/drawer/drawer-router.js.map +1 -1
- package/dist/drawer/drawer-status.d.ts +2 -2
- package/dist/drawer/drawer-status.d.ts.map +1 -1
- package/dist/drawer/drawer-status.js +1 -9
- package/dist/drawer/drawer-status.js.map +1 -1
- package/dist/drawer/drawer-view.d.ts.map +1 -1
- package/dist/drawer/drawer-view.js +8 -12
- package/dist/drawer/drawer-view.js.map +1 -1
- package/dist/drawer/types.d.ts +2 -0
- package/dist/drawer/types.d.ts.map +1 -1
- package/dist/drawer/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/shared/header-bar.d.ts.map +1 -1
- package/dist/shared/header-bar.js +2 -2
- package/dist/shared/header-bar.js.map +1 -1
- package/dist/shared/routes.d.ts.map +1 -1
- package/dist/shared/scene-page.d.ts +3 -1
- package/dist/shared/scene-page.d.ts.map +1 -1
- package/dist/shared/scene-page.js +8 -1
- package/dist/shared/scene-page.js.map +1 -1
- package/dist/shared/use-pop-to-top-on-blur.d.ts.map +1 -1
- package/dist/split-view/create-split-view-navigator.d.ts.map +1 -1
- package/dist/split-view/create-split-view-navigator.js +2 -2
- package/dist/split-view/create-split-view-navigator.js.map +1 -1
- package/dist/split-view/split-view.d.ts.map +1 -1
- package/dist/split-view/split-view.js +3 -7
- package/dist/split-view/split-view.js.map +1 -1
- package/dist/split-view/types.d.ts.map +1 -1
- package/dist/split-view/types.js.map +1 -1
- package/dist/stack/create-stack-navigator.d.ts.map +1 -1
- package/dist/stack/create-stack-navigator.js +2 -2
- package/dist/stack/create-stack-navigator.js.map +1 -1
- package/dist/stack/stack-pages.d.ts.map +1 -1
- package/dist/stack/stack-pages.js +4 -14
- package/dist/stack/stack-pages.js.map +1 -1
- package/dist/stack/stack-view.d.ts.map +1 -1
- package/dist/stack/stack-view.js +5 -22
- package/dist/stack/stack-view.js.map +1 -1
- package/dist/stack/sync-navigation-stack.d.ts.map +1 -1
- package/dist/stack/types.d.ts.map +1 -1
- package/dist/stack/types.js.map +1 -1
- package/dist/tabs/create-tab-navigator.d.ts.map +1 -1
- package/dist/tabs/create-tab-navigator.js +2 -2
- package/dist/tabs/create-tab-navigator.js.map +1 -1
- package/dist/tabs/tab-view.d.ts.map +1 -1
- package/dist/tabs/tab-view.js +5 -9
- package/dist/tabs/tab-view.js.map +1 -1
- package/dist/tabs/types.d.ts +2 -0
- package/dist/tabs/types.d.ts.map +1 -1
- package/dist/tabs/types.js.map +1 -1
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js.map +1 -1
- package/package.json +13 -21
- package/src/drawer/create-drawer-navigator.tsx +14 -16
- package/src/drawer/drawer-item-list.tsx +22 -15
- package/src/drawer/drawer-router.ts +4 -2
- package/src/drawer/drawer-status.ts +3 -16
- package/src/drawer/drawer-view.tsx +18 -23
- package/src/drawer/types.ts +6 -3
- package/src/index.ts +1 -5
- package/src/shared/header-bar.tsx +2 -2
- package/src/shared/scene-page.tsx +24 -12
- package/src/split-view/create-split-view-navigator.tsx +15 -17
- package/src/split-view/split-view.tsx +32 -26
- package/src/split-view/types.ts +4 -3
- package/src/stack/create-stack-navigator.tsx +9 -11
- package/src/stack/stack-pages.ts +14 -24
- package/src/stack/stack-view.tsx +9 -29
- package/src/stack/types.ts +4 -3
- package/src/tabs/create-tab-navigator.tsx +3 -5
- package/src/tabs/tab-view.tsx +28 -24
- package/src/tabs/types.ts +6 -3
- package/src/theme.ts +0 -1
- package/dist/shared/use-loaded-routes.d.ts +0 -3
- package/dist/shared/use-loaded-routes.d.ts.map +0 -1
- package/dist/shared/use-loaded-routes.js +0 -11
- package/dist/shared/use-loaded-routes.js.map +0 -1
- package/src/shared/use-loaded-routes.ts +0 -14
|
@@ -1 +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,EAAE,MAAM,oBAAoB,CAAC;AAExD,wEAAwE;AACxE,KAAK,mBAAmB,GAAG;IACvB,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,iFAAiF;AACjF,KAAK,uBAAuB,GAAG;IAC3B,uCAAuC;IACvC,eAAe,EAAE;QACb,yCAAyC;QACzC,IAAI,EAAE,mBAAmB,CAAC;KAC7B,CAAC;IACF,yCAAyC;IACzC,aAAa,EAAE;QACX,yCAAyC;QACzC,IAAI,EAAE,mBAAmB,CAAC;KAC7B,CAAC;CACL,CAAC;AAEF,sEAAsE;AACtE,KAAK,eAAe,GAAG;IACnB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,iDAAiD;AACjD,KAAK,sBAAsB,GAAG,aAAa,GAAG;IAC1C,sEAAsE;IACtE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,SAAS,CAAC;IAChD,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gHAAgH;IAChH,MAA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AmB,CAAC,aAAa,CAAC,CAAC;IAC/C,sCAAsC;IACtC,OAAO,EAAE,sBAAsB,CAAC;IAChC,oDAAoD;IACpD,IAAI,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,wDAAwD;AACxD,KAAK,sBAAsB,GAAG,iBAAiB,CAAC,aAAa,EAAE,uBAAuB,CAAC,GACnF,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAEtC,qCAAqC;AACrC,KAAK,eAAe,GAAG,UAAU,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;AACxH,2DAA2D;AAC3D,KAAK,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE1D,gDAAgD;AAChD,KAAK,mBAAmB,GAAG,uBAAuB,CAC9C,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,oBAAoB,CAAC,aAAa,CAAC,EACnC,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,CAAC,aAAa,CAAC,CACrC,GACG,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B,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,CAAC"}
|
package/dist/stack/types.js.map
CHANGED
|
@@ -1 +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>
|
|
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> &\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> &\n StackRouterOptions &\n StackNavigationConfig;\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"]}
|
|
@@ -1 +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,kBAAkB,EAElB,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpH,8EAA8E;AAC9E,KAAK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AAG,SAAS,IAC3D;IACA,oCAAoC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,6BAA6B;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,oCAAoC;IACpC,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACrC,0BAA0B;IAC1B,aAAa,EAAE,oBAAoB,CAAC;IACpC,kCAAkC;IAClC,QAAQ,EAAE,qBAAqB,CAAC;IAChC,mCAAmC;IACnC,cAAc,EAAE;SACX,SAAS,IAAI,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;KACvF,CAAC;IACF,+BAA+B;IAC/B,SAAS,EAAE,OAAO,YAAY,CAAC;CAClC,CAAC;AAEF,mFAAmF;AACnF,QAAA,MAAM,eAAe,EAAE,mBAAmB,CAAC,UAAU,CAAqC,CAAC;AAE3F,8GAA8G;AAC9G,iBAAS,YAAY,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,EAAE,EAAE,iBAAiB,GAAG,SAAS,CAYlF;AAED,qFAAqF;AACrF,iBAAS,kBAAkB,CACvB,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,EAC/E,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,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,CAAC"}
|
|
@@ -5,8 +5,8 @@ import { TabView } from "./tab-view.js";
|
|
|
5
5
|
const createTabScreen = createScreenFactory();
|
|
6
6
|
/** Renders the screens of a {@link createTabNavigator} as pages of an `AdwViewStack` with a view switcher. */
|
|
7
7
|
function TabNavigator({ tabBarPosition, ...options }) {
|
|
8
|
-
const { state, descriptors, navigation,
|
|
9
|
-
return (_jsx(
|
|
8
|
+
const { state, descriptors, navigation, render } = useNavigationBuilder(TabRouter, options);
|
|
9
|
+
return render(_jsx(TabView, { tabBarPosition: tabBarPosition, state: state, navigation: navigation, descriptors: descriptors }));
|
|
10
10
|
}
|
|
11
11
|
/** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */
|
|
12
12
|
function createTabNavigator(config) {
|
|
@@ -1 +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,
|
|
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,MAAM,EAAE,GAAG,oBAAoB,CAMrE,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtB,OAAO,MAAM,CACT,KAAC,OAAO,IAAC,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAI,CAC9G,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, render } = useNavigationBuilder<\n TabNavigationState<ParamListBase>,\n TabRouterOptions,\n TabActionHelpers<ParamListBase>,\n TabNavigationOptions,\n TabNavigationEventMap\n >(TabRouter, options);\n\n return render(\n <TabView tabBarPosition={tabBarPosition} state={state} navigation={navigation} descriptors={descriptors} />,\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"]}
|
|
@@ -1 +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;
|
|
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;AAM7G,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;AA2EF,QAAA,MAAM,OAAO,uDAAgE,YAAY,KAAG,SAoC3F,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/tabs/tab-view.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as Adw from "@gtkx/gi/adw";
|
|
3
3
|
import { AdwToolbarView, AdwViewStack, AdwViewSwitcher, AdwViewSwitcherBar, AdwWindowTitle } from "@gtkx/jsx/adw";
|
|
4
4
|
import { CommonActions } from "@react-navigation/core";
|
|
@@ -6,7 +6,6 @@ import { useCallback, useState } from "react";
|
|
|
6
6
|
import { HeaderBar } from "../shared/header-bar.js";
|
|
7
7
|
import { getFocusedRoute, requireDescriptor } from "../shared/routes.js";
|
|
8
8
|
import { ScenePage } from "../shared/scene-page.js";
|
|
9
|
-
import { useLoadedRoutes } from "../shared/use-loaded-routes.js";
|
|
10
9
|
import { usePopToTopOnBlur } from "../shared/use-pop-to-top-on-blur.js";
|
|
11
10
|
const useTabSelection = (navigation) => useCallback((name) => {
|
|
12
11
|
const current = navigation.getState();
|
|
@@ -31,22 +30,19 @@ const TabHeader = (props) => {
|
|
|
31
30
|
? defaultTabHeader(props)
|
|
32
31
|
: options.header({ route, navigation, options, viewSwitcher }) }));
|
|
33
32
|
};
|
|
34
|
-
const TabPage = ({ descriptor, isLoaded }) => {
|
|
33
|
+
const TabPage = ({ descriptor, isFocused, isLoaded }) => {
|
|
35
34
|
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() }));
|
|
35
|
+
return (_jsx(ScenePage, { name: route.key, title: options.tabBarLabel ?? options.title ?? route.name, useUnderline: options.useUnderline, iconName: options.tabBarIcon, badgeNumber: options.tabBarBadge, needsAttention: options.needsAttention, isFocused: isFocused, isLoaded: isLoaded || options.lazy === false, render: () => descriptor.render() }));
|
|
37
36
|
};
|
|
38
37
|
const TabView = ({ state, navigation, descriptors, tabBarPosition = "top" }) => {
|
|
39
38
|
const [stack, setStack] = useState(null);
|
|
40
39
|
const focused = getFocusedRoute(state);
|
|
41
40
|
const descriptor = requireDescriptor(descriptors, focused.key);
|
|
42
|
-
const loaded = useLoadedRoutes(focused.key, state.preloadedRouteKeys);
|
|
43
41
|
const onVisibleChildChanged = useTabSelection(navigation);
|
|
44
|
-
const viewSwitcher = stack === null
|
|
45
|
-
? undefined
|
|
46
|
-
: _jsx(AdwViewSwitcher, { stack: stack, policy: Adw.ViewSwitcherPolicy.WIDE });
|
|
42
|
+
const viewSwitcher = stack === null ? undefined : _jsx(AdwViewSwitcher, { stack: stack, policy: Adw.ViewSwitcherPolicy.WIDE });
|
|
47
43
|
const hasSwitcherBar = tabBarPosition === "bottom" && stack !== null;
|
|
48
44
|
usePopToTopOnBlur(state, descriptors, navigation);
|
|
49
|
-
return (_jsx(AdwToolbarView, { topBar:
|
|
45
|
+
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), isFocused: route.key === focused.key, isLoaded: route.key === focused.key || state.preloadedRouteKeys.includes(route.key) }, route.key))) }) }));
|
|
50
46
|
};
|
|
51
47
|
export { TabView };
|
|
52
48
|
//# sourceMappingURL=tab-view.js.map
|
|
@@ -1 +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,
|
|
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,iBAAiB,EAAE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CAAC,GAAG,KAAK,OAAO,CAAC,GAAG,EACpC,QAAQ,EAAE,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAH9E,KAAK,CAAC,GAAG,CAIhB,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 { 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 isFocused: boolean;\n isLoaded: boolean;\n};\n\nconst useTabSelection = (navigation: TabNavigationHelpers): ((name: string | null) => void) =>\n useCallback(\n (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 },\n [navigation],\n );\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, isFocused, 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 useUnderline={options.useUnderline}\n iconName={options.tabBarIcon}\n badgeNumber={options.tabBarBadge}\n needsAttention={options.needsAttention}\n isFocused={isFocused}\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 onVisibleChildChanged = useTabSelection(navigation);\n\n const viewSwitcher =\n stack === null ? undefined : <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 isFocused={route.key === focused.key}\n isLoaded={route.key === focused.key || state.preloadedRouteKeys.includes(route.key)}\n />\n ))}\n </AdwViewStack>\n </AdwToolbarView>\n );\n};\n\nexport { TabView };\n"]}
|
package/dist/tabs/types.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ type TabNavigationOptions = HeaderOptions & {
|
|
|
17
17
|
header?: (props: TabHeaderProps) => ReactNode;
|
|
18
18
|
/** Label shown in the view switcher; defaults to `title`, then to the route name. */
|
|
19
19
|
tabBarLabel?: string;
|
|
20
|
+
/** Whether underscores in the tab label indicate mnemonics; defaults to `false`. */
|
|
21
|
+
useUnderline?: boolean;
|
|
20
22
|
/** Icon name shown in the view switcher. */
|
|
21
23
|
tabBarIcon?: string;
|
|
22
24
|
/** Badge number shown in the view switcher; `0` hides the badge. */
|
package/dist/tabs/types.d.ts.map
CHANGED
|
@@ -1 +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,CAAC;CACL,CAAC;AAEF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oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACjB,CAAC"}
|
package/dist/tabs/types.js.map
CHANGED
|
@@ -1 +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>
|
|
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 /** Whether underscores in the tab label indicate mnemonics; defaults to `false`. */\n useUnderline?: boolean;\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> &\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> &\n TabRouterOptions &\n TabNavigationConfig;\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"]}
|
package/dist/theme.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;IACpC,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.map
CHANGED
|
@@ -1 +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;
|
|
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;AAchC,+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 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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/navigation",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
4
|
-
"description": "React Navigation for GTKX
|
|
3
|
+
"version": "2.0.0-beta.12",
|
|
4
|
+
"description": "React Navigation navigators for GTKX.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
7
7
|
"gtk",
|
|
@@ -40,34 +40,26 @@
|
|
|
40
40
|
"dist",
|
|
41
41
|
"src"
|
|
42
42
|
],
|
|
43
|
-
"nx": {
|
|
44
|
-
"targets": {
|
|
45
|
-
"lint": {
|
|
46
|
-
"options": {
|
|
47
|
-
"cwd": ".",
|
|
48
|
-
"command": "eslint {projectRoot}"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
43
|
"engines": {
|
|
54
44
|
"node": ">=26.7.0"
|
|
55
45
|
},
|
|
56
46
|
"dependencies": {
|
|
57
|
-
"@gtkx/react": "2.0.0-beta.
|
|
58
|
-
"@react-navigation/core": "^7.
|
|
59
|
-
"@react-navigation/routers": "^7.6.
|
|
47
|
+
"@gtkx/react": "2.0.0-beta.12",
|
|
48
|
+
"@react-navigation/core": "^7.24.0",
|
|
49
|
+
"@react-navigation/routers": "^7.6.5"
|
|
60
50
|
},
|
|
61
51
|
"peerDependencies": {
|
|
62
|
-
"react": "^19.
|
|
52
|
+
"@types/react": "^19.3",
|
|
53
|
+
"react": "^19.3"
|
|
63
54
|
},
|
|
64
55
|
"devDependencies": {
|
|
65
|
-
"@gtkx/config": "2.0.0-beta.
|
|
66
|
-
"@gtkx/testing": "2.0.0-beta.
|
|
67
|
-
"@gtkx/vitest": "2.0.0-beta.
|
|
68
|
-
"
|
|
56
|
+
"@gtkx/config": "2.0.0-beta.12",
|
|
57
|
+
"@gtkx/testing": "2.0.0-beta.12",
|
|
58
|
+
"@gtkx/vitest": "2.0.0-beta.12",
|
|
59
|
+
"@types/react": "^19.3.0",
|
|
60
|
+
"vitest": "5.0.5"
|
|
69
61
|
},
|
|
70
62
|
"scripts": {
|
|
71
|
-
"release": "
|
|
63
|
+
"release": "node ../../scripts/release/publish-package.ts"
|
|
72
64
|
}
|
|
73
65
|
}
|
|
@@ -82,7 +82,7 @@ function DrawerNavigator({
|
|
|
82
82
|
}: DrawerNavigatorProps): ReactNode {
|
|
83
83
|
const createRouter = useDrawerRouter(collapsed === true);
|
|
84
84
|
|
|
85
|
-
const { state, descriptors, navigation,
|
|
85
|
+
const { state, descriptors, navigation, render } = useNavigationBuilder<
|
|
86
86
|
DrawerNavigationState<ParamListBase>,
|
|
87
87
|
DrawerRouterOptions,
|
|
88
88
|
DrawerActionHelpers<ParamListBase>,
|
|
@@ -90,21 +90,19 @@ function DrawerNavigator({
|
|
|
90
90
|
DrawerNavigationEventMap
|
|
91
91
|
>(createRouter, { ...options, defaultStatus: defaultStatus ?? (collapsed === true ? "closed" : "open") });
|
|
92
92
|
|
|
93
|
-
return (
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/>
|
|
107
|
-
</NavigationContent>
|
|
93
|
+
return render(
|
|
94
|
+
<DrawerView
|
|
95
|
+
state={state}
|
|
96
|
+
navigation={navigation}
|
|
97
|
+
descriptors={descriptors}
|
|
98
|
+
drawerContent={drawerContent}
|
|
99
|
+
collapsed={collapsed}
|
|
100
|
+
sidebarPosition={sidebarPosition}
|
|
101
|
+
pinSidebar={pinSidebar}
|
|
102
|
+
minSidebarWidth={minSidebarWidth}
|
|
103
|
+
maxSidebarWidth={maxSidebarWidth}
|
|
104
|
+
sidebarWidthFraction={sidebarWidthFraction}
|
|
105
|
+
/>,
|
|
108
106
|
);
|
|
109
107
|
}
|
|
110
108
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { NavigationState } from "@react-navigation/core";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
-
import { GtkBox, GtkImage, GtkLabel, GtkListBox } from "@gtkx/jsx/gtk";
|
|
4
|
+
import { GtkBox, GtkImage, GtkLabel, GtkListBox, GtkListBoxRow } from "@gtkx/jsx/gtk";
|
|
5
5
|
import { CommonActions, DrawerActions } from "@react-navigation/core";
|
|
6
|
-
import { useCallback, useContext } from "react";
|
|
6
|
+
import { useCallback, useContext, useState } from "react";
|
|
7
7
|
import type { DrawerContentProps, DrawerDescriptor, DrawerNavigationHelpers } from "./types.js";
|
|
8
8
|
import { requireDescriptor } from "../shared/routes.js";
|
|
9
9
|
import { DrawerCollapsedContext } from "./drawer-collapsed-context.js";
|
|
@@ -29,26 +29,33 @@ const didNavigateToRow = (navigation: DrawerNavigationHelpers, state: Navigation
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const useDrawerItemPress = (navigation: DrawerNavigationHelpers, isCollapsed: boolean): RowActivated =>
|
|
32
|
-
useCallback(
|
|
33
|
-
|
|
32
|
+
useCallback(
|
|
33
|
+
(row: Gtk.ListBoxRow) => {
|
|
34
|
+
const state = navigation.getState();
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
if (!didNavigateToRow(navigation, state, row.getIndex())) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (isCollapsed) {
|
|
41
|
+
navigation.dispatch({ ...DrawerActions.closeDrawer(), target: state.key });
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
[navigation, isCollapsed],
|
|
45
|
+
);
|
|
43
46
|
|
|
44
47
|
const DrawerItem = ({ descriptor }: { descriptor: DrawerDescriptor }): ReactNode => {
|
|
45
48
|
const { route, options } = descriptor;
|
|
49
|
+
const label = options.drawerLabel ?? options.title ?? route.name;
|
|
50
|
+
const [labelWidget, setLabelWidget] = useState<Gtk.Label | null>(null);
|
|
46
51
|
|
|
47
52
|
return (
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
<GtkListBoxRow accessibleLabelledBy={labelWidget === null ? undefined : [labelWidget]}>
|
|
54
|
+
<GtkBox spacing={12}>
|
|
55
|
+
{options.drawerIcon === undefined ? null : <GtkImage iconName={options.drawerIcon} />}
|
|
56
|
+
<GtkLabel ref={setLabelWidget} label={label} useUnderline={options.useUnderline ?? false} xalign={0} />
|
|
57
|
+
</GtkBox>
|
|
58
|
+
</GtkListBoxRow>
|
|
52
59
|
);
|
|
53
60
|
};
|
|
54
61
|
|
|
@@ -84,7 +84,9 @@ const withShownSidebar = (router: DrawerRouterInstance, isCollapsed: () => boole
|
|
|
84
84
|
keepSidebarShown(state, router.getStateForRouteFocus(state, key), isCollapsed()),
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
const createDrawerRouter =
|
|
88
|
-
|
|
87
|
+
const createDrawerRouter =
|
|
88
|
+
(isCollapsed: () => boolean): DrawerRouterFactory =>
|
|
89
|
+
(options) =>
|
|
90
|
+
withShownSidebar(DrawerRouter(options), isCollapsed);
|
|
89
91
|
|
|
90
92
|
export { createDrawerRouter, type DrawerRouterFactory };
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import type { DrawerStatus,
|
|
1
|
+
import type { DrawerNavigationState, DrawerStatus, ParamListBase } from "@react-navigation/core";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const isDrawerEntry = (entry: unknown): entry is DrawerHistoryEntry =>
|
|
6
|
-
typeof entry === "object" && entry !== null && "type" in entry && entry.type === "drawer";
|
|
7
|
-
|
|
8
|
-
const getDrawerStatus = (state: NavigationState): DrawerStatus => {
|
|
9
|
-
const history: readonly unknown[] = state.history ?? [];
|
|
10
|
-
const entry = history.findLast(isDrawerEntry);
|
|
11
|
-
|
|
12
|
-
if (entry !== undefined) {
|
|
13
|
-
return entry.status;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return "default" in state && state.default === "open" ? "open" : "closed";
|
|
17
|
-
};
|
|
3
|
+
const getDrawerStatus = (state: DrawerNavigationState<ParamListBase>): DrawerStatus =>
|
|
4
|
+
state.history.findLast((entry) => entry.type === "drawer")?.status ?? state.default;
|
|
18
5
|
|
|
19
6
|
export { getDrawerStatus };
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { DrawerNavigationState, ParamListBase } from "@react-navigation/core";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
-
import {
|
|
5
|
-
AdwHeaderBar,
|
|
6
|
-
AdwOverlaySplitView,
|
|
7
|
-
AdwToolbarView,
|
|
8
|
-
AdwViewStack,
|
|
9
|
-
AdwWindowTitle,
|
|
10
|
-
} from "@gtkx/jsx/adw";
|
|
4
|
+
import { AdwHeaderBar, AdwOverlaySplitView, AdwToolbarView, AdwViewStack, AdwWindowTitle } from "@gtkx/jsx/adw";
|
|
11
5
|
import { GtkButton, GtkScrolledWindow } from "@gtkx/jsx/gtk";
|
|
12
6
|
import { DrawerActions } from "@react-navigation/core";
|
|
13
7
|
import { useCallback, useEffect, useRef } from "react";
|
|
@@ -21,7 +15,6 @@ import type {
|
|
|
21
15
|
import { HeaderBar } from "../shared/header-bar.js";
|
|
22
16
|
import { getFocusedRoute, requireDescriptor } from "../shared/routes.js";
|
|
23
17
|
import { ScenePage } from "../shared/scene-page.js";
|
|
24
|
-
import { useLoadedRoutes } from "../shared/use-loaded-routes.js";
|
|
25
18
|
import { usePopToTopOnBlur } from "../shared/use-pop-to-top-on-blur.js";
|
|
26
19
|
import { DrawerCollapsedContext } from "./drawer-collapsed-context.js";
|
|
27
20
|
import { DrawerItemList } from "./drawer-item-list.js";
|
|
@@ -40,23 +33,24 @@ type DrawerHeaderProps = {
|
|
|
40
33
|
|
|
41
34
|
type DrawerPageProps = {
|
|
42
35
|
descriptor: DrawerDescriptor;
|
|
36
|
+
isFocused: boolean;
|
|
43
37
|
isLoaded: boolean;
|
|
44
38
|
};
|
|
45
39
|
|
|
46
40
|
const PACK_TYPES = { start: Gtk.PackType.START, end: Gtk.PackType.END } as const;
|
|
47
41
|
|
|
48
42
|
const useSidebarSync = (navigation: DrawerNavigationHelpers): ((isShown: boolean | null) => void) =>
|
|
49
|
-
useCallback(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
navigation
|
|
59
|
-
|
|
43
|
+
useCallback(
|
|
44
|
+
(isShown: boolean | null) => {
|
|
45
|
+
if (isShown === null) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const action = isShown ? DrawerActions.openDrawer() : DrawerActions.closeDrawer();
|
|
50
|
+
navigation.dispatch({ ...action, target: navigation.getState().key });
|
|
51
|
+
},
|
|
52
|
+
[navigation],
|
|
53
|
+
);
|
|
60
54
|
|
|
61
55
|
const useCloseOnNavigate = (
|
|
62
56
|
state: DrawerNavigationState<ParamListBase>,
|
|
@@ -70,7 +64,7 @@ const useCloseOnNavigate = (
|
|
|
70
64
|
const hasChanged = previousKeyRef.current !== focusedKey;
|
|
71
65
|
previousKeyRef.current = focusedKey;
|
|
72
66
|
|
|
73
|
-
if (hasChanged && isCollapsed
|
|
67
|
+
if (hasChanged && isCollapsed) {
|
|
74
68
|
navigation.dispatch({ ...DrawerActions.closeDrawer(), target: navigation.getState().key });
|
|
75
69
|
}
|
|
76
70
|
}, [focusedKey, isCollapsed, navigation]);
|
|
@@ -115,13 +109,14 @@ const DrawerHeader = ({ descriptor, navigation }: DrawerHeaderProps): ReactNode
|
|
|
115
109
|
);
|
|
116
110
|
};
|
|
117
111
|
|
|
118
|
-
const DrawerPage = ({ descriptor, isLoaded }: DrawerPageProps): ReactNode => {
|
|
112
|
+
const DrawerPage = ({ descriptor, isFocused, isLoaded }: DrawerPageProps): ReactNode => {
|
|
119
113
|
const { route, options } = descriptor;
|
|
120
114
|
|
|
121
115
|
return (
|
|
122
116
|
<ScenePage
|
|
123
117
|
name={route.key}
|
|
124
118
|
title={options.title ?? route.name}
|
|
119
|
+
isFocused={isFocused}
|
|
125
120
|
isLoaded={isLoaded || options.lazy === false}
|
|
126
121
|
render={() => descriptor.render()}
|
|
127
122
|
/>
|
|
@@ -132,7 +127,6 @@ const DrawerView = ({ state, navigation, descriptors, drawerContent, ...config }
|
|
|
132
127
|
const { collapsed = false, sidebarPosition = "start", pinSidebar, minSidebarWidth, maxSidebarWidth } = config;
|
|
133
128
|
const focused = getFocusedRoute(state);
|
|
134
129
|
const descriptor = requireDescriptor(descriptors, focused.key);
|
|
135
|
-
const loaded = useLoadedRoutes(focused.key, state.preloadedRouteKeys);
|
|
136
130
|
const onShowSidebarChanged = useSidebarSync(navigation);
|
|
137
131
|
const contentProps = { state, navigation, descriptors };
|
|
138
132
|
const sidebar = drawerContent === undefined ? <DrawerContent {...contentProps} /> : drawerContent(contentProps);
|
|
@@ -158,7 +152,8 @@ const DrawerView = ({ state, navigation, descriptors, drawerContent, ...config }
|
|
|
158
152
|
<DrawerPage
|
|
159
153
|
key={route.key}
|
|
160
154
|
descriptor={requireDescriptor(descriptors, route.key)}
|
|
161
|
-
|
|
155
|
+
isFocused={route.key === focused.key}
|
|
156
|
+
isLoaded={route.key === focused.key || state.preloadedRouteKeys.includes(route.key)}
|
|
162
157
|
/>
|
|
163
158
|
))}
|
|
164
159
|
</AdwViewStack>
|
package/src/drawer/types.ts
CHANGED
|
@@ -29,6 +29,8 @@ type DrawerNavigationOptions = HeaderOptions & {
|
|
|
29
29
|
header?: (props: DrawerHeaderProps) => ReactNode;
|
|
30
30
|
/** Label shown in the sidebar; defaults to `title`, then to the route name. */
|
|
31
31
|
drawerLabel?: string;
|
|
32
|
+
/** Whether underscores in the sidebar label indicate mnemonics; defaults to `false`. */
|
|
33
|
+
useUnderline?: boolean;
|
|
32
34
|
/** Icon name shown next to the sidebar label. */
|
|
33
35
|
drawerIcon?: string;
|
|
34
36
|
/** Whether the screen mounts on first focus instead of at startup; defaults to `true`. */
|
|
@@ -49,7 +51,8 @@ type DrawerNavigationProp<
|
|
|
49
51
|
DrawerNavigationState<ParamList>,
|
|
50
52
|
DrawerNavigationOptions,
|
|
51
53
|
DrawerNavigationEventMap
|
|
52
|
-
> &
|
|
54
|
+
> &
|
|
55
|
+
DrawerActionHelpers<ParamList>;
|
|
53
56
|
|
|
54
57
|
/** Props a drawer screen component receives. */
|
|
55
58
|
type DrawerScreenProps<
|
|
@@ -124,8 +127,8 @@ type DrawerNavigatorProps = DefaultNavigatorOptions<
|
|
|
124
127
|
DrawerNavigationEventMap,
|
|
125
128
|
DrawerNavigationProp<ParamListBase>
|
|
126
129
|
> &
|
|
127
|
-
DrawerRouterOptions &
|
|
128
|
-
DrawerNavigationConfig;
|
|
130
|
+
DrawerRouterOptions &
|
|
131
|
+
DrawerNavigationConfig;
|
|
129
132
|
|
|
130
133
|
export type {
|
|
131
134
|
DrawerContentProps,
|
package/src/index.ts
CHANGED
|
@@ -61,11 +61,7 @@ export type {
|
|
|
61
61
|
StackScreenProps,
|
|
62
62
|
StackTransitionData,
|
|
63
63
|
} from "./stack/types.js";
|
|
64
|
-
export {
|
|
65
|
-
createStaticNavigation,
|
|
66
|
-
type StaticNavigationProps,
|
|
67
|
-
type StaticNavigationTree,
|
|
68
|
-
} from "./static-navigation.js";
|
|
64
|
+
export { createStaticNavigation, type StaticNavigationProps, type StaticNavigationTree } from "./static-navigation.js";
|
|
69
65
|
export { createTabNavigator, createTabScreen, TabNavigator, type TabTypeBag } from "./tabs/create-tab-navigator.js";
|
|
70
66
|
export type {
|
|
71
67
|
TabDescriptor,
|
|
@@ -21,12 +21,12 @@ const HeaderBar = ({ options, titleWidget, start, showBackButton }: HeaderBarPro
|
|
|
21
21
|
<AdwHeaderBar
|
|
22
22
|
showBackButton={showBackButton ?? true}
|
|
23
23
|
titleWidget={resolveTitleWidget(options, titleWidget)}
|
|
24
|
-
start={
|
|
24
|
+
start={
|
|
25
25
|
<>
|
|
26
26
|
{start}
|
|
27
27
|
{options.headerStart}
|
|
28
28
|
</>
|
|
29
|
-
|
|
29
|
+
}
|
|
30
30
|
end={options.headerEnd}
|
|
31
31
|
/>
|
|
32
32
|
);
|