@tearleads/windowing 0.2.43 → 0.2.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/desktop/DesktopIconMenu.d.ts +2 -1
  2. package/desktop/DesktopIconMenu.js +2 -2
  3. package/desktop/DesktopIconMenu.js.map +1 -1
  4. package/display/AppSwitch.d.ts +10 -0
  5. package/display/AppSwitch.js +5 -0
  6. package/display/AppSwitch.js.map +1 -0
  7. package/display/DisplayProperties.css +13 -6
  8. package/display/DisplayProperties.d.ts +3 -1
  9. package/display/DisplayProperties.js +18 -4
  10. package/display/DisplayProperties.js.map +1 -1
  11. package/docs/launcher.md +24 -0
  12. package/index.d.ts +1 -0
  13. package/index.js +1 -0
  14. package/index.js.map +1 -1
  15. package/launcher/launcherDefinition.d.ts +2 -0
  16. package/launcher/launcherDefinition.js.map +1 -1
  17. package/launcher/storedPreference.d.ts +2 -1
  18. package/launcher/storedPreference.js +8 -4
  19. package/launcher/storedPreference.js.map +1 -1
  20. package/launcher/useLauncherEntryMenu.d.ts +2 -1
  21. package/launcher/useLauncherEntryMenu.js +4 -1
  22. package/launcher/useLauncherEntryMenu.js.map +1 -1
  23. package/menu/Menu.d.ts +2 -1
  24. package/menu/Menu.js +2 -2
  25. package/menu/Menu.js.map +1 -1
  26. package/menu/StartMenu.js +5 -1
  27. package/menu/StartMenu.js.map +1 -1
  28. package/menu/StartMenuPreferencesProvider.d.ts +18 -0
  29. package/menu/StartMenuPreferencesProvider.js +33 -0
  30. package/menu/StartMenuPreferencesProvider.js.map +1 -0
  31. package/menu/startMenuStore.d.ts +8 -0
  32. package/menu/startMenuStore.js +92 -0
  33. package/menu/startMenuStore.js.map +1 -0
  34. package/package.json +1 -1
  35. package/routed/RoutedPane.js +6 -1
  36. package/routed/RoutedPane.js.map +1 -1
  37. package/routed/RoutedPaneNav.js +27 -3
  38. package/routed/RoutedPaneNav.js.map +1 -1
@@ -9,7 +9,8 @@ export interface DesktopIconMenuItem {
9
9
  onSelect: () => void;
10
10
  }
11
11
  /** An icon's context menu: Open, then the host's items. Each closes it. */
12
- export declare function DesktopIconMenu({ icon, items, onClose, onOpen, position, }: {
12
+ export declare function DesktopIconMenu({ id, icon, items, onClose, onOpen, position, }: {
13
+ id?: string | undefined;
13
14
  icon: WindowingIcon | undefined;
14
15
  items: ReadonlyArray<DesktopIconMenuItem>;
15
16
  onClose: () => void;
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Menu } from "../menu/Menu.js";
3
3
  import { MenuItem } from "../menu/MenuItem.js";
4
4
  /** An icon's context menu: Open, then the host's items. Each closes it. */
5
- export function DesktopIconMenu({ icon, items, onClose, onOpen, position, }) {
6
- return (_jsxs(Menu, { direction: "down", onClose: onClose, position: position, children: [_jsx(MenuItem, { icon: icon, label: "Open", onClick: () => {
5
+ export function DesktopIconMenu({ id, icon, items, onClose, onOpen, position, }) {
6
+ return (_jsxs(Menu, { id: id, direction: "down", onClose: onClose, position: position, children: [_jsx(MenuItem, { icon: icon, label: "Open", onClick: () => {
7
7
  onClose();
8
8
  onOpen();
9
9
  } }), items.map((item) => (_jsx(MenuItem, { disabled: item.disabled, icon: item.icon, label: item.label, onClick: () => {
@@ -1 +1 @@
1
- {"version":3,"file":"DesktopIconMenu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/desktop/DesktopIconMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5C,2EAA2E;AAC3E,MAAM,UAAU,eAAe,CAAC,EAC9B,IAAI,EACJ,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GAOT;IACC,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,aACzD,KAAC,QAAQ,IACP,IAAI,EAAE,IAAI,EACV,KAAK,EAAC,MAAM,EACZ,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,EAAE,CAAC;oBACV,MAAM,EAAE,CAAC;gBACX,CAAC,GACD,EACD,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,QAAQ,IACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EAEf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,EAAE,CAAC;oBACV,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC,IALI,IAAI,CAAC,EAAE,CAMZ,CACH,CAAC,IACG,CACR,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { Menu, type MenuPosition } from \"../menu/Menu\";\nimport { MenuItem } from \"../menu/MenuItem\";\n\n/** An item a host adds to an icon's context menu, below Open. */\nexport interface DesktopIconMenuItem {\n disabled?: boolean | undefined;\n icon?: WindowingIcon | undefined;\n id: string;\n label: string;\n onSelect: () => void;\n}\n\n/** An icon's context menu: Open, then the host's items. Each closes it. */\nexport function DesktopIconMenu({\n icon,\n items,\n onClose,\n onOpen,\n position,\n}: {\n icon: WindowingIcon | undefined;\n items: ReadonlyArray<DesktopIconMenuItem>;\n onClose: () => void;\n onOpen: () => void;\n position: MenuPosition;\n}) {\n return (\n <Menu direction=\"down\" onClose={onClose} position={position}>\n <MenuItem\n icon={icon}\n label=\"Open\"\n onClick={() => {\n onClose();\n onOpen();\n }}\n />\n {items.map((item) => (\n <MenuItem\n disabled={item.disabled}\n icon={item.icon}\n key={item.id}\n label={item.label}\n onClick={() => {\n onClose();\n item.onSelect();\n }}\n />\n ))}\n </Menu>\n );\n}\n"]}
1
+ {"version":3,"file":"DesktopIconMenu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/desktop/DesktopIconMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5C,2EAA2E;AAC3E,MAAM,UAAU,eAAe,CAAC,EAC9B,EAAE,EACF,IAAI,EACJ,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GAQT;IACC,OAAO,CACL,MAAC,IAAI,IAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,aACjE,KAAC,QAAQ,IACP,IAAI,EAAE,IAAI,EACV,KAAK,EAAC,MAAM,EACZ,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,EAAE,CAAC;oBACV,MAAM,EAAE,CAAC;gBACX,CAAC,GACD,EACD,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,QAAQ,IACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EAEf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,EAAE,CAAC;oBACV,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC,IALI,IAAI,CAAC,EAAE,CAMZ,CACH,CAAC,IACG,CACR,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { Menu, type MenuPosition } from \"../menu/Menu\";\nimport { MenuItem } from \"../menu/MenuItem\";\n\n/** An item a host adds to an icon's context menu, below Open. */\nexport interface DesktopIconMenuItem {\n disabled?: boolean | undefined;\n icon?: WindowingIcon | undefined;\n id: string;\n label: string;\n onSelect: () => void;\n}\n\n/** An icon's context menu: Open, then the host's items. Each closes it. */\nexport function DesktopIconMenu({\n id,\n icon,\n items,\n onClose,\n onOpen,\n position,\n}: {\n id?: string | undefined;\n icon: WindowingIcon | undefined;\n items: ReadonlyArray<DesktopIconMenuItem>;\n onClose: () => void;\n onOpen: () => void;\n position: MenuPosition;\n}) {\n return (\n <Menu id={id} direction=\"down\" onClose={onClose} position={position}>\n <MenuItem\n icon={icon}\n label=\"Open\"\n onClick={() => {\n onClose();\n onOpen();\n }}\n />\n {items.map((item) => (\n <MenuItem\n disabled={item.disabled}\n icon={item.icon}\n key={item.id}\n label={item.label}\n onClick={() => {\n onClose();\n item.onSelect();\n }}\n />\n ))}\n </Menu>\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { WindowingIcon } from "../icons/windowingIcon.js";
2
+ interface AppSwitchProps {
3
+ checked: boolean;
4
+ className: string;
5
+ icon?: WindowingIcon | undefined;
6
+ onChange: (checked: boolean) => void;
7
+ title: string;
8
+ }
9
+ export declare function AppSwitch({ checked, className, icon: Icon, onChange, title, }: AppSwitchProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function AppSwitch({ checked, className, icon: Icon, onChange, title, }) {
3
+ return (_jsxs("label", { className: `display-properties-app-switch ${className}`, children: [Icon && (_jsx(Icon, { className: `${className}-icon`, "aria-hidden": "true", focusable: "false", size: 16 })), _jsx("span", { className: "display-properties-label", children: title }), _jsx("input", { "aria-checked": checked, checked: checked, className: "display-properties-switch", onChange: (event) => onChange(event.currentTarget.checked), role: "switch", type: "checkbox" })] }));
4
+ }
5
+ //# sourceMappingURL=AppSwitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppSwitch.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/display/AppSwitch.tsx"],"names":[],"mappings":";AAUA,MAAM,UAAU,SAAS,CAAC,EACxB,OAAO,EACP,SAAS,EACT,IAAI,EAAE,IAAI,EACV,QAAQ,EACR,KAAK,GACU;IACf,OAAO,CACL,iBAAO,SAAS,EAAE,iCAAiC,SAAS,EAAE,aAC3D,IAAI,IAAI,CACP,KAAC,IAAI,IACH,SAAS,EAAE,GAAG,SAAS,OAAO,iBAClB,MAAM,EAClB,SAAS,EAAC,OAAO,EACjB,IAAI,EAAE,EAAE,GACR,CACH,EACD,eAAM,SAAS,EAAC,0BAA0B,YAAE,KAAK,GAAQ,EACzD,gCACgB,OAAO,EACrB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,2BAA2B,EACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,EAC1D,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,UAAU,GACf,IACI,CACT,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowingIcon } from \"../icons/windowingIcon\";\n\ninterface AppSwitchProps {\n checked: boolean;\n className: string;\n icon?: WindowingIcon | undefined;\n onChange: (checked: boolean) => void;\n title: string;\n}\n\nexport function AppSwitch({\n checked,\n className,\n icon: Icon,\n onChange,\n title,\n}: AppSwitchProps) {\n return (\n <label className={`display-properties-app-switch ${className}`}>\n {Icon && (\n <Icon\n className={`${className}-icon`}\n aria-hidden=\"true\"\n focusable=\"false\"\n size={16}\n />\n )}\n <span className=\"display-properties-label\">{title}</span>\n <input\n aria-checked={checked}\n checked={checked}\n className=\"display-properties-switch\"\n onChange={(event) => onChange(event.currentTarget.checked)}\n role=\"switch\"\n type=\"checkbox\"\n />\n </label>\n );\n}\n"]}
@@ -113,16 +113,18 @@
113
113
  white-space: nowrap;
114
114
  }
115
115
 
116
- /* System Tray: one row per tray app, its name and an on/off switch. The rows
116
+ /* Each app has one row with its name and an on/off switch. The rows
117
117
  * stay narrow so a wide window does not set a switch far from its name. */
118
- .display-properties-tray-apps {
118
+ .display-properties-tray-apps,
119
+ .display-properties-menu-apps {
119
120
  display: flex;
120
121
  flex-direction: column;
121
122
  gap: var(--space-2xs);
122
123
  max-width: 24rem;
123
124
  }
124
125
 
125
- .display-properties-tray-app {
126
+ .display-properties-app-switch {
127
+ min-width: 0;
126
128
  display: flex;
127
129
  align-items: center;
128
130
  gap: var(--space-sm);
@@ -131,15 +133,20 @@
131
133
  cursor: pointer;
132
134
  }
133
135
 
134
- .display-properties-tray-app:hover {
136
+ .display-properties-app-switch:hover {
135
137
  background: var(--app-hover-surface);
136
138
  }
137
139
 
138
- .display-properties-tray-app .display-properties-label {
140
+ .display-properties-app-switch .display-properties-label {
139
141
  flex: 1 1 auto;
140
142
  }
141
143
 
142
- .display-properties-tray-app-icon {
144
+ .display-properties-menu-app .display-properties-label {
145
+ overflow-wrap: anywhere;
146
+ white-space: normal;
147
+ }
148
+
149
+ .display-properties-app-switch svg {
143
150
  flex: 0 0 auto;
144
151
  }
145
152
 
@@ -7,4 +7,6 @@
7
7
  * apps, is left out. It has no toolbar actions, so its window shows no
8
8
  * toolbar row.
9
9
  */
10
- export declare function DisplayProperties(): import("react").JSX.Element;
10
+ export declare function DisplayProperties({ startMenuAppIds, }?: {
11
+ startMenuAppIds?: readonly string[];
12
+ }): import("react").JSX.Element;
@@ -1,10 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
+ import { resolveLauncherOrder } from "../launcher/launcherDefinition.js";
4
+ import { useOptionalStartMenuPreferences } from "../menu/StartMenuPreferencesProvider.js";
3
5
  import { useOptionalTheme } from "../theme/ThemeProvider.js";
4
6
  import { useOptionalSystemTray } from "../tray/SystemTrayProvider.js";
5
7
  import { useOptionalWallpaper } from "../wallpaper/WallpaperProvider.js";
6
8
  import { wallpaperStyle } from "../wallpaper/wallpapers.js";
7
9
  import { useSuppressWindowToolbar } from "../window/CurrentWindowContext.js";
10
+ import { AppSwitch } from "./AppSwitch.js";
8
11
  import "../wallpaper/Wallpaper.css";
9
12
  import "./DisplayProperties.css";
10
13
  function BackgroundSection() {
@@ -34,8 +37,19 @@ function SystemTraySection() {
34
37
  if (!app) {
35
38
  return null;
36
39
  }
37
- const { icon: Icon, title } = app;
38
- return (_jsxs("label", { className: "display-properties-tray-app", children: [Icon && (_jsx(Icon, { "aria-hidden": "true", className: "display-properties-tray-app-icon", focusable: "false", size: 16 })), _jsx("span", { className: "display-properties-label", children: title }), _jsx("input", { "aria-checked": isEnabled(id), checked: isEnabled(id), className: "display-properties-switch", onChange: (event) => setEnabled(id, event.currentTarget.checked), role: "switch", type: "checkbox" })] }, id));
40
+ return (_jsx(AppSwitch, { className: "display-properties-tray-app", icon: app.icon, title: app.title, checked: isEnabled(id), onChange: (enabled) => setEnabled(id, enabled) }, id));
41
+ }) })] }));
42
+ }
43
+ function StartMenuSection({ appIds, }) {
44
+ const preferences = useOptionalStartMenuPreferences();
45
+ if (!preferences)
46
+ return null;
47
+ const ids = (appIds ?? resolveLauncherOrder(preferences.definition)).filter((id) => preferences.configurableIds.includes(id));
48
+ if (!ids.length)
49
+ return null;
50
+ return (_jsxs("fieldset", { className: "display-properties-section", children: [_jsx("legend", { children: "Start menu" }), _jsx("div", { className: "display-properties-menu-apps", children: ids.map((id) => {
51
+ const app = preferences.definition.apps[id];
52
+ return (app && (_jsx(AppSwitch, { icon: app.icon, className: "display-properties-menu-app", title: app.iconLabel ?? app.title, checked: preferences.isVisible(id), onChange: (visible) => preferences.setVisible(id, visible) }, id)));
39
53
  }) })] }));
40
54
  }
41
55
  /**
@@ -47,8 +61,8 @@ function SystemTraySection() {
47
61
  * apps, is left out. It has no toolbar actions, so its window shows no
48
62
  * toolbar row.
49
63
  */
50
- export function DisplayProperties() {
64
+ export function DisplayProperties({ startMenuAppIds, } = {}) {
51
65
  useSuppressWindowToolbar(true);
52
- return (_jsxs("div", { className: "display-properties", children: [_jsx(BackgroundSection, {}), _jsx(ThemeSection, {}), _jsx(SystemTraySection, {})] }));
66
+ return (_jsxs("div", { className: "display-properties", children: [_jsx(BackgroundSection, {}), _jsx(ThemeSection, {}), _jsx(SystemTraySection, {}), _jsx(StartMenuSection, { appIds: startMenuAppIds })] }));
53
67
  }
54
68
  //# sourceMappingURL=DisplayProperties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayProperties.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/display/DisplayProperties.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AAEjC,SAAS,iBAAiB;IACxB,MAAM,SAAS,GAAG,oBAAoB,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,oBAAU,SAAS,EAAC,4BAA4B,aAC9C,0CAA2B,EAC3B,cAAK,SAAS,EAAC,+BAA+B,YAC3C,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACpC,iBAAO,SAAS,EAAC,8BAA8B,aAC7C,gBACE,OAAO,EAAE,MAAM,CAAC,EAAE,KAAK,SAAS,CAAC,eAAe,CAAC,EAAE,EACnD,SAAS,EAAC,0BAA0B,EACpC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,EACjD,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,MAAM,CAAC,EA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CAAC;IAC/B,OAAO,CACL,eAAK,SAAS,EAAC,oBAAoB,aACjC,KAAC,iBAAiB,KAAG,EACrB,KAAC,YAAY,KAAG,EAChB,KAAC,iBAAiB,KAAG,IACjB,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useId } from \"react\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider\";\nimport { useOptionalSystemTray } from \"../tray/SystemTrayProvider\";\nimport { useOptionalWallpaper } from \"../wallpaper/WallpaperProvider\";\nimport { wallpaperStyle } from \"../wallpaper/wallpapers\";\nimport { useSuppressWindowToolbar } from \"../window/CurrentWindowContext\";\nimport \"../wallpaper/Wallpaper.css\";\nimport \"./DisplayProperties.css\";\n\nfunction BackgroundSection() {\n const wallpaper = useOptionalWallpaper();\n const name = useId();\n if (!wallpaper) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Background</legend>\n <div className=\"display-properties-wallpapers\">\n {wallpaper.wallpapers.map((option) => (\n <label className=\"display-properties-wallpaper\" key={option.id}>\n <input\n checked={option.id === wallpaper.activeWallpaper.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => wallpaper.setWallpaper(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span\n aria-hidden=\"true\"\n className=\"display-properties-swatch wallpaper-pattern\"\n data-pattern={option.tile ? \"\" : undefined}\n style={wallpaperStyle(option)}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction ThemeSection() {\n const theme = useOptionalTheme();\n const name = useId();\n if (!theme || theme.themes.length < 2) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Theme</legend>\n <div className=\"display-properties-themes\">\n {theme.themes.map((option) => (\n <label className=\"display-properties-theme\" key={option.id}>\n <input\n checked={option.id === theme.activeTheme.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => theme.setTheme(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction SystemTraySection() {\n const tray = useOptionalSystemTray();\n if (!tray || tray.definition.order.length === 0) {\n return null;\n }\n const { definition, isEnabled, setEnabled } = tray;\n return (\n <fieldset className=\"display-properties-section\">\n <legend>System Tray</legend>\n <div className=\"display-properties-tray-apps\">\n {definition.order.map((id) => {\n const app = definition.apps[id];\n if (!app) {\n return null;\n }\n const { icon: Icon, title } = app;\n return (\n <label className=\"display-properties-tray-app\" key={id}>\n {Icon && (\n <Icon\n aria-hidden=\"true\"\n className=\"display-properties-tray-app-icon\"\n focusable=\"false\"\n size={16}\n />\n )}\n <span className=\"display-properties-label\">{title}</span>\n <input\n aria-checked={isEnabled(id)}\n checked={isEnabled(id)}\n className=\"display-properties-switch\"\n onChange={(event) =>\n setEnabled(id, event.currentTarget.checked)\n }\n role=\"switch\"\n type=\"checkbox\"\n />\n </label>\n );\n })}\n </div>\n </fieldset>\n );\n}\n\n/**\n * The display settings, for a host's Display Properties mini-app: the\n * desktop's background, from the nearest {@link WallpaperProvider}; the color\n * theme, from the nearest {@link ThemeProvider}; and a switch per tray app,\n * from the nearest {@link SystemTrayProvider}. Each choice applies at once. A\n * section whose provider is missing, or that offers one theme or no tray\n * apps, is left out. It has no toolbar actions, so its window shows no\n * toolbar row.\n */\nexport function DisplayProperties() {\n useSuppressWindowToolbar(true);\n return (\n <div className=\"display-properties\">\n <BackgroundSection />\n <ThemeSection />\n <SystemTraySection />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"DisplayProperties.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/display/DisplayProperties.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,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L,KAAC,SAAS,IAER,IAAI,EAAE,GAAG,CAAC,IAAI,EACd,SAAS,EAAC,6BAA6B,EACvC,KAAK,EAAE,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,KAAK,EACjC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC,EAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,IALrD,EAAE,CAMP,CACH,CACF,CAAC;gBACJ,CAAC,CAAC,GACE,IACG,CACZ,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,eAAe,MAGb,EAAE;IACJ,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,CACL,eAAK,SAAS,EAAC,oBAAoB,aACjC,KAAC,iBAAiB,KAAG,EACrB,KAAC,YAAY,KAAG,EAChB,KAAC,iBAAiB,KAAG,EACrB,KAAC,gBAAgB,IAAC,MAAM,EAAE,eAAe,GAAI,IACzC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useId } from \"react\";\nimport { resolveLauncherOrder } from \"../launcher/launcherDefinition\";\nimport { useOptionalStartMenuPreferences } from \"../menu/StartMenuPreferencesProvider\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider\";\nimport { useOptionalSystemTray } from \"../tray/SystemTrayProvider\";\nimport { useOptionalWallpaper } from \"../wallpaper/WallpaperProvider\";\nimport { wallpaperStyle } from \"../wallpaper/wallpapers\";\nimport { useSuppressWindowToolbar } from \"../window/CurrentWindowContext\";\nimport { AppSwitch } from \"./AppSwitch\";\nimport \"../wallpaper/Wallpaper.css\";\nimport \"./DisplayProperties.css\";\n\nfunction BackgroundSection() {\n const wallpaper = useOptionalWallpaper();\n const name = useId();\n if (!wallpaper) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Background</legend>\n <div className=\"display-properties-wallpapers\">\n {wallpaper.wallpapers.map((option) => (\n <label className=\"display-properties-wallpaper\" key={option.id}>\n <input\n checked={option.id === wallpaper.activeWallpaper.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => wallpaper.setWallpaper(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span\n aria-hidden=\"true\"\n className=\"display-properties-swatch wallpaper-pattern\"\n data-pattern={option.tile ? \"\" : undefined}\n style={wallpaperStyle(option)}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction ThemeSection() {\n const theme = useOptionalTheme();\n const name = useId();\n if (!theme || theme.themes.length < 2) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Theme</legend>\n <div className=\"display-properties-themes\">\n {theme.themes.map((option) => (\n <label className=\"display-properties-theme\" key={option.id}>\n <input\n checked={option.id === theme.activeTheme.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => theme.setTheme(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction SystemTraySection() {\n const tray = useOptionalSystemTray();\n if (!tray || tray.definition.order.length === 0) {\n return null;\n }\n const { definition, isEnabled, setEnabled } = tray;\n return (\n <fieldset className=\"display-properties-section\">\n <legend>System Tray</legend>\n <div className=\"display-properties-tray-apps\">\n {definition.order.map((id) => {\n const app = definition.apps[id];\n if (!app) {\n return null;\n }\n return (\n <AppSwitch\n key={id}\n className=\"display-properties-tray-app\"\n icon={app.icon}\n title={app.title}\n checked={isEnabled(id)}\n onChange={(enabled) => setEnabled(id, enabled)}\n />\n );\n })}\n </div>\n </fieldset>\n );\n}\n\nfunction StartMenuSection({\n appIds,\n}: {\n appIds?: readonly string[] | undefined;\n}) {\n const preferences = useOptionalStartMenuPreferences();\n if (!preferences) return null;\n const ids = (appIds ?? resolveLauncherOrder(preferences.definition)).filter(\n (id) => preferences.configurableIds.includes(id),\n );\n if (!ids.length) return null;\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Start menu</legend>\n <div className=\"display-properties-menu-apps\">\n {ids.map((id) => {\n const app = preferences.definition.apps[id];\n return (\n app && (\n <AppSwitch\n key={id}\n icon={app.icon}\n className=\"display-properties-menu-app\"\n title={app.iconLabel ?? app.title}\n checked={preferences.isVisible(id)}\n onChange={(visible) => preferences.setVisible(id, visible)}\n />\n )\n );\n })}\n </div>\n </fieldset>\n );\n}\n\n/**\n * The display settings, for a host's Display Properties mini-app: the\n * desktop's background, from the nearest {@link WallpaperProvider}; the color\n * theme, from the nearest {@link ThemeProvider}; and a switch per tray app,\n * from the nearest {@link SystemTrayProvider}. Each choice applies at once. A\n * section whose provider is missing, or that offers one theme or no tray\n * apps, is left out. It has no toolbar actions, so its window shows no\n * toolbar row.\n */\nexport function DisplayProperties({\n startMenuAppIds,\n}: {\n startMenuAppIds?: readonly string[];\n} = {}) {\n useSuppressWindowToolbar(true);\n return (\n <div className=\"display-properties\">\n <BackgroundSection />\n <ThemeSection />\n <SystemTraySection />\n <StartMenuSection appIds={startMenuAppIds} />\n </div>\n );\n}\n"]}
package/docs/launcher.md CHANGED
@@ -34,6 +34,30 @@ host's own button styles apply alone. A menu that needs more than a list passes
34
34
  and a `close` callback. Tearleads' footer does this in
35
35
  [`packages/app/src/shell/pane/footer/PaneFooter.tsx`][pane-footer].
36
36
 
37
+ ### Start menu preferences
38
+
39
+ Wrap the desktop and routed shells in a shared provider to let users choose
40
+ which mini-apps appear in their launchers.
41
+
42
+ ```tsx
43
+ <StartMenuPreferencesProvider definition={LAUNCHER} storageKey="myApp.startMenu">
44
+ <Desktop />
45
+ </StartMenuPreferencesProvider>
46
+ ```
47
+
48
+ Each mini-app can set `startMenuVisibility` in its launcher definition.
49
+ The default is `"visible"`. Use `"hidden"` to let users opt in or `"pinned"`
50
+ to keep an entry such as Settings available. The provider uses launcher order
51
+ for the default switches. It saves each choice under the host's storage key
52
+ prefix and shares changes across tabs.
53
+
54
+ `DisplayProperties` renders the switches and accepts `startMenuAppIds` to match
55
+ a custom launcher's eligible apps and order. `StartMenu` matches item IDs to
56
+ mini-app IDs, and `RoutedPane` filters its launcher links. A custom
57
+ `renderMenu` can filter app entries with `useStartMenuPreferences().isVisible`.
58
+ Call `reset()` on the same preferences to restore the host's defaults.
59
+ Desktop icons, direct routes, and open windows remain available.
60
+
37
61
  ## Launching mini-apps
38
62
 
39
63
  A launcher application is a set of mini-apps, defined once and shown either in
package/index.d.ts CHANGED
@@ -27,6 +27,7 @@ export { type RoutedLayoutTier, useRoutedLayoutTier, } from "./launcher/useRoute
27
27
  export { Menu, type MenuPosition } from "./menu/Menu.js";
28
28
  export { MenuItem, type MenuItemProps } from "./menu/MenuItem.js";
29
29
  export { StartMenu, type StartMenuItem, type StartMenuProps, } from "./menu/StartMenu.js";
30
+ export { StartMenuPreferencesProvider, useOptionalStartMenuPreferences, useStartMenuPreferences, } from "./menu/StartMenuPreferencesProvider.js";
30
31
  export { type ContextMenuState, useContextMenuPositionState, useContextMenuState, } from "./menu/useContextMenuState.js";
31
32
  export { useLongPress } from "./menu/useLongPress.js";
32
33
  export { RoutedPane, type RoutedPaneProps } from "./routed/RoutedPane.js";
package/index.js CHANGED
@@ -32,6 +32,7 @@ export { useRoutedLayoutTier, } from "./launcher/useRoutedLayoutTier.js";
32
32
  export { Menu } from "./menu/Menu.js";
33
33
  export { MenuItem } from "./menu/MenuItem.js";
34
34
  export { StartMenu, } from "./menu/StartMenu.js";
35
+ export { StartMenuPreferencesProvider, useOptionalStartMenuPreferences, useStartMenuPreferences, } from "./menu/StartMenuPreferencesProvider.js";
35
36
  export { useContextMenuPositionState, useContextMenuState, } from "./menu/useContextMenuState.js";
36
37
  export { useLongPress } from "./menu/useLongPress.js";
37
38
  export { RoutedPane } from "./routed/RoutedPane.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.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B,CAAC;AAKnC,OAAO,EACL,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAA8B,MAAM,iBAAiB,CAAC;AACrE,OAAO,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"]}
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,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAEL,0BAA0B,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,eAAe,EAGf,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAwB,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,2CAA2C,CA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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 StartMenuPreferencesProvider,\n useOptionalStartMenuPreferences,\n useStartMenuPreferences,\n} from \"./menu/StartMenuPreferencesProvider\";\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"]}
@@ -21,6 +21,8 @@ export interface MiniAppDefinition {
21
21
  * the sidebar hidden.
22
22
  */
23
23
  initialShowSidebar?: boolean | undefined;
24
+ /** Initial Start menu visibility. Defaults to visible. Pinned entries stay visible. */
25
+ startMenuVisibility?: "visible" | "hidden" | "pinned" | undefined;
24
26
  /** The window title and routed content heading. */
25
27
  title: string;
26
28
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"launcherDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/launcherDefinition.ts"],"names":[],"mappings":"AAwDA,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAC7B,UAAqC,EACrC,KAAgC;IAEhC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,oBAAoB,CAClC,UAAqC;IAErC,MAAM,KAAK,GACT,UAAU,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,wBAAwB,CACtC,UAAqC;IAErC,IACE,UAAU,CAAC,SAAS,KAAK,SAAS;QAClC,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACjD,CAAC;QACD,OAAO,UAAU,CAAC,SAAS,CAAC;IAC9B,CAAC;IACD,OAAO,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACrD,CAAC","sourcesContent":["import type { ComponentType } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport type { WindowSize } from \"../window/WindowStateProvider\";\n\n/** One app a launcher opens: in a window, or as the routed shell's page. */\nexport interface MiniAppDefinition {\n /**\n * Builds the app's component. A window calls it when it opens, and the\n * routed shell when it shows the app, so each gets its own component.\n */\n createComponent: () => ComponentType;\n /** The app's glyph in the launchers and the taskbar. */\n icon?: WindowingIcon | undefined;\n /**\n * Label for desktop icons and launcher navigation. Defaults to `title`.\n * Does not change window titles, routed headings, app ids, or routes.\n */\n iconLabel?: string | undefined;\n /**\n * Whether the app's sidebar starts shown, in a new window and on the routed\n * shell's tablet tier. Defaults to shown. The phone tier always starts with\n * the sidebar hidden.\n */\n initialShowSidebar?: boolean | undefined;\n /** The window title and routed content heading. */\n title: string;\n /**\n * The size a new window opens at, in CSS pixels. Defaults to the\n * stylesheet's window size.\n */\n windowSize?: WindowSize | undefined;\n}\n\n/**\n * A launcher application: the mini-apps it can open, the order its launchers\n * list them in, the ones the windowed desktop opens on entry, and the one the\n * routed shell shows at the root route.\n */\nexport interface LauncherDefinition<AppId extends string = string> {\n apps: Readonly<Record<AppId, MiniAppDefinition>>;\n /**\n * Open, in this order, when entering windowed mode with no windows,\n * including on mount, so the last opens in front. Closing the last window\n * leaves the desktop empty until the next entry. Omit to leave window\n * startup to the host. Unknown app ids are skipped.\n */\n defaultWindowAppIds?: ReadonlyArray<AppId> | undefined;\n /** Shown at the root route. Defaults to the first app in `order`. */\n homeAppId?: AppId | undefined;\n /**\n * The order the launchers list the apps in. Ids with no app in `apps` are\n * skipped. Defaults to the order of `apps`' keys.\n */\n order?: ReadonlyArray<AppId> | undefined;\n}\n\n/** Narrows an opaque window `appId` to one of the launcher's apps. */\nexport function isLauncherAppId<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n value: string | null | undefined,\n): value is AppId {\n return typeof value === \"string\" && Object.hasOwn(definition.apps, value);\n}\n\n/** The launcher's apps in the order its launchers list them. */\nexport function resolveLauncherOrder<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n): ReadonlyArray<AppId> {\n const order: ReadonlyArray<string> =\n definition.order ?? Object.keys(definition.apps);\n return order.filter((appId) => isLauncherAppId(definition, appId));\n}\n\n/** The app the routed shell shows at the root route, if the launcher has any. */\nexport function resolveLauncherHomeAppId<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n): AppId | null {\n if (\n definition.homeAppId !== undefined &&\n isLauncherAppId(definition, definition.homeAppId)\n ) {\n return definition.homeAppId;\n }\n return resolveLauncherOrder(definition)[0] ?? null;\n}\n"]}
1
+ {"version":3,"file":"launcherDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/launcherDefinition.ts"],"names":[],"mappings":"AA0DA,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAC7B,UAAqC,EACrC,KAAgC;IAEhC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,oBAAoB,CAClC,UAAqC;IAErC,MAAM,KAAK,GACT,UAAU,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,wBAAwB,CACtC,UAAqC;IAErC,IACE,UAAU,CAAC,SAAS,KAAK,SAAS;QAClC,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACjD,CAAC;QACD,OAAO,UAAU,CAAC,SAAS,CAAC;IAC9B,CAAC;IACD,OAAO,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACrD,CAAC","sourcesContent":["import type { ComponentType } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport type { WindowSize } from \"../window/WindowStateProvider\";\n\n/** One app a launcher opens: in a window, or as the routed shell's page. */\nexport interface MiniAppDefinition {\n /**\n * Builds the app's component. A window calls it when it opens, and the\n * routed shell when it shows the app, so each gets its own component.\n */\n createComponent: () => ComponentType;\n /** The app's glyph in the launchers and the taskbar. */\n icon?: WindowingIcon | undefined;\n /**\n * Label for desktop icons and launcher navigation. Defaults to `title`.\n * Does not change window titles, routed headings, app ids, or routes.\n */\n iconLabel?: string | undefined;\n /**\n * Whether the app's sidebar starts shown, in a new window and on the routed\n * shell's tablet tier. Defaults to shown. The phone tier always starts with\n * the sidebar hidden.\n */\n initialShowSidebar?: boolean | undefined;\n /** Initial Start menu visibility. Defaults to visible. Pinned entries stay visible. */\n startMenuVisibility?: \"visible\" | \"hidden\" | \"pinned\" | undefined;\n /** The window title and routed content heading. */\n title: string;\n /**\n * The size a new window opens at, in CSS pixels. Defaults to the\n * stylesheet's window size.\n */\n windowSize?: WindowSize | undefined;\n}\n\n/**\n * A launcher application: the mini-apps it can open, the order its launchers\n * list them in, the ones the windowed desktop opens on entry, and the one the\n * routed shell shows at the root route.\n */\nexport interface LauncherDefinition<AppId extends string = string> {\n apps: Readonly<Record<AppId, MiniAppDefinition>>;\n /**\n * Open, in this order, when entering windowed mode with no windows,\n * including on mount, so the last opens in front. Closing the last window\n * leaves the desktop empty until the next entry. Omit to leave window\n * startup to the host. Unknown app ids are skipped.\n */\n defaultWindowAppIds?: ReadonlyArray<AppId> | undefined;\n /** Shown at the root route. Defaults to the first app in `order`. */\n homeAppId?: AppId | undefined;\n /**\n * The order the launchers list the apps in. Ids with no app in `apps` are\n * skipped. Defaults to the order of `apps`' keys.\n */\n order?: ReadonlyArray<AppId> | undefined;\n}\n\n/** Narrows an opaque window `appId` to one of the launcher's apps. */\nexport function isLauncherAppId<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n value: string | null | undefined,\n): value is AppId {\n return typeof value === \"string\" && Object.hasOwn(definition.apps, value);\n}\n\n/** The launcher's apps in the order its launchers list them. */\nexport function resolveLauncherOrder<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n): ReadonlyArray<AppId> {\n const order: ReadonlyArray<string> =\n definition.order ?? Object.keys(definition.apps);\n return order.filter((appId) => isLauncherAppId(definition, appId));\n}\n\n/** The app the routed shell shows at the root route, if the launcher has any. */\nexport function resolveLauncherHomeAppId<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n): AppId | null {\n if (\n definition.homeAppId !== undefined &&\n isLauncherAppId(definition, definition.homeAppId)\n ) {\n return definition.homeAppId;\n }\n return resolveLauncherOrder(definition)[0] ?? null;\n}\n"]}
@@ -1,7 +1,8 @@
1
+ export declare function getLocalStorage(): Pick<Storage, "getItem" | "setItem" | "removeItem"> | null;
1
2
  /**
2
3
  * Loads a stored preference, funneling every failure mode (no storage,
3
4
  * storage throws, `parse` throws) into `parse(null)` so the parser's
4
5
  * null-branch is the single source of the fallback value.
5
6
  */
6
7
  export declare function loadStoredPreference<T>(storageKey: string, parse: (stored: string | null) => T): T;
7
- export declare function saveStoredPreference(storageKey: string, value: string): void;
8
+ export declare function saveStoredPreference(storageKey: string, value: string | null): boolean;
@@ -1,7 +1,7 @@
1
1
  // Best-effort localStorage persistence for the launcher's display preferences
2
2
  // (the navigation-mode choice, the launcher's placement). Unavailable or
3
3
  // throwing storage degrades to the caller's fallback.
4
- function getLocalStorage() {
4
+ export function getLocalStorage() {
5
5
  try {
6
6
  return typeof globalThis.localStorage === "undefined"
7
7
  ? null
@@ -31,13 +31,17 @@ export function loadStoredPreference(storageKey, parse) {
31
31
  export function saveStoredPreference(storageKey, value) {
32
32
  const storage = getLocalStorage();
33
33
  if (!storage) {
34
- return;
34
+ return false;
35
35
  }
36
36
  try {
37
- storage.setItem(storageKey, value);
37
+ if (value === null)
38
+ storage.removeItem(storageKey);
39
+ else
40
+ storage.setItem(storageKey, value);
41
+ return true;
38
42
  }
39
43
  catch {
40
- // Persistence is best-effort; ignore disabled storage and quota errors.
44
+ return false;
41
45
  }
42
46
  }
43
47
  //# sourceMappingURL=storedPreference.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storedPreference.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/storedPreference.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,yEAAyE;AACzE,sDAAsD;AAEtD,SAAS,eAAe;IACtB,IAAI,CAAC;QACH,OAAO,OAAO,UAAU,CAAC,YAAY,KAAK,WAAW;YACnD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,KAAmC;IAEnC,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAkB,EAAE,KAAa;IACpE,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;IAC1E,CAAC;AACH,CAAC","sourcesContent":["// Best-effort localStorage persistence for the launcher's display preferences\n// (the navigation-mode choice, the launcher's placement). Unavailable or\n// throwing storage degrades to the caller's fallback.\n\nfunction getLocalStorage(): Pick<Storage, \"getItem\" | \"setItem\"> | null {\n try {\n return typeof globalThis.localStorage === \"undefined\"\n ? null\n : globalThis.localStorage;\n } catch {\n return null;\n }\n}\n\n/**\n * Loads a stored preference, funneling every failure mode (no storage,\n * storage throws, `parse` throws) into `parse(null)` so the parser's\n * null-branch is the single source of the fallback value.\n */\nexport function loadStoredPreference<T>(\n storageKey: string,\n parse: (stored: string | null) => T,\n): T {\n const storage = getLocalStorage();\n if (!storage) {\n return parse(null);\n }\n try {\n return parse(storage.getItem(storageKey));\n } catch {\n return parse(null);\n }\n}\n\nexport function saveStoredPreference(storageKey: string, value: string): void {\n const storage = getLocalStorage();\n if (!storage) {\n return;\n }\n try {\n storage.setItem(storageKey, value);\n } catch {\n // Persistence is best-effort; ignore disabled storage and quota errors.\n }\n}\n"]}
1
+ {"version":3,"file":"storedPreference.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/storedPreference.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,yEAAyE;AACzE,sDAAsD;AAEtD,MAAM,UAAU,eAAe;IAI7B,IAAI,CAAC;QACH,OAAO,OAAO,UAAU,CAAC,YAAY,KAAK,WAAW;YACnD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,KAAmC;IAEnC,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,KAAoB;IAEpB,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;;YAC9C,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["// Best-effort localStorage persistence for the launcher's display preferences\n// (the navigation-mode choice, the launcher's placement). Unavailable or\n// throwing storage degrades to the caller's fallback.\n\nexport function getLocalStorage(): Pick<\n Storage,\n \"getItem\" | \"setItem\" | \"removeItem\"\n> | null {\n try {\n return typeof globalThis.localStorage === \"undefined\"\n ? null\n : globalThis.localStorage;\n } catch {\n return null;\n }\n}\n\n/**\n * Loads a stored preference, funneling every failure mode (no storage,\n * storage throws, `parse` throws) into `parse(null)` so the parser's\n * null-branch is the single source of the fallback value.\n */\nexport function loadStoredPreference<T>(\n storageKey: string,\n parse: (stored: string | null) => T,\n): T {\n const storage = getLocalStorage();\n if (!storage) {\n return parse(null);\n }\n try {\n return parse(storage.getItem(storageKey));\n } catch {\n return parse(null);\n }\n}\n\nexport function saveStoredPreference(\n storageKey: string,\n value: string | null,\n): boolean {\n const storage = getLocalStorage();\n if (!storage) {\n return false;\n }\n try {\n if (value === null) storage.removeItem(storageKey);\n else storage.setItem(storageKey, value);\n return true;\n } catch {\n return false;\n }\n}\n"]}
@@ -1,8 +1,9 @@
1
- import type { MouseEvent } from "react";
1
+ import { type MouseEvent } from "react";
2
2
  import type { WindowingIcon } from "../icons/windowingIcon.js";
3
3
  /** Secondary activation offers the same Open action as the entry itself. */
4
4
  export declare function useLauncherEntryMenu(icon: WindowingIcon | undefined, onOpen: () => void): {
5
5
  triggerProps: {
6
+ "aria-controls": string | undefined;
6
7
  onContextMenu(event: MouseEvent<HTMLElement>): void;
7
8
  onPointerCancel: (event: import("react").PointerEvent<HTMLElement>) => void;
8
9
  onPointerDown: (event: import("react").PointerEvent<HTMLElement>) => void;
@@ -1,20 +1,23 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useId } from "react";
2
3
  import { DesktopIconMenu } from "../desktop/DesktopIconMenu.js";
3
4
  import { useContextMenuState } from "../menu/useContextMenuState.js";
4
5
  import { useLongPress } from "../menu/useLongPress.js";
5
6
  /** Secondary activation offers the same Open action as the entry itself. */
6
7
  export function useLauncherEntryMenu(icon, onOpen) {
8
+ const menuId = useId();
7
9
  const { closeContextMenu, contextMenu, openContextMenu } = useContextMenuState();
8
10
  const longPress = useLongPress(true, { emulateRightClick: true });
9
11
  return {
10
12
  triggerProps: {
11
13
  ...longPress,
14
+ "aria-controls": contextMenu ? menuId : undefined,
12
15
  onContextMenu(event) {
13
16
  event.currentTarget.focus({ preventScroll: true });
14
17
  openContextMenu(event, null);
15
18
  },
16
19
  },
17
- menu: contextMenu && (_jsx(DesktopIconMenu, { icon: icon, items: [], onClose: closeContextMenu, onOpen: onOpen, position: contextMenu.position })),
20
+ menu: contextMenu && (_jsx(DesktopIconMenu, { id: menuId, icon: icon, items: [], onClose: closeContextMenu, onOpen: onOpen, position: contextMenu.position })),
18
21
  };
19
22
  }
20
23
  //# sourceMappingURL=useLauncherEntryMenu.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"useLauncherEntryMenu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/useLauncherEntryMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,KAAK,EAAE,MAAM,OAAO,CAAC;AAC/C,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,MAAM,GAAG,KAAK,EAAE,CAAC;IACvB,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,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YACjD,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,EAAE,EAAE,MAAM,EACV,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, useId } 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 menuId = useId();\n const { closeContextMenu, contextMenu, openContextMenu } =\n useContextMenuState<null>();\n const longPress = useLongPress(true, { emulateRightClick: true });\n return {\n triggerProps: {\n ...longPress,\n \"aria-controls\": contextMenu ? menuId : undefined,\n onContextMenu(event: MouseEvent<HTMLElement>) {\n event.currentTarget.focus({ preventScroll: true });\n openContextMenu(event, null);\n },\n },\n menu: contextMenu && (\n <DesktopIconMenu\n id={menuId}\n icon={icon}\n items={[]}\n onClose={closeContextMenu}\n onOpen={onOpen}\n position={contextMenu.position}\n />\n ),\n };\n}\n"]}
package/menu/Menu.d.ts CHANGED
@@ -3,7 +3,8 @@ export interface MenuPosition {
3
3
  x: number;
4
4
  y: number;
5
5
  }
6
- export declare function Menu({ position, onClose, direction, keyboardNavigation, children, }: PropsWithChildren<{
6
+ export declare function Menu({ id, position, onClose, direction, keyboardNavigation, children, }: PropsWithChildren<{
7
+ id?: string | undefined;
7
8
  position: MenuPosition;
8
9
  onClose: () => void;
9
10
  direction?: "up" | "down";
package/menu/Menu.js CHANGED
@@ -106,7 +106,7 @@ function placeMenuInViewport(input) {
106
106
  top: clamp(preferredTop, MENU_VIEWPORT_MARGIN_PX, maxTop),
107
107
  };
108
108
  }
109
- export function Menu({ position, onClose, direction = "up", keyboardNavigation = true, children, }) {
109
+ export function Menu({ id, position, onClose, direction = "up", keyboardNavigation = true, children, }) {
110
110
  const menuRef = useRef(null);
111
111
  const parent = useContext(ParentMenu);
112
112
  useLayoutEffect(() => {
@@ -169,6 +169,6 @@ export function Menu({ position, onClose, direction = "up", keyboardNavigation =
169
169
  top: placement.top,
170
170
  }
171
171
  : MEASUREMENT_MENU_STYLE;
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);
172
+ return createPortal(_jsx("div", { id: id, ref: menuRef, className: "menu", "data-scrollable": scrollable || undefined, style: menuStyle, tabIndex: -1, children: _jsx(ParentMenu.Provider, { value: menuRef, children: children }) }), document.body);
173
173
  }
174
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,UAAU,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,W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AS,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"]}
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,gB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AI,CAAC,CAAC;QACvB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACnD,OAAO,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,EAAE,EAAE,EAAE,EACN,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 id,\n position,\n onClose,\n direction = \"up\",\n keyboardNavigation = true,\n children,\n}: PropsWithChildren<{\n id?: string | undefined;\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 id={id}\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/StartMenu.js CHANGED
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { Menu } from "./Menu.js";
3
3
  import { MenuItem } from "./MenuItem.js";
4
4
  import "./StartMenu.css";
5
+ import { useOptionalStartMenuPreferences } from "./StartMenuPreferencesProvider.js";
5
6
  import { useContextMenuPositionState } from "./useContextMenuState.js";
6
7
  /**
7
8
  * A taskbar's start menu: a button, usually at the bar's leading edge, that
@@ -9,12 +10,15 @@ import { useContextMenuPositionState } from "./useContextMenuState.js";
9
10
  * entries, or `renderMenu` to render the menu yourself.
10
11
  */
11
12
  export function StartMenu({ className, icon, items = [], label = "Menu", renderMenu, }) {
13
+ const preferences = useOptionalStartMenuPreferences();
12
14
  const { closeContextMenu: close, contextMenu: position, openContextMenuAt, } = useContextMenuPositionState();
13
15
  return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: className ?? "start-menu-button", "aria-label": label, "aria-haspopup": "menu", "aria-expanded": position !== null, onClick: (event) => {
14
16
  const bounds = event.currentTarget.getBoundingClientRect();
15
17
  openContextMenuAt({ x: bounds.left, y: bounds.top });
16
18
  }, children: icon }), position &&
17
- (renderMenu ? (renderMenu({ close, position })) : (_jsx(Menu, { position: position, onClose: close, children: items.map((item) => (_jsx(MenuItem, { disabled: item.disabled, icon: item.icon, label: item.label, onClick: () => {
19
+ (renderMenu ? (renderMenu({ close, position })) : (_jsx(Menu, { position: position, onClose: close, children: items
20
+ .filter((item) => preferences?.isVisible(item.id) ?? true)
21
+ .map((item) => (_jsx(MenuItem, { disabled: item.disabled, icon: item.icon, label: item.label, onClick: () => {
18
22
  close();
19
23
  item.onSelect(position);
20
24
  } }, item.id))) })))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"StartMenu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/StartMenu.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAqB,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAoCpE;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,SAAS,EACT,IAAI,EACJ,KAAK,GAAG,EAAE,EACV,KAAK,GAAG,MAAM,EACd,UAAU,GACK;IACf,MAAM,EACJ,gBAAgB,EAAE,KAAK,EACvB,WAAW,EAAE,QAAQ,EACrB,iBAAiB,GAClB,GAAG,2BAA2B,EAAE,CAAC;IAElC,OAAO,CACL,8BACE,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,SAAS,IAAI,mBAAmB,gBAC/B,KAAK,mBACH,MAAM,mBACL,QAAQ,KAAK,IAAI,EAChC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;oBACjB,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,qBAAqB,EAAE,CAAC;oBAC3D,iBAAiB,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;gBACvD,CAAC,YAEA,IAAI,GACE,EACR,QAAQ;gBACP,CAAC,UAAU,CAAC,CAAC,CAAC,CACZ,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAChC,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,YACrC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,QAAQ,IAEP,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE;4BACZ,KAAK,EAAE,CAAC;4BACR,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;wBAC1B,CAAC,IAPI,IAAI,CAAC,EAAE,CAQZ,CACH,CAAC,GACG,CACR,CAAC,IACH,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { Menu, type MenuPosition } from \"./Menu\";\nimport { MenuItem } from \"./MenuItem\";\nimport \"./StartMenu.css\";\nimport { useContextMenuPositionState } from \"./useContextMenuState\";\n\n/** One entry in a {@link StartMenu}. */\nexport interface StartMenuItem {\n disabled?: boolean | undefined;\n icon?: WindowingIcon | undefined;\n id: string;\n label: string;\n /**\n * Runs when the item is chosen, after the menu closes. `position` is where\n * the menu opened, for placing what the item opens near it.\n */\n onSelect: (position: MenuPosition) => void;\n}\n\nexport interface StartMenuProps {\n /**\n * Classes for the button. They replace the default `start-menu-button`\n * styling, so a host's own button styles apply alone.\n */\n className?: string | undefined;\n /** What the button shows, such as a logo or an icon. */\n icon: ReactNode;\n /** The menu's entries, in order. Ignored when `renderMenu` is given. */\n items?: readonly StartMenuItem[] | undefined;\n /** The button's accessible name. */\n label?: string | undefined;\n /**\n * Renders the open menu itself, such as a `Menu` whose content needs more\n * than a list of items, in place of `items`. Call `close` to close it.\n */\n renderMenu?:\n | ((menu: { close: () => void; position: MenuPosition }) => ReactNode)\n | undefined;\n}\n\n/**\n * A taskbar's start menu: a button, usually at the bar's leading edge, that\n * opens a menu above its top-left corner. Give it `items` for a list of\n * entries, or `renderMenu` to render the menu yourself.\n */\nexport function StartMenu({\n className,\n icon,\n items = [],\n label = \"Menu\",\n renderMenu,\n}: StartMenuProps) {\n const {\n closeContextMenu: close,\n contextMenu: position,\n openContextMenuAt,\n } = useContextMenuPositionState();\n\n return (\n <>\n <button\n type=\"button\"\n className={className ?? \"start-menu-button\"}\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={position !== null}\n onClick={(event) => {\n const bounds = event.currentTarget.getBoundingClientRect();\n openContextMenuAt({ x: bounds.left, y: bounds.top });\n }}\n >\n {icon}\n </button>\n {position &&\n (renderMenu ? (\n renderMenu({ close, position })\n ) : (\n <Menu position={position} onClose={close}>\n {items.map((item) => (\n <MenuItem\n key={item.id}\n disabled={item.disabled}\n icon={item.icon}\n label={item.label}\n onClick={() => {\n close();\n item.onSelect(position);\n }}\n />\n ))}\n </Menu>\n ))}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"StartMenu.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/StartMenu.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAqB,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAoCpE;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,SAAS,EACT,IAAI,EACJ,KAAK,GAAG,EAAE,EACV,KAAK,GAAG,MAAM,EACd,UAAU,GACK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,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { Menu, type MenuPosition } from \"./Menu\";\nimport { MenuItem } from \"./MenuItem\";\nimport \"./StartMenu.css\";\nimport { useOptionalStartMenuPreferences } from \"./StartMenuPreferencesProvider\";\nimport { useContextMenuPositionState } from \"./useContextMenuState\";\n\n/** One entry in a {@link StartMenu}. */\nexport interface StartMenuItem {\n disabled?: boolean | undefined;\n icon?: WindowingIcon | undefined;\n id: string;\n label: string;\n /**\n * Runs when the item is chosen, after the menu closes. `position` is where\n * the menu opened, for placing what the item opens near it.\n */\n onSelect: (position: MenuPosition) => void;\n}\n\nexport interface StartMenuProps {\n /**\n * Classes for the button. They replace the default `start-menu-button`\n * styling, so a host's own button styles apply alone.\n */\n className?: string | undefined;\n /** What the button shows, such as a logo or an icon. */\n icon: ReactNode;\n /** The menu's entries, in order. Ignored when `renderMenu` is given. */\n items?: readonly StartMenuItem[] | undefined;\n /** The button's accessible name. */\n label?: string | undefined;\n /**\n * Renders the open menu itself, such as a `Menu` whose content needs more\n * than a list of items, in place of `items`. Call `close` to close it.\n */\n renderMenu?:\n | ((menu: { close: () => void; position: MenuPosition }) => ReactNode)\n | undefined;\n}\n\n/**\n * A taskbar's start menu: a button, usually at the bar's leading edge, that\n * opens a menu above its top-left corner. Give it `items` for a list of\n * entries, or `renderMenu` to render the menu yourself.\n */\nexport function StartMenu({\n className,\n icon,\n items = [],\n label = \"Menu\",\n renderMenu,\n}: StartMenuProps) {\n const preferences = useOptionalStartMenuPreferences();\n const {\n closeContextMenu: close,\n contextMenu: position,\n openContextMenuAt,\n } = useContextMenuPositionState();\n\n return (\n <>\n <button\n type=\"button\"\n className={className ?? \"start-menu-button\"}\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={position !== null}\n onClick={(event) => {\n const bounds = event.currentTarget.getBoundingClientRect();\n openContextMenuAt({ x: bounds.left, y: bounds.top });\n }}\n >\n {icon}\n </button>\n {position &&\n (renderMenu ? (\n renderMenu({ close, position })\n ) : (\n <Menu position={position} onClose={close}>\n {items\n .filter((item) => preferences?.isVisible(item.id) ?? true)\n .map((item) => (\n <MenuItem\n key={item.id}\n disabled={item.disabled}\n icon={item.icon}\n label={item.label}\n onClick={() => {\n close();\n item.onSelect(position);\n }}\n />\n ))}\n </Menu>\n ))}\n </>\n );\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { type PropsWithChildren } from "react";
2
+ import type { LauncherDefinition } from "../launcher/launcherDefinition.js";
3
+ interface StartMenuPreferences {
4
+ definition: LauncherDefinition;
5
+ configurableIds: readonly string[];
6
+ isVisible: (id: string) => boolean;
7
+ setVisible: (id: string, visible: boolean) => void;
8
+ reset: () => void;
9
+ }
10
+ interface Props extends PropsWithChildren {
11
+ definition: LauncherDefinition;
12
+ storageKey: string;
13
+ }
14
+ /** Shares one host's Start menu choices across its taskbars and Settings windows. */
15
+ export declare function StartMenuPreferencesProvider({ children, definition, storageKey, }: Props): import("react").JSX.Element;
16
+ export declare const useStartMenuPreferences: () => StartMenuPreferences;
17
+ export declare const useOptionalStartMenuPreferences: () => StartMenuPreferences | null;
18
+ export {};
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo, useSyncExternalStore } from "react";
3
+ import { createRequiredContext } from "../createRequiredContext.js";
4
+ import { createStartMenuStore, EMPTY_MENU_OVERRIDES } from "./startMenuStore.js";
5
+ const preferences = createRequiredContext("useStartMenuPreferences must be used within a StartMenuPreferencesProvider");
6
+ /** Shares one host's Start menu choices across its taskbars and Settings windows. */
7
+ export function StartMenuPreferencesProvider({ children, definition, storageKey, }) {
8
+ // Equivalent host definitions share the same in-memory preferences, including
9
+ // when localStorage is unavailable. Launcher display order is independent.
10
+ const idsKey = useMemo(() => JSON.stringify(Object.keys(definition.apps)
11
+ .filter((id) => definition.apps[id]?.startMenuVisibility !== "pinned")
12
+ .sort()), [definition.apps]);
13
+ const configurableIds = useMemo(() => JSON.parse(idsKey), [idsKey]);
14
+ const namespace = useMemo(() => ({ storageKey, unsaved: new Map() }), [storageKey]);
15
+ const store = useMemo(() => createStartMenuStore(namespace.storageKey, configurableIds, namespace.unsaved), [namespace, configurableIds]);
16
+ const overrides = useSyncExternalStore(store.subscribe, store.snapshot, () => EMPTY_MENU_OVERRIDES);
17
+ const value = useMemo(() => ({
18
+ definition,
19
+ configurableIds,
20
+ isVisible(id) {
21
+ if (!configurableIds.includes(id))
22
+ return true;
23
+ return (overrides.get(id) ??
24
+ definition.apps[id]?.startMenuVisibility !== "hidden");
25
+ },
26
+ setVisible: store.setVisible,
27
+ reset: store.reset,
28
+ }), [definition, configurableIds, overrides, store]);
29
+ return (_jsx(preferences.context.Provider, { value: value, children: children }));
30
+ }
31
+ export const useStartMenuPreferences = preferences.useRequired;
32
+ export const useOptionalStartMenuPreferences = preferences.useOptional;
33
+ //# sourceMappingURL=StartMenuPreferencesProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartMenuPreferencesProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/StartMenuPreferencesProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAU9E,MAAM,WAAW,GAAG,qBAAqB,CACvC,4EAA4E,CAC7E,CAAC;AAOF,qFAAqF;AACrF,MAAM,UAAU,4BAA4B,CAAC,EAC3C,QAAQ,EACR,UAAU,EACV,UAAU,GACJ;IACN,8EAA8E;IAC9E,2EAA2E;IAC3E,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CACH,IAAI,CAAC,SAAS,CACZ,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IA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EAAE,KAAK,CAAC,CAChD,CAAC;IAEF,OAAO,CACL,KAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACvC,QAAQ,GACoB,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,WAAW,CAAC,WAAW,CAAC;AAC/D,MAAM,CAAC,MAAM,+BAA+B,GAAG,WAAW,CAAC,WAAW,CAAC","sourcesContent":["import { type PropsWithChildren, useMemo, useSyncExternalStore } from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport type { LauncherDefinition } from \"../launcher/launcherDefinition\";\nimport { createStartMenuStore, EMPTY_MENU_OVERRIDES } from \"./startMenuStore\";\n\ninterface StartMenuPreferences {\n definition: LauncherDefinition;\n configurableIds: readonly string[];\n isVisible: (id: string) => boolean;\n setVisible: (id: string, visible: boolean) => void;\n reset: () => void;\n}\n\nconst preferences = createRequiredContext<StartMenuPreferences>(\n \"useStartMenuPreferences must be used within a StartMenuPreferencesProvider\",\n);\n\ninterface Props extends PropsWithChildren {\n definition: LauncherDefinition;\n storageKey: string;\n}\n\n/** Shares one host's Start menu choices across its taskbars and Settings windows. */\nexport function StartMenuPreferencesProvider({\n children,\n definition,\n storageKey,\n}: Props) {\n // Equivalent host definitions share the same in-memory preferences, including\n // when localStorage is unavailable. Launcher display order is independent.\n const idsKey = useMemo(\n () =>\n JSON.stringify(\n Object.keys(definition.apps)\n .filter((id) => definition.apps[id]?.startMenuVisibility !== \"pinned\")\n .sort(),\n ),\n [definition.apps],\n );\n const configurableIds = useMemo<readonly string[]>(\n () => JSON.parse(idsKey),\n [idsKey],\n );\n const namespace = useMemo(\n () => ({ storageKey, unsaved: new Map<string, boolean | undefined>() }),\n [storageKey],\n );\n const store = useMemo(\n () =>\n createStartMenuStore(\n namespace.storageKey,\n configurableIds,\n namespace.unsaved,\n ),\n [namespace, configurableIds],\n );\n const overrides = useSyncExternalStore(\n store.subscribe,\n store.snapshot,\n () => EMPTY_MENU_OVERRIDES,\n );\n const value = useMemo<StartMenuPreferences>(\n () => ({\n definition,\n configurableIds,\n isVisible(id) {\n if (!configurableIds.includes(id)) return true;\n return (\n overrides.get(id) ??\n definition.apps[id]?.startMenuVisibility !== \"hidden\"\n );\n },\n setVisible: store.setVisible,\n reset: store.reset,\n }),\n [definition, configurableIds, overrides, store],\n );\n\n return (\n <preferences.context.Provider value={value}>\n {children}\n </preferences.context.Provider>\n );\n}\n\nexport const useStartMenuPreferences = preferences.useRequired;\nexport const useOptionalStartMenuPreferences = preferences.useOptional;\n"]}
@@ -0,0 +1,8 @@
1
+ export declare const EMPTY_MENU_OVERRIDES: ReadonlyMap<string, boolean>;
2
+ /** One preference namespace. A storage event only changes the app that was written. */
3
+ export declare function createStartMenuStore(storageKey: string, ids: readonly string[], unsaved?: Map<string, boolean | undefined>): {
4
+ snapshot: () => ReadonlyMap<string, boolean>;
5
+ subscribe(notify: () => void): () => void;
6
+ setVisible(id: string, visible: boolean): void;
7
+ reset(): void;
8
+ };
@@ -0,0 +1,92 @@
1
+ import { getLocalStorage, loadStoredPreference, saveStoredPreference, } from "../launcher/storedPreference.js";
2
+ export const EMPTY_MENU_OVERRIDES = new Map();
3
+ function readVisibility(key) {
4
+ return loadStoredPreference(key, (value) => {
5
+ if (value === "true")
6
+ return true;
7
+ if (value === "false")
8
+ return false;
9
+ return undefined;
10
+ });
11
+ }
12
+ /** One preference namespace. A storage event only changes the app that was written. */
13
+ export function createStartMenuStore(storageKey, ids, unsaved = new Map()) {
14
+ // Leave a single unescaped boundary between the namespace and the app ID.
15
+ const keyFor = (id) => `${storageKey}.${id.replaceAll("%", "%25").replaceAll(".", "%2E")}`;
16
+ function persist(id, visible) {
17
+ const value = visible === undefined ? null : String(visible);
18
+ if (saveStoredPreference(keyFor(id), value))
19
+ unsaved.delete(id);
20
+ else
21
+ unsaved.set(id, visible);
22
+ }
23
+ function readAll() {
24
+ const next = new Map();
25
+ for (const id of ids) {
26
+ const visible = unsaved.has(id)
27
+ ? unsaved.get(id)
28
+ : readVisibility(keyFor(id));
29
+ if (visible !== undefined)
30
+ next.set(id, visible);
31
+ }
32
+ return next;
33
+ }
34
+ let overrides = readAll();
35
+ const listeners = new Set();
36
+ function publish(next) {
37
+ if (overrides.size === next.size &&
38
+ [...next].every(([id, value]) => overrides.get(id) === value))
39
+ return;
40
+ overrides = next;
41
+ for (const notify of listeners)
42
+ notify();
43
+ }
44
+ function update(id, visible) {
45
+ const next = new Map(overrides);
46
+ if (visible === undefined)
47
+ next.delete(id);
48
+ else
49
+ next.set(id, visible);
50
+ publish(next);
51
+ }
52
+ function onStorage(event) {
53
+ if (event.storageArea && event.storageArea !== getLocalStorage())
54
+ return;
55
+ if (event.key === null) {
56
+ publish(readAll());
57
+ return;
58
+ }
59
+ const id = ids.find((id) => keyFor(id) === event.key);
60
+ // A queued storage event may predate a failed local write. The local
61
+ // choice wins in this tab until its next successful write or reset.
62
+ if (id !== undefined && !unsaved.has(id)) {
63
+ update(id, readVisibility(keyFor(id)));
64
+ }
65
+ }
66
+ return {
67
+ snapshot: () => overrides,
68
+ subscribe(notify) {
69
+ listeners.add(notify);
70
+ window.addEventListener("storage", onStorage);
71
+ // Include writes between render and subscription.
72
+ publish(readAll());
73
+ return () => {
74
+ listeners.delete(notify);
75
+ if (!listeners.size)
76
+ window.removeEventListener("storage", onStorage);
77
+ };
78
+ },
79
+ setVisible(id, visible) {
80
+ if (!ids.includes(id))
81
+ return;
82
+ persist(id, visible);
83
+ update(id, visible);
84
+ },
85
+ reset() {
86
+ for (const id of ids)
87
+ persist(id, undefined);
88
+ publish(EMPTY_MENU_OVERRIDES);
89
+ },
90
+ };
91
+ }
92
+ //# sourceMappingURL=startMenuStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startMenuStore.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/startMenuStore.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oB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export const EMPTY_MENU_OVERRIDES: ReadonlyMap<string, boolean> = new Map();\n\nfunction readVisibility(key: string) {\n return loadStoredPreference(key, (value) => {\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n return undefined;\n });\n}\n\n/** One preference namespace. A storage event only changes the app that was written. */\nexport function createStartMenuStore(\n storageKey: string,\n ids: readonly string[],\n unsaved = new Map<string, boolean | undefined>(),\n) {\n // Leave a single unescaped boundary between the namespace and the app ID.\n const keyFor = (id: string) =>\n `${storageKey}.${id.replaceAll(\"%\", \"%25\").replaceAll(\".\", \"%2E\")}`;\n function persist(id: string, visible: boolean | undefined) {\n const value = visible === undefined ? null : String(visible);\n if (saveStoredPreference(keyFor(id), value)) unsaved.delete(id);\n else unsaved.set(id, visible);\n }\n function readAll() {\n const next = new Map<string, boolean>();\n for (const id of ids) {\n const visible = unsaved.has(id)\n ? unsaved.get(id)\n : readVisibility(keyFor(id));\n if (visible !== undefined) next.set(id, visible);\n }\n return next;\n }\n let overrides: ReadonlyMap<string, boolean> = readAll();\n const listeners = new Set<() => void>();\n function publish(next: ReadonlyMap<string, boolean>) {\n if (\n overrides.size === next.size &&\n [...next].every(([id, value]) => overrides.get(id) === value)\n )\n return;\n overrides = next;\n for (const notify of listeners) notify();\n }\n function update(id: string, visible: boolean | undefined) {\n const next = new Map(overrides);\n if (visible === undefined) next.delete(id);\n else next.set(id, visible);\n publish(next);\n }\n function onStorage(event: StorageEvent) {\n if (event.storageArea && event.storageArea !== getLocalStorage()) return;\n if (event.key === null) {\n publish(readAll());\n return;\n }\n const id = ids.find((id) => keyFor(id) === event.key);\n // A queued storage event may predate a failed local write. The local\n // choice wins in this tab until its next successful write or reset.\n if (id !== undefined && !unsaved.has(id)) {\n update(id, readVisibility(keyFor(id)));\n }\n }\n return {\n snapshot: () => overrides,\n subscribe(notify: () => void) {\n listeners.add(notify);\n window.addEventListener(\"storage\", onStorage);\n // Include writes between render and subscription.\n publish(readAll());\n return () => {\n listeners.delete(notify);\n if (!listeners.size) window.removeEventListener(\"storage\", onStorage);\n };\n },\n setVisible(id: string, visible: boolean) {\n if (!ids.includes(id)) return;\n persist(id, visible);\n update(id, visible);\n },\n reset() {\n for (const id of ids) persist(id, undefined);\n publish(EMPTY_MENU_OVERRIDES);\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tearleads/windowing",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
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": {
@@ -3,6 +3,7 @@ import { useCallback, useMemo, useState } from "react";
3
3
  import { useLauncherNavigationState } from "../launcher/LauncherNavigationProvider.js";
4
4
  import { resolveLauncherHomeAppId, resolveLauncherOrder, } from "../launcher/launcherDefinition.js";
5
5
  import { useRoutedLayoutTier, } from "../launcher/useRoutedLayoutTier.js";
6
+ import { useOptionalStartMenuPreferences } from "../menu/StartMenuPreferencesProvider.js";
6
7
  import { WindowMenuProvider } from "../window/WindowMenuContext.js";
7
8
  import { hasWindowSidebar, useWindowSidebar, WindowSidebarProvider, } from "../window/WindowSidebarContext.js";
8
9
  import "./RoutedPane.css";
@@ -75,7 +76,11 @@ export function RoutedPane({ AppBoundary = PassThroughBoundary, appIds, launcher
75
76
  // The route only ever names one of the launcher's apps, so the root route is
76
77
  // the one case that falls back to the home app.
77
78
  const activeAppId = appId ?? resolveLauncherHomeAppId(definition);
78
- const offeredAppIds = useMemo(() => appIds ?? resolveLauncherOrder(definition), [appIds, definition]);
79
+ const preferences = useOptionalStartMenuPreferences();
80
+ const offeredAppIds = useMemo(() => {
81
+ const ids = appIds ?? resolveLauncherOrder(definition);
82
+ return preferences ? ids.filter(preferences.isVisible) : ids;
83
+ }, [appIds, definition, preferences]);
79
84
  const toggleNavigationRail = useCallback(() => setNavigationRailExpanded(invertBoolean), []);
80
85
  const toggleLauncherPlacement = useCallback((wasOpen) => {
81
86
  const next = launcherPlacement === "side" ? "bottom" : "side";
@@ -1 +1 @@
1
- {"version":3,"file":"RoutedPane.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPane.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAEL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAEL,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAEL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAEL,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAE/E,MAAM,sCAAsC,GAAG,6BAA6B,CAAC;AAE7E,SAAS,mBAAmB,CAAC,EAAE,QAAQ,EAA4B;IACjE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,UAA8B,EAC9B,IAAsB,EACtB,WAAmB;IAEnB,IAAI,IAA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AC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,wBAAwB,OAEnB,KAAK,EACT,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EACrB,iBAAiB,EAAE,iBAAiB,EACpC,sBAAsB,EAAE,sBAAsB,EAC9C,yBAAyB,EAAE,uBAAuB,EAClD,sBAAsB,EAAE,oBAAoB,EAC5C,IAAI,EAAE,IAAI,IATL,WAAW,CAUhB,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { type ReactNode, useCallback, useMemo, useState } from \"react\";\nimport { useLauncherNavigationState } from \"../launcher/LauncherNavigationProvider\";\nimport {\n type LauncherDefinition,\n resolveLauncherHomeAppId,\n resolveLauncherOrder,\n} from \"../launcher/launcherDefinition\";\nimport type { MiniAppBoundary } from \"../launcher/MiniAppWindow\";\nimport {\n type RoutedLayoutTier,\n useRoutedLayoutTier,\n} from \"../launcher/useRoutedLayoutTier\";\nimport { WindowMenuProvider } from \"../window/WindowMenuContext\";\nimport {\n hasWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"../window/WindowSidebarContext\";\nimport \"./RoutedPane.css\";\nimport {\n type LauncherPlacement,\n loadLauncherPlacement,\n saveLauncherPlacement,\n} from \"./launcherPlacement\";\nimport { RoutedPaneAppBar } from \"./RoutedPaneAppBar\";\nimport { RoutedPaneMain } from \"./RoutedPaneMain\";\nimport { RoutedPaneNav } from \"./RoutedPaneNav\";\nimport { RoutedPaneSidebar } from \"./RoutedPaneSidebar\";\nimport { RoutedPaneTaskBar } from \"./RoutedPaneTaskBar\";\nimport {\n type SubscribeKeyboardVisibility,\n useMobileKeyboardVisible,\n} from \"./useMobileKeyboardVisible\";\nimport { invertBoolean, useRoutedPaneOverlays } from \"./useRoutedPaneOverlays\";\n\nconst DEFAULT_LAUNCHER_PLACEMENT_STORAGE_KEY = \"windowing.launcherPlacement\";\n\nfunction PassThroughBoundary({ children }: { children?: ReactNode }) {\n return children;\n}\n\n/**\n * Whether a freshly mounted routed mini-app shows its sidebar.\n *\n * On mobile the sidebar is a dismissable overlay (dialog + scrim), so it must\n * never open on its own when an app loads — it starts collapsed and the user\n * reveals it from the app bar. The tablet rail honours each app's configured\n * {@link MiniAppDefinition.initialShowSidebar} default (defaulting to shown).\n */\nexport function initialRoutedSidebarExpanded(\n definition: LauncherDefinition,\n tier: RoutedLayoutTier,\n activeAppId: string,\n): boolean {\n if (tier === \"mobile\") {\n return false;\n }\n\n return definition.apps[activeAppId]?.initialShowSidebar ?? true;\n}\n\nexport interface RoutedPaneProps {\n /**\n * Wraps the active mini-app, such as an error boundary that fails inside the\n * app rather than the shell.\n */\n AppBoundary?: MiniAppBoundary | undefined;\n /**\n * The apps the launcher offers, in order, such as the definition's order less\n * the apps the session may not see. Defaults to the definition's order.\n */\n appIds?: ReadonlyArray<string> | undefined;\n /** Rides above the active app in the content pane. */\n contentTop?: ReactNode;\n /**\n * Where the tablet tier's launcher placement persists in localStorage.\n * Defaults to `windowing.launcherPlacement`.\n */\n launcherPlacementStorageKey?: string | undefined;\n /**\n * The taskbar's menu button, centered: the product's logo, which opens the\n * launcher sheet, or the rail on the tablet tier in side mode.\n */\n menuIcon: ReactNode;\n /**\n * A strip in its own row directly above the taskbar, such as a deployment\n * warning. It is told whether the phone's software keyboard is open, while\n * the taskbar itself hides.\n */\n renderAboveTaskbar?:\n | ((state: { keyboardVisible: boolean }) => ReactNode)\n | undefined;\n /** Native keyboard state, for a WebView whose resizing hides it. */\n subscribeKeyboardVisibility?: SubscribeKeyboardVisibility | undefined;\n /** The taskbar's end-aligned tray, such as the windowed/routed switch. */\n taskbarTray?: ReactNode;\n}\n\ninterface RoutedPaneSurfaceProps\n extends Omit<\n RoutedPaneProps,\n \"AppBoundary\" | \"appIds\" | \"launcherPlacementStorageKey\"\n > {\n AppBoundary: MiniAppBoundary;\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n launcherPlacement: LauncherPlacement;\n navigationRailExpanded: boolean;\n onToggleLauncherPlacement: (wasOpen: boolean) => void;\n onToggleNavigationRail: () => void;\n tier: RoutedLayoutTier;\n}\n\nfunction RoutedPaneSurface({\n activeAppId,\n AppBoundary,\n appIds,\n contentTop,\n launcherPlacement,\n menuIcon,\n navigationRailExpanded,\n onToggleLauncherPlacement,\n onToggleNavigationRail,\n renderAboveTaskbar,\n subscribeKeyboardVisibility,\n taskbarTray,\n tier,\n}: RoutedPaneSurfaceProps) {\n const { definition } = useLauncherNavigationState();\n const { sidebar } = useWindowSidebar();\n const hasSidebar = hasWindowSidebar(sidebar);\n const mobileKeyboardVisible = useMobileKeyboardVisible(\n tier === \"mobile\",\n subscribeKeyboardVisibility,\n );\n\n const {\n closeDrawer,\n closeSidebar,\n dismissDrawer,\n drawerOpen,\n menuButtonRef,\n moveLauncher,\n sidebarExpanded,\n toggleDrawer,\n toggleSidebar,\n } = useRoutedPaneOverlays({\n initialSidebarExpanded: () =>\n initialRoutedSidebarExpanded(definition, tier, activeAppId),\n launcherPlacement,\n navigationRailExpanded,\n onToggleLauncherPlacement,\n tier,\n });\n const sidebarVisible = hasSidebar && sidebarExpanded;\n\n return (\n <section\n className={`routed-pane routed-pane--${tier}`}\n data-keyboard={mobileKeyboardVisible ? \"open\" : \"closed\"}\n data-launcher-placement={launcherPlacement}\n data-sidebar={sidebarVisible ? \"open\" : \"closed\"}\n role=\"application\"\n >\n <RoutedPaneAppBar\n activeAppId={activeAppId}\n hasSidebar={hasSidebar}\n onToggleSidebar={toggleSidebar}\n sidebarExpanded={sidebarExpanded}\n tier={tier}\n />\n <RoutedPaneNav\n activeAppId={activeAppId}\n appIds={appIds}\n drawerOpen={drawerOpen}\n launcherPlacement={launcherPlacement}\n onCloseDrawer={dismissDrawer}\n onNavigateRail={closeDrawer}\n onToggleLauncherPlacement={moveLauncher}\n onToggleRail={onToggleNavigationRail}\n railExpanded={navigationRailExpanded}\n tier={tier}\n />\n {sidebarVisible && (\n <RoutedPaneSidebar onClose={closeSidebar} tier={tier}>\n {sidebar}\n </RoutedPaneSidebar>\n )}\n <RoutedPaneMain\n activeAppId={activeAppId}\n AppBoundary={AppBoundary}\n contentTop={contentTop}\n tier={tier}\n />\n {renderAboveTaskbar && (\n <div className=\"routed-pane-above-taskbar\">\n {renderAboveTaskbar({ keyboardVisible: mobileKeyboardVisible })}\n </div>\n )}\n <RoutedPaneTaskBar\n drawerOpen={drawerOpen}\n hidden={mobileKeyboardVisible}\n launcherPlacement={launcherPlacement}\n menuButtonRef={menuButtonRef}\n menuIcon={menuIcon}\n onToggleDrawer={toggleDrawer}\n onToggleRail={onToggleNavigationRail}\n railExpanded={navigationRailExpanded}\n tier={tier}\n tray={taskbarTray}\n />\n </section>\n );\n}\n\n/**\n * Hosts the per-app chrome registries (toolbar actions and the mini-app\n * sidebar). Keyed by the active app id upstream so each mini-app mounts against\n * fresh registries.\n */\nfunction RoutedPaneWithRegistries(props: RoutedPaneSurfaceProps) {\n return (\n <WindowMenuProvider>\n <WindowSidebarProvider>\n <RoutedPaneSurface {...props} />\n </WindowSidebarProvider>\n </WindowMenuProvider>\n );\n}\n\n/**\n * The routed shell, the iPad / phone layout: one mini-app at a time, chosen by\n * the route, with an app bar, a launcher, and a taskbar. Render it inside a\n * {@link LauncherNavigationProvider} in `routed` mode, in a container that\n * gives it its size.\n *\n * Below 760px it is a phone layout whose launcher is a bottom sheet of tiles;\n * at or above it, a tablet layout whose launcher is a left rail or, at the\n * user's choice, the same sheet. The app's sidebar and toolbar actions, which\n * it registers with the window hooks, appear in the shell's sidebar and app\n * bar.\n */\nexport function RoutedPane({\n AppBoundary = PassThroughBoundary,\n appIds,\n launcherPlacementStorageKey = DEFAULT_LAUNCHER_PLACEMENT_STORAGE_KEY,\n ...props\n}: RoutedPaneProps) {\n const tier = useRoutedLayoutTier();\n const {\n definition,\n route: { appId },\n } = useLauncherNavigationState();\n const [launcherPlacement, setLauncherPlacement] = useState<LauncherPlacement>(\n () => loadLauncherPlacement(launcherPlacementStorageKey),\n );\n const [navigationRailExpanded, setNavigationRailExpanded] = useState(false);\n // The route only ever names one of the launcher's apps, so the root route is\n // the one case that falls back to the home app.\n const activeAppId = appId ?? resolveLauncherHomeAppId(definition);\n const offeredAppIds = useMemo(\n () => appIds ?? resolveLauncherOrder(definition),\n [appIds, definition],\n );\n const toggleNavigationRail = useCallback(\n () => setNavigationRailExpanded(invertBoolean),\n [],\n );\n const toggleLauncherPlacement = useCallback(\n (wasOpen: boolean) => {\n const next = launcherPlacement === \"side\" ? \"bottom\" : \"side\";\n setNavigationRailExpanded(next === \"side\" && wasOpen);\n setLauncherPlacement(next);\n saveLauncherPlacement(launcherPlacementStorageKey, next);\n },\n [launcherPlacement, launcherPlacementStorageKey],\n );\n\n if (activeAppId === null) {\n return null;\n }\n\n return (\n <RoutedPaneWithRegistries\n key={activeAppId}\n {...props}\n AppBoundary={AppBoundary}\n activeAppId={activeAppId}\n appIds={offeredAppIds}\n launcherPlacement={launcherPlacement}\n navigationRailExpanded={navigationRailExpanded}\n onToggleLauncherPlacement={toggleLauncherPlacement}\n onToggleNavigationRail={toggleNavigationRail}\n tier={tier}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"RoutedPane.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPane.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAEL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAEL,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,qBA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IAAI,IATL,WAAW,CAUhB,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { type ReactNode, useCallback, useMemo, useState } from \"react\";\nimport { useLauncherNavigationState } from \"../launcher/LauncherNavigationProvider\";\nimport {\n type LauncherDefinition,\n resolveLauncherHomeAppId,\n resolveLauncherOrder,\n} from \"../launcher/launcherDefinition\";\nimport type { MiniAppBoundary } from \"../launcher/MiniAppWindow\";\nimport {\n type RoutedLayoutTier,\n useRoutedLayoutTier,\n} from \"../launcher/useRoutedLayoutTier\";\nimport { useOptionalStartMenuPreferences } from \"../menu/StartMenuPreferencesProvider\";\nimport { WindowMenuProvider } from \"../window/WindowMenuContext\";\nimport {\n hasWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"../window/WindowSidebarContext\";\nimport \"./RoutedPane.css\";\nimport {\n type LauncherPlacement,\n loadLauncherPlacement,\n saveLauncherPlacement,\n} from \"./launcherPlacement\";\nimport { RoutedPaneAppBar } from \"./RoutedPaneAppBar\";\nimport { RoutedPaneMain } from \"./RoutedPaneMain\";\nimport { RoutedPaneNav } from \"./RoutedPaneNav\";\nimport { RoutedPaneSidebar } from \"./RoutedPaneSidebar\";\nimport { RoutedPaneTaskBar } from \"./RoutedPaneTaskBar\";\nimport {\n type SubscribeKeyboardVisibility,\n useMobileKeyboardVisible,\n} from \"./useMobileKeyboardVisible\";\nimport { invertBoolean, useRoutedPaneOverlays } from \"./useRoutedPaneOverlays\";\n\nconst DEFAULT_LAUNCHER_PLACEMENT_STORAGE_KEY = \"windowing.launcherPlacement\";\n\nfunction PassThroughBoundary({ children }: { children?: ReactNode }) {\n return children;\n}\n\n/**\n * Whether a freshly mounted routed mini-app shows its sidebar.\n *\n * On mobile the sidebar is a dismissable overlay (dialog + scrim), so it must\n * never open on its own when an app loads — it starts collapsed and the user\n * reveals it from the app bar. The tablet rail honours each app's configured\n * {@link MiniAppDefinition.initialShowSidebar} default (defaulting to shown).\n */\nexport function initialRoutedSidebarExpanded(\n definition: LauncherDefinition,\n tier: RoutedLayoutTier,\n activeAppId: string,\n): boolean {\n if (tier === \"mobile\") {\n return false;\n }\n\n return definition.apps[activeAppId]?.initialShowSidebar ?? true;\n}\n\nexport interface RoutedPaneProps {\n /**\n * Wraps the active mini-app, such as an error boundary that fails inside the\n * app rather than the shell.\n */\n AppBoundary?: MiniAppBoundary | undefined;\n /**\n * The apps the launcher offers, in order, such as the definition's order less\n * the apps the session may not see. Defaults to the definition's order.\n */\n appIds?: ReadonlyArray<string> | undefined;\n /** Rides above the active app in the content pane. */\n contentTop?: ReactNode;\n /**\n * Where the tablet tier's launcher placement persists in localStorage.\n * Defaults to `windowing.launcherPlacement`.\n */\n launcherPlacementStorageKey?: string | undefined;\n /**\n * The taskbar's menu button, centered: the product's logo, which opens the\n * launcher sheet, or the rail on the tablet tier in side mode.\n */\n menuIcon: ReactNode;\n /**\n * A strip in its own row directly above the taskbar, such as a deployment\n * warning. It is told whether the phone's software keyboard is open, while\n * the taskbar itself hides.\n */\n renderAboveTaskbar?:\n | ((state: { keyboardVisible: boolean }) => ReactNode)\n | undefined;\n /** Native keyboard state, for a WebView whose resizing hides it. */\n subscribeKeyboardVisibility?: SubscribeKeyboardVisibility | undefined;\n /** The taskbar's end-aligned tray, such as the windowed/routed switch. */\n taskbarTray?: ReactNode;\n}\n\ninterface RoutedPaneSurfaceProps\n extends Omit<\n RoutedPaneProps,\n \"AppBoundary\" | \"appIds\" | \"launcherPlacementStorageKey\"\n > {\n AppBoundary: MiniAppBoundary;\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n launcherPlacement: LauncherPlacement;\n navigationRailExpanded: boolean;\n onToggleLauncherPlacement: (wasOpen: boolean) => void;\n onToggleNavigationRail: () => void;\n tier: RoutedLayoutTier;\n}\n\nfunction RoutedPaneSurface({\n activeAppId,\n AppBoundary,\n appIds,\n contentTop,\n launcherPlacement,\n menuIcon,\n navigationRailExpanded,\n onToggleLauncherPlacement,\n onToggleNavigationRail,\n renderAboveTaskbar,\n subscribeKeyboardVisibility,\n taskbarTray,\n tier,\n}: RoutedPaneSurfaceProps) {\n const { definition } = useLauncherNavigationState();\n const { sidebar } = useWindowSidebar();\n const hasSidebar = hasWindowSidebar(sidebar);\n const mobileKeyboardVisible = useMobileKeyboardVisible(\n tier === \"mobile\",\n subscribeKeyboardVisibility,\n );\n\n const {\n closeDrawer,\n closeSidebar,\n dismissDrawer,\n drawerOpen,\n menuButtonRef,\n moveLauncher,\n sidebarExpanded,\n toggleDrawer,\n toggleSidebar,\n } = useRoutedPaneOverlays({\n initialSidebarExpanded: () =>\n initialRoutedSidebarExpanded(definition, tier, activeAppId),\n launcherPlacement,\n navigationRailExpanded,\n onToggleLauncherPlacement,\n tier,\n });\n const sidebarVisible = hasSidebar && sidebarExpanded;\n\n return (\n <section\n className={`routed-pane routed-pane--${tier}`}\n data-keyboard={mobileKeyboardVisible ? \"open\" : \"closed\"}\n data-launcher-placement={launcherPlacement}\n data-sidebar={sidebarVisible ? \"open\" : \"closed\"}\n role=\"application\"\n >\n <RoutedPaneAppBar\n activeAppId={activeAppId}\n hasSidebar={hasSidebar}\n onToggleSidebar={toggleSidebar}\n sidebarExpanded={sidebarExpanded}\n tier={tier}\n />\n <RoutedPaneNav\n activeAppId={activeAppId}\n appIds={appIds}\n drawerOpen={drawerOpen}\n launcherPlacement={launcherPlacement}\n onCloseDrawer={dismissDrawer}\n onNavigateRail={closeDrawer}\n onToggleLauncherPlacement={moveLauncher}\n onToggleRail={onToggleNavigationRail}\n railExpanded={navigationRailExpanded}\n tier={tier}\n />\n {sidebarVisible && (\n <RoutedPaneSidebar onClose={closeSidebar} tier={tier}>\n {sidebar}\n </RoutedPaneSidebar>\n )}\n <RoutedPaneMain\n activeAppId={activeAppId}\n AppBoundary={AppBoundary}\n contentTop={contentTop}\n tier={tier}\n />\n {renderAboveTaskbar && (\n <div className=\"routed-pane-above-taskbar\">\n {renderAboveTaskbar({ keyboardVisible: mobileKeyboardVisible })}\n </div>\n )}\n <RoutedPaneTaskBar\n drawerOpen={drawerOpen}\n hidden={mobileKeyboardVisible}\n launcherPlacement={launcherPlacement}\n menuButtonRef={menuButtonRef}\n menuIcon={menuIcon}\n onToggleDrawer={toggleDrawer}\n onToggleRail={onToggleNavigationRail}\n railExpanded={navigationRailExpanded}\n tier={tier}\n tray={taskbarTray}\n />\n </section>\n );\n}\n\n/**\n * Hosts the per-app chrome registries (toolbar actions and the mini-app\n * sidebar). Keyed by the active app id upstream so each mini-app mounts against\n * fresh registries.\n */\nfunction RoutedPaneWithRegistries(props: RoutedPaneSurfaceProps) {\n return (\n <WindowMenuProvider>\n <WindowSidebarProvider>\n <RoutedPaneSurface {...props} />\n </WindowSidebarProvider>\n </WindowMenuProvider>\n );\n}\n\n/**\n * The routed shell, the iPad / phone layout: one mini-app at a time, chosen by\n * the route, with an app bar, a launcher, and a taskbar. Render it inside a\n * {@link LauncherNavigationProvider} in `routed` mode, in a container that\n * gives it its size.\n *\n * Below 760px it is a phone layout whose launcher is a bottom sheet of tiles;\n * at or above it, a tablet layout whose launcher is a left rail or, at the\n * user's choice, the same sheet. The app's sidebar and toolbar actions, which\n * it registers with the window hooks, appear in the shell's sidebar and app\n * bar.\n */\nexport function RoutedPane({\n AppBoundary = PassThroughBoundary,\n appIds,\n launcherPlacementStorageKey = DEFAULT_LAUNCHER_PLACEMENT_STORAGE_KEY,\n ...props\n}: RoutedPaneProps) {\n const tier = useRoutedLayoutTier();\n const {\n definition,\n route: { appId },\n } = useLauncherNavigationState();\n const [launcherPlacement, setLauncherPlacement] = useState<LauncherPlacement>(\n () => loadLauncherPlacement(launcherPlacementStorageKey),\n );\n const [navigationRailExpanded, setNavigationRailExpanded] = useState(false);\n // The route only ever names one of the launcher's apps, so the root route is\n // the one case that falls back to the home app.\n const activeAppId = appId ?? resolveLauncherHomeAppId(definition);\n const preferences = useOptionalStartMenuPreferences();\n const offeredAppIds = useMemo(() => {\n const ids = appIds ?? resolveLauncherOrder(definition);\n return preferences ? ids.filter(preferences.isVisible) : ids;\n }, [appIds, definition, preferences]);\n const toggleNavigationRail = useCallback(\n () => setNavigationRailExpanded(invertBoolean),\n [],\n );\n const toggleLauncherPlacement = useCallback(\n (wasOpen: boolean) => {\n const next = launcherPlacement === \"side\" ? \"bottom\" : \"side\";\n setNavigationRailExpanded(next === \"side\" && wasOpen);\n setLauncherPlacement(next);\n saveLauncherPlacement(launcherPlacementStorageKey, next);\n },\n [launcherPlacement, launcherPlacementStorageKey],\n );\n\n if (activeAppId === null) {\n return null;\n }\n\n return (\n <RoutedPaneWithRegistries\n key={activeAppId}\n {...props}\n AppBoundary={AppBoundary}\n activeAppId={activeAppId}\n appIds={offeredAppIds}\n launcherPlacement={launcherPlacement}\n navigationRailExpanded={navigationRailExpanded}\n onToggleLauncherPlacement={toggleLauncherPlacement}\n onToggleNavigationRail={toggleNavigationRail}\n tier={tier}\n />\n );\n}\n"]}
@@ -29,6 +29,28 @@ function isBrowserHandledNavClick(event) {
29
29
  event.shiftKey ||
30
30
  event.altKey);
31
31
  }
32
+ // A storage event can remove a focused launcher entry while the menu is open.
33
+ function keepFocusInLauncher(link) {
34
+ if (!link)
35
+ return;
36
+ return () => {
37
+ const focused = link.ownerDocument.activeElement;
38
+ const popupId = link.getAttribute("aria-controls");
39
+ const popup = popupId ? link.ownerDocument.getElementById(popupId) : null;
40
+ if (!focused || (focused !== link && !popup?.contains(focused)))
41
+ return;
42
+ const launcher = link.closest("aside");
43
+ queueMicrotask(() => {
44
+ if (focused.isConnected ||
45
+ !launcher?.isConnected ||
46
+ launcher.getAttribute("aria-hidden") === "true" ||
47
+ link.ownerDocument.activeElement !== link.ownerDocument.body)
48
+ return;
49
+ (launcher.querySelector("a[href]") ??
50
+ launcher.querySelector("button"))?.focus();
51
+ });
52
+ };
53
+ }
32
54
  function RoutedPaneNavLink({ appId, activeAppId, icon: LinkIcon, label, onNavigate, }) {
33
55
  const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();
34
56
  const open = () => {
@@ -36,7 +58,7 @@ function RoutedPaneNavLink({ appId, activeAppId, icon: LinkIcon, label, onNaviga
36
58
  onNavigate();
37
59
  };
38
60
  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) => {
61
+ return (_jsxs(_Fragment, { children: [_jsxs("a", { ...triggerProps, ref: keepFocusInLauncher, "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
62
  if (isBrowserHandledNavClick(event))
41
63
  return;
42
64
  event.preventDefault();
@@ -59,7 +81,7 @@ function RoutedPaneRailToggle({ expanded, onToggle, }) {
59
81
  return (_jsx("button", { "aria-controls": expanded ? ROUTED_PANE_NAV_PANEL_ID : undefined, "aria-expanded": expanded, "aria-label": label, className: "routed-pane-iconbutton routed-pane-rail-toggle", title: label, type: "button", onClick: onToggle, children: _jsx(SidebarSimpleIcon, { "aria-hidden": "true", size: 18 }) }));
60
82
  }
61
83
  function RoutedPaneMobileNavTile({ active, href, icon: TileIcon, label, onSelect, }) {
62
- return (_jsxs("a", { "aria-current": active ? "page" : undefined, className: classNames("routed-pane-sheet-tile", active && "routed-pane-sheet-tile--active"), href: href, onClick: (event) => {
84
+ return (_jsxs("a", { ref: keepFocusInLauncher, "aria-current": active ? "page" : undefined, className: classNames("routed-pane-sheet-tile", active && "routed-pane-sheet-tile--active"), href: href, onClick: (event) => {
63
85
  if (isBrowserHandledNavClick(event)) {
64
86
  return;
65
87
  }
@@ -95,7 +117,9 @@ export function RoutedPaneNav({ activeAppId, appIds, drawerOpen, launcherPlaceme
95
117
  if (drawerOpen && (tier === "mobile" || launcherPlacement === "bottom")) {
96
118
  const sheet = sheetRef.current;
97
119
  const tile = sheet?.querySelector('.routed-pane-sheet-tile[aria-current="page"]');
98
- (tile ?? sheet?.querySelector(".routed-pane-sheet-tile"))?.focus();
120
+ (tile ??
121
+ sheet?.querySelector(".routed-pane-sheet-tile") ??
122
+ sheet?.querySelector(".routed-pane-sheet-handle"))?.focus();
99
123
  }
100
124
  }, [drawerOpen, launcherPlacement, tier]);
101
125
  const mobileSheetDrag = useMobileSheetDrag({
@@ -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,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,EAA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,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 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
+ {"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,O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,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 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\n// A storage event can remove a focused launcher entry while the menu is open.\nfunction keepFocusInLauncher(link: HTMLAnchorElement | null) {\n if (!link) return;\n return () => {\n const focused = link.ownerDocument.activeElement;\n const popupId = link.getAttribute(\"aria-controls\");\n const popup = popupId ? link.ownerDocument.getElementById(popupId) : null;\n if (!focused || (focused !== link && !popup?.contains(focused))) return;\n const launcher = link.closest(\"aside\");\n queueMicrotask(() => {\n if (\n focused.isConnected ||\n !launcher?.isConnected ||\n launcher.getAttribute(\"aria-hidden\") === \"true\" ||\n link.ownerDocument.activeElement !== link.ownerDocument.body\n )\n return;\n (\n launcher.querySelector<HTMLElement>(\"a[href]\") ??\n launcher.querySelector(\"button\")\n )?.focus();\n });\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 ref={keepFocusInLauncher}\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 ref={keepFocusInLauncher}\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 ??\n sheet?.querySelector<HTMLElement>(\".routed-pane-sheet-tile\") ??\n sheet?.querySelector<HTMLButtonElement>(\".routed-pane-sheet-handle\")\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"]}