@tearleads/windowing 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -1
- package/index.d.ts +19 -0
- package/index.js +20 -1
- package/index.js.map +1 -1
- package/launcher/LauncherNavigationProvider.d.ts +71 -0
- package/launcher/LauncherNavigationProvider.js +253 -0
- package/launcher/LauncherNavigationProvider.js.map +1 -0
- package/launcher/MiniAppRouteSegmentsContext.d.ts +19 -0
- package/launcher/MiniAppRouteSegmentsContext.js +26 -0
- package/launcher/MiniAppRouteSegmentsContext.js.map +1 -0
- package/launcher/MiniAppWindow.d.ts +18 -0
- package/launcher/MiniAppWindow.js +41 -0
- package/launcher/MiniAppWindow.js.map +1 -0
- package/launcher/NavigationModeOverrideProvider.d.ts +23 -0
- package/launcher/NavigationModeOverrideProvider.js +31 -0
- package/launcher/NavigationModeOverrideProvider.js.map +1 -0
- package/launcher/NavigationModeSwitch.css +22 -0
- package/launcher/NavigationModeSwitch.d.ts +24 -0
- package/launcher/NavigationModeSwitch.js +40 -0
- package/launcher/NavigationModeSwitch.js.map +1 -0
- package/launcher/breakpoints.d.ts +17 -0
- package/launcher/breakpoints.js +18 -0
- package/launcher/breakpoints.js.map +1 -0
- package/launcher/launcherDefinition.d.ts +39 -0
- package/launcher/launcherDefinition.js +18 -0
- package/launcher/launcherDefinition.js.map +1 -0
- package/launcher/navigationHistory.d.ts +16 -0
- package/launcher/navigationHistory.js +48 -0
- package/launcher/navigationHistory.js.map +1 -0
- package/launcher/navigationMode.d.ts +31 -0
- package/launcher/navigationMode.js +35 -0
- package/launcher/navigationMode.js.map +1 -0
- package/launcher/routePaths.d.ts +17 -0
- package/launcher/routePaths.js +46 -0
- package/launcher/routePaths.js.map +1 -0
- package/launcher/routedPathNavigator.d.ts +20 -0
- package/launcher/routedPathNavigator.js +36 -0
- package/launcher/routedPathNavigator.js.map +1 -0
- package/launcher/storedPreference.d.ts +7 -0
- package/launcher/storedPreference.js +43 -0
- package/launcher/storedPreference.js.map +1 -0
- package/launcher/useActiveLauncherRoute.d.ts +14 -0
- package/launcher/useActiveLauncherRoute.js +41 -0
- package/launcher/useActiveLauncherRoute.js.map +1 -0
- package/launcher/useCompactRoutedMode.d.ts +2 -0
- package/launcher/useCompactRoutedMode.js +9 -0
- package/launcher/useCompactRoutedMode.js.map +1 -0
- package/launcher/useMiniAppRouteState.d.ts +14 -0
- package/launcher/useMiniAppRouteState.js +15 -0
- package/launcher/useMiniAppRouteState.js.map +1 -0
- package/launcher/useNavigationMode.d.ts +23 -0
- package/launcher/useNavigationMode.js +34 -0
- package/launcher/useNavigationMode.js.map +1 -0
- package/launcher/useNavigationModeDocumentAttribute.d.ts +16 -0
- package/launcher/useNavigationModeDocumentAttribute.js +24 -0
- package/launcher/useNavigationModeDocumentAttribute.js.map +1 -0
- package/launcher/useRoutedLayoutActive.d.ts +25 -0
- package/launcher/useRoutedLayoutActive.js +69 -0
- package/launcher/useRoutedLayoutActive.js.map +1 -0
- package/launcher/useRoutedLayoutTier.d.ts +17 -0
- package/launcher/useRoutedLayoutTier.js +24 -0
- package/launcher/useRoutedLayoutTier.js.map +1 -0
- package/package.json +1 -1
- package/routed/RoutedPane.css +393 -0
- package/routed/RoutedPane.d.ts +63 -0
- package/routed/RoutedPane.js +91 -0
- package/routed/RoutedPane.js.map +1 -0
- package/routed/RoutedPaneAppBar.d.ts +8 -0
- package/routed/RoutedPaneAppBar.js +23 -0
- package/routed/RoutedPaneAppBar.js.map +1 -0
- package/routed/RoutedPaneMain.d.ts +15 -0
- package/routed/RoutedPaneMain.js +27 -0
- package/routed/RoutedPaneMain.js.map +1 -0
- package/routed/RoutedPaneNav.css +298 -0
- package/routed/RoutedPaneNav.d.ts +20 -0
- package/routed/RoutedPaneNav.js +106 -0
- package/routed/RoutedPaneNav.js.map +1 -0
- package/routed/RoutedPaneOverlayHost.d.ts +37 -0
- package/routed/RoutedPaneOverlayHost.js +29 -0
- package/routed/RoutedPaneOverlayHost.js.map +1 -0
- package/routed/RoutedPanePlacementButton.d.ts +5 -0
- package/routed/RoutedPanePlacementButton.js +10 -0
- package/routed/RoutedPanePlacementButton.js.map +1 -0
- package/routed/RoutedPaneSidebar.css +61 -0
- package/routed/RoutedPaneSidebar.d.ts +7 -0
- package/routed/RoutedPaneSidebar.js +18 -0
- package/routed/RoutedPaneSidebar.js.map +1 -0
- package/routed/RoutedPaneTaskBar.d.ts +24 -0
- package/routed/RoutedPaneTaskBar.js +24 -0
- package/routed/RoutedPaneTaskBar.js.map +1 -0
- package/routed/classNames.d.ts +2 -0
- package/routed/classNames.js +6 -0
- package/routed/classNames.js.map +1 -0
- package/routed/launcherPlacement.d.ts +7 -0
- package/routed/launcherPlacement.js +8 -0
- package/routed/launcherPlacement.js.map +1 -0
- package/routed/useMobileKeyboardVisible.d.ts +7 -0
- package/routed/useMobileKeyboardVisible.js +78 -0
- package/routed/useMobileKeyboardVisible.js.map +1 -0
- package/routed/useMobileSheetDrag.d.ts +10 -0
- package/routed/useMobileSheetDrag.js +83 -0
- package/routed/useMobileSheetDrag.js.map +1 -0
- package/routed/useRoutedPaneOverlays.d.ts +25 -0
- package/routed/useRoutedPaneOverlays.js +72 -0
- package/routed/useRoutedPaneOverlays.js.map +1 -0
- package/tokens.css +24 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* === Mini-app sidebar === */
|
|
2
|
+
|
|
3
|
+
.routed-pane-sidebar-frame {
|
|
4
|
+
grid-area: sidebar;
|
|
5
|
+
display: flex;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
min-height: 0;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
background: var(--routed-sidebar-surface);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.routed-pane-sidebar {
|
|
13
|
+
min-width: 0;
|
|
14
|
+
overflow: auto;
|
|
15
|
+
scrollbar-gutter: var(--scrollbar-gutter);
|
|
16
|
+
background: var(--routed-sidebar-surface);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.routed-pane--tablet .routed-pane-sidebar {
|
|
20
|
+
width: var(--routed-rail-width);
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.routed-pane--tablet[data-launcher-placement="bottom"] .routed-pane-sidebar {
|
|
25
|
+
width: calc(var(--routed-rail-width) + var(--safe-area-left));
|
|
26
|
+
padding-inline-start: var(--safe-area-left);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* The drawer slides in from the leading edge, matching the app bar's sidebar
|
|
30
|
+
toggle (and the tablet tier's rail-side sidebar column). */
|
|
31
|
+
.routed-pane--mobile .routed-pane-sidebar {
|
|
32
|
+
position: absolute;
|
|
33
|
+
inset-block: 0;
|
|
34
|
+
inset-inline-start: 0;
|
|
35
|
+
z-index: 2;
|
|
36
|
+
width: var(--routed-drawer-width);
|
|
37
|
+
/* The drawer overlays the screen's leading edge; keep its content clear of
|
|
38
|
+
a landscape cutout. */
|
|
39
|
+
padding-inline-start: var(--safe-area-left);
|
|
40
|
+
/*
|
|
41
|
+
* Stop the drawer itself below the top cutout. iOS renders its status bar over
|
|
42
|
+
* the webview, so padding only the drawer's content still lets this light
|
|
43
|
+
* surface show through behind the clock and indicators.
|
|
44
|
+
*/
|
|
45
|
+
inset-block-start: var(--safe-area-top);
|
|
46
|
+
border-right: var(--border-strong);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.routed-pane-sidebar-resize-handle {
|
|
50
|
+
width: 16px;
|
|
51
|
+
margin: 0 -8px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.routed-pane-sidebar-resize-handle::before {
|
|
55
|
+
left: calc(50% - 0.5px);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.routed-pane-sidebar-resize-handle:hover::before,
|
|
59
|
+
.routed-pane-sidebar-resize-handle:focus-visible::before {
|
|
60
|
+
left: calc(50% - 1px);
|
|
61
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RoutedLayoutTier } from "../launcher/useRoutedLayoutTier.js";
|
|
3
|
+
export declare function RoutedPaneSidebar({ children, onClose, tier, }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
tier: RoutedLayoutTier;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SidebarResizeHandle, useSidebarResize, } from "../sidebar/SidebarResize.js";
|
|
3
|
+
import "./RoutedPaneSidebar.css";
|
|
4
|
+
const DEFAULT_WIDTH = 224;
|
|
5
|
+
function RoutedPaneMobileSidebar({ children, onClose, }) {
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": "Close sidebar", className: "routed-pane-scrim", type: "button", onClick: onClose }), _jsx("div", { className: "routed-pane-sidebar", id: "routed-pane-sidebar", role: "dialog", children: children })] }));
|
|
7
|
+
}
|
|
8
|
+
function RoutedPaneTabletSidebar({ children }) {
|
|
9
|
+
const resize = useSidebarResize({
|
|
10
|
+
defaultWidth: DEFAULT_WIDTH,
|
|
11
|
+
initialWidth: null,
|
|
12
|
+
});
|
|
13
|
+
return (_jsxs("div", { className: "routed-pane-sidebar-frame", children: [_jsx("div", { className: "routed-pane-sidebar", id: "routed-pane-sidebar", ref: resize.sidebarRef, style: resize.width === null ? undefined : { width: resize.width }, children: children }), _jsx(SidebarResizeHandle, { className: "routed-pane-sidebar-resize-handle", controls: "routed-pane-sidebar", currentWidth: resize.resolvedWidth, onKeyDown: resize.handleKeyDown, onPointerDown: resize.handlePointerDown })] }));
|
|
14
|
+
}
|
|
15
|
+
export function RoutedPaneSidebar({ children, onClose, tier, }) {
|
|
16
|
+
return tier === "mobile" ? (_jsx(RoutedPaneMobileSidebar, { onClose: onClose, children: children })) : (_jsx(RoutedPaneTabletSidebar, { children: children }));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=RoutedPaneSidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutedPaneSidebar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneSidebar.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC;AAEjC,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,SAAS,uBAAuB,CAAC,EAC/B,QAAQ,EACR,OAAO,GAIR;IACC,OAAO,CACL,8BACE,+BACa,eAAe,EAC1B,SAAS,EAAC,mBAAmB,EAC7B,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,GAChB,EACF,cACE,SAAS,EAAC,qBAAqB,EAC/B,EAAE,EAAC,qBAAqB,EACxB,IAAI,EAAC,QAAQ,YAEZ,QAAQ,GACL,IACL,CACJ,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,EAAE,QAAQ,EAA2B;IACpE,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAC9B,YAAY,EAAE,aAAa;QAC3B,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IAEH,OAAO,CACL,eAAK,SAAS,EAAC,2BAA2B,aACxC,cACE,SAAS,EAAC,qBAAqB,EAC/B,EAAE,EAAC,qBAAqB,EACxB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,YAEjE,QAAQ,GACL,EACN,KAAC,mBAAmB,IAClB,SAAS,EAAC,mCAAmC,EAC7C,QAAQ,EAAC,qBAAqB,EAC9B,YAAY,EAAE,MAAM,CAAC,aAAa,EAClC,SAAS,EAAE,MAAM,CAAC,aAAa,EAC/B,aAAa,EAAE,MAAM,CAAC,iBAAiB,GACvC,IACE,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAChC,QAAQ,EACR,OAAO,EACP,IAAI,GAKL;IACC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CACzB,KAAC,uBAAuB,IAAC,OAAO,EAAE,OAAO,YACtC,QAAQ,GACe,CAC3B,CAAC,CAAC,CAAC,CACF,KAAC,uBAAuB,cAAE,QAAQ,GAA2B,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport {\n SidebarResizeHandle,\n useSidebarResize,\n} from \"../sidebar/SidebarResize\";\nimport \"./RoutedPaneSidebar.css\";\n\nconst DEFAULT_WIDTH = 224;\n\nfunction RoutedPaneMobileSidebar({\n children,\n onClose,\n}: {\n children: ReactNode;\n onClose: () => void;\n}) {\n return (\n <>\n <button\n aria-label=\"Close sidebar\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onClose}\n />\n <div\n className=\"routed-pane-sidebar\"\n id=\"routed-pane-sidebar\"\n role=\"dialog\"\n >\n {children}\n </div>\n </>\n );\n}\n\nfunction RoutedPaneTabletSidebar({ children }: { children: ReactNode }) {\n const resize = useSidebarResize({\n defaultWidth: DEFAULT_WIDTH,\n initialWidth: null,\n });\n\n return (\n <div className=\"routed-pane-sidebar-frame\">\n <div\n className=\"routed-pane-sidebar\"\n id=\"routed-pane-sidebar\"\n ref={resize.sidebarRef}\n style={resize.width === null ? undefined : { width: resize.width }}\n >\n {children}\n </div>\n <SidebarResizeHandle\n className=\"routed-pane-sidebar-resize-handle\"\n controls=\"routed-pane-sidebar\"\n currentWidth={resize.resolvedWidth}\n onKeyDown={resize.handleKeyDown}\n onPointerDown={resize.handlePointerDown}\n />\n </div>\n );\n}\n\nexport function RoutedPaneSidebar({\n children,\n onClose,\n tier,\n}: {\n children: ReactNode;\n onClose: () => void;\n tier: RoutedLayoutTier;\n}) {\n return tier === \"mobile\" ? (\n <RoutedPaneMobileSidebar onClose={onClose}>\n {children}\n </RoutedPaneMobileSidebar>\n ) : (\n <RoutedPaneTabletSidebar>{children}</RoutedPaneTabletSidebar>\n );\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from "react";
|
|
2
|
+
import type { RoutedLayoutTier } from "../launcher/useRoutedLayoutTier.js";
|
|
3
|
+
import type { LauncherPlacement } from "./launcherPlacement.js";
|
|
4
|
+
interface RoutedPaneTaskBarProps {
|
|
5
|
+
drawerOpen: boolean;
|
|
6
|
+
hidden: boolean;
|
|
7
|
+
launcherPlacement: LauncherPlacement;
|
|
8
|
+
menuButtonRef: RefObject<HTMLButtonElement | null>;
|
|
9
|
+
menuIcon: ReactNode;
|
|
10
|
+
onToggleDrawer: () => void;
|
|
11
|
+
onToggleRail: () => void;
|
|
12
|
+
railExpanded: boolean;
|
|
13
|
+
tier: RoutedLayoutTier;
|
|
14
|
+
tray: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The routed shell's bottom taskbar — the routed counterpart of a desktop's
|
|
18
|
+
* taskbar. Present in both tiers: the centered menu icon opens the launcher
|
|
19
|
+
* sheet on mobile or in bottom mode, and reveals the rail in tablet side mode.
|
|
20
|
+
* The corner hosts the tray. On mobile it hides while a text-editing control
|
|
21
|
+
* has focus to leave room for the software keyboard.
|
|
22
|
+
*/
|
|
23
|
+
export declare function RoutedPaneTaskBar({ drawerOpen, hidden, launcherPlacement, menuButtonRef, menuIcon, onToggleDrawer, onToggleRail, railExpanded, tier, tray, }: RoutedPaneTaskBarProps): import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ROUTED_PANE_NAV_PANEL_ID } from "./RoutedPaneNav.js";
|
|
3
|
+
/**
|
|
4
|
+
* The routed shell's bottom taskbar — the routed counterpart of a desktop's
|
|
5
|
+
* taskbar. Present in both tiers: the centered menu icon opens the launcher
|
|
6
|
+
* sheet on mobile or in bottom mode, and reveals the rail in tablet side mode.
|
|
7
|
+
* The corner hosts the tray. On mobile it hides while a text-editing control
|
|
8
|
+
* has focus to leave room for the software keyboard.
|
|
9
|
+
*/
|
|
10
|
+
export function RoutedPaneTaskBar({ drawerOpen, hidden, launcherPlacement, menuButtonRef, menuIcon, onToggleDrawer, onToggleRail, railExpanded, tier, tray, }) {
|
|
11
|
+
const usesSheet = tier === "mobile" || launcherPlacement === "bottom";
|
|
12
|
+
const expanded = usesSheet ? drawerOpen : railExpanded;
|
|
13
|
+
// The launcher sheet stays mounted (just hidden), so keep its disclosure
|
|
14
|
+
// relationship wired regardless of open state. The tablet rail's
|
|
15
|
+
// nav panel only exists while expanded, so reference it only then (mirroring
|
|
16
|
+
// the rail toggle) rather than pointing aria-controls at an absent element.
|
|
17
|
+
const controls = usesSheet
|
|
18
|
+
? "routed-pane-sheet"
|
|
19
|
+
: expanded
|
|
20
|
+
? ROUTED_PANE_NAV_PANEL_ID
|
|
21
|
+
: undefined;
|
|
22
|
+
return (_jsxs("footer", { className: "routed-pane-taskbar", hidden: hidden, children: [_jsx("button", { "aria-controls": controls, "aria-expanded": expanded, "aria-label": "Menu", className: "routed-pane-taskbar-menu-button", ref: menuButtonRef, type: "button", onClick: usesSheet ? onToggleDrawer : onToggleRail, children: menuIcon }), _jsx("div", { className: "routed-pane-taskbar-end", children: tray })] }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=RoutedPaneTaskBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutedPaneTaskBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneTaskBar.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAe3D;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,IAAI,GACmB;IACvB,MAAM,SAAS,GAAG,IAAI,KAAK,QAAQ,IAAI,iBAAiB,KAAK,QAAQ,CAAC;IACtE,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC;IACvD,yEAAyE;IACzE,iEAAiE;IACjE,6EAA6E;IAC7E,4EAA4E;IAC5E,MAAM,QAAQ,GAAG,SAAS;QACxB,CAAC,CAAC,mBAAmB;QACrB,CAAC,CAAC,QAAQ;YACR,CAAC,CAAC,wBAAwB;YAC1B,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,CACL,kBAAQ,SAAS,EAAC,qBAAqB,EAAC,MAAM,EAAE,MAAM,aACpD,kCACiB,QAAQ,mBACR,QAAQ,gBACZ,MAAM,EACjB,SAAS,EAAC,iCAAiC,EAC3C,GAAG,EAAE,aAAa,EAClB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,YAEjD,QAAQ,GACF,EACT,cAAK,SAAS,EAAC,yBAAyB,YAAE,IAAI,GAAO,IAC9C,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport { ROUTED_PANE_NAV_PANEL_ID } from \"./RoutedPaneNav\";\n\ninterface RoutedPaneTaskBarProps {\n drawerOpen: boolean;\n hidden: boolean;\n launcherPlacement: LauncherPlacement;\n menuButtonRef: RefObject<HTMLButtonElement | null>;\n menuIcon: ReactNode;\n onToggleDrawer: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n tray: ReactNode;\n}\n\n/**\n * The routed shell's bottom taskbar — the routed counterpart of a desktop's\n * taskbar. Present in both tiers: the centered menu icon opens the launcher\n * sheet on mobile or in bottom mode, and reveals the rail in tablet side mode.\n * The corner hosts the tray. On mobile it hides while a text-editing control\n * has focus to leave room for the software keyboard.\n */\nexport function RoutedPaneTaskBar({\n drawerOpen,\n hidden,\n launcherPlacement,\n menuButtonRef,\n menuIcon,\n onToggleDrawer,\n onToggleRail,\n railExpanded,\n tier,\n tray,\n}: RoutedPaneTaskBarProps) {\n const usesSheet = tier === \"mobile\" || launcherPlacement === \"bottom\";\n const expanded = usesSheet ? drawerOpen : railExpanded;\n // The launcher sheet stays mounted (just hidden), so keep its disclosure\n // relationship wired regardless of open state. The tablet rail's\n // nav panel only exists while expanded, so reference it only then (mirroring\n // the rail toggle) rather than pointing aria-controls at an absent element.\n const controls = usesSheet\n ? \"routed-pane-sheet\"\n : expanded\n ? ROUTED_PANE_NAV_PANEL_ID\n : undefined;\n\n return (\n <footer className=\"routed-pane-taskbar\" hidden={hidden}>\n <button\n aria-controls={controls}\n aria-expanded={expanded}\n aria-label=\"Menu\"\n className=\"routed-pane-taskbar-menu-button\"\n ref={menuButtonRef}\n type=\"button\"\n onClick={usesSheet ? onToggleDrawer : onToggleRail}\n >\n {menuIcon}\n </button>\n <div className=\"routed-pane-taskbar-end\">{tray}</div>\n </footer>\n );\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Joins the truthy class names, or `undefined` when there are none. */
|
|
2
|
+
export function classNames(...values) {
|
|
3
|
+
const result = values.filter((value) => Boolean(value)).join(" ");
|
|
4
|
+
return result.length > 0 ? result : undefined;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=classNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/classNames.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,UAAU,UAAU,CACxB,GAAG,MAAgD;IAEnD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAElE,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC","sourcesContent":["/** Joins the truthy class names, or `undefined` when there are none. */\nexport function classNames(\n ...values: Array<string | false | null | undefined>\n): string | undefined {\n const result = values.filter((value) => Boolean(value)).join(\" \");\n\n return result.length > 0 ? result : undefined;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the tablet tier's launcher sits: a rail on the left, or a sheet of
|
|
3
|
+
* tiles from the bottom, as on a phone.
|
|
4
|
+
*/
|
|
5
|
+
export type LauncherPlacement = "side" | "bottom";
|
|
6
|
+
export declare function loadLauncherPlacement(storageKey: string): LauncherPlacement;
|
|
7
|
+
export declare function saveLauncherPlacement(storageKey: string, placement: LauncherPlacement): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { loadStoredPreference, saveStoredPreference, } from "../launcher/storedPreference.js";
|
|
2
|
+
export function loadLauncherPlacement(storageKey) {
|
|
3
|
+
return loadStoredPreference(storageKey, (stored) => stored === "bottom" ? "bottom" : "side");
|
|
4
|
+
}
|
|
5
|
+
export function saveLauncherPlacement(storageKey, placement) {
|
|
6
|
+
saveStoredPreference(storageKey, placement);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=launcherPlacement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcherPlacement.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/launcherPlacement.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAQtC,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,OAAO,oBAAoB,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CACjD,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,UAAkB,EAClB,SAA4B;IAE5B,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import {\n loadStoredPreference,\n saveStoredPreference,\n} from \"../launcher/storedPreference\";\n\n/**\n * Where the tablet tier's launcher sits: a rail on the left, or a sheet of\n * tiles from the bottom, as on a phone.\n */\nexport type LauncherPlacement = \"side\" | \"bottom\";\n\nexport function loadLauncherPlacement(storageKey: string): LauncherPlacement {\n return loadStoredPreference(storageKey, (stored) =>\n stored === \"bottom\" ? \"bottom\" : \"side\",\n );\n}\n\nexport function saveLauncherPlacement(\n storageKey: string,\n placement: LauncherPlacement,\n): void {\n saveStoredPreference(storageKey, placement);\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscribes to native keyboard state, for hosts whose WebView resizing hides
|
|
3
|
+
* the viewport change a software keyboard makes. Returns an unsubscribe.
|
|
4
|
+
*/
|
|
5
|
+
export type SubscribeKeyboardVisibility = (listener: (visible: boolean) => void) => () => void;
|
|
6
|
+
/** Tracks a software keyboard covering the bottom of the mobile viewport. */
|
|
7
|
+
export declare function useMobileKeyboardVisible(enabled: boolean, subscribeKeyboardVisibility?: SubscribeKeyboardVisibility | undefined): boolean;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const MIN_KEYBOARD_INSET_PX = 100;
|
|
3
|
+
const NON_TEXT_INPUT_TYPES = new Set([
|
|
4
|
+
"button",
|
|
5
|
+
"checkbox",
|
|
6
|
+
"color",
|
|
7
|
+
"file",
|
|
8
|
+
"hidden",
|
|
9
|
+
"image",
|
|
10
|
+
"radio",
|
|
11
|
+
"range",
|
|
12
|
+
"reset",
|
|
13
|
+
"submit",
|
|
14
|
+
]);
|
|
15
|
+
function isTextInputElement(target) {
|
|
16
|
+
if (target instanceof HTMLInputElement) {
|
|
17
|
+
return (!target.disabled &&
|
|
18
|
+
!target.readOnly &&
|
|
19
|
+
!NON_TEXT_INPUT_TYPES.has(target.type));
|
|
20
|
+
}
|
|
21
|
+
if (target instanceof HTMLTextAreaElement) {
|
|
22
|
+
return !target.disabled && !target.readOnly;
|
|
23
|
+
}
|
|
24
|
+
return target instanceof HTMLElement && target.isContentEditable;
|
|
25
|
+
}
|
|
26
|
+
function isSoftwareKeyboardVisible(target) {
|
|
27
|
+
const viewport = window.visualViewport;
|
|
28
|
+
return (isTextInputElement(target) &&
|
|
29
|
+
viewport !== undefined &&
|
|
30
|
+
viewport !== null &&
|
|
31
|
+
viewport.scale <= 1 &&
|
|
32
|
+
window.innerHeight - viewport.height >= MIN_KEYBOARD_INSET_PX);
|
|
33
|
+
}
|
|
34
|
+
/** Tracks a software keyboard covering the bottom of the mobile viewport. */
|
|
35
|
+
export function useMobileKeyboardVisible(enabled, subscribeKeyboardVisibility) {
|
|
36
|
+
const [visible, setVisible] = useState(false);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!enabled) {
|
|
39
|
+
setVisible(false);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (subscribeKeyboardVisibility) {
|
|
43
|
+
return subscribeKeyboardVisibility(setVisible);
|
|
44
|
+
}
|
|
45
|
+
let subscribed = true;
|
|
46
|
+
const updateFromActiveElement = () => {
|
|
47
|
+
if (subscribed) {
|
|
48
|
+
setVisible(isSoftwareKeyboardVisible(document.activeElement));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const updateFromFocus = (event) => {
|
|
52
|
+
setVisible(isSoftwareKeyboardVisible(event.target));
|
|
53
|
+
};
|
|
54
|
+
const updateAfterBlur = (event) => {
|
|
55
|
+
if (event.relatedTarget !== null) {
|
|
56
|
+
setVisible(isSoftwareKeyboardVisible(event.relatedTarget));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
queueMicrotask(updateFromActiveElement);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const viewport = window.visualViewport;
|
|
63
|
+
updateFromActiveElement();
|
|
64
|
+
document.addEventListener("focusin", updateFromFocus);
|
|
65
|
+
document.addEventListener("focusout", updateAfterBlur);
|
|
66
|
+
window.addEventListener("resize", updateFromActiveElement);
|
|
67
|
+
viewport?.addEventListener("resize", updateFromActiveElement);
|
|
68
|
+
return () => {
|
|
69
|
+
subscribed = false;
|
|
70
|
+
document.removeEventListener("focusin", updateFromFocus);
|
|
71
|
+
document.removeEventListener("focusout", updateAfterBlur);
|
|
72
|
+
window.removeEventListener("resize", updateFromActiveElement);
|
|
73
|
+
viewport?.removeEventListener("resize", updateFromActiveElement);
|
|
74
|
+
};
|
|
75
|
+
}, [enabled, subscribeKeyboardVisibility]);
|
|
76
|
+
return enabled && visible;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=useMobileKeyboardVisible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMobileKeyboardVisible.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/useMobileKeyboardVisible.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU5C,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,QAAQ;IACR,UAAU;IACV,OAAO;IACP,MAAM;IACN,QAAQ;IACR,OAAO;IACP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,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC;IAE3C,OAAO,OAAO,IAAI,OAAO,CAAC;AAC5B,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\n\n/**\n * Subscribes to native keyboard state, for hosts whose WebView resizing hides\n * the viewport change a software keyboard makes. Returns an unsubscribe.\n */\nexport type SubscribeKeyboardVisibility = (\n listener: (visible: boolean) => void,\n) => () => void;\n\nconst MIN_KEYBOARD_INSET_PX = 100;\nconst NON_TEXT_INPUT_TYPES = new Set([\n \"button\",\n \"checkbox\",\n \"color\",\n \"file\",\n \"hidden\",\n \"image\",\n \"radio\",\n \"range\",\n \"reset\",\n \"submit\",\n]);\n\nfunction isTextInputElement(target: EventTarget | null): boolean {\n if (target instanceof HTMLInputElement) {\n return (\n !target.disabled &&\n !target.readOnly &&\n !NON_TEXT_INPUT_TYPES.has(target.type)\n );\n }\n if (target instanceof HTMLTextAreaElement) {\n return !target.disabled && !target.readOnly;\n }\n\n return target instanceof HTMLElement && target.isContentEditable;\n}\n\nfunction isSoftwareKeyboardVisible(target: EventTarget | null): boolean {\n const viewport = window.visualViewport;\n return (\n isTextInputElement(target) &&\n viewport !== undefined &&\n viewport !== null &&\n viewport.scale <= 1 &&\n window.innerHeight - viewport.height >= MIN_KEYBOARD_INSET_PX\n );\n}\n\n/** Tracks a software keyboard covering the bottom of the mobile viewport. */\nexport function useMobileKeyboardVisible(\n enabled: boolean,\n subscribeKeyboardVisibility?: SubscribeKeyboardVisibility | undefined,\n): boolean {\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n if (!enabled) {\n setVisible(false);\n return;\n }\n\n if (subscribeKeyboardVisibility) {\n return subscribeKeyboardVisibility(setVisible);\n }\n\n let subscribed = true;\n const updateFromActiveElement = () => {\n if (subscribed) {\n setVisible(isSoftwareKeyboardVisible(document.activeElement));\n }\n };\n const updateFromFocus = (event: FocusEvent) => {\n setVisible(isSoftwareKeyboardVisible(event.target));\n };\n const updateAfterBlur = (event: FocusEvent) => {\n if (event.relatedTarget !== null) {\n setVisible(isSoftwareKeyboardVisible(event.relatedTarget));\n } else {\n queueMicrotask(updateFromActiveElement);\n }\n };\n const viewport = window.visualViewport;\n\n updateFromActiveElement();\n document.addEventListener(\"focusin\", updateFromFocus);\n document.addEventListener(\"focusout\", updateAfterBlur);\n window.addEventListener(\"resize\", updateFromActiveElement);\n viewport?.addEventListener(\"resize\", updateFromActiveElement);\n return () => {\n subscribed = false;\n document.removeEventListener(\"focusin\", updateFromFocus);\n document.removeEventListener(\"focusout\", updateAfterBlur);\n window.removeEventListener(\"resize\", updateFromActiveElement);\n viewport?.removeEventListener(\"resize\", updateFromActiveElement);\n };\n }, [enabled, subscribeKeyboardVisibility]);\n\n return enabled && visible;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent } from "react";
|
|
2
|
+
export declare function useMobileSheetDrag({ drawerOpen, onClose, }: {
|
|
3
|
+
drawerOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
}): {
|
|
6
|
+
dragOffset: number;
|
|
7
|
+
dragging: boolean;
|
|
8
|
+
handleClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
9
|
+
handlePointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
2
|
+
const MOBILE_SHEET_DISMISS_THRESHOLD_PX = 80;
|
|
3
|
+
const MOBILE_SHEET_CLICK_SLOP_PX = 4;
|
|
4
|
+
export function useMobileSheetDrag({ drawerOpen, onClose, }) {
|
|
5
|
+
const dragState = useRef(null);
|
|
6
|
+
const suppressNextClick = useRef(false);
|
|
7
|
+
const [dragOffset, setDragOffset] = useState(0);
|
|
8
|
+
const [dragging, setDragging] = useState(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!drawerOpen) {
|
|
11
|
+
dragState.current = null;
|
|
12
|
+
setDragOffset(0);
|
|
13
|
+
setDragging(false);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
function handlePointerMove(event) {
|
|
17
|
+
const state = dragState.current;
|
|
18
|
+
if (!state || event.pointerId !== state.pointerId) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const travel = Math.abs(event.clientY - state.startY);
|
|
22
|
+
state.travel = Math.max(state.travel, travel);
|
|
23
|
+
state.offsetY = Math.max(0, event.clientY - state.startY);
|
|
24
|
+
setDragOffset(state.offsetY);
|
|
25
|
+
}
|
|
26
|
+
function handlePointerEnd(event, suppressClick) {
|
|
27
|
+
const state = dragState.current;
|
|
28
|
+
if (!state || event.pointerId !== state.pointerId) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
dragState.current = null;
|
|
32
|
+
setDragging(false);
|
|
33
|
+
suppressNextClick.current =
|
|
34
|
+
suppressClick && state.travel >= MOBILE_SHEET_CLICK_SLOP_PX;
|
|
35
|
+
if (state.offsetY >= MOBILE_SHEET_DISMISS_THRESHOLD_PX) {
|
|
36
|
+
onClose();
|
|
37
|
+
}
|
|
38
|
+
setDragOffset(0);
|
|
39
|
+
}
|
|
40
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
41
|
+
const handlePointerUp = (event) => handlePointerEnd(event, true);
|
|
42
|
+
const handlePointerCancel = (event) => handlePointerEnd(event, false);
|
|
43
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
44
|
+
document.addEventListener("pointercancel", handlePointerCancel);
|
|
45
|
+
return () => {
|
|
46
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
47
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
48
|
+
document.removeEventListener("pointercancel", handlePointerCancel);
|
|
49
|
+
};
|
|
50
|
+
}, [drawerOpen, onClose]);
|
|
51
|
+
const handlePointerDown = useCallback((event) => {
|
|
52
|
+
if (event.button !== 0) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (dragState.current) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
suppressNextClick.current = false;
|
|
60
|
+
dragState.current = {
|
|
61
|
+
offsetY: 0,
|
|
62
|
+
pointerId: event.pointerId,
|
|
63
|
+
startY: event.clientY,
|
|
64
|
+
travel: 0,
|
|
65
|
+
};
|
|
66
|
+
setDragging(true);
|
|
67
|
+
}, []);
|
|
68
|
+
const handleClick = useCallback((event) => {
|
|
69
|
+
if (suppressNextClick.current) {
|
|
70
|
+
suppressNextClick.current = false;
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
onClose();
|
|
75
|
+
}, [onClose]);
|
|
76
|
+
return {
|
|
77
|
+
dragOffset,
|
|
78
|
+
dragging,
|
|
79
|
+
handleClick,
|
|
80
|
+
handlePointerDown,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=useMobileSheetDrag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMobileSheetDrag.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/useMobileSheetDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAC7C,MAAM,0BAA0B,GAAG,CAAC,CAAC;AASrC,MAAM,UAAU,kBAAkB,CAAC,EACjC,UAAU,EACV,OAAO,GAIR;IACC,MAAM,SAAS,GAAG,MAAM,CAA8B,IAAI,CAAC,CAAC;IAC5D,MAAM,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,CAAC,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M,EAAE,CAAC;SACV,CAAC;QACF,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,KAAyC,EAAE,EAAE;QAC5C,IAAI,iBAAiB,CAAC,OAAO,EAAE,CAAC;YAC9B,iBAAiB,CAAC,OAAO,GAAG,KAAK,CAAC;YAClC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,EACD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO;QACL,UAAU;QACV,QAAQ;QACR,WAAW;QACX,iBAAiB;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import {\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nconst MOBILE_SHEET_DISMISS_THRESHOLD_PX = 80;\nconst MOBILE_SHEET_CLICK_SLOP_PX = 4;\n\ninterface MobileSheetDragState {\n pointerId: number;\n startY: number;\n travel: number;\n offsetY: number;\n}\n\nexport function useMobileSheetDrag({\n drawerOpen,\n onClose,\n}: {\n drawerOpen: boolean;\n onClose: () => void;\n}) {\n const dragState = useRef<MobileSheetDragState | null>(null);\n const suppressNextClick = useRef(false);\n const [dragOffset, setDragOffset] = useState(0);\n const [dragging, setDragging] = useState(false);\n\n useEffect(() => {\n if (!drawerOpen) {\n dragState.current = null;\n setDragOffset(0);\n setDragging(false);\n return;\n }\n\n function handlePointerMove(event: PointerEvent) {\n const state = dragState.current;\n if (!state || event.pointerId !== state.pointerId) {\n return;\n }\n\n const travel = Math.abs(event.clientY - state.startY);\n state.travel = Math.max(state.travel, travel);\n state.offsetY = Math.max(0, event.clientY - state.startY);\n setDragOffset(state.offsetY);\n }\n\n function handlePointerEnd(event: PointerEvent, suppressClick: boolean) {\n const state = dragState.current;\n if (!state || event.pointerId !== state.pointerId) {\n return;\n }\n\n dragState.current = null;\n setDragging(false);\n suppressNextClick.current =\n suppressClick && state.travel >= MOBILE_SHEET_CLICK_SLOP_PX;\n if (state.offsetY >= MOBILE_SHEET_DISMISS_THRESHOLD_PX) {\n onClose();\n }\n setDragOffset(0);\n }\n\n document.addEventListener(\"pointermove\", handlePointerMove);\n const handlePointerUp = (event: PointerEvent) =>\n handlePointerEnd(event, true);\n const handlePointerCancel = (event: PointerEvent) =>\n handlePointerEnd(event, false);\n document.addEventListener(\"pointerup\", handlePointerUp);\n document.addEventListener(\"pointercancel\", handlePointerCancel);\n return () => {\n document.removeEventListener(\"pointermove\", handlePointerMove);\n document.removeEventListener(\"pointerup\", handlePointerUp);\n document.removeEventListener(\"pointercancel\", handlePointerCancel);\n };\n }, [drawerOpen, onClose]);\n\n const handlePointerDown = useCallback(\n (event: ReactPointerEvent<HTMLButtonElement>) => {\n if (event.button !== 0) {\n return;\n }\n if (dragState.current) {\n return;\n }\n\n event.preventDefault();\n suppressNextClick.current = false;\n dragState.current = {\n offsetY: 0,\n pointerId: event.pointerId,\n startY: event.clientY,\n travel: 0,\n };\n setDragging(true);\n },\n [],\n );\n\n const handleClick = useCallback(\n (event: ReactMouseEvent<HTMLButtonElement>) => {\n if (suppressNextClick.current) {\n suppressNextClick.current = false;\n event.preventDefault();\n return;\n }\n\n onClose();\n },\n [onClose],\n );\n\n return {\n dragOffset,\n dragging,\n handleClick,\n handlePointerDown,\n };\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RoutedLayoutTier } from "../launcher/useRoutedLayoutTier.js";
|
|
2
|
+
import type { LauncherPlacement } from "./launcherPlacement.js";
|
|
3
|
+
export declare function invertBoolean(value: boolean): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The sidebar and the launcher sheet: whether each is open, and the actions
|
|
6
|
+
* that open, close, and move them. Dismissing the sheet returns focus to the
|
|
7
|
+
* taskbar's menu button, which opened it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useRoutedPaneOverlays({ initialSidebarExpanded, launcherPlacement, navigationRailExpanded, onToggleLauncherPlacement, tier, }: {
|
|
10
|
+
initialSidebarExpanded: () => boolean;
|
|
11
|
+
launcherPlacement: LauncherPlacement;
|
|
12
|
+
navigationRailExpanded: boolean;
|
|
13
|
+
onToggleLauncherPlacement: (wasOpen: boolean) => void;
|
|
14
|
+
tier: RoutedLayoutTier;
|
|
15
|
+
}): {
|
|
16
|
+
closeDrawer: () => void;
|
|
17
|
+
closeSidebar: () => void;
|
|
18
|
+
dismissDrawer: () => void;
|
|
19
|
+
drawerOpen: boolean;
|
|
20
|
+
menuButtonRef: import("react").RefObject<HTMLButtonElement | null>;
|
|
21
|
+
moveLauncher: () => void;
|
|
22
|
+
sidebarExpanded: boolean;
|
|
23
|
+
toggleDrawer: () => void;
|
|
24
|
+
toggleSidebar: () => void;
|
|
25
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
export function invertBoolean(value) {
|
|
3
|
+
return !value;
|
|
4
|
+
}
|
|
5
|
+
// Reset the tier-specific overlays when the layout crosses the breakpoint
|
|
6
|
+
// (resize / rotation): the bottom sheet belongs to mobile or tablet bottom
|
|
7
|
+
// mode, and the expanded sidebar becomes a full-screen dialog on mobile.
|
|
8
|
+
function useCollapseOverlaysOnTierChange({ closeDrawer, closeSidebar, tier, }) {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (tier === "tablet") {
|
|
11
|
+
closeDrawer();
|
|
12
|
+
}
|
|
13
|
+
}, [tier, closeDrawer]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (tier === "mobile") {
|
|
16
|
+
closeSidebar();
|
|
17
|
+
}
|
|
18
|
+
}, [tier, closeSidebar]);
|
|
19
|
+
}
|
|
20
|
+
function useEscapeToDismissDrawer(drawerOpen, dismissDrawer) {
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!drawerOpen) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const dismissOnEscape = (event) => {
|
|
26
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
dismissDrawer();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener("keydown", dismissOnEscape);
|
|
32
|
+
return () => document.removeEventListener("keydown", dismissOnEscape);
|
|
33
|
+
}, [dismissDrawer, drawerOpen]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The sidebar and the launcher sheet: whether each is open, and the actions
|
|
37
|
+
* that open, close, and move them. Dismissing the sheet returns focus to the
|
|
38
|
+
* taskbar's menu button, which opened it.
|
|
39
|
+
*/
|
|
40
|
+
export function useRoutedPaneOverlays({ initialSidebarExpanded, launcherPlacement, navigationRailExpanded, onToggleLauncherPlacement, tier, }) {
|
|
41
|
+
const [sidebarExpanded, setSidebarExpanded] = useState(initialSidebarExpanded);
|
|
42
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
43
|
+
const menuButtonRef = useRef(null);
|
|
44
|
+
const toggleSidebar = useCallback(() => setSidebarExpanded(invertBoolean), []);
|
|
45
|
+
const closeSidebar = useCallback(() => setSidebarExpanded(false), []);
|
|
46
|
+
const toggleDrawer = useCallback(() => setDrawerOpen(invertBoolean), []);
|
|
47
|
+
const closeDrawer = useCallback(() => setDrawerOpen(false), []);
|
|
48
|
+
const dismissDrawer = useCallback(() => {
|
|
49
|
+
closeDrawer();
|
|
50
|
+
menuButtonRef.current?.focus();
|
|
51
|
+
}, [closeDrawer]);
|
|
52
|
+
useEscapeToDismissDrawer(drawerOpen, dismissDrawer);
|
|
53
|
+
const moveLauncher = () => {
|
|
54
|
+
const wasOpen = launcherPlacement === "side" ? navigationRailExpanded : drawerOpen;
|
|
55
|
+
setDrawerOpen(launcherPlacement === "side" && wasOpen);
|
|
56
|
+
menuButtonRef.current?.focus();
|
|
57
|
+
onToggleLauncherPlacement(wasOpen);
|
|
58
|
+
};
|
|
59
|
+
useCollapseOverlaysOnTierChange({ closeDrawer, closeSidebar, tier });
|
|
60
|
+
return {
|
|
61
|
+
closeDrawer,
|
|
62
|
+
closeSidebar,
|
|
63
|
+
dismissDrawer,
|
|
64
|
+
drawerOpen,
|
|
65
|
+
menuButtonRef,
|
|
66
|
+
moveLauncher,
|
|
67
|
+
sidebarExpanded,
|
|
68
|
+
toggleDrawer,
|
|
69
|
+
toggleSidebar,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=useRoutedPaneOverlays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRoutedPaneOverlays.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/useRoutedPaneOverlays.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjE,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,CAAC,KAAK,CAAC;AAChB,CAAC;AAED,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,SAAS,+BAA+B,CAAC,EACvC,WAAW,EACX,YAAY,EACZ,IAAI,GAKL;IACC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAExB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,wBAAwB,CAC/B,UAAmB,EACnB,aAAyB;IAEzB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAA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E,CAAC,CAAC;IAChE,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,WAAW,EAAE,CAAC;QACd,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAClB,wBAAwB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,MAAM,OAAO,GACX,iBAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,UAAU,CAAC;QACrE,aAAa,CAAC,iBAAiB,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC;QACvD,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;QAC/B,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,+BAA+B,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAErE,OAAO;QACL,WAAW;QACX,YAAY;QACZ,aAAa;QACb,UAAU;QACV,aAAa;QACb,YAAY;QACZ,eAAe;QACf,YAAY;QACZ,aAAa;KACd,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\n\nexport function invertBoolean(value: boolean): boolean {\n return !value;\n}\n\n// Reset the tier-specific overlays when the layout crosses the breakpoint\n// (resize / rotation): the bottom sheet belongs to mobile or tablet bottom\n// mode, and the expanded sidebar becomes a full-screen dialog on mobile.\nfunction useCollapseOverlaysOnTierChange({\n closeDrawer,\n closeSidebar,\n tier,\n}: {\n closeDrawer: () => void;\n closeSidebar: () => void;\n tier: RoutedLayoutTier;\n}) {\n useEffect(() => {\n if (tier === \"tablet\") {\n closeDrawer();\n }\n }, [tier, closeDrawer]);\n\n useEffect(() => {\n if (tier === \"mobile\") {\n closeSidebar();\n }\n }, [tier, closeSidebar]);\n}\n\nfunction useEscapeToDismissDrawer(\n drawerOpen: boolean,\n dismissDrawer: () => void,\n) {\n useEffect(() => {\n if (!drawerOpen) {\n return;\n }\n const dismissOnEscape = (event: KeyboardEvent) => {\n if (event.key === \"Escape\" && !event.defaultPrevented) {\n event.preventDefault();\n dismissDrawer();\n }\n };\n document.addEventListener(\"keydown\", dismissOnEscape);\n return () => document.removeEventListener(\"keydown\", dismissOnEscape);\n }, [dismissDrawer, drawerOpen]);\n}\n\n/**\n * The sidebar and the launcher sheet: whether each is open, and the actions\n * that open, close, and move them. Dismissing the sheet returns focus to the\n * taskbar's menu button, which opened it.\n */\nexport function useRoutedPaneOverlays({\n initialSidebarExpanded,\n launcherPlacement,\n navigationRailExpanded,\n onToggleLauncherPlacement,\n tier,\n}: {\n initialSidebarExpanded: () => boolean;\n launcherPlacement: LauncherPlacement;\n navigationRailExpanded: boolean;\n onToggleLauncherPlacement: (wasOpen: boolean) => void;\n tier: RoutedLayoutTier;\n}) {\n const [sidebarExpanded, setSidebarExpanded] = useState(\n initialSidebarExpanded,\n );\n const [drawerOpen, setDrawerOpen] = useState(false);\n const menuButtonRef = useRef<HTMLButtonElement>(null);\n\n const toggleSidebar = useCallback(\n () => setSidebarExpanded(invertBoolean),\n [],\n );\n const closeSidebar = useCallback(() => setSidebarExpanded(false), []);\n const toggleDrawer = useCallback(() => setDrawerOpen(invertBoolean), []);\n const closeDrawer = useCallback(() => setDrawerOpen(false), []);\n const dismissDrawer = useCallback(() => {\n closeDrawer();\n menuButtonRef.current?.focus();\n }, [closeDrawer]);\n useEscapeToDismissDrawer(drawerOpen, dismissDrawer);\n const moveLauncher = () => {\n const wasOpen =\n launcherPlacement === \"side\" ? navigationRailExpanded : drawerOpen;\n setDrawerOpen(launcherPlacement === \"side\" && wasOpen);\n menuButtonRef.current?.focus();\n onToggleLauncherPlacement(wasOpen);\n };\n\n useCollapseOverlaysOnTierChange({ closeDrawer, closeSidebar, tier });\n\n return {\n closeDrawer,\n closeSidebar,\n dismissDrawer,\n drawerOpen,\n menuButtonRef,\n moveLauncher,\n sidebarExpanded,\n toggleDrawer,\n toggleSidebar,\n };\n}\n"]}
|
package/tokens.css
CHANGED
|
@@ -54,6 +54,30 @@
|
|
|
54
54
|
--app-shadow-surface: 0 0.5rem 2rem rgb(0 0 0 / 14%);
|
|
55
55
|
--app-shadow-window:
|
|
56
56
|
0 1rem 3rem rgb(0 0 0 / 12%), 0 0.25rem 0.75rem rgb(0 0 0 / 8%);
|
|
57
|
+
|
|
58
|
+
/* The routed shell's surfaces and the screen's safe areas. */
|
|
59
|
+
--border: var(--border-width) solid var(--color-hairline);
|
|
60
|
+
--app-control-border: color-mix(
|
|
61
|
+
in srgb,
|
|
62
|
+
var(--color-dark) 55%,
|
|
63
|
+
var(--color-light)
|
|
64
|
+
);
|
|
65
|
+
--opacity-muted: 0.75;
|
|
66
|
+
--overlay-background: rgb(0 0 0 / 35%);
|
|
67
|
+
--safe-area-top: env(safe-area-inset-top, 0px);
|
|
68
|
+
--safe-area-right: env(safe-area-inset-right, 0px);
|
|
69
|
+
--safe-area-bottom: env(safe-area-inset-bottom, 0px);
|
|
70
|
+
--safe-area-left: env(safe-area-inset-left, 0px);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
* Touch sizing while the routed shell is active (see
|
|
75
|
+
* useNavigationModeDocumentAttribute): 44px hit targets and 24px glyphs. Zero
|
|
76
|
+
* specificity, like the defaults above, so a host's routed values win.
|
|
77
|
+
*/
|
|
78
|
+
:where(:root[data-navigation-mode="routed"]) {
|
|
79
|
+
--control-height: 44px;
|
|
80
|
+
--control-icon-size: 24px;
|
|
57
81
|
}
|
|
58
82
|
|
|
59
83
|
@media (prefers-reduced-motion: reduce) {
|