@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-view.js","sourceRoot":"","sources":["../../src/split-view/split-view.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAO5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAWnD,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAW,CAAC;AACjF,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,aAAa,GAAG,GAAG,CAAC,UAAU,CAAC;AAErC,MAAM,UAAU,GAAG,CAAC,KAAqC,EAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAE/F,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,WAAmC,EAAU,EAAE;IAC7G,MAAM,KAAK,GAAG,KAAK,CAA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C5B,GACe,GACC,CAC5B,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type { ParamListBase, RouteProp, StackNavigationState } from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { AdwNavigationPage, AdwNavigationSplitView, AdwToolbarView } from \"@gtkx/jsx/adw\";\nimport { GtkEventControllerKey } from \"@gtkx/jsx/gtk\";\nimport { StackActions } from \"@react-navigation/core\";\nimport { useCallback, useRef } from \"react\";\nimport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationHelpers,\n} from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { requireDescriptor } from \"../shared/routes.js\";\nimport { StackView } from \"../stack/stack-view.js\";\n\ntype ViewRef = { current: Adw.NavigationSplitView | null };\n\ntype SplitViewProps = SplitViewNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: SplitViewNavigationHelpers;\n descriptors: SplitViewDescriptorMap;\n describe: (route: RouteProp<ParamListBase>, isPlaceholder: boolean) => SplitViewDescriptor;\n};\n\nconst PACK_TYPES = { start: Gtk.PackType.START, end: Gtk.PackType.END } as const;\nconst CONTENT_TITLE = \"Content\";\nconst ESCAPE_KEYVAL = Gdk.KEY_Escape;\n\nconst hasContent = (state: { routes: readonly unknown[] }): boolean => state.routes.length > 1;\n\nconst contentTitle = (state: StackNavigationState<ParamListBase>, descriptors: SplitViewDescriptorMap): string => {\n const route = state.routes[state.index];\n\n if (route === undefined || state.index === 0) {\n return state.routeNames[1] ?? CONTENT_TITLE;\n }\n\n return descriptors[route.key]?.options.title ?? route.name;\n};\n\nconst popContent = (navigation: SplitViewNavigationHelpers): void => {\n const state = navigation.getState();\n navigation.dispatch({ ...StackActions.pop(state.routes.length - 1), target: state.key });\n};\n\nconst settleShowContent = (viewRef: ViewRef, isShown: boolean, isSettled: boolean): void => {\n if (isSettled !== isShown && viewRef.current !== null) {\n viewRef.current.setShowContent(isSettled);\n }\n};\n\nconst useContentSync = (\n viewRef: ViewRef,\n navigation: SplitViewNavigationHelpers,\n): ((isShown: boolean | null) => void) =>\n useCallback(\n (isShown: boolean | null) => {\n if (isShown === null || isShown === hasContent(navigation.getState())) {\n return;\n }\n\n if (!isShown) {\n popContent(navigation);\n }\n\n settleShowContent(viewRef, isShown, hasContent(navigation.getState()));\n },\n [viewRef, navigation],\n );\n\nconst EscapeGuard = (): ReactNode => (\n <GtkEventControllerKey\n propagationPhase={Gtk.PropagationPhase.BUBBLE}\n onKeyPressed={(keyval) => keyval === ESCAPE_KEYVAL}\n />\n);\n\nconst SidebarPage = ({ descriptor }: { descriptor: SplitViewDescriptor }): ReactNode => {\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return <AdwNavigationPage title={options.title ?? route.name}>{descriptor.render()}</AdwNavigationPage>;\n }\n\n const topBar =\n options.header === undefined ? (\n <HeaderBar options={options} showBackButton={false} />\n ) : (\n <>{options.header({ route, navigation, options, back: undefined })}</>\n );\n\n return (\n <AdwNavigationPage title={options.title ?? route.name}>\n <AdwToolbarView topBar={topBar}>{descriptor.render()}</AdwToolbarView>\n </AdwNavigationPage>\n );\n};\n\nconst SplitView = (props: SplitViewProps): ReactNode => {\n const { state, navigation, descriptors, describe, contentPlaceholder } = props;\n const { collapsed = false, sidebarPosition = \"start\", minSidebarWidth, maxSidebarWidth } = props;\n const viewRef = useRef<Adw.NavigationSplitView | null>(null);\n const onShowContentChanged = useContentSync(viewRef, navigation);\n const sidebar = requireDescriptor(descriptors, state.routes[0]?.key ?? \"\");\n\n return (\n <AdwNavigationSplitView\n ref={viewRef}\n collapsed={collapsed}\n showContent={hasContent(state)}\n sidebarPosition={PACK_TYPES[sidebarPosition]}\n minSidebarWidth={minSidebarWidth}\n maxSidebarWidth={maxSidebarWidth}\n sidebarWidthFraction={props.sidebarWidthFraction}\n onNotifyShowContent={onShowContentChanged}\n sidebar={<SidebarPage descriptor={sidebar} />}\n >\n <AdwNavigationPage\n title={contentTitle(state, descriptors)}\n controllers={collapsed && props.popOnEscape === false ? <EscapeGuard /> : null}\n >\n {hasContent(state) ? (\n <StackView\n offset={1}\n popOnEscape={props.popOnEscape}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n />\n ) : (\n <>{contentPlaceholder}</>\n )}\n </AdwNavigationPage>\n </AdwNavigationSplitView>\n );\n};\n\nexport { SplitView };\n"]}
|
|
1
|
+
{"version":3,"file":"split-view.js","sourceRoot":"","sources":["../../src/split-view/split-view.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAOxE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAStE,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,GAAG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ChC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAChD,mBAAmB,EAAE,oBAAoB,EACzC,OAAO,EAAE,KAAC,WAAW,IAAC,UAAU,EAAE,OAAO,GAAI,YAE7C,KAAC,iBAAiB,IACd,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,EACvC,WAAW,EAAE,WAAW,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,KAAC,WAAW,KAAG,CAAC,CAAC,CAAC,IAAI,YAE/E,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACjB,KAAC,SAAS,IACN,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,GACpB,CACL,CAAC,CAAC,CAAC,CACA,KAAC,cAAc,IAAC,GAAG,EAAE,KAAC,YAAY,IAAC,SAAS,EAAE,KAAK,GAAI,YAClD,kBAAkB,GACN,CACpB,GACe,GACC,GACV,GACK,CAC/B,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { ParamListBase, RouteProp, StackNavigationState } from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport {\n AdwBreakpoint,\n AdwBreakpointBin,\n AdwHeaderBar,\n AdwNavigationPage,\n AdwNavigationSplitView,\n AdwToolbarView,\n} from \"@gtkx/jsx/adw\";\nimport { GtkEventControllerKey } from \"@gtkx/jsx/gtk\";\nimport { useProperty } from \"@gtkx/react\";\nimport { StackActions } from \"@react-navigation/core\";\nimport { useCallback, useLayoutEffect, useMemo, useState } from \"react\";\nimport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationHelpers,\n} from \"./types.js\";\nimport { HeaderBar } from \"../shared/header-bar.js\";\nimport { requireDescriptor } from \"../shared/routes.js\";\nimport { StackView } from \"../stack/stack-view.js\";\nimport { SplitViewCollapsedContext } from \"./split-view-collapsed.js\";\n\ntype SplitViewProps = SplitViewNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: SplitViewNavigationHelpers;\n descriptors: SplitViewDescriptorMap;\n describe: (route: RouteProp<ParamListBase>, isPlaceholder: boolean) => SplitViewDescriptor;\n};\n\nconst PACK_TYPES = { start: Gtk.PackType.START, end: Gtk.PackType.END } as const;\nconst CONTENT_TITLE = \"Content\";\nconst ESCAPE_KEYVAL = Gdk.KEY_Escape;\n\nconst hasContent = (state: { routes: readonly unknown[] }): boolean => state.routes.length > 1;\n\nconst contentTitle = (state: StackNavigationState<ParamListBase>, descriptors: SplitViewDescriptorMap): string => {\n const route = state.routes[state.index];\n\n if (route === undefined || state.index === 0) {\n return state.routeNames[1] ?? CONTENT_TITLE;\n }\n\n return descriptors[route.key]?.options.title ?? route.name;\n};\n\nconst popContent = (navigation: SplitViewNavigationHelpers): void => {\n const state = navigation.getState();\n navigation.dispatch({ ...StackActions.pop(state.routes.length - 1), target: state.key });\n};\n\nconst collapsedValue = (): GObject.Value => {\n const value = new GObject.Value();\n value.init(GObject.TYPE_BOOLEAN);\n value.setBoolean(true);\n\n return value;\n};\n\nconst useCollapseBreakpoint = (\n view: Adw.NavigationSplitView | null,\n collapseCondition: string | undefined,\n): ReactNode => {\n const [breakpoint, setBreakpoint] = useState<Adw.Breakpoint | null>(null);\n const condition = useMemo(\n () => (collapseCondition === undefined ? null : Adw.BreakpointCondition.parse(collapseCondition)),\n [collapseCondition],\n );\n\n useLayoutEffect(() => {\n if (breakpoint === null || view === null) {\n return;\n }\n\n breakpoint.addSetter(view, \"collapsed\", collapsedValue());\n }, [view, breakpoint]);\n\n return condition === null ? null : <AdwBreakpoint ref={setBreakpoint} condition={condition} />;\n};\n\nconst settleShowContent = (view: Adw.NavigationSplitView | null, isShown: boolean, isSettled: boolean): void => {\n if (isSettled !== isShown && view !== null) {\n view.setShowContent(isSettled);\n }\n};\n\nconst useContentSync = (\n view: Adw.NavigationSplitView | null,\n navigation: SplitViewNavigationHelpers,\n): ((isShown: boolean | null) => void) =>\n useCallback(\n (isShown: boolean | null) => {\n if (isShown === null || isShown === hasContent(navigation.getState())) {\n return;\n }\n\n if (!isShown) {\n popContent(navigation);\n }\n\n settleShowContent(view, isShown, hasContent(navigation.getState()));\n },\n [view, navigation],\n );\n\nconst EscapeGuard = (): ReactNode => (\n <GtkEventControllerKey\n propagationPhase={Gtk.PropagationPhase.BUBBLE}\n onKeyPressed={(keyval) => keyval === ESCAPE_KEYVAL}\n />\n);\n\nconst SidebarPage = ({ descriptor }: { descriptor: SplitViewDescriptor }): ReactNode => {\n const { route, options, navigation } = descriptor;\n\n if (options.headerShown === false) {\n return <AdwNavigationPage title={options.title ?? route.name}>{descriptor.render()}</AdwNavigationPage>;\n }\n\n const topBar =\n options.header === undefined ? (\n <HeaderBar options={options} showBackButton={false} />\n ) : (\n <>{options.header({ route, navigation, options, back: undefined })}</>\n );\n\n return (\n <AdwNavigationPage title={options.title ?? route.name}>\n <AdwToolbarView top={topBar}>{descriptor.render()}</AdwToolbarView>\n </AdwNavigationPage>\n );\n};\n\nconst SplitView = (props: SplitViewProps): ReactNode => {\n const { state, navigation, descriptors, describe, contentPlaceholder, collapseCondition } = props;\n const { sidebarPosition = \"start\", minSidebarWidth, maxSidebarWidth } = props;\n const [view, setView] = useState<Adw.NavigationSplitView | null>(null);\n const onShowContentChanged = useContentSync(view, navigation);\n const collapseBreakpoint = useCollapseBreakpoint(view, collapseCondition);\n const sidebar = requireDescriptor(descriptors, state.routes[0]?.key ?? \"\");\n const collapsed = collapseCondition === undefined ? (props.collapsed ?? false) : undefined;\n const isCollapsed = useProperty(view, \"collapsed\") ?? collapsed ?? false;\n\n // AdwBreakpointBin warns without a size request; the window's size request sets the smallest supported size.\n return (\n <SplitViewCollapsedContext value={isCollapsed}>\n <AdwBreakpointBin widthRequest={1} heightRequest={1} breakpoints={collapseBreakpoint}>\n <AdwNavigationSplitView\n ref={setView}\n collapsed={collapsed}\n showContent={hasContent(state)}\n sidebarPosition={PACK_TYPES[sidebarPosition]}\n minSidebarWidth={minSidebarWidth}\n maxSidebarWidth={maxSidebarWidth}\n sidebarWidthFraction={props.sidebarWidthFraction}\n onNotifyShowContent={onShowContentChanged}\n sidebar={<SidebarPage descriptor={sidebar} />}\n >\n <AdwNavigationPage\n title={contentTitle(state, descriptors)}\n controllers={isCollapsed && props.popOnEscape === false ? <EscapeGuard /> : null}\n >\n {hasContent(state) ? (\n <StackView\n offset={1}\n popOnEscape={props.popOnEscape}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n />\n ) : (\n <AdwToolbarView top={<AdwHeaderBar showTitle={false} />}>\n {contentPlaceholder}\n </AdwToolbarView>\n )}\n </AdwNavigationPage>\n </AdwNavigationSplitView>\n </AdwBreakpointBin>\n </SplitViewCollapsedContext>\n );\n};\n\nexport { SplitView };\n"]}
|
|
@@ -22,9 +22,16 @@ type SplitViewDescriptor = Descriptor<SplitViewNavigationOptions, SplitViewNavig
|
|
|
22
22
|
type SplitViewDescriptorMap = Record<string, SplitViewDescriptor>;
|
|
23
23
|
/** Props of the split view navigator beyond the options every navigator shares. */
|
|
24
24
|
type SplitViewNavigationConfig = {
|
|
25
|
-
/** Whether the panes stack into one instead of sitting side by side; defaults to `false`. */
|
|
25
|
+
/** Whether the panes stack into one instead of sitting side by side; defaults to `false`. Ignored while `collapseCondition` is set. */
|
|
26
26
|
collapsed?: boolean;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* An `Adw.BreakpointCondition` string, such as `"max-width: 500sp"`, measured against the navigator's size.
|
|
29
|
+
* The panes collapse while it holds. libadwaita applies it during layout, before GTK moves focus, so
|
|
30
|
+
* widening the window does not reselect the focused sidebar row the way a `collapsed` prop set from a
|
|
31
|
+
* breakpoint handler can. Give the window a `widthRequest` and `heightRequest`, as for window breakpoints.
|
|
32
|
+
*/
|
|
33
|
+
collapseCondition?: string;
|
|
34
|
+
/** Fills the content pane, below an untitled header bar, while no content route is open; defaults to nothing. */
|
|
28
35
|
contentPlaceholder?: ReactNode;
|
|
29
36
|
/** Which side the sidebar sits on; defaults to `"start"`. */
|
|
30
37
|
sidebarPosition?: "start" | "end";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/split-view/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEzF,mGAAmG;AACnG,KAAK,2BAA2B,GAAG,uBAAuB,CAAC;AAC3D,0FAA0F;AAC1F,KAAK,0BAA0B,GAAG,sBAAsB,CAAC;AAEzD,gDAAgD;AAChD,KAAK,uBAAuB,CACxB,SAAS,SAAS,aAAa,EAC/B,SAAS,SAAS,MAAM,SAAS,GAAG,MAAM,SAAS,EACnD,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,IAClD,cAAc,CACd,SAAS,EACT,SAAS,EACT,WAAW,EACX,oBAAoB,CAAC,SAAS,CAAC,EAC/B,0BAA0B,EAC1B,2BAA2B,CAC9B,GACG,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAElC,oDAAoD;AACpD,KAAK,oBAAoB,CACrB,SAAS,SAAS,aAAa,EAC/B,SA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B,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iFAAiF;IACjF,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,qDAAqD;AACrD,KAAK,uBAAuB,GAAG,uBAAuB,CAClD,aAAa,EACb,MAAM,GAAG,SAAS,EAClB,oBAAoB,CAAC,aAAa,CAAC,EACnC,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,CAAC,aAAa,CAAC,CACzC,GACG,kBAAkB,GAClB,yBAAyB,CAAC;AAE9B,YAAY,EACR,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,GACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/split-view/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DefaultNavigatorOptions,\n Descriptor,\n NavigationHelpers,\n NavigationProp,\n ParamListBase,\n RouteProp,\n StackActionHelpers,\n StackNavigationState,\n StackRouterOptions,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport type { StackNavigationEventMap, StackNavigationOptions } from \"../stack/types.js\";\n\n/** Events the split view navigator emits: the stack's transition events, from the content pane. */\ntype SplitViewNavigationEventMap = StackNavigationEventMap;\n/** Per-screen options of the split view navigator, the same ones a stack screen takes. */\ntype SplitViewNavigationOptions = StackNavigationOptions;\n\n/** Navigation object of a split view screen. */\ntype SplitViewNavigationProp<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = NavigationProp<\n ParamList,\n RouteName,\n NavigatorID,\n StackNavigationState<ParamList>,\n SplitViewNavigationOptions,\n SplitViewNavigationEventMap\n> &\n StackActionHelpers<ParamList>;\n\n/** Props a split view screen component receives. */\ntype SplitViewScreenProps<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = {\n /** Navigation object of the screen. */\n navigation: SplitViewNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Navigation helpers of the split view navigator itself. */\ntype SplitViewNavigationHelpers = NavigationHelpers<ParamListBase, SplitViewNavigationEventMap> &\n StackActionHelpers<ParamListBase>;\n\n/** Descriptor of one split view route. */\ntype SplitViewDescriptor = Descriptor<\n SplitViewNavigationOptions,\n SplitViewNavigationProp<ParamListBase>,\n RouteProp<ParamListBase>\n>;\n\n/** Descriptors of the split view routes, keyed by route key. */\ntype SplitViewDescriptorMap = Record<string, SplitViewDescriptor>;\n\n/** Props of the split view navigator beyond the options every navigator shares. */\ntype SplitViewNavigationConfig = {\n /** Whether the panes stack into one instead of sitting side by side; defaults to `false`. */\n collapsed?: boolean;\n /** Fills the content pane while no content route is open; defaults to nothing. */\n contentPlaceholder?: ReactNode;\n /** Which side the sidebar sits on; defaults to `\"start\"`. */\n sidebarPosition?: \"start\" | \"end\";\n /** Minimum sidebar width, in the unit libadwaita uses for the split view. */\n minSidebarWidth?: number;\n /** Maximum sidebar width, in the unit libadwaita uses for the split view. */\n maxSidebarWidth?: number;\n /** Preferred sidebar width as a fraction of the total width. */\n sidebarWidthFraction?: number;\n /** Whether pressing Escape pops the visible content page; defaults to `true`. */\n popOnEscape?: boolean;\n};\n\n/** Props of the split view `Navigator` component. */\ntype SplitViewNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n StackNavigationState<ParamListBase>,\n SplitViewNavigationOptions,\n SplitViewNavigationEventMap,\n SplitViewNavigationProp<ParamListBase>\n> &\n StackRouterOptions &\n SplitViewNavigationConfig;\n\nexport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationEventMap,\n SplitViewNavigationHelpers,\n SplitViewNavigationOptions,\n SplitViewNavigationProp,\n SplitViewNavigatorProps,\n SplitViewScreenProps,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/split-view/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n DefaultNavigatorOptions,\n Descriptor,\n NavigationHelpers,\n NavigationProp,\n ParamListBase,\n RouteProp,\n StackActionHelpers,\n StackNavigationState,\n StackRouterOptions,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport type { StackNavigationEventMap, StackNavigationOptions } from \"../stack/types.js\";\n\n/** Events the split view navigator emits: the stack's transition events, from the content pane. */\ntype SplitViewNavigationEventMap = StackNavigationEventMap;\n/** Per-screen options of the split view navigator, the same ones a stack screen takes. */\ntype SplitViewNavigationOptions = StackNavigationOptions;\n\n/** Navigation object of a split view screen. */\ntype SplitViewNavigationProp<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = NavigationProp<\n ParamList,\n RouteName,\n NavigatorID,\n StackNavigationState<ParamList>,\n SplitViewNavigationOptions,\n SplitViewNavigationEventMap\n> &\n StackActionHelpers<ParamList>;\n\n/** Props a split view screen component receives. */\ntype SplitViewScreenProps<\n ParamList extends ParamListBase,\n RouteName extends keyof ParamList = keyof ParamList,\n NavigatorID extends string | undefined = undefined,\n> = {\n /** Navigation object of the screen. */\n navigation: SplitViewNavigationProp<ParamList, RouteName, NavigatorID>;\n /** The route the screen renders. */\n route: RouteProp<ParamList, RouteName>;\n};\n\n/** Navigation helpers of the split view navigator itself. */\ntype SplitViewNavigationHelpers = NavigationHelpers<ParamListBase, SplitViewNavigationEventMap> &\n StackActionHelpers<ParamListBase>;\n\n/** Descriptor of one split view route. */\ntype SplitViewDescriptor = Descriptor<\n SplitViewNavigationOptions,\n SplitViewNavigationProp<ParamListBase>,\n RouteProp<ParamListBase>\n>;\n\n/** Descriptors of the split view routes, keyed by route key. */\ntype SplitViewDescriptorMap = Record<string, SplitViewDescriptor>;\n\n/** Props of the split view navigator beyond the options every navigator shares. */\ntype SplitViewNavigationConfig = {\n /** Whether the panes stack into one instead of sitting side by side; defaults to `false`. Ignored while `collapseCondition` is set. */\n collapsed?: boolean;\n /**\n * An `Adw.BreakpointCondition` string, such as `\"max-width: 500sp\"`, measured against the navigator's size.\n * The panes collapse while it holds. libadwaita applies it during layout, before GTK moves focus, so\n * widening the window does not reselect the focused sidebar row the way a `collapsed` prop set from a\n * breakpoint handler can. Give the window a `widthRequest` and `heightRequest`, as for window breakpoints.\n */\n collapseCondition?: string;\n /** Fills the content pane, below an untitled header bar, while no content route is open; defaults to nothing. */\n contentPlaceholder?: ReactNode;\n /** Which side the sidebar sits on; defaults to `\"start\"`. */\n sidebarPosition?: \"start\" | \"end\";\n /** Minimum sidebar width, in the unit libadwaita uses for the split view. */\n minSidebarWidth?: number;\n /** Maximum sidebar width, in the unit libadwaita uses for the split view. */\n maxSidebarWidth?: number;\n /** Preferred sidebar width as a fraction of the total width. */\n sidebarWidthFraction?: number;\n /** Whether pressing Escape pops the visible content page; defaults to `true`. */\n popOnEscape?: boolean;\n};\n\n/** Props of the split view `Navigator` component. */\ntype SplitViewNavigatorProps = DefaultNavigatorOptions<\n ParamListBase,\n string | undefined,\n StackNavigationState<ParamListBase>,\n SplitViewNavigationOptions,\n SplitViewNavigationEventMap,\n SplitViewNavigationProp<ParamListBase>\n> &\n StackRouterOptions &\n SplitViewNavigationConfig;\n\nexport type {\n SplitViewDescriptor,\n SplitViewDescriptorMap,\n SplitViewNavigationConfig,\n SplitViewNavigationEventMap,\n SplitViewNavigationHelpers,\n SplitViewNavigationOptions,\n SplitViewNavigationProp,\n SplitViewNavigatorProps,\n SplitViewScreenProps,\n};\n"]}
|
|
@@ -25,6 +25,8 @@ declare const createStackScreen: StaticScreenFactory<StackTypeBag>;
|
|
|
25
25
|
/** Renders the screens of a {@link createStackNavigator} as pages of an `AdwNavigationView`. */
|
|
26
26
|
declare function StackNavigator({ popOnEscape, ...options }: StackNavigatorProps): ReactNode;
|
|
27
27
|
/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */
|
|
28
|
-
declare function createStackNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID
|
|
28
|
+
declare function createStackNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>>(): TypedNavigator<TypeBag, undefined>;
|
|
29
|
+
/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */
|
|
30
|
+
declare function createStackNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>, const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>>(config: Config): TypedNavigator<TypeBag, Config>;
|
|
29
31
|
export { createStackNavigator, createStackScreen, StackNavigator, type StackTypeBag };
|
|
30
32
|
//# sourceMappingURL=create-stack-navigator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-stack-navigator.d.ts","sourceRoot":"","sources":["../../src/stack/create-stack-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EAEb,oBAAoB,EAEpB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACR,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,YAAY,CAAC;AAGpB,gFAAgF;AAChF,KAAK,YAAY,CACb,SAAS,SAAS,aAAa,GAAG,aAAa,EAC/C,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3D;IACA,oCAAoC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,6BAA6B;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,oCAAoC;IACpC,KAAK,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACvC,0BAA0B;IAC1B,aAAa,EAAE,sBAAsB,CAAC;IACtC,kCAAkC;IAClC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,mCAAmC;IACnC,cAAc,EAAE;SACX,SAAS,IAAI,MAAM,SAAS,GAAG,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;KACzF,CAAC;IACF,+BAA+B;IAC/B,SAAS,EAAE,OAAO,cAAc,CAAC;CACpC,CAAC;AAEF,qFAAqF;AACrF,QAAA,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,YAAY,CAAuC,CAAC;AAEjG,gGAAgG;AAChG,iBAAS,cAAc,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,EAAE,mBAAmB,GAAG,SAAS,CAkBnF;AAED,sHAAsH;AACtH,iBAAS,oBAAoB,CACzB,KAAK,CAAC,SAAS,SAAS,aAAa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC,EACjF,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"create-stack-navigator.d.ts","sourceRoot":"","sources":["../../src/stack/create-stack-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EAEb,oBAAoB,EAEpB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE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Aa,EACrC,KAAK,CAAC,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACjE,KAAK,CAAC,OAAO,SAAS,oBAAoB,GAAG,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC,EACjF,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EACpE,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAQnD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,CAAC"}
|
|
@@ -8,7 +8,6 @@ function StackNavigator({ popOnEscape, ...options }) {
|
|
|
8
8
|
const { state, describe, descriptors, navigation, render } = useNavigationBuilder(StackRouter, options);
|
|
9
9
|
return render(_jsx(StackView, { popOnEscape: popOnEscape, state: state, navigation: navigation, descriptors: descriptors, describe: describe }));
|
|
10
10
|
}
|
|
11
|
-
/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */
|
|
12
11
|
function createStackNavigator(config) {
|
|
13
12
|
return createNavigatorFactory(StackNavigator)(config);
|
|
14
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-stack-navigator.js","sourceRoot":"","sources":["../../src/stack/create-stack-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAOxH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAyB5C,qFAAqF;AACrF,MAAM,iBAAiB,GAAsC,mBAAmB,EAAgB,CAAC;AAEjG,gGAAgG;AAChG,SAAS,cAAc,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,EAAuB;IACpE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAM/E,WAAW,EAAE,OAAO,CAAC,CAAC;IAExB,OAAO,MAAM,CACT,KAAC,SAAS,IACN,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,GACpB,CACL,CAAC;AACN,CAAC;
|
|
1
|
+
{"version":3,"file":"create-stack-navigator.js","sourceRoot":"","sources":["../../src/stack/create-stack-navigator.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAOxH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAyB5C,qFAAqF;AACrF,MAAM,iBAAiB,GAAsC,mBAAmB,EAAgB,CAAC;AAEjG,gGAAgG;AAChG,SAAS,cAAc,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,EAAuB;IACpE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAM/E,WAAW,EAAE,OAAO,CAAC,CAAC;IAExB,OAAO,MAAM,CACT,KAAC,SAAS,IACN,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,GACpB,CACL,CAAC;AACN,CAAC;AAeD,SAAS,oBAAoB,CAG3B,MAAe;IACb,OAAO,sBAAsB,CAAC,cAAc,CAAC,CAAC,MAAM,CAAoC,CAAC;AAC7F,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,cAAc,EAAqB,CAAC","sourcesContent":["import type {\n NavigatorTypeBagBase,\n ParamListBase,\n StackActionHelpers,\n StackNavigationState,\n StackRouterOptions,\n StaticConfig,\n StaticScreenFactory,\n TypedNavigator,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport { createNavigatorFactory, createScreenFactory, StackRouter, useNavigationBuilder } from \"@react-navigation/core\";\nimport type {\n StackNavigationEventMap,\n StackNavigationOptions,\n StackNavigationProp,\n StackNavigatorProps,\n} from \"./types.js\";\nimport { StackView } from \"./stack-view.js\";\n\n/** Type bag describing the stack navigator to React Navigation's typed APIs. */\ntype StackTypeBag<\n ParamList extends ParamListBase = ParamListBase,\n NavigatorID extends string | undefined = string | undefined,\n> = {\n /** Route names and their params. */\n ParamList: ParamList;\n /** Optional navigator id. */\n NavigatorID: NavigatorID;\n /** Shape of the navigator state. */\n State: StackNavigationState<ParamList>;\n /** Per-screen options. */\n ScreenOptions: StackNavigationOptions;\n /** Events the navigator emits. */\n EventMap: StackNavigationEventMap;\n /** Navigation object per route. */\n NavigationList: {\n [RouteName in keyof ParamList]: StackNavigationProp<ParamList, RouteName, NavigatorID>;\n };\n /** The navigator component. */\n Navigator: typeof StackNavigator;\n};\n\n/** Declares a typed screen of a stack navigator for the static configuration API. */\nconst createStackScreen: StaticScreenFactory<StackTypeBag> = createScreenFactory<StackTypeBag>();\n\n/** Renders the screens of a {@link createStackNavigator} as pages of an `AdwNavigationView`. */\nfunction StackNavigator({ popOnEscape, ...options }: StackNavigatorProps): ReactNode {\n const { state, describe, descriptors, navigation, render } = useNavigationBuilder<\n StackNavigationState<ParamListBase>,\n StackRouterOptions,\n StackActionHelpers<ParamListBase>,\n StackNavigationOptions,\n StackNavigationEventMap\n >(StackRouter, options);\n\n return render(\n <StackView\n popOnEscape={popOnEscape}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n describe={describe}\n />,\n );\n}\n\n/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */\nfunction createStackNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>,\n>(): TypedNavigator<TypeBag, undefined>;\n/** Creates a stack navigator rendered with `AdwNavigationView`: pushes and pops animate like native Adwaita pages. */\nfunction createStackNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = StackTypeBag<ParamList, NavigatorID>,\n const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,\n>(config: Config): TypedNavigator<TypeBag, Config>;\nfunction createStackNavigator<\n const TypeBag extends NavigatorTypeBagBase,\n const Config extends StaticConfig<TypeBag> | undefined,\n>(config?: Config): TypedNavigator<TypeBag, Config> {\n return createNavigatorFactory(StackNavigator)(config) as TypedNavigator<TypeBag, Config>;\n}\n\nexport { createStackNavigator, createStackScreen, StackNavigator, type StackTypeBag };\n"]}
|
package/dist/stack/stack-view.js
CHANGED
|
@@ -46,7 +46,7 @@ const StackPageContent = ({ descriptor, previous }) => {
|
|
|
46
46
|
}
|
|
47
47
|
const back = previous === undefined ? undefined : { title: previous.options.title ?? previous.route.name };
|
|
48
48
|
const topBar = options.header === undefined ? (_jsx(HeaderBar, { options: options, showBackButton: options.headerBackVisible ?? true })) : (_jsx(_Fragment, { children: options.header({ route, navigation, options, back }) }));
|
|
49
|
-
return _jsx(AdwToolbarView, {
|
|
49
|
+
return _jsx(AdwToolbarView, { top: topBar, children: descriptor.render() });
|
|
50
50
|
};
|
|
51
51
|
const StackPage = ({ descriptor, previous, navigation, onHidden }) => {
|
|
52
52
|
const { route, options } = descriptor;
|
|
@@ -1 +1 @@
|
|
|
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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OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACxE,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAE9C,OAAO,CACH,KAAC,iBAAiB,IAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,IAAI,IAAI,EAAE,QAAQ,EAAE,QAAQ,YAChF,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CACvB,KAAC,SAAS,IAEN,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,EAC9E,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
|
+
{"version":3,"file":"stack-view.js","sourceRoot":"","sources":["../../src/stack/stack-view.tsx"],"names":[],"mappings":";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AAY,CAAe,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACpH,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACxE,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAE9C,OAAO,CACH,KAAC,iBAAiB,IAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,IAAI,IAAI,EAAE,QAAQ,EAAE,QAAQ,YAChF,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CACvB,KAAC,SAAS,IAEN,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,EAC9E,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 top={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"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { NavigatorTypeBagBase, ParamListBase, StaticConfig, StaticScreenFactory, TypedNavigator } from "@react-navigation/core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { TabViewNavigationEventMap, TabViewNavigationOptions, TabViewNavigationProp, TabViewNavigationState, TabViewNavigatorProps } from "./types.js";
|
|
4
|
+
/** Type bag describing the tab view navigator to React Navigation's typed APIs. */
|
|
5
|
+
type TabViewTypeBag<ParamList extends ParamListBase = ParamListBase, NavigatorID extends string | undefined = string | undefined> = {
|
|
6
|
+
/** Route names and their params. */
|
|
7
|
+
ParamList: ParamList;
|
|
8
|
+
/** Optional navigator id. */
|
|
9
|
+
NavigatorID: NavigatorID;
|
|
10
|
+
/** Shape of the navigator state. */
|
|
11
|
+
State: TabViewNavigationState<ParamList>;
|
|
12
|
+
/** Per-screen options. */
|
|
13
|
+
ScreenOptions: TabViewNavigationOptions;
|
|
14
|
+
/** Events the navigator emits. */
|
|
15
|
+
EventMap: TabViewNavigationEventMap;
|
|
16
|
+
/** Navigation object per route. */
|
|
17
|
+
NavigationList: {
|
|
18
|
+
[RouteName in keyof ParamList]: TabViewNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
19
|
+
};
|
|
20
|
+
/** The navigator component. */
|
|
21
|
+
Navigator: typeof TabViewNavigator;
|
|
22
|
+
};
|
|
23
|
+
/** Declares a typed screen of a tab view navigator for the static configuration API. */
|
|
24
|
+
declare const createTabViewScreen: StaticScreenFactory<TabViewTypeBag>;
|
|
25
|
+
/** Renders each open route of a {@link createTabViewNavigator} as a page of an `Adw.TabView`. */
|
|
26
|
+
declare function TabViewNavigator({ view: providedView, tabBarVisible, tabBarAutohide, tabBarExpand, tabBarInverted, overview, menuModel, renderMenu, extraDropTarget, onExtraDragDrop, onCreateWindow, onSetupMenu, shortcuts, defaultIcon, ...options }: TabViewNavigatorProps): ReactNode;
|
|
27
|
+
/** Creates a navigator whose routes are the pages of an `Adw.TabView`, with a tab bar and an optional overview. */
|
|
28
|
+
declare function createTabViewNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = TabViewTypeBag<ParamList, NavigatorID>>(): TypedNavigator<TypeBag, undefined>;
|
|
29
|
+
/** Creates a navigator whose routes are the pages of an `Adw.TabView`, with a tab bar and an optional overview. */
|
|
30
|
+
declare function createTabViewNavigator<const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = TabViewTypeBag<ParamList, NavigatorID>, const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>>(config: Config): TypedNavigator<TypeBag, Config>;
|
|
31
|
+
export { createTabViewNavigator, createTabViewScreen, TabViewNavigator, type TabViewTypeBag };
|
|
32
|
+
//# sourceMappingURL=create-tab-view-navigator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tab-view-navigator.d.ts","sourceRoot":"","sources":["../../src/tab-view/create-tab-view-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAER,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EAExB,MAAM,YAAY,CAAC;AAKpB,mFAAmF;AACnF,KAAK,cAAc,CACf,SAAS,SAAS,aAAa,GAAG,aAAa,EAC/C,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3D;IACA,oCAAoC;IACp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oB,GAAG,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,EACnF,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,sBAAsB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as Adw from "@gtkx/gi/adw";
|
|
3
|
+
import { createNavigatorFactory, createScreenFactory, useNavigationBuilder } from "@react-navigation/core";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { readExistingTabs } from "./page-registry.js";
|
|
6
|
+
import { TabViewHost } from "./tab-view-host.js";
|
|
7
|
+
import { createTabViewRouter } from "./tab-view-router.js";
|
|
8
|
+
/** Declares a typed screen of a tab view navigator for the static configuration API. */
|
|
9
|
+
const createTabViewScreen = createScreenFactory();
|
|
10
|
+
/** Renders each open route of a {@link createTabViewNavigator} as a page of an `Adw.TabView`. */
|
|
11
|
+
function TabViewNavigator({ view: providedView, tabBarVisible, tabBarAutohide, tabBarExpand, tabBarInverted, overview, menuModel, renderMenu, extraDropTarget, onExtraDragDrop, onCreateWindow, onSetupMenu, shortcuts, defaultIcon, ...options }) {
|
|
12
|
+
const [view] = useState(() => providedView ?? new Adw.TabView());
|
|
13
|
+
const [router] = useState(() => createTabViewRouter(() => readExistingTabs(view)));
|
|
14
|
+
const { state, descriptors, navigation, render } = useNavigationBuilder(router, options);
|
|
15
|
+
return render(_jsx(TabViewHost, { view: view, state: state, navigation: navigation, descriptors: descriptors, tabBarVisible: tabBarVisible, tabBarAutohide: tabBarAutohide, tabBarExpand: tabBarExpand, tabBarInverted: tabBarInverted, overview: overview, menuModel: menuModel, renderMenu: renderMenu, extraDropTarget: extraDropTarget, onExtraDragDrop: onExtraDragDrop, onCreateWindow: onCreateWindow, onSetupMenu: onSetupMenu, shortcuts: shortcuts, defaultIcon: defaultIcon }));
|
|
16
|
+
}
|
|
17
|
+
function createTabViewNavigator(config) {
|
|
18
|
+
return createNavigatorFactory(TabViewNavigator)(config);
|
|
19
|
+
}
|
|
20
|
+
export { createTabViewNavigator, createTabViewScreen, TabViewNavigator };
|
|
21
|
+
//# sourceMappingURL=create-tab-view-navigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tab-view-navigator.js","sourceRoot":"","sources":["../../src/tab-view/create-tab-view-navigator.tsx"],"names":[],"mappings":";AAQA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC3G,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAyB3D,wFAAwF;AACxF,MAAM,mBAAmB,GAAwC,mBAAmB,EAAkB,CAAC;AAEvG,iGAAiG;AACjG,SAAS,gBAAgB,CAAC,EACtB,IAAI,EAAE,YAAY,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,SAAS,EACT,UAAU,EACV,eAAe,EACf,eAAe,EACf,cAAc,EACd,WAAW,EACX,SAAS,EACT,WAAW,EACX,GAAG,OAAO,EACU;IACpB,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,YAAY,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACjE,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnF,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAMrE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnB,OAAO,MAAM,CACT,KAAC,WAAW,IACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,GAC1B,CACL,CAAC;AACN,CAAC;AAeD,SAAS,sBAAsB,CAG7B,MAAe;IACb,OAAO,sBAAsB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAoC,CAAC;AAC/F,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,gBAAgB,EAAuB,CAAC","sourcesContent":["import type {\n NavigatorTypeBagBase,\n ParamListBase,\n StaticConfig,\n StaticScreenFactory,\n TypedNavigator,\n} from \"@react-navigation/core\";\nimport type { ReactNode } from \"react\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport { createNavigatorFactory, createScreenFactory, useNavigationBuilder } from \"@react-navigation/core\";\nimport { useState } from \"react\";\nimport type {\n TabViewActionHelpers,\n TabViewNavigationEventMap,\n TabViewNavigationOptions,\n TabViewNavigationProp,\n TabViewNavigationState,\n TabViewNavigatorProps,\n TabViewRouterOptions,\n} from \"./types.js\";\nimport { readExistingTabs } from \"./page-registry.js\";\nimport { TabViewHost } from \"./tab-view-host.js\";\nimport { createTabViewRouter } from \"./tab-view-router.js\";\n\n/** Type bag describing the tab view navigator to React Navigation's typed APIs. */\ntype TabViewTypeBag<\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: TabViewNavigationState<ParamList>;\n /** Per-screen options. */\n ScreenOptions: TabViewNavigationOptions;\n /** Events the navigator emits. */\n EventMap: TabViewNavigationEventMap;\n /** Navigation object per route. */\n NavigationList: {\n [RouteName in keyof ParamList]: TabViewNavigationProp<ParamList, RouteName, NavigatorID>;\n };\n /** The navigator component. */\n Navigator: typeof TabViewNavigator;\n};\n\n/** Declares a typed screen of a tab view navigator for the static configuration API. */\nconst createTabViewScreen: StaticScreenFactory<TabViewTypeBag> = createScreenFactory<TabViewTypeBag>();\n\n/** Renders each open route of a {@link createTabViewNavigator} as a page of an `Adw.TabView`. */\nfunction TabViewNavigator({\n view: providedView,\n tabBarVisible,\n tabBarAutohide,\n tabBarExpand,\n tabBarInverted,\n overview,\n menuModel,\n renderMenu,\n extraDropTarget,\n onExtraDragDrop,\n onCreateWindow,\n onSetupMenu,\n shortcuts,\n defaultIcon,\n ...options\n}: TabViewNavigatorProps): ReactNode {\n const [view] = useState(() => providedView ?? new Adw.TabView());\n const [router] = useState(() => createTabViewRouter(() => readExistingTabs(view)));\n const { state, descriptors, navigation, render } = useNavigationBuilder<\n TabViewNavigationState<ParamListBase>,\n TabViewRouterOptions,\n TabViewActionHelpers<ParamListBase>,\n TabViewNavigationOptions,\n TabViewNavigationEventMap\n >(router, options);\n\n return render(\n <TabViewHost\n view={view}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n tabBarVisible={tabBarVisible}\n tabBarAutohide={tabBarAutohide}\n tabBarExpand={tabBarExpand}\n tabBarInverted={tabBarInverted}\n overview={overview}\n menuModel={menuModel}\n renderMenu={renderMenu}\n extraDropTarget={extraDropTarget}\n onExtraDragDrop={onExtraDragDrop}\n onCreateWindow={onCreateWindow}\n onSetupMenu={onSetupMenu}\n shortcuts={shortcuts}\n defaultIcon={defaultIcon}\n />,\n );\n}\n\n/** Creates a navigator whose routes are the pages of an `Adw.TabView`, with a tab bar and an optional overview. */\nfunction createTabViewNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = TabViewTypeBag<ParamList, NavigatorID>,\n>(): TypedNavigator<TypeBag, undefined>;\n/** Creates a navigator whose routes are the pages of an `Adw.TabView`, with a tab bar and an optional overview. */\nfunction createTabViewNavigator<\n const ParamList extends ParamListBase,\n const NavigatorID extends string | undefined = string | undefined,\n const TypeBag extends NavigatorTypeBagBase = TabViewTypeBag<ParamList, NavigatorID>,\n const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,\n>(config: Config): TypedNavigator<TypeBag, Config>;\nfunction createTabViewNavigator<\n const TypeBag extends NavigatorTypeBagBase,\n const Config extends StaticConfig<TypeBag> | undefined,\n>(config?: Config): TypedNavigator<TypeBag, Config> {\n return createNavigatorFactory(TabViewNavigator)(config) as TypedNavigator<TypeBag, Config>;\n}\n\nexport { createTabViewNavigator, createTabViewScreen, TabViewNavigator, type TabViewTypeBag };\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/gi/adw";
|
|
2
|
+
import type { ParamListBase } from "@react-navigation/core";
|
|
3
|
+
import type { ExistingTab } from "./tab-view-router.js";
|
|
4
|
+
import type { TabViewNavigationOptions, TabViewNavigationState } from "./types.js";
|
|
5
|
+
type Route = TabViewNavigationState<ParamListBase>["routes"][number];
|
|
6
|
+
/** Page property values last written from a route's options. */
|
|
7
|
+
type AppliedOptions = Pick<TabViewNavigationOptions, "icon" | "indicatorActivatable" | "indicatorIcon" | "indicatorTooltip" | "keyword" | "liveThumbnail" | "loading" | "needsAttention" | "thumbnailXalign" | "thumbnailYalign" | "tooltip"> & {
|
|
8
|
+
title?: string;
|
|
9
|
+
};
|
|
10
|
+
/** A native page a tab view navigator created or adopted, with the host its content renders into. */
|
|
11
|
+
type PageRecord = {
|
|
12
|
+
route: Route;
|
|
13
|
+
page: Adw.TabPage;
|
|
14
|
+
host: Adw.Bin;
|
|
15
|
+
applied: AppliedOptions;
|
|
16
|
+
};
|
|
17
|
+
/** The pages of one navigator by route key, notifying React when the set changes. */
|
|
18
|
+
type PageStore = {
|
|
19
|
+
get: (key: string) => PageRecord | undefined;
|
|
20
|
+
set: (record: PageRecord) => void;
|
|
21
|
+
delete: (key: string) => void;
|
|
22
|
+
keys: () => string[];
|
|
23
|
+
subscribe: (listener: () => void) => () => void;
|
|
24
|
+
getVersion: () => number;
|
|
25
|
+
/** Key of the route whose page was selected by the last sync, so native selection changes are not undone. */
|
|
26
|
+
lastFocus: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
declare const recordOf: (page: Adw.TabPage) => PageRecord | undefined;
|
|
29
|
+
declare const registerPage: (record: PageRecord) => void;
|
|
30
|
+
declare const ownerOf: (page: Adw.TabPage) => Adw.TabView | null;
|
|
31
|
+
declare const readExistingTabs: (view: Adw.TabView) => ExistingTab[];
|
|
32
|
+
declare const createPageStore: () => PageStore;
|
|
33
|
+
export { type AppliedOptions, createPageStore, ownerOf, type PageRecord, type PageStore, readExistingTabs, recordOf, registerPage, };
|
|
34
|
+
//# sourceMappingURL=page-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-registry.d.ts","sourceRoot":"","sources":["../../src/tab-view/page-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE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AAG,GAAG,CAAC,OAAO,GAAG,IAYlD,CAAC;AAEF,QAAA,MAAM,gBAAgB,SAAU,GAAG,CAAC,OAAO,KAAG,WAAW,EAwBxD,CAAC;AAEF,QAAA,MAAM,eAAe,QAAO,SAmC3B,CAAC;AAEF,OAAO,EACH,KAAK,cAAc,EACnB,eAAe,EACf,OAAO,EACP,KAAK,UAAU,EACf,KAAK,SAAS,EACd,gBAAgB,EAChB,QAAQ,EACR,YAAY,GACf,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/gi/adw";
|
|
2
|
+
const records = new WeakMap();
|
|
3
|
+
const recordOf = (page) => records.get(page);
|
|
4
|
+
const registerPage = (record) => {
|
|
5
|
+
records.set(record.page, record);
|
|
6
|
+
};
|
|
7
|
+
const ownerOf = (page) => {
|
|
8
|
+
let widget = page.getChild();
|
|
9
|
+
while (widget !== null) {
|
|
10
|
+
if (widget instanceof Adw.TabView) {
|
|
11
|
+
return widget;
|
|
12
|
+
}
|
|
13
|
+
widget = widget.getParent();
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
const readExistingTabs = (view) => {
|
|
18
|
+
const selected = view.getSelectedPage();
|
|
19
|
+
const tabs = [];
|
|
20
|
+
for (let position = 0; position < view.getNPages(); position += 1) {
|
|
21
|
+
const page = view.getNthPage(position);
|
|
22
|
+
const record = records.get(page);
|
|
23
|
+
if (record === undefined) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const parent = page.getParent();
|
|
27
|
+
const parentRecord = parent === null ? undefined : records.get(parent);
|
|
28
|
+
tabs.push({
|
|
29
|
+
route: record.route,
|
|
30
|
+
pinned: page.getPinned(),
|
|
31
|
+
parent: parentRecord?.route.key,
|
|
32
|
+
selected: page === selected,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return tabs;
|
|
36
|
+
};
|
|
37
|
+
const createPageStore = () => {
|
|
38
|
+
const byKey = new Map();
|
|
39
|
+
const listeners = new Set();
|
|
40
|
+
let version = 0;
|
|
41
|
+
const notify = () => {
|
|
42
|
+
version += 1;
|
|
43
|
+
for (const listener of listeners) {
|
|
44
|
+
listener();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
get: (key) => byKey.get(key),
|
|
49
|
+
set: (record) => {
|
|
50
|
+
byKey.set(record.route.key, record);
|
|
51
|
+
notify();
|
|
52
|
+
},
|
|
53
|
+
delete: (key) => {
|
|
54
|
+
if (byKey.delete(key)) {
|
|
55
|
+
notify();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
keys: () => [...byKey.keys()],
|
|
59
|
+
subscribe: (listener) => {
|
|
60
|
+
listeners.add(listener);
|
|
61
|
+
return () => {
|
|
62
|
+
listeners.delete(listener);
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
getVersion: () => version,
|
|
66
|
+
lastFocus: undefined,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export { createPageStore, ownerOf, readExistingTabs, recordOf, registerPage, };
|
|
70
|
+
//# sourceMappingURL=page-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-registry.js","sourceRoot":"","sources":["../../src/tab-view/page-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AA2CpC,MAAM,OAAO,GAAG,IAAI,OAAO,EAA2B,CAAC;AAEvD,MAAM,QAAQ,GAAG,CAAC,IAAiB,EAA0B,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAElF,MAAM,YAAY,GAAG,CAAC,MAAkB,EAAQ,EAAE;IAC9C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,IAAiB,EAAsB,EAAE;IACtD,IAAI,MAAM,GAAsB,IAAI,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igation/core\";\nimport type { ExistingTab } from \"./tab-view-router.js\";\nimport type { TabViewNavigationOptions, TabViewNavigationState } from \"./types.js\";\n\ntype Route = TabViewNavigationState<ParamListBase>[\"routes\"][number];\n\n/** Page property values last written from a route's options. */\ntype AppliedOptions = Pick<\n TabViewNavigationOptions,\n | \"icon\"\n | \"indicatorActivatable\"\n | \"indicatorIcon\"\n | \"indicatorTooltip\"\n | \"keyword\"\n | \"liveThumbnail\"\n | \"loading\"\n | \"needsAttention\"\n | \"thumbnailXalign\"\n | \"thumbnailYalign\"\n | \"tooltip\"\n> & { title?: string };\n\n/** A native page a tab view navigator created or adopted, with the host its content renders into. */\ntype PageRecord = {\n route: Route;\n page: Adw.TabPage;\n host: Adw.Bin;\n applied: AppliedOptions;\n};\n\n/** The pages of one navigator by route key, notifying React when the set changes. */\ntype PageStore = {\n get: (key: string) => PageRecord | undefined;\n set: (record: PageRecord) => void;\n delete: (key: string) => void;\n keys: () => string[];\n subscribe: (listener: () => void) => () => void;\n getVersion: () => number;\n /** Key of the route whose page was selected by the last sync, so native selection changes are not undone. */\n lastFocus: string | undefined;\n};\n\nconst records = new WeakMap<Adw.TabPage, PageRecord>();\n\nconst recordOf = (page: Adw.TabPage): PageRecord | undefined => records.get(page);\n\nconst registerPage = (record: PageRecord): void => {\n records.set(record.page, record);\n};\n\nconst ownerOf = (page: Adw.TabPage): Adw.TabView | null => {\n let widget: Gtk.Widget | null = page.getChild();\n\n while (widget !== null) {\n if (widget instanceof Adw.TabView) {\n return widget;\n }\n\n widget = widget.getParent();\n }\n\n return null;\n};\n\nconst readExistingTabs = (view: Adw.TabView): ExistingTab[] => {\n const selected = view.getSelectedPage();\n const tabs: ExistingTab[] = [];\n\n for (let position = 0; position < view.getNPages(); position += 1) {\n const page = view.getNthPage(position);\n const record = records.get(page);\n\n if (record === undefined) {\n continue;\n }\n\n const parent = page.getParent();\n const parentRecord = parent === null ? undefined : records.get(parent);\n\n tabs.push({\n route: record.route,\n pinned: page.getPinned(),\n parent: parentRecord?.route.key,\n selected: page === selected,\n });\n }\n\n return tabs;\n};\n\nconst createPageStore = (): PageStore => {\n const byKey = new Map<string, PageRecord>();\n const listeners = new Set<() => void>();\n let version = 0;\n\n const notify = (): void => {\n version += 1;\n\n for (const listener of listeners) {\n listener();\n }\n };\n\n return {\n get: (key) => byKey.get(key),\n set: (record) => {\n byKey.set(record.route.key, record);\n notify();\n },\n delete: (key) => {\n if (byKey.delete(key)) {\n notify();\n }\n },\n keys: () => [...byKey.keys()],\n subscribe: (listener) => {\n listeners.add(listener);\n\n return () => {\n listeners.delete(listener);\n };\n },\n getVersion: () => version,\n lastFocus: undefined,\n };\n};\n\nexport {\n type AppliedOptions,\n createPageStore,\n ownerOf,\n type PageRecord,\n type PageStore,\n readExistingTabs,\n recordOf,\n registerPage,\n};\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ParamListBase } from "@react-navigation/core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import * as Adw from "@gtkx/gi/adw";
|
|
4
|
+
import type { TabViewDescriptorMap, TabViewNavigationConfig, TabViewNavigationHelpers, TabViewNavigationState } from "./types.js";
|
|
5
|
+
type State = TabViewNavigationState<ParamListBase>;
|
|
6
|
+
type TabViewHostProps = TabViewNavigationConfig & {
|
|
7
|
+
view: Adw.TabView;
|
|
8
|
+
state: State;
|
|
9
|
+
navigation: TabViewNavigationHelpers;
|
|
10
|
+
descriptors: TabViewDescriptorMap;
|
|
11
|
+
};
|
|
12
|
+
/** The native view of the surrounding tab view navigator and access to its pages. */
|
|
13
|
+
type TabViewHandle = {
|
|
14
|
+
/** The `Adw.TabView` the navigator renders into. */
|
|
15
|
+
view: Adw.TabView;
|
|
16
|
+
/** Returns the native page of a route, or `null` when it is not in this view. */
|
|
17
|
+
getPage: (key: string) => Adw.TabPage | null;
|
|
18
|
+
/** Moves a route's page into another view, appending to its pinned or unpinned group by default. */
|
|
19
|
+
transferTab: (key: string, target: Adw.TabView, position?: number) => void;
|
|
20
|
+
};
|
|
21
|
+
/** Returns the surrounding tab view navigator's native view and page access. */
|
|
22
|
+
declare const useTabView: () => TabViewHandle;
|
|
23
|
+
declare const TabViewHost: (props: TabViewHostProps) => ReactNode;
|
|
24
|
+
export { type TabViewHandle, TabViewHost, useTabView };
|
|
25
|
+
//# sourceMappingURL=tab-view-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-view-host.d.ts","sourceRoot":"","sources":["../../src/tab-view/tab-view-host.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAMpC,OAAO,KAAK,EAER,oBAAoB,EAEpB,uBAAuB,EACvB,wBAAwB,EAExB,sBAAsB,EACzB,MAAM,YAAY,CAAC;AAOpB,KAAK,KAAK,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAGnD,KAAK,gBAAgB,GAAG,uBAAuB,GAAG;IAC9C,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,wBAAwB,CAAC;IACrC,WAAW,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAOF,qFAAqF;AACrF,KAAK,aAAa,GAAG;IACjB,oDAAoD;IACpD,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC;IAClB,iFAAiF;IACjF,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7C,oGAAoG;IACpG,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9E,CAAC;AAIF,gFAAgF;AAChF,QAAA,MAAM,UAAU,QAAO,aAQtB,CAAC;AAmJF,QAAA,MAAM,WAAW,UAAW,gBAAgB,KAAG,SAwQ9C,CAAC;AAEF,OAAO,EAAE,KAAK,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC"}
|