@gtkx/navigation 2.0.0-beta.11 → 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.
Files changed (64) hide show
  1. package/README.md +3 -3
  2. package/dist/drawer/drawer-item-list.d.ts.map +1 -1
  3. package/dist/drawer/drawer-item-list.js +3 -2
  4. package/dist/drawer/drawer-item-list.js.map +1 -1
  5. package/dist/drawer/drawer-router.d.ts.map +1 -1
  6. package/dist/drawer/drawer-router.js.map +1 -1
  7. package/dist/drawer/drawer-status.d.ts.map +1 -1
  8. package/dist/drawer/drawer-view.d.ts.map +1 -1
  9. package/dist/drawer/drawer-view.js +5 -5
  10. package/dist/drawer/drawer-view.js.map +1 -1
  11. package/dist/drawer/types.d.ts +2 -0
  12. package/dist/drawer/types.d.ts.map +1 -1
  13. package/dist/drawer/types.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/shared/header-bar.d.ts.map +1 -1
  19. package/dist/shared/header-bar.js +2 -2
  20. package/dist/shared/header-bar.js.map +1 -1
  21. package/dist/shared/routes.d.ts.map +1 -1
  22. package/dist/shared/scene-page.d.ts +3 -1
  23. package/dist/shared/scene-page.d.ts.map +1 -1
  24. package/dist/shared/scene-page.js +2 -2
  25. package/dist/shared/scene-page.js.map +1 -1
  26. package/dist/shared/use-pop-to-top-on-blur.d.ts.map +1 -1
  27. package/dist/split-view/split-view.d.ts.map +1 -1
  28. package/dist/split-view/split-view.js +3 -7
  29. package/dist/split-view/split-view.js.map +1 -1
  30. package/dist/split-view/types.d.ts.map +1 -1
  31. package/dist/split-view/types.js.map +1 -1
  32. package/dist/stack/stack-pages.d.ts.map +1 -1
  33. package/dist/stack/stack-pages.js +3 -5
  34. package/dist/stack/stack-pages.js.map +1 -1
  35. package/dist/stack/stack-view.d.ts.map +1 -1
  36. package/dist/stack/stack-view.js +5 -13
  37. package/dist/stack/stack-view.js.map +1 -1
  38. package/dist/stack/sync-navigation-stack.d.ts.map +1 -1
  39. package/dist/stack/types.d.ts.map +1 -1
  40. package/dist/stack/types.js.map +1 -1
  41. package/dist/tabs/tab-view.d.ts.map +1 -1
  42. package/dist/tabs/tab-view.js +5 -7
  43. package/dist/tabs/tab-view.js.map +1 -1
  44. package/dist/tabs/types.d.ts +2 -0
  45. package/dist/tabs/types.d.ts.map +1 -1
  46. package/dist/tabs/types.js.map +1 -1
  47. package/dist/theme.d.ts.map +1 -1
  48. package/dist/theme.js.map +1 -1
  49. package/package.json +9 -19
  50. package/src/drawer/drawer-item-list.tsx +16 -12
  51. package/src/drawer/drawer-router.ts +4 -2
  52. package/src/drawer/drawer-view.tsx +16 -16
  53. package/src/drawer/types.ts +6 -3
  54. package/src/index.ts +1 -5
  55. package/src/shared/header-bar.tsx +2 -2
  56. package/src/shared/scene-page.tsx +5 -2
  57. package/src/split-view/split-view.tsx +32 -26
  58. package/src/split-view/types.ts +4 -3
  59. package/src/stack/stack-pages.ts +14 -12
  60. package/src/stack/stack-view.tsx +9 -15
  61. package/src/stack/types.ts +4 -3
  62. package/src/tabs/tab-view.tsx +27 -21
  63. package/src/tabs/types.ts +6 -3
  64. package/src/theme.ts +0 -1
@@ -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) => (current.closing[key] === undefined
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;IACtF,GAAG,QAAQ,C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igationState } 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 (!hasSameMembers(tracking.order, neededKeys(state, tracking.closing, offset)) ||\n tracking.focusedKey !== getFocusedKey(state, offset) ||\n tracking.descriptors !== descriptors) {\n setTracking(advance(tracking, state, descriptors, offset));\n }\n\n const release = useCallback((key: string) => {\n setTracking((current) => (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 const sources = { state, descriptors, closing: tracking.closing };\n\n const pages = tracking.order\n .map((key) => resolvePage(key, sources, describe))\n .filter((page) => page !== undefined);\n\n return { pages, release };\n};\n\nexport { type Describe, useStackPages };\n"]}
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,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AC,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;AAGlD,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;AA0IF,QAAA,MAAM,SAAS,GAAI,OAAO,cAAc,KAAG,SAqB1C,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,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"}
@@ -1,5 +1,6 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
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 = useLatest(navigation);
26
+ const navigationRef = useLatestRef(navigation);
33
27
  const isScheduledRef = useRef(false);
34
28
  return useCallback(() => {
35
29
  if (isScheduledRef.current) {
@@ -51,9 +45,7 @@ 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
- ? _jsx(HeaderBar, { options: options, showBackButton: options.headerBackVisible ?? true })
56
- : _jsx(_Fragment, { children: options.header({ route, navigation, options, back }) });
48
+ const topBar = options.header === undefined ? (_jsx(HeaderBar, { options: options, showBackButton: options.headerBackVisible ?? true })) : (_jsx(_Fragment, { children: options.header({ route, navigation, options, back }) }));
57
49
  return _jsx(AdwToolbarView, { topBar: topBar, children: descriptor.render() });
58
50
  };
59
51
  const StackPage = ({ descriptor, previous, navigation, onHidden }) => {
@@ -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 = useLatest(Object.fromEntries(pages.map((page) => [page.route.key, page.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 },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actNode, RefObject } from \"react\";\nimport { AdwNavigationPage, AdwNavigationView, AdwToolbarView } from \"@gtkx/jsx/adw\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport type { Describe } from \"./stack-pages.js\";\nimport type { OptionsByKey } from \"./sync-navigation-stack.js\";\nimport type {\n StackDescriptor,\n StackDescriptorMap,\n StackNavigationConfig,\n StackNavigationEventMap,\n StackNavigationHelpers,\n} from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { useStackPages } from \"./stack-pages.js\";\nimport { reconcilePoppedStack, syncNavigationStack } from \"./sync-navigation-stack.js\";\n\ntype ViewRef = RefObject<Adw.NavigationView | null>;\n\ntype StackViewProps = StackNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: StackNavigationHelpers;\n descriptors: StackDescriptorMap;\n describe: Describe;\n offset?: number;\n};\n\ntype StackPageProps = {\n descriptor: StackDescriptor;\n previous?: StackDescriptor;\n navigation: StackNavigationHelpers;\n onHidden: (key: string) => void;\n};\n\ntype TransitionEvent = keyof StackNavigationEventMap;\n\nconst previousDescriptor = (\n state: StackNavigationState<ParamListBase>,\n descriptors: StackDescriptorMap,\n key: string,\n offset: number,\n): StackDescriptor | undefined => {\n const index = state.routes.findIndex((route) => route.key === key);\n const previousKey = index > offset ? state.routes[index - 1]?.key : undefined;\n\n return previousKey === undefined ? undefined : descriptors[previousKey];\n};\n\nconst useLatest = <T,>(value: T): RefObject<T> => {\n const ref = useRef(value);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n};\n\nconst useStackSync = (\n viewRef: ViewRef,\n state: StackNavigationState<ParamListBase>,\n options: RefObject<OptionsByKey>,\n offset: number,\n): void => {\n const isInitialRef = useRef(true);\n\n useEffect(() => {\n const view = viewRef.current;\n\n if (view === null) {\n return;\n }\n\n const desired = state.routes.slice(offset).map((route) => route.key);\n syncNavigationStack(view, desired, options.current, isInitialRef.current);\n isInitialRef.current = false;\n }, [viewRef, state, options, offset]);\n};\n\nconst usePoppedHandler = (\n viewRef: ViewRef,\n navigation: StackNavigationHelpers,\n options: RefObject<OptionsByKey>,\n offset: number,\n): (() => void) => {\n const navigationRef = useLatest(navigation);\n const isScheduledRef = useRef(false);\n\n return useCallback(() => {\n if (isScheduledRef.current) {\n return;\n }\n\n isScheduledRef.current = true;\n\n queueMicrotask(() => {\n isScheduledRef.current = false;\n const view = viewRef.current;\n\n if (view !== null) {\n reconcilePoppedStack(view, navigationRef.current, options.current, offset);\n }\n });\n }, [viewRef, navigationRef, options, offset]);\n};\n\nconst StackPageContent = ({ descriptor, previous }: Omit<StackPageProps, \"navigation\" | \"onHidden\">): ReactNode => {\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return descriptor.render();\n }\n\n const back = previous === undefined ? undefined : { title: previous.options.title ?? previous.route.name };\n\n const topBar = options.header === undefined\n ? <HeaderBar options={options} showBackButton={options.headerBackVisible ?? true} />\n : <>{options.header({ route, navigation, options, back })}</>;\n\n return <AdwToolbarView topBar={topBar}>{descriptor.render()}</AdwToolbarView>;\n};\n\nconst StackPage = ({ descriptor, previous, navigation, onHidden }: StackPageProps): ReactNode => {\n const { route, options } = descriptor;\n const pageRef = useRef<Adw.NavigationPage | null>(null);\n\n const emit = (type: TransitionEvent, isClosing: boolean): void => {\n navigation.emit({ type, data: { closing: isClosing }, target: route.key });\n };\n\n useEffect(() => {\n const page = pageRef.current;\n\n if (page !== null && !page.getMapped()) {\n onHidden(route.key);\n }\n });\n\n return (\n <AdwNavigationPage\n ref={pageRef}\n tag={route.key}\n title={options.title ?? route.name}\n canPop={options.canPop ?? true}\n onShowing={() => {\n emit(\"transitionStart\", false);\n }}\n onHiding={() => {\n emit(\"transitionStart\", true);\n }}\n onShown={() => {\n emit(\"transitionEnd\", false);\n }}\n onHidden={() => {\n emit(\"transitionEnd\", true);\n onHidden(route.key);\n }}\n >\n <StackPageContent descriptor={descriptor} previous={previous} />\n </AdwNavigationPage>\n );\n};\n\nconst StackView = (props: StackViewProps): ReactNode => {\n const { state, navigation, descriptors, describe, popOnEscape, offset = 0 } = props;\n const viewRef = useRef<Adw.NavigationView | null>(null);\n const { pages, release } = useStackPages(state, descriptors, describe, offset);\n const options = useLatest<OptionsByKey>(Object.fromEntries(pages.map((page) => [page.route.key, page.options])));\n const onPopped = usePoppedHandler(viewRef, navigation, options, offset);\n useStackSync(viewRef, state, options, offset);\n\n return (\n <AdwNavigationView ref={viewRef} popOnEscape={popOnEscape ?? true} onPopped={onPopped}>\n {pages.map((descriptor) => (\n <StackPage\n key={descriptor.route.key}\n descriptor={descriptor}\n previous={previousDescriptor(state, descriptors, descriptor.route.key, offset)}\n navigation={navigation}\n onHidden={release}\n />\n ))}\n </AdwNavigationView>\n );\n};\n\nexport { StackView };\n"]}
1
+ {"version":3,"file":"stack-view.js","sourceRoot":"","sources":["../../src/stack/stack-view.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAUvD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAqBvF,MAAM,kBAAkB,GAAG,CACvB,KAA0C,EAC1C,WAA+B,EAC/B,GAAW,EACX,MAAc,EACa,EAAE;IAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAA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E,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,OAAO,IAJZ,UAAU,CAAC,KAAK,CAAC,GAAG,CAK3B,CACL,CAAC,GACc,CACvB,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type { ParamListBase, StackNavigationState } from \"@react-navigation/core\";\nimport type { ReactNode, RefObject } from \"react\";\nimport { AdwNavigationPage, AdwNavigationView, AdwToolbarView } from \"@gtkx/jsx/adw\";\nimport { useLatestRef } from \"@gtkx/react/internal\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport type { Describe } from \"./stack-pages.js\";\nimport type { OptionsByKey } from \"./sync-navigation-stack.js\";\nimport type {\n StackDescriptor,\n StackDescriptorMap,\n StackNavigationConfig,\n StackNavigationEventMap,\n StackNavigationHelpers,\n} from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { useStackPages } from \"./stack-pages.js\";\nimport { reconcilePoppedStack, syncNavigationStack } from \"./sync-navigation-stack.js\";\n\ntype ViewRef = RefObject<Adw.NavigationView | null>;\n\ntype StackViewProps = StackNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: StackNavigationHelpers;\n descriptors: StackDescriptorMap;\n describe: Describe;\n offset?: number;\n};\n\ntype StackPageProps = {\n descriptor: StackDescriptor;\n previous?: StackDescriptor;\n navigation: StackNavigationHelpers;\n onHidden: (key: string) => void;\n};\n\ntype TransitionEvent = keyof StackNavigationEventMap;\n\nconst previousDescriptor = (\n state: StackNavigationState<ParamListBase>,\n descriptors: StackDescriptorMap,\n key: string,\n offset: number,\n): StackDescriptor | undefined => {\n const index = state.routes.findIndex((route) => route.key === key);\n const previousKey = index > offset ? state.routes[index - 1]?.key : undefined;\n\n return previousKey === undefined ? undefined : descriptors[previousKey];\n};\n\nconst useStackSync = (\n viewRef: ViewRef,\n state: StackNavigationState<ParamListBase>,\n options: RefObject<OptionsByKey>,\n offset: number,\n): void => {\n const isInitialRef = useRef(true);\n\n useEffect(() => {\n const view = viewRef.current;\n\n if (view === null) {\n return;\n }\n\n const desired = state.routes.slice(offset).map((route) => route.key);\n syncNavigationStack(view, desired, options.current, isInitialRef.current);\n isInitialRef.current = false;\n }, [viewRef, state, options, offset]);\n};\n\nconst usePoppedHandler = (\n viewRef: ViewRef,\n navigation: StackNavigationHelpers,\n options: RefObject<OptionsByKey>,\n offset: number,\n): (() => void) => {\n const navigationRef = useLatestRef(navigation);\n const isScheduledRef = useRef(false);\n\n return useCallback(() => {\n if (isScheduledRef.current) {\n return;\n }\n\n isScheduledRef.current = true;\n\n queueMicrotask(() => {\n isScheduledRef.current = false;\n const view = viewRef.current;\n\n if (view !== null) {\n reconcilePoppedStack(view, navigationRef.current, options.current, offset);\n }\n });\n }, [viewRef, navigationRef, options, offset]);\n};\n\nconst StackPageContent = ({ descriptor, previous }: Omit<StackPageProps, \"navigation\" | \"onHidden\">): ReactNode => {\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return descriptor.render();\n }\n\n const back = previous === undefined ? undefined : { title: previous.options.title ?? previous.route.name };\n\n const topBar =\n options.header === undefined ? (\n <HeaderBar options={options} showBackButton={options.headerBackVisible ?? true} />\n ) : (\n <>{options.header({ route, navigation, options, back })}</>\n );\n\n return <AdwToolbarView topBar={topBar}>{descriptor.render()}</AdwToolbarView>;\n};\n\nconst StackPage = ({ descriptor, previous, navigation, onHidden }: StackPageProps): ReactNode => {\n const { route, options } = descriptor;\n const pageRef = useRef<Adw.NavigationPage | null>(null);\n\n const emit = (type: TransitionEvent, isClosing: boolean): void => {\n navigation.emit({ type, data: { closing: isClosing }, target: route.key });\n };\n\n useEffect(() => {\n const page = pageRef.current;\n\n if (page !== null && !page.getMapped()) {\n onHidden(route.key);\n }\n });\n\n return (\n <AdwNavigationPage\n ref={pageRef}\n tag={route.key}\n title={options.title ?? route.name}\n canPop={options.canPop ?? true}\n onShowing={() => {\n emit(\"transitionStart\", false);\n }}\n onHiding={() => {\n emit(\"transitionStart\", true);\n }}\n onShown={() => {\n emit(\"transitionEnd\", false);\n }}\n onHidden={() => {\n emit(\"transitionEnd\", true);\n onHidden(route.key);\n }}\n >\n <StackPageContent descriptor={descriptor} previous={previous} />\n </AdwNavigationPage>\n );\n};\n\nconst StackView = (props: StackViewProps): ReactNode => {\n const { state, navigation, descriptors, describe, popOnEscape, offset = 0 } = props;\n const viewRef = useRef<Adw.NavigationView | null>(null);\n const { pages, release } = useStackPages(state, descriptors, describe, offset);\n const options = useLatestRef<OptionsByKey>(Object.fromEntries(pages.map((page) => [page.route.key, page.options])));\n const onPopped = usePoppedHandler(viewRef, navigation, options, offset);\n useStackSync(viewRef, state, options, offset);\n\n return (\n <AdwNavigationView ref={viewRef} popOnEscape={popOnEscape ?? true} onPopped={onPopped}>\n {pages.map((descriptor) => (\n <StackPage\n key={descriptor.route.key}\n descriptor={descriptor}\n previous={previousDescriptor(state, descriptors, descriptor.route.key, offset)}\n navigation={navigation}\n onHidden={release}\n />\n ))}\n </AdwNavigationView>\n );\n};\n\nexport { StackView };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sync-navigation-stack.d.ts","sourceRoot":"","sources":["../../src/stack/sync-navigation-stack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEjF,KAAK,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC,CAAC;AAiEjF,QAAA,MAAM,mBAAmB,GACrB,MAAM,GAAG,CAAC,cAAc,EACxB,SAAS,SAAS,MAAM,EAAE,EAC1B,SAAS,YAAY,EACrB,WAAW,OAAO,KACnB,IAYF,CAAC;AAcF,QAAA,MAAM,oBAAoB,GACtB,MAAM,GAAG,CAAC,cAAc,EACxB,YAAY,sBAAsB,EAClC,SAAS,YAAY,EACrB,QAAQ,MAAM,KACf,IASF,CAAC;AAEF,OAAO,EAAE,KAAK,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"sync-navigation-stack.d.ts","sourceRoot":"","sources":["../../src/stack/sync-navigation-stack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEjF,KAAK,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC,CAAC;AAiEjF,QAAA,MAAM,mBAAmB,SACf,GAAG,CAAC,cAAc,WACf,SAAS,MAAM,EAAE,WACjB,YAAY,aACV,OAAO,KACnB,IAYF,CAAC;AAcF,QAAA,MAAM,oBAAoB,SAChB,GAAG,CAAC,cAAc,cACZ,sBAAsB,WACzB,YAAY,UACb,MAAM,KACf,IASF,CAAC;AAEF,OAAO,EAAE,KAAK,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC"}
@@ -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;IACv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AAoB,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"}
@@ -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> & StackActionHelpers<ParamList>;\n\n/** Props a stack screen component receives. */\ntype StackScreenProps<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = {\n /** Navigation object of the screen. */\n navigation: StackNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Arguments of a custom stack `header` renderer. */\ntype StackHeaderProps = {\n /** The route whose header is rendered. */\n route: RouteProp<ParamListBase>;\n /** Navigation object of that route. */\n navigation: StackNavigationProp<ParamListBase>;\n /** Resolved options of that route. */\n options: StackNavigationOptions;\n /** The page below this one in the stack, if any. */\n back?: StackHeaderBack;\n};\n\n/** Navigation helpers of the stack navigator itself. */\ntype StackNavigationHelpers = NavigationHelpers<ParamListBase, StackNavigationEventMap> &\n StackActionHelpers<ParamListBase>;\n\n/** Descriptor of one stack route. */\ntype StackDescriptor = Descriptor<StackNavigationOptions, StackNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;\n/** Descriptors of the stack routes, keyed by route key. */\ntype StackDescriptorMap = Record<string, StackDescriptor>;\n\n/** Props of the stack `Navigator` component. */\ntype StackNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n StackNavigationState<ParamListBase>,\n StackNavigationOptions,\n StackNavigationEventMap,\n StackNavigationProp<ParamListBase>\n> &\nStackRouterOptions &\nStackNavigationConfig;\n\nexport type {\n StackDescriptor,\n StackDescriptorMap,\n StackHeaderBack,\n StackHeaderProps,\n StackNavigationConfig,\n StackNavigationEventMap,\n StackNavigationHelpers,\n StackNavigationOptions,\n StackNavigationProp,\n StackNavigatorProps,\n StackScreenProps,\n StackTransitionData,\n};\n"]}
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":"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;AAqEF,QAAA,MAAM,OAAO,GAAI,oDAA4D,YAAY,KAAG,SAoC3F,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,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"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
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";
@@ -30,21 +30,19 @@ const TabHeader = (props) => {
30
30
  ? defaultTabHeader(props)
31
31
  : options.header({ route, navigation, options, viewSwitcher }) }));
32
32
  };
33
- const TabPage = ({ descriptor, isLoaded }) => {
33
+ const TabPage = ({ descriptor, isFocused, isLoaded }) => {
34
34
  const { route, options } = descriptor;
35
- 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() }));
36
36
  };
37
37
  const TabView = ({ state, navigation, descriptors, tabBarPosition = "top" }) => {
38
38
  const [stack, setStack] = useState(null);
39
39
  const focused = getFocusedRoute(state);
40
40
  const descriptor = requireDescriptor(descriptors, focused.key);
41
41
  const onVisibleChildChanged = useTabSelection(navigation);
42
- const viewSwitcher = stack === null
43
- ? undefined
44
- : _jsx(AdwViewSwitcher, { stack: stack, policy: Adw.ViewSwitcherPolicy.WIDE });
42
+ const viewSwitcher = stack === null ? undefined : _jsx(AdwViewSwitcher, { stack: stack, policy: Adw.ViewSwitcherPolicy.WIDE });
45
43
  const hasSwitcherBar = tabBarPosition === "bottom" && stack !== null;
46
44
  usePopToTopOnBlur(state, descriptors, navigation);
47
- return (_jsx(AdwToolbarView, { topBar: (_jsx(TabHeader, { descriptor: descriptor, viewSwitcher: tabBarPosition === "top" ? viewSwitcher : undefined })), bottomBar: hasSwitcherBar ? _jsx(AdwViewSwitcherBar, { stack: stack, reveal: true }) : undefined, children: _jsx(AdwViewStack, { ref: setStack, visibleChildName: focused.key, enableTransitions: descriptor.options.animation === "fade", onNotifyVisibleChildName: onVisibleChildChanged, children: state.routes.map((route) => (_jsx(TabPage, { descriptor: requireDescriptor(descriptors, route.key), isLoaded: route.key === focused.key || state.preloadedRouteKeys.includes(route.key) }, route.key))) }) }));
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))) }) }));
48
46
  };
49
47
  export { TabView };
50
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,MAA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GAAG,KAAK,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAF9E,KAAK,CAAC,GAAG,CAGhB,CACL,CAAC,GACS,GACF,CACpB,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import type { ParamListBase, TabNavigationState } from \"@react-navigation/core\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport { AdwToolbarView, AdwViewStack, AdwViewSwitcher, AdwViewSwitcherBar, AdwWindowTitle } from \"@gtkx/jsx/adw\";\nimport { CommonActions } from \"@react-navigation/core\";\nimport { useCallback, useState } from \"react\";\nimport type { TabDescriptor, TabDescriptorMap, TabNavigationConfig, TabNavigationHelpers } from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { getFocusedRoute, requireDescriptor } from \"../shared/routes.js\";\nimport { ScenePage } from \"../shared/scene-page.js\";\nimport { usePopToTopOnBlur } from \"../shared/use-pop-to-top-on-blur.js\";\n\ntype TabViewProps = TabNavigationConfig & {\n state: TabNavigationState<ParamListBase>;\n navigation: TabNavigationHelpers;\n descriptors: TabDescriptorMap;\n};\n\ntype TabHeaderProps = {\n descriptor: TabDescriptor;\n viewSwitcher: ReactElement | undefined;\n};\n\ntype TabPageProps = {\n descriptor: TabDescriptor;\n isLoaded: boolean;\n};\n\nconst useTabSelection = (navigation: TabNavigationHelpers): ((name: string | null) => void) =>\n useCallback((name: string | null) => {\n const current = navigation.getState();\n const focusedKey = getFocusedRoute(current).key;\n const route = current.routes.find((candidate) => candidate.key === name);\n\n if (route === undefined || route.key === focusedKey) {\n return;\n }\n\n const event = navigation.emit({ type: \"tabPress\", target: route.key, canPreventDefault: true });\n\n if (!event.defaultPrevented) {\n navigation.dispatch({ ...CommonActions.navigate(route.name, route.params), target: current.key });\n }\n }, [navigation]);\n\nconst defaultTabHeader = ({ descriptor, viewSwitcher }: TabHeaderProps): ReactElement => (\n <HeaderBar\n options={descriptor.options}\n titleWidget={viewSwitcher ?? <AdwWindowTitle title={descriptor.options.title ?? descriptor.route.name} />}\n />\n);\n\nconst TabHeader = (props: TabHeaderProps): ReactNode => {\n const { descriptor, viewSwitcher } = props;\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return <>{viewSwitcher}</>;\n }\n\n return (\n <>\n {options.header === undefined\n ? defaultTabHeader(props)\n : options.header({ route, navigation, options, viewSwitcher })}\n </>\n );\n};\n\nconst TabPage = ({ descriptor, isLoaded }: TabPageProps): ReactNode => {\n const { route, options } = descriptor;\n\n return (\n <ScenePage\n name={route.key}\n title={options.tabBarLabel ?? options.title ?? route.name}\n iconName={options.tabBarIcon}\n badgeNumber={options.tabBarBadge}\n needsAttention={options.needsAttention}\n isLoaded={isLoaded || options.lazy === false}\n render={() => descriptor.render()}\n />\n );\n};\n\nconst TabView = ({ state, navigation, descriptors, tabBarPosition = \"top\" }: TabViewProps): ReactNode => {\n const [stack, setStack] = useState<Adw.ViewStack | null>(null);\n const focused = getFocusedRoute(state);\n const descriptor = requireDescriptor(descriptors, focused.key);\n const onVisibleChildChanged = useTabSelection(navigation);\n\n const viewSwitcher = stack === null\n ? undefined\n : <AdwViewSwitcher stack={stack} policy={Adw.ViewSwitcherPolicy.WIDE} />;\n\n const hasSwitcherBar = tabBarPosition === \"bottom\" && stack !== null;\n usePopToTopOnBlur(state, descriptors, navigation);\n\n return (\n <AdwToolbarView\n topBar={(\n <TabHeader descriptor={descriptor} viewSwitcher={tabBarPosition === \"top\" ? viewSwitcher : undefined} />\n )}\n bottomBar={hasSwitcherBar ? <AdwViewSwitcherBar stack={stack} reveal /> : undefined}\n >\n <AdwViewStack\n ref={setStack}\n visibleChildName={focused.key}\n enableTransitions={descriptor.options.animation === \"fade\"}\n onNotifyVisibleChildName={onVisibleChildChanged}\n >\n {state.routes.map((route) => (\n <TabPage\n key={route.key}\n descriptor={requireDescriptor(descriptors, route.key)}\n isLoaded={route.key === focused.key || state.preloadedRouteKeys.includes(route.key)}\n />\n ))}\n </AdwViewStack>\n </AdwToolbarView>\n );\n};\n\nexport { TabView };\n"]}
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,MAAM,qCAAqC,CAAC;AAmBxE,MAAM,eAAe,GAAG,CAAC,UAAgC,EAAmC,EAAE,CAC1F,WAAW,CACP,CAAC,IAAmB,EAAE,EAAE;IACpB,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;IAEzE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QAClD,OAAO;IACX,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,GAA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AElD,OAAO,CACH,KAAC,cAAc,IACX,MAAM,EACF,KAAC,SAAS,IAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,GAAI,EAE5G,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,KAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,SAAG,CAAC,CAAC,CAAC,SAAS,YAEnF,KAAC,YAAY,IACT,GAAG,EAAE,QAAQ,EACb,gBAAgB,EAAE,OAAO,CAAC,GAAG,EAC7B,iBAAiB,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS,KAAK,MAAM,EAC1D,wBAAwB,EAAE,qBAAqB,YAE9C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACzB,KAAC,OAAO,IAEJ,UAAU,EAAE,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,EACrD,SAAS,EAAE,KAAK,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"]}
@@ -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. */
@@ -1 +1 @@
1
- {"version":3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AC5C,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,kBAAkB,CAAC,aAAa,CAAC,EACjC,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAAC,aAAa,CAAC,CACnC,GACD,gBAAgB,GAChB,mBAAmB,CAAC;AAEpB,YAAY,EACR,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACjB,CAAC"}
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,+CAA+C;AAC/C,KAAK,oBAAoB,GAAG,aAAa,GAAG;IACxC,sEAAsE;IACtE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,CAAC;IAC9C,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,cAAc,CAAC,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AAEF,sDAAsD;AACtD,KAAK,oBAAoB,GAAG,iBAAiB,CAAC,aAAa,EAAE,qBAAqB,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;AACtH,mCAAmC;AACnC,KAAK,aAAa,GAAG,UAAU,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;AAClH,yDAAyD;AACzD,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEtD,8CAA8C;AAC9C,KAAK,iBAAiB,GAAG,uBAAuB,CAC5C,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,kBAAkB,CAAC,aAAa,CAAC,EACjC,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAAC,aAAa,CAAC,CACnC,GACG,gBAAgB,GAChB,mBAAmB,CAAC;AAExB,YAAY,EACR,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACjB,CAAC"}
@@ -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> & TabActionHelpers<ParamList>;\n\n/** Props a tab screen component receives. */\ntype TabScreenProps<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = {\n /** Navigation object of the screen. */\n navigation: TabNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Arguments of a custom tab `header` renderer. */\ntype TabHeaderProps = {\n /** The focused route. */\n route: RouteProp<ParamListBase>;\n /** Navigation object of the focused route. */\n navigation: TabNavigationProp<ParamListBase>;\n /** Resolved options of the focused route. */\n options: TabNavigationOptions;\n /** The view switcher to place in the header when `tabBarPosition` is `\"top\"`. */\n viewSwitcher: ReactNode;\n};\n\n/** Navigation helpers of the tab navigator itself. */\ntype TabNavigationHelpers = NavigationHelpers<ParamListBase, TabNavigationEventMap> & TabActionHelpers<ParamListBase>;\n/** Descriptor of one tab route. */\ntype TabDescriptor = Descriptor<TabNavigationOptions, TabNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;\n/** Descriptors of the tab routes, keyed by route key. */\ntype TabDescriptorMap = Record<string, TabDescriptor>;\n\n/** Props of the tab `Navigator` component. */\ntype TabNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n TabNavigationState<ParamListBase>,\n TabNavigationOptions,\n TabNavigationEventMap,\n TabNavigationProp<ParamListBase>\n> &\nTabRouterOptions &\nTabNavigationConfig;\n\nexport type {\n TabDescriptor,\n TabDescriptorMap,\n TabHeaderProps,\n TabNavigationConfig,\n TabNavigationEventMap,\n TabNavigationHelpers,\n TabNavigationOptions,\n TabNavigationProp,\n TabNavigatorProps,\n TabScreenProps,\n};\n"]}
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"]}
@@ -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;IAEpC,UAAU,KAAM,SAAQ,YAAY;KAAG;CAC1C;AAED,+BAA+B;AAC/B,QAAA,MAAM,YAAY,EAAE,YAAmD,CAAC;AACxE,8BAA8B;AAC9B,QAAA,MAAM,SAAS,EAAE,YAAkD,CAAC;AAEpE,QAAA,MAAM,eAAe,QAAO,YAM3B,CAAC;AAEF,OAAO,EAAE,KAAK,YAAY,IAAI,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC"}
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,OAA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AC;AAEF,OAAO,EAA8B,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import * as Adw from \"@gtkx/gi/adw\";\nimport { useProperty } from \"@gtkx/react\";\nimport { useMemo } from \"react\";\n\n/** Style state handed to `useTheme` and to option callbacks as `theme`, mirroring Adwaita's style manager. */\ntype AdwaitaTheme = {\n /** Whether the application currently uses the dark color scheme. */\n dark: boolean;\n /** Whether the system requested high-contrast styling. */\n highContrast: boolean;\n};\n\ndeclare module \"@react-navigation/core\" {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Theme extends AdwaitaTheme {}\n}\n\n/** The light Adwaita theme. */\nconst DefaultTheme: AdwaitaTheme = { dark: false, highContrast: false };\n/** The dark Adwaita theme. */\nconst DarkTheme: AdwaitaTheme = { dark: true, highContrast: false };\n\nconst useAdwaitaTheme = (): AdwaitaTheme => {\n const manager = Adw.StyleManager.getDefault();\n const isDark = useProperty(manager, \"dark\") ?? manager.getDark();\n const isHighContrast = useProperty(manager, \"highContrast\") ?? manager.getHighContrast();\n\n return useMemo(() => ({ dark: isDark, highContrast: isHighContrast }), [isDark, isHighContrast]);\n};\n\nexport { type AdwaitaTheme as Theme, DarkTheme, DefaultTheme, useAdwaitaTheme };\n"]}
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/navigation",
3
- "version": "2.0.0-beta.11",
3
+ "version": "2.0.0-beta.12",
4
4
  "description": "React Navigation navigators for GTKX.",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -40,36 +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.11",
58
- "@react-navigation/core": "^7.22.1",
59
- "@react-navigation/routers": "^7.6.4"
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
52
  "@types/react": "^19.3",
63
53
  "react": "^19.3"
64
54
  },
65
55
  "devDependencies": {
66
- "@gtkx/config": "2.0.0-beta.11",
67
- "@gtkx/testing": "2.0.0-beta.11",
68
- "@gtkx/vitest": "2.0.0-beta.11",
56
+ "@gtkx/config": "2.0.0-beta.12",
57
+ "@gtkx/testing": "2.0.0-beta.12",
58
+ "@gtkx/vitest": "2.0.0-beta.12",
69
59
  "@types/react": "^19.3.0",
70
- "vitest": "^5.0.1"
60
+ "vitest": "5.0.5"
71
61
  },
72
62
  "scripts": {
73
- "release": "tsx ../../scripts/release-package.ts"
63
+ "release": "node ../../scripts/release/publish-package.ts"
74
64
  }
75
65
  }
@@ -3,7 +3,7 @@ import type { ReactNode } from "react";
3
3
  import * as Gtk from "@gtkx/gi/gtk";
4
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,27 +29,31 @@ const didNavigateToRow = (navigation: DrawerNavigationHelpers, state: Navigation
29
29
  };
30
30
 
31
31
  const useDrawerItemPress = (navigation: DrawerNavigationHelpers, isCollapsed: boolean): RowActivated =>
32
- useCallback((row: Gtk.ListBoxRow) => {
33
- const state = navigation.getState();
32
+ useCallback(
33
+ (row: Gtk.ListBoxRow) => {
34
+ const state = navigation.getState();
34
35
 
35
- if (!didNavigateToRow(navigation, state, row.getIndex())) {
36
- return;
37
- }
36
+ if (!didNavigateToRow(navigation, state, row.getIndex())) {
37
+ return;
38
+ }
38
39
 
39
- if (isCollapsed) {
40
- navigation.dispatch({ ...DrawerActions.closeDrawer(), target: state.key });
41
- }
42
- }, [navigation, isCollapsed]);
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;
46
49
  const label = options.drawerLabel ?? options.title ?? route.name;
50
+ const [labelWidget, setLabelWidget] = useState<Gtk.Label | null>(null);
47
51
 
48
52
  return (
49
- <GtkListBoxRow accessibleLabel={label}>
53
+ <GtkListBoxRow accessibleLabelledBy={labelWidget === null ? undefined : [labelWidget]}>
50
54
  <GtkBox spacing={12}>
51
55
  {options.drawerIcon === undefined ? null : <GtkImage iconName={options.drawerIcon} />}
52
- <GtkLabel label={label} xalign={0} />
56
+ <GtkLabel ref={setLabelWidget} label={label} useUnderline={options.useUnderline ?? false} xalign={0} />
53
57
  </GtkBox>
54
58
  </GtkListBoxRow>
55
59
  );
@@ -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 = (isCollapsed: () => boolean): DrawerRouterFactory => (options) =>
88
- withShownSidebar(DrawerRouter(options), isCollapsed);
87
+ const createDrawerRouter =
88
+ (isCollapsed: () => boolean): DrawerRouterFactory =>
89
+ (options) =>
90
+ withShownSidebar(DrawerRouter(options), isCollapsed);
89
91
 
90
92
  export { createDrawerRouter, type DrawerRouterFactory };
@@ -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";
@@ -39,20 +33,24 @@ type DrawerHeaderProps = {
39
33
 
40
34
  type DrawerPageProps = {
41
35
  descriptor: DrawerDescriptor;
36
+ isFocused: boolean;
42
37
  isLoaded: boolean;
43
38
  };
44
39
 
45
40
  const PACK_TYPES = { start: Gtk.PackType.START, end: Gtk.PackType.END } as const;
46
41
 
47
42
  const useSidebarSync = (navigation: DrawerNavigationHelpers): ((isShown: boolean | null) => void) =>
48
- useCallback((isShown: boolean | null) => {
49
- if (isShown === null) {
50
- return;
51
- }
52
-
53
- const action = isShown ? DrawerActions.openDrawer() : DrawerActions.closeDrawer();
54
- navigation.dispatch({ ...action, target: navigation.getState().key });
55
- }, [navigation]);
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
+ );
56
54
 
57
55
  const useCloseOnNavigate = (
58
56
  state: DrawerNavigationState<ParamListBase>,
@@ -111,13 +109,14 @@ const DrawerHeader = ({ descriptor, navigation }: DrawerHeaderProps): ReactNode
111
109
  );
112
110
  };
113
111
 
114
- const DrawerPage = ({ descriptor, isLoaded }: DrawerPageProps): ReactNode => {
112
+ const DrawerPage = ({ descriptor, isFocused, isLoaded }: DrawerPageProps): ReactNode => {
115
113
  const { route, options } = descriptor;
116
114
 
117
115
  return (
118
116
  <ScenePage
119
117
  name={route.key}
120
118
  title={options.title ?? route.name}
119
+ isFocused={isFocused}
121
120
  isLoaded={isLoaded || options.lazy === false}
122
121
  render={() => descriptor.render()}
123
122
  />
@@ -153,6 +152,7 @@ const DrawerView = ({ state, navigation, descriptors, drawerContent, ...config }
153
152
  <DrawerPage
154
153
  key={route.key}
155
154
  descriptor={requireDescriptor(descriptors, route.key)}
155
+ isFocused={route.key === focused.key}
156
156
  isLoaded={route.key === focused.key || state.preloadedRouteKeys.includes(route.key)}
157
157
  />
158
158
  ))}