@gtkx/navigation 2.0.0-beta.12 → 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 +1 -1
- 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-view.js +2 -2
- package/dist/drawer/drawer-view.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/shared/scene-page.d.ts.map +1 -1
- package/dist/shared/scene-page.js +2 -5
- 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/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 +39 -14
- 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-view.js +1 -1
- package/dist/stack/stack-view.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.js +1 -1
- package/dist/tabs/tab-view.js.map +1 -1
- package/dist/theme.js +2 -2
- package/dist/theme.js.map +1 -1
- package/package.json +6 -6
- package/src/drawer/create-drawer-navigator.tsx +23 -11
- package/src/drawer/drawer-view.tsx +2 -2
- package/src/index.ts +30 -0
- package/src/shared/scene-page.tsx +2 -6
- 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 +92 -45
- package/src/split-view/types.ts +9 -2
- package/src/stack/create-stack-navigator.tsx +11 -1
- package/src/stack/stack-view.tsx +1 -1
- 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 +2 -2
- package/src/theme.ts +2 -2
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type * as Adw from "@gtkx/gi/adw";
|
|
2
|
+
import type * as Gio from "@gtkx/gi/gio";
|
|
3
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
4
|
+
import type { AdwTabDropProps } from "@gtkx/react/internal";
|
|
5
|
+
import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, NavigationState, ParamListBase, RouteProp } from "@react-navigation/core";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import type { HeaderOptions } from "../shared/types.js";
|
|
8
|
+
/** Navigation state of a tab view navigator. Pinned routes come first in `routes`, in `pinnedKeys` order. */
|
|
9
|
+
type TabViewNavigationState<ParamList extends ParamListBase> = NavigationState<ParamList> & {
|
|
10
|
+
/** Type of the router, in this case `tabview`. */
|
|
11
|
+
type: "tabview";
|
|
12
|
+
/** Keys of the pinned routes. */
|
|
13
|
+
pinnedKeys: string[];
|
|
14
|
+
/** Key of the tab each tab was opened from, by route key. */
|
|
15
|
+
parents: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
/** Options accepted when opening a tab. */
|
|
18
|
+
type TabViewOpenOptions = {
|
|
19
|
+
/** Key of the tab the new one is opened from; the new tab follows that tab and its descendants, which are selected again when it closes. */
|
|
20
|
+
parent?: string;
|
|
21
|
+
/** Whether the new tab is selected; defaults to `true`. */
|
|
22
|
+
select?: boolean;
|
|
23
|
+
/** Position among the unpinned tabs; defaults to the end. */
|
|
24
|
+
position?: number;
|
|
25
|
+
};
|
|
26
|
+
/** Actions specific to the tab view router. */
|
|
27
|
+
type TabViewActionType = {
|
|
28
|
+
type: "OPEN_TAB";
|
|
29
|
+
payload: {
|
|
30
|
+
name: string;
|
|
31
|
+
params?: object;
|
|
32
|
+
key?: string;
|
|
33
|
+
parent?: string;
|
|
34
|
+
select?: boolean;
|
|
35
|
+
position?: number;
|
|
36
|
+
pinned?: boolean;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
type: "CLOSE_TAB";
|
|
40
|
+
payload: {
|
|
41
|
+
key?: string;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
type: "CLOSE_OTHER_TABS";
|
|
45
|
+
payload: {
|
|
46
|
+
key?: string;
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
type: "CLOSE_TABS_BEFORE";
|
|
50
|
+
payload: {
|
|
51
|
+
key?: string;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
type: "CLOSE_TABS_AFTER";
|
|
55
|
+
payload: {
|
|
56
|
+
key?: string;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
type: "SELECT_TAB";
|
|
60
|
+
payload: {
|
|
61
|
+
key: string;
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
type: "REORDER_TAB";
|
|
65
|
+
payload: {
|
|
66
|
+
key: string;
|
|
67
|
+
position: number;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
type: "PIN_TAB";
|
|
71
|
+
payload: {
|
|
72
|
+
key: string;
|
|
73
|
+
pinned: boolean;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/** Action helpers added to the navigation object of tab view screens. Keys default to the selected tab. */
|
|
77
|
+
type TabViewActionHelpers<ParamList extends ParamListBase> = {
|
|
78
|
+
/** Opens a new tab for a screen, or selects the open tab whose `getId` matches. */
|
|
79
|
+
openTab<RouteName extends keyof ParamList>(name: RouteName, params?: ParamList[RouteName], options?: TabViewOpenOptions): void;
|
|
80
|
+
/** Closes a tab. Closing the last tab is left to the parent navigator or `onUnhandledAction`. */
|
|
81
|
+
closeTab(key?: string): void;
|
|
82
|
+
/** Closes every unpinned tab except one. */
|
|
83
|
+
closeOtherTabs(key?: string): void;
|
|
84
|
+
/** Closes the unpinned tabs before one. */
|
|
85
|
+
closeTabsBefore(key?: string): void;
|
|
86
|
+
/** Closes the unpinned tabs after one. */
|
|
87
|
+
closeTabsAfter(key?: string): void;
|
|
88
|
+
/** Selects a tab. */
|
|
89
|
+
selectTab(key: string): void;
|
|
90
|
+
/** Moves a tab within its pinned or unpinned group. */
|
|
91
|
+
reorderTab(key: string, position: number): void;
|
|
92
|
+
/** Pins a tab, moving it after the other pinned tabs, or unpins it, moving it before the unpinned tabs. */
|
|
93
|
+
pinTab(key: string, pinned: boolean): void;
|
|
94
|
+
};
|
|
95
|
+
/** Events the tab view navigator emits on top of React Navigation's core events. */
|
|
96
|
+
type TabViewNavigationEventMap = {
|
|
97
|
+
/** The user selected a tab natively. */
|
|
98
|
+
tabPress: {
|
|
99
|
+
/** No payload. */
|
|
100
|
+
data: undefined;
|
|
101
|
+
/** Calling `preventDefault` keeps the current tab. */
|
|
102
|
+
canPreventDefault: true;
|
|
103
|
+
};
|
|
104
|
+
/** The user activated the tab's indicator icon. */
|
|
105
|
+
indicatorActivated: {
|
|
106
|
+
/** No payload. */
|
|
107
|
+
data: undefined;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/** An icon given by theme name or as a `Gio.Icon`. */
|
|
111
|
+
type TabViewIcon = string | Gio.Icon;
|
|
112
|
+
/** Per-screen options of the tab view navigator. */
|
|
113
|
+
type TabViewNavigationOptions = HeaderOptions & {
|
|
114
|
+
/** Renders a custom top bar instead of the default `AdwHeaderBar`. */
|
|
115
|
+
header?: (props: TabViewHeaderProps) => ReactNode;
|
|
116
|
+
/** Icon shown in the tab; `null` shows the view's default icon. */
|
|
117
|
+
icon?: TabViewIcon | null;
|
|
118
|
+
/** Tooltip of the tab; supports Pango markup. */
|
|
119
|
+
tooltip?: string;
|
|
120
|
+
/** Search keyword for the tab overview. */
|
|
121
|
+
keyword?: string;
|
|
122
|
+
/** Whether the tab shows a loading spinner instead of its icon. */
|
|
123
|
+
loading?: boolean;
|
|
124
|
+
/** Whether the tab is highlighted as needing attention. */
|
|
125
|
+
needsAttention?: boolean;
|
|
126
|
+
/** Indicator icon shown at the end of the tab. */
|
|
127
|
+
indicatorIcon?: TabViewIcon | null;
|
|
128
|
+
/** Whether clicking the indicator emits `indicatorActivated`. */
|
|
129
|
+
indicatorActivatable?: boolean;
|
|
130
|
+
/** Tooltip of the indicator icon; supports Pango markup. */
|
|
131
|
+
indicatorTooltip?: string;
|
|
132
|
+
/** Whether the overview thumbnail stays live while the tab is not selected. */
|
|
133
|
+
liveThumbnail?: boolean;
|
|
134
|
+
/** Horizontal alignment of the overview thumbnail, from 0 to 1. */
|
|
135
|
+
thumbnailXalign?: number;
|
|
136
|
+
/** Vertical alignment of the overview thumbnail, from 0 to 1. */
|
|
137
|
+
thumbnailYalign?: number;
|
|
138
|
+
/** Whether the screen mounts on first selection instead of as soon as the tab opens; defaults to `true`. */
|
|
139
|
+
lazy?: boolean;
|
|
140
|
+
};
|
|
141
|
+
/** The screen a new tab opens, as returned by the overview's `onCreateTab`. */
|
|
142
|
+
type TabViewTarget = {
|
|
143
|
+
/** Name of the screen to open. */
|
|
144
|
+
name: string;
|
|
145
|
+
/** Params of the new tab. */
|
|
146
|
+
params?: object;
|
|
147
|
+
};
|
|
148
|
+
/** Settings of the `AdwTabOverview` rendered around the view. */
|
|
149
|
+
type TabViewOverviewConfig = {
|
|
150
|
+
/**
|
|
151
|
+
* Whether the overview is open. When given, the overview follows it: the user opening or closing the overview
|
|
152
|
+
* calls `onOpenChange`, and a value the app does not update is restored. Leave it out to let the overview open
|
|
153
|
+
* and close on its own.
|
|
154
|
+
*/
|
|
155
|
+
open?: boolean;
|
|
156
|
+
/** Called when the overview opens or closes natively. */
|
|
157
|
+
onOpenChange?: (open: boolean) => void;
|
|
158
|
+
/** Whether the overview shows a new tab button; defaults to `false`. */
|
|
159
|
+
enableNewTab?: boolean;
|
|
160
|
+
/** Whether the overview offers search; defaults to `true`. */
|
|
161
|
+
enableSearch?: boolean;
|
|
162
|
+
/** Returns the screen the new tab button opens. */
|
|
163
|
+
onCreateTab?: () => TabViewTarget;
|
|
164
|
+
};
|
|
165
|
+
/** Additional drop target of the tab bar and overview. */
|
|
166
|
+
type TabViewExtraDropTarget = NonNullable<AdwTabDropProps["extraDropTarget"]>;
|
|
167
|
+
/** Props of the tab view navigator beyond the options every navigator shares. */
|
|
168
|
+
type TabViewNavigationConfig = {
|
|
169
|
+
/** A view created before the navigator renders, such as one returned from a `create-window` handler. */
|
|
170
|
+
view?: Adw.TabView;
|
|
171
|
+
/** Whether the tab bar renders; defaults to `true`. */
|
|
172
|
+
tabBarVisible?: boolean;
|
|
173
|
+
/** Whether the tab bar hides with a single tab; defaults to `true`. */
|
|
174
|
+
tabBarAutohide?: boolean;
|
|
175
|
+
/** Whether tabs expand to fill the bar; defaults to `true`. */
|
|
176
|
+
tabBarExpand?: boolean;
|
|
177
|
+
/** Whether close buttons sit at the start of tabs; defaults to `false`. */
|
|
178
|
+
tabBarInverted?: boolean;
|
|
179
|
+
/** Renders an `AdwTabOverview` around the view. */
|
|
180
|
+
overview?: TabViewOverviewConfig;
|
|
181
|
+
/** An existing menu model to use as the tabs' context menu. Use `renderMenu` to declare the menu in JSX instead. */
|
|
182
|
+
menuModel?: Gio.MenuModel | null;
|
|
183
|
+
/**
|
|
184
|
+
* Renders the tabs' context menu. Attach `ref` to a `GMenu`, or to any menu model element, anywhere in the
|
|
185
|
+
* returned tree; the navigator renders the tree outside the widget hierarchy and uses that model. A navigator
|
|
186
|
+
* given both `renderMenu` and a `menuModel` throws.
|
|
187
|
+
*/
|
|
188
|
+
renderMenu?: (ref: (menu: Gio.MenuModel | null) => void) => ReactNode;
|
|
189
|
+
/** Additional content accepted by drops on tabs. */
|
|
190
|
+
extraDropTarget?: TabViewExtraDropTarget | null;
|
|
191
|
+
/** Handles content dropped on a tab; returns whether the drop was accepted. */
|
|
192
|
+
onExtraDragDrop?: (route: RouteProp<ParamListBase>, value: GObject.Value) => boolean;
|
|
193
|
+
/** Returns the view of a new window when a tab is dragged out of this one. */
|
|
194
|
+
onCreateWindow?: () => Adw.TabView | null;
|
|
195
|
+
/** Called with the tab whose context menu opens, or `null` when it closes, after the chosen menu action has run. */
|
|
196
|
+
onSetupMenu?: (route: RouteProp<ParamListBase> | null) => void;
|
|
197
|
+
/** Keyboard shortcuts the view handles. */
|
|
198
|
+
shortcuts?: Adw.TabViewShortcuts;
|
|
199
|
+
/** Icon of tabs without an `icon` option. */
|
|
200
|
+
defaultIcon?: TabViewIcon | null;
|
|
201
|
+
};
|
|
202
|
+
/** Options of the tab view router. */
|
|
203
|
+
type TabViewRouterOptions = {
|
|
204
|
+
/** Screen of the tab opened when the view starts empty; defaults to the first screen. */
|
|
205
|
+
initialRouteName?: string;
|
|
206
|
+
/**
|
|
207
|
+
* Whether closing the last tab replaces it with a new tab of the initial route, instead of leaving that close
|
|
208
|
+
* unhandled for a parent navigator or the container's `onUnhandledAction`. Use it for a tab view inside a section
|
|
209
|
+
* of the app rather than a window of its own; defaults to `false`.
|
|
210
|
+
*/
|
|
211
|
+
replaceLastTab?: boolean;
|
|
212
|
+
};
|
|
213
|
+
/** Navigation object of a tab view screen. */
|
|
214
|
+
type TabViewNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = NavigationProp<ParamList, RouteName, NavigatorID, TabViewNavigationState<ParamList>, TabViewNavigationOptions, TabViewNavigationEventMap> & TabViewActionHelpers<ParamList>;
|
|
215
|
+
/** Props a tab view screen component receives. */
|
|
216
|
+
type TabViewScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = keyof ParamList, NavigatorID extends string | undefined = undefined> = {
|
|
217
|
+
/** Navigation object of the screen. */
|
|
218
|
+
navigation: TabViewNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
219
|
+
/** The route the screen renders. */
|
|
220
|
+
route: RouteProp<ParamList, RouteName>;
|
|
221
|
+
};
|
|
222
|
+
/** Arguments of a custom tab view `header` renderer. */
|
|
223
|
+
type TabViewHeaderProps = {
|
|
224
|
+
/** The selected route. */
|
|
225
|
+
route: RouteProp<ParamListBase>;
|
|
226
|
+
/** Navigation object of the selected route. */
|
|
227
|
+
navigation: TabViewNavigationProp<ParamListBase>;
|
|
228
|
+
/** Resolved options of the selected route. */
|
|
229
|
+
options: TabViewNavigationOptions;
|
|
230
|
+
};
|
|
231
|
+
/** Navigation helpers of the tab view navigator itself. */
|
|
232
|
+
type TabViewNavigationHelpers = NavigationHelpers<ParamListBase, TabViewNavigationEventMap> & TabViewActionHelpers<ParamListBase>;
|
|
233
|
+
/** Descriptor of one tab view route. */
|
|
234
|
+
type TabViewDescriptor = Descriptor<TabViewNavigationOptions, TabViewNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
|
|
235
|
+
/** Descriptors of the tab view routes, keyed by route key. */
|
|
236
|
+
type TabViewDescriptorMap = Record<string, TabViewDescriptor>;
|
|
237
|
+
/** Props of the tab view `Navigator` component. */
|
|
238
|
+
type TabViewNavigatorProps = DefaultNavigatorOptions<ParamListBase, string | undefined, TabViewNavigationState<ParamListBase>, TabViewNavigationOptions, TabViewNavigationEventMap, TabViewNavigationProp<ParamListBase>> & TabViewRouterOptions & TabViewNavigationConfig;
|
|
239
|
+
export type { TabViewActionHelpers, TabViewActionType, TabViewDescriptor, TabViewDescriptorMap, TabViewExtraDropTarget, TabViewHeaderProps, TabViewIcon, TabViewNavigationConfig, TabViewNavigationEventMap, TabViewNavigationHelpers, TabViewNavigationOptions, TabViewNavigationProp, TabViewNavigationState, TabViewNavigatorProps, TabViewOpenOptions, TabViewOverviewConfig, TabViewRouterOptions, TabViewScreenProps, TabViewTarget, };
|
|
240
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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G,oBAAoB,GACpB,uBAAuB,CAAC;AAE5B,YAAY,EACR,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,GAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tab-view/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type * as Gio from \"@gtkx/gi/gio\";\nimport type * as GObject from \"@gtkx/gi/gobject\";\nimport type { AdwTabDropProps } from \"@gtkx/react/internal\";\nimport type {\n DefaultNavigatorOptions,\n Descriptor,\n NavigationHelpers,\n NavigationProp,\n NavigationState,\n ParamListBase,\n RouteProp,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport type { HeaderOptions } from \"../shared/types.js\";\n\n/** Navigation state of a tab view navigator. Pinned routes come first in `routes`, in `pinnedKeys` order. */\ntype TabViewNavigationState<ParamList extends ParamListBase> = NavigationState<ParamList> & {\n /** Type of the router, in this case `tabview`. */\n type: \"tabview\";\n /** Keys of the pinned routes. */\n pinnedKeys: string[];\n /** Key of the tab each tab was opened from, by route key. */\n parents: Record<string, string>;\n};\n\n/** Options accepted when opening a tab. */\ntype TabViewOpenOptions = {\n /** Key of the tab the new one is opened from; the new tab follows that tab and its descendants, which are selected again when it closes. */\n parent?: string;\n /** Whether the new tab is selected; defaults to `true`. */\n select?: boolean;\n /** Position among the unpinned tabs; defaults to the end. */\n position?: number;\n};\n\n/** Actions specific to the tab view router. */\ntype TabViewActionType =\n | {\n type: \"OPEN_TAB\";\n payload: {\n name: string;\n params?: object;\n key?: string;\n parent?: string;\n select?: boolean;\n position?: number;\n pinned?: boolean;\n };\n }\n | { type: \"CLOSE_TAB\"; payload: { key?: string } }\n | { type: \"CLOSE_OTHER_TABS\"; payload: { key?: string } }\n | { type: \"CLOSE_TABS_BEFORE\"; payload: { key?: string } }\n | { type: \"CLOSE_TABS_AFTER\"; payload: { key?: string } }\n | { type: \"SELECT_TAB\"; payload: { key: string } }\n | { type: \"REORDER_TAB\"; payload: { key: string; position: number } }\n | { type: \"PIN_TAB\"; payload: { key: string; pinned: boolean } };\n\n/** Action helpers added to the navigation object of tab view screens. Keys default to the selected tab. */\ntype TabViewActionHelpers<ParamList extends ParamListBase> = {\n /** Opens a new tab for a screen, or selects the open tab whose `getId` matches. */\n openTab<RouteName extends keyof ParamList>(\n name: RouteName,\n params?: ParamList[RouteName],\n options?: TabViewOpenOptions,\n ): void;\n /** Closes a tab. Closing the last tab is left to the parent navigator or `onUnhandledAction`. */\n closeTab(key?: string): void;\n /** Closes every unpinned tab except one. */\n closeOtherTabs(key?: string): void;\n /** Closes the unpinned tabs before one. */\n closeTabsBefore(key?: string): void;\n /** Closes the unpinned tabs after one. */\n closeTabsAfter(key?: string): void;\n /** Selects a tab. */\n selectTab(key: string): void;\n /** Moves a tab within its pinned or unpinned group. */\n reorderTab(key: string, position: number): void;\n /** Pins a tab, moving it after the other pinned tabs, or unpins it, moving it before the unpinned tabs. */\n pinTab(key: string, pinned: boolean): void;\n};\n\n/** Events the tab view navigator emits on top of React Navigation's core events. */\ntype TabViewNavigationEventMap = {\n /** The user selected a tab natively. */\n tabPress: {\n /** No payload. */\n data: undefined;\n /** Calling `preventDefault` keeps the current tab. */\n canPreventDefault: true;\n };\n /** The user activated the tab's indicator icon. */\n indicatorActivated: {\n /** No payload. */\n data: undefined;\n };\n};\n\n/** An icon given by theme name or as a `Gio.Icon`. */\ntype TabViewIcon = string | Gio.Icon;\n\n/** Per-screen options of the tab view navigator. */\ntype TabViewNavigationOptions = HeaderOptions & {\n /** Renders a custom top bar instead of the default `AdwHeaderBar`. */\n header?: (props: TabViewHeaderProps) => ReactNode;\n /** Icon shown in the tab; `null` shows the view's default icon. */\n icon?: TabViewIcon | null;\n /** Tooltip of the tab; supports Pango markup. */\n tooltip?: string;\n /** Search keyword for the tab overview. */\n keyword?: string;\n /** Whether the tab shows a loading spinner instead of its icon. */\n loading?: boolean;\n /** Whether the tab is highlighted as needing attention. */\n needsAttention?: boolean;\n /** Indicator icon shown at the end of the tab. */\n indicatorIcon?: TabViewIcon | null;\n /** Whether clicking the indicator emits `indicatorActivated`. */\n indicatorActivatable?: boolean;\n /** Tooltip of the indicator icon; supports Pango markup. */\n indicatorTooltip?: string;\n /** Whether the overview thumbnail stays live while the tab is not selected. */\n liveThumbnail?: boolean;\n /** Horizontal alignment of the overview thumbnail, from 0 to 1. */\n thumbnailXalign?: number;\n /** Vertical alignment of the overview thumbnail, from 0 to 1. */\n thumbnailYalign?: number;\n /** Whether the screen mounts on first selection instead of as soon as the tab opens; defaults to `true`. */\n lazy?: boolean;\n};\n\n/** The screen a new tab opens, as returned by the overview's `onCreateTab`. */\ntype TabViewTarget = {\n /** Name of the screen to open. */\n name: string;\n /** Params of the new tab. */\n params?: object;\n};\n\n/** Settings of the `AdwTabOverview` rendered around the view. */\ntype TabViewOverviewConfig = {\n /**\n * Whether the overview is open. When given, the overview follows it: the user opening or closing the overview\n * calls `onOpenChange`, and a value the app does not update is restored. Leave it out to let the overview open\n * and close on its own.\n */\n open?: boolean;\n /** Called when the overview opens or closes natively. */\n onOpenChange?: (open: boolean) => void;\n /** Whether the overview shows a new tab button; defaults to `false`. */\n enableNewTab?: boolean;\n /** Whether the overview offers search; defaults to `true`. */\n enableSearch?: boolean;\n /** Returns the screen the new tab button opens. */\n onCreateTab?: () => TabViewTarget;\n};\n\n/** Additional drop target of the tab bar and overview. */\ntype TabViewExtraDropTarget = NonNullable<AdwTabDropProps[\"extraDropTarget\"]>;\n\n/** Props of the tab view navigator beyond the options every navigator shares. */\ntype TabViewNavigationConfig = {\n /** A view created before the navigator renders, such as one returned from a `create-window` handler. */\n view?: Adw.TabView;\n /** Whether the tab bar renders; defaults to `true`. */\n tabBarVisible?: boolean;\n /** Whether the tab bar hides with a single tab; defaults to `true`. */\n tabBarAutohide?: boolean;\n /** Whether tabs expand to fill the bar; defaults to `true`. */\n tabBarExpand?: boolean;\n /** Whether close buttons sit at the start of tabs; defaults to `false`. */\n tabBarInverted?: boolean;\n /** Renders an `AdwTabOverview` around the view. */\n overview?: TabViewOverviewConfig;\n /** An existing menu model to use as the tabs' context menu. Use `renderMenu` to declare the menu in JSX instead. */\n menuModel?: Gio.MenuModel | null;\n /**\n * Renders the tabs' context menu. Attach `ref` to a `GMenu`, or to any menu model element, anywhere in the\n * returned tree; the navigator renders the tree outside the widget hierarchy and uses that model. A navigator\n * given both `renderMenu` and a `menuModel` throws.\n */\n renderMenu?: (ref: (menu: Gio.MenuModel | null) => void) => ReactNode;\n /** Additional content accepted by drops on tabs. */\n extraDropTarget?: TabViewExtraDropTarget | null;\n /** Handles content dropped on a tab; returns whether the drop was accepted. */\n onExtraDragDrop?: (route: RouteProp<ParamListBase>, value: GObject.Value) => boolean;\n /** Returns the view of a new window when a tab is dragged out of this one. */\n onCreateWindow?: () => Adw.TabView | null;\n /** Called with the tab whose context menu opens, or `null` when it closes, after the chosen menu action has run. */\n onSetupMenu?: (route: RouteProp<ParamListBase> | null) => void;\n /** Keyboard shortcuts the view handles. */\n shortcuts?: Adw.TabViewShortcuts;\n /** Icon of tabs without an `icon` option. */\n defaultIcon?: TabViewIcon | null;\n};\n\n/** Options of the tab view router. */\ntype TabViewRouterOptions = {\n /** Screen of the tab opened when the view starts empty; defaults to the first screen. */\n initialRouteName?: string;\n /**\n * Whether closing the last tab replaces it with a new tab of the initial route, instead of leaving that close\n * unhandled for a parent navigator or the container's `onUnhandledAction`. Use it for a tab view inside a section\n * of the app rather than a window of its own; defaults to `false`.\n */\n replaceLastTab?: boolean;\n};\n\n/** Navigation object of a tab view screen. */\ntype TabViewNavigationProp<\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 TabViewNavigationState<ParamList>,\n TabViewNavigationOptions,\n TabViewNavigationEventMap\n> &\n TabViewActionHelpers<ParamList>;\n\n/** Props a tab view screen component receives. */\ntype TabViewScreenProps<\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: TabViewNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Arguments of a custom tab view `header` renderer. */\ntype TabViewHeaderProps = {\n /** The selected route. */\n route: RouteProp<ParamListBase>;\n /** Navigation object of the selected route. */\n navigation: TabViewNavigationProp<ParamListBase>;\n /** Resolved options of the selected route. */\n options: TabViewNavigationOptions;\n};\n\n/** Navigation helpers of the tab view navigator itself. */\ntype TabViewNavigationHelpers = NavigationHelpers<ParamListBase, TabViewNavigationEventMap> &\n TabViewActionHelpers<ParamListBase>;\n\n/** Descriptor of one tab view route. */\ntype TabViewDescriptor = Descriptor<\n TabViewNavigationOptions,\n TabViewNavigationProp<ParamListBase>,\n RouteProp<ParamListBase>\n>;\n/** Descriptors of the tab view routes, keyed by route key. */\ntype TabViewDescriptorMap = Record<string, TabViewDescriptor>;\n\n/** Props of the tab view `Navigator` component. */\ntype TabViewNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n TabViewNavigationState<ParamListBase>,\n TabViewNavigationOptions,\n TabViewNavigationEventMap,\n TabViewNavigationProp<ParamListBase>\n> &\n TabViewRouterOptions &\n TabViewNavigationConfig;\n\nexport type {\n TabViewActionHelpers,\n TabViewActionType,\n TabViewDescriptor,\n TabViewDescriptorMap,\n TabViewExtraDropTarget,\n TabViewHeaderProps,\n TabViewIcon,\n TabViewNavigationConfig,\n TabViewNavigationEventMap,\n TabViewNavigationHelpers,\n TabViewNavigationOptions,\n TabViewNavigationProp,\n TabViewNavigationState,\n TabViewNavigatorProps,\n TabViewOpenOptions,\n TabViewOverviewConfig,\n TabViewRouterOptions,\n TabViewScreenProps,\n TabViewTarget,\n};\n"]}
|
|
@@ -25,6 +25,8 @@ declare const createTabScreen: StaticScreenFactory<TabTypeBag>;
|
|
|
25
25
|
/** Renders the screens of a {@link createTabNavigator} as pages of an `AdwViewStack` with a view switcher. */
|
|
26
26
|
declare function TabNavigator({ tabBarPosition, ...options }: TabNavigatorProps): ReactNode;
|
|
27
27
|
/** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */
|
|
28
|
-
declare function createTabNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = TabTypeBag<ParamList, NavigatorID
|
|
28
|
+
declare function createTabNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = TabTypeBag<ParamList, NavigatorID>>(): TypedNavigator<TypeBag, undefined>;
|
|
29
|
+
/** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */
|
|
30
|
+
declare function createTabNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = TabTypeBag<ParamList, NavigatorID>, const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>>(config: Config): TypedNavigator<TypeBag, Config>;
|
|
29
31
|
export { createTabNavigator, createTabScreen, TabNavigator, type TabTypeBag };
|
|
30
32
|
//# sourceMappingURL=create-tab-navigator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tab-navigator.d.ts","sourceRoot":"","sources":["../../src/tabs/create-tab-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,mBAAm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AC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,KAC9E,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACxC,qFAAqF;AACrF,iBAAS,kBAAkB,CACvB,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,EAC/E,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EACpE,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAQnD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,CAAC"}
|
|
@@ -8,7 +8,6 @@ function TabNavigator({ tabBarPosition, ...options }) {
|
|
|
8
8
|
const { state, descriptors, navigation, render } = useNavigationBuilder(TabRouter, options);
|
|
9
9
|
return render(_jsx(TabView, { tabBarPosition: tabBarPosition, state: state, navigation: navigation, descriptors: descriptors }));
|
|
10
10
|
}
|
|
11
|
-
/** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */
|
|
12
11
|
function createTabNavigator(config) {
|
|
13
12
|
return createNavigatorFactory(TabNavigator)(config);
|
|
14
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tab-navigator.js","sourceRoot":"","sources":["../../src/tabs/create-tab-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAw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;AAC3F,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAmB,CAAC","sourcesContent":["import type {\n NavigatorTypeBagBase,\n ParamListBase,\n StaticConfig,\n StaticScreenFactory,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n TypedNavigator,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport { createNavigatorFactory, createScreenFactory, TabRouter, useNavigationBuilder } from \"@react-navigation/core\";\nimport type { TabNavigationEventMap, TabNavigationOptions, TabNavigationProp, TabNavigatorProps } from \"./types.js\";\nimport { TabView } from \"./tab-view.js\";\n\n/** Type bag describing the tab navigator to React Navigation's typed APIs. */\ntype TabTypeBag<\n ParamList extends ParamListBase = ParamListBase,\n NavigatorID extends string | undefined = string | undefined,\n> = {\n /** Route names and their params. */\n ParamList: ParamList;\n /** Optional navigator id. */\n NavigatorID: NavigatorID;\n /** Shape of the navigator state. */\n State: TabNavigationState<ParamList>;\n /** Per-screen options. */\n ScreenOptions: TabNavigationOptions;\n /** Events the navigator emits. */\n EventMap: TabNavigationEventMap;\n /** Navigation object per route. */\n NavigationList: {\n [RouteName in keyof ParamList]: TabNavigationProp<ParamList, RouteName, NavigatorID>;\n };\n /** The navigator component. */\n Navigator: typeof TabNavigator;\n};\n\n/** Declares a typed screen of a tab navigator for the static configuration API. */\nconst createTabScreen: StaticScreenFactory<TabTypeBag> = createScreenFactory<TabTypeBag>();\n\n/** Renders the screens of a {@link createTabNavigator} as pages of an `AdwViewStack` with a view switcher. */\nfunction TabNavigator({ tabBarPosition, ...options }: TabNavigatorProps): ReactNode {\n const { state, descriptors, navigation, render } = useNavigationBuilder<\n TabNavigationState<ParamListBase>,\n TabRouterOptions,\n TabActionHelpers<ParamListBase>,\n TabNavigationOptions,\n TabNavigationEventMap\n >(TabRouter, options);\n\n return render(\n <TabView tabBarPosition={tabBarPosition} state={state} navigation={navigation} descriptors={descriptors} />,\n );\n}\n\n/** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */\nfunction createTabNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = TabTypeBag<ParamList, NavigatorID>,\n>(): TypedNavigator<TypeBag, undefined>;\n/** Creates a tab navigator rendered with `AdwViewStack` and an `AdwViewSwitcher`. */\nfunction createTabNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = TabTypeBag<ParamList, NavigatorID>,\n const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,\n>(config: Config): TypedNavigator<TypeBag, Config>;\nfunction createTabNavigator<\n const TypeBag extends NavigatorTypeBagBase,\n const Config extends StaticConfig<TypeBag> | undefined,\n>(config?: Config): TypedNavigator<TypeBag, Config> {\n return createNavigatorFactory(TabNavigator)(config) as TypedNavigator<TypeBag, Config>;\n}\n\nexport { createTabNavigator, createTabScreen, TabNavigator, type TabTypeBag };\n"]}
|
package/dist/tabs/tab-view.js
CHANGED
|
@@ -42,7 +42,7 @@ const TabView = ({ state, navigation, descriptors, tabBarPosition = "top" }) =>
|
|
|
42
42
|
const viewSwitcher = stack === null ? undefined : _jsx(AdwViewSwitcher, { stack: stack, policy: Adw.ViewSwitcherPolicy.WIDE });
|
|
43
43
|
const hasSwitcherBar = tabBarPosition === "bottom" && stack !== null;
|
|
44
44
|
usePopToTopOnBlur(state, descriptors, navigation);
|
|
45
|
-
return (_jsx(AdwToolbarView, {
|
|
45
|
+
return (_jsx(AdwToolbarView, { top: _jsx(TabHeader, { descriptor: descriptor, viewSwitcher: tabBarPosition === "top" ? viewSwitcher : undefined }), bottom: 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))) }) }));
|
|
46
46
|
};
|
|
47
47
|
export { TabView };
|
|
48
48
|
//# sourceMappingURL=tab-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-view.js","sourceRoot":"","sources":["../../src/tabs/tab-view.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,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,CA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ACH,KAAC,cAAc,IACX,GAAG,EACC,KAAC,SAAS,IAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,GAAI,EAE5G,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,KAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,SAAG,CAAC,CAAC,CAAC,SAAS,YAEhF,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 top={\n <TabHeader descriptor={descriptor} viewSwitcher={tabBarPosition === \"top\" ? viewSwitcher : undefined} />\n }\n bottom={hasSwitcherBar ? <AdwViewSwitcherBar stack={stack} reveal /> : undefined}\n >\n <AdwViewStack\n ref={setStack}\n visibleChildName={focused.key}\n enableTransitions={descriptor.options.animation === \"fade\"}\n onNotifyVisibleChildName={onVisibleChildChanged}\n >\n {state.routes.map((route) => (\n <TabPage\n key={route.key}\n descriptor={requireDescriptor(descriptors, route.key)}\n isFocused={route.key === focused.key}\n isLoaded={route.key === focused.key || state.preloadedRouteKeys.includes(route.key)}\n />\n ))}\n </AdwViewStack>\n </AdwToolbarView>\n );\n};\n\nexport { TabView };\n"]}
|
package/dist/theme.js
CHANGED
|
@@ -7,8 +7,8 @@ const DefaultTheme = { dark: false, highContrast: false };
|
|
|
7
7
|
const DarkTheme = { dark: true, highContrast: false };
|
|
8
8
|
const useAdwaitaTheme = () => {
|
|
9
9
|
const manager = Adw.StyleManager.getDefault();
|
|
10
|
-
const isDark = useProperty(manager, "dark")
|
|
11
|
-
const isHighContrast = useProperty(manager, "highContrast")
|
|
10
|
+
const isDark = useProperty(manager, "dark");
|
|
11
|
+
const isHighContrast = useProperty(manager, "highContrast");
|
|
12
12
|
return useMemo(() => ({ dark: isDark, highContrast: isHighContrast }), [isDark, isHighContrast]);
|
|
13
13
|
};
|
|
14
14
|
export { DarkTheme, DefaultTheme, useAdwaitaTheme };
|
package/dist/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;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,
|
|
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,CAAC;IAC5C,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE5D,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\");\n const isHighContrast = useProperty(manager, \"highContrast\");\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.
|
|
3
|
+
"version": "2.0.0-beta.13",
|
|
4
4
|
"description": "React Navigation navigators for GTKX.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"node": ">=26.7.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@gtkx/react": "2.0.0-beta.
|
|
47
|
+
"@gtkx/react": "^2.0.0-beta.13",
|
|
48
48
|
"@react-navigation/core": "^7.24.0",
|
|
49
49
|
"@react-navigation/routers": "^7.6.5"
|
|
50
50
|
},
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"react": "^19.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@gtkx/config": "2.0.0-beta.
|
|
57
|
-
"@gtkx/testing": "2.0.0-beta.
|
|
58
|
-
"@gtkx/vitest": "2.0.0-beta.
|
|
56
|
+
"@gtkx/config": "2.0.0-beta.13",
|
|
57
|
+
"@gtkx/testing": "2.0.0-beta.13",
|
|
58
|
+
"@gtkx/vitest": "2.0.0-beta.13",
|
|
59
59
|
"@types/react": "^19.3.0",
|
|
60
|
-
"vitest": "5.0
|
|
60
|
+
"vitest": "5.1.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"release": "node ../../scripts/release/publish-package.ts"
|
|
@@ -47,17 +47,19 @@ type DrawerTypeBag<
|
|
|
47
47
|
/** Declares a typed screen of a drawer navigator for the static configuration API. */
|
|
48
48
|
const createDrawerScreen: StaticScreenFactory<DrawerTypeBag> = createScreenFactory<DrawerTypeBag>();
|
|
49
49
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const createFlag = (isInitial: boolean) => {
|
|
51
|
+
let isCurrent = isInitial;
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
read: () => isCurrent,
|
|
55
|
+
update: (isNext: boolean) => {
|
|
56
|
+
isCurrent = isNext;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
};
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
update: (isNext: boolean) => {
|
|
57
|
-
isCurrent = isNext;
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
+
const useDrawerRouter = (isCollapsed: boolean): DrawerRouterFactory => {
|
|
62
|
+
const [flag] = useState(() => createFlag(isCollapsed));
|
|
61
63
|
|
|
62
64
|
const [createRouter] = useState(() => createDrawerRouter(flag.read));
|
|
63
65
|
|
|
@@ -111,7 +113,17 @@ function createDrawerNavigator<
|
|
|
111
113
|
const ParamList extends ParamListBase,
|
|
112
114
|
const NavigatorID extends string | undefined = string | undefined,
|
|
113
115
|
const TypeBag extends NavigatorTypeBagBase = DrawerTypeBag<ParamList, NavigatorID>,
|
|
114
|
-
|
|
116
|
+
>(): TypedNavigator<TypeBag, undefined>;
|
|
117
|
+
/** Creates a drawer navigator rendered with `AdwOverlaySplitView`: a sidebar listing the screens beside the content. */
|
|
118
|
+
function createDrawerNavigator<
|
|
119
|
+
const ParamList extends ParamListBase,
|
|
120
|
+
const NavigatorID extends string | undefined = string | undefined,
|
|
121
|
+
const TypeBag extends NavigatorTypeBagBase = DrawerTypeBag<ParamList, NavigatorID>,
|
|
122
|
+
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
|
123
|
+
>(config: Config): TypedNavigator<TypeBag, Config>;
|
|
124
|
+
function createDrawerNavigator<
|
|
125
|
+
const TypeBag extends NavigatorTypeBagBase,
|
|
126
|
+
const Config extends StaticConfig<TypeBag> | undefined,
|
|
115
127
|
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
|
116
128
|
return createNavigatorFactory(DrawerNavigator)(config) as TypedNavigator<TypeBag, Config>;
|
|
117
129
|
}
|
|
@@ -71,7 +71,7 @@ const useCloseOnNavigate = (
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
const DrawerContent = (props: DrawerContentProps): ReactNode => (
|
|
74
|
-
<AdwToolbarView
|
|
74
|
+
<AdwToolbarView top={<AdwHeaderBar />}>
|
|
75
75
|
<GtkScrolledWindow hscrollbarPolicy={Gtk.PolicyType.NEVER}>
|
|
76
76
|
<DrawerItemList {...props} />
|
|
77
77
|
</GtkScrolledWindow>
|
|
@@ -146,7 +146,7 @@ const DrawerView = ({ state, navigation, descriptors, drawerContent, ...config }
|
|
|
146
146
|
onNotifyShowSidebar={onShowSidebarChanged}
|
|
147
147
|
sidebar={<>{sidebar}</>}
|
|
148
148
|
>
|
|
149
|
-
<AdwToolbarView
|
|
149
|
+
<AdwToolbarView top={<DrawerHeader descriptor={descriptor} navigation={navigation} />}>
|
|
150
150
|
<AdwViewStack visibleChildName={focused.key}>
|
|
151
151
|
{state.routes.map((route) => (
|
|
152
152
|
<DrawerPage
|
package/src/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ export {
|
|
|
30
30
|
SplitViewNavigator,
|
|
31
31
|
type SplitViewTypeBag,
|
|
32
32
|
} from "./split-view/create-split-view-navigator.js";
|
|
33
|
+
export { useSplitViewCollapsed } from "./split-view/split-view-collapsed.js";
|
|
33
34
|
export type {
|
|
34
35
|
SplitViewDescriptor,
|
|
35
36
|
SplitViewDescriptorMap,
|
|
@@ -75,5 +76,34 @@ export type {
|
|
|
75
76
|
TabNavigatorProps,
|
|
76
77
|
TabScreenProps,
|
|
77
78
|
} from "./tabs/types.js";
|
|
79
|
+
export {
|
|
80
|
+
createTabViewNavigator,
|
|
81
|
+
createTabViewScreen,
|
|
82
|
+
TabViewNavigator,
|
|
83
|
+
type TabViewTypeBag,
|
|
84
|
+
} from "./tab-view/create-tab-view-navigator.js";
|
|
85
|
+
export { type TabViewHandle, useTabView } from "./tab-view/tab-view-host.js";
|
|
86
|
+
export { TabViewActions } from "./tab-view/tab-view-router.js";
|
|
87
|
+
export type {
|
|
88
|
+
TabViewActionHelpers,
|
|
89
|
+
TabViewActionType,
|
|
90
|
+
TabViewDescriptor,
|
|
91
|
+
TabViewDescriptorMap,
|
|
92
|
+
TabViewExtraDropTarget,
|
|
93
|
+
TabViewHeaderProps,
|
|
94
|
+
TabViewIcon,
|
|
95
|
+
TabViewNavigationConfig,
|
|
96
|
+
TabViewNavigationEventMap,
|
|
97
|
+
TabViewNavigationHelpers,
|
|
98
|
+
TabViewNavigationOptions,
|
|
99
|
+
TabViewNavigationProp,
|
|
100
|
+
TabViewNavigationState,
|
|
101
|
+
TabViewNavigatorProps,
|
|
102
|
+
TabViewOpenOptions,
|
|
103
|
+
TabViewOverviewConfig,
|
|
104
|
+
TabViewRouterOptions,
|
|
105
|
+
TabViewScreenProps,
|
|
106
|
+
TabViewTarget,
|
|
107
|
+
} from "./tab-view/types.js";
|
|
78
108
|
export { DarkTheme, DefaultTheme, type Theme } from "./theme.js";
|
|
79
109
|
export * from "@react-navigation/core";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { AdwBin, AdwViewStackPage } from "@gtkx/jsx/adw";
|
|
3
|
-
import {
|
|
3
|
+
import { useHasLoaded } from "./use-has-loaded.js";
|
|
4
4
|
|
|
5
5
|
type ScenePageProps = {
|
|
6
6
|
name: string;
|
|
@@ -15,11 +15,7 @@ type ScenePageProps = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const ScenePage = ({ name, title, isFocused, isLoaded, render, ...page }: ScenePageProps): ReactNode => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
if (isLoaded && !hasLoaded) {
|
|
21
|
-
setHasLoaded(true);
|
|
22
|
-
}
|
|
18
|
+
const hasLoaded = useHasLoaded(isLoaded);
|
|
23
19
|
|
|
24
20
|
return (
|
|
25
21
|
<AdwViewStackPage
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useHasLoaded = (isLoaded: boolean): boolean => {
|
|
4
|
+
const [hasLoaded, setHasLoaded] = useState(isLoaded);
|
|
5
|
+
|
|
6
|
+
if (isLoaded && !hasLoaded) {
|
|
7
|
+
setHasLoaded(true);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return isLoaded || hasLoaded;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { useHasLoaded };
|