@gtkx/navigation 2.0.0-beta.11 → 2.0.0-beta.13
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 +3 -3
- package/dist/drawer/create-drawer-navigator.d.ts +3 -1
- package/dist/drawer/create-drawer-navigator.d.ts.map +1 -1
- package/dist/drawer/create-drawer-navigator.js +10 -10
- 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 +3 -2
- 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.map +1 -1
- package/dist/drawer/drawer-view.d.ts.map +1 -1
- package/dist/drawer/drawer-view.js +6 -6
- 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 +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -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 +4 -7
- package/dist/shared/scene-page.js.map +1 -1
- package/dist/shared/use-has-loaded.d.ts +3 -0
- package/dist/shared/use-has-loaded.d.ts.map +1 -0
- package/dist/shared/use-has-loaded.js +10 -0
- package/dist/shared/use-has-loaded.js.map +1 -0
- package/dist/shared/use-pop-to-top-on-blur.d.ts.map +1 -1
- package/dist/split-view/create-split-view-navigator.d.ts +7 -2
- package/dist/split-view/create-split-view-navigator.d.ts.map +1 -1
- package/dist/split-view/create-split-view-navigator.js +2 -6
- package/dist/split-view/create-split-view-navigator.js.map +1 -1
- package/dist/split-view/split-view-collapsed.d.ts +11 -0
- package/dist/split-view/split-view-collapsed.d.ts.map +1 -0
- package/dist/split-view/split-view-collapsed.js +17 -0
- package/dist/split-view/split-view-collapsed.js.map +1 -0
- package/dist/split-view/split-view.d.ts.map +1 -1
- package/dist/split-view/split-view.js +41 -20
- package/dist/split-view/split-view.js.map +1 -1
- package/dist/split-view/types.d.ts +9 -2
- 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 +3 -1
- package/dist/stack/create-stack-navigator.d.ts.map +1 -1
- package/dist/stack/create-stack-navigator.js +0 -1
- 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 +3 -5
- 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 +6 -14
- 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/tab-view/create-tab-view-navigator.d.ts +32 -0
- package/dist/tab-view/create-tab-view-navigator.d.ts.map +1 -0
- package/dist/tab-view/create-tab-view-navigator.js +21 -0
- package/dist/tab-view/create-tab-view-navigator.js.map +1 -0
- package/dist/tab-view/page-registry.d.ts +34 -0
- package/dist/tab-view/page-registry.d.ts.map +1 -0
- package/dist/tab-view/page-registry.js +70 -0
- package/dist/tab-view/page-registry.js.map +1 -0
- package/dist/tab-view/tab-view-host.d.ts +25 -0
- package/dist/tab-view/tab-view-host.d.ts.map +1 -0
- package/dist/tab-view/tab-view-host.js +284 -0
- package/dist/tab-view/tab-view-host.js.map +1 -0
- package/dist/tab-view/tab-view-router.d.ts +34 -0
- package/dist/tab-view/tab-view-router.d.ts.map +1 -0
- package/dist/tab-view/tab-view-router.js +359 -0
- package/dist/tab-view/tab-view-router.js.map +1 -0
- package/dist/tab-view/types.d.ts +240 -0
- package/dist/tab-view/types.d.ts.map +1 -0
- package/dist/tab-view/types.js +2 -0
- package/dist/tab-view/types.js.map +1 -0
- package/dist/tabs/create-tab-navigator.d.ts +3 -1
- package/dist/tabs/create-tab-navigator.d.ts.map +1 -1
- package/dist/tabs/create-tab-navigator.js +0 -1
- 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 -7
- 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 +2 -2
- package/dist/theme.js.map +1 -1
- package/package.json +9 -19
- package/src/drawer/create-drawer-navigator.tsx +23 -11
- package/src/drawer/drawer-item-list.tsx +16 -12
- package/src/drawer/drawer-router.ts +4 -2
- package/src/drawer/drawer-view.tsx +18 -18
- package/src/drawer/types.ts +6 -3
- package/src/index.ts +31 -5
- package/src/shared/header-bar.tsx +2 -2
- package/src/shared/scene-page.tsx +7 -8
- package/src/shared/use-has-loaded.ts +13 -0
- package/src/split-view/create-split-view-navigator.tsx +16 -1
- package/src/split-view/split-view-collapsed.ts +21 -0
- package/src/split-view/split-view.tsx +102 -49
- package/src/split-view/types.ts +13 -5
- package/src/stack/create-stack-navigator.tsx +11 -1
- package/src/stack/stack-pages.ts +14 -12
- package/src/stack/stack-view.tsx +10 -16
- package/src/stack/types.ts +4 -3
- package/src/tab-view/create-tab-view-navigator.tsx +122 -0
- package/src/tab-view/page-registry.ts +139 -0
- package/src/tab-view/tab-view-host.tsx +474 -0
- package/src/tab-view/tab-view-router.ts +528 -0
- package/src/tab-view/types.ts +291 -0
- package/src/tabs/create-tab-navigator.tsx +11 -1
- package/src/tabs/tab-view.tsx +28 -22
- package/src/tabs/types.ts +6 -3
- package/src/theme.ts +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pop-to-top-on-blur.d.ts","sourceRoot":"","sources":["../../src/shared/use-pop-to-top-on-blur.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIhG,KAAK,WAAW,GAAG;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAChD,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AAehE,QAAA,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"use-pop-to-top-on-blur.d.ts","sourceRoot":"","sources":["../../src/shared/use-pop-to-top-on-blur.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIhG,KAAK,WAAW,GAAG;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAChD,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AAehE,QAAA,MAAM,iBAAiB,UACZ,eAAe,eACT,eAAe,cAChB,iBAAiB,CAAC,aAAa,CAAC,KAC7C,IAkBF,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -23,11 +23,16 @@ type SplitViewTypeBag<ParamList extends ParamListBase = ParamListBase, Navigator
|
|
|
23
23
|
/** Declares a typed screen of a split view navigator for the static configuration API. */
|
|
24
24
|
declare const createSplitViewScreen: StaticScreenFactory<SplitViewTypeBag>;
|
|
25
25
|
/** Renders the screens of a {@link createSplitViewNavigator} in an `AdwNavigationSplitView`. */
|
|
26
|
-
declare function SplitViewNavigator({ collapsed, contentPlaceholder, sidebarPosition, minSidebarWidth, maxSidebarWidth, sidebarWidthFraction, popOnEscape, ...options }: SplitViewNavigatorProps): ReactNode;
|
|
26
|
+
declare function SplitViewNavigator({ collapsed, collapseCondition, contentPlaceholder, sidebarPosition, minSidebarWidth, maxSidebarWidth, sidebarWidthFraction, popOnEscape, ...options }: SplitViewNavigatorProps): ReactNode;
|
|
27
27
|
/**
|
|
28
28
|
* Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar
|
|
29
29
|
* pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.
|
|
30
30
|
*/
|
|
31
|
-
declare function createSplitViewNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = SplitViewTypeBag<ParamList, NavigatorID
|
|
31
|
+
declare function createSplitViewNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = SplitViewTypeBag<ParamList, NavigatorID>>(): TypedNavigator<TypeBag, undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar
|
|
34
|
+
* pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.
|
|
35
|
+
*/
|
|
36
|
+
declare function createSplitViewNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = SplitViewTypeBag<ParamList, NavigatorID>, const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>>(config: Config): TypedNavigator<TypeBag, Config>;
|
|
32
37
|
export { createSplitViewNavigator, createSplitViewScreen, SplitViewNavigator, type SplitViewTypeBag };
|
|
33
38
|
//# sourceMappingURL=create-split-view-navigator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-split-view-navigator.d.ts","sourceRoot":"","sources":["../../src/split-view/create-split-view-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EAEb,oBAAoB,EAEpB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACR,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EAC1B,MAAM,YAAY,CAAC;AAIpB,qFAAqF;AACrF,KAAK,gBAAgB,CACjB,SAAS,SAAS,aAAa,GAAG,aAAa,EAC/C,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3D;IACA,oCAAoC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,6BAA6B;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,oCAAoC;IACpC,KAAK,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACvC,0BAA0B;IAC1B,aAAa,EAAE,0BAA0B,CAAC;IAC1C,kCAAkC;IAClC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,mCAAmC;IACnC,cAAc,EAAE;SACX,SAAS,IAAI,MAAM,SAAS,GAAG,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;KAC7F,CAAC;IACF,+BAA+B;IAC/B,SAAS,EAAE,OAAO,kBAAkB,CAAC;CACxC,CAAC;AAEF,0FAA0F;AAC1F,QAAA,MAAM,qBAAqB,EAAE,mBAAmB,CAAC,gBAAgB,CAA2C,CAAC;AAE7G,gGAAgG;AAChG,iBAAS,kBAAkB,CAAC,EACxB,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,GAAG,OAAO,EACb,EAAE,uBAAuB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"create-split-view-navigator.d.ts","sourceRoot":"","sources":["../../src/split-view/create-split-view-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EA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MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,KACpF,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACxC;;;GAGG;AACH,iBAAS,wBAAwB,CAC7B,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,EACrF,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EACpE,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAQnD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
|
@@ -5,14 +5,10 @@ import { SplitView } from "./split-view.js";
|
|
|
5
5
|
/** Declares a typed screen of a split view navigator for the static configuration API. */
|
|
6
6
|
const createSplitViewScreen = createScreenFactory();
|
|
7
7
|
/** Renders the screens of a {@link createSplitViewNavigator} in an `AdwNavigationSplitView`. */
|
|
8
|
-
function SplitViewNavigator({ collapsed, contentPlaceholder, sidebarPosition, minSidebarWidth, maxSidebarWidth, sidebarWidthFraction, popOnEscape, ...options }) {
|
|
8
|
+
function SplitViewNavigator({ collapsed, collapseCondition, contentPlaceholder, sidebarPosition, minSidebarWidth, maxSidebarWidth, sidebarWidthFraction, popOnEscape, ...options }) {
|
|
9
9
|
const { state, describe, descriptors, navigation, render } = useNavigationBuilder(splitViewRouter, options);
|
|
10
|
-
return render(_jsx(SplitView, { state: state, navigation: navigation, descriptors: descriptors, describe: describe, collapsed: collapsed, contentPlaceholder: contentPlaceholder, sidebarPosition: sidebarPosition, minSidebarWidth: minSidebarWidth, maxSidebarWidth: maxSidebarWidth, sidebarWidthFraction: sidebarWidthFraction, popOnEscape: popOnEscape }));
|
|
10
|
+
return render(_jsx(SplitView, { state: state, navigation: navigation, descriptors: descriptors, describe: describe, collapsed: collapsed, collapseCondition: collapseCondition, contentPlaceholder: contentPlaceholder, sidebarPosition: sidebarPosition, minSidebarWidth: minSidebarWidth, maxSidebarWidth: maxSidebarWidth, sidebarWidthFraction: sidebarWidthFraction, popOnEscape: popOnEscape }));
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar
|
|
14
|
-
* pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.
|
|
15
|
-
*/
|
|
16
12
|
function createSplitViewNavigator(config) {
|
|
17
13
|
return createNavigatorFactory(SplitViewNavigator)(config);
|
|
18
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-split-view-navigator.js","sourceRoot":"","sources":["../../src/split-view/create-split-view-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO3G,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAyB5C,0FAA0F;AAC1F,MAAM,qBAAqB,GAA0C,mBAAmB,EAAoB,CAAC;AAE7G,gGAAgG;AAChG,SAAS,kBAAkB,CAAC,EACxB,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,GAAG,OAAO,EACY;IACtB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAM/E,eAAe,EAAE,OAAO,CAAC,CAAC;IAE5B,OAAO,MAAM,CACT,KAAC,SAAS,IACN,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,GAC1B,CACL,CAAC;AACN,CAAC;
|
|
1
|
+
{"version":3,"file":"create-split-view-navigator.js","sourceRoot":"","sources":["../../src/split-view/create-split-view-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO3G,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAyB5C,0FAA0F;AAC1F,MAAM,qBAAqB,GAA0C,mBAAmB,EAAoB,CAAC;AAE7G,gGAAgG;AAChG,SAAS,kBAAkB,CAAC,EACxB,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,GAAG,OAAO,EACY;IACtB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAM/E,eAAe,EAAE,OAAO,CAAC,CAAC;IAE5B,OAAO,MAAM,CACT,KAAC,SAAS,IACN,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,GAC1B,CACL,CAAC;AACN,CAAC;AAqBD,SAAS,wBAAwB,CAG/B,MAAe;IACb,OAAO,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAoC,CAAC;AACjG,CAAC;AAED,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,kBAAkB,EAAyB,CAAC","sourcesContent":["import type {\n NavigatorTypeBagBase,\n ParamListBase,\n StackActionHelpers,\n StackNavigationState,\n StackRouterOptions,\n StaticConfig,\n StaticScreenFactory,\n TypedNavigator,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport { createNavigatorFactory, createScreenFactory, useNavigationBuilder } from \"@react-navigation/core\";\nimport type {\n SplitViewNavigationEventMap,\n SplitViewNavigationOptions,\n SplitViewNavigationProp,\n SplitViewNavigatorProps,\n} from \"./types.js\";\nimport { splitViewRouter } from \"./split-view-router.js\";\nimport { SplitView } from \"./split-view.js\";\n\n/** Type bag describing the split view navigator to React Navigation's typed APIs. */\ntype SplitViewTypeBag<\n ParamList extends ParamListBase = ParamListBase,\n NavigatorID extends string | undefined = string | undefined,\n> = {\n /** Route names and their params. */\n ParamList: ParamList;\n /** Optional navigator id. */\n NavigatorID: NavigatorID;\n /** Shape of the navigator state. */\n State: StackNavigationState<ParamList>;\n /** Per-screen options. */\n ScreenOptions: SplitViewNavigationOptions;\n /** Events the navigator emits. */\n EventMap: SplitViewNavigationEventMap;\n /** Navigation object per route. */\n NavigationList: {\n [RouteName in keyof ParamList]: SplitViewNavigationProp<ParamList, RouteName, NavigatorID>;\n };\n /** The navigator component. */\n Navigator: typeof SplitViewNavigator;\n};\n\n/** Declares a typed screen of a split view navigator for the static configuration API. */\nconst createSplitViewScreen: StaticScreenFactory<SplitViewTypeBag> = createScreenFactory<SplitViewTypeBag>();\n\n/** Renders the screens of a {@link createSplitViewNavigator} in an `AdwNavigationSplitView`. */\nfunction SplitViewNavigator({\n collapsed,\n collapseCondition,\n contentPlaceholder,\n sidebarPosition,\n minSidebarWidth,\n maxSidebarWidth,\n sidebarWidthFraction,\n popOnEscape,\n ...options\n}: SplitViewNavigatorProps): ReactNode {\n const { state, describe, descriptors, navigation, render } = useNavigationBuilder<\n StackNavigationState<ParamListBase>,\n StackRouterOptions,\n StackActionHelpers<ParamListBase>,\n SplitViewNavigationOptions,\n SplitViewNavigationEventMap\n >(splitViewRouter, options);\n\n return render(\n <SplitView\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n collapsed={collapsed}\n collapseCondition={collapseCondition}\n contentPlaceholder={contentPlaceholder}\n sidebarPosition={sidebarPosition}\n minSidebarWidth={minSidebarWidth}\n maxSidebarWidth={maxSidebarWidth}\n sidebarWidthFraction={sidebarWidthFraction}\n popOnEscape={popOnEscape}\n />,\n );\n}\n\n/**\n * Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar\n * pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.\n */\nfunction createSplitViewNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = SplitViewTypeBag<ParamList, NavigatorID>,\n>(): TypedNavigator<TypeBag, undefined>;\n/**\n * Creates a master/detail navigator rendered with `AdwNavigationSplitView`: the first screen fills the sidebar\n * pane, the rest are a stack in the content pane, and a narrow window collapses the two into one.\n */\nfunction createSplitViewNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = SplitViewTypeBag<ParamList, NavigatorID>,\n const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,\n>(config: Config): TypedNavigator<TypeBag, Config>;\nfunction createSplitViewNavigator<\n const TypeBag extends NavigatorTypeBagBase,\n const Config extends StaticConfig<TypeBag> | undefined,\n>(config?: Config): TypedNavigator<TypeBag, Config> {\n return createNavigatorFactory(SplitViewNavigator)(config) as TypedNavigator<TypeBag, Config>;\n}\n\nexport { createSplitViewNavigator, createSplitViewScreen, SplitViewNavigator, type SplitViewTypeBag };\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Context } from "react";
|
|
2
|
+
declare const SplitViewCollapsedContext: Context<boolean | null>;
|
|
3
|
+
/**
|
|
4
|
+
* Returns whether the surrounding split view navigator shows one pane at a time, for its sidebar and content
|
|
5
|
+
* screens. It follows the split view's `collapsed` property, so it holds for both the `collapsed` prop and
|
|
6
|
+
* `collapseCondition`, and changes after libadwaita has laid out the collapsed or widened panes. Use it to
|
|
7
|
+
* adapt a screen's presentation, such as switching an `AdwSidebar` to `Adw.SidebarMode.PAGE`.
|
|
8
|
+
*/
|
|
9
|
+
declare const useSplitViewCollapsed: () => boolean;
|
|
10
|
+
export { SplitViewCollapsedContext, useSplitViewCollapsed };
|
|
11
|
+
//# sourceMappingURL=split-view-collapsed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-view-collapsed.d.ts","sourceRoot":"","sources":["../../src/split-view/split-view-collapsed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAA6B,MAAM,OAAO,CAAC;AAEhE,QAAA,MAAM,yBAAyB,EAAE,OAAO,CAAC,OAAO,GAAG,IAAI,CAAuC,CAAC;AAE/F;;;;;GAKG;AACH,QAAA,MAAM,qBAAqB,QAAO,OAQjC,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const SplitViewCollapsedContext = createContext(null);
|
|
3
|
+
/**
|
|
4
|
+
* Returns whether the surrounding split view navigator shows one pane at a time, for its sidebar and content
|
|
5
|
+
* screens. It follows the split view's `collapsed` property, so it holds for both the `collapsed` prop and
|
|
6
|
+
* `collapseCondition`, and changes after libadwaita has laid out the collapsed or widened panes. Use it to
|
|
7
|
+
* adapt a screen's presentation, such as switching an `AdwSidebar` to `Adw.SidebarMode.PAGE`.
|
|
8
|
+
*/
|
|
9
|
+
const useSplitViewCollapsed = () => {
|
|
10
|
+
const isCollapsed = useContext(SplitViewCollapsedContext);
|
|
11
|
+
if (isCollapsed === null) {
|
|
12
|
+
throw new Error("useSplitViewCollapsed must be called inside a split view navigator.");
|
|
13
|
+
}
|
|
14
|
+
return isCollapsed;
|
|
15
|
+
};
|
|
16
|
+
export { SplitViewCollapsedContext, useSplitViewCollapsed };
|
|
17
|
+
//# sourceMappingURL=split-view-collapsed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-view-collapsed.js","sourceRoot":"","sources":["../../src/split-view/split-view-collapsed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEhE,MAAM,yBAAyB,GAA4B,aAAa,CAAiB,IAAI,CAAC,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,GAAY,EAAE;IACxC,MAAM,WAAW,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC;IAE1D,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import { type Context, createContext, useContext } from \"react\";\n\nconst SplitViewCollapsedContext: Context<boolean | null> = createContext<boolean | null>(null);\n\n/**\n * Returns whether the surrounding split view navigator shows one pane at a time, for its sidebar and content\n * screens. It follows the split view's `collapsed` property, so it holds for both the `collapsed` prop and\n * `collapseCondition`, and changes after libadwaita has laid out the collapsed or widened panes. Use it to\n * adapt a screen's presentation, such as switching an `AdwSidebar` to `Adw.SidebarMode.PAGE`.\n */\nconst useSplitViewCollapsed = (): boolean => {\n const isCollapsed = useContext(SplitViewCollapsedContext);\n\n if (isCollapsed === null) {\n throw new Error(\"useSplitViewCollapsed must be called inside a split view navigator.\");\n }\n\n return isCollapsed;\n};\n\nexport { SplitViewCollapsedContext, useSplitViewCollapsed };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-view.d.ts","sourceRoot":"","sources":["../../src/split-view/split-view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"split-view.d.ts","sourceRoot":"","sources":["../../src/split-view/split-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBvC,OAAO,KAAK,EACR,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC7B,MAAM,YAAY,CAAC;AAMpB,KAAK,cAAc,GAAG,yBAAyB,GAAG;IAC9C,KAAK,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC3C,UAAU,EAAE,0BAA0B,CAAC;IACvC,WAAW,EAAE,sBAAsB,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,EAAE,aAAa,EAAE,OAAO,KAAK,mBAAmB,CAAC;CAC9F,CAAC;AAyGF,QAAA,MAAM,SAAS,UAAW,cAAc,KAAG,SAgD1C,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as Adw from "@gtkx/gi/adw";
|
|
2
3
|
import * as Gdk from "@gtkx/gi/gdk";
|
|
4
|
+
import * as GObject from "@gtkx/gi/gobject";
|
|
3
5
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
-
import { AdwNavigationPage, AdwNavigationSplitView, AdwToolbarView } from "@gtkx/jsx/adw";
|
|
6
|
+
import { AdwBreakpoint, AdwBreakpointBin, AdwHeaderBar, AdwNavigationPage, AdwNavigationSplitView, AdwToolbarView, } from "@gtkx/jsx/adw";
|
|
5
7
|
import { GtkEventControllerKey } from "@gtkx/jsx/gtk";
|
|
8
|
+
import { useProperty } from "@gtkx/react";
|
|
6
9
|
import { StackActions } from "@react-navigation/core";
|
|
7
|
-
import { useCallback,
|
|
10
|
+
import { useCallback, useLayoutEffect, useMemo, useState } from "react";
|
|
8
11
|
import { HeaderBar } from "../shared/header-bar.js";
|
|
9
12
|
import { requireDescriptor } from "../shared/routes.js";
|
|
10
13
|
import { StackView } from "../stack/stack-view.js";
|
|
14
|
+
import { SplitViewCollapsedContext } from "./split-view-collapsed.js";
|
|
11
15
|
const PACK_TYPES = { start: Gtk.PackType.START, end: Gtk.PackType.END };
|
|
12
16
|
const CONTENT_TITLE = "Content";
|
|
13
17
|
const ESCAPE_KEYVAL = Gdk.KEY_Escape;
|
|
@@ -23,40 +27,57 @@ const popContent = (navigation) => {
|
|
|
23
27
|
const state = navigation.getState();
|
|
24
28
|
navigation.dispatch({ ...StackActions.pop(state.routes.length - 1), target: state.key });
|
|
25
29
|
};
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
const collapsedValue = () => {
|
|
31
|
+
const value = new GObject.Value();
|
|
32
|
+
value.init(GObject.TYPE_BOOLEAN);
|
|
33
|
+
value.setBoolean(true);
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
36
|
+
const useCollapseBreakpoint = (view, collapseCondition) => {
|
|
37
|
+
const [breakpoint, setBreakpoint] = useState(null);
|
|
38
|
+
const condition = useMemo(() => (collapseCondition === undefined ? null : Adw.BreakpointCondition.parse(collapseCondition)), [collapseCondition]);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
if (breakpoint === null || view === null) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
breakpoint.addSetter(view, "collapsed", collapsedValue());
|
|
44
|
+
}, [view, breakpoint]);
|
|
45
|
+
return condition === null ? null : _jsx(AdwBreakpoint, { ref: setBreakpoint, condition: condition });
|
|
46
|
+
};
|
|
47
|
+
const settleShowContent = (view, isShown, isSettled) => {
|
|
48
|
+
if (isSettled !== isShown && view !== null) {
|
|
49
|
+
view.setShowContent(isSettled);
|
|
29
50
|
}
|
|
30
51
|
};
|
|
31
|
-
const useContentSync = (
|
|
52
|
+
const useContentSync = (view, navigation) => useCallback((isShown) => {
|
|
32
53
|
if (isShown === null || isShown === hasContent(navigation.getState())) {
|
|
33
54
|
return;
|
|
34
55
|
}
|
|
35
56
|
if (!isShown) {
|
|
36
57
|
popContent(navigation);
|
|
37
58
|
}
|
|
38
|
-
settleShowContent(
|
|
39
|
-
}, [
|
|
59
|
+
settleShowContent(view, isShown, hasContent(navigation.getState()));
|
|
60
|
+
}, [view, navigation]);
|
|
40
61
|
const EscapeGuard = () => (_jsx(GtkEventControllerKey, { propagationPhase: Gtk.PropagationPhase.BUBBLE, onKeyPressed: (keyval) => keyval === ESCAPE_KEYVAL }));
|
|
41
62
|
const SidebarPage = ({ descriptor }) => {
|
|
42
63
|
const { route, options, navigation } = descriptor;
|
|
43
64
|
if (options.headerShown === false) {
|
|
44
65
|
return _jsx(AdwNavigationPage, { title: options.title ?? route.name, children: descriptor.render() });
|
|
45
66
|
}
|
|
46
|
-
const topBar = options.header === undefined
|
|
47
|
-
|
|
48
|
-
: _jsx(_Fragment, { children: options.header({ route, navigation, options, back: undefined }) });
|
|
49
|
-
return (_jsx(AdwNavigationPage, { title: options.title ?? route.name, children: _jsx(AdwToolbarView, { topBar: topBar, children: descriptor.render() }) }));
|
|
67
|
+
const topBar = options.header === undefined ? (_jsx(HeaderBar, { options: options, showBackButton: false })) : (_jsx(_Fragment, { children: options.header({ route, navigation, options, back: undefined }) }));
|
|
68
|
+
return (_jsx(AdwNavigationPage, { title: options.title ?? route.name, children: _jsx(AdwToolbarView, { top: topBar, children: descriptor.render() }) }));
|
|
50
69
|
};
|
|
51
70
|
const SplitView = (props) => {
|
|
52
|
-
const { state, navigation, descriptors, describe, contentPlaceholder } = props;
|
|
53
|
-
const {
|
|
54
|
-
const
|
|
55
|
-
const onShowContentChanged = useContentSync(
|
|
71
|
+
const { state, navigation, descriptors, describe, contentPlaceholder, collapseCondition } = props;
|
|
72
|
+
const { sidebarPosition = "start", minSidebarWidth, maxSidebarWidth } = props;
|
|
73
|
+
const [view, setView] = useState(null);
|
|
74
|
+
const onShowContentChanged = useContentSync(view, navigation);
|
|
75
|
+
const collapseBreakpoint = useCollapseBreakpoint(view, collapseCondition);
|
|
56
76
|
const sidebar = requireDescriptor(descriptors, state.routes[0]?.key ?? "");
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
const collapsed = collapseCondition === undefined ? (props.collapsed ?? false) : undefined;
|
|
78
|
+
const isCollapsed = useProperty(view, "collapsed") ?? collapsed ?? false;
|
|
79
|
+
// AdwBreakpointBin warns without a size request; the window's size request sets the smallest supported size.
|
|
80
|
+
return (_jsx(SplitViewCollapsedContext, { value: isCollapsed, children: _jsx(AdwBreakpointBin, { widthRequest: 1, heightRequest: 1, breakpoints: collapseBreakpoint, children: _jsx(AdwNavigationSplitView, { ref: setView, collapsed: collapsed, showContent: hasContent(state), sidebarPosition: PACK_TYPES[sidebarPosition], minSidebarWidth: minSidebarWidth, maxSidebarWidth: maxSidebarWidth, sidebarWidthFraction: props.sidebarWidthFraction, onNotifyShowContent: onShowContentChanged, sidebar: _jsx(SidebarPage, { descriptor: sidebar }), children: _jsx(AdwNavigationPage, { title: contentTitle(state, descriptors), controllers: isCollapsed && props.popOnEscape === false ? _jsx(EscapeGuard, {}) : null, children: hasContent(state) ? (_jsx(StackView, { offset: 1, popOnEscape: props.popOnEscape, state: state, navigation: navigation, descriptors: descriptors, describe: describe })) : (_jsx(AdwToolbarView, { top: _jsx(AdwHeaderBar, { showTitle: false }), children: contentPlaceholder })) }) }) }) }));
|
|
60
81
|
};
|
|
61
82
|
export { SplitView };
|
|
62
83
|
//# sourceMappingURL=split-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-view.js","sourceRoot":"","sources":["../../src/split-view/split-view.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAO5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAWnD,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAW,CAAC;AACjF,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,aAAa,GAAG,GAAG,CAAC,UAAU,CAAC;AAErC,MAAM,UAAU,GAAG,CAAC,KAAqC,EAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAE/F,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,WAAmC,EAAU,EAAE;IAC7G,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAExC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO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K,CAAC;IACjG,MAAM,OAAO,GAAG,MAAM,CAAiC,IAAI,CAAC,CAAC;IAC7D,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAE3E,OAAO,CACH,KAAC,sBAAsB,IACnB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,EAC9B,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC,EAC5C,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAChD,mBAAmB,EAAE,oBAAoB,EACzC,OAAO,EAAE,KAAC,WAAW,IAAC,UAAU,EAAE,OAAO,GAAI,YAE7C,KAAC,iBAAiB,IACd,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,EACvC,WAAW,EAAE,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,KAAC,WAAW,KAAG,CAAC,CAAC,CAAC,IAAI,YAE7E,UAAU,CAAC,KAAK,CAAC;gBACd,CAAC,CAAC,CACM,KAAC,SAAS,IACN,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,GACpB,CACL;gBACL,CAAC,CAAC,4BAAG,kBAAkB,GAAI,GACf,GACC,CAC5B,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type { ParamListBase, RouteProp, StackNavigationState } from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { AdwNavigationPage, AdwNavigationSplitView, AdwToolbarView } from \"@gtkx/jsx/adw\";\nimport { GtkEventControllerKey } from \"@gtkx/jsx/gtk\";\nimport { StackActions } from \"@react-navigation/core\";\nimport { useCallback, useRef } from \"react\";\nimport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationHelpers,\n} from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { requireDescriptor } from \"../shared/routes.js\";\nimport { StackView } from \"../stack/stack-view.js\";\n\ntype ViewRef = { current: Adw.NavigationSplitView | null };\n\ntype SplitViewProps = SplitViewNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: SplitViewNavigationHelpers;\n descriptors: SplitViewDescriptorMap;\n describe: (route: RouteProp<ParamListBase>, isPlaceholder: boolean) => SplitViewDescriptor;\n};\n\nconst PACK_TYPES = { start: Gtk.PackType.START, end: Gtk.PackType.END } as const;\nconst CONTENT_TITLE = \"Content\";\nconst ESCAPE_KEYVAL = Gdk.KEY_Escape;\n\nconst hasContent = (state: { routes: readonly unknown[] }): boolean => state.routes.length > 1;\n\nconst contentTitle = (state: StackNavigationState<ParamListBase>, descriptors: SplitViewDescriptorMap): string => {\n const route = state.routes[state.index];\n\n if (route === undefined || state.index === 0) {\n return state.routeNames[1] ?? CONTENT_TITLE;\n }\n\n return descriptors[route.key]?.options.title ?? route.name;\n};\n\nconst popContent = (navigation: SplitViewNavigationHelpers): void => {\n const state = navigation.getState();\n navigation.dispatch({ ...StackActions.pop(state.routes.length - 1), target: state.key });\n};\n\nconst settleShowContent = (viewRef: ViewRef, isShown: boolean, isSettled: boolean): void => {\n if (isSettled !== isShown && viewRef.current !== null) {\n viewRef.current.setShowContent(isSettled);\n }\n};\n\nconst useContentSync = (\n viewRef: ViewRef,\n navigation: SplitViewNavigationHelpers,\n): ((isShown: boolean | null) => void) =>\n useCallback((isShown: boolean | null) => {\n if (isShown === null || isShown === hasContent(navigation.getState())) {\n return;\n }\n\n if (!isShown) {\n popContent(navigation);\n }\n\n settleShowContent(viewRef, isShown, hasContent(navigation.getState()));\n }, [viewRef, navigation]);\n\nconst EscapeGuard = (): ReactNode => (\n <GtkEventControllerKey\n propagationPhase={Gtk.PropagationPhase.BUBBLE}\n onKeyPressed={(keyval) => keyval === ESCAPE_KEYVAL}\n />\n);\n\nconst SidebarPage = ({ descriptor }: { descriptor: SplitViewDescriptor }): ReactNode => {\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return <AdwNavigationPage title={options.title ?? route.name}>{descriptor.render()}</AdwNavigationPage>;\n }\n\n const topBar = options.header === undefined\n ? <HeaderBar options={options} showBackButton={false} />\n : <>{options.header({ route, navigation, options, back: undefined })}</>;\n\n return (\n <AdwNavigationPage title={options.title ?? route.name}>\n <AdwToolbarView topBar={topBar}>{descriptor.render()}</AdwToolbarView>\n </AdwNavigationPage>\n );\n};\n\nconst SplitView = (props: SplitViewProps): ReactNode => {\n const { state, navigation, descriptors, describe, contentPlaceholder } = props;\n const { collapsed = false, sidebarPosition = \"start\", minSidebarWidth, maxSidebarWidth } = props;\n const viewRef = useRef<Adw.NavigationSplitView | null>(null);\n const onShowContentChanged = useContentSync(viewRef, navigation);\n const sidebar = requireDescriptor(descriptors, state.routes[0]?.key ?? \"\");\n\n return (\n <AdwNavigationSplitView\n ref={viewRef}\n collapsed={collapsed}\n showContent={hasContent(state)}\n sidebarPosition={PACK_TYPES[sidebarPosition]}\n minSidebarWidth={minSidebarWidth}\n maxSidebarWidth={maxSidebarWidth}\n sidebarWidthFraction={props.sidebarWidthFraction}\n onNotifyShowContent={onShowContentChanged}\n sidebar={<SidebarPage descriptor={sidebar} />}\n >\n <AdwNavigationPage\n title={contentTitle(state, descriptors)}\n controllers={collapsed && props.popOnEscape === false ? <EscapeGuard /> : null}\n >\n {hasContent(state)\n ? (\n <StackView\n offset={1}\n popOnEscape={props.popOnEscape}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n />\n )\n : <>{contentPlaceholder}</>}\n </AdwNavigationPage>\n </AdwNavigationSplitView>\n );\n};\n\nexport { SplitView };\n"]}
|
|
1
|
+
{"version":3,"file":"split-view.js","sourceRoot":"","sources":["../../src/split-view/split-view.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAOxE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAStE,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAW,CAAC;AACjF,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,aAAa,GAAG,GAAG,CAAC,UAAU,CAAC;AAErC,MAAM,UAAU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,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,EACvC,WAAW,EAAE,WAAW,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,KAAC,WAAW,KAAG,CAAC,CAAC,CAAC,IAAI,YAE/E,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACjB,KAAC,SAAS,IACN,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,GACpB,CACL,CAAC,CAAC,CAAC,CACA,KAAC,cAAc,IAAC,GAAG,EAAE,KAAC,YAAY,IAAC,SAAS,EAAE,KAAK,GAAI,YAClD,kBAAkB,GACN,CACpB,GACe,GACC,GACV,GACK,CAC/B,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { ParamListBase, RouteProp, StackNavigationState } from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport {\n AdwBreakpoint,\n AdwBreakpointBin,\n AdwHeaderBar,\n AdwNavigationPage,\n AdwNavigationSplitView,\n AdwToolbarView,\n} from \"@gtkx/jsx/adw\";\nimport { GtkEventControllerKey } from \"@gtkx/jsx/gtk\";\nimport { useProperty } from \"@gtkx/react\";\nimport { StackActions } from \"@react-navigation/core\";\nimport { useCallback, useLayoutEffect, useMemo, useState } from \"react\";\nimport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationHelpers,\n} from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { requireDescriptor } from \"../shared/routes.js\";\nimport { StackView } from \"../stack/stack-view.js\";\nimport { SplitViewCollapsedContext } from \"./split-view-collapsed.js\";\n\ntype SplitViewProps = SplitViewNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: SplitViewNavigationHelpers;\n descriptors: SplitViewDescriptorMap;\n describe: (route: RouteProp<ParamListBase>, isPlaceholder: boolean) => SplitViewDescriptor;\n};\n\nconst PACK_TYPES = { start: Gtk.PackType.START, end: Gtk.PackType.END } as const;\nconst CONTENT_TITLE = \"Content\";\nconst ESCAPE_KEYVAL = Gdk.KEY_Escape;\n\nconst hasContent = (state: { routes: readonly unknown[] }): boolean => state.routes.length > 1;\n\nconst contentTitle = (state: StackNavigationState<ParamListBase>, descriptors: SplitViewDescriptorMap): string => {\n const route = state.routes[state.index];\n\n if (route === undefined || state.index === 0) {\n return state.routeNames[1] ?? CONTENT_TITLE;\n }\n\n return descriptors[route.key]?.options.title ?? route.name;\n};\n\nconst popContent = (navigation: SplitViewNavigationHelpers): void => {\n const state = navigation.getState();\n navigation.dispatch({ ...StackActions.pop(state.routes.length - 1), target: state.key });\n};\n\nconst collapsedValue = (): GObject.Value => {\n const value = new GObject.Value();\n value.init(GObject.TYPE_BOOLEAN);\n value.setBoolean(true);\n\n return value;\n};\n\nconst useCollapseBreakpoint = (\n view: Adw.NavigationSplitView | null,\n collapseCondition: string | undefined,\n): ReactNode => {\n const [breakpoint, setBreakpoint] = useState<Adw.Breakpoint | null>(null);\n const condition = useMemo(\n () => (collapseCondition === undefined ? null : Adw.BreakpointCondition.parse(collapseCondition)),\n [collapseCondition],\n );\n\n useLayoutEffect(() => {\n if (breakpoint === null || view === null) {\n return;\n }\n\n breakpoint.addSetter(view, \"collapsed\", collapsedValue());\n }, [view, breakpoint]);\n\n return condition === null ? null : <AdwBreakpoint ref={setBreakpoint} condition={condition} />;\n};\n\nconst settleShowContent = (view: Adw.NavigationSplitView | null, isShown: boolean, isSettled: boolean): void => {\n if (isSettled !== isShown && view !== null) {\n view.setShowContent(isSettled);\n }\n};\n\nconst useContentSync = (\n view: Adw.NavigationSplitView | null,\n navigation: SplitViewNavigationHelpers,\n): ((isShown: boolean | null) => void) =>\n useCallback(\n (isShown: boolean | null) => {\n if (isShown === null || isShown === hasContent(navigation.getState())) {\n return;\n }\n\n if (!isShown) {\n popContent(navigation);\n }\n\n settleShowContent(view, isShown, hasContent(navigation.getState()));\n },\n [view, navigation],\n );\n\nconst EscapeGuard = (): ReactNode => (\n <GtkEventControllerKey\n propagationPhase={Gtk.PropagationPhase.BUBBLE}\n onKeyPressed={(keyval) => keyval === ESCAPE_KEYVAL}\n />\n);\n\nconst SidebarPage = ({ descriptor }: { descriptor: SplitViewDescriptor }): ReactNode => {\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return <AdwNavigationPage title={options.title ?? route.name}>{descriptor.render()}</AdwNavigationPage>;\n }\n\n const topBar =\n options.header === undefined ? (\n <HeaderBar options={options} showBackButton={false} />\n ) : (\n <>{options.header({ route, navigation, options, back: undefined })}</>\n );\n\n return (\n <AdwNavigationPage title={options.title ?? route.name}>\n <AdwToolbarView top={topBar}>{descriptor.render()}</AdwToolbarView>\n </AdwNavigationPage>\n );\n};\n\nconst SplitView = (props: SplitViewProps): ReactNode => {\n const { state, navigation, descriptors, describe, contentPlaceholder, collapseCondition } = props;\n const { sidebarPosition = \"start\", minSidebarWidth, maxSidebarWidth } = props;\n const [view, setView] = useState<Adw.NavigationSplitView | null>(null);\n const onShowContentChanged = useContentSync(view, navigation);\n const collapseBreakpoint = useCollapseBreakpoint(view, collapseCondition);\n const sidebar = requireDescriptor(descriptors, state.routes[0]?.key ?? \"\");\n const collapsed = collapseCondition === undefined ? (props.collapsed ?? false) : undefined;\n const isCollapsed = useProperty(view, \"collapsed\") ?? collapsed ?? false;\n\n // AdwBreakpointBin warns without a size request; the window's size request sets the smallest supported size.\n return (\n <SplitViewCollapsedContext value={isCollapsed}>\n <AdwBreakpointBin widthRequest={1} heightRequest={1} breakpoints={collapseBreakpoint}>\n <AdwNavigationSplitView\n ref={setView}\n collapsed={collapsed}\n showContent={hasContent(state)}\n sidebarPosition={PACK_TYPES[sidebarPosition]}\n minSidebarWidth={minSidebarWidth}\n maxSidebarWidth={maxSidebarWidth}\n sidebarWidthFraction={props.sidebarWidthFraction}\n onNotifyShowContent={onShowContentChanged}\n sidebar={<SidebarPage descriptor={sidebar} />}\n >\n <AdwNavigationPage\n title={contentTitle(state, descriptors)}\n controllers={isCollapsed && props.popOnEscape === false ? <EscapeGuard /> : null}\n >\n {hasContent(state) ? (\n <StackView\n offset={1}\n popOnEscape={props.popOnEscape}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n />\n ) : (\n <AdwToolbarView top={<AdwHeaderBar showTitle={false} />}>\n {contentPlaceholder}\n </AdwToolbarView>\n )}\n </AdwNavigationPage>\n </AdwNavigationSplitView>\n </AdwBreakpointBin>\n </SplitViewCollapsedContext>\n );\n};\n\nexport { SplitView };\n"]}
|
|
@@ -22,9 +22,16 @@ type SplitViewDescriptor = Descriptor<SplitViewNavigationOptions, SplitViewNavig
|
|
|
22
22
|
type SplitViewDescriptorMap = Record<string, SplitViewDescriptor>;
|
|
23
23
|
/** Props of the split view navigator beyond the options every navigator shares. */
|
|
24
24
|
type SplitViewNavigationConfig = {
|
|
25
|
-
/** Whether the panes stack into one instead of sitting side by side; defaults to `false`. */
|
|
25
|
+
/** Whether the panes stack into one instead of sitting side by side; defaults to `false`. Ignored while `collapseCondition` is set. */
|
|
26
26
|
collapsed?: boolean;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* An `Adw.BreakpointCondition` string, such as `"max-width: 500sp"`, measured against the navigator's size.
|
|
29
|
+
* The panes collapse while it holds. libadwaita applies it during layout, before GTK moves focus, so
|
|
30
|
+
* widening the window does not reselect the focused sidebar row the way a `collapsed` prop set from a
|
|
31
|
+
* breakpoint handler can. Give the window a `widthRequest` and `heightRequest`, as for window breakpoints.
|
|
32
|
+
*/
|
|
33
|
+
collapseCondition?: string;
|
|
34
|
+
/** Fills the content pane, below an untitled header bar, while no content route is open; defaults to nothing. */
|
|
28
35
|
contentPlaceholder?: ReactNode;
|
|
29
36
|
/** Which side the sidebar sits on; defaults to `"start"`. */
|
|
30
37
|
sidebarPosition?: "start" | "end";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/split-view/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,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEzF,mGAAmG;AACnG,KAAK,2BAA2B,GAAG,uBAAuB,CAAC;AAC3D,0FAA0F;AAC1F,KAAK,0BAA0B,GAAG,sBAAsB,CAAC;AAEzD,gDAAgD;AAChD,KAAK,uBAAuB,CACxB,SAAS,SAAS,aAAa,EAC/B,SAAS,SAAS,MAAM,SAAS,GAAG,MAAM,SAAS,EACnD,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,IAClD,cAAc,CACd,SAAS,EACT,SAAS,EACT,WAAW,EACX,oBAAoB,CAAC,SAAS,CAAC,EAC/B,0BAA0B,EAC1B,2BAA2B,CAC9B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/split-view/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;AAC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AAuI;IACvI,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iHAAiH;IACjH,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,6DAA6D;IAC7D,eAAe,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAClC,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iFAAiF;IACjF,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,qDAAqD;AACrD,KAAK,uBAAuB,GAAG,uBAAuB,CAClD,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,oBAAoB,CAAC,aAAa,CAAC,EACnC,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,CAAC,aAAa,CAAC,CACzC,GACG,kBAAkB,GAClB,yBAAyB,CAAC;AAE9B,YAAY,EACR,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,GACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/split-view/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 { StackNavigationEventMap, StackNavigationOptions } from \"../stack/types.js\";\n\n/** Events the split view navigator emits: the stack's transition events, from the content pane. */\ntype SplitViewNavigationEventMap = StackNavigationEventMap;\n/** Per-screen options of the split view navigator, the same ones a stack screen takes. */\ntype SplitViewNavigationOptions = StackNavigationOptions;\n\n/** Navigation object of a split view screen. */\ntype SplitViewNavigationProp<\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 SplitViewNavigationOptions,\n SplitViewNavigationEventMap\n>
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/split-view/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 { StackNavigationEventMap, StackNavigationOptions } from \"../stack/types.js\";\n\n/** Events the split view navigator emits: the stack's transition events, from the content pane. */\ntype SplitViewNavigationEventMap = StackNavigationEventMap;\n/** Per-screen options of the split view navigator, the same ones a stack screen takes. */\ntype SplitViewNavigationOptions = StackNavigationOptions;\n\n/** Navigation object of a split view screen. */\ntype SplitViewNavigationProp<\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 SplitViewNavigationOptions,\n SplitViewNavigationEventMap\n> &\n StackActionHelpers<ParamList>;\n\n/** Props a split view screen component receives. */\ntype SplitViewScreenProps<\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: SplitViewNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Navigation helpers of the split view navigator itself. */\ntype SplitViewNavigationHelpers = NavigationHelpers<ParamListBase, SplitViewNavigationEventMap> &\n StackActionHelpers<ParamListBase>;\n\n/** Descriptor of one split view route. */\ntype SplitViewDescriptor = Descriptor<\n SplitViewNavigationOptions,\n SplitViewNavigationProp<ParamListBase>,\n RouteProp<ParamListBase>\n>;\n\n/** Descriptors of the split view routes, keyed by route key. */\ntype SplitViewDescriptorMap = Record<string, SplitViewDescriptor>;\n\n/** Props of the split view navigator beyond the options every navigator shares. */\ntype SplitViewNavigationConfig = {\n /** Whether the panes stack into one instead of sitting side by side; defaults to `false`. Ignored while `collapseCondition` is set. */\n collapsed?: boolean;\n /**\n * An `Adw.BreakpointCondition` string, such as `\"max-width: 500sp\"`, measured against the navigator's size.\n * The panes collapse while it holds. libadwaita applies it during layout, before GTK moves focus, so\n * widening the window does not reselect the focused sidebar row the way a `collapsed` prop set from a\n * breakpoint handler can. Give the window a `widthRequest` and `heightRequest`, as for window breakpoints.\n */\n collapseCondition?: string;\n /** Fills the content pane, below an untitled header bar, while no content route is open; defaults to nothing. */\n contentPlaceholder?: ReactNode;\n /** Which side the sidebar sits on; defaults to `\"start\"`. */\n sidebarPosition?: \"start\" | \"end\";\n /** Minimum sidebar width, in the unit libadwaita uses for the split view. */\n minSidebarWidth?: number;\n /** Maximum sidebar width, in the unit libadwaita uses for the split view. */\n maxSidebarWidth?: number;\n /** Preferred sidebar width as a fraction of the total width. */\n sidebarWidthFraction?: number;\n /** Whether pressing Escape pops the visible content page; defaults to `true`. */\n popOnEscape?: boolean;\n};\n\n/** Props of the split view `Navigator` component. */\ntype SplitViewNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n StackNavigationState<ParamListBase>,\n SplitViewNavigationOptions,\n SplitViewNavigationEventMap,\n SplitViewNavigationProp<ParamListBase>\n> &\n StackRouterOptions &\n SplitViewNavigationConfig;\n\nexport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationEventMap,\n SplitViewNavigationHelpers,\n SplitViewNavigationOptions,\n SplitViewNavigationProp,\n SplitViewNavigatorProps,\n SplitViewScreenProps,\n};\n"]}
|
|
@@ -25,6 +25,8 @@ declare const createStackScreen: StaticScreenFactory<StackTypeBag>;
|
|
|
25
25
|
/** Renders the screens of a {@link createStackNavigator} as pages of an `AdwNavigationView`. */
|
|
26
26
|
declare function StackNavigator({ popOnEscape, ...options }: StackNavigatorProps): ReactNode;
|
|
27
27
|
/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */
|
|
28
|
-
declare function createStackNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID
|
|
28
|
+
declare function createStackNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>>(): TypedNavigator<TypeBag, undefined>;
|
|
29
|
+
/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */
|
|
30
|
+
declare function createStackNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>, const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>>(config: Config): TypedNavigator<TypeBag, Config>;
|
|
29
31
|
export { createStackNavigator, createStackScreen, StackNavigator, type StackTypeBag };
|
|
30
32
|
//# sourceMappingURL=create-stack-navigator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-stack-navigator.d.ts","sourceRoot":"","sources":["../../src/stack/create-stack-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EAEb,oBAAoB,EAEpB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACR,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,YAAY,CAAC;AAGpB,gFAAgF;AAChF,KAAK,YAAY,CACb,SAAS,SAAS,aAAa,GAAG,aAAa,EAC/C,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3D;IACA,oCAAoC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,6BAA6B;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,oCAAoC;IACpC,KAAK,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACvC,0BAA0B;IAC1B,aAAa,EAAE,sBAAsB,CAAC;IACtC,kCAAkC;IAClC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,mCAAmC;IACnC,cAAc,EAAE;SACX,SAAS,IAAI,MAAM,SAAS,GAAG,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;KACzF,CAAC;IACF,+BAA+B;IAC/B,SAAS,EAAE,OAAO,cAAc,CAAC;CACpC,CAAC;AAEF,qFAAqF;AACrF,QAAA,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,YAAY,CAAuC,CAAC;AAEjG,gGAAgG;AAChG,iBAAS,cAAc,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,EAAE,mBAAmB,GAAG,SAAS,CAkBnF;AAED,sHAAsH;AACtH,iBAAS,oBAAoB,CACzB,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC,EACjF,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"create-stack-navigator.d.ts","sourceRoot":"","sources":["../../src/stack/create-stack-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK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,SAAS,EAAE,WAAW,CAAC,KAChF,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACxC,sHAAsH;AACtH,iBAAS,oBAAoB,CACzB,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC,EACjF,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EACpE,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAQnD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,CAAC"}
|
|
@@ -8,7 +8,6 @@ function StackNavigator({ popOnEscape, ...options }) {
|
|
|
8
8
|
const { state, describe, descriptors, navigation, render } = useNavigationBuilder(StackRouter, options);
|
|
9
9
|
return render(_jsx(StackView, { popOnEscape: popOnEscape, state: state, navigation: navigation, descriptors: descriptors, describe: describe }));
|
|
10
10
|
}
|
|
11
|
-
/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */
|
|
12
11
|
function createStackNavigator(config) {
|
|
13
12
|
return createNavigatorFactory(StackNavigator)(config);
|
|
14
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-stack-navigator.js","sourceRoot":"","sources":["../../src/stack/create-stack-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAOxH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAyB5C,qFAAqF;AACrF,MAAM,iBAAiB,GAAsC,mBAAmB,EAAgB,CAAC;AAEjG,gGA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,cAAc,EAAqB,CAAC","sourcesContent":["import type {\n NavigatorTypeBagBase,\n ParamListBase,\n StackActionHelpers,\n StackNavigationState,\n StackRouterOptions,\n StaticConfig,\n StaticScreenFactory,\n TypedNavigator,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport { createNavigatorFactory, createScreenFactory, StackRouter, useNavigationBuilder } from \"@react-navigation/core\";\nimport type {\n StackNavigationEventMap,\n StackNavigationOptions,\n StackNavigationProp,\n StackNavigatorProps,\n} from \"./types.js\";\nimport { StackView } from \"./stack-view.js\";\n\n/** Type bag describing the stack navigator to React Navigation's typed APIs. */\ntype StackTypeBag<\n ParamList extends ParamListBase = ParamListBase,\n NavigatorID extends string | undefined = string | undefined,\n> = {\n /** Route names and their params. */\n ParamList: ParamList;\n /** Optional navigator id. */\n NavigatorID: NavigatorID;\n /** Shape of the navigator state. */\n State: StackNavigationState<ParamList>;\n /** Per-screen options. */\n ScreenOptions: StackNavigationOptions;\n /** Events the navigator emits. */\n EventMap: StackNavigationEventMap;\n /** Navigation object per route. */\n NavigationList: {\n [RouteName in keyof ParamList]: StackNavigationProp<ParamList, RouteName, NavigatorID>;\n };\n /** The navigator component. */\n Navigator: typeof StackNavigator;\n};\n\n/** Declares a typed screen of a stack navigator for the static configuration API. */\nconst createStackScreen: StaticScreenFactory<StackTypeBag> = createScreenFactory<StackTypeBag>();\n\n/** Renders the screens of a {@link createStackNavigator} as pages of an `AdwNavigationView`. */\nfunction StackNavigator({ popOnEscape, ...options }: StackNavigatorProps): ReactNode {\n const { state, describe, descriptors, navigation, render } = useNavigationBuilder<\n StackNavigationState<ParamListBase>,\n StackRouterOptions,\n StackActionHelpers<ParamListBase>,\n StackNavigationOptions,\n StackNavigationEventMap\n >(StackRouter, options);\n\n return render(\n <StackView\n popOnEscape={popOnEscape}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n />,\n );\n}\n\n/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */\nfunction createStackNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>,\n>(): TypedNavigator<TypeBag, undefined>;\n/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */\nfunction createStackNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>,\n const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,\n>(config: Config): TypedNavigator<TypeBag, Config>;\nfunction createStackNavigator<\n const TypeBag extends NavigatorTypeBagBase,\n const Config extends StaticConfig<TypeBag> | undefined,\n>(config?: Config): TypedNavigator<TypeBag, Config> {\n return createNavigatorFactory(StackNavigator)(config) as TypedNavigator<TypeBag, Config>;\n}\n\nexport { createStackNavigator, createStackScreen, StackNavigator, type StackTypeBag };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-pages.d.ts","sourceRoot":"","sources":["../../src/stack/stack-pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEtE,KAAK,UAAU,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;AACtD,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,EAAE,aAAa,EAAE,OAAO,KAAK,eAAe,CAAC;AAS7F,KAAK,UAAU,GAAG;IACd,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAClC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AA6EF,QAAA,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"stack-pages.d.ts","sourceRoot":"","sources":["../../src/stack/stack-pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEtE,KAAK,UAAU,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;AACtD,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,EAAE,aAAa,EAAE,OAAO,KAAK,eAAe,CAAC;AAS7F,KAAK,UAAU,GAAG;IACd,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAClC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AA6EF,QAAA,MAAM,aAAa,UACR,UAAU,eACJ,kBAAkB,YACrB,QAAQ,UACV,MAAM,KACf,UA4BF,CAAC;AAEF,OAAO,EAAE,KAAK,QAAQ,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -54,18 +54,16 @@ const useStackPages = (state, descriptors, describe, offset) => {
|
|
|
54
54
|
setTracking(advance(tracking, state, descriptors, offset));
|
|
55
55
|
}
|
|
56
56
|
const release = useCallback((key) => {
|
|
57
|
-
setTracking((current) =>
|
|
57
|
+
setTracking((current) => current.closing[key] === undefined
|
|
58
58
|
? current
|
|
59
59
|
: {
|
|
60
60
|
...current,
|
|
61
61
|
order: current.order.filter((entry) => entry !== key),
|
|
62
62
|
closing: withoutKeys(current.closing, [key]),
|
|
63
|
-
})
|
|
63
|
+
});
|
|
64
64
|
}, []);
|
|
65
65
|
const sources = { state, descriptors, closing: tracking.closing };
|
|
66
|
-
const pages = tracking.order
|
|
67
|
-
.map((key) => resolvePage(key, sources, describe))
|
|
68
|
-
.filter((page) => page !== undefined);
|
|
66
|
+
const pages = tracking.order.map((key) => resolvePage(key, sources, describe)).filter((page) => page !== undefined);
|
|
69
67
|
return { pages, release };
|
|
70
68
|
};
|
|
71
69
|
export { useStackPages };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-pages.js","sourceRoot":"","sources":["../../src/stack/stack-pages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAkB9C,MAAM,aAAa,GAAG,CAAC,KAAiB,EAAE,MAAc,EAAsB,EAAE,CAC5E,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC;AAEtE,MAAM,WAAW,GAAG,CAAC,KAAiB,EAAE,MAAc,EAAY,EAAE,CAAC;IACjE,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;IACvD,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;CACrD,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,KAAiB,EAAE,OAA2B,EAAE,MAAc,EAAY,EAAE,CAAC;IAC7F,GAAG,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;IAC7B,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAuB,EAAE,KAAwB,EAAW,EAAE,CAClF,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAE7E,MAAM,WAAW,GAAG,CAAC,QAA2B,EAAE,MAAyB,EAAY,EAAE,CAAC;IAC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C5E,QAAQ,CAAC,UAAU,KAAK,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC;QACpD,QAAQ,CAAC,WAAW,KAAK,WAAW,EACtC,CAAC;QACC,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,GAAW,EAAE,EAAE;QACxC,WAAW,CAAC,CAAC,OAAO,EAAE,EAAE,CACpB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;YAC9B,CAAC,CAAC,OAAO;YACT,CAAC,CAAC;gBACI,GAAG,OAAO;gBACV,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,GAAG,CAAC;gBACrD,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;aAC/C,CACV,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAElE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAEpH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC,CAAC;AAEF,OAAO,EAAiB,aAAa,EAAE,CAAC","sourcesContent":["import type { ParamListBase, RouteProp, StackNavigationState } from \"@react-navigation/core\";\nimport { useCallback, useState } from \"react\";\nimport type { StackDescriptor, StackDescriptorMap } from \"./types.js\";\n\ntype StackState = StackNavigationState<ParamListBase>;\ntype Describe = (route: RouteProp<ParamListBase>, isPlaceholder: boolean) => StackDescriptor;\n\ntype PageTracking = {\n order: readonly string[];\n focusedKey: string | undefined;\n descriptors: StackDescriptorMap;\n closing: StackDescriptorMap;\n};\n\ntype StackPages = {\n pages: readonly StackDescriptor[];\n release: (key: string) => void;\n};\n\nconst getFocusedKey = (state: StackState, offset: number): string | undefined =>\n state.index < offset ? undefined : state.routes[state.index]?.key;\n\nconst mountedKeys = (state: StackState, offset: number): string[] => [\n ...state.routes.slice(offset).map((route) => route.key),\n ...state.preloadedRoutes.map((route) => route.key),\n];\n\nconst neededKeys = (state: StackState, closing: StackDescriptorMap, offset: number): string[] => [\n ...mountedKeys(state, offset),\n ...Object.keys(closing),\n];\n\nconst hasSameMembers = (left: readonly string[], right: readonly string[]): boolean =>\n left.length === right.length && left.every((key) => right.includes(key));\n\nconst appendOrder = (previous: readonly string[], needed: readonly string[]): string[] => [\n ...previous.filter((key) => needed.includes(key)),\n ...needed.filter((key) => !previous.includes(key)),\n];\n\nconst withoutKeys = (map: StackDescriptorMap, keys: readonly string[]): StackDescriptorMap =>\n Object.fromEntries(Object.entries(map).filter(([key]) => !keys.includes(key)));\n\nconst nextClosing = (tracking: PageTracking, state: StackState, offset: number): StackDescriptorMap => {\n const mounted = mountedKeys(state, offset);\n const kept = withoutKeys(tracking.closing, mounted);\n const { focusedKey } = tracking;\n\n if (focusedKey === undefined || mounted.includes(focusedKey)) {\n return kept;\n }\n\n const descriptor = tracking.descriptors[focusedKey];\n\n return descriptor === undefined ? kept : { ...kept, [focusedKey]: descriptor };\n};\n\nconst advance = (\n tracking: PageTracking,\n state: StackState,\n descriptors: StackDescriptorMap,\n offset: number,\n): PageTracking => {\n const closing = nextClosing(tracking, state, offset);\n\n return {\n order: appendOrder(tracking.order, neededKeys(state, closing, offset)),\n focusedKey: getFocusedKey(state, offset),\n descriptors,\n closing,\n };\n};\n\nconst initialTracking = (state: StackState, descriptors: StackDescriptorMap, offset: number): PageTracking => ({\n order: neededKeys(state, {}, offset),\n focusedKey: getFocusedKey(state, offset),\n descriptors,\n closing: {},\n});\n\nconst resolvePage = (\n key: string,\n sources: { state: StackState; descriptors: StackDescriptorMap; closing: StackDescriptorMap },\n describe: Describe,\n): StackDescriptor | undefined => {\n const preloaded = sources.state.preloadedRoutes.find((route) => route.key === key);\n\n if (preloaded !== undefined) {\n return describe(preloaded, true);\n }\n\n return sources.descriptors[key] ?? sources.closing[key];\n};\n\nconst useStackPages = (\n state: StackState,\n descriptors: StackDescriptorMap,\n describe: Describe,\n offset: number,\n): StackPages => {\n const [tracking, setTracking] = useState<PageTracking>(() => initialTracking(state, descriptors, offset));\n\n if (\n !hasSameMembers(tracking.order, neededKeys(state, tracking.closing, offset)) ||\n tracking.focusedKey !== getFocusedKey(state, offset) ||\n tracking.descriptors !== descriptors\n ) {\n setTracking(advance(tracking, state, descriptors, offset));\n }\n\n const release = useCallback((key: string) => {\n setTracking((current) =>\n current.closing[key] === undefined\n ? current\n : {\n ...current,\n order: current.order.filter((entry) => entry !== key),\n closing: withoutKeys(current.closing, [key]),\n },\n );\n }, []);\n\n const sources = { state, descriptors, closing: tracking.closing };\n\n const pages = tracking.order.map((key) => resolvePage(key, sources, describe)).filter((page) => page !== undefined);\n\n return { pages, release };\n};\n\nexport { type Describe, useStackPages };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-view.d.ts","sourceRoot":"","sources":["../../src/stack/stack-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"stack-view.d.ts","sourceRoot":"","sources":["../../src/stack/stack-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAIlD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAER,kBAAkB,EAClB,qBAAqB,EAErB,sBAAsB,EACzB,MAAM,YAAY,CAAC;AAOpB,KAAK,cAAc,GAAG,qBAAqB,GAAG;IAC1C,KAAK,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC3C,UAAU,EAAE,sBAAsB,CAAC;IACnC,WAAW,EAAE,kBAAkB,CAAC;IAChC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAmIF,QAAA,MAAM,SAAS,UAAW,cAAc,KAAG,SAqB1C,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/stack/stack-view.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { AdwNavigationPage, AdwNavigationView, AdwToolbarView } from "@gtkx/jsx/adw";
|
|
3
|
+
import { useLatestRef } from "@gtkx/react/internal";
|
|
3
4
|
import { useCallback, useEffect, useRef } from "react";
|
|
4
5
|
import { HeaderBar } from "../shared/header-bar.js";
|
|
5
6
|
import { useStackPages } from "./stack-pages.js";
|
|
@@ -9,13 +10,6 @@ const previousDescriptor = (state, descriptors, key, offset) => {
|
|
|
9
10
|
const previousKey = index > offset ? state.routes[index - 1]?.key : undefined;
|
|
10
11
|
return previousKey === undefined ? undefined : descriptors[previousKey];
|
|
11
12
|
};
|
|
12
|
-
const useLatest = (value) => {
|
|
13
|
-
const ref = useRef(value);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
ref.current = value;
|
|
16
|
-
}, [value]);
|
|
17
|
-
return ref;
|
|
18
|
-
};
|
|
19
13
|
const useStackSync = (viewRef, state, options, offset) => {
|
|
20
14
|
const isInitialRef = useRef(true);
|
|
21
15
|
useEffect(() => {
|
|
@@ -29,7 +23,7 @@ const useStackSync = (viewRef, state, options, offset) => {
|
|
|
29
23
|
}, [viewRef, state, options, offset]);
|
|
30
24
|
};
|
|
31
25
|
const usePoppedHandler = (viewRef, navigation, options, offset) => {
|
|
32
|
-
const navigationRef =
|
|
26
|
+
const navigationRef = useLatestRef(navigation);
|
|
33
27
|
const isScheduledRef = useRef(false);
|
|
34
28
|
return useCallback(() => {
|
|
35
29
|
if (isScheduledRef.current) {
|
|
@@ -51,10 +45,8 @@ const StackPageContent = ({ descriptor, previous }) => {
|
|
|
51
45
|
return descriptor.render();
|
|
52
46
|
}
|
|
53
47
|
const back = previous === undefined ? undefined : { title: previous.options.title ?? previous.route.name };
|
|
54
|
-
const topBar = options.header === undefined
|
|
55
|
-
|
|
56
|
-
: _jsx(_Fragment, { children: options.header({ route, navigation, options, back }) });
|
|
57
|
-
return _jsx(AdwToolbarView, { topBar: topBar, children: descriptor.render() });
|
|
48
|
+
const topBar = options.header === undefined ? (_jsx(HeaderBar, { options: options, showBackButton: options.headerBackVisible ?? true })) : (_jsx(_Fragment, { children: options.header({ route, navigation, options, back }) }));
|
|
49
|
+
return _jsx(AdwToolbarView, { top: topBar, children: descriptor.render() });
|
|
58
50
|
};
|
|
59
51
|
const StackPage = ({ descriptor, previous, navigation, onHidden }) => {
|
|
60
52
|
const { route, options } = descriptor;
|
|
@@ -83,7 +75,7 @@ const StackView = (props) => {
|
|
|
83
75
|
const { state, navigation, descriptors, describe, popOnEscape, offset = 0 } = props;
|
|
84
76
|
const viewRef = useRef(null);
|
|
85
77
|
const { pages, release } = useStackPages(state, descriptors, describe, offset);
|
|
86
|
-
const options =
|
|
78
|
+
const options = useLatestRef(Object.fromEntries(pages.map((page) => [page.route.key, page.options])));
|
|
87
79
|
const onPopped = usePoppedHandler(viewRef, navigation, options, offset);
|
|
88
80
|
useStackSync(viewRef, state, options, offset);
|
|
89
81
|
return (_jsx(AdwNavigationView, { ref: viewRef, popOnEscape: popOnEscape ?? true, onPopped: onPopped, children: pages.map((descriptor) => (_jsx(StackPage, { descriptor: descriptor, previous: previousDescriptor(state, descriptors, descriptor.route.key, offset), navigation: navigation, onHidden: release }, descriptor.route.key))) }));
|