@tearleads/windowing 0.2.35 → 0.2.37

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.
@@ -37,7 +37,7 @@ export function DesktopIcons({ appIds, label = "Desktop", menuItems, onOpen, sto
37
37
  return (_jsxs("div", { "aria-label": label, "aria-orientation": "vertical", className: "desktop-icons", ref: setLayer, role: "listbox", children: [shownIds.map((appId) => {
38
38
  const app = definition.apps[appId];
39
39
  const position = positions[appId];
40
- return app && position ? (_jsx(DesktopIcon, { appId: appId, clamp: clamp, icon: app.icon, onContextMenu: (event) => openContextMenu(event, appId), onMove: (next) => moveIcon(appId, next), onOpen: () => open(appId), onSelect: () => setSelected(appId), onStep: (direction) => step(appId, direction), position: position, selected: selected === appId, tabbable: tabbableId === appId, title: app.title }, appId)) : null;
40
+ return app && position ? (_jsx(DesktopIcon, { appId: appId, clamp: clamp, icon: app.icon, onContextMenu: (event) => openContextMenu(event, appId), onMove: (next) => moveIcon(appId, next), onOpen: () => open(appId), onSelect: () => setSelected(appId), onStep: (direction) => step(appId, direction), position: position, selected: selected === appId, tabbable: tabbableId === appId, title: app.iconLabel ?? app.title }, appId)) : null;
41
41
  }), contextMenu && menuAppId !== undefined && menuApp && (_jsx(DesktopIconMenu, { icon: menuApp.icon, items: menuItems?.(menuAppId) ?? NO_MENU_ITEMS, onClose: closeContextMenu, onOpen: () => open(menuAppId), position: contextMenu.position }))] }));
42
42
  }
43
43
  //# sourceMappingURL=DesktopIcons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DesktopIcons.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/desktop/DesktopIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,E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E,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,GAAG,CAAC,IAAI,EAEd,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,EACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAClC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAC7C,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,KAAK,KAAK,EAC5B,QAAQ,EAAE,UAAU,KAAK,KAAK,EAC9B,KAAK,EAAE,GAAG,CAAC,KAAK,IATX,KAAK,CAUV,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;YACX,CAAC,CAAC,EACD,WAAW,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,IAAI,CACpD,KAAC,eAAe,IACd,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,KAAK,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,aAAa,EAC9C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAC7B,QAAQ,EAAE,WAAW,CAAC,QAAQ,GAC9B,CACH,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport { isLauncherAppId } from \"../launcher/launcherDefinition\";\nimport { useContextMenuState } from \"../menu/useContextMenuState\";\nimport { DesktopIcon } from \"./DesktopIcon\";\nimport { DesktopIconMenu, type DesktopIconMenuItem } from \"./DesktopIconMenu\";\nimport { resolveDesktopIconPositions } from \"./desktopState\";\nimport {\n createMemoryDesktopStateStorage,\n type DesktopStateStorage,\n} from \"./desktopStateStorage\";\nimport { useDesktopIconSelection } from \"./useDesktopIconSelection\";\nimport { useDesktopIconState } from \"./useDesktopIconState\";\nimport { useDesktopSurface } from \"./useDesktopSurface\";\nimport \"./DesktopIcons.css\";\n\nexport interface DesktopIconsProps<AppId extends string = string> {\n /** The launcher apps to show, in their default grid order. */\n appIds: ReadonlyArray<AppId>;\n /** The icon list's accessible name. Defaults to \"Desktop\". */\n label?: string | undefined;\n /** Extra context-menu items for an icon, shown below Open. */\n menuItems?:\n | ((appId: AppId) => ReadonlyArray<DesktopIconMenuItem>)\n | undefined;\n /** Opens an app. Defaults to the launcher's `openMiniApp`. */\n onOpen?: ((appId: AppId) => void) | undefined;\n /**\n * Where the icon positions persist. Without one they last as long as the\n * component. Keep the adapter stable: a new one reloads the layout.\n */\n storage?: DesktopStateStorage | undefined;\n}\n\nconst NO_MENU_ITEMS: ReadonlyArray<DesktopIconMenuItem> = [];\n\n/**\n * Launcher apps as icons on the windowed desktop, behind its windows. Drag an\n * icon to move it; double-click it, or press Enter, to open its app;\n * right-click it for its menu. Positions persist through `storage`.\n *\n * Render it inside a {@link LauncherNavigationProvider}, as the first child of\n * the positioned surface the windows lay out on.\n */\nexport function DesktopIcons<AppId extends string>({\n appIds,\n label = \"Desktop\",\n menuItems,\n onOpen,\n storage,\n}: DesktopIconsProps<AppId>) {\n const { definition } = useLauncherNavigationState();\n const { openMiniApp } = useLauncherNavigationActions();\n const [memoryStorage] = useState(createMemoryDesktopStateStorage);\n const { icons, moveIcon } = useDesktopIconState(storage ?? memoryStorage);\n const [layer, setLayer] = useState<HTMLDivElement | null>(null);\n const { clamp, surface } = useDesktopSurface(layer);\n const shownIds = useMemo(\n () => appIds.filter((appId) => isLauncherAppId(definition, appId)),\n [appIds, definition],\n );\n const { selected, setSelected, step, tabbableId } = useDesktopIconSelection(\n layer,\n shownIds,\n );\n const { closeContextMenu, contextMenu, openContextMenu } =\n useContextMenuState<AppId>({ onOpen: setSelected });\n const positions = useMemo(\n () => resolveDesktopIconPositions(shownIds, icons, surface),\n [icons, shownIds, surface],\n );\n const open = useCallback(\n (appId: AppId) => (onOpen ? onOpen(appId) : openMiniApp({ appId })),\n [onOpen, openMiniApp],\n );\n\n const menuAppId = contextMenu?.id;\n const menuApp = menuAppId === undefined ? null : definition.apps[menuAppId];\n return (\n <div\n aria-label={label}\n aria-orientation=\"vertical\"\n className=\"desktop-icons\"\n ref={setLayer}\n role=\"listbox\"\n >\n {shownIds.map((appId) => {\n const app = definition.apps[appId];\n const position = positions[appId];\n return app && position ? (\n <DesktopIcon\n appId={appId}\n clamp={clamp}\n icon={app.icon}\n key={appId}\n onContextMenu={(event) => openContextMenu(event, appId)}\n onMove={(next) => moveIcon(appId, next)}\n onOpen={() => open(appId)}\n onSelect={() => setSelected(appId)}\n onStep={(direction) => step(appId, direction)}\n position={position}\n selected={selected === appId}\n tabbable={tabbableId === appId}\n title={app.title}\n />\n ) : null;\n })}\n {contextMenu && menuAppId !== undefined && menuApp && (\n <DesktopIconMenu\n icon={menuApp.icon}\n items={menuItems?.(menuAppId) ?? NO_MENU_ITEMS}\n onClose={closeContextMenu}\n onOpen={() => open(menuAppId)}\n position={contextMenu.position}\n />\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"DesktopIcons.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/desktop/DesktopIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAA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AAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,EACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAClC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAC7C,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,KAAK,KAAK,EAC5B,QAAQ,EAAE,UAAU,KAAK,KAAK,EAC9B,KAAK,EAAE,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,KAAK,IAT5B,KAAK,CAUV,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;YACX,CAAC,CAAC,EACD,WAAW,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,IAAI,CACpD,KAAC,eAAe,IACd,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,KAAK,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,aAAa,EAC9C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAC7B,QAAQ,EAAE,WAAW,CAAC,QAAQ,GAC9B,CACH,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport { isLauncherAppId } from \"../launcher/launcherDefinition\";\nimport { useContextMenuState } from \"../menu/useContextMenuState\";\nimport { DesktopIcon } from \"./DesktopIcon\";\nimport { DesktopIconMenu, type DesktopIconMenuItem } from \"./DesktopIconMenu\";\nimport { resolveDesktopIconPositions } from \"./desktopState\";\nimport {\n createMemoryDesktopStateStorage,\n type DesktopStateStorage,\n} from \"./desktopStateStorage\";\nimport { useDesktopIconSelection } from \"./useDesktopIconSelection\";\nimport { useDesktopIconState } from \"./useDesktopIconState\";\nimport { useDesktopSurface } from \"./useDesktopSurface\";\nimport \"./DesktopIcons.css\";\n\nexport interface DesktopIconsProps<AppId extends string = string> {\n /** The launcher apps to show, in their default grid order. */\n appIds: ReadonlyArray<AppId>;\n /** The icon list's accessible name. Defaults to \"Desktop\". */\n label?: string | undefined;\n /** Extra context-menu items for an icon, shown below Open. */\n menuItems?:\n | ((appId: AppId) => ReadonlyArray<DesktopIconMenuItem>)\n | undefined;\n /** Opens an app. Defaults to the launcher's `openMiniApp`. */\n onOpen?: ((appId: AppId) => void) | undefined;\n /**\n * Where the icon positions persist. Without one they last as long as the\n * component. Keep the adapter stable: a new one reloads the layout.\n */\n storage?: DesktopStateStorage | undefined;\n}\n\nconst NO_MENU_ITEMS: ReadonlyArray<DesktopIconMenuItem> = [];\n\n/**\n * Launcher apps as icons on the windowed desktop, behind its windows. Drag an\n * icon to move it; double-click it, or press Enter, to open its app;\n * right-click it for its menu. Positions persist through `storage`.\n *\n * Render it inside a {@link LauncherNavigationProvider}, as the first child of\n * the positioned surface the windows lay out on.\n */\nexport function DesktopIcons<AppId extends string>({\n appIds,\n label = \"Desktop\",\n menuItems,\n onOpen,\n storage,\n}: DesktopIconsProps<AppId>) {\n const { definition } = useLauncherNavigationState();\n const { openMiniApp } = useLauncherNavigationActions();\n const [memoryStorage] = useState(createMemoryDesktopStateStorage);\n const { icons, moveIcon } = useDesktopIconState(storage ?? memoryStorage);\n const [layer, setLayer] = useState<HTMLDivElement | null>(null);\n const { clamp, surface } = useDesktopSurface(layer);\n const shownIds = useMemo(\n () => appIds.filter((appId) => isLauncherAppId(definition, appId)),\n [appIds, definition],\n );\n const { selected, setSelected, step, tabbableId } = useDesktopIconSelection(\n layer,\n shownIds,\n );\n const { closeContextMenu, contextMenu, openContextMenu } =\n useContextMenuState<AppId>({ onOpen: setSelected });\n const positions = useMemo(\n () => resolveDesktopIconPositions(shownIds, icons, surface),\n [icons, shownIds, surface],\n );\n const open = useCallback(\n (appId: AppId) => (onOpen ? onOpen(appId) : openMiniApp({ appId })),\n [onOpen, openMiniApp],\n );\n\n const menuAppId = contextMenu?.id;\n const menuApp = menuAppId === undefined ? null : definition.apps[menuAppId];\n return (\n <div\n aria-label={label}\n aria-orientation=\"vertical\"\n className=\"desktop-icons\"\n ref={setLayer}\n role=\"listbox\"\n >\n {shownIds.map((appId) => {\n const app = definition.apps[appId];\n const position = positions[appId];\n return app && position ? (\n <DesktopIcon\n appId={appId}\n clamp={clamp}\n icon={app.icon}\n key={appId}\n onContextMenu={(event) => openContextMenu(event, appId)}\n onMove={(next) => moveIcon(appId, next)}\n onOpen={() => open(appId)}\n onSelect={() => setSelected(appId)}\n onStep={(direction) => step(appId, direction)}\n position={position}\n selected={selected === appId}\n tabbable={tabbableId === appId}\n title={app.iconLabel ?? app.title}\n />\n ) : null;\n })}\n {contextMenu && menuAppId !== undefined && menuApp && (\n <DesktopIconMenu\n icon={menuApp.icon}\n items={menuItems?.(menuAppId) ?? NO_MENU_ITEMS}\n onClose={closeContextMenu}\n onOpen={() => open(menuAppId)}\n position={contextMenu.position}\n />\n )}\n </div>\n );\n}\n"]}
@@ -49,6 +49,11 @@ the browser paints and removes them on unmount; under a dark scheme,
49
49
  [`tokens.css`][tokens] sets `color-scheme: dark`. Tearleads sets its themes per
50
50
  host profile in [`packages/app/src/host/AppHostConfig.ts`][host-profile].
51
51
 
52
+ A host with no windows, such as a static site, can import `ThemeProvider`,
53
+ `ThemeSwitch`, the theme hooks, their types, and the switch's
54
+ `ThemeInvertIcon` from `@tearleads/windowing/theme`. That entry leaves out the
55
+ window chrome and its stylesheets, which the package entry imports.
56
+
52
57
  ## Wallpapers and Display Properties
53
58
 
54
59
  A host offers its own desktop wallpapers. A `WallpaperDefinition` is
package/docs/launcher.md CHANGED
@@ -55,6 +55,7 @@ const LAUNCHER: LauncherDefinition<"notes" | "contacts"> = {
55
55
  notes: {
56
56
  createComponent: () => NotesApp,
57
57
  icon: NoteIcon,
58
+ iconLabel: "Quick notes",
58
59
  initialShowSidebar: false,
59
60
  title: "Notes",
60
61
  },
@@ -65,6 +66,13 @@ const LAUNCHER: LauncherDefinition<"notes" | "contacts"> = {
65
66
  };
66
67
  ```
67
68
 
69
+ Each app's optional `iconLabel` labels its desktop icon and routed launcher
70
+ entries (both the tablet rail and mobile sheet). Omit it to use `title`.
71
+ Window chrome and the routed content heading always keep `title`; app ids,
72
+ routes, and stored desktop positions do not change. Hosts building a start
73
+ menu from the definition should use `app.iconLabel ?? app.title` for each
74
+ item's `label`, as Tearleads' start and desktop context menus do.
75
+
68
76
  `LauncherNavigationProvider` takes the definition and a `NavigationMode`, and
69
77
  goes inside a `WindowStateProvider`. In `windowed` mode
70
78
  `useLauncherNavigationActions().openMiniApp({ appId })` opens the app's window,
@@ -24,6 +24,8 @@ The declarations drop the stylesheet imports tsc keeps
24
24
  in them, which a consumer's typecheck could not resolve. The smoke script
25
25
  installs the lowest React the peer range admits, typechecks against the
26
26
  declarations with TypeScript's defaults, and bundles a named import with webpack.
27
+ It also consumes `MiniAppDefinition.iconLabel` through the packed declarations
28
+ and opens a labeled desktop icon, checking that the window keeps its own title.
27
29
 
28
30
  Merging to `main` publishes. When [`packages/windowing`][windowing-source] changes
29
31
  there, [`.github/workflows/windowing-publish.yml`][windowing-publish] publishes
@@ -10,12 +10,18 @@ export interface MiniAppDefinition {
10
10
  createComponent: () => ComponentType;
11
11
  /** The app's glyph in the launchers and the taskbar. */
12
12
  icon?: WindowingIcon | undefined;
13
+ /**
14
+ * Label for desktop icons and launcher navigation. Defaults to `title`.
15
+ * Does not change window titles, routed headings, app ids, or routes.
16
+ */
17
+ iconLabel?: string | undefined;
13
18
  /**
14
19
  * Whether the app's sidebar starts shown, in a new window and on the routed
15
20
  * shell's tablet tier. Defaults to shown. The phone tier always starts with
16
21
  * the sidebar hidden.
17
22
  */
18
23
  initialShowSidebar?: boolean | undefined;
24
+ /** The window title and routed content heading. */
19
25
  title: string;
20
26
  /**
21
27
  * The size a new window opens at, in CSS pixels. Defaults to the
@@ -1 +1 @@
1
- {"version":3,"file":"launcherDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/launcherDefinition.ts"],"names":[],"mappings":"AAkDA,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 * 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 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":"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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tearleads/windowing",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
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": {
@@ -16,6 +16,10 @@
16
16
  "types": "./index.d.ts",
17
17
  "default": "./index.js"
18
18
  },
19
+ "./theme": {
20
+ "types": "./theme/index.d.ts",
21
+ "default": "./theme/index.js"
22
+ },
19
23
  "./*.css": "./*.css"
20
24
  },
21
25
  "sideEffects": [
@@ -13,7 +13,9 @@ function useRoutedPaneNavItems(appIds) {
13
13
  const { definition } = useLauncherNavigationState();
14
14
  return useMemo(() => appIds.flatMap((appId) => {
15
15
  const app = definition.apps[appId];
16
- return app ? [{ appId, icon: app.icon, label: app.title }] : [];
16
+ return app
17
+ ? [{ appId, icon: app.icon, label: app.iconLabel ?? app.title }]
18
+ : [];
17
19
  }), [appIds, definition]);
18
20
  }
19
21
  // Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,
@@ -1 +1 @@
1
- {"version":3,"file":"RoutedPaneNav.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1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AAC;oBAC1C,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,eAAe,CAAC,UAAU,KAAK,EAAE;oBAC9D,CAAC,CAAC,SAAS,aAGf,eAAK,SAAS,EAAC,0BAA0B,aACvC,KAAC,2BAA2B,IAC1B,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAClC,OAAO,EAAE,eAAe,CAAC,WAAW,EACpC,aAAa,EAAE,eAAe,CAAC,iBAAiB,GAChD,EACD,IAAI,KAAK,QAAQ,IAAI,CACpB,KAAC,yBAAyB,IACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,yBAAyB,GACnC,CACH,IACG,EACN,KAAC,mBAAmB,IAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,GACzB,IACI,IACP,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { classNames } from \"./classNames\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport { RoutedPanePlacementButton } from \"./RoutedPanePlacementButton\";\nimport { useMobileSheetDrag } from \"./useMobileSheetDrag\";\nimport \"./RoutedPaneNav.css\";\n\nexport const ROUTED_PANE_NAV_PANEL_ID = \"routed-pane-nav-panel\";\nexport const ROUTED_PANE_SHEET_ID = \"routed-pane-sheet\";\n\ninterface RoutedPaneNavItem {\n appId: string;\n icon: WindowingIcon | undefined;\n label: string;\n}\n\n// The launcher entries, in the order given, labeled from the definition.\nfunction useRoutedPaneNavItems(\n appIds: ReadonlyArray<string>,\n): ReadonlyArray<RoutedPaneNavItem> {\n const { definition } = useLauncherNavigationState();\n return useMemo(\n () =>\n appIds.flatMap((appId) => {\n const app = definition.apps[appId];\n return app ? [{ appId, icon: app.icon, label: app.title }] : [];\n }),\n [appIds, definition],\n );\n}\n\n// Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,\n// middle-click) so the href still opens in a new tab/window; only intercept\n// a plain left-click for in-app navigation.\nfunction isBrowserHandledNavClick(\n event: ReactMouseEvent<HTMLAnchorElement>,\n): boolean {\n return (\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n );\n}\n\nfunction RoutedPaneNavLink({\n appId,\n activeAppId,\n icon: LinkIcon,\n label,\n onNavigate,\n}: {\n appId: string;\n activeAppId: string;\n icon: WindowingIcon | undefined;\n label: string;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const handleClick = useCallback(\n (event: ReactMouseEvent<HTMLAnchorElement>) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n openMiniApp({ appId });\n onNavigate();\n },\n [appId, onNavigate, openMiniApp],\n );\n\n return (\n <a\n aria-current={activeAppId === appId ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-nav-link\",\n activeAppId === appId && \"routed-pane-nav-link--active\",\n )}\n href={getMiniAppHref(appId)}\n onClick={handleClick}\n >\n {LinkIcon && <LinkIcon aria-hidden=\"true\" size={20} />}\n <span className=\"routed-pane-nav-link-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The tablet rail's navigation surface: an icon-and-label link per routed\n * mini-app. System commands and per-app file/view actions belong to the app bar\n * toolbar at the top of the shell.\n */\nfunction RoutedPaneNavPanel({\n activeAppId,\n appIds,\n id,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n id: string;\n onNavigate: () => void;\n}) {\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-nav-panel\" id={id}>\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneNavLink\n key={appId}\n activeAppId={activeAppId}\n appId={appId}\n icon={icon}\n label={label}\n onNavigate={onNavigate}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneRailToggle({\n expanded,\n onToggle,\n}: {\n expanded: boolean;\n onToggle: () => void;\n}) {\n const label = expanded\n ? \"Collapse navigation rail\"\n : \"Expand navigation rail\";\n\n return (\n <button\n aria-controls={expanded ? ROUTED_PANE_NAV_PANEL_ID : undefined}\n aria-expanded={expanded}\n aria-label={label}\n className=\"routed-pane-iconbutton routed-pane-rail-toggle\"\n title={label}\n type=\"button\"\n onClick={onToggle}\n >\n <SidebarSimpleIcon aria-hidden=\"true\" size={18} />\n </button>\n );\n}\n\nfunction RoutedPaneMobileNavTile({\n active,\n href,\n icon: TileIcon,\n label,\n onSelect,\n}: {\n active: boolean;\n href: string;\n icon: WindowingIcon | undefined;\n label: string;\n onSelect: () => void;\n}) {\n return (\n <a\n aria-current={active ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-sheet-tile\",\n active && \"routed-pane-sheet-tile--active\",\n )}\n href={href}\n onClick={(event) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n onSelect();\n }}\n >\n {TileIcon && <TileIcon aria-hidden=\"true\" size={32} />}\n <span className=\"routed-pane-sheet-tile-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The bottom-sheet navigation: every routed mini-app as a grid of square\n * icon-and-label tiles (styled after Explorer's New Document screen). Like the\n * tablet rail it carries no per-app contextual actions. Selecting a tile\n * navigates and dismisses.\n */\nfunction RoutedPaneMobileNav({\n activeAppId,\n appIds,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-sheet-grid\">\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneMobileNavTile\n key={appId}\n active={activeAppId === appId}\n href={getMiniAppHref(appId)}\n icon={icon}\n label={label}\n onSelect={() => {\n openMiniApp({ appId });\n onNavigate();\n }}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneMobileSheetHandle({\n dragging,\n onClick,\n onPointerDown,\n}: {\n dragging: boolean;\n onClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;\n}) {\n return (\n <button\n aria-label=\"Dismiss menu\"\n className=\"routed-pane-sheet-handle\"\n data-dragging={dragging ? \"true\" : \"false\"}\n type=\"button\"\n onClick={onClick}\n onPointerDown={onPointerDown}\n >\n <span aria-hidden=\"true\" />\n </button>\n );\n}\n\n/**\n * The navigation surface in its tier-appropriate container: a persistent\n * `<aside>` rail in tablet side mode, or a bottom sheet of launcher tiles (plus\n * dismiss scrim) on mobile and in tablet bottom mode.\n */\nexport function RoutedPaneNav({\n activeAppId,\n appIds,\n drawerOpen,\n launcherPlacement,\n onCloseDrawer,\n onNavigateRail,\n onToggleLauncherPlacement,\n onToggleRail,\n railExpanded,\n tier,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n drawerOpen: boolean;\n launcherPlacement: LauncherPlacement;\n onCloseDrawer: () => void;\n onNavigateRail: () => void;\n onToggleLauncherPlacement: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const sheetRef = useRef<HTMLElement>(null);\n useEffect(() => {\n if (drawerOpen && (tier === \"mobile\" || launcherPlacement === \"bottom\")) {\n const sheet = sheetRef.current;\n const tile = sheet?.querySelector<HTMLElement>(\n '.routed-pane-sheet-tile[aria-current=\"page\"]',\n );\n (\n tile ?? sheet?.querySelector<HTMLElement>(\".routed-pane-sheet-tile\")\n )?.focus();\n }\n }, [drawerOpen, launcherPlacement, tier]);\n\n const mobileSheetDrag = useMobileSheetDrag({\n drawerOpen:\n (tier === \"mobile\" || launcherPlacement === \"bottom\") && drawerOpen,\n onClose: onCloseDrawer,\n });\n\n if (tier === \"tablet\" && launcherPlacement === \"side\") {\n return (\n <aside\n className={classNames(\n \"routed-pane-rail\",\n !railExpanded && \"routed-pane-rail--collapsed\",\n )}\n data-state={railExpanded ? \"open\" : \"closed\"}\n >\n <RoutedPaneRailToggle expanded={railExpanded} onToggle={onToggleRail} />\n {railExpanded && (\n <RoutedPaneNavPanel\n activeAppId={activeAppId}\n appIds={appIds}\n id={ROUTED_PANE_NAV_PANEL_ID}\n onNavigate={onNavigateRail}\n />\n )}\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n </aside>\n );\n }\n\n return (\n <>\n {drawerOpen && (\n <button\n aria-label=\"Close menu\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onCloseDrawer}\n />\n )}\n <aside\n aria-hidden={!drawerOpen}\n className=\"routed-pane-sheet\"\n ref={sheetRef}\n data-dragging={mobileSheetDrag.dragging ? \"true\" : \"false\"}\n data-open={drawerOpen ? \"true\" : \"false\"}\n id={ROUTED_PANE_SHEET_ID}\n style={\n drawerOpen && mobileSheetDrag.dragOffset > 0\n ? { transform: `translateY(${mobileSheetDrag.dragOffset}px)` }\n : undefined\n }\n >\n <div className=\"routed-pane-sheet-header\">\n <RoutedPaneMobileSheetHandle\n dragging={mobileSheetDrag.dragging}\n onClick={mobileSheetDrag.handleClick}\n onPointerDown={mobileSheetDrag.handlePointerDown}\n />\n {tier === \"tablet\" && (\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n )}\n </div>\n <RoutedPaneMobileNav\n activeAppId={activeAppId}\n appIds={appIds}\n onNavigate={onCloseDrawer}\n />\n </aside>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"RoutedPaneNav.js","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BAAyB,GACnC,IACI,CACT,CAAC;IACJ,CAAC;IAED,OAAO,CACL,8BACG,UAAU,IAAI,CACb,+BACa,YAAY,EACvB,SAAS,EAAC,mBAAmB,EAC7B,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,aAAa,GACtB,CACH,EACD,gCACe,CAAC,UAAU,EACxB,SAAS,EAAC,mBAAmB,EAC7B,GAAG,EAAE,QAAQ,mBACE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,eAC/C,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACxC,EAAE,EAAE,oBAAoB,EACxB,KAAK,EACH,UAAU,IAAI,eAAe,CAAC,UAAU,GAAG,CAAC;oBAC1C,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,eAAe,CAAC,UAAU,KAAK,EAAE;oBAC9D,CAAC,CAAC,SAAS,aAGf,eAAK,SAAS,EAAC,0BAA0B,aACvC,KAAC,2BAA2B,IAC1B,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAClC,OAAO,EAAE,eAAe,CAAC,WAAW,EACpC,aAAa,EAAE,eAAe,CAAC,iBAAiB,GAChD,EACD,IAAI,KAAK,QAAQ,IAAI,CACpB,KAAC,yBAAyB,IACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,yBAAyB,GACnC,CACH,IACG,EACN,KAAC,mBAAmB,IAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,GACzB,IACI,IACP,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { classNames } from \"./classNames\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport { RoutedPanePlacementButton } from \"./RoutedPanePlacementButton\";\nimport { useMobileSheetDrag } from \"./useMobileSheetDrag\";\nimport \"./RoutedPaneNav.css\";\n\nexport const ROUTED_PANE_NAV_PANEL_ID = \"routed-pane-nav-panel\";\nexport const ROUTED_PANE_SHEET_ID = \"routed-pane-sheet\";\n\ninterface RoutedPaneNavItem {\n appId: string;\n icon: WindowingIcon | undefined;\n label: string;\n}\n\n// The launcher entries, in the order given, labeled from the definition.\nfunction useRoutedPaneNavItems(\n appIds: ReadonlyArray<string>,\n): ReadonlyArray<RoutedPaneNavItem> {\n const { definition } = useLauncherNavigationState();\n return useMemo(\n () =>\n appIds.flatMap((appId) => {\n const app = definition.apps[appId];\n return app\n ? [{ appId, icon: app.icon, label: app.iconLabel ?? app.title }]\n : [];\n }),\n [appIds, definition],\n );\n}\n\n// Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,\n// middle-click) so the href still opens in a new tab/window; only intercept\n// a plain left-click for in-app navigation.\nfunction isBrowserHandledNavClick(\n event: ReactMouseEvent<HTMLAnchorElement>,\n): boolean {\n return (\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n );\n}\n\nfunction RoutedPaneNavLink({\n appId,\n activeAppId,\n icon: LinkIcon,\n label,\n onNavigate,\n}: {\n appId: string;\n activeAppId: string;\n icon: WindowingIcon | undefined;\n label: string;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const handleClick = useCallback(\n (event: ReactMouseEvent<HTMLAnchorElement>) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n openMiniApp({ appId });\n onNavigate();\n },\n [appId, onNavigate, openMiniApp],\n );\n\n return (\n <a\n aria-current={activeAppId === appId ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-nav-link\",\n activeAppId === appId && \"routed-pane-nav-link--active\",\n )}\n href={getMiniAppHref(appId)}\n onClick={handleClick}\n >\n {LinkIcon && <LinkIcon aria-hidden=\"true\" size={20} />}\n <span className=\"routed-pane-nav-link-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The tablet rail's navigation surface: an icon-and-label link per routed\n * mini-app. System commands and per-app file/view actions belong to the app bar\n * toolbar at the top of the shell.\n */\nfunction RoutedPaneNavPanel({\n activeAppId,\n appIds,\n id,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n id: string;\n onNavigate: () => void;\n}) {\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-nav-panel\" id={id}>\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneNavLink\n key={appId}\n activeAppId={activeAppId}\n appId={appId}\n icon={icon}\n label={label}\n onNavigate={onNavigate}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneRailToggle({\n expanded,\n onToggle,\n}: {\n expanded: boolean;\n onToggle: () => void;\n}) {\n const label = expanded\n ? \"Collapse navigation rail\"\n : \"Expand navigation rail\";\n\n return (\n <button\n aria-controls={expanded ? ROUTED_PANE_NAV_PANEL_ID : undefined}\n aria-expanded={expanded}\n aria-label={label}\n className=\"routed-pane-iconbutton routed-pane-rail-toggle\"\n title={label}\n type=\"button\"\n onClick={onToggle}\n >\n <SidebarSimpleIcon aria-hidden=\"true\" size={18} />\n </button>\n );\n}\n\nfunction RoutedPaneMobileNavTile({\n active,\n href,\n icon: TileIcon,\n label,\n onSelect,\n}: {\n active: boolean;\n href: string;\n icon: WindowingIcon | undefined;\n label: string;\n onSelect: () => void;\n}) {\n return (\n <a\n aria-current={active ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-sheet-tile\",\n active && \"routed-pane-sheet-tile--active\",\n )}\n href={href}\n onClick={(event) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n onSelect();\n }}\n >\n {TileIcon && <TileIcon aria-hidden=\"true\" size={32} />}\n <span className=\"routed-pane-sheet-tile-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The bottom-sheet navigation: every routed mini-app as a grid of square\n * icon-and-label tiles (styled after Explorer's New Document screen). Like the\n * tablet rail it carries no per-app contextual actions. Selecting a tile\n * navigates and dismisses.\n */\nfunction RoutedPaneMobileNav({\n activeAppId,\n appIds,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-sheet-grid\">\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneMobileNavTile\n key={appId}\n active={activeAppId === appId}\n href={getMiniAppHref(appId)}\n icon={icon}\n label={label}\n onSelect={() => {\n openMiniApp({ appId });\n onNavigate();\n }}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneMobileSheetHandle({\n dragging,\n onClick,\n onPointerDown,\n}: {\n dragging: boolean;\n onClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;\n}) {\n return (\n <button\n aria-label=\"Dismiss menu\"\n className=\"routed-pane-sheet-handle\"\n data-dragging={dragging ? \"true\" : \"false\"}\n type=\"button\"\n onClick={onClick}\n onPointerDown={onPointerDown}\n >\n <span aria-hidden=\"true\" />\n </button>\n );\n}\n\n/**\n * The navigation surface in its tier-appropriate container: a persistent\n * `<aside>` rail in tablet side mode, or a bottom sheet of launcher tiles (plus\n * dismiss scrim) on mobile and in tablet bottom mode.\n */\nexport function RoutedPaneNav({\n activeAppId,\n appIds,\n drawerOpen,\n launcherPlacement,\n onCloseDrawer,\n onNavigateRail,\n onToggleLauncherPlacement,\n onToggleRail,\n railExpanded,\n tier,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n drawerOpen: boolean;\n launcherPlacement: LauncherPlacement;\n onCloseDrawer: () => void;\n onNavigateRail: () => void;\n onToggleLauncherPlacement: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const sheetRef = useRef<HTMLElement>(null);\n useEffect(() => {\n if (drawerOpen && (tier === \"mobile\" || launcherPlacement === \"bottom\")) {\n const sheet = sheetRef.current;\n const tile = sheet?.querySelector<HTMLElement>(\n '.routed-pane-sheet-tile[aria-current=\"page\"]',\n );\n (\n tile ?? sheet?.querySelector<HTMLElement>(\".routed-pane-sheet-tile\")\n )?.focus();\n }\n }, [drawerOpen, launcherPlacement, tier]);\n\n const mobileSheetDrag = useMobileSheetDrag({\n drawerOpen:\n (tier === \"mobile\" || launcherPlacement === \"bottom\") && drawerOpen,\n onClose: onCloseDrawer,\n });\n\n if (tier === \"tablet\" && launcherPlacement === \"side\") {\n return (\n <aside\n className={classNames(\n \"routed-pane-rail\",\n !railExpanded && \"routed-pane-rail--collapsed\",\n )}\n data-state={railExpanded ? \"open\" : \"closed\"}\n >\n <RoutedPaneRailToggle expanded={railExpanded} onToggle={onToggleRail} />\n {railExpanded && (\n <RoutedPaneNavPanel\n activeAppId={activeAppId}\n appIds={appIds}\n id={ROUTED_PANE_NAV_PANEL_ID}\n onNavigate={onNavigateRail}\n />\n )}\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n </aside>\n );\n }\n\n return (\n <>\n {drawerOpen && (\n <button\n aria-label=\"Close menu\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onCloseDrawer}\n />\n )}\n <aside\n aria-hidden={!drawerOpen}\n className=\"routed-pane-sheet\"\n ref={sheetRef}\n data-dragging={mobileSheetDrag.dragging ? \"true\" : \"false\"}\n data-open={drawerOpen ? \"true\" : \"false\"}\n id={ROUTED_PANE_SHEET_ID}\n style={\n drawerOpen && mobileSheetDrag.dragOffset > 0\n ? { transform: `translateY(${mobileSheetDrag.dragOffset}px)` }\n : undefined\n }\n >\n <div className=\"routed-pane-sheet-header\">\n <RoutedPaneMobileSheetHandle\n dragging={mobileSheetDrag.dragging}\n onClick={mobileSheetDrag.handleClick}\n onPointerDown={mobileSheetDrag.handlePointerDown}\n />\n {tier === \"tablet\" && (\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n )}\n </div>\n <RoutedPaneMobileNav\n activeAppId={activeAppId}\n appIds={appIds}\n onNavigate={onCloseDrawer}\n />\n </aside>\n </>\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export { ThemeInvertIcon } from "../icons/ThemeInvertIcon.js";
2
+ export { ThemeProvider, useOptionalTheme, useTheme } from "./ThemeProvider.js";
3
+ export { ThemeSwitch } from "./ThemeSwitch.js";
4
+ export type { DefaultTheme, ThemeDefinition, ThemeScheme } from "./themes.js";
package/theme/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // The `@tearleads/windowing/theme` entry: the color theme alone, for a host
2
+ // that has no windows, such as a static site. It leaves out the window chrome
3
+ // and its stylesheets, which the package entry pulls in.
4
+ export { ThemeInvertIcon } from "../icons/ThemeInvertIcon.js";
5
+ export { ThemeProvider, useOptionalTheme, useTheme } from "./ThemeProvider.js";
6
+ export { ThemeSwitch } from "./ThemeSwitch.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/theme/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,yDAAyD;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["// The `@tearleads/windowing/theme` entry: the color theme alone, for a host\n// that has no windows, such as a static site. It leaves out the window chrome\n// and its stylesheets, which the package entry pulls in.\nexport { ThemeInvertIcon } from \"../icons/ThemeInvertIcon\";\nexport { ThemeProvider, useOptionalTheme, useTheme } from \"./ThemeProvider\";\nexport { ThemeSwitch } from \"./ThemeSwitch\";\nexport type { DefaultTheme, ThemeDefinition, ThemeScheme } from \"./themes\";\n"]}