@tearleads/windowing 0.2.41 → 0.2.43
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/docs/launcher.md +9 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/launcher/LauncherMenuItem.d.ts +6 -0
- package/launcher/LauncherMenuItem.js +8 -0
- package/launcher/LauncherMenuItem.js.map +1 -0
- package/launcher/LauncherNavigationProvider.d.ts +9 -3
- package/launcher/LauncherNavigationProvider.js +10 -8
- package/launcher/LauncherNavigationProvider.js.map +1 -1
- package/launcher/useLauncherEntryMenu.d.ts +13 -0
- package/launcher/useLauncherEntryMenu.js +20 -0
- package/launcher/useLauncherEntryMenu.js.map +1 -0
- package/launcher/useWindowedEntryWindows.d.ts +17 -0
- package/launcher/useWindowedEntryWindows.js +76 -0
- package/launcher/useWindowedEntryWindows.js.map +1 -0
- package/menu/Menu.js +12 -13
- package/menu/Menu.js.map +1 -1
- package/menu/MenuItem.d.ts +3 -3
- package/menu/MenuItem.js +2 -2
- package/menu/MenuItem.js.map +1 -1
- package/menu/menuOwnership.d.ts +4 -0
- package/menu/menuOwnership.js +25 -0
- package/menu/menuOwnership.js.map +1 -0
- package/menu/useMenuKeyboard.js +2 -1
- package/menu/useMenuKeyboard.js.map +1 -1
- package/package.json +1 -1
- package/routed/RoutedPaneNav.css +2 -0
- package/routed/RoutedPaneNav.js +11 -8
- package/routed/RoutedPaneNav.js.map +1 -1
- package/launcher/useDefaultWindow.d.ts +0 -15
- package/launcher/useDefaultWindow.js +0 -28
- package/launcher/useDefaultWindow.js.map +0 -1
package/docs/launcher.md
CHANGED
|
@@ -89,6 +89,15 @@ workspaces). Hiding and showing an already initialized desktop preserves it,
|
|
|
89
89
|
even if empty. Omit the list to manage startup yourself; `homeAppId` only sets
|
|
90
90
|
the routed home.
|
|
91
91
|
|
|
92
|
+
Entering windowed mode also opens the app the browser's URL names
|
|
93
|
+
(`/app/<app id>/…`), in front of the default windows, so a link to an app, or
|
|
94
|
+
a switch from the routed shell, shows that app in either mode. An app that is
|
|
95
|
+
already open is raised, and routed to the URL's path if it has one. While
|
|
96
|
+
windowed, a browser history step to another app's URL opens that app too.
|
|
97
|
+
Windowed mode never changes the URL. Where several launchers share a page,
|
|
98
|
+
pass `routeWindowEnabled` to one: a launcher with it false at the entry skips
|
|
99
|
+
that URL, and does not open it when enabled later.
|
|
100
|
+
|
|
92
101
|
A new window opens at the request's `position`, or `DEFAULT_MINI_APP_POSITION`,
|
|
93
102
|
at the app's `windowSize`. A host that places its apps itself passes the
|
|
94
103
|
provider a `placeWindow` callback. It receives each request that opens a new
|
package/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { DisplayProperties } from "./display/DisplayProperties.js";
|
|
|
7
7
|
export { type WindowingIcons, WindowingIconsProvider, } from "./icons/WindowingIcons.js";
|
|
8
8
|
export type { WindowingIcon, WindowingIconProps } from "./icons/windowingIcon.js";
|
|
9
9
|
export { ROUTED_TABLET_BREAKPOINT_PX, ROUTED_TABLET_QUERY, WINDOWED_LAYOUT_MIN_WIDTH_PX, } from "./launcher/breakpoints.js";
|
|
10
|
+
export { LauncherMenuItem } from "./launcher/LauncherMenuItem.js";
|
|
10
11
|
export { type LauncherNavigationActions, LauncherNavigationProvider, type LauncherNavigationState, useLauncherNavigationActions, useLauncherNavigationState, useMiniAppRouteSegments, useOptionalLauncherNavigationState, } from "./launcher/LauncherNavigationProvider.js";
|
|
11
12
|
export { isLauncherAppId, type LauncherDefinition, type MiniAppDefinition, resolveLauncherHomeAppId, resolveLauncherOrder, } from "./launcher/launcherDefinition.js";
|
|
12
13
|
export { MiniAppRouteSegmentsProvider, useMiniAppWindowRouteSegments, } from "./launcher/MiniAppRouteSegmentsContext.js";
|
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { createMemoryDesktopStateStorage, createOpfsDesktopStateStorage, } from
|
|
|
12
12
|
export { DisplayProperties } from "./display/DisplayProperties.js";
|
|
13
13
|
export { WindowingIconsProvider, } from "./icons/WindowingIcons.js";
|
|
14
14
|
export { ROUTED_TABLET_BREAKPOINT_PX, ROUTED_TABLET_QUERY, WINDOWED_LAYOUT_MIN_WIDTH_PX, } from "./launcher/breakpoints.js";
|
|
15
|
+
export { LauncherMenuItem } from "./launcher/LauncherMenuItem.js";
|
|
15
16
|
export { LauncherNavigationProvider, useLauncherNavigationActions, useLauncherNavigationState, useMiniAppRouteSegments, useOptionalLauncherNavigationState, } from "./launcher/LauncherNavigationProvider.js";
|
|
16
17
|
export { isLauncherAppId, resolveLauncherHomeAppId, resolveLauncherOrder, } from "./launcher/launcherDefinition.js";
|
|
17
18
|
export { MiniAppRouteSegmentsProvider, useMiniAppWindowRouteSegments, } from "./launcher/MiniAppRouteSegmentsContext.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,sEAAsE;AACtE,6BAA6B;AAC7B,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAG9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAEL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,0BAA0B,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,uC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qB,EACrB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAQlB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import \"./tokens.css\";\n\n// The public windowing API: window state, window chrome and its registration\n// hooks, the menu and sidebar primitives the chrome renders with, a taskbar's\n// start menu, theme switch, and system tray, the icons the chrome draws, a\n// launcher of mini-apps that shows them in windows or in the routed (iPad /\n// phone) shell, and desktop icons that open them, with a storage adapter for\n// their layout, over a wallpaper chosen in Display Properties, plus a\n// host-supplied screensaver.\nexport {\n createRequiredContext,\n type RequiredContext,\n} from \"./createRequiredContext\";\nexport type { DesktopIconMenuItem } from \"./desktop/DesktopIconMenu\";\nexport {\n DesktopIcons,\n type DesktopIconsProps,\n} from \"./desktop/DesktopIcons\";\nexport type {\n DesktopIconPosition,\n DesktopState,\n} from \"./desktop/desktopState\";\nexport {\n createMemoryDesktopStateStorage,\n createOpfsDesktopStateStorage,\n type DesktopStateStorage,\n type OpfsDesktopStateStorageOptions,\n} from \"./desktop/desktopStateStorage\";\nexport { DisplayProperties } from \"./display/DisplayProperties\";\nexport {\n type WindowingIcons,\n WindowingIconsProvider,\n} from \"./icons/WindowingIcons\";\nexport type { WindowingIcon, WindowingIconProps } from \"./icons/windowingIcon\";\nexport {\n ROUTED_TABLET_BREAKPOINT_PX,\n ROUTED_TABLET_QUERY,\n WINDOWED_LAYOUT_MIN_WIDTH_PX,\n} from \"./launcher/breakpoints\";\nexport {\n type LauncherNavigationActions,\n LauncherNavigationProvider,\n type LauncherNavigationState,\n useLauncherNavigationActions,\n useLauncherNavigationState,\n useMiniAppRouteSegments,\n useOptionalLauncherNavigationState,\n} from \"./launcher/LauncherNavigationProvider\";\nexport {\n isLauncherAppId,\n type LauncherDefinition,\n type MiniAppDefinition,\n resolveLauncherHomeAppId,\n resolveLauncherOrder,\n} from \"./launcher/launcherDefinition\";\nexport {\n MiniAppRouteSegmentsProvider,\n useMiniAppWindowRouteSegments,\n} from \"./launcher/MiniAppRouteSegmentsContext\";\nexport { type MiniAppBoundary, MiniAppWindow } from \"./launcher/MiniAppWindow\";\nexport {\n NavigationModeOverrideProvider,\n useNavigationModeOverride,\n useOptionalNavigationModeOverride,\n} from \"./launcher/NavigationModeOverrideProvider\";\nexport { NavigationModeSwitch } from \"./launcher/NavigationModeSwitch\";\nexport {\n isWindowedLayoutEligible,\n type NavigationEnvironment,\n type NavigationMode,\n readNavigationEnvironment,\n resolveNavigationMode,\n} from \"./launcher/navigationMode\";\nexport {\n DEFAULT_MINI_APP_POSITION,\n type MiniAppWindowPlacement,\n type OpenMiniAppRequest,\n type PlaceMiniAppWindow,\n} from \"./launcher/openMiniAppWindow\";\nexport {\n buildMiniAppPath,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./launcher/routePaths\";\nexport {\n resolveActiveLauncherRoute,\n useActiveLauncherRoute,\n} from \"./launcher/useActiveLauncherRoute\";\nexport { useCompactRoutedMode } from \"./launcher/useCompactRoutedMode\";\nexport {\n type MiniAppRouteSetOptions,\n useMiniAppRouteState,\n} from \"./launcher/useMiniAppRouteState\";\nexport { useNavigationMode } from \"./launcher/useNavigationMode\";\nexport { useNavigationModeDocumentAttribute } from \"./launcher/useNavigationModeDocumentAttribute\";\nexport {\n useRoutedLayoutActive,\n useWindowedLayoutActive,\n} from \"./launcher/useRoutedLayoutActive\";\nexport {\n type RoutedLayoutTier,\n useRoutedLayoutTier,\n} from \"./launcher/useRoutedLayoutTier\";\nexport { Menu, type MenuPosition } from \"./menu/Menu\";\nexport { MenuItem, type MenuItemProps } from \"./menu/MenuItem\";\nexport {\n StartMenu,\n type StartMenuItem,\n type StartMenuProps,\n} from \"./menu/StartMenu\";\nexport {\n type ContextMenuState,\n useContextMenuPositionState,\n useContextMenuState,\n} from \"./menu/useContextMenuState\";\nexport { useLongPress } from \"./menu/useLongPress\";\nexport { RoutedPane, type RoutedPaneProps } from \"./routed/RoutedPane\";\nexport {\n RoutedPaneOverlayHostProvider,\n type RoutedPaneOverlayHostValue,\n useRoutedPaneOverlayHost,\n} from \"./routed/RoutedPaneOverlayHost\";\nexport type { SubscribeKeyboardVisibility } from \"./routed/useMobileKeyboardVisible\";\nexport { LaserScreensaver } from \"./screensaver/LaserScreensaver\";\nexport {\n type ScreensaverControls,\n ScreensaverProvider,\n type ScreensaverProviderProps,\n useOptionalScreensaver,\n useScreensaver,\n} from \"./screensaver/ScreensaverProvider\";\nexport type { ScreensaverPinVerifier } from \"./screensaver/screensaverPinVerifier\";\nexport { SidebarResizeHandle, useSidebarResize } from \"./sidebar/SidebarResize\";\nexport {\n ThemeProvider,\n useOptionalTheme,\n useTheme,\n} from \"./theme/ThemeProvider\";\nexport { ThemeSwitch } from \"./theme/ThemeSwitch\";\nexport type {\n DefaultTheme,\n ThemeDefinition,\n ThemeScheme,\n} from \"./theme/themes\";\nexport { SystemTray, type SystemTrayMenuItem } from \"./tray/SystemTray\";\nexport {\n SystemTrayProvider,\n useOptionalSystemTray,\n useSystemTray,\n} from \"./tray/SystemTrayProvider\";\nexport type {\n SystemTrayDefinition,\n TrayAppDefinition,\n} from \"./tray/systemTrayDefinition\";\nexport {\n DesktopWallpaper,\n type DesktopWallpaperProps,\n} from \"./wallpaper/DesktopWallpaper\";\nexport {\n BLOCKS_WALLPAPER,\n CHEVRON_WALLPAPER,\n HARLEQUIN_WALLPAPER,\n HONEYCOMB_WALLPAPER,\n PLAIN_WALLPAPER,\n TRIANGLES_WALLPAPER,\n} from \"./wallpaper/tessellations\";\nexport {\n useOptionalWallpaper,\n useWallpaper,\n WallpaperProvider,\n} from \"./wallpaper/WallpaperProvider\";\nexport type {\n WallpaperDefinition,\n WallpaperTile,\n} from \"./wallpaper/wallpapers\";\nexport {\n CurrentWindowProvider,\n useCurrentWindow,\n useSuppressWindowToolbar,\n useWindowBackground,\n useWindowContentSize,\n} from \"./window/CurrentWindowContext\";\nexport { Window, type WindowContentBoundary } from \"./window/Window\";\nexport { WindowTitleBarActionButtons } from \"./window/WindowChromeActions\";\nexport { WindowCloseButton } from \"./window/WindowCloseButton\";\nexport {\n useWindowBackAction,\n useWindowBackActionValue,\n useWindowFileMenuItem,\n useWindowRefreshMenuItem,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarAction,\n useWindowTitleBarActions,\n useWindowToolbarReservation,\n useWindowViewMenuItem,\n WindowMenuProvider,\n} from \"./window/WindowMenuContext\";\nexport {\n hasWindowSidebar,\n useRegisteredWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"./window/WindowSidebarContext\";\nexport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowCreateOptions,\n type WindowEntry,\n type WindowGeometry,\n type WindowPosition,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n WindowStateProvider,\n} from \"./window/WindowStateProvider\";\nexport { WindowToolBar } from \"./window/WindowToolBar\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,sEAAsE;AACtE,6BAA6B;AAC7B,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAG9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAEL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEh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EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAQlB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import \"./tokens.css\";\n\n// The public windowing API: window state, window chrome and its registration\n// hooks, the menu and sidebar primitives the chrome renders with, a taskbar's\n// start menu, theme switch, and system tray, the icons the chrome draws, a\n// launcher of mini-apps that shows them in windows or in the routed (iPad /\n// phone) shell, and desktop icons that open them, with a storage adapter for\n// their layout, over a wallpaper chosen in Display Properties, plus a\n// host-supplied screensaver.\nexport {\n createRequiredContext,\n type RequiredContext,\n} from \"./createRequiredContext\";\nexport type { DesktopIconMenuItem } from \"./desktop/DesktopIconMenu\";\nexport {\n DesktopIcons,\n type DesktopIconsProps,\n} from \"./desktop/DesktopIcons\";\nexport type {\n DesktopIconPosition,\n DesktopState,\n} from \"./desktop/desktopState\";\nexport {\n createMemoryDesktopStateStorage,\n createOpfsDesktopStateStorage,\n type DesktopStateStorage,\n type OpfsDesktopStateStorageOptions,\n} from \"./desktop/desktopStateStorage\";\nexport { DisplayProperties } from \"./display/DisplayProperties\";\nexport {\n type WindowingIcons,\n WindowingIconsProvider,\n} from \"./icons/WindowingIcons\";\nexport type { WindowingIcon, WindowingIconProps } from \"./icons/windowingIcon\";\nexport {\n ROUTED_TABLET_BREAKPOINT_PX,\n ROUTED_TABLET_QUERY,\n WINDOWED_LAYOUT_MIN_WIDTH_PX,\n} from \"./launcher/breakpoints\";\nexport { LauncherMenuItem } from \"./launcher/LauncherMenuItem\";\nexport {\n type LauncherNavigationActions,\n LauncherNavigationProvider,\n type LauncherNavigationState,\n useLauncherNavigationActions,\n useLauncherNavigationState,\n useMiniAppRouteSegments,\n useOptionalLauncherNavigationState,\n} from \"./launcher/LauncherNavigationProvider\";\nexport {\n isLauncherAppId,\n type LauncherDefinition,\n type MiniAppDefinition,\n resolveLauncherHomeAppId,\n resolveLauncherOrder,\n} from \"./launcher/launcherDefinition\";\nexport {\n MiniAppRouteSegmentsProvider,\n useMiniAppWindowRouteSegments,\n} from \"./launcher/MiniAppRouteSegmentsContext\";\nexport { type MiniAppBoundary, MiniAppWindow } from \"./launcher/MiniAppWindow\";\nexport {\n NavigationModeOverrideProvider,\n useNavigationModeOverride,\n useOptionalNavigationModeOverride,\n} from \"./launcher/NavigationModeOverrideProvider\";\nexport { NavigationModeSwitch } from \"./launcher/NavigationModeSwitch\";\nexport {\n isWindowedLayoutEligible,\n type NavigationEnvironment,\n type NavigationMode,\n readNavigationEnvironment,\n resolveNavigationMode,\n} from \"./launcher/navigationMode\";\nexport {\n DEFAULT_MINI_APP_POSITION,\n type MiniAppWindowPlacement,\n type OpenMiniAppRequest,\n type PlaceMiniAppWindow,\n} from \"./launcher/openMiniAppWindow\";\nexport {\n buildMiniAppPath,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./launcher/routePaths\";\nexport {\n resolveActiveLauncherRoute,\n useActiveLauncherRoute,\n} from \"./launcher/useActiveLauncherRoute\";\nexport { useCompactRoutedMode } from \"./launcher/useCompactRoutedMode\";\nexport {\n type MiniAppRouteSetOptions,\n useMiniAppRouteState,\n} from \"./launcher/useMiniAppRouteState\";\nexport { useNavigationMode } from \"./launcher/useNavigationMode\";\nexport { useNavigationModeDocumentAttribute } from \"./launcher/useNavigationModeDocumentAttribute\";\nexport {\n useRoutedLayoutActive,\n useWindowedLayoutActive,\n} from \"./launcher/useRoutedLayoutActive\";\nexport {\n type RoutedLayoutTier,\n useRoutedLayoutTier,\n} from \"./launcher/useRoutedLayoutTier\";\nexport { Menu, type MenuPosition } from \"./menu/Menu\";\nexport { MenuItem, type MenuItemProps } from \"./menu/MenuItem\";\nexport {\n StartMenu,\n type StartMenuItem,\n type StartMenuProps,\n} from \"./menu/StartMenu\";\nexport {\n type ContextMenuState,\n useContextMenuPositionState,\n useContextMenuState,\n} from \"./menu/useContextMenuState\";\nexport { useLongPress } from \"./menu/useLongPress\";\nexport { RoutedPane, type RoutedPaneProps } from \"./routed/RoutedPane\";\nexport {\n RoutedPaneOverlayHostProvider,\n type RoutedPaneOverlayHostValue,\n useRoutedPaneOverlayHost,\n} from \"./routed/RoutedPaneOverlayHost\";\nexport type { SubscribeKeyboardVisibility } from \"./routed/useMobileKeyboardVisible\";\nexport { LaserScreensaver } from \"./screensaver/LaserScreensaver\";\nexport {\n type ScreensaverControls,\n ScreensaverProvider,\n type ScreensaverProviderProps,\n useOptionalScreensaver,\n useScreensaver,\n} from \"./screensaver/ScreensaverProvider\";\nexport type { ScreensaverPinVerifier } from \"./screensaver/screensaverPinVerifier\";\nexport { SidebarResizeHandle, useSidebarResize } from \"./sidebar/SidebarResize\";\nexport {\n ThemeProvider,\n useOptionalTheme,\n useTheme,\n} from \"./theme/ThemeProvider\";\nexport { ThemeSwitch } from \"./theme/ThemeSwitch\";\nexport type {\n DefaultTheme,\n ThemeDefinition,\n ThemeScheme,\n} from \"./theme/themes\";\nexport { SystemTray, type SystemTrayMenuItem } from \"./tray/SystemTray\";\nexport {\n SystemTrayProvider,\n useOptionalSystemTray,\n useSystemTray,\n} from \"./tray/SystemTrayProvider\";\nexport type {\n SystemTrayDefinition,\n TrayAppDefinition,\n} from \"./tray/systemTrayDefinition\";\nexport {\n DesktopWallpaper,\n type DesktopWallpaperProps,\n} from \"./wallpaper/DesktopWallpaper\";\nexport {\n BLOCKS_WALLPAPER,\n CHEVRON_WALLPAPER,\n HARLEQUIN_WALLPAPER,\n HONEYCOMB_WALLPAPER,\n PLAIN_WALLPAPER,\n TRIANGLES_WALLPAPER,\n} from \"./wallpaper/tessellations\";\nexport {\n useOptionalWallpaper,\n useWallpaper,\n WallpaperProvider,\n} from \"./wallpaper/WallpaperProvider\";\nexport type {\n WallpaperDefinition,\n WallpaperTile,\n} from \"./wallpaper/wallpapers\";\nexport {\n CurrentWindowProvider,\n useCurrentWindow,\n useSuppressWindowToolbar,\n useWindowBackground,\n useWindowContentSize,\n} from \"./window/CurrentWindowContext\";\nexport { Window, type WindowContentBoundary } from \"./window/Window\";\nexport { WindowTitleBarActionButtons } from \"./window/WindowChromeActions\";\nexport { WindowCloseButton } from \"./window/WindowCloseButton\";\nexport {\n useWindowBackAction,\n useWindowBackActionValue,\n useWindowFileMenuItem,\n useWindowRefreshMenuItem,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarAction,\n useWindowTitleBarActions,\n useWindowToolbarReservation,\n useWindowViewMenuItem,\n WindowMenuProvider,\n} from \"./window/WindowMenuContext\";\nexport {\n hasWindowSidebar,\n useRegisteredWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"./window/WindowSidebarContext\";\nexport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowCreateOptions,\n type WindowEntry,\n type WindowGeometry,\n type WindowPosition,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n WindowStateProvider,\n} from \"./window/WindowStateProvider\";\nexport { WindowToolBar } from \"./window/WindowToolBar\";\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MenuItem } from "../menu/MenuItem.js";
|
|
3
|
+
import { useLauncherEntryMenu } from "./useLauncherEntryMenu.js";
|
|
4
|
+
export function LauncherMenuItem({ icon, label, onClick, }) {
|
|
5
|
+
const { menu, triggerProps } = useLauncherEntryMenu(icon, onClick);
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsx(MenuItem, { ...triggerProps, icon: icon, label: label, onClick: onClick }), menu] }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=LauncherMenuItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LauncherMenuItem.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/LauncherMenuItem.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,UAAU,gBAAgB,CAAC,EAC/B,IAAI,EACJ,KAAK,EACL,OAAO,GAKR;IACC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnE,OAAO,CACL,8BACE,KAAC,QAAQ,OAAK,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,EACzE,IAAI,IACJ,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { MenuItem } from \"../menu/MenuItem\";\nimport { useLauncherEntryMenu } from \"./useLauncherEntryMenu\";\n\nexport function LauncherMenuItem({\n icon,\n label,\n onClick,\n}: {\n icon?: WindowingIcon | undefined;\n label: string;\n onClick: () => void;\n}) {\n const { menu, triggerProps } = useLauncherEntryMenu(icon, onClick);\n return (\n <>\n <MenuItem {...triggerProps} icon={icon} label={label} onClick={onClick} />\n {menu}\n </>\n );\n}\n"]}
|
|
@@ -34,14 +34,20 @@ interface LauncherNavigationProviderProps extends PropsWithChildren {
|
|
|
34
34
|
* positions or sizes. Read when a window opens.
|
|
35
35
|
*/
|
|
36
36
|
placeWindow?: PlaceMiniAppWindow | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Whether windowed mode opens the app the browser's URL names. Defaults to
|
|
39
|
+
* true; a host with several launchers on one page enables it for one.
|
|
40
|
+
*/
|
|
41
|
+
routeWindowEnabled?: boolean | undefined;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,
|
|
40
45
|
* opening an app opens or raises its window (inside a
|
|
41
|
-
* {@link WindowStateProvider})
|
|
42
|
-
*
|
|
46
|
+
* {@link WindowStateProvider}), and entering the mode opens the app the
|
|
47
|
+
* browser's URL names; in `routed` mode it navigates the browser to the app's
|
|
48
|
+
* route, `/app/<app id>/…`, which the routed shell shows.
|
|
43
49
|
*/
|
|
44
|
-
export declare function LauncherNavigationProvider({ children, defaultWindowEnabled, definition, mode, placeWindow, }: LauncherNavigationProviderProps): import("react").JSX.Element;
|
|
50
|
+
export declare function LauncherNavigationProvider({ children, defaultWindowEnabled, definition, mode, placeWindow, routeWindowEnabled, }: LauncherNavigationProviderProps): import("react").JSX.Element;
|
|
45
51
|
export declare const useLauncherNavigationActions: () => LauncherNavigationActions<string>;
|
|
46
52
|
export declare const useLauncherNavigationState: () => LauncherNavigationState<string>;
|
|
47
53
|
export declare const useOptionalLauncherNavigationState: () => LauncherNavigationState<string> | null;
|
|
@@ -7,7 +7,7 @@ import { DEFAULT_NAVIGATION_HISTORY_CURSOR, getNavigationHistoryAvailability, re
|
|
|
7
7
|
import { openMiniAppWindow, } from "./openMiniAppWindow.js";
|
|
8
8
|
import { replaceWindowHistoryCursor, useRoutedPathNavigator, } from "./routedPathNavigator.js";
|
|
9
9
|
import { buildMiniAppPath, LAUNCHER_HOME_PATH, parseLauncherRoute, } from "./routePaths.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useWindowedEntryWindows } from "./useWindowedEntryWindows.js";
|
|
11
11
|
const launcherNavigationActionsContext = createRequiredContext("useLauncherNavigationActions requires LauncherNavigationProvider.");
|
|
12
12
|
const launcherNavigationStateContext = createRequiredContext("useLauncherNavigationState requires LauncherNavigationProvider.");
|
|
13
13
|
const EMPTY_ROUTE_SEGMENTS = [];
|
|
@@ -25,7 +25,7 @@ function ensureWindowHistoryCursor() {
|
|
|
25
25
|
}
|
|
26
26
|
return cursor;
|
|
27
27
|
}
|
|
28
|
-
function LauncherNavigationWindowRuntimeBridge({ defaultWindowEnabled, definition, mode, openMiniApp, placeWindow, runtimeRef, }) {
|
|
28
|
+
function LauncherNavigationWindowRuntimeBridge({ defaultWindowEnabled, definition, mode, openMiniApp, placeWindow, routeWindowEnabled, runtimeRef, }) {
|
|
29
29
|
const { bringToFront, create, restore, updateRoute } = useWindowActions();
|
|
30
30
|
const { windows } = useWindowStateData();
|
|
31
31
|
useEffect(() => {
|
|
@@ -47,11 +47,12 @@ function LauncherNavigationWindowRuntimeBridge({ defaultWindowEnabled, definitio
|
|
|
47
47
|
updateRoute,
|
|
48
48
|
windows,
|
|
49
49
|
]);
|
|
50
|
-
|
|
50
|
+
useWindowedEntryWindows({
|
|
51
|
+
defaultWindowEnabled,
|
|
51
52
|
definition,
|
|
52
|
-
enabled: defaultWindowEnabled,
|
|
53
53
|
mode,
|
|
54
54
|
openMiniApp,
|
|
55
|
+
routeWindowEnabled,
|
|
55
56
|
windowCount: windows.length,
|
|
56
57
|
});
|
|
57
58
|
return null;
|
|
@@ -163,10 +164,11 @@ function useLauncherNavigationActionValue(runtimeRef, goBack, goForward, navigat
|
|
|
163
164
|
/**
|
|
164
165
|
* Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,
|
|
165
166
|
* opening an app opens or raises its window (inside a
|
|
166
|
-
* {@link WindowStateProvider})
|
|
167
|
-
*
|
|
167
|
+
* {@link WindowStateProvider}), and entering the mode opens the app the
|
|
168
|
+
* browser's URL names; in `routed` mode it navigates the browser to the app's
|
|
169
|
+
* route, `/app/<app id>/…`, which the routed shell shows.
|
|
168
170
|
*/
|
|
169
|
-
export function LauncherNavigationProvider({ children, defaultWindowEnabled = true, definition, mode, placeWindow, }) {
|
|
171
|
+
export function LauncherNavigationProvider({ children, defaultWindowEnabled = true, definition, mode, placeWindow, routeWindowEnabled = true, }) {
|
|
170
172
|
const runtimeRef = useRef({
|
|
171
173
|
actions: {
|
|
172
174
|
bringToFront: () => { },
|
|
@@ -186,7 +188,7 @@ export function LauncherNavigationProvider({ children, defaultWindowEnabled = tr
|
|
|
186
188
|
});
|
|
187
189
|
const actions = useLauncherNavigationActionValue(runtimeRef, goBack, goForward, navigateHome, navigateMiniAppRoute);
|
|
188
190
|
const state = useMemo(() => ({ definition, history, mode, route }), [definition, history, mode, route]);
|
|
189
|
-
return (_jsx(launcherNavigationActionsContext.context.Provider, { value: actions, children: _jsxs(launcherNavigationStateContext.context.Provider, { value: state, children: [_jsx(LauncherNavigationWindowRuntimeBridge, { defaultWindowEnabled: defaultWindowEnabled, definition: definition, mode: mode, openMiniApp: actions.openMiniApp, placeWindow: placeWindow, runtimeRef: runtimeRef }), children] }) }));
|
|
191
|
+
return (_jsx(launcherNavigationActionsContext.context.Provider, { value: actions, children: _jsxs(launcherNavigationStateContext.context.Provider, { value: state, children: [_jsx(LauncherNavigationWindowRuntimeBridge, { defaultWindowEnabled: defaultWindowEnabled, definition: definition, mode: mode, openMiniApp: actions.openMiniApp, placeWindow: placeWindow, routeWindowEnabled: routeWindowEnabled, runtimeRef: runtimeRef }), children] }) }));
|
|
190
192
|
}
|
|
191
193
|
// The context names apps by their string ids. The actions accept a host's own
|
|
192
194
|
// narrower id type as they are; a host narrows the route's id with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LauncherNavigationProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/LauncherNavigationProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE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,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,YAAY,EAAE,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM;QACN,QAAQ;QACR,YAAY;QACZ,eAAe;KAChB,CAAC,EACF,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n useWindowActions,\n useWindowStateData,\n type WindowStateActions,\n type WindowStateData,\n} from \"../window/WindowStateProvider\";\nimport type { LauncherDefinition } from \"./launcherDefinition\";\nimport { useMiniAppWindowRouteSegments } from \"./MiniAppRouteSegmentsContext\";\nimport {\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n getNavigationHistoryAvailability,\n type NavigationHistoryAvailability,\n type NavigationHistoryCursor,\n readNavigationHistoryCursor,\n} from \"./navigationHistory\";\nimport type { NavigationMode } from \"./navigationMode\";\nimport {\n type OpenMiniAppRequest,\n openMiniAppWindow,\n type PlaceMiniAppWindow,\n} from \"./openMiniAppWindow\";\nimport {\n replaceWindowHistoryCursor,\n useRoutedPathNavigator,\n} from \"./routedPathNavigator\";\nimport {\n buildMiniAppPath,\n LAUNCHER_HOME_PATH,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./routePaths\";\nimport { useDefaultWindow } from \"./useDefaultWindow\";\n\nexport interface LauncherNavigationActions<AppId extends string = string> {\n getMiniAppHref: (\n appId: AppId,\n pathSegments?: ReadonlyArray<string> | undefined,\n ) => string;\n goBack: () => void;\n goForward: () => void;\n navigateMiniAppRoute: (input: {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => void;\n navigateHome: (input?: { replace?: boolean | undefined }) => void;\n // Returns the window the app opened in or was raised to, or null when the\n // routed shell shows it instead.\n openMiniApp: (request: OpenMiniAppRequest<AppId>) => string | null;\n}\n\nexport interface LauncherNavigationState<AppId extends string = string> {\n definition: LauncherDefinition<AppId>;\n history: NavigationHistoryAvailability;\n mode: NavigationMode;\n route: LauncherRoute<AppId>;\n}\n\ninterface LauncherNavigationProviderProps extends PropsWithChildren {\n /** Defers the default windows while false, for example in a hidden workspace. */\n defaultWindowEnabled?: boolean | undefined;\n definition: LauncherDefinition;\n mode: NavigationMode;\n /**\n * Places each new window, for a host that opens its apps at their own\n * positions or sizes. Read when a window opens.\n */\n placeWindow?: PlaceMiniAppWindow | undefined;\n}\n\ninterface LauncherNavigationRuntime {\n actions: Pick<\n WindowStateActions,\n \"bringToFront\" | \"create\" | \"restore\" | \"updateRoute\"\n >;\n definition: LauncherDefinition;\n mode: NavigationMode;\n placeWindow: PlaceMiniAppWindow | undefined;\n windows: WindowStateData[\"windows\"];\n}\n\nconst launcherNavigationActionsContext =\n createRequiredContext<LauncherNavigationActions>(\n \"useLauncherNavigationActions requires LauncherNavigationProvider.\",\n );\nconst launcherNavigationStateContext =\n createRequiredContext<LauncherNavigationState>(\n \"useLauncherNavigationState requires LauncherNavigationProvider.\",\n );\nconst EMPTY_ROUTE_SEGMENTS: ReadonlyArray<string> = [];\n\nfunction readCurrentRoute(definition: LauncherDefinition): LauncherRoute {\n return parseLauncherRoute(window.location.pathname, definition);\n}\n\nfunction readWindowHistoryCursor(): NavigationHistoryCursor {\n return (\n readNavigationHistoryCursor(window.history.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR\n );\n}\n\nfunction ensureWindowHistoryCursor(): NavigationHistoryCursor {\n const cursor = readWindowHistoryCursor();\n if (readNavigationHistoryCursor(window.history.state) === null) {\n replaceWindowHistoryCursor(cursor);\n }\n\n return cursor;\n}\n\nfunction LauncherNavigationWindowRuntimeBridge({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n placeWindow,\n runtimeRef,\n}: {\n defaultWindowEnabled: boolean;\n definition: LauncherDefinition;\n mode: NavigationMode;\n openMiniApp: LauncherNavigationActions[\"openMiniApp\"];\n placeWindow: PlaceMiniAppWindow | undefined;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const { bringToFront, create, restore, updateRoute } = useWindowActions();\n const { windows } = useWindowStateData();\n\n useEffect(() => {\n runtimeRef.current = {\n actions: { bringToFront, create, restore, updateRoute },\n definition,\n mode,\n placeWindow,\n windows,\n };\n }, [\n bringToFront,\n create,\n definition,\n mode,\n placeWindow,\n restore,\n runtimeRef,\n updateRoute,\n windows,\n ]);\n\n useDefaultWindow({\n definition,\n enabled: defaultWindowEnabled,\n mode,\n openMiniApp,\n windowCount: windows.length,\n });\n\n return null;\n}\n\nfunction useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n}: {\n definition: LauncherDefinition;\n mode: NavigationMode;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const [route, setRoute] = useState<LauncherRoute>(() =>\n readCurrentRoute(definition),\n );\n const [historyCursor, setHistoryCursorState] =\n useState<NavigationHistoryCursor>(readWindowHistoryCursor);\n const historyCursorRef = useRef(historyCursor);\n const setHistoryCursor = useCallback((cursor: NavigationHistoryCursor) => {\n historyCursorRef.current = cursor;\n setHistoryCursorState(cursor);\n }, []);\n const navigateRoutedPath = useRoutedPathNavigator({\n historyCursorRef,\n runtimeRef,\n setHistoryCursor,\n setRoute,\n });\n\n useEffect(() => {\n if (mode !== \"routed\") {\n return;\n }\n\n const handlePopState = (event: PopStateEvent) => {\n setHistoryCursor(\n readNavigationHistoryCursor(event.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n );\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n };\n\n setHistoryCursor(ensureWindowHistoryCursor());\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n window.addEventListener(\"popstate\", handlePopState);\n return () => window.removeEventListener(\"popstate\", handlePopState);\n }, [mode, runtimeRef, setHistoryCursor]);\n\n const navigateMiniAppRoute = useCallback(\n ({\n appId,\n pathSegments = [],\n replace = false,\n }: {\n appId: string;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => {\n navigateRoutedPath({\n path: buildMiniAppPath(appId, pathSegments),\n replace,\n route: { appId, pathSegments: [...pathSegments] },\n });\n },\n [navigateRoutedPath],\n );\n const navigateHome = useCallback(\n ({ replace = false }: { replace?: boolean | undefined } = {}) => {\n navigateRoutedPath({\n path: LAUNCHER_HOME_PATH,\n replace,\n route: { appId: null, pathSegments: [] },\n });\n },\n [navigateRoutedPath],\n );\n\n const goBack = useCallback(() => {\n if (historyCursorRef.current.index > 0) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: historyCursorRef.current.index - 1,\n });\n window.history.back();\n }\n }, [setHistoryCursor]);\n const goForward = useCallback(() => {\n const { entries, index } = historyCursorRef.current;\n if (index < entries - 1) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: index + 1,\n });\n window.history.forward();\n }\n }, [setHistoryCursor]);\n const history = useMemo(\n () => getNavigationHistoryAvailability(historyCursor),\n [historyCursor],\n );\n\n return {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n };\n}\n\nfunction useLauncherNavigationActionValue(\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>,\n goBack: LauncherNavigationActions[\"goBack\"],\n goForward: LauncherNavigationActions[\"goForward\"],\n navigateHome: LauncherNavigationActions[\"navigateHome\"],\n navigateMiniAppRoute: LauncherNavigationActions[\"navigateMiniAppRoute\"],\n): LauncherNavigationActions {\n const openMiniApp = useCallback(\n (request: OpenMiniAppRequest) => {\n const { actions, definition, mode, placeWindow, windows } =\n runtimeRef.current;\n if (mode === \"routed\") {\n const { appId, pathSegments } = request;\n navigateMiniAppRoute({ appId, pathSegments });\n return null;\n }\n return openMiniAppWindow({\n actions,\n definition,\n placeWindow,\n request,\n windows,\n });\n },\n [navigateMiniAppRoute, runtimeRef],\n );\n const getMiniAppHref = useCallback(buildMiniAppPath, []);\n return useMemo<LauncherNavigationActions>(\n () => ({\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n }),\n [\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n ],\n );\n}\n\n/**\n * Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,\n * opening an app opens or raises its window (inside a\n * {@link WindowStateProvider}); in `routed` mode it navigates the browser to\n * the app's route, `/app/<app id>/…`, which the routed shell shows.\n */\nexport function LauncherNavigationProvider({\n children,\n defaultWindowEnabled = true,\n definition,\n mode,\n placeWindow,\n}: LauncherNavigationProviderProps) {\n const runtimeRef = useRef<LauncherNavigationRuntime>({\n actions: {\n bringToFront: () => {},\n create: () => \"\",\n restore: () => {},\n updateRoute: () => {},\n },\n definition,\n mode,\n placeWindow,\n windows: [],\n });\n const {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n } = useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n });\n const actions = useLauncherNavigationActionValue(\n runtimeRef,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n );\n const state = useMemo<LauncherNavigationState>(\n () => ({ definition, history, mode, route }),\n [definition, history, mode, route],\n );\n\n return (\n <launcherNavigationActionsContext.context.Provider value={actions}>\n <launcherNavigationStateContext.context.Provider value={state}>\n <LauncherNavigationWindowRuntimeBridge\n defaultWindowEnabled={defaultWindowEnabled}\n definition={definition}\n mode={mode}\n openMiniApp={actions.openMiniApp}\n placeWindow={placeWindow}\n runtimeRef={runtimeRef}\n />\n {children}\n </launcherNavigationStateContext.context.Provider>\n </launcherNavigationActionsContext.context.Provider>\n );\n}\n\n// The context names apps by their string ids. The actions accept a host's own\n// narrower id type as they are; a host narrows the route's id with\n// isLauncherAppId (or its own guard) to read it back as that type.\nexport const useLauncherNavigationActions =\n launcherNavigationActionsContext.useRequired;\n\nexport const useLauncherNavigationState =\n launcherNavigationStateContext.useRequired;\n\nexport const useOptionalLauncherNavigationState =\n launcherNavigationStateContext.useOptional;\n\n/**\n * The route of `appId` where it is hosted: the browser route in the routed\n * shell, or its window's own route and Back stack in a window. Mini-apps read\n * this rather than branching on navigation mode.\n */\nexport function useMiniAppRouteSegments(appId: string) {\n const actions = launcherNavigationActionsContext.useOptional();\n const state = launcherNavigationStateContext.useOptional();\n const windowRoute = useMiniAppWindowRouteSegments(appId);\n const isGlobalRouted = actions !== null && state?.mode === \"routed\";\n const isRouted = isGlobalRouted || windowRoute !== null;\n const pathSegments =\n isGlobalRouted && state.route.appId === appId\n ? state.route.pathSegments\n : (windowRoute?.pathSegments ?? EMPTY_ROUTE_SEGMENTS);\n const windowSetPathSegments = windowRoute?.setPathSegments;\n const setPathSegments = useCallback(\n (\n nextPathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n if (isGlobalRouted) {\n actions?.navigateMiniAppRoute({\n appId,\n pathSegments: nextPathSegments,\n ...(options.replace === undefined\n ? {}\n : { replace: options.replace }),\n });\n return;\n }\n\n windowSetPathSegments?.(nextPathSegments, options);\n },\n [actions, appId, isGlobalRouted, windowSetPathSegments],\n );\n // \"Can this mini-app step back where it is hosted?\" — browser history in the\n // routed shell, the window's own Back stack in a window. Mini-apps read this\n // rather than branching on navigation mode, so a detail surface that must\n // yield to a real Back affordance asks one question and gets the right answer\n // in both shells.\n const windowGoBack = windowRoute?.goBack;\n const canGoBack = isGlobalRouted\n ? state.history.canGoBack\n : (windowRoute?.canGoBack ?? false);\n const goBack = useCallback(() => {\n if (isGlobalRouted) {\n actions?.goBack();\n return;\n }\n\n windowGoBack?.();\n }, [actions, isGlobalRouted, windowGoBack]);\n\n return useMemo(\n () => ({\n canGoBack,\n goBack,\n isRouted,\n pathSegments,\n setPathSegments,\n }),\n [canGoBack, goBack, isRouted, pathSegments, setPathSegments],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LauncherNavigationProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/LauncherNavigationProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GAGnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAGhC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAElB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAuDpE,MAAM,gCAAgC,GACpC,qBAAqB,CACnB,mEAAmE,CACpE,CAAC;AACJ,MAAM,8BAA8B,GAClC,qBAAqB,CACnB,iEAAiE,CAClE,CAAC;AACJ,MAAM,oBAAoB,GAA0B,EAAE,CAAC;AAEvD,SAAS,gBAAgB,CAAC,UAA8B;IACtD,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAClE,CA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,OAAO,KAAK,SAAS;oBAC/B,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;aAClC,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,qBAAqB,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC,EACD,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,CAAC,CACxD,CAAC;IACF,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,8EAA8E;IAC9E,kBAAkB;IAClB,MAAM,YAAY,GAAG,WAAW,EAAE,MAAM,CAAC;IACzC,MAAM,SAAS,GAAG,cAAc;QAC9B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS;QACzB,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,YAAY,EAAE,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM;QACN,QAAQ;QACR,YAAY;QACZ,eAAe;KAChB,CAAC,EACF,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n useWindowActions,\n useWindowStateData,\n type WindowStateActions,\n type WindowStateData,\n} from \"../window/WindowStateProvider\";\nimport type { LauncherDefinition } from \"./launcherDefinition\";\nimport { useMiniAppWindowRouteSegments } from \"./MiniAppRouteSegmentsContext\";\nimport {\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n getNavigationHistoryAvailability,\n type NavigationHistoryAvailability,\n type NavigationHistoryCursor,\n readNavigationHistoryCursor,\n} from \"./navigationHistory\";\nimport type { NavigationMode } from \"./navigationMode\";\nimport {\n type OpenMiniAppRequest,\n openMiniAppWindow,\n type PlaceMiniAppWindow,\n} from \"./openMiniAppWindow\";\nimport {\n replaceWindowHistoryCursor,\n useRoutedPathNavigator,\n} from \"./routedPathNavigator\";\nimport {\n buildMiniAppPath,\n LAUNCHER_HOME_PATH,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./routePaths\";\nimport { useWindowedEntryWindows } from \"./useWindowedEntryWindows\";\n\nexport interface LauncherNavigationActions<AppId extends string = string> {\n getMiniAppHref: (\n appId: AppId,\n pathSegments?: ReadonlyArray<string> | undefined,\n ) => string;\n goBack: () => void;\n goForward: () => void;\n navigateMiniAppRoute: (input: {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => void;\n navigateHome: (input?: { replace?: boolean | undefined }) => void;\n // Returns the window the app opened in or was raised to, or null when the\n // routed shell shows it instead.\n openMiniApp: (request: OpenMiniAppRequest<AppId>) => string | null;\n}\n\nexport interface LauncherNavigationState<AppId extends string = string> {\n definition: LauncherDefinition<AppId>;\n history: NavigationHistoryAvailability;\n mode: NavigationMode;\n route: LauncherRoute<AppId>;\n}\n\ninterface LauncherNavigationProviderProps extends PropsWithChildren {\n /** Defers the default windows while false, for example in a hidden workspace. */\n defaultWindowEnabled?: boolean | undefined;\n definition: LauncherDefinition;\n mode: NavigationMode;\n /**\n * Places each new window, for a host that opens its apps at their own\n * positions or sizes. Read when a window opens.\n */\n placeWindow?: PlaceMiniAppWindow | undefined;\n /**\n * Whether windowed mode opens the app the browser's URL names. Defaults to\n * true; a host with several launchers on one page enables it for one.\n */\n routeWindowEnabled?: boolean | undefined;\n}\n\ninterface LauncherNavigationRuntime {\n actions: Pick<\n WindowStateActions,\n \"bringToFront\" | \"create\" | \"restore\" | \"updateRoute\"\n >;\n definition: LauncherDefinition;\n mode: NavigationMode;\n placeWindow: PlaceMiniAppWindow | undefined;\n windows: WindowStateData[\"windows\"];\n}\n\nconst launcherNavigationActionsContext =\n createRequiredContext<LauncherNavigationActions>(\n \"useLauncherNavigationActions requires LauncherNavigationProvider.\",\n );\nconst launcherNavigationStateContext =\n createRequiredContext<LauncherNavigationState>(\n \"useLauncherNavigationState requires LauncherNavigationProvider.\",\n );\nconst EMPTY_ROUTE_SEGMENTS: ReadonlyArray<string> = [];\n\nfunction readCurrentRoute(definition: LauncherDefinition): LauncherRoute {\n return parseLauncherRoute(window.location.pathname, definition);\n}\n\nfunction readWindowHistoryCursor(): NavigationHistoryCursor {\n return (\n readNavigationHistoryCursor(window.history.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR\n );\n}\n\nfunction ensureWindowHistoryCursor(): NavigationHistoryCursor {\n const cursor = readWindowHistoryCursor();\n if (readNavigationHistoryCursor(window.history.state) === null) {\n replaceWindowHistoryCursor(cursor);\n }\n\n return cursor;\n}\n\nfunction LauncherNavigationWindowRuntimeBridge({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n placeWindow,\n routeWindowEnabled,\n runtimeRef,\n}: {\n defaultWindowEnabled: boolean;\n definition: LauncherDefinition;\n mode: NavigationMode;\n openMiniApp: LauncherNavigationActions[\"openMiniApp\"];\n placeWindow: PlaceMiniAppWindow | undefined;\n routeWindowEnabled: boolean;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const { bringToFront, create, restore, updateRoute } = useWindowActions();\n const { windows } = useWindowStateData();\n\n useEffect(() => {\n runtimeRef.current = {\n actions: { bringToFront, create, restore, updateRoute },\n definition,\n mode,\n placeWindow,\n windows,\n };\n }, [\n bringToFront,\n create,\n definition,\n mode,\n placeWindow,\n restore,\n runtimeRef,\n updateRoute,\n windows,\n ]);\n\n useWindowedEntryWindows({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n routeWindowEnabled,\n windowCount: windows.length,\n });\n\n return null;\n}\n\nfunction useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n}: {\n definition: LauncherDefinition;\n mode: NavigationMode;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const [route, setRoute] = useState<LauncherRoute>(() =>\n readCurrentRoute(definition),\n );\n const [historyCursor, setHistoryCursorState] =\n useState<NavigationHistoryCursor>(readWindowHistoryCursor);\n const historyCursorRef = useRef(historyCursor);\n const setHistoryCursor = useCallback((cursor: NavigationHistoryCursor) => {\n historyCursorRef.current = cursor;\n setHistoryCursorState(cursor);\n }, []);\n const navigateRoutedPath = useRoutedPathNavigator({\n historyCursorRef,\n runtimeRef,\n setHistoryCursor,\n setRoute,\n });\n\n useEffect(() => {\n if (mode !== \"routed\") {\n return;\n }\n\n const handlePopState = (event: PopStateEvent) => {\n setHistoryCursor(\n readNavigationHistoryCursor(event.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n );\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n };\n\n setHistoryCursor(ensureWindowHistoryCursor());\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n window.addEventListener(\"popstate\", handlePopState);\n return () => window.removeEventListener(\"popstate\", handlePopState);\n }, [mode, runtimeRef, setHistoryCursor]);\n\n const navigateMiniAppRoute = useCallback(\n ({\n appId,\n pathSegments = [],\n replace = false,\n }: {\n appId: string;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => {\n navigateRoutedPath({\n path: buildMiniAppPath(appId, pathSegments),\n replace,\n route: { appId, pathSegments: [...pathSegments] },\n });\n },\n [navigateRoutedPath],\n );\n const navigateHome = useCallback(\n ({ replace = false }: { replace?: boolean | undefined } = {}) => {\n navigateRoutedPath({\n path: LAUNCHER_HOME_PATH,\n replace,\n route: { appId: null, pathSegments: [] },\n });\n },\n [navigateRoutedPath],\n );\n\n const goBack = useCallback(() => {\n if (historyCursorRef.current.index > 0) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: historyCursorRef.current.index - 1,\n });\n window.history.back();\n }\n }, [setHistoryCursor]);\n const goForward = useCallback(() => {\n const { entries, index } = historyCursorRef.current;\n if (index < entries - 1) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: index + 1,\n });\n window.history.forward();\n }\n }, [setHistoryCursor]);\n const history = useMemo(\n () => getNavigationHistoryAvailability(historyCursor),\n [historyCursor],\n );\n\n return {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n };\n}\n\nfunction useLauncherNavigationActionValue(\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>,\n goBack: LauncherNavigationActions[\"goBack\"],\n goForward: LauncherNavigationActions[\"goForward\"],\n navigateHome: LauncherNavigationActions[\"navigateHome\"],\n navigateMiniAppRoute: LauncherNavigationActions[\"navigateMiniAppRoute\"],\n): LauncherNavigationActions {\n const openMiniApp = useCallback(\n (request: OpenMiniAppRequest) => {\n const { actions, definition, mode, placeWindow, windows } =\n runtimeRef.current;\n if (mode === \"routed\") {\n const { appId, pathSegments } = request;\n navigateMiniAppRoute({ appId, pathSegments });\n return null;\n }\n return openMiniAppWindow({\n actions,\n definition,\n placeWindow,\n request,\n windows,\n });\n },\n [navigateMiniAppRoute, runtimeRef],\n );\n const getMiniAppHref = useCallback(buildMiniAppPath, []);\n return useMemo<LauncherNavigationActions>(\n () => ({\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n }),\n [\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n ],\n );\n}\n\n/**\n * Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,\n * opening an app opens or raises its window (inside a\n * {@link WindowStateProvider}), and entering the mode opens the app the\n * browser's URL names; in `routed` mode it navigates the browser to the app's\n * route, `/app/<app id>/…`, which the routed shell shows.\n */\nexport function LauncherNavigationProvider({\n children,\n defaultWindowEnabled = true,\n definition,\n mode,\n placeWindow,\n routeWindowEnabled = true,\n}: LauncherNavigationProviderProps) {\n const runtimeRef = useRef<LauncherNavigationRuntime>({\n actions: {\n bringToFront: () => {},\n create: () => \"\",\n restore: () => {},\n updateRoute: () => {},\n },\n definition,\n mode,\n placeWindow,\n windows: [],\n });\n const {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n } = useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n });\n const actions = useLauncherNavigationActionValue(\n runtimeRef,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n );\n const state = useMemo<LauncherNavigationState>(\n () => ({ definition, history, mode, route }),\n [definition, history, mode, route],\n );\n\n return (\n <launcherNavigationActionsContext.context.Provider value={actions}>\n <launcherNavigationStateContext.context.Provider value={state}>\n <LauncherNavigationWindowRuntimeBridge\n defaultWindowEnabled={defaultWindowEnabled}\n definition={definition}\n mode={mode}\n openMiniApp={actions.openMiniApp}\n placeWindow={placeWindow}\n routeWindowEnabled={routeWindowEnabled}\n runtimeRef={runtimeRef}\n />\n {children}\n </launcherNavigationStateContext.context.Provider>\n </launcherNavigationActionsContext.context.Provider>\n );\n}\n\n// The context names apps by their string ids. The actions accept a host's own\n// narrower id type as they are; a host narrows the route's id with\n// isLauncherAppId (or its own guard) to read it back as that type.\nexport const useLauncherNavigationActions =\n launcherNavigationActionsContext.useRequired;\n\nexport const useLauncherNavigationState =\n launcherNavigationStateContext.useRequired;\n\nexport const useOptionalLauncherNavigationState =\n launcherNavigationStateContext.useOptional;\n\n/**\n * The route of `appId` where it is hosted: the browser route in the routed\n * shell, or its window's own route and Back stack in a window. Mini-apps read\n * this rather than branching on navigation mode.\n */\nexport function useMiniAppRouteSegments(appId: string) {\n const actions = launcherNavigationActionsContext.useOptional();\n const state = launcherNavigationStateContext.useOptional();\n const windowRoute = useMiniAppWindowRouteSegments(appId);\n const isGlobalRouted = actions !== null && state?.mode === \"routed\";\n const isRouted = isGlobalRouted || windowRoute !== null;\n const pathSegments =\n isGlobalRouted && state.route.appId === appId\n ? state.route.pathSegments\n : (windowRoute?.pathSegments ?? EMPTY_ROUTE_SEGMENTS);\n const windowSetPathSegments = windowRoute?.setPathSegments;\n const setPathSegments = useCallback(\n (\n nextPathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n if (isGlobalRouted) {\n actions?.navigateMiniAppRoute({\n appId,\n pathSegments: nextPathSegments,\n ...(options.replace === undefined\n ? {}\n : { replace: options.replace }),\n });\n return;\n }\n\n windowSetPathSegments?.(nextPathSegments, options);\n },\n [actions, appId, isGlobalRouted, windowSetPathSegments],\n );\n // \"Can this mini-app step back where it is hosted?\" — browser history in the\n // routed shell, the window's own Back stack in a window. Mini-apps read this\n // rather than branching on navigation mode, so a detail surface that must\n // yield to a real Back affordance asks one question and gets the right answer\n // in both shells.\n const windowGoBack = windowRoute?.goBack;\n const canGoBack = isGlobalRouted\n ? state.history.canGoBack\n : (windowRoute?.canGoBack ?? false);\n const goBack = useCallback(() => {\n if (isGlobalRouted) {\n actions?.goBack();\n return;\n }\n\n windowGoBack?.();\n }, [actions, isGlobalRouted, windowGoBack]);\n\n return useMemo(\n () => ({\n canGoBack,\n goBack,\n isRouted,\n pathSegments,\n setPathSegments,\n }),\n [canGoBack, goBack, isRouted, pathSegments, setPathSegments],\n );\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MouseEvent } from "react";
|
|
2
|
+
import type { WindowingIcon } from "../icons/windowingIcon.js";
|
|
3
|
+
/** Secondary activation offers the same Open action as the entry itself. */
|
|
4
|
+
export declare function useLauncherEntryMenu(icon: WindowingIcon | undefined, onOpen: () => void): {
|
|
5
|
+
triggerProps: {
|
|
6
|
+
onContextMenu(event: MouseEvent<HTMLElement>): void;
|
|
7
|
+
onPointerCancel: (event: import("react").PointerEvent<HTMLElement>) => void;
|
|
8
|
+
onPointerDown: (event: import("react").PointerEvent<HTMLElement>) => void;
|
|
9
|
+
onPointerMove: (event: import("react").PointerEvent<HTMLElement>) => void;
|
|
10
|
+
onPointerUp: (event: import("react").PointerEvent<HTMLElement>) => void;
|
|
11
|
+
};
|
|
12
|
+
menu: import("react").JSX.Element | null;
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DesktopIconMenu } from "../desktop/DesktopIconMenu.js";
|
|
3
|
+
import { useContextMenuState } from "../menu/useContextMenuState.js";
|
|
4
|
+
import { useLongPress } from "../menu/useLongPress.js";
|
|
5
|
+
/** Secondary activation offers the same Open action as the entry itself. */
|
|
6
|
+
export function useLauncherEntryMenu(icon, onOpen) {
|
|
7
|
+
const { closeContextMenu, contextMenu, openContextMenu } = useContextMenuState();
|
|
8
|
+
const longPress = useLongPress(true, { emulateRightClick: true });
|
|
9
|
+
return {
|
|
10
|
+
triggerProps: {
|
|
11
|
+
...longPress,
|
|
12
|
+
onContextMenu(event) {
|
|
13
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
14
|
+
openContextMenu(event, null);
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
menu: contextMenu && (_jsx(DesktopIconMenu, { icon: icon, items: [], onClose: closeContextMenu, onOpen: onOpen, position: contextMenu.position })),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=useLauncherEntryMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLauncherEntryMenu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/useLauncherEntryMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,4EAA4E;AAC5E,MAAM,UAAU,oBAAoB,CAClC,IAA+B,EAC/B,MAAkB;IAElB,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,GACtD,mBAAmB,EAAQ,CAAC;IAC9B,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,OAAO;QACL,YAAY,EAAE;YACZ,GAAG,SAAS;YACZ,aAAa,CAAC,KAA8B;gBAC1C,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;gBACnD,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC/B,CAAC;SACF;QACD,IAAI,EAAE,WAAW,IAAI,CACnB,KAAC,eAAe,IACd,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,WAAW,CAAC,QAAQ,GAC9B,CACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { MouseEvent } from \"react\";\nimport { DesktopIconMenu } from \"../desktop/DesktopIconMenu\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { useContextMenuState } from \"../menu/useContextMenuState\";\nimport { useLongPress } from \"../menu/useLongPress\";\n\n/** Secondary activation offers the same Open action as the entry itself. */\nexport function useLauncherEntryMenu(\n icon: WindowingIcon | undefined,\n onOpen: () => void,\n) {\n const { closeContextMenu, contextMenu, openContextMenu } =\n useContextMenuState<null>();\n const longPress = useLongPress(true, { emulateRightClick: true });\n return {\n triggerProps: {\n ...longPress,\n onContextMenu(event: MouseEvent<HTMLElement>) {\n event.currentTarget.focus({ preventScroll: true });\n openContextMenu(event, null);\n },\n },\n menu: contextMenu && (\n <DesktopIconMenu\n icon={icon}\n items={[]}\n onClose={closeContextMenu}\n onOpen={onOpen}\n position={contextMenu.position}\n />\n ),\n };\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type LauncherDefinition } from "./launcherDefinition.js";
|
|
2
|
+
import type { NavigationMode } from "./navigationMode.js";
|
|
3
|
+
import type { OpenMiniAppRequest } from "./openMiniAppWindow.js";
|
|
4
|
+
/**
|
|
5
|
+
* Opens the windows a windowed desktop starts with, once per entry into
|
|
6
|
+
* windowed mode: the host's default windows, in order, if the desktop is
|
|
7
|
+
* empty, and then the app the browser's URL names, in front. While windowed,
|
|
8
|
+
* a browser history step to another app's URL opens that app too.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useWindowedEntryWindows({ defaultWindowEnabled, definition, mode, openMiniApp, routeWindowEnabled, windowCount, }: {
|
|
11
|
+
defaultWindowEnabled: boolean;
|
|
12
|
+
definition: LauncherDefinition;
|
|
13
|
+
mode: NavigationMode;
|
|
14
|
+
openMiniApp: (request: OpenMiniAppRequest) => string | null;
|
|
15
|
+
routeWindowEnabled: boolean;
|
|
16
|
+
windowCount: number;
|
|
17
|
+
}): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { isLauncherAppId } from "./launcherDefinition.js";
|
|
3
|
+
import { parseLauncherRoute } from "./routePaths.js";
|
|
4
|
+
/** The request that opens the app the browser's URL names, if it names one. */
|
|
5
|
+
function readRouteWindowRequest(definition) {
|
|
6
|
+
const { appId, pathSegments } = parseLauncherRoute(window.location.pathname, definition);
|
|
7
|
+
if (appId === null)
|
|
8
|
+
return null;
|
|
9
|
+
// An app's root route names no place within it, so the app's open window
|
|
10
|
+
// is raised where it is.
|
|
11
|
+
return pathSegments.length > 0 ? { appId, pathSegments } : { appId };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The requests that open the host's default windows, each app once and
|
|
15
|
+
* without the URL's app, which opens after them: the launcher's open requests
|
|
16
|
+
* within one pass cannot see the windows the earlier ones created.
|
|
17
|
+
*/
|
|
18
|
+
function readDefaultWindowRequests(definition, routeRequest) {
|
|
19
|
+
return [...new Set(definition.defaultWindowAppIds)]
|
|
20
|
+
.filter((appId) => appId !== routeRequest?.appId && isLauncherAppId(definition, appId))
|
|
21
|
+
.map((appId) => ({ appId }));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Opens the windows a windowed desktop starts with, once per entry into
|
|
25
|
+
* windowed mode: the host's default windows, in order, if the desktop is
|
|
26
|
+
* empty, and then the app the browser's URL names, in front. While windowed,
|
|
27
|
+
* a browser history step to another app's URL opens that app too.
|
|
28
|
+
*/
|
|
29
|
+
export function useWindowedEntryWindows({ defaultWindowEnabled, definition, mode, openMiniApp, routeWindowEnabled, windowCount, }) {
|
|
30
|
+
const handledDefaultWindows = useRef(false);
|
|
31
|
+
const handledRouteWindow = useRef(false);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (mode !== "windowed") {
|
|
34
|
+
handledDefaultWindows.current = false;
|
|
35
|
+
handledRouteWindow.current = false;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// The URL belongs to the entry, not to this launcher: one that is
|
|
39
|
+
// disabled at the entry skips it rather than opening it when enabled.
|
|
40
|
+
const routeRequest = routeWindowEnabled && !handledRouteWindow.current
|
|
41
|
+
? readRouteWindowRequest(definition)
|
|
42
|
+
: null;
|
|
43
|
+
// Record the entry before opening, including across StrictMode effects.
|
|
44
|
+
handledRouteWindow.current = true;
|
|
45
|
+
const requests = [];
|
|
46
|
+
if (defaultWindowEnabled && !handledDefaultWindows.current) {
|
|
47
|
+
handledDefaultWindows.current = true;
|
|
48
|
+
if (windowCount === 0) {
|
|
49
|
+
requests.push(...readDefaultWindowRequests(definition, routeRequest));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (routeRequest)
|
|
53
|
+
requests.push(routeRequest);
|
|
54
|
+
for (const request of requests)
|
|
55
|
+
openMiniApp(request);
|
|
56
|
+
}, [
|
|
57
|
+
defaultWindowEnabled,
|
|
58
|
+
definition,
|
|
59
|
+
mode,
|
|
60
|
+
openMiniApp,
|
|
61
|
+
routeWindowEnabled,
|
|
62
|
+
windowCount,
|
|
63
|
+
]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (mode !== "windowed" || !routeWindowEnabled)
|
|
66
|
+
return;
|
|
67
|
+
const openRouteWindow = () => {
|
|
68
|
+
const routeRequest = readRouteWindowRequest(definition);
|
|
69
|
+
if (routeRequest)
|
|
70
|
+
openMiniApp(routeRequest);
|
|
71
|
+
};
|
|
72
|
+
window.addEventListener("popstate", openRouteWindow);
|
|
73
|
+
return () => window.removeEventListener("popstate", openRouteWindow);
|
|
74
|
+
}, [definition, mode, openMiniApp, routeWindowEnabled]);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=useWindowedEntryWindows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowedEntryWindows.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/useWindowedEntryWindows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAA2B,MAAM,sBAAsB,CAAC;AAGhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,+EAA+E;AAC/E,SAAS,sBAAsB,CAC7B,UAA8B;IAE9B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAChD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EACxB,UAAU,CACX,CAAC;IACF,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,yEAAyE;IACzE,yBAAyB;IACzB,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,C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AC,EAAE,CAAC;gBACtB,QAAQ,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;QACD,IAAI,YAAY;YAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC,EAAE;QACD,oBAAoB;QACpB,UAAU;QACV,IAAI;QACJ,WAAW;QACX,kBAAkB;QAClB,WAAW;KACZ,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,UAAU,IAAI,CAAC,kBAAkB;YAAE,OAAO;QACvD,MAAM,eAAe,GAAG,GAAG,EAAE;YAC3B,MAAM,YAAY,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;YACxD,IAAI,YAAY;gBAAE,WAAW,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QACrD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IACvE,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { isLauncherAppId, type LauncherDefinition } from \"./launcherDefinition\";\nimport type { NavigationMode } from \"./navigationMode\";\nimport type { OpenMiniAppRequest } from \"./openMiniAppWindow\";\nimport { parseLauncherRoute } from \"./routePaths\";\n\n/** The request that opens the app the browser's URL names, if it names one. */\nfunction readRouteWindowRequest(\n definition: LauncherDefinition,\n): OpenMiniAppRequest | null {\n const { appId, pathSegments } = parseLauncherRoute(\n window.location.pathname,\n definition,\n );\n if (appId === null) return null;\n // An app's root route names no place within it, so the app's open window\n // is raised where it is.\n return pathSegments.length > 0 ? { appId, pathSegments } : { appId };\n}\n\n/**\n * The requests that open the host's default windows, each app once and\n * without the URL's app, which opens after them: the launcher's open requests\n * within one pass cannot see the windows the earlier ones created.\n */\nfunction readDefaultWindowRequests(\n definition: LauncherDefinition,\n routeRequest: OpenMiniAppRequest | null,\n): OpenMiniAppRequest[] {\n return [...new Set(definition.defaultWindowAppIds)]\n .filter(\n (appId) =>\n appId !== routeRequest?.appId && isLauncherAppId(definition, appId),\n )\n .map((appId) => ({ appId }));\n}\n\n/**\n * Opens the windows a windowed desktop starts with, once per entry into\n * windowed mode: the host's default windows, in order, if the desktop is\n * empty, and then the app the browser's URL names, in front. While windowed,\n * a browser history step to another app's URL opens that app too.\n */\nexport function useWindowedEntryWindows({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n routeWindowEnabled,\n windowCount,\n}: {\n defaultWindowEnabled: boolean;\n definition: LauncherDefinition;\n mode: NavigationMode;\n openMiniApp: (request: OpenMiniAppRequest) => string | null;\n routeWindowEnabled: boolean;\n windowCount: number;\n}) {\n const handledDefaultWindows = useRef(false);\n const handledRouteWindow = useRef(false);\n\n useEffect(() => {\n if (mode !== \"windowed\") {\n handledDefaultWindows.current = false;\n handledRouteWindow.current = false;\n return;\n }\n // The URL belongs to the entry, not to this launcher: one that is\n // disabled at the entry skips it rather than opening it when enabled.\n const routeRequest =\n routeWindowEnabled && !handledRouteWindow.current\n ? readRouteWindowRequest(definition)\n : null;\n // Record the entry before opening, including across StrictMode effects.\n handledRouteWindow.current = true;\n const requests: OpenMiniAppRequest[] = [];\n if (defaultWindowEnabled && !handledDefaultWindows.current) {\n handledDefaultWindows.current = true;\n if (windowCount === 0) {\n requests.push(...readDefaultWindowRequests(definition, routeRequest));\n }\n }\n if (routeRequest) requests.push(routeRequest);\n for (const request of requests) openMiniApp(request);\n }, [\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n routeWindowEnabled,\n windowCount,\n ]);\n\n useEffect(() => {\n if (mode !== \"windowed\" || !routeWindowEnabled) return;\n const openRouteWindow = () => {\n const routeRequest = readRouteWindowRequest(definition);\n if (routeRequest) openMiniApp(routeRequest);\n };\n window.addEventListener(\"popstate\", openRouteWindow);\n return () => window.removeEventListener(\"popstate\", openRouteWindow);\n }, [definition, mode, openMiniApp, routeWindowEnabled]);\n}\n"]}
|
package/menu/Menu.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useEffectEvent, useLayoutEffect, useRef, useState, } from "react";
|
|
2
|
+
import { useContext, useEffect, useEffectEvent, useLayoutEffect, useRef, useState, } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import "./Menu.css";
|
|
5
|
+
import { menuContainsTarget, ParentMenu, registerMenuParent, } from "./menuOwnership.js";
|
|
5
6
|
import { useMenuKeyboard } from "./useMenuKeyboard.js";
|
|
6
7
|
const MENU_VIEWPORT_MARGIN_PX = 8;
|
|
7
8
|
const MEASUREMENT_MENU_STYLE = {
|
|
@@ -46,12 +47,7 @@ function useMenuOutsideDismissal(menuRef, onClose) {
|
|
|
46
47
|
const close = useEffectEvent(onClose);
|
|
47
48
|
useEffect(() => {
|
|
48
49
|
function handleClick(e) {
|
|
49
|
-
|
|
50
|
-
if (!(target instanceof Node)) {
|
|
51
|
-
close();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (menuRef.current && !menuRef.current.contains(target)) {
|
|
50
|
+
if (menuRef.current && !menuContainsTarget(menuRef.current, e.target)) {
|
|
55
51
|
close();
|
|
56
52
|
}
|
|
57
53
|
}
|
|
@@ -62,13 +58,10 @@ function useMenuOutsideDismissal(menuRef, onClose) {
|
|
|
62
58
|
// anywhere else would leave it floating where the trigger used to be. Close
|
|
63
59
|
// it instead. Scrolls inside the menu — its own overflow, or a list it
|
|
64
60
|
// hosts — are the menu working as intended. Capture phase, because scroll
|
|
65
|
-
// events do not bubble.
|
|
66
|
-
// nested Menu is portaled to the body too, so scrolling one would close its
|
|
67
|
-
// parent. Nothing nests menus today; revisit here if that changes.
|
|
61
|
+
// events do not bubble. Include any child menus portaled to the body.
|
|
68
62
|
useEffect(() => {
|
|
69
63
|
function handleScroll(e) {
|
|
70
|
-
|
|
71
|
-
if (target instanceof Node && menuRef.current?.contains(target)) {
|
|
64
|
+
if (menuRef.current && menuContainsTarget(menuRef.current, e.target)) {
|
|
72
65
|
return;
|
|
73
66
|
}
|
|
74
67
|
close();
|
|
@@ -115,6 +108,12 @@ function placeMenuInViewport(input) {
|
|
|
115
108
|
}
|
|
116
109
|
export function Menu({ position, onClose, direction = "up", keyboardNavigation = true, children, }) {
|
|
117
110
|
const menuRef = useRef(null);
|
|
111
|
+
const parent = useContext(ParentMenu);
|
|
112
|
+
useLayoutEffect(() => {
|
|
113
|
+
return parent && menuRef.current
|
|
114
|
+
? registerMenuParent(menuRef.current, parent)
|
|
115
|
+
: undefined;
|
|
116
|
+
}, [parent]);
|
|
118
117
|
useMenuOutsideDismissal(menuRef, onClose);
|
|
119
118
|
const { x, y } = position;
|
|
120
119
|
const [placement, setPlacement] = useState(() => createInitialMenuPlacement(position, direction));
|
|
@@ -170,6 +169,6 @@ export function Menu({ position, onClose, direction = "up", keyboardNavigation =
|
|
|
170
169
|
top: placement.top,
|
|
171
170
|
}
|
|
172
171
|
: MEASUREMENT_MENU_STYLE;
|
|
173
|
-
return createPortal(_jsx("div", { ref: menuRef, className: "menu", "data-scrollable": scrollable || undefined, style: menuStyle, tabIndex: -1, children: children }), document.body);
|
|
172
|
+
return createPortal(_jsx("div", { ref: menuRef, className: "menu", "data-scrollable": scrollable || undefined, style: menuStyle, tabIndex: -1, children: _jsx(ParentMenu.Provider, { value: menuRef, children: children }) }), document.body);
|
|
174
173
|
}
|
|
175
174
|
//# sourceMappingURL=Menu.js.map
|
package/menu/Menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/Menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,SAAS,EACT,cAAc,EACd,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,sBAAsB,GAAkB;IAC5C,IAAI,EAAE,uBAAuB;IAC7B,aAAa,EAAE,MAAM;IACrB,GAAG,EAAE,uBAAuB;IAC5B,UAAU,EAAE,QAAQ;CACrB,CAAC;AAEF,2EAA2E;AAC3E,2EAA2E;AAC3E,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAEvC,SAAS,SAAS,CAAC,OAAoB;IACrC,OAAO,CACL,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,GAAG,4BAA4B,CAC3E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,yBAAyB,CAAC,IAAiB;IAClD,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAc,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1E,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;QACtD,IAAI,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;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AS,CAAC,CAAC,CAAC;IAEtB,MAAM,sBAAsB,GAC1B,SAAS,CAAC,QAAQ;QAClB,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;QAChC,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;QAChC,SAAS,CAAC,eAAe,KAAK,SAAS,CAAC;IAC1C,eAAe,CACb,OAAO,EACP,sBAAsB,IAAI,kBAAkB,EAC5C,OAAO,CACR,CAAC;IACF,MAAM,SAAS,GAAkB,sBAAsB;QACrD,CAAC,CAAC;YACE,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,SAAS,EAAE,SAAS,CAAC,SAAS;YAC9B,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,GAAG,EAAE,SAAS,CAAC,GAAG;SACnB;QACH,CAAC,CAAC,sBAAsB,CAAC;IAE3B,OAAO,YAAY,CACjB,cACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAC,MAAM,qBACC,UAAU,IAAI,SAAS,EACxC,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,CAAC,YAEX,QAAQ,GACL,EACN,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC","sourcesContent":["import {\n type CSSProperties,\n type PropsWithChildren,\n type RefObject,\n useEffect,\n useEffectEvent,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport \"./Menu.css\";\nimport { useMenuKeyboard } from \"./useMenuKeyboard\";\n\nconst MENU_VIEWPORT_MARGIN_PX = 8;\nconst MEASUREMENT_MENU_STYLE: CSSProperties = {\n left: MENU_VIEWPORT_MARGIN_PX,\n pointerEvents: \"none\",\n top: MENU_VIEWPORT_MARGIN_PX,\n visibility: \"hidden\",\n};\n\n// Fractional layout or zoom can report a spurious pixel of overflow; treat\n// that as fitting, since a false positive hands touch panning to the page.\nconst SCROLL_OVERFLOW_TOLERANCE_PX = 1;\n\nfunction overflows(element: HTMLElement): boolean {\n return (\n element.scrollHeight > element.clientHeight + SCROLL_OVERFLOW_TOLERANCE_PX\n );\n}\n\n/**\n * Whether touch should be allowed to pan inside the menu: its own box scrolls,\n * or a descendant scroll container (a select menu's option list) does. The\n * menu box is a scroll container by its stylesheet; descendants qualify by\n * their computed overflow so a plain overflowing block does not count.\n */\nfunction hasTouchScrollableContent(menu: HTMLElement): boolean {\n if (overflows(menu)) {\n return true;\n }\n\n for (const element of Array.from(menu.querySelectorAll<HTMLElement>(\"*\"))) {\n if (!overflows(element)) {\n continue;\n }\n const overflowY = getComputedStyle(element).overflowY;\n if (overflowY === \"auto\" || overflowY === \"scroll\") {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Dismiss the menu on a pointer press or a scroll outside it. The closer is\n * read through an effect event: consumers commonly pass an inline one, and\n * the document listeners should subscribe once, not on every render.\n */\nfunction useMenuOutsideDismissal(\n menuRef: RefObject<HTMLDivElement | null>,\n onClose: () => void,\n): void {\n const close = useEffectEvent(onClose);\n\n useEffect(() => {\n function handleClick(e: MouseEvent) {\n const target = e.target;\n if (!(target instanceof Node)) {\n close();\n return;\n }\n\n if (menuRef.current && !menuRef.current.contains(target)) {\n close();\n }\n }\n document.addEventListener(\"mousedown\", handleClick);\n return () => document.removeEventListener(\"mousedown\", handleClick);\n }, [menuRef]);\n\n // The menu is anchored once, from its trigger's position, so a scroll\n // anywhere else would leave it floating where the trigger used to be. Close\n // it instead. Scrolls inside the menu — its own overflow, or a list it\n // hosts — are the menu working as intended. Capture phase, because scroll\n // events do not bubble. The check covers this menu's own subtree only: a\n // nested Menu is portaled to the body too, so scrolling one would close its\n // parent. Nothing nests menus today; revisit here if that changes.\n useEffect(() => {\n function handleScroll(e: Event) {\n const target = e.target;\n if (target instanceof Node && menuRef.current?.contains(target)) {\n return;\n }\n close();\n }\n document.addEventListener(\"scroll\", handleScroll, true);\n return () => document.removeEventListener(\"scroll\", handleScroll, true);\n }, [menuRef]);\n}\n\nexport interface MenuPosition {\n x: number;\n y: number;\n}\n\ninterface MenuPlacement {\n anchorDirection: \"up\" | \"down\";\n anchorX: number;\n anchorY: number;\n left: number;\n maxHeight: number | undefined;\n maxWidth: number | undefined;\n measured: boolean;\n top: number;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction createInitialMenuPlacement(\n position: MenuPosition,\n direction: \"up\" | \"down\",\n): MenuPlacement {\n return {\n anchorDirection: direction,\n anchorX: position.x,\n anchorY: position.y,\n left: position.x,\n maxHeight: undefined,\n maxWidth: undefined,\n measured: false,\n top: position.y,\n };\n}\n\nfunction placeMenuInViewport(input: {\n direction: \"up\" | \"down\";\n height: number;\n position: MenuPosition;\n viewportHeight: number;\n viewportWidth: number;\n width: number;\n}): MenuPlacement {\n const availableWidth = Math.max(\n 0,\n input.viewportWidth - MENU_VIEWPORT_MARGIN_PX * 2,\n );\n const availableHeight = Math.max(\n 0,\n input.viewportHeight - MENU_VIEWPORT_MARGIN_PX * 2,\n );\n const boundedWidth = Math.min(input.width, availableWidth);\n const boundedHeight = Math.min(input.height, availableHeight);\n const maxLeft = Math.max(\n MENU_VIEWPORT_MARGIN_PX,\n input.viewportWidth - MENU_VIEWPORT_MARGIN_PX - boundedWidth,\n );\n const maxTop = Math.max(\n MENU_VIEWPORT_MARGIN_PX,\n input.viewportHeight - MENU_VIEWPORT_MARGIN_PX - boundedHeight,\n );\n const preferredTop =\n input.direction === \"up\"\n ? input.position.y - boundedHeight\n : input.position.y;\n\n return {\n anchorDirection: input.direction,\n anchorX: input.position.x,\n anchorY: input.position.y,\n left: clamp(input.position.x, MENU_VIEWPORT_MARGIN_PX, maxLeft),\n maxHeight: availableHeight > 0 ? availableHeight : undefined,\n maxWidth: availableWidth > 0 ? availableWidth : undefined,\n measured: true,\n top: clamp(preferredTop, MENU_VIEWPORT_MARGIN_PX, maxTop),\n };\n}\n\nexport function Menu({\n position,\n onClose,\n direction = \"up\",\n keyboardNavigation = true,\n children,\n}: PropsWithChildren<{\n position: MenuPosition;\n onClose: () => void;\n direction?: \"up\" | \"down\";\n keyboardNavigation?: boolean;\n}>) {\n const menuRef = useRef<HTMLDivElement>(null);\n useMenuOutsideDismissal(menuRef, onClose);\n const { x, y } = position;\n const [placement, setPlacement] = useState(() =>\n createInitialMenuPlacement(position, direction),\n );\n // Whether anything in the menu scrolls, so the stylesheet can let touch pan\n // it while consuming swipes on a menu that fits (see Menu.css).\n const [scrollable, setScrollable] = useState(false);\n\n // Re-measure after every commit as well as on resize below: children can be\n // swapped or filtered while the menu is open without its box changing size,\n // which moves scrollHeight but not the ResizeObserver. setState bails out\n // when the answer is unchanged.\n useLayoutEffect(() => {\n const menu = menuRef.current;\n if (menu) {\n setScrollable(hasTouchScrollableContent(menu));\n }\n });\n\n useLayoutEffect(() => {\n const menu = menuRef.current;\n if (!menu) {\n return;\n }\n\n const updatePlacement = () => {\n const rect = menu.getBoundingClientRect();\n setPlacement(\n placeMenuInViewport({\n direction,\n height: rect.height,\n position: { x, y },\n viewportHeight: window.innerHeight,\n viewportWidth: window.innerWidth,\n width: rect.width,\n }),\n );\n setScrollable(hasTouchScrollableContent(menu));\n };\n updatePlacement();\n const observer = new ResizeObserver(updatePlacement);\n observer.observe(menu);\n window.addEventListener(\"resize\", updatePlacement);\n return () => {\n observer.disconnect();\n window.removeEventListener(\"resize\", updatePlacement);\n };\n }, [x, y, direction]);\n\n const placementMatchesAnchor =\n placement.measured &&\n placement.anchorX === position.x &&\n placement.anchorY === position.y &&\n placement.anchorDirection === direction;\n useMenuKeyboard(\n menuRef,\n placementMatchesAnchor && keyboardNavigation,\n onClose,\n );\n const menuStyle: CSSProperties = placementMatchesAnchor\n ? {\n left: placement.left,\n maxHeight: placement.maxHeight,\n maxWidth: placement.maxWidth,\n top: placement.top,\n }\n : MEASUREMENT_MENU_STYLE;\n\n return createPortal(\n <div\n ref={menuRef}\n className=\"menu\"\n data-scrollable={scrollable || undefined}\n style={menuStyle}\n tabIndex={-1}\n >\n {children}\n </div>,\n document.body,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/Menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,UAAU,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,sBAAsB,GAAkB;IAC5C,IAAI,EAAE,uBAAuB;IAC7B,aAAa,EAAE,MAAM;IACrB,GAAG,EAAE,uBAAuB;IAC5B,UAAU,EAAE,QAAQ;CACrB,CAAC;AAEF,2EAA2E;AAC3E,2EAA2E;AAC3E,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAEvC,SAAS,SAAS,CAAC,OAAoB;IACrC,OAAO,CACL,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,GAAG,4BAA4B,CAC3E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,yBAAyB,CAAC,IAAiB;IAClD,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAc,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1E,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;QACtD,IAAI,SAAS,KAAK,MAAM,IAAI,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O,GAAG,EAAE;YACV,QAAQ,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IAEtB,MAAM,sBAAsB,GAC1B,SAAS,CAAC,QAAQ;QAClB,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;QAChC,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;QAChC,SAAS,CAAC,eAAe,KAAK,SAAS,CAAC;IAC1C,eAAe,CACb,OAAO,EACP,sBAAsB,IAAI,kBAAkB,EAC5C,OAAO,CACR,CAAC;IACF,MAAM,SAAS,GAAkB,sBAAsB;QACrD,CAAC,CAAC;YACE,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,SAAS,EAAE,SAAS,CAAC,SAAS;YAC9B,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,GAAG,EAAE,SAAS,CAAC,GAAG;SACnB;QACH,CAAC,CAAC,sBAAsB,CAAC;IAE3B,OAAO,YAAY,CACjB,cACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAC,MAAM,qBACC,UAAU,IAAI,SAAS,EACxC,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,CAAC,YAEZ,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YAAG,QAAQ,GAAuB,GACjE,EACN,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC","sourcesContent":["import {\n type CSSProperties,\n type PropsWithChildren,\n type RefObject,\n useContext,\n useEffect,\n useEffectEvent,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport \"./Menu.css\";\nimport {\n menuContainsTarget,\n ParentMenu,\n registerMenuParent,\n} from \"./menuOwnership\";\nimport { useMenuKeyboard } from \"./useMenuKeyboard\";\n\nconst MENU_VIEWPORT_MARGIN_PX = 8;\nconst MEASUREMENT_MENU_STYLE: CSSProperties = {\n left: MENU_VIEWPORT_MARGIN_PX,\n pointerEvents: \"none\",\n top: MENU_VIEWPORT_MARGIN_PX,\n visibility: \"hidden\",\n};\n\n// Fractional layout or zoom can report a spurious pixel of overflow; treat\n// that as fitting, since a false positive hands touch panning to the page.\nconst SCROLL_OVERFLOW_TOLERANCE_PX = 1;\n\nfunction overflows(element: HTMLElement): boolean {\n return (\n element.scrollHeight > element.clientHeight + SCROLL_OVERFLOW_TOLERANCE_PX\n );\n}\n\n/**\n * Whether touch should be allowed to pan inside the menu: its own box scrolls,\n * or a descendant scroll container (a select menu's option list) does. The\n * menu box is a scroll container by its stylesheet; descendants qualify by\n * their computed overflow so a plain overflowing block does not count.\n */\nfunction hasTouchScrollableContent(menu: HTMLElement): boolean {\n if (overflows(menu)) {\n return true;\n }\n\n for (const element of Array.from(menu.querySelectorAll<HTMLElement>(\"*\"))) {\n if (!overflows(element)) {\n continue;\n }\n const overflowY = getComputedStyle(element).overflowY;\n if (overflowY === \"auto\" || overflowY === \"scroll\") {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Dismiss the menu on a pointer press or a scroll outside it. The closer is\n * read through an effect event: consumers commonly pass an inline one, and\n * the document listeners should subscribe once, not on every render.\n */\nfunction useMenuOutsideDismissal(\n menuRef: RefObject<HTMLDivElement | null>,\n onClose: () => void,\n): void {\n const close = useEffectEvent(onClose);\n\n useEffect(() => {\n function handleClick(e: MouseEvent) {\n if (menuRef.current && !menuContainsTarget(menuRef.current, e.target)) {\n close();\n }\n }\n document.addEventListener(\"mousedown\", handleClick);\n return () => document.removeEventListener(\"mousedown\", handleClick);\n }, [menuRef]);\n\n // The menu is anchored once, from its trigger's position, so a scroll\n // anywhere else would leave it floating where the trigger used to be. Close\n // it instead. Scrolls inside the menu — its own overflow, or a list it\n // hosts — are the menu working as intended. Capture phase, because scroll\n // events do not bubble. Include any child menus portaled to the body.\n useEffect(() => {\n function handleScroll(e: Event) {\n if (menuRef.current && menuContainsTarget(menuRef.current, e.target)) {\n return;\n }\n close();\n }\n document.addEventListener(\"scroll\", handleScroll, true);\n return () => document.removeEventListener(\"scroll\", handleScroll, true);\n }, [menuRef]);\n}\n\nexport interface MenuPosition {\n x: number;\n y: number;\n}\n\ninterface MenuPlacement {\n anchorDirection: \"up\" | \"down\";\n anchorX: number;\n anchorY: number;\n left: number;\n maxHeight: number | undefined;\n maxWidth: number | undefined;\n measured: boolean;\n top: number;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction createInitialMenuPlacement(\n position: MenuPosition,\n direction: \"up\" | \"down\",\n): MenuPlacement {\n return {\n anchorDirection: direction,\n anchorX: position.x,\n anchorY: position.y,\n left: position.x,\n maxHeight: undefined,\n maxWidth: undefined,\n measured: false,\n top: position.y,\n };\n}\n\nfunction placeMenuInViewport(input: {\n direction: \"up\" | \"down\";\n height: number;\n position: MenuPosition;\n viewportHeight: number;\n viewportWidth: number;\n width: number;\n}): MenuPlacement {\n const availableWidth = Math.max(\n 0,\n input.viewportWidth - MENU_VIEWPORT_MARGIN_PX * 2,\n );\n const availableHeight = Math.max(\n 0,\n input.viewportHeight - MENU_VIEWPORT_MARGIN_PX * 2,\n );\n const boundedWidth = Math.min(input.width, availableWidth);\n const boundedHeight = Math.min(input.height, availableHeight);\n const maxLeft = Math.max(\n MENU_VIEWPORT_MARGIN_PX,\n input.viewportWidth - MENU_VIEWPORT_MARGIN_PX - boundedWidth,\n );\n const maxTop = Math.max(\n MENU_VIEWPORT_MARGIN_PX,\n input.viewportHeight - MENU_VIEWPORT_MARGIN_PX - boundedHeight,\n );\n const preferredTop =\n input.direction === \"up\"\n ? input.position.y - boundedHeight\n : input.position.y;\n\n return {\n anchorDirection: input.direction,\n anchorX: input.position.x,\n anchorY: input.position.y,\n left: clamp(input.position.x, MENU_VIEWPORT_MARGIN_PX, maxLeft),\n maxHeight: availableHeight > 0 ? availableHeight : undefined,\n maxWidth: availableWidth > 0 ? availableWidth : undefined,\n measured: true,\n top: clamp(preferredTop, MENU_VIEWPORT_MARGIN_PX, maxTop),\n };\n}\n\nexport function Menu({\n position,\n onClose,\n direction = \"up\",\n keyboardNavigation = true,\n children,\n}: PropsWithChildren<{\n position: MenuPosition;\n onClose: () => void;\n direction?: \"up\" | \"down\";\n keyboardNavigation?: boolean;\n}>) {\n const menuRef = useRef<HTMLDivElement>(null);\n const parent = useContext(ParentMenu);\n useLayoutEffect(() => {\n return parent && menuRef.current\n ? registerMenuParent(menuRef.current, parent)\n : undefined;\n }, [parent]);\n useMenuOutsideDismissal(menuRef, onClose);\n const { x, y } = position;\n const [placement, setPlacement] = useState(() =>\n createInitialMenuPlacement(position, direction),\n );\n // Whether anything in the menu scrolls, so the stylesheet can let touch pan\n // it while consuming swipes on a menu that fits (see Menu.css).\n const [scrollable, setScrollable] = useState(false);\n\n // Re-measure after every commit as well as on resize below: children can be\n // swapped or filtered while the menu is open without its box changing size,\n // which moves scrollHeight but not the ResizeObserver. setState bails out\n // when the answer is unchanged.\n useLayoutEffect(() => {\n const menu = menuRef.current;\n if (menu) {\n setScrollable(hasTouchScrollableContent(menu));\n }\n });\n\n useLayoutEffect(() => {\n const menu = menuRef.current;\n if (!menu) {\n return;\n }\n\n const updatePlacement = () => {\n const rect = menu.getBoundingClientRect();\n setPlacement(\n placeMenuInViewport({\n direction,\n height: rect.height,\n position: { x, y },\n viewportHeight: window.innerHeight,\n viewportWidth: window.innerWidth,\n width: rect.width,\n }),\n );\n setScrollable(hasTouchScrollableContent(menu));\n };\n updatePlacement();\n const observer = new ResizeObserver(updatePlacement);\n observer.observe(menu);\n window.addEventListener(\"resize\", updatePlacement);\n return () => {\n observer.disconnect();\n window.removeEventListener(\"resize\", updatePlacement);\n };\n }, [x, y, direction]);\n\n const placementMatchesAnchor =\n placement.measured &&\n placement.anchorX === position.x &&\n placement.anchorY === position.y &&\n placement.anchorDirection === direction;\n useMenuKeyboard(\n menuRef,\n placementMatchesAnchor && keyboardNavigation,\n onClose,\n );\n const menuStyle: CSSProperties = placementMatchesAnchor\n ? {\n left: placement.left,\n maxHeight: placement.maxHeight,\n maxWidth: placement.maxWidth,\n top: placement.top,\n }\n : MEASUREMENT_MENU_STYLE;\n\n return createPortal(\n <div\n ref={menuRef}\n className=\"menu\"\n data-scrollable={scrollable || undefined}\n style={menuStyle}\n tabIndex={-1}\n >\n <ParentMenu.Provider value={menuRef}>{children}</ParentMenu.Provider>\n </div>,\n document.body,\n );\n}\n"]}
|
package/menu/MenuItem.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { MouseEventHandler } from "react";
|
|
1
|
+
import type { ButtonHTMLAttributes, MouseEventHandler } from "react";
|
|
2
2
|
import type { WindowingIcon } from "../icons/windowingIcon.js";
|
|
3
|
-
export interface MenuItemProps {
|
|
3
|
+
export interface MenuItemProps extends Pick<ButtonHTMLAttributes<HTMLButtonElement>, "onContextMenu" | "onPointerDown" | "onPointerMove" | "onPointerUp" | "onPointerCancel"> {
|
|
4
4
|
/** Any icon component, such as a Phosphor or Lucide icon. */
|
|
5
5
|
icon?: WindowingIcon | undefined;
|
|
6
6
|
label: string;
|
|
7
7
|
disabled?: boolean | undefined;
|
|
8
8
|
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
9
9
|
}
|
|
10
|
-
export declare function MenuItem({ icon: IconComponent, label, disabled, onClick, }: MenuItemProps): import("react").JSX.Element;
|
|
10
|
+
export declare function MenuItem({ icon: IconComponent, label, disabled, onClick, ...buttonProps }: MenuItemProps): import("react").JSX.Element;
|
package/menu/MenuItem.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
export function MenuItem({ icon: IconComponent, label, disabled, onClick, }) {
|
|
3
|
-
return (_jsxs("button", { type: "button", disabled: disabled, onClick: onClick, children: [IconComponent && (_jsx(IconComponent, { "aria-hidden": "true", className: "menu-item-icon", focusable: "false", size: 16 })), _jsx("span", { className: "menu-item-label", children: label })] }));
|
|
2
|
+
export function MenuItem({ icon: IconComponent, label, disabled, onClick, ...buttonProps }) {
|
|
3
|
+
return (_jsxs("button", { ...buttonProps, type: "button", disabled: disabled, onClick: onClick, children: [IconComponent && (_jsx(IconComponent, { "aria-hidden": "true", className: "menu-item-icon", focusable: "false", size: 16 })), _jsx("span", { className: "menu-item-label", children: label })] }));
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=MenuItem.js.map
|
package/menu/MenuItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/MenuItem.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/MenuItem.tsx"],"names":[],"mappings":";AAmBA,MAAM,UAAU,QAAQ,CAAC,EACvB,IAAI,EAAE,aAAa,EACnB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,GAAG,WAAW,EACA;IACd,OAAO,CACL,qBACM,WAAW,EACf,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,aAEf,aAAa,IAAI,CAChB,KAAC,aAAa,mBACA,MAAM,EAClB,SAAS,EAAC,gBAAgB,EAC1B,SAAS,EAAC,OAAO,EACjB,IAAI,EAAE,EAAE,GACR,CACH,EACD,eAAM,SAAS,EAAC,iBAAiB,YAAE,KAAK,GAAQ,IACzC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { ButtonHTMLAttributes, MouseEventHandler } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\n\nexport interface MenuItemProps\n extends Pick<\n ButtonHTMLAttributes<HTMLButtonElement>,\n | \"onContextMenu\"\n | \"onPointerDown\"\n | \"onPointerMove\"\n | \"onPointerUp\"\n | \"onPointerCancel\"\n > {\n /** Any icon component, such as a Phosphor or Lucide icon. */\n icon?: WindowingIcon | undefined;\n label: string;\n disabled?: boolean | undefined;\n onClick: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport function MenuItem({\n icon: IconComponent,\n label,\n disabled,\n onClick,\n ...buttonProps\n}: MenuItemProps) {\n return (\n <button\n {...buttonProps}\n type=\"button\"\n disabled={disabled}\n onClick={onClick}\n >\n {IconComponent && (\n <IconComponent\n aria-hidden=\"true\"\n className=\"menu-item-icon\"\n focusable=\"false\"\n size={16}\n />\n )}\n <span className=\"menu-item-label\">{label}</span>\n </button>\n );\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
export declare const ParentMenu: import("react").Context<RefObject<HTMLDivElement | null> | null>;
|
|
3
|
+
export declare function registerMenuParent(menu: HTMLElement, parent: RefObject<HTMLDivElement | null>): () => void;
|
|
4
|
+
export declare function menuContainsTarget(menu: HTMLElement, target: EventTarget | null): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
// Nested menus portal to the body. Follow their owner refs when deciding
|
|
3
|
+
// whether a pointer press or scroll happened outside an ancestor menu.
|
|
4
|
+
export const ParentMenu = createContext(null);
|
|
5
|
+
const parents = new WeakMap();
|
|
6
|
+
export function registerMenuParent(menu, parent) {
|
|
7
|
+
parents.set(menu, parent);
|
|
8
|
+
return () => {
|
|
9
|
+
parents.delete(menu);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function menuContainsTarget(menu, target) {
|
|
13
|
+
if (!(target instanceof Node))
|
|
14
|
+
return false;
|
|
15
|
+
if (menu.contains(target))
|
|
16
|
+
return true;
|
|
17
|
+
let owner = (target instanceof Element ? target : target.parentElement)?.closest(".menu");
|
|
18
|
+
while (owner) {
|
|
19
|
+
owner = parents.get(owner)?.current;
|
|
20
|
+
if (owner === menu)
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=menuOwnership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menuOwnership.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/menuOwnership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAEtD,yEAAyE;AACzE,uEAAuE;AACvE,MAAM,CAAC,MAAM,UAAU,GACrB,aAAa,CAA0C,IAAI,CAAC,CAAC;AAE/D,MAAM,OAAO,GAAG,IAAI,OAAO,EAA6C,CAAC;AAEzE,MAAM,UAAU,kBAAkB,CAChC,IAAiB,EACjB,MAAwC;IAExC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1B,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,IAAiB,EACjB,MAA0B;IAE1B,IAAI,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,KAAK,GAAG,CACV,MAAM,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAC1D,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,OAAO,KAAK,EAAE,CAAC;QACb,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QACpC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { createContext, type RefObject } from \"react\";\n\n// Nested menus portal to the body. Follow their owner refs when deciding\n// whether a pointer press or scroll happened outside an ancestor menu.\nexport const ParentMenu =\n createContext<RefObject<HTMLDivElement | null> | null>(null);\n\nconst parents = new WeakMap<Element, RefObject<HTMLDivElement | null>>();\n\nexport function registerMenuParent(\n menu: HTMLElement,\n parent: RefObject<HTMLDivElement | null>,\n) {\n parents.set(menu, parent);\n return () => {\n parents.delete(menu);\n };\n}\n\nexport function menuContainsTarget(\n menu: HTMLElement,\n target: EventTarget | null,\n): boolean {\n if (!(target instanceof Node)) return false;\n if (menu.contains(target)) return true;\n let owner = (\n target instanceof Element ? target : target.parentElement\n )?.closest(\".menu\");\n while (owner) {\n owner = parents.get(owner)?.current;\n if (owner === menu) return true;\n }\n return false;\n}\n"]}
|
package/menu/useMenuKeyboard.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useEffectEvent } from "react";
|
|
2
|
+
import { menuContainsTarget } from "./menuOwnership.js";
|
|
2
3
|
function nextControl(controls, focused, key) {
|
|
3
4
|
if (controls.length === 0)
|
|
4
5
|
return undefined;
|
|
@@ -75,7 +76,7 @@ export function useMenuKeyboard(menuRef, ready, onClose) {
|
|
|
75
76
|
}
|
|
76
77
|
function handleMouseDown(event) {
|
|
77
78
|
dismissedByPointer =
|
|
78
|
-
|
|
79
|
+
menu !== null && !menuContainsTarget(menu, event.target);
|
|
79
80
|
}
|
|
80
81
|
document.addEventListener("mousedown", handleMouseDown, true);
|
|
81
82
|
document.addEventListener("keydown", handleKeyDown, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuKeyboard.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/useMenuKeyboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAElE,SAAS,WAAW,CAClB,QAAuB,EACvB,OAAuB,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aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACrE,IAAI,IAAI,EAAE,CAAC;gBACT,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,CAAC,eAAe,EAAE,CAAC;gBACxB,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QAED,qEAAqE;QACrE,uCAAuC;QACvC,SAAS,SAAS,CAAC,KAAoB;YACrC,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC3B,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,CAAC,eAAe,EAAE,CAAC;gBACxB,YAAY,EAAE,CAAC;YACjB,CAAC;iBAAM,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;gBAC3B,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC;QAED,SAAS,eAAe,CAAC,KAAiB;YACxC,kBAAkB;gBAChB,KAAK,
|
|
1
|
+
{"version":3,"file":"useMenuKeyboard.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/useMenuKeyboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,SAAS,WAAW,CAClB,QAAuB,EACvB,OAAuB,EACvB,GAAW;IAEX,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,KAAK,GAAG,OAAO,YAAY,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,WAAW;YACd,OAAO,QAAQ,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,QAAQ,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,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,CAAC,eAAe,EAAE,CAAC;gBACxB,YAAY,EAAE,CAAC;YACjB,CAAC;iBAAM,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;gBAC3B,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC;QAED,SAAS,eAAe,CAAC,KAAiB;YACxC,kBAAkB;gBAChB,IAAI,KAAK,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;QAC9D,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;QAC1D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,UAAU,EAAE,CAAC;YACtB,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;YACjE,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;YAC7D,IACE,CAAC,kBAAkB;gBACnB,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC;oBACpC,QAAQ,CAAC,aAAa,KAAK,QAAQ,CAAC,IAAI,CAAC,EAC3C,CAAC;gBACD,YAAY,EAAE,CAAC;YACjB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import { type RefObject, useEffect, useEffectEvent } from \"react\";\n\nimport { menuContainsTarget } from \"./menuOwnership\";\n\nfunction nextControl(\n controls: HTMLElement[],\n focused: Element | null,\n key: string,\n) {\n if (controls.length === 0) return undefined;\n const index = focused instanceof HTMLElement ? controls.indexOf(focused) : -1;\n switch (key) {\n case \"ArrowDown\":\n return controls[(index + 1) % controls.length];\n case \"ArrowUp\":\n return controls[\n index < 0\n ? controls.length - 1\n : (index - 1 + controls.length) % controls.length\n ];\n case \"Home\":\n return controls[0];\n case \"End\":\n return controls.at(-1);\n default:\n return undefined;\n }\n}\n\nexport function useMenuKeyboard(\n menuRef: RefObject<HTMLDivElement | null>,\n ready: boolean,\n onClose: () => void,\n) {\n const close = useEffectEvent(onClose);\n\n useEffect(() => {\n const menu = menuRef.current;\n if (!ready || !menu) return;\n\n const trigger = document.activeElement;\n let dismissedByPointer = false;\n const items = () =>\n Array.from(\n menu.querySelectorAll<HTMLElement>(\n \":is(button, input[type=checkbox]):not(:disabled):not([hidden])\",\n ),\n );\n const focusFirst = () =>\n (items()[0] ?? menu).focus({ preventScroll: true });\n focusFirst();\n // Startup and sync can replace an action while its menu is open. Recover\n // focus only when that replacement dropped it onto the document body.\n const observer = new MutationObserver(() => {\n if (!dismissedByPointer && document.activeElement === document.body) {\n focusFirst();\n }\n });\n observer.observe(menu, { childList: true, subtree: true });\n\n function restoreFocus() {\n if (trigger instanceof HTMLElement && trigger.isConnected) {\n trigger.focus({ preventScroll: true });\n return document.activeElement === trigger && trigger !== document.body;\n }\n return false;\n }\n\n function handleKeyDown(event: KeyboardEvent) {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n if (!menu?.contains(document.activeElement)) return;\n if (event.key === \"Escape\" || event.key === \"Tab\") {\n leaveMenu(event);\n return;\n }\n const next = nextControl(items(), document.activeElement, event.key);\n if (next) {\n event.preventDefault();\n event.stopPropagation();\n next.focus();\n }\n }\n\n // Escape returns focus to the trigger; Tab moves on from it natively\n // unless focus could not return there.\n function leaveMenu(event: KeyboardEvent) {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n restoreFocus();\n } else if (!restoreFocus()) {\n event.preventDefault();\n }\n close();\n }\n\n function handleMouseDown(event: MouseEvent) {\n dismissedByPointer =\n menu !== null && !menuContainsTarget(menu, event.target);\n }\n\n document.addEventListener(\"mousedown\", handleMouseDown, true);\n document.addEventListener(\"keydown\", handleKeyDown, true);\n return () => {\n observer.disconnect();\n document.removeEventListener(\"mousedown\", handleMouseDown, true);\n document.removeEventListener(\"keydown\", handleKeyDown, true);\n if (\n !dismissedByPointer &&\n (menu.contains(document.activeElement) ||\n document.activeElement === document.body)\n ) {\n restoreFocus();\n }\n };\n }, [menuRef, ready]);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tearleads/windowing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43",
|
|
4
4
|
"description": "App-agnostic window management for React: window state, window chrome, and the menu and sidebar primitives it renders with.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
package/routed/RoutedPaneNav.css
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
/* Borderless rows: the active/hover fill is the only affordance, so the rail
|
|
22
22
|
reads as a launcher list rather than a stack of buttons. */
|
|
23
23
|
.routed-pane-nav-link {
|
|
24
|
+
-webkit-touch-callout: none;
|
|
25
|
+
user-select: none;
|
|
24
26
|
border-radius: var(--app-radius-control);
|
|
25
27
|
display: flex;
|
|
26
28
|
align-items: center;
|
package/routed/RoutedPaneNav.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { SidebarSimpleIcon } from "@phosphor-icons/react/dist/csr/SidebarSimple";
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect, useMemo, useRef, } from "react";
|
|
4
4
|
import { useLauncherNavigationActions, useLauncherNavigationState, } from "../launcher/LauncherNavigationProvider.js";
|
|
5
|
+
import { useLauncherEntryMenu } from "../launcher/useLauncherEntryMenu.js";
|
|
5
6
|
import { classNames } from "./classNames.js";
|
|
6
7
|
import { RoutedPanePlacementButton } from "./RoutedPanePlacementButton.js";
|
|
7
8
|
import { useMobileSheetDrag } from "./useMobileSheetDrag.js";
|
|
@@ -30,15 +31,17 @@ function isBrowserHandledNavClick(event) {
|
|
|
30
31
|
}
|
|
31
32
|
function RoutedPaneNavLink({ appId, activeAppId, icon: LinkIcon, label, onNavigate, }) {
|
|
32
33
|
const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();
|
|
33
|
-
const
|
|
34
|
-
if (isBrowserHandledNavClick(event)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
event.preventDefault();
|
|
34
|
+
const open = () => {
|
|
38
35
|
openMiniApp({ appId });
|
|
39
36
|
onNavigate();
|
|
40
|
-
}
|
|
41
|
-
|
|
37
|
+
};
|
|
38
|
+
const { menu, triggerProps } = useLauncherEntryMenu(LinkIcon, open);
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsxs("a", { ...triggerProps, "aria-current": activeAppId === appId ? "page" : undefined, className: classNames("routed-pane-nav-link", activeAppId === appId && "routed-pane-nav-link--active"), href: getMiniAppHref(appId), onClick: (event) => {
|
|
40
|
+
if (isBrowserHandledNavClick(event))
|
|
41
|
+
return;
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
open();
|
|
44
|
+
}, children: [LinkIcon && _jsx(LinkIcon, { "aria-hidden": "true", size: 20 }), _jsx("span", { className: "routed-pane-nav-link-label", children: label })] }), menu] }));
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
44
47
|
* The tablet rail's navigation surface: an icon-and-label link per routed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutedPaneNav.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,4BA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G,EAAE,QAAQ,mBACE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,eAC/C,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACxC,EAAE,EAAE,oBAAoB,EACxB,KAAK,EACH,UAAU,IAAI,eAAe,CAAC,UAAU,GAAG,CAAC;oBAC1C,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,eAAe,CAAC,UAAU,KAAK,EAAE;oBAC9D,CAAC,CAAC,SAAS,aAGf,eAAK,SAAS,EAAC,0BAA0B,aACvC,KAAC,2BAA2B,IAC1B,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAClC,OAAO,EAAE,eAAe,CAAC,WAAW,EACpC,aAAa,EAAE,eAAe,CAAC,iBAAiB,GAChD,EACD,IAAI,KAAK,QAAQ,IAAI,CACpB,KAAC,yBAAyB,IACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,yBAAyB,GACnC,CACH,IACG,EACN,KAAC,mBAAmB,IAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,GACzB,IACI,IACP,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { classNames } from \"./classNames\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport { RoutedPanePlacementButton } from \"./RoutedPanePlacementButton\";\nimport { useMobileSheetDrag } from \"./useMobileSheetDrag\";\nimport \"./RoutedPaneNav.css\";\n\nexport const ROUTED_PANE_NAV_PANEL_ID = \"routed-pane-nav-panel\";\nexport const ROUTED_PANE_SHEET_ID = \"routed-pane-sheet\";\n\ninterface RoutedPaneNavItem {\n appId: string;\n icon: WindowingIcon | undefined;\n label: string;\n}\n\n// The launcher entries, in the order given, labeled from the definition.\nfunction useRoutedPaneNavItems(\n appIds: ReadonlyArray<string>,\n): ReadonlyArray<RoutedPaneNavItem> {\n const { definition } = useLauncherNavigationState();\n return useMemo(\n () =>\n appIds.flatMap((appId) => {\n const app = definition.apps[appId];\n return app\n ? [{ appId, icon: app.icon, label: app.iconLabel ?? app.title }]\n : [];\n }),\n [appIds, definition],\n );\n}\n\n// Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,\n// middle-click) so the href still opens in a new tab/window; only intercept\n// a plain left-click for in-app navigation.\nfunction isBrowserHandledNavClick(\n event: ReactMouseEvent<HTMLAnchorElement>,\n): boolean {\n return (\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n );\n}\n\nfunction RoutedPaneNavLink({\n appId,\n activeAppId,\n icon: LinkIcon,\n label,\n onNavigate,\n}: {\n appId: string;\n activeAppId: string;\n icon: WindowingIcon | undefined;\n label: string;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const handleClick = useCallback(\n (event: ReactMouseEvent<HTMLAnchorElement>) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n openMiniApp({ appId });\n onNavigate();\n },\n [appId, onNavigate, openMiniApp],\n );\n\n return (\n <a\n aria-current={activeAppId === appId ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-nav-link\",\n activeAppId === appId && \"routed-pane-nav-link--active\",\n )}\n href={getMiniAppHref(appId)}\n onClick={handleClick}\n >\n {LinkIcon && <LinkIcon aria-hidden=\"true\" size={20} />}\n <span className=\"routed-pane-nav-link-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The tablet rail's navigation surface: an icon-and-label link per routed\n * mini-app. System commands and per-app file/view actions belong to the app bar\n * toolbar at the top of the shell.\n */\nfunction RoutedPaneNavPanel({\n activeAppId,\n appIds,\n id,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n id: string;\n onNavigate: () => void;\n}) {\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-nav-panel\" id={id}>\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneNavLink\n key={appId}\n activeAppId={activeAppId}\n appId={appId}\n icon={icon}\n label={label}\n onNavigate={onNavigate}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneRailToggle({\n expanded,\n onToggle,\n}: {\n expanded: boolean;\n onToggle: () => void;\n}) {\n const label = expanded\n ? \"Collapse navigation rail\"\n : \"Expand navigation rail\";\n\n return (\n <button\n aria-controls={expanded ? ROUTED_PANE_NAV_PANEL_ID : undefined}\n aria-expanded={expanded}\n aria-label={label}\n className=\"routed-pane-iconbutton routed-pane-rail-toggle\"\n title={label}\n type=\"button\"\n onClick={onToggle}\n >\n <SidebarSimpleIcon aria-hidden=\"true\" size={18} />\n </button>\n );\n}\n\nfunction RoutedPaneMobileNavTile({\n active,\n href,\n icon: TileIcon,\n label,\n onSelect,\n}: {\n active: boolean;\n href: string;\n icon: WindowingIcon | undefined;\n label: string;\n onSelect: () => void;\n}) {\n return (\n <a\n aria-current={active ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-sheet-tile\",\n active && \"routed-pane-sheet-tile--active\",\n )}\n href={href}\n onClick={(event) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n onSelect();\n }}\n >\n {TileIcon && <TileIcon aria-hidden=\"true\" size={32} />}\n <span className=\"routed-pane-sheet-tile-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The bottom-sheet navigation: every routed mini-app as a grid of square\n * icon-and-label tiles (styled after Explorer's New Document screen). Like the\n * tablet rail it carries no per-app contextual actions. Selecting a tile\n * navigates and dismisses.\n */\nfunction RoutedPaneMobileNav({\n activeAppId,\n appIds,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-sheet-grid\">\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneMobileNavTile\n key={appId}\n active={activeAppId === appId}\n href={getMiniAppHref(appId)}\n icon={icon}\n label={label}\n onSelect={() => {\n openMiniApp({ appId });\n onNavigate();\n }}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneMobileSheetHandle({\n dragging,\n onClick,\n onPointerDown,\n}: {\n dragging: boolean;\n onClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;\n}) {\n return (\n <button\n aria-label=\"Dismiss menu\"\n className=\"routed-pane-sheet-handle\"\n data-dragging={dragging ? \"true\" : \"false\"}\n type=\"button\"\n onClick={onClick}\n onPointerDown={onPointerDown}\n >\n <span aria-hidden=\"true\" />\n </button>\n );\n}\n\n/**\n * The navigation surface in its tier-appropriate container: a persistent\n * `<aside>` rail in tablet side mode, or a bottom sheet of launcher tiles (plus\n * dismiss scrim) on mobile and in tablet bottom mode.\n */\nexport function RoutedPaneNav({\n activeAppId,\n appIds,\n drawerOpen,\n launcherPlacement,\n onCloseDrawer,\n onNavigateRail,\n onToggleLauncherPlacement,\n onToggleRail,\n railExpanded,\n tier,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n drawerOpen: boolean;\n launcherPlacement: LauncherPlacement;\n onCloseDrawer: () => void;\n onNavigateRail: () => void;\n onToggleLauncherPlacement: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const sheetRef = useRef<HTMLElement>(null);\n useEffect(() => {\n if (drawerOpen && (tier === \"mobile\" || launcherPlacement === \"bottom\")) {\n const sheet = sheetRef.current;\n const tile = sheet?.querySelector<HTMLElement>(\n '.routed-pane-sheet-tile[aria-current=\"page\"]',\n );\n (\n tile ?? sheet?.querySelector<HTMLElement>(\".routed-pane-sheet-tile\")\n )?.focus();\n }\n }, [drawerOpen, launcherPlacement, tier]);\n\n const mobileSheetDrag = useMobileSheetDrag({\n drawerOpen:\n (tier === \"mobile\" || launcherPlacement === \"bottom\") && drawerOpen,\n onClose: onCloseDrawer,\n });\n\n if (tier === \"tablet\" && launcherPlacement === \"side\") {\n return (\n <aside\n className={classNames(\n \"routed-pane-rail\",\n !railExpanded && \"routed-pane-rail--collapsed\",\n )}\n data-state={railExpanded ? \"open\" : \"closed\"}\n >\n <RoutedPaneRailToggle expanded={railExpanded} onToggle={onToggleRail} />\n {railExpanded && (\n <RoutedPaneNavPanel\n activeAppId={activeAppId}\n appIds={appIds}\n id={ROUTED_PANE_NAV_PANEL_ID}\n onNavigate={onNavigateRail}\n />\n )}\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n </aside>\n );\n }\n\n return (\n <>\n {drawerOpen && (\n <button\n aria-label=\"Close menu\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onCloseDrawer}\n />\n )}\n <aside\n aria-hidden={!drawerOpen}\n className=\"routed-pane-sheet\"\n ref={sheetRef}\n data-dragging={mobileSheetDrag.dragging ? \"true\" : \"false\"}\n data-open={drawerOpen ? \"true\" : \"false\"}\n id={ROUTED_PANE_SHEET_ID}\n style={\n drawerOpen && mobileSheetDrag.dragOffset > 0\n ? { transform: `translateY(${mobileSheetDrag.dragOffset}px)` }\n : undefined\n }\n >\n <div className=\"routed-pane-sheet-header\">\n <RoutedPaneMobileSheetHandle\n dragging={mobileSheetDrag.dragging}\n onClick={mobileSheetDrag.handleClick}\n onPointerDown={mobileSheetDrag.handlePointerDown}\n />\n {tier === \"tablet\" && (\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n )}\n </div>\n <RoutedPaneMobileNav\n activeAppId={activeAppId}\n appIds={appIds}\n onNavigate={onCloseDrawer}\n />\n </aside>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RoutedPaneNav.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAGL,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,qBAAqB,CAAC;AAE7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAQxD,yEAAyE;AACzE,SAAS,qBAAqB,CAC5B,MAA6B;IAE7B,MAAM,EAAE,UAAU,EAAE,GAAG,0BAA0B,EAAE,CAAC;IACpD,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,GAAG;YACR,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,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AyB,GACnC,CACH,IACG,EACN,KAAC,mBAAmB,IAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,GACzB,IACI,IACP,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport { useLauncherEntryMenu } from \"../launcher/useLauncherEntryMenu\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { classNames } from \"./classNames\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport { RoutedPanePlacementButton } from \"./RoutedPanePlacementButton\";\nimport { useMobileSheetDrag } from \"./useMobileSheetDrag\";\nimport \"./RoutedPaneNav.css\";\n\nexport const ROUTED_PANE_NAV_PANEL_ID = \"routed-pane-nav-panel\";\nexport const ROUTED_PANE_SHEET_ID = \"routed-pane-sheet\";\n\ninterface RoutedPaneNavItem {\n appId: string;\n icon: WindowingIcon | undefined;\n label: string;\n}\n\n// The launcher entries, in the order given, labeled from the definition.\nfunction useRoutedPaneNavItems(\n appIds: ReadonlyArray<string>,\n): ReadonlyArray<RoutedPaneNavItem> {\n const { definition } = useLauncherNavigationState();\n return useMemo(\n () =>\n appIds.flatMap((appId) => {\n const app = definition.apps[appId];\n return app\n ? [{ appId, icon: app.icon, label: app.iconLabel ?? app.title }]\n : [];\n }),\n [appIds, definition],\n );\n}\n\n// Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,\n// middle-click) so the href still opens in a new tab/window; only intercept\n// a plain left-click for in-app navigation.\nfunction isBrowserHandledNavClick(\n event: ReactMouseEvent<HTMLAnchorElement>,\n): boolean {\n return (\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n );\n}\n\nfunction RoutedPaneNavLink({\n appId,\n activeAppId,\n icon: LinkIcon,\n label,\n onNavigate,\n}: {\n appId: string;\n activeAppId: string;\n icon: WindowingIcon | undefined;\n label: string;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const open = () => {\n openMiniApp({ appId });\n onNavigate();\n };\n const { menu, triggerProps } = useLauncherEntryMenu(LinkIcon, open);\n\n return (\n <>\n <a\n {...triggerProps}\n aria-current={activeAppId === appId ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-nav-link\",\n activeAppId === appId && \"routed-pane-nav-link--active\",\n )}\n href={getMiniAppHref(appId)}\n onClick={(event) => {\n if (isBrowserHandledNavClick(event)) return;\n event.preventDefault();\n open();\n }}\n >\n {LinkIcon && <LinkIcon aria-hidden=\"true\" size={20} />}\n <span className=\"routed-pane-nav-link-label\">{label}</span>\n </a>\n {menu}\n </>\n );\n}\n\n/**\n * The tablet rail's navigation surface: an icon-and-label link per routed\n * mini-app. System commands and per-app file/view actions belong to the app bar\n * toolbar at the top of the shell.\n */\nfunction RoutedPaneNavPanel({\n activeAppId,\n appIds,\n id,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n id: string;\n onNavigate: () => void;\n}) {\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-nav-panel\" id={id}>\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneNavLink\n key={appId}\n activeAppId={activeAppId}\n appId={appId}\n icon={icon}\n label={label}\n onNavigate={onNavigate}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneRailToggle({\n expanded,\n onToggle,\n}: {\n expanded: boolean;\n onToggle: () => void;\n}) {\n const label = expanded\n ? \"Collapse navigation rail\"\n : \"Expand navigation rail\";\n\n return (\n <button\n aria-controls={expanded ? ROUTED_PANE_NAV_PANEL_ID : undefined}\n aria-expanded={expanded}\n aria-label={label}\n className=\"routed-pane-iconbutton routed-pane-rail-toggle\"\n title={label}\n type=\"button\"\n onClick={onToggle}\n >\n <SidebarSimpleIcon aria-hidden=\"true\" size={18} />\n </button>\n );\n}\n\nfunction RoutedPaneMobileNavTile({\n active,\n href,\n icon: TileIcon,\n label,\n onSelect,\n}: {\n active: boolean;\n href: string;\n icon: WindowingIcon | undefined;\n label: string;\n onSelect: () => void;\n}) {\n return (\n <a\n aria-current={active ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-sheet-tile\",\n active && \"routed-pane-sheet-tile--active\",\n )}\n href={href}\n onClick={(event) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n onSelect();\n }}\n >\n {TileIcon && <TileIcon aria-hidden=\"true\" size={32} />}\n <span className=\"routed-pane-sheet-tile-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The bottom-sheet navigation: every routed mini-app as a grid of square\n * icon-and-label tiles (styled after Explorer's New Document screen). Like the\n * tablet rail it carries no per-app contextual actions. Selecting a tile\n * navigates and dismisses.\n */\nfunction RoutedPaneMobileNav({\n activeAppId,\n appIds,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-sheet-grid\">\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneMobileNavTile\n key={appId}\n active={activeAppId === appId}\n href={getMiniAppHref(appId)}\n icon={icon}\n label={label}\n onSelect={() => {\n openMiniApp({ appId });\n onNavigate();\n }}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneMobileSheetHandle({\n dragging,\n onClick,\n onPointerDown,\n}: {\n dragging: boolean;\n onClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;\n}) {\n return (\n <button\n aria-label=\"Dismiss menu\"\n className=\"routed-pane-sheet-handle\"\n data-dragging={dragging ? \"true\" : \"false\"}\n type=\"button\"\n onClick={onClick}\n onPointerDown={onPointerDown}\n >\n <span aria-hidden=\"true\" />\n </button>\n );\n}\n\n/**\n * The navigation surface in its tier-appropriate container: a persistent\n * `<aside>` rail in tablet side mode, or a bottom sheet of launcher tiles (plus\n * dismiss scrim) on mobile and in tablet bottom mode.\n */\nexport function RoutedPaneNav({\n activeAppId,\n appIds,\n drawerOpen,\n launcherPlacement,\n onCloseDrawer,\n onNavigateRail,\n onToggleLauncherPlacement,\n onToggleRail,\n railExpanded,\n tier,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n drawerOpen: boolean;\n launcherPlacement: LauncherPlacement;\n onCloseDrawer: () => void;\n onNavigateRail: () => void;\n onToggleLauncherPlacement: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const sheetRef = useRef<HTMLElement>(null);\n useEffect(() => {\n if (drawerOpen && (tier === \"mobile\" || launcherPlacement === \"bottom\")) {\n const sheet = sheetRef.current;\n const tile = sheet?.querySelector<HTMLElement>(\n '.routed-pane-sheet-tile[aria-current=\"page\"]',\n );\n (\n tile ?? sheet?.querySelector<HTMLElement>(\".routed-pane-sheet-tile\")\n )?.focus();\n }\n }, [drawerOpen, launcherPlacement, tier]);\n\n const mobileSheetDrag = useMobileSheetDrag({\n drawerOpen:\n (tier === \"mobile\" || launcherPlacement === \"bottom\") && drawerOpen,\n onClose: onCloseDrawer,\n });\n\n if (tier === \"tablet\" && launcherPlacement === \"side\") {\n return (\n <aside\n className={classNames(\n \"routed-pane-rail\",\n !railExpanded && \"routed-pane-rail--collapsed\",\n )}\n data-state={railExpanded ? \"open\" : \"closed\"}\n >\n <RoutedPaneRailToggle expanded={railExpanded} onToggle={onToggleRail} />\n {railExpanded && (\n <RoutedPaneNavPanel\n activeAppId={activeAppId}\n appIds={appIds}\n id={ROUTED_PANE_NAV_PANEL_ID}\n onNavigate={onNavigateRail}\n />\n )}\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n </aside>\n );\n }\n\n return (\n <>\n {drawerOpen && (\n <button\n aria-label=\"Close menu\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onCloseDrawer}\n />\n )}\n <aside\n aria-hidden={!drawerOpen}\n className=\"routed-pane-sheet\"\n ref={sheetRef}\n data-dragging={mobileSheetDrag.dragging ? \"true\" : \"false\"}\n data-open={drawerOpen ? \"true\" : \"false\"}\n id={ROUTED_PANE_SHEET_ID}\n style={\n drawerOpen && mobileSheetDrag.dragOffset > 0\n ? { transform: `translateY(${mobileSheetDrag.dragOffset}px)` }\n : undefined\n }\n >\n <div className=\"routed-pane-sheet-header\">\n <RoutedPaneMobileSheetHandle\n dragging={mobileSheetDrag.dragging}\n onClick={mobileSheetDrag.handleClick}\n onPointerDown={mobileSheetDrag.handlePointerDown}\n />\n {tier === \"tablet\" && (\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n )}\n </div>\n <RoutedPaneMobileNav\n activeAppId={activeAppId}\n appIds={appIds}\n onNavigate={onCloseDrawer}\n />\n </aside>\n </>\n );\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type LauncherDefinition } from "./launcherDefinition.js";
|
|
2
|
-
import type { NavigationMode } from "./navigationMode.js";
|
|
3
|
-
/**
|
|
4
|
-
* Opens the host's default windows, in order so the last is in front, once
|
|
5
|
-
* per entry into an empty windowed desktop.
|
|
6
|
-
*/
|
|
7
|
-
export declare function useDefaultWindow({ definition, enabled, mode, openMiniApp, windowCount, }: {
|
|
8
|
-
definition: LauncherDefinition;
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
mode: NavigationMode;
|
|
11
|
-
openMiniApp: (request: {
|
|
12
|
-
appId: string;
|
|
13
|
-
}) => string | null;
|
|
14
|
-
windowCount: number;
|
|
15
|
-
}): void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { isLauncherAppId } from "./launcherDefinition.js";
|
|
3
|
-
/**
|
|
4
|
-
* Opens the host's default windows, in order so the last is in front, once
|
|
5
|
-
* per entry into an empty windowed desktop.
|
|
6
|
-
*/
|
|
7
|
-
export function useDefaultWindow({ definition, enabled, mode, openMiniApp, windowCount, }) {
|
|
8
|
-
const handledWindowedEntry = useRef(false);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (mode !== "windowed") {
|
|
11
|
-
handledWindowedEntry.current = false;
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (!enabled || handledWindowedEntry.current)
|
|
15
|
-
return;
|
|
16
|
-
// Record the entry before opening, including across StrictMode effects.
|
|
17
|
-
handledWindowedEntry.current = true;
|
|
18
|
-
if (windowCount > 0)
|
|
19
|
-
return;
|
|
20
|
-
// Each app once: the launcher's open requests within this pass cannot see
|
|
21
|
-
// the windows the earlier ones created.
|
|
22
|
-
for (const appId of new Set(definition.defaultWindowAppIds)) {
|
|
23
|
-
if (isLauncherAppId(definition, appId))
|
|
24
|
-
openMiniApp({ appId });
|
|
25
|
-
}
|
|
26
|
-
}, [definition, enabled, mode, openMiniApp, windowCount]);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=useDefaultWindow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDefaultWindow.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/useDefaultWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAA2B,MAAM,sBAAsB,CAAC;AAGhF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,UAAU,EACV,OAAO,EACP,IAAI,EACJ,WAAW,EACX,WAAW,GAOZ;IACC,MAAM,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACxB,oBAAoB,CAAC,OAAO,GAAG,KAAK,CAAC;YACrC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,IAAI,oBAAoB,CAAC,OAAO;YAAE,OAAO;QACrD,wEAAwE;QACxE,oBAAoB,CAAC,OAAO,GAAG,IAAI,CAAC;QACpC,IAAI,WAAW,GAAG,CAAC;YAAE,OAAO;QAC5B,0EAA0E;QAC1E,wCAAwC;QACxC,KAAK,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC5D,IAAI,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC;gBAAE,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { isLauncherAppId, type LauncherDefinition } from \"./launcherDefinition\";\nimport type { NavigationMode } from \"./navigationMode\";\n\n/**\n * Opens the host's default windows, in order so the last is in front, once\n * per entry into an empty windowed desktop.\n */\nexport function useDefaultWindow({\n definition,\n enabled,\n mode,\n openMiniApp,\n windowCount,\n}: {\n definition: LauncherDefinition;\n enabled: boolean;\n mode: NavigationMode;\n openMiniApp: (request: { appId: string }) => string | null;\n windowCount: number;\n}) {\n const handledWindowedEntry = useRef(false);\n\n useEffect(() => {\n if (mode !== \"windowed\") {\n handledWindowedEntry.current = false;\n return;\n }\n if (!enabled || handledWindowedEntry.current) return;\n // Record the entry before opening, including across StrictMode effects.\n handledWindowedEntry.current = true;\n if (windowCount > 0) return;\n // Each app once: the launcher's open requests within this pass cannot see\n // the windows the earlier ones created.\n for (const appId of new Set(definition.defaultWindowAppIds)) {\n if (isLauncherAppId(definition, appId)) openMiniApp({ appId });\n }\n }, [definition, enabled, mode, openMiniApp, windowCount]);\n}\n"]}
|