@tearleads/windowing 0.2.20 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/package.json +1 -1
- package/routed/RoutedPaneAppBar.js +3 -4
- package/routed/RoutedPaneAppBar.js.map +1 -1
- package/window/WindowChromeActions.d.ts +3 -0
- package/window/WindowChromeActions.js +5 -2
- package/window/WindowChromeActions.js.map +1 -1
- package/window/WindowMenuContext.d.ts +3 -3
- package/window/WindowMenuContext.js +3 -3
- package/window/WindowMenuContext.js.map +1 -1
- package/window/WindowRefreshButton.d.ts +6 -0
- package/window/WindowRefreshButton.js +7 -0
- package/window/WindowRefreshButton.js.map +1 -0
- package/window/WindowTitleBar.d.ts +6 -1
- package/window/WindowTitleBar.js.map +1 -1
- package/window/WindowToolBar.d.ts +1 -1
- package/window/WindowToolBar.js +9 -4
- package/window/WindowToolBar.js.map +1 -1
package/README.md
CHANGED
|
@@ -95,8 +95,8 @@ and a window on a hidden surface fits once the surface shows.
|
|
|
95
95
|
- **`ContentBoundary`** — `Window` renders a window's component inside this
|
|
96
96
|
optional wrapper, which receives the `WindowEntry`. Hosts use it to give
|
|
97
97
|
content app-specific context (a route provider, an error boundary) without the
|
|
98
|
-
window layer knowing about apps.
|
|
99
|
-
|
|
98
|
+
window layer knowing about apps. `MiniAppWindow` fills it for launcher apps
|
|
99
|
+
(see [Launching mini-apps](#launching-mini-apps)).
|
|
100
100
|
- **`appId`** — an opaque string a host attaches when creating a window. The
|
|
101
101
|
window layer only stores and compares it; the host interprets it.
|
|
102
102
|
|
|
@@ -120,11 +120,11 @@ useWindowTitleBarAction(
|
|
|
120
120
|
);
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
Memoized `buttonProps` forwards `ref`, `aria-expanded`, and `onMouseDown` to
|
|
124
|
+
popup triggers. Both toolbars place Refresh last; it also remains in View.
|
|
125
|
+
|
|
126
|
+
Windows with an `appId` reserve the toolbar and offer route-history Back.
|
|
127
|
+
With `historyBack={false}`, the row appears when actions register, then stays.
|
|
128
128
|
|
|
129
129
|
## Icons
|
|
130
130
|
|
|
@@ -455,7 +455,7 @@ an external consumer. It needs the network to install the consumer dependencies.
|
|
|
455
455
|
manifest copies `version` from `package.json`. For a release outside that flow,
|
|
456
456
|
bump the version yourself before publishing. The manifest names this repository,
|
|
457
457
|
which npm requires of a version with provenance, and declares
|
|
458
|
-
`"license": "UNLICENSED"
|
|
458
|
+
`"license": "UNLICENSED"`.
|
|
459
459
|
|
|
460
460
|
## Dependency compatibility
|
|
461
461
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tearleads/windowing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
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": {
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ArrowsClockwiseIcon } from "@phosphor-icons/react/dist/csr/ArrowsClockwise";
|
|
3
2
|
import { CaretLeftIcon } from "@phosphor-icons/react/dist/csr/CaretLeft";
|
|
4
3
|
import { CaretRightIcon } from "@phosphor-icons/react/dist/csr/CaretRight";
|
|
5
4
|
import { SidebarSimpleIcon } from "@phosphor-icons/react/dist/csr/SidebarSimple";
|
|
6
5
|
import { useLauncherNavigationActions, useLauncherNavigationState, } from "../launcher/LauncherNavigationProvider.js";
|
|
7
6
|
import { WindowTitleBarActionButtons } from "../window/WindowChromeActions.js";
|
|
8
7
|
import { useWindowBackActionValue, useWindowRefreshMenuItemValue, useWindowTitleBarActions, } from "../window/WindowMenuContext.js";
|
|
8
|
+
import { WindowRefreshButton } from "../window/WindowRefreshButton.js";
|
|
9
9
|
export function RoutedPaneAppBar({ activeAppId, hasSidebar, onToggleSidebar, sidebarExpanded, tier, }) {
|
|
10
10
|
const { goBack, goForward } = useLauncherNavigationActions();
|
|
11
11
|
const { definition, history } = useLauncherNavigationState();
|
|
12
12
|
const backAction = useWindowBackActionValue();
|
|
13
13
|
const toolbarActions = useWindowTitleBarActions();
|
|
14
|
-
//
|
|
15
|
-
// windowed mode reaches through the View menu — rides the toolbar as a glyph.
|
|
14
|
+
// Both hosts draw the same registered refresh action beside app actions.
|
|
16
15
|
const refreshItem = useWindowRefreshMenuItemValue();
|
|
17
16
|
const backLabel = backAction?.label ?? "Back";
|
|
18
17
|
const canGoBack = backAction ? !backAction.disabled : history.canGoBack;
|
|
19
18
|
const sidebarLabel = sidebarExpanded ? "Hide Sidebar" : "Show Sidebar";
|
|
20
19
|
const showToolbar = toolbarActions.length > 0 || refreshItem !== null;
|
|
21
|
-
return (_jsxs("header", { className: "routed-pane-appbar", children: [_jsxs("div", { className: "routed-pane-appbar-primary", children: [_jsxs("div", { className: "routed-pane-history-controls", children: [_jsx("button", { "aria-label": backLabel, className: "routed-pane-iconbutton", disabled: !canGoBack, title: backLabel, type: "button", onClick: backAction?.onClick ?? goBack, children: _jsx(CaretLeftIcon, { "aria-hidden": true, size: 18 }) }), _jsx("button", { "aria-label": "Forward", className: "routed-pane-iconbutton", disabled: !history.canGoForward, title: "Forward", type: "button", onClick: goForward, children: _jsx(CaretRightIcon, { "aria-hidden": true, size: 18 }) })] }), hasSidebar && (_jsx("button", { "aria-controls": "routed-pane-sidebar", "aria-expanded": sidebarExpanded, "aria-label": sidebarLabel, className: "routed-pane-iconbutton", title: sidebarLabel, type: "button", onClick: onToggleSidebar, children: _jsx(SidebarSimpleIcon, { "aria-hidden": true, size: 18 }) })), tier !== "mobile" && (_jsx("div", { className: "routed-pane-title", children: definition.apps[activeAppId]?.title }))] }), _jsx("div", { className: "routed-pane-appbar-spacer" }), showToolbar && (_jsxs("div", { "aria-label": "Toolbar", className: "routed-pane-toolbar", role: "toolbar", children: [_jsx(WindowTitleBarActionButtons, { actions: toolbarActions, className: "routed-pane-iconbutton" }), refreshItem && (_jsx(
|
|
20
|
+
return (_jsxs("header", { className: "routed-pane-appbar", children: [_jsxs("div", { className: "routed-pane-appbar-primary", children: [_jsxs("div", { className: "routed-pane-history-controls", children: [_jsx("button", { "aria-label": backLabel, className: "routed-pane-iconbutton", disabled: !canGoBack, title: backLabel, type: "button", onClick: backAction?.onClick ?? goBack, children: _jsx(CaretLeftIcon, { "aria-hidden": true, size: 18 }) }), _jsx("button", { "aria-label": "Forward", className: "routed-pane-iconbutton", disabled: !history.canGoForward, title: "Forward", type: "button", onClick: goForward, children: _jsx(CaretRightIcon, { "aria-hidden": true, size: 18 }) })] }), hasSidebar && (_jsx("button", { "aria-controls": "routed-pane-sidebar", "aria-expanded": sidebarExpanded, "aria-label": sidebarLabel, className: "routed-pane-iconbutton", title: sidebarLabel, type: "button", onClick: onToggleSidebar, children: _jsx(SidebarSimpleIcon, { "aria-hidden": true, size: 18 }) })), tier !== "mobile" && (_jsx("div", { className: "routed-pane-title", children: definition.apps[activeAppId]?.title }))] }), _jsx("div", { className: "routed-pane-appbar-spacer" }), showToolbar && (_jsxs("div", { "aria-label": "Toolbar", className: "routed-pane-toolbar", role: "toolbar", children: [_jsx(WindowTitleBarActionButtons, { actions: toolbarActions, className: "routed-pane-iconbutton" }), refreshItem && (_jsx(WindowRefreshButton, { className: "routed-pane-iconbutton", item: refreshItem }))] }))] }));
|
|
22
21
|
}
|
|
23
22
|
//# sourceMappingURL=RoutedPaneAppBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutedPaneAppBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneAppBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RoutedPaneAppBar.js","sourceRoot":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AC;AACJ,CAAC","sourcesContent":["import { CaretLeftIcon } from \"@phosphor-icons/react/dist/csr/CaretLeft\";\nimport { CaretRightIcon } from \"@phosphor-icons/react/dist/csr/CaretRight\";\nimport { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { WindowTitleBarActionButtons } from \"../window/WindowChromeActions\";\nimport {\n useWindowBackActionValue,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarActions,\n} from \"../window/WindowMenuContext\";\nimport { WindowRefreshButton } from \"../window/WindowRefreshButton\";\n\nexport function RoutedPaneAppBar({\n activeAppId,\n hasSidebar,\n onToggleSidebar,\n sidebarExpanded,\n tier,\n}: {\n activeAppId: string;\n hasSidebar: boolean;\n onToggleSidebar: () => void;\n sidebarExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const { goBack, goForward } = useLauncherNavigationActions();\n const { definition, history } = useLauncherNavigationState();\n const backAction = useWindowBackActionValue();\n const toolbarActions = useWindowTitleBarActions();\n // Both hosts draw the same registered refresh action beside app actions.\n const refreshItem = useWindowRefreshMenuItemValue();\n const backLabel = backAction?.label ?? \"Back\";\n const canGoBack = backAction ? !backAction.disabled : history.canGoBack;\n const sidebarLabel = sidebarExpanded ? \"Hide Sidebar\" : \"Show Sidebar\";\n const showToolbar = toolbarActions.length > 0 || refreshItem !== null;\n\n return (\n <header className=\"routed-pane-appbar\">\n <div className=\"routed-pane-appbar-primary\">\n <div className=\"routed-pane-history-controls\">\n <button\n aria-label={backLabel}\n className=\"routed-pane-iconbutton\"\n disabled={!canGoBack}\n title={backLabel}\n type=\"button\"\n onClick={backAction?.onClick ?? goBack}\n >\n <CaretLeftIcon aria-hidden size={18} />\n </button>\n <button\n aria-label=\"Forward\"\n className=\"routed-pane-iconbutton\"\n disabled={!history.canGoForward}\n title=\"Forward\"\n type=\"button\"\n onClick={goForward}\n >\n <CaretRightIcon aria-hidden size={18} />\n </button>\n </div>\n {hasSidebar && (\n <button\n aria-controls=\"routed-pane-sidebar\"\n aria-expanded={sidebarExpanded}\n aria-label={sidebarLabel}\n className=\"routed-pane-iconbutton\"\n title={sidebarLabel}\n type=\"button\"\n onClick={onToggleSidebar}\n >\n <SidebarSimpleIcon aria-hidden size={18} />\n </button>\n )}\n {tier !== \"mobile\" && (\n <div className=\"routed-pane-title\">\n {definition.apps[activeAppId]?.title}\n </div>\n )}\n </div>\n <div className=\"routed-pane-appbar-spacer\" />\n {showToolbar && (\n <div\n aria-label=\"Toolbar\"\n className=\"routed-pane-toolbar\"\n role=\"toolbar\"\n >\n <WindowTitleBarActionButtons\n actions={toolbarActions}\n className=\"routed-pane-iconbutton\"\n />\n {refreshItem && (\n <WindowRefreshButton\n className=\"routed-pane-iconbutton\"\n item={refreshItem}\n />\n )}\n </div>\n )}\n </header>\n );\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { WindowTitleBarAction } from "./WindowTitleBar.js";
|
|
3
3
|
export interface WindowTitleBarActionInput {
|
|
4
|
+
buttonProps?: WindowTitleBarAction["buttonProps"];
|
|
4
5
|
disabled?: boolean;
|
|
5
6
|
icon: ReactNode;
|
|
6
7
|
id: string;
|
|
@@ -10,6 +11,7 @@ export interface WindowTitleBarActionInput {
|
|
|
10
11
|
* Reserves the slot immediately left of the lowest-priority toolbar action.
|
|
11
12
|
* If multiple actions request it, the highest-priority action wins, with the
|
|
12
13
|
* action id providing a deterministic tie-break. A sole action stays sole.
|
|
14
|
+
* Refresh follows the registered actions and is not part of this ordering.
|
|
13
15
|
*/
|
|
14
16
|
placement?: "penultimate";
|
|
15
17
|
/**
|
|
@@ -27,6 +29,7 @@ export interface WindowBackActionInput {
|
|
|
27
29
|
priority?: number;
|
|
28
30
|
}
|
|
29
31
|
export interface RegisteredWindowTitleBarAction {
|
|
32
|
+
buttonProps?: WindowTitleBarAction["buttonProps"];
|
|
30
33
|
disabled: boolean;
|
|
31
34
|
icon: ReactNode;
|
|
32
35
|
id: string;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
2
3
|
/**
|
|
3
4
|
* The registered title-bar actions rendered as icon buttons — the shared markup
|
|
4
5
|
* behind the windowed toolbar row and the routed app bar, which differ only in
|
|
5
6
|
* their button class.
|
|
6
7
|
*/
|
|
7
8
|
export function WindowTitleBarActionButtons({ actions, className, }) {
|
|
8
|
-
return (_jsx(_Fragment, { children: actions.map((action) => (
|
|
9
|
+
return (_jsx(_Fragment, { children: actions.map((action) => (_createElement("button", { ...action.buttonProps, "aria-label": action.label, className: className, "aria-pressed": action.pressed, disabled: action.disabled, key: action.id, title: action.label, type: "button", onClick: action.onClick }, action.icon))) }));
|
|
9
10
|
}
|
|
10
11
|
export function createTitleBarActions(items) {
|
|
11
12
|
const ordered = Array.from(items.values()).sort((left, right) => right.priority - left.priority ||
|
|
@@ -18,6 +19,7 @@ export function createTitleBarActions(items) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
return ordered.map((item) => ({
|
|
22
|
+
...(item.buttonProps ? { buttonProps: item.buttonProps } : {}),
|
|
21
23
|
disabled: item.disabled,
|
|
22
24
|
icon: item.icon,
|
|
23
25
|
id: item.id,
|
|
@@ -30,6 +32,7 @@ export function createTitleBarActions(items) {
|
|
|
30
32
|
}
|
|
31
33
|
export function createRegisteredTitleBarAction(item, onClick) {
|
|
32
34
|
return {
|
|
35
|
+
...(item.buttonProps ? { buttonProps: item.buttonProps } : {}),
|
|
33
36
|
disabled: item.disabled ?? false,
|
|
34
37
|
icon: item.icon,
|
|
35
38
|
id: item.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WindowChromeActions.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowChromeActions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WindowChromeActions.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowChromeActions.tsx"],"names":[],"mappings":";;AA0DA;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAC1C,OAAO,EACP,SAAS,GAIV;IACC,OAAO,CACL,4BACG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,8BACM,MAAM,CAAC,WAAW,gBACV,MAAM,CAAC,KAAK,EACxB,SAAS,EAAE,SAAS,kBACN,MAAM,CAAC,OAAO,EAC5B,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,GAAG,EAAE,MAAM,CAAC,EAAE,EACd,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,MAAM,CAAC,IAAI,CACL,CACV,CAAC,GACD,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAA0D;IAE1D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAC7C,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACd,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ;QAC9B,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACzD,CAAC;IACF,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,C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C,IAAI;QACf,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO;QACP,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI;QAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,IAA2B,EAC3B,OAAsB;IAEtB,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;QAChC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO;QACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,IAAuC;IAEvC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport type { WindowTitleBarAction } from \"./WindowTitleBar\";\n\nexport interface WindowTitleBarActionInput {\n buttonProps?: WindowTitleBarAction[\"buttonProps\"];\n disabled?: boolean;\n icon: ReactNode;\n id: string;\n label: string;\n onClick: () => unknown;\n /**\n * Reserves the slot immediately left of the lowest-priority toolbar action.\n * If multiple actions request it, the highest-priority action wins, with the\n * action id providing a deterministic tie-break. A sole action stays sole.\n * Refresh follows the registered actions and is not part of this ordering.\n */\n placement?: \"penultimate\";\n /**\n * Makes the action a toggle: the button announces this value as\n * `aria-pressed` and the toolbar draws it pressed while true. Leave it unset\n * for an action that is not a toggle.\n */\n pressed?: boolean;\n priority?: number;\n}\n\nexport interface WindowBackActionInput {\n disabled?: boolean;\n label: string;\n onClick: () => unknown;\n priority?: number;\n}\n\nexport interface RegisteredWindowTitleBarAction {\n buttonProps?: WindowTitleBarAction[\"buttonProps\"];\n disabled: boolean;\n icon: ReactNode;\n id: string;\n label: string;\n onClick: () => unknown;\n placement: \"penultimate\" | null;\n pressed: boolean | null;\n priority: number;\n}\n\nexport interface RegisteredWindowBackAction {\n disabled: boolean;\n label: string;\n onClick: () => unknown;\n priority: number;\n}\n\nexport interface WindowBackAction {\n disabled?: boolean;\n label: string;\n onClick: () => void;\n}\n\n/**\n * The registered title-bar actions rendered as icon buttons — the shared markup\n * behind the windowed toolbar row and the routed app bar, which differ only in\n * their button class.\n */\nexport function WindowTitleBarActionButtons({\n actions,\n className,\n}: {\n actions: ReadonlyArray<WindowTitleBarAction>;\n className: string;\n}) {\n return (\n <>\n {actions.map((action) => (\n <button\n {...action.buttonProps}\n aria-label={action.label}\n className={className}\n aria-pressed={action.pressed}\n disabled={action.disabled}\n key={action.id}\n title={action.label}\n type=\"button\"\n onClick={action.onClick}\n >\n {action.icon}\n </button>\n ))}\n </>\n );\n}\n\nexport function createTitleBarActions(\n items: ReadonlyMap<object, RegisteredWindowTitleBarAction>,\n): WindowTitleBarAction[] {\n const ordered = Array.from(items.values()).sort(\n (left, right) =>\n right.priority - left.priority ||\n (left.id < right.id ? -1 : left.id > right.id ? 1 : 0),\n );\n const penultimateIndex = ordered.findIndex(\n (item) => item.placement === \"penultimate\",\n );\n if (penultimateIndex >= 0 && ordered.length > 1) {\n const [penultimate] = ordered.splice(penultimateIndex, 1);\n if (penultimate) {\n ordered.splice(ordered.length - 1, 0, penultimate);\n }\n }\n\n return ordered.map((item) => ({\n ...(item.buttonProps ? { buttonProps: item.buttonProps } : {}),\n disabled: item.disabled,\n icon: item.icon,\n id: item.id,\n label: item.label,\n onClick: () => {\n void item.onClick();\n },\n ...(item.pressed === null ? {} : { pressed: item.pressed }),\n }));\n}\n\nexport function createRegisteredTitleBarAction(\n item: WindowTitleBarActionInput,\n onClick: () => unknown,\n): RegisteredWindowTitleBarAction {\n return {\n ...(item.buttonProps ? { buttonProps: item.buttonProps } : {}),\n disabled: item.disabled ?? false,\n icon: item.icon,\n id: item.id,\n label: item.label,\n onClick,\n placement: item.placement ?? null,\n pressed: item.pressed ?? null,\n priority: item.priority ?? 0,\n };\n}\n\nexport function createRegisteredBackAction(\n item: WindowBackActionInput,\n onClick: () => unknown,\n): RegisteredWindowBackAction {\n return {\n disabled: item.disabled ?? false,\n label: item.label,\n onClick,\n priority: item.priority ?? 0,\n };\n}\n\nexport function createBackAction(\n item: RegisteredWindowBackAction | null,\n): WindowBackAction | null {\n if (!item) {\n return null;\n }\n\n return {\n disabled: item.disabled,\n label: item.label,\n onClick: () => {\n void item.onClick();\n },\n };\n}\n"]}
|
|
@@ -27,10 +27,10 @@ export declare function useWindowToolbarReservationReleased(): boolean;
|
|
|
27
27
|
export declare function useWindowFileMenuItem(item: WindowFileMenuItemInput | null): void;
|
|
28
28
|
export declare function useWindowViewMenuItem(item: WindowFileMenuItemInput | null): void;
|
|
29
29
|
/**
|
|
30
|
-
* Registers an action in the current window's
|
|
30
|
+
* Registers an action in the current window's toolbar.
|
|
31
31
|
*
|
|
32
|
-
* Keep `
|
|
33
|
-
*
|
|
32
|
+
* Keep `icon` and `buttonProps` reference-stable (for example with `useMemo`)
|
|
33
|
+
* so context updates do not continuously re-register the action.
|
|
34
34
|
*/
|
|
35
35
|
export declare function useWindowTitleBarAction(item: WindowTitleBarActionInput | null): void;
|
|
36
36
|
export declare function useWindowBackAction(item: WindowBackActionInput | null): void;
|
|
@@ -142,10 +142,10 @@ export function useWindowViewMenuItem(item) {
|
|
|
142
142
|
useRegisteredWindowMenuItem(item, registerViewMenuItem, unregisterViewMenuItem);
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
|
-
* Registers an action in the current window's
|
|
145
|
+
* Registers an action in the current window's toolbar.
|
|
146
146
|
*
|
|
147
|
-
* Keep `
|
|
148
|
-
*
|
|
147
|
+
* Keep `icon` and `buttonProps` reference-stable (for example with `useMemo`)
|
|
148
|
+
* so context updates do not continuously re-register the action.
|
|
149
149
|
*/
|
|
150
150
|
export function useWindowTitleBarAction(item) {
|
|
151
151
|
const { registerTitleBarAction, unregisterTitleBarAction } = useContext(WindowMenuContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WindowMenuContext.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowMenuContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,GAMtB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,GAGd,MAAM,2BAA2B,CAAC;AAkBnC,SAAS,wBAAwB,CAC/B,IAA6B,EAC7B,OAAsB;IAEtB,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO;QACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B,CACtC,IAAgC,EAChC,SAAwB;IAExB,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;QAChC,KAAK,EAAE,IAAI,CAAC,KAAK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A0B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,GAAG,EAAE,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,IAAuC;IAEvC,MAAM,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,GAC1D,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAChC,yBAAyB,CAAC;QACxB,MAAM,EAAE,IAAI,EAAE,SAAS,IAAI,IAAI;QAC/B,oBAAoB,EAAE,+BAA+B;QACrD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,uBAAuB;QACrC,cAAc,EAAE,yBAAyB;KAC1C,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { useWindowItemRegistration } from \"./useWindowItemRegistration\";\nimport {\n sameWindowItem,\n selectHighestPriorityItem,\n useWindowItemRegistry,\n} from \"./useWindowItemRegistry\";\nimport { useWindowToolbarReservationRegistry } from \"./useWindowToolbarReservationRegistry\";\nimport {\n createBackAction,\n createRegisteredBackAction,\n createRegisteredTitleBarAction,\n createTitleBarActions,\n type RegisteredWindowBackAction,\n type RegisteredWindowTitleBarAction,\n type WindowBackAction,\n type WindowBackActionInput,\n type WindowTitleBarActionInput,\n} from \"./WindowChromeActions\";\nimport type { WindowMenuItem } from \"./WindowMenuBar\";\nimport type { WindowTitleBarAction } from \"./WindowTitleBar\";\nimport {\n createMenuItems,\n createRefreshMenuItem,\n REFRESH_LABEL,\n type RegisteredWindowMenuItem,\n type RegisteredWindowRefreshMenuItem,\n} from \"./windowMenuRegistrations\";\n\ninterface WindowRefreshMenuItemInput {\n disabled?: boolean;\n label?: string;\n onRefresh: () => unknown;\n priority?: number;\n refreshing?: boolean;\n}\n\ninterface WindowFileMenuItemInput {\n disabled?: boolean;\n id: string;\n label: string;\n onClick: () => unknown;\n priority?: number;\n}\n\nfunction createRegisteredMenuItem(\n item: WindowFileMenuItemInput,\n onClick: () => unknown,\n): RegisteredWindowMenuItem {\n return {\n disabled: item.disabled ?? false,\n id: item.id,\n label: item.label,\n onClick,\n priority: item.priority ?? 0,\n };\n}\n\nfunction createRegisteredRefreshMenuItem(\n item: WindowRefreshMenuItemInput,\n onRefresh: () => unknown,\n): RegisteredWindowRefreshMenuItem {\n return {\n disabled: item.disabled ?? false,\n label: item.label ?? REFRESH_LABEL,\n onRefresh,\n priority: item.priority ?? 0,\n refreshing: item.refreshing ?? false,\n };\n}\n\ninterface WindowMenuContextValue {\n fileMenuItems: WindowMenuItem[];\n viewMenuItems: WindowMenuItem[];\n /**\n * The winning refresh registration, also folded into `viewMenuItems` for the\n * windowed menu bar. Exposed on its own because the routed shell has no menu\n * bar and renders it as an app bar toolbar button instead.\n */\n refreshMenuItem: WindowMenuItem | null;\n titleBarActions: WindowTitleBarAction[];\n backAction: WindowBackAction | null;\n toolbarReserved: boolean;\n toolbarReservationReleased: boolean;\n registerFileMenuItem: (id: object, item: RegisteredWindowMenuItem) => void;\n unregisterFileMenuItem: (id: object) => void;\n registerViewMenuItem: (id: object, item: RegisteredWindowMenuItem) => void;\n unregisterViewMenuItem: (id: object) => void;\n registerTitleBarAction: (\n id: object,\n item: RegisteredWindowTitleBarAction,\n ) => void;\n unregisterTitleBarAction: (id: object) => void;\n registerBackAction: (id: object, item: RegisteredWindowBackAction) => void;\n unregisterBackAction: (id: object) => void;\n registerRefreshMenuItem: (\n id: object,\n item: RegisteredWindowRefreshMenuItem,\n ) => void;\n unregisterRefreshMenuItem: (id: object) => void;\n registerToolbarReservation: (id: object, reserved: boolean) => void;\n unregisterToolbarReservation: (id: object) => void;\n}\n\nconst WindowMenuContext = createContext<WindowMenuContextValue>({\n fileMenuItems: [],\n viewMenuItems: [],\n refreshMenuItem: null,\n titleBarActions: [],\n backAction: null,\n toolbarReserved: false,\n toolbarReservationReleased: false,\n registerFileMenuItem: () => {},\n unregisterFileMenuItem: () => {},\n registerViewMenuItem: () => {},\n unregisterViewMenuItem: () => {},\n registerTitleBarAction: () => {},\n unregisterTitleBarAction: () => {},\n registerBackAction: () => {},\n unregisterBackAction: () => {},\n registerRefreshMenuItem: () => {},\n unregisterRefreshMenuItem: () => {},\n registerToolbarReservation: () => {},\n unregisterToolbarReservation: () => {},\n});\n\nfunction useWindowMenuContextValue(): WindowMenuContextValue {\n const fileMenu =\n useWindowItemRegistry<RegisteredWindowMenuItem>(sameWindowItem);\n const viewMenu =\n useWindowItemRegistry<RegisteredWindowMenuItem>(sameWindowItem);\n const titleBar =\n useWindowItemRegistry<RegisteredWindowTitleBarAction>(sameWindowItem);\n const back =\n useWindowItemRegistry<RegisteredWindowBackAction>(sameWindowItem);\n const refresh =\n useWindowItemRegistry<RegisteredWindowRefreshMenuItem>(sameWindowItem);\n const toolbarReservation = useWindowToolbarReservationRegistry();\n\n const fileMenuItemList = useMemo(\n () => createMenuItems(fileMenu.items),\n [fileMenu.items],\n );\n const refreshMenuItem = useMemo(\n () => createRefreshMenuItem(selectHighestPriorityItem(refresh.items)),\n [refresh.items],\n );\n const viewMenuItemList = useMemo(\n () => [\n ...createMenuItems(viewMenu.items),\n ...(refreshMenuItem ? [refreshMenuItem] : []),\n ],\n [refreshMenuItem, viewMenu.items],\n );\n const titleBarActionList = useMemo(\n () => createTitleBarActions(titleBar.items),\n [titleBar.items],\n );\n const backAction = useMemo(\n () => createBackAction(selectHighestPriorityItem(back.items)),\n [back.items],\n );\n\n const value = useMemo(\n () => ({\n fileMenuItems: fileMenuItemList,\n viewMenuItems: viewMenuItemList,\n refreshMenuItem,\n titleBarActions: titleBarActionList,\n backAction,\n toolbarReserved: toolbarReservation.reserved,\n toolbarReservationReleased: toolbarReservation.released,\n registerFileMenuItem: fileMenu.registerItem,\n unregisterFileMenuItem: fileMenu.unregisterItem,\n registerViewMenuItem: viewMenu.registerItem,\n unregisterViewMenuItem: viewMenu.unregisterItem,\n registerTitleBarAction: titleBar.registerItem,\n unregisterTitleBarAction: titleBar.unregisterItem,\n registerBackAction: back.registerItem,\n unregisterBackAction: back.unregisterItem,\n registerRefreshMenuItem: refresh.registerItem,\n unregisterRefreshMenuItem: refresh.unregisterItem,\n registerToolbarReservation: toolbarReservation.register,\n unregisterToolbarReservation: toolbarReservation.unregister,\n }),\n [\n fileMenuItemList,\n viewMenuItemList,\n refreshMenuItem,\n titleBarActionList,\n backAction,\n toolbarReservation,\n fileMenu.registerItem,\n fileMenu.unregisterItem,\n viewMenu.registerItem,\n viewMenu.unregisterItem,\n titleBar.registerItem,\n titleBar.unregisterItem,\n back.registerItem,\n back.unregisterItem,\n refresh.registerItem,\n refresh.unregisterItem,\n ],\n );\n\n return value;\n}\n\nexport function WindowMenuProvider({ children }: PropsWithChildren) {\n const value = useWindowMenuContextValue();\n\n return (\n <WindowMenuContext.Provider value={value}>\n {children}\n </WindowMenuContext.Provider>\n );\n}\n\nexport function useWindowFileMenuItems(): WindowMenuItem[] {\n return useContext(WindowMenuContext).fileMenuItems;\n}\n\nexport function useWindowViewMenuItems(): WindowMenuItem[] {\n return useContext(WindowMenuContext).viewMenuItems;\n}\n\nexport function useWindowRefreshMenuItemValue(): WindowMenuItem | null {\n return useContext(WindowMenuContext).refreshMenuItem;\n}\n\nexport function useWindowTitleBarActions(): WindowTitleBarAction[] {\n return useContext(WindowMenuContext).titleBarActions;\n}\n\nexport function useWindowBackActionValue(): WindowBackAction | null {\n return useContext(WindowMenuContext).backAction;\n}\n\nexport function useWindowToolbarReserved(): boolean {\n return useContext(WindowMenuContext).toolbarReserved;\n}\n\nexport function useWindowToolbarReservationReleased(): boolean {\n return useContext(WindowMenuContext).toolbarReservationReleased;\n}\n\nfunction useRegisteredWindowMenuItem(\n item: WindowFileMenuItemInput | null,\n registerMenuItem: (id: object, item: RegisteredWindowMenuItem) => void,\n unregisterMenuItem: (id: object) => void,\n): void {\n useWindowItemRegistration({\n action: item?.onClick ?? null,\n createRegisteredItem: createRegisteredMenuItem,\n input: item,\n registerItem: registerMenuItem,\n unregisterItem: unregisterMenuItem,\n });\n}\n\nexport function useWindowFileMenuItem(\n item: WindowFileMenuItemInput | null,\n): void {\n const { registerFileMenuItem, unregisterFileMenuItem } =\n useContext(WindowMenuContext);\n useRegisteredWindowMenuItem(\n item,\n registerFileMenuItem,\n unregisterFileMenuItem,\n );\n}\n\nexport function useWindowViewMenuItem(\n item: WindowFileMenuItemInput | null,\n): void {\n const { registerViewMenuItem, unregisterViewMenuItem } =\n useContext(WindowMenuContext);\n useRegisteredWindowMenuItem(\n item,\n registerViewMenuItem,\n unregisterViewMenuItem,\n );\n}\n\n/**\n * Registers an action in the current window's title bar.\n *\n * Keep `item` and its `icon` reference-stable, such as by memoizing them with\n * `useMemo`, so the window does not re-register the action on every render.\n */\nexport function useWindowTitleBarAction(\n item: WindowTitleBarActionInput | null,\n): void {\n const { registerTitleBarAction, unregisterTitleBarAction } =\n useContext(WindowMenuContext);\n useWindowItemRegistration({\n action: item?.onClick ?? null,\n createRegisteredItem: createRegisteredTitleBarAction,\n input: item,\n registerItem: registerTitleBarAction,\n unregisterItem: unregisterTitleBarAction,\n });\n}\n\nexport function useWindowBackAction(item: WindowBackActionInput | null): void {\n const { registerBackAction, unregisterBackAction } =\n useContext(WindowMenuContext);\n useWindowItemRegistration({\n action: item?.onClick ?? null,\n createRegisteredItem: createRegisteredBackAction,\n input: item,\n registerItem: registerBackAction,\n unregisterItem: unregisterBackAction,\n });\n}\n\n/**\n * Keeps this window's toolbar row reserved (rendered) while the caller is\n * mounted, even when it registers no title-bar or back actions. A mini-app that\n * wants explorer-style chrome on every route — a blank bar on the routes that\n * have no actions rather than a collapsing/reappearing row — calls this once.\n * Pass `reserve = false` to release the reservation without unmounting.\n */\nexport function useWindowToolbarReservation(reserve = true): void {\n const { registerToolbarReservation, unregisterToolbarReservation } =\n useContext(WindowMenuContext);\n const idRef = useRef<object>({});\n const hasEverReservedRef = useRef(false);\n\n useEffect(() => {\n const id = idRef.current;\n\n if (reserve) {\n hasEverReservedRef.current = true;\n registerToolbarReservation(id, true);\n return () => unregisterToolbarReservation(id);\n }\n\n if (!hasEverReservedRef.current) {\n return;\n }\n\n // A caller that previously reserved the row is now explicitly releasing it.\n // This lets WindowToolBar clear its latched blank row while callers that\n // never opted into reservations keep the older latch-once behavior.\n registerToolbarReservation(id, false);\n return () => unregisterToolbarReservation(id);\n }, [reserve, registerToolbarReservation, unregisterToolbarReservation]);\n}\n\nexport function useWindowRefreshMenuItem(\n item: WindowRefreshMenuItemInput | null,\n): void {\n const { registerRefreshMenuItem, unregisterRefreshMenuItem } =\n useContext(WindowMenuContext);\n useWindowItemRegistration({\n action: item?.onRefresh ?? null,\n createRegisteredItem: createRegisteredRefreshMenuItem,\n input: item,\n registerItem: registerRefreshMenuItem,\n unregisterItem: unregisterRefreshMenuItem,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"WindowMenuContext.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowMenuContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,GAMtB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,GAGd,MAAM,2BAA2B,CAAC;AAkBnC,SAAS,wBAAwB,CAC/B,IAA6B,EAC7B,OAAsB;IAEtB,OAAO;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AAK,CAAC,OAAO,CAAC;QAEzB,IAAI,OAAO,EAAE,CAAC;YACZ,kBAAkB,CAAC,OAAO,GAAG,IAAI,CAAC;YAClC,0BAA0B,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACrC,OAAO,GAAG,EAAE,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAED,4EAA4E;QAC5E,yEAAyE;QACzE,oEAAoE;QACpE,0BAA0B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,GAAG,EAAE,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,IAAuC;IAEvC,MAAM,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,GAC1D,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAChC,yBAAyB,CAAC;QACxB,MAAM,EAAE,IAAI,EAAE,SAAS,IAAI,IAAI;QAC/B,oBAAoB,EAAE,+BAA+B;QACrD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,uBAAuB;QACrC,cAAc,EAAE,yBAAyB;KAC1C,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n createContext,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { useWindowItemRegistration } from \"./useWindowItemRegistration\";\nimport {\n sameWindowItem,\n selectHighestPriorityItem,\n useWindowItemRegistry,\n} from \"./useWindowItemRegistry\";\nimport { useWindowToolbarReservationRegistry } from \"./useWindowToolbarReservationRegistry\";\nimport {\n createBackAction,\n createRegisteredBackAction,\n createRegisteredTitleBarAction,\n createTitleBarActions,\n type RegisteredWindowBackAction,\n type RegisteredWindowTitleBarAction,\n type WindowBackAction,\n type WindowBackActionInput,\n type WindowTitleBarActionInput,\n} from \"./WindowChromeActions\";\nimport type { WindowMenuItem } from \"./WindowMenuBar\";\nimport type { WindowTitleBarAction } from \"./WindowTitleBar\";\nimport {\n createMenuItems,\n createRefreshMenuItem,\n REFRESH_LABEL,\n type RegisteredWindowMenuItem,\n type RegisteredWindowRefreshMenuItem,\n} from \"./windowMenuRegistrations\";\n\ninterface WindowRefreshMenuItemInput {\n disabled?: boolean;\n label?: string;\n onRefresh: () => unknown;\n priority?: number;\n refreshing?: boolean;\n}\n\ninterface WindowFileMenuItemInput {\n disabled?: boolean;\n id: string;\n label: string;\n onClick: () => unknown;\n priority?: number;\n}\n\nfunction createRegisteredMenuItem(\n item: WindowFileMenuItemInput,\n onClick: () => unknown,\n): RegisteredWindowMenuItem {\n return {\n disabled: item.disabled ?? false,\n id: item.id,\n label: item.label,\n onClick,\n priority: item.priority ?? 0,\n };\n}\n\nfunction createRegisteredRefreshMenuItem(\n item: WindowRefreshMenuItemInput,\n onRefresh: () => unknown,\n): RegisteredWindowRefreshMenuItem {\n return {\n disabled: item.disabled ?? false,\n label: item.label ?? REFRESH_LABEL,\n onRefresh,\n priority: item.priority ?? 0,\n refreshing: item.refreshing ?? false,\n };\n}\n\ninterface WindowMenuContextValue {\n fileMenuItems: WindowMenuItem[];\n viewMenuItems: WindowMenuItem[];\n /**\n * The winning refresh registration, also folded into `viewMenuItems` for the\n * windowed menu bar. Exposed on its own for the Refresh button shared by the\n * windowed toolbar and routed app bar.\n */\n refreshMenuItem: WindowMenuItem | null;\n titleBarActions: WindowTitleBarAction[];\n backAction: WindowBackAction | null;\n toolbarReserved: boolean;\n toolbarReservationReleased: boolean;\n registerFileMenuItem: (id: object, item: RegisteredWindowMenuItem) => void;\n unregisterFileMenuItem: (id: object) => void;\n registerViewMenuItem: (id: object, item: RegisteredWindowMenuItem) => void;\n unregisterViewMenuItem: (id: object) => void;\n registerTitleBarAction: (\n id: object,\n item: RegisteredWindowTitleBarAction,\n ) => void;\n unregisterTitleBarAction: (id: object) => void;\n registerBackAction: (id: object, item: RegisteredWindowBackAction) => void;\n unregisterBackAction: (id: object) => void;\n registerRefreshMenuItem: (\n id: object,\n item: RegisteredWindowRefreshMenuItem,\n ) => void;\n unregisterRefreshMenuItem: (id: object) => void;\n registerToolbarReservation: (id: object, reserved: boolean) => void;\n unregisterToolbarReservation: (id: object) => void;\n}\n\nconst WindowMenuContext = createContext<WindowMenuContextValue>({\n fileMenuItems: [],\n viewMenuItems: [],\n refreshMenuItem: null,\n titleBarActions: [],\n backAction: null,\n toolbarReserved: false,\n toolbarReservationReleased: false,\n registerFileMenuItem: () => {},\n unregisterFileMenuItem: () => {},\n registerViewMenuItem: () => {},\n unregisterViewMenuItem: () => {},\n registerTitleBarAction: () => {},\n unregisterTitleBarAction: () => {},\n registerBackAction: () => {},\n unregisterBackAction: () => {},\n registerRefreshMenuItem: () => {},\n unregisterRefreshMenuItem: () => {},\n registerToolbarReservation: () => {},\n unregisterToolbarReservation: () => {},\n});\n\nfunction useWindowMenuContextValue(): WindowMenuContextValue {\n const fileMenu =\n useWindowItemRegistry<RegisteredWindowMenuItem>(sameWindowItem);\n const viewMenu =\n useWindowItemRegistry<RegisteredWindowMenuItem>(sameWindowItem);\n const titleBar =\n useWindowItemRegistry<RegisteredWindowTitleBarAction>(sameWindowItem);\n const back =\n useWindowItemRegistry<RegisteredWindowBackAction>(sameWindowItem);\n const refresh =\n useWindowItemRegistry<RegisteredWindowRefreshMenuItem>(sameWindowItem);\n const toolbarReservation = useWindowToolbarReservationRegistry();\n\n const fileMenuItemList = useMemo(\n () => createMenuItems(fileMenu.items),\n [fileMenu.items],\n );\n const refreshMenuItem = useMemo(\n () => createRefreshMenuItem(selectHighestPriorityItem(refresh.items)),\n [refresh.items],\n );\n const viewMenuItemList = useMemo(\n () => [\n ...createMenuItems(viewMenu.items),\n ...(refreshMenuItem ? [refreshMenuItem] : []),\n ],\n [refreshMenuItem, viewMenu.items],\n );\n const titleBarActionList = useMemo(\n () => createTitleBarActions(titleBar.items),\n [titleBar.items],\n );\n const backAction = useMemo(\n () => createBackAction(selectHighestPriorityItem(back.items)),\n [back.items],\n );\n\n const value = useMemo(\n () => ({\n fileMenuItems: fileMenuItemList,\n viewMenuItems: viewMenuItemList,\n refreshMenuItem,\n titleBarActions: titleBarActionList,\n backAction,\n toolbarReserved: toolbarReservation.reserved,\n toolbarReservationReleased: toolbarReservation.released,\n registerFileMenuItem: fileMenu.registerItem,\n unregisterFileMenuItem: fileMenu.unregisterItem,\n registerViewMenuItem: viewMenu.registerItem,\n unregisterViewMenuItem: viewMenu.unregisterItem,\n registerTitleBarAction: titleBar.registerItem,\n unregisterTitleBarAction: titleBar.unregisterItem,\n registerBackAction: back.registerItem,\n unregisterBackAction: back.unregisterItem,\n registerRefreshMenuItem: refresh.registerItem,\n unregisterRefreshMenuItem: refresh.unregisterItem,\n registerToolbarReservation: toolbarReservation.register,\n unregisterToolbarReservation: toolbarReservation.unregister,\n }),\n [\n fileMenuItemList,\n viewMenuItemList,\n refreshMenuItem,\n titleBarActionList,\n backAction,\n toolbarReservation,\n fileMenu.registerItem,\n fileMenu.unregisterItem,\n viewMenu.registerItem,\n viewMenu.unregisterItem,\n titleBar.registerItem,\n titleBar.unregisterItem,\n back.registerItem,\n back.unregisterItem,\n refresh.registerItem,\n refresh.unregisterItem,\n ],\n );\n\n return value;\n}\n\nexport function WindowMenuProvider({ children }: PropsWithChildren) {\n const value = useWindowMenuContextValue();\n\n return (\n <WindowMenuContext.Provider value={value}>\n {children}\n </WindowMenuContext.Provider>\n );\n}\n\nexport function useWindowFileMenuItems(): WindowMenuItem[] {\n return useContext(WindowMenuContext).fileMenuItems;\n}\n\nexport function useWindowViewMenuItems(): WindowMenuItem[] {\n return useContext(WindowMenuContext).viewMenuItems;\n}\n\nexport function useWindowRefreshMenuItemValue(): WindowMenuItem | null {\n return useContext(WindowMenuContext).refreshMenuItem;\n}\n\nexport function useWindowTitleBarActions(): WindowTitleBarAction[] {\n return useContext(WindowMenuContext).titleBarActions;\n}\n\nexport function useWindowBackActionValue(): WindowBackAction | null {\n return useContext(WindowMenuContext).backAction;\n}\n\nexport function useWindowToolbarReserved(): boolean {\n return useContext(WindowMenuContext).toolbarReserved;\n}\n\nexport function useWindowToolbarReservationReleased(): boolean {\n return useContext(WindowMenuContext).toolbarReservationReleased;\n}\n\nfunction useRegisteredWindowMenuItem(\n item: WindowFileMenuItemInput | null,\n registerMenuItem: (id: object, item: RegisteredWindowMenuItem) => void,\n unregisterMenuItem: (id: object) => void,\n): void {\n useWindowItemRegistration({\n action: item?.onClick ?? null,\n createRegisteredItem: createRegisteredMenuItem,\n input: item,\n registerItem: registerMenuItem,\n unregisterItem: unregisterMenuItem,\n });\n}\n\nexport function useWindowFileMenuItem(\n item: WindowFileMenuItemInput | null,\n): void {\n const { registerFileMenuItem, unregisterFileMenuItem } =\n useContext(WindowMenuContext);\n useRegisteredWindowMenuItem(\n item,\n registerFileMenuItem,\n unregisterFileMenuItem,\n );\n}\n\nexport function useWindowViewMenuItem(\n item: WindowFileMenuItemInput | null,\n): void {\n const { registerViewMenuItem, unregisterViewMenuItem } =\n useContext(WindowMenuContext);\n useRegisteredWindowMenuItem(\n item,\n registerViewMenuItem,\n unregisterViewMenuItem,\n );\n}\n\n/**\n * Registers an action in the current window's toolbar.\n *\n * Keep `icon` and `buttonProps` reference-stable (for example with `useMemo`)\n * so context updates do not continuously re-register the action.\n */\nexport function useWindowTitleBarAction(\n item: WindowTitleBarActionInput | null,\n): void {\n const { registerTitleBarAction, unregisterTitleBarAction } =\n useContext(WindowMenuContext);\n useWindowItemRegistration({\n action: item?.onClick ?? null,\n createRegisteredItem: createRegisteredTitleBarAction,\n input: item,\n registerItem: registerTitleBarAction,\n unregisterItem: unregisterTitleBarAction,\n });\n}\n\nexport function useWindowBackAction(item: WindowBackActionInput | null): void {\n const { registerBackAction, unregisterBackAction } =\n useContext(WindowMenuContext);\n useWindowItemRegistration({\n action: item?.onClick ?? null,\n createRegisteredItem: createRegisteredBackAction,\n input: item,\n registerItem: registerBackAction,\n unregisterItem: unregisterBackAction,\n });\n}\n\n/**\n * Keeps this window's toolbar row reserved (rendered) while the caller is\n * mounted, even when it registers no title-bar or back actions. A mini-app that\n * wants explorer-style chrome on every route — a blank bar on the routes that\n * have no actions rather than a collapsing/reappearing row — calls this once.\n * Pass `reserve = false` to release the reservation without unmounting.\n */\nexport function useWindowToolbarReservation(reserve = true): void {\n const { registerToolbarReservation, unregisterToolbarReservation } =\n useContext(WindowMenuContext);\n const idRef = useRef<object>({});\n const hasEverReservedRef = useRef(false);\n\n useEffect(() => {\n const id = idRef.current;\n\n if (reserve) {\n hasEverReservedRef.current = true;\n registerToolbarReservation(id, true);\n return () => unregisterToolbarReservation(id);\n }\n\n if (!hasEverReservedRef.current) {\n return;\n }\n\n // A caller that previously reserved the row is now explicitly releasing it.\n // This lets WindowToolBar clear its latched blank row while callers that\n // never opted into reservations keep the older latch-once behavior.\n registerToolbarReservation(id, false);\n return () => unregisterToolbarReservation(id);\n }, [reserve, registerToolbarReservation, unregisterToolbarReservation]);\n}\n\nexport function useWindowRefreshMenuItem(\n item: WindowRefreshMenuItemInput | null,\n): void {\n const { registerRefreshMenuItem, unregisterRefreshMenuItem } =\n useContext(WindowMenuContext);\n useWindowItemRegistration({\n action: item?.onRefresh ?? null,\n createRegisteredItem: createRegisteredRefreshMenuItem,\n input: item,\n registerItem: registerRefreshMenuItem,\n unregisterItem: unregisterRefreshMenuItem,\n });\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WindowMenuItem } from "./WindowMenuBar.js";
|
|
2
|
+
/** The registered refresh action shared by floating and routed toolbars. */
|
|
3
|
+
export declare function WindowRefreshButton({ className, item, }: {
|
|
4
|
+
className: string;
|
|
5
|
+
item: WindowMenuItem;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowsClockwiseIcon } from "@phosphor-icons/react/dist/csr/ArrowsClockwise";
|
|
3
|
+
/** The registered refresh action shared by floating and routed toolbars. */
|
|
4
|
+
export function WindowRefreshButton({ className, item, }) {
|
|
5
|
+
return (_jsx("button", { "aria-label": item.label, className: className, disabled: item.disabled, title: item.label, type: "button", onClick: item.onClick, children: _jsx(ArrowsClockwiseIcon, { "aria-hidden": true, size: 18 }) }));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=WindowRefreshButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WindowRefreshButton.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowRefreshButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAGrF,4EAA4E;AAC5E,MAAM,UAAU,mBAAmB,CAAC,EAClC,SAAS,EACT,IAAI,GAIL;IACC,OAAO,CACL,+BACc,IAAI,CAAC,KAAK,EACtB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,IAAI,CAAC,OAAO,YAErB,KAAC,mBAAmB,yBAAa,IAAI,EAAE,EAAE,GAAI,GACtC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { ArrowsClockwiseIcon } from \"@phosphor-icons/react/dist/csr/ArrowsClockwise\";\nimport type { WindowMenuItem } from \"./WindowMenuBar\";\n\n/** The registered refresh action shared by floating and routed toolbars. */\nexport function WindowRefreshButton({\n className,\n item,\n}: {\n className: string;\n item: WindowMenuItem;\n}) {\n return (\n <button\n aria-label={item.label}\n className={className}\n disabled={item.disabled}\n title={item.label}\n type=\"button\"\n onClick={item.onClick}\n >\n <ArrowsClockwiseIcon aria-hidden size={18} />\n </button>\n );\n}\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
2
|
export interface WindowTitleBarAction {
|
|
3
|
+
/**
|
|
4
|
+
* Memoized popup trigger attributes. Custom action hosts must spread these
|
|
5
|
+
* onto their button, including the ref used to anchor the popup.
|
|
6
|
+
*/
|
|
7
|
+
buttonProps?: Pick<ComponentProps<"button">, "aria-expanded" | "onMouseDown" | "ref">;
|
|
3
8
|
disabled?: boolean;
|
|
4
9
|
icon: ReactNode;
|
|
5
10
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WindowTitleBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowTitleBar.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"WindowTitleBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowTitleBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuC,WAAW,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmB9D,MAAM,UAAU,cAAc,CAAC,EAC7B,KAAK,EACL,OAAO,EACP,aAAa,EACb,UAAU,EACV,UAAU,EACV,OAAO,EACP,aAAa,EACb,cAAc,GAUf;IACC,MAAM,EAAE,gBAAgB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MAAM,aAEhB,KAAC,QAAQ,IACP,IAAI,EAAE,KAAK,CAAC,WAAW,EACvB,KAAK,EAAC,cAAc,EACpB,OAAO,EAAE,GAAG,EAAE;4BACZ,aAAa,EAAE,CAAC;4BAChB,gBAAgB,EAAE,CAAC;wBACrB,CAAC,GACD,EACF,KAAC,QAAQ,IACP,IAAI,EAAE,KAAK,CAAC,YAAY,EACxB,KAAK,EAAC,eAAe,EACrB,OAAO,EAAE,GAAG,EAAE;4BACZ,cAAc,EAAE,CAAC;4BACjB,gBAAgB,EAAE,CAAC;wBACrB,CAAC,GACD,IACG,CACR,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { type ComponentProps, type ReactNode, useCallback } from \"react\";\nimport { useWindowingIcons } from \"../icons/WindowingIcons\";\nimport { Menu } from \"../menu/Menu\";\nimport { MenuItem } from \"../menu/MenuItem\";\nimport { useContextMenuPositionState } from \"../menu/useContextMenuState\";\nimport \"./WindowTitleBar.css\";\nimport { WindowCloseButton } from \"./WindowCloseButton\";\nimport { WindowMaximizeButton } from \"./WindowMaximizeButton\";\nimport { WindowMinimizeButton } from \"./WindowMinimizeButton\";\n\nexport interface WindowTitleBarAction {\n /**\n * Memoized popup trigger attributes. Custom action hosts must spread these\n * onto their button, including the ref used to anchor the popup.\n */\n buttonProps?: Pick<\n ComponentProps<\"button\">,\n \"aria-expanded\" | \"onMouseDown\" | \"ref\"\n >;\n disabled?: boolean;\n icon: ReactNode;\n id: string;\n label: string;\n onClick: () => void;\n pressed?: boolean;\n}\n\nexport function WindowTitleBar({\n title,\n titleId,\n onPointerDown,\n onMinimize,\n onMaximize,\n onClose,\n onMoveForward,\n onMoveBackward,\n}: {\n title: string;\n titleId?: string | undefined;\n onPointerDown: (e: React.PointerEvent) => void;\n onMinimize: () => void;\n onMaximize: () => void;\n onClose: () => void;\n onMoveForward: () => void;\n onMoveBackward: () => void;\n}) {\n const { closeContextMenu, contextMenu, openContextMenuAt } =\n useContextMenuPositionState();\n const icons = useWindowingIcons();\n\n const handlePointerDown = useCallback(\n (e: React.PointerEvent<HTMLDivElement>) => {\n const target = e.target;\n if (e.button !== 0) return;\n // Element, not HTMLElement: an icon inside a button (including the\n // portaled context menu, whose events bubble through React) is SVG.\n if (target instanceof Element && target.closest(\"button\")) return;\n onPointerDown(e);\n },\n [onPointerDown],\n );\n\n return (\n <div\n role=\"toolbar\"\n aria-label=\"Window controls\"\n className=\"window-titlebar\"\n onPointerDown={handlePointerDown}\n onContextMenu={(event) => {\n event.preventDefault();\n event.stopPropagation();\n openContextMenuAt({ x: event.clientX, y: event.clientY });\n }}\n >\n <span className=\"window-titlebar-title\" id={titleId} title={title}>\n {title}\n </span>\n <div className=\"window-titlebar-buttons\">\n <WindowMinimizeButton onClick={onMinimize} />\n <WindowMaximizeButton onClick={onMaximize} />\n <WindowCloseButton label=\"Close window\" onClick={onClose} />\n </div>\n {contextMenu && (\n <Menu\n position={contextMenu}\n onClose={closeContextMenu}\n direction=\"down\"\n >\n <MenuItem\n icon={icons.moveForward}\n label=\"Move Forward\"\n onClick={() => {\n onMoveForward();\n closeContextMenu();\n }}\n />\n <MenuItem\n icon={icons.moveBackward}\n label=\"Move Backward\"\n onClick={() => {\n onMoveBackward();\n closeContextMenu();\n }}\n />\n </Menu>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The window's toolbar row, sitting below the File/View menu bar and above the
|
|
3
3
|
* body. It renders the same actions the routed app bar shows — the registered
|
|
4
4
|
* {@link useWindowBackAction} on the left and {@link useWindowTitleBarAction}
|
|
5
|
-
* icon buttons on the right — so a
|
|
5
|
+
* icon buttons followed by Refresh on the right — so a window gets the same
|
|
6
6
|
* toolbar chrome it gets in the routed shell.
|
|
7
7
|
*
|
|
8
8
|
* The left slot resolves exactly as `RoutedPaneAppBar` does: a registered back
|
package/window/WindowToolBar.js
CHANGED
|
@@ -3,12 +3,13 @@ import { useState } from "react";
|
|
|
3
3
|
import { useWindowingIcons } from "../icons/WindowingIcons.js";
|
|
4
4
|
import "./WindowToolBar.css";
|
|
5
5
|
import { WindowTitleBarActionButtons } from "./WindowChromeActions.js";
|
|
6
|
-
import { useWindowBackActionValue, useWindowTitleBarActions, useWindowToolbarReservationReleased, useWindowToolbarReserved, } from "./WindowMenuContext.js";
|
|
6
|
+
import { useWindowBackActionValue, useWindowRefreshMenuItemValue, useWindowTitleBarActions, useWindowToolbarReservationReleased, useWindowToolbarReserved, } from "./WindowMenuContext.js";
|
|
7
|
+
import { WindowRefreshButton } from "./WindowRefreshButton.js";
|
|
7
8
|
/**
|
|
8
9
|
* The window's toolbar row, sitting below the File/View menu bar and above the
|
|
9
10
|
* body. It renders the same actions the routed app bar shows — the registered
|
|
10
11
|
* {@link useWindowBackAction} on the left and {@link useWindowTitleBarAction}
|
|
11
|
-
* icon buttons on the right — so a
|
|
12
|
+
* icon buttons followed by Refresh on the right — so a window gets the same
|
|
12
13
|
* toolbar chrome it gets in the routed shell.
|
|
13
14
|
*
|
|
14
15
|
* The left slot resolves exactly as `RoutedPaneAppBar` does: a registered back
|
|
@@ -41,10 +42,14 @@ export function WindowToolBar({ canGoBack = false, onGoBack, showHistoryBack = f
|
|
|
41
42
|
const { back: BackIcon } = useWindowingIcons();
|
|
42
43
|
const backAction = useWindowBackActionValue();
|
|
43
44
|
const actions = useWindowTitleBarActions();
|
|
45
|
+
const refreshItem = useWindowRefreshMenuItemValue();
|
|
44
46
|
const reserved = useWindowToolbarReserved();
|
|
45
47
|
const reservationReleased = useWindowToolbarReservationReleased();
|
|
46
48
|
const showBack = backAction !== null || (showHistoryBack && canGoBack);
|
|
47
|
-
const hasChrome = backAction !== null ||
|
|
49
|
+
const hasChrome = backAction !== null ||
|
|
50
|
+
showHistoryBack ||
|
|
51
|
+
actions.length > 0 ||
|
|
52
|
+
refreshItem !== null;
|
|
48
53
|
// Latch: this window's app has shown toolbar chrome at least once, so keep the
|
|
49
54
|
// row reserved from here on rather than collapsing it on a transient empty.
|
|
50
55
|
// Seed from the mount-time value so a window that already has chrome does not
|
|
@@ -64,6 +69,6 @@ export function WindowToolBar({ canGoBack = false, onGoBack, showHistoryBack = f
|
|
|
64
69
|
return null;
|
|
65
70
|
}
|
|
66
71
|
const backLabel = backAction?.label ?? "Back";
|
|
67
|
-
return (_jsxs("div", { "aria-label": "Toolbar", className: "window-toolbar", role: "toolbar", children: [_jsx("div", { className: "window-toolbar-primary", children: showBack && (_jsxs("button", { "aria-label": backLabel, className: "window-toolbar-button", disabled: backAction?.disabled ?? false, title: backLabel, type: "button", onClick: backAction?.onClick ?? onGoBack, children: [_jsx(BackIcon, { "aria-hidden": true, size: 18 }), _jsx("span", { className: "window-toolbar-back-label", children: backLabel })] })) }), _jsx("div", { className: "window-toolbar-spacer" }), actions.length > 0 && (
|
|
72
|
+
return (_jsxs("div", { "aria-label": "Toolbar", className: "window-toolbar", role: "toolbar", children: [_jsx("div", { className: "window-toolbar-primary", children: showBack && (_jsxs("button", { "aria-label": backLabel, className: "window-toolbar-button", disabled: backAction?.disabled ?? false, title: backLabel, type: "button", onClick: backAction?.onClick ?? onGoBack, children: [_jsx(BackIcon, { "aria-hidden": true, size: 18 }), _jsx("span", { className: "window-toolbar-back-label", children: backLabel })] })) }), _jsx("div", { className: "window-toolbar-spacer" }), (actions.length > 0 || refreshItem !== null) && (_jsxs("div", { className: "window-toolbar-actions", children: [_jsx(WindowTitleBarActionButtons, { actions: actions, className: "window-toolbar-button" }), refreshItem && (_jsx(WindowRefreshButton, { className: "window-toolbar-button", item: refreshItem }))] }))] }));
|
|
68
73
|
}
|
|
69
74
|
//# sourceMappingURL=WindowToolBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WindowToolBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowToolBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"WindowToolBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowToolBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,wBAAwB,EACxB,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,SAAS,GAAG,KAAK,EACjB,QAAQ,EACR,eAAe,GAAG,KAAK,MAKrB,EAAE;IACJ,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAC/C,MAAM,UAAU,GAAG,wBAAwB,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAC;IAC3C,MAAM,WAAW,GAAG,6BAA6B,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;IAC5C,MAAM,mBAAmB,GAAG,mCAAmC,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,UAAU,KAAK,IAAI,IAAI,CAAC,eAAe,IAAI,SAAS,CAAC,CAAC;IACvE,MAAM,SAAS,GACb,UA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C,MAAM,GAAG,CAAC,IAAI,WAAW,KAAK,IAAI,CAAC,IAAI,CAC/C,eAAK,SAAS,EAAC,wBAAwB,aACrC,KAAC,2BAA2B,IAC1B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,uBAAuB,GACjC,EACD,WAAW,IAAI,CACd,KAAC,mBAAmB,IAClB,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAE,WAAW,GACjB,CACH,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { useWindowingIcons } from \"../icons/WindowingIcons\";\nimport \"./WindowToolBar.css\";\nimport { WindowTitleBarActionButtons } from \"./WindowChromeActions\";\nimport {\n useWindowBackActionValue,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarActions,\n useWindowToolbarReservationReleased,\n useWindowToolbarReserved,\n} from \"./WindowMenuContext\";\nimport { WindowRefreshButton } from \"./WindowRefreshButton\";\n\n/**\n * The window's toolbar row, sitting below the File/View menu bar and above the\n * body. It renders the same actions the routed app bar shows — the registered\n * {@link useWindowBackAction} on the left and {@link useWindowTitleBarAction}\n * icon buttons followed by Refresh on the right — so a window gets the same\n * toolbar chrome it gets in the routed shell.\n *\n * The left slot resolves exactly as `RoutedPaneAppBar` does: a registered back\n * action wins, and otherwise the button steps back through the host's own\n * history. `showHistoryBack` turns that fallback on for a window hosting a\n * routed mini-app, whose history is the window's Back stack (windows are not\n * backed by browser history); the fallback is omitted when that stack is empty.\n * Unlike the routed shell's paired Back/Forward controls, the window has no\n * adjacent history control whose stable placement would justify a disabled\n * Back button.\n *\n * Both surfaces read one shared registry (WindowMenuContext), so a mini-app\n * registers its actions once and they appear wherever it is hosted.\n *\n * A window whose app never registers toolbar chrome keeps a flush menu bar/body\n * (the row renders nothing). But once an app HAS shown chrome, the row stays\n * mounted and reserves its {@link WindowToolBar.css} min-height even when the\n * action set momentarily clears — on an action-less sub-route or a loading tick\n * where the app's `show` conditions are briefly false. Unmounting the row in\n * those windows would drop a full bar-height out of the flex column and shift\n * the body up, then back down when the actions re-register (visible flicker).\n *\n * An app that wants the row on every route — a blank bar where a route carries\n * no actions, rather than one that only appears after some route first shows\n * chrome — reserves it via {@link useWindowToolbarReservation} (the reserved row\n * still mounts a commit late, once that hook's effect registers, as all window\n * chrome does).\n */\nexport function WindowToolBar({\n canGoBack = false,\n onGoBack,\n showHistoryBack = false,\n}: {\n canGoBack?: boolean;\n onGoBack?: (() => void) | undefined;\n showHistoryBack?: boolean;\n} = {}) {\n const { back: BackIcon } = useWindowingIcons();\n const backAction = useWindowBackActionValue();\n const actions = useWindowTitleBarActions();\n const refreshItem = useWindowRefreshMenuItemValue();\n const reserved = useWindowToolbarReserved();\n const reservationReleased = useWindowToolbarReservationReleased();\n const showBack = backAction !== null || (showHistoryBack && canGoBack);\n const hasChrome =\n backAction !== null ||\n showHistoryBack ||\n actions.length > 0 ||\n refreshItem !== null;\n // Latch: this window's app has shown toolbar chrome at least once, so keep the\n // row reserved from here on rather than collapsing it on a transient empty.\n // Seed from the mount-time value so a window that already has chrome does not\n // latch during render at all; the render-phase set below catches chrome that\n // first appears after mount, without an effect's extra committed render pass.\n const [hasShownChrome, setHasShownChrome] = useState(hasChrome);\n let latchedChrome = hasShownChrome;\n if (hasChrome && !latchedChrome) {\n setHasShownChrome(true);\n latchedChrome = true;\n } else if (!hasChrome && reservationReleased && latchedChrome) {\n setHasShownChrome(false);\n latchedChrome = false;\n }\n\n if (!hasChrome && !latchedChrome && !reserved) {\n return null;\n }\n\n const backLabel = backAction?.label ?? \"Back\";\n\n return (\n <div aria-label=\"Toolbar\" className=\"window-toolbar\" role=\"toolbar\">\n <div className=\"window-toolbar-primary\">\n {showBack && (\n <button\n aria-label={backLabel}\n className=\"window-toolbar-button\"\n disabled={backAction?.disabled ?? false}\n title={backLabel}\n type=\"button\"\n onClick={backAction?.onClick ?? onGoBack}\n >\n <BackIcon aria-hidden size={18} />\n <span className=\"window-toolbar-back-label\">{backLabel}</span>\n </button>\n )}\n </div>\n <div className=\"window-toolbar-spacer\" />\n {(actions.length > 0 || refreshItem !== null) && (\n <div className=\"window-toolbar-actions\">\n <WindowTitleBarActionButtons\n actions={actions}\n className=\"window-toolbar-button\"\n />\n {refreshItem && (\n <WindowRefreshButton\n className=\"window-toolbar-button\"\n item={refreshItem}\n />\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
|