@tearleads/windowing 0.2.28 → 0.2.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tearleads/windowing",
3
- "version": "0.2.28",
3
+ "version": "0.2.29",
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": {
@@ -5,6 +5,15 @@ import "./WindowToolBar.css";
5
5
  import { WindowTitleBarActionButtons } from "./WindowChromeActions.js";
6
6
  import { useWindowBackActionValue, useWindowRefreshMenuItemValue, useWindowTitleBarActions, useWindowToolbarReservationReleased, useWindowToolbarReserved, } from "./WindowMenuContext.js";
7
7
  import { WindowRefreshButton } from "./WindowRefreshButton.js";
8
+ /**
9
+ * Latch: once an app has shown toolbar chrome the row stays reserved, rather
10
+ * than collapsing on a transient empty, until its reservation is released.
11
+ */
12
+ function latchedToolbarChrome(hasChrome, reservationReleased, hasShownChrome) {
13
+ if (hasChrome)
14
+ return true;
15
+ return hasShownChrome && !reservationReleased;
16
+ }
8
17
  /**
9
18
  * The window's toolbar row, sitting below the File/View menu bar and above the
10
19
  * body. It renders the same actions the routed app bar shows — the registered
@@ -56,14 +65,9 @@ export function WindowToolBar({ canGoBack = false, onGoBack, showHistoryBack = f
56
65
  // latch during render at all; the render-phase set below catches chrome that
57
66
  // first appears after mount, without an effect's extra committed render pass.
58
67
  const [hasShownChrome, setHasShownChrome] = useState(hasChrome);
59
- let latchedChrome = hasShownChrome;
60
- if (hasChrome && !latchedChrome) {
61
- setHasShownChrome(true);
62
- latchedChrome = true;
63
- }
64
- else if (!hasChrome && reservationReleased && latchedChrome) {
65
- setHasShownChrome(false);
66
- latchedChrome = false;
68
+ const latchedChrome = latchedToolbarChrome(hasChrome, reservationReleased, hasShownChrome);
69
+ if (latchedChrome !== hasShownChrome) {
70
+ setHasShownChrome(latchedChrome);
67
71
  }
68
72
  if (!hasChrome && !latchedChrome && !reserved) {
69
73
  return null;
@@ -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,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,UAAU,KAAK,IAAI;QACnB,eAAe;QACf,OAAO,CAAC,MAAM,GAAG,CAAC;QAClB,WAAW,KAAK,IAAI,CAAC;IACvB,+EAA+E;IAC/E,4EAA4E;IAC5E,8EA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O,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"]}
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;;;GAGG;AACH,SAAS,oBAAoB,CAC3B,SAAkB,EAClB,mBAA4B,EAC5B,cAAuB;IAEvB,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,cAAc,IAAI,CAAC,mBAAmB,CAAC;AAChD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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,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 * Latch: once an app has shown toolbar chrome the row stays reserved, rather\n * than collapsing on a transient empty, until its reservation is released.\n */\nfunction latchedToolbarChrome(\n hasChrome: boolean,\n reservationReleased: boolean,\n hasShownChrome: boolean,\n): boolean {\n if (hasChrome) return true;\n return hasShownChrome && !reservationReleased;\n}\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 const latchedChrome = latchedToolbarChrome(\n hasChrome,\n reservationReleased,\n hasShownChrome,\n );\n if (latchedChrome !== hasShownChrome) {\n setHasShownChrome(latchedChrome);\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"]}