@tearleads/windowing 0.2.0 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +46 -7
  2. package/createRequiredContext.js.map +1 -1
  3. package/index.d.ts +1 -1
  4. package/index.js +1 -1
  5. package/index.js.map +1 -1
  6. package/menu/Menu.js.map +1 -1
  7. package/menu/MenuItem.js.map +1 -1
  8. package/menu/useContextMenuState.js.map +1 -1
  9. package/menu/useMenuKeyboard.js.map +1 -1
  10. package/package.json +6 -1
  11. package/sidebar/SidebarResize.js.map +1 -1
  12. package/window/CurrentWindowContext.d.ts +17 -1
  13. package/window/CurrentWindowContext.js +28 -2
  14. package/window/CurrentWindowContext.js.map +1 -1
  15. package/window/Window.css +1 -1
  16. package/window/Window.js +6 -2
  17. package/window/Window.js.map +1 -1
  18. package/window/WindowBody.css +17 -0
  19. package/window/WindowBody.js.map +1 -1
  20. package/window/WindowChromeActions.js.map +1 -1
  21. package/window/WindowCloseButton.js.map +1 -1
  22. package/window/WindowMaximizeButton.js.map +1 -1
  23. package/window/WindowMenuBar.js.map +1 -1
  24. package/window/WindowMenuContext.js.map +1 -1
  25. package/window/WindowMinimizeButton.js.map +1 -1
  26. package/window/WindowResizeHandle.js.map +1 -1
  27. package/window/WindowSidebar.js.map +1 -1
  28. package/window/WindowSidebarContext.js.map +1 -1
  29. package/window/WindowStateProvider/WindowStateProvider.js.map +1 -1
  30. package/window/WindowStateProvider/context.js.map +1 -1
  31. package/window/WindowStateProvider/index.js.map +1 -1
  32. package/window/WindowStateProvider/types.js.map +1 -1
  33. package/window/WindowStateProvider/useWindowActions.js.map +1 -1
  34. package/window/WindowStateProvider/useWindowStateActions.js.map +1 -1
  35. package/window/WindowStateProvider/useWindowStateData.js.map +1 -1
  36. package/window/WindowStateProvider/util/bringWindowToFront.js.map +1 -1
  37. package/window/WindowStateProvider/util/createWindowEntry.js.map +1 -1
  38. package/window/WindowStateProvider/util/findAdjacentWindow.js.map +1 -1
  39. package/window/WindowStateProvider/util/findTopWindow.js.map +1 -1
  40. package/window/WindowStateProvider/util/getMaxWindowZIndex.js.map +1 -1
  41. package/window/WindowStateProvider/util/index.js.map +1 -1
  42. package/window/WindowStateProvider/util/swapWindowZIndexes.js.map +1 -1
  43. package/window/WindowStateProvider/util/updateWindowFlag.js.map +1 -1
  44. package/window/WindowStatusBar.js.map +1 -1
  45. package/window/WindowTitleBar.js.map +1 -1
  46. package/window/WindowToolBar.js.map +1 -1
  47. package/window/useWindowGeometry.js.map +1 -1
  48. package/window/useWindowItemRegistration.js.map +1 -1
  49. package/window/useWindowItemRegistry.js.map +1 -1
  50. package/window/useWindowKeyboardGeometry.js +14 -1
  51. package/window/useWindowKeyboardGeometry.js.map +1 -1
  52. package/window/useWindowLayout.js.map +1 -1
  53. package/window/useWindowToolbarReservationRegistry.js.map +1 -1
  54. package/window/windowGeometry.js.map +1 -1
  55. package/window/windowMenuRegistrations.js.map +1 -1
@@ -5,6 +5,23 @@
5
5
  overflow: hidden;
6
6
  }
7
7
 
8
+ /*
9
+ * The window rounds its corners but cannot clip what it holds: its resize
10
+ * handles and menus reach past its edges. So while no visible status bar sits
11
+ * below it, the body rounds its own bottom corners to the window's inner radius
12
+ * (the outer radius less the border) and, through its overflow, clips content
13
+ * painted edge to edge, such as a full-bleed canvas, inside the rounded border.
14
+ */
15
+ .window:not(.window--maximized)
16
+ > .window-body:not(
17
+ :has(
18
+ + .window-statusbar-live > .window-statusbar:not(.window-statusbar--hidden)
19
+ )
20
+ ) {
21
+ border-radius: 0 0 calc(var(--app-radius-surface) - var(--border-width))
22
+ calc(var(--app-radius-surface) - var(--border-width));
23
+ }
24
+
8
25
  .window-body-content {
9
26
  position: relative;
10
27
  flex: 1;
@@ -1 +1 @@
1
- {"version":3,"file":"WindowBody.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowBody.tsx"],"names":[],"mappings":";AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,+EAA+E;AAC/E,+EAA+E;AAC/E,yDAAyD;AACzD,MAAM,UAAU,UAAU,CAAC,EACzB,UAAU,EACV,WAAW,GAAG,KAAK,EACnB,OAAO,EACP,QAAQ,GAC2B;IACnC,OAAO,CACL,cAAK,SAAS,EAAC,aAAa,YACzB,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,aAAa,IAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,YACpD,QAAQ,GACK,CACjB,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,qBAAqB,EAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,YAChE,cAAK,SAAS,EAAC,4BAA4B,YAAE,QAAQ,GAAO,GACxD,CACP,GACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { PropsWithChildren, Ref } from \"react\";\nimport \"./WindowBody.css\";\nimport { WindowSidebar } from \"./WindowSidebar\";\n\ninterface WindowBodyProps {\n contentRef?: Ref<HTMLDivElement> | undefined;\n showSidebar?: boolean;\n sidebar?: React.ReactNode;\n}\n\n// The content pane is programmatically focusable (`tabIndex={-1}`, so never in\n// the tab order): an overlay that covered it lands focus here when the control\n// that opened the overlay is gone by the time it closes.\nexport function WindowBody({\n contentRef,\n showSidebar = false,\n sidebar,\n children,\n}: PropsWithChildren<WindowBodyProps>) {\n return (\n <div className=\"window-body\">\n {showSidebar ? (\n <WindowSidebar contentRef={contentRef} sidebar={sidebar}>\n {children}\n </WindowSidebar>\n ) : (\n <div className=\"window-body-content\" ref={contentRef} tabIndex={-1}>\n <div className=\"window-body-content-scroll\">{children}</div>\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowBody.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowBody.tsx"],"names":[],"mappings":";AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,+EAA+E;AAC/E,+EAA+E;AAC/E,yDAAyD;AACzD,MAAM,UAAU,UAAU,CAAC,EACzB,UAAU,EACV,WAAW,GAAG,KAAK,EACnB,OAAO,EACP,QAAQ,GAC2B;IACnC,OAAO,CACL,cAAK,SAAS,EAAC,aAAa,YACzB,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,aAAa,IAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,YACpD,QAAQ,GACK,CACjB,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,qBAAqB,EAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,YAChE,cAAK,SAAS,EAAC,4BAA4B,YAAE,QAAQ,GAAO,GACxD,CACP,GACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { PropsWithChildren, Ref } from \"react\";\nimport \"./WindowBody.css\";\nimport { WindowSidebar } from \"./WindowSidebar\";\n\ninterface WindowBodyProps {\n contentRef?: Ref<HTMLDivElement> | undefined;\n showSidebar?: boolean;\n sidebar?: React.ReactNode;\n}\n\n// The content pane is programmatically focusable (`tabIndex={-1}`, so never in\n// the tab order): an overlay that covered it lands focus here when the control\n// that opened the overlay is gone by the time it closes.\nexport function WindowBody({\n contentRef,\n showSidebar = false,\n sidebar,\n children,\n}: PropsWithChildren<WindowBodyProps>) {\n return (\n <div className=\"window-body\">\n {showSidebar ? (\n <WindowSidebar contentRef={contentRef} sidebar={sidebar}>\n {children}\n </WindowSidebar>\n ) : (\n <div className=\"window-body-content\" ref={contentRef} tabIndex={-1}>\n <div className=\"window-body-content-scroll\">{children}</div>\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowChromeActions.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowChromeActions.tsx"],"names":[],"mappings":";AAuDA;;;;G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U,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 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 */\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 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 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 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 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"]}
1
+ {"version":3,"file":"WindowChromeActions.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowChromeActions.tsx"],"names":[],"mappings":";AAuDA;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAC1C,OAAO,EACP,S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,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 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 */\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 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 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 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 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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowCloseButton.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowCloseButton.tsx"],"names":[],"mappings":";AAEA,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,mFAAmF;AACnF,MAAM,UAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,KAAK,EACL,OAAO,GAKR;IACC,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,cAAc,EACxB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,SAAS,gBACF,KAAK,EACjB,KAAK,EAAE,KAAK,uBAGL,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { RefObject } from \"react\";\n\n// The floating-window close control (the `×` in the title bar). Shared beyond\n// WindowTitleBar so any surface dressing as a window — e.g. the note attachment\n// preview — closes with the identical glyph and chrome instead of a look-alike.\n// `label` names it for assistive tech; `buttonRef` lets a caller move focus to it.\nexport function WindowCloseButton({\n buttonRef,\n label,\n onClick,\n}: {\n buttonRef?: RefObject<HTMLButtonElement | null>;\n label?: string;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n className=\"window-close\"\n onClick={onClick}\n ref={buttonRef}\n aria-label={label}\n title={label}\n >\n &times;\n </button>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowCloseButton.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowCloseButton.tsx"],"names":[],"mappings":";AAEA,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,mFAAmF;AACnF,MAAM,UAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,KAAK,EACL,OAAO,GAKR;IACC,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,cAAc,EACxB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,SAAS,gBACF,KAAK,EACjB,KAAK,EAAE,KAAK,uBAGL,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { RefObject } from \"react\";\n\n// The floating-window close control (the `×` in the title bar). Shared beyond\n// WindowTitleBar so any surface dressing as a window — e.g. the note attachment\n// preview — closes with the identical glyph and chrome instead of a look-alike.\n// `label` names it for assistive tech; `buttonRef` lets a caller move focus to it.\nexport function WindowCloseButton({\n buttonRef,\n label,\n onClick,\n}: {\n buttonRef?: RefObject<HTMLButtonElement | null>;\n label?: string;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n className=\"window-close\"\n onClick={onClick}\n ref={buttonRef}\n aria-label={label}\n title={label}\n >\n &times;\n </button>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowMaximizeButton.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowMaximizeButton.tsx"],"names":[],"mappings":";AAAA,MAAM,UAAU,oBAAoB,CAAC,EAAE,OAAO,EAA2B;IACvE,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iBAAiB,gBAChB,wBAAwB,EACnC,KAAK,EAAC,wBAAwB,EAC9B,OAAO,EAAE,OAAO,uBAGT,CACV,CAAC;AACJ,CAAC","sourcesContent":["export function WindowMaximizeButton({ onClick }: { onClick: () => void }) {\n return (\n <button\n type=\"button\"\n className=\"window-maximize\"\n aria-label=\"Toggle maximize window\"\n title=\"Toggle maximize window\"\n onClick={onClick}\n >\n &#9633;\n </button>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowMaximizeButton.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowMaximizeButton.tsx"],"names":[],"mappings":";AAAA,MAAM,UAAU,oBAAoB,CAAC,EAAE,OAAO,EAA2B;IACvE,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iBAAiB,gBAChB,wBAAwB,EACnC,KAAK,EAAC,wBAAwB,EAC9B,OAAO,EAAE,OAAO,uBAGT,CACV,CAAC;AACJ,CAAC","sourcesContent":["export function WindowMaximizeButton({ onClick }: { onClick: () => void }) {\n return (\n <button\n type=\"button\"\n className=\"window-maximize\"\n aria-label=\"Toggle maximize window\"\n title=\"Toggle maximize window\"\n onClick={onClick}\n >\n &#9633;\n </button>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowMenuBar.js","sourceRoot":"","sources":["../../../home/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E,EAAE,CAAC,CACtB,eAAsB,SAAS,EAAC,qBAAqB,aACnD,iBACE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,UAAU,mBACD,MAAM,mBACL,SAAS,KAAK,CAAC,EAC9B,SAAS,EACP,SAAS,KAAK,CAAC;wBACb,CAAC,CAAC,uDAAuD;wBACzD,CAAC,CAAC,wBAAwB,EAE9B,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EACvD,YAAY,EAAE,GAAG,EAAE;wBACjB,IAAI,SAAS,KAAK,IAAI;4BAAE,YAAY,CAAC,CAAC,CAAC,CAAC;oBAC1C,CAAC,YAEA,IAAI,CAAC,KAAK,GACJ,EACR,SAAS,KAAK,CAAC,IAAI,CAClB,cAAK,SAAS,EAAC,yBAAyB,EAAC,IAAI,EAAC,MAAM,YACjD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACxB,iBAEE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,GAAG,EAAE;4BACZ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gCAClB,OAAO;4BACT,CAAC;4BACD,IAAI,CAAC,OAAO,EAAE,CAAC;4BACf,KAAK,EAAE,CAAC;wBACV,CAAC,YAEA,IAAI,CAAC,KAAK,IAZN,IAAI,CAAC,EAAE,CAaL,CACV,CAAC,GACE,CACP,KAtCO,IAAI,CAAC,KAAK,CAuCd,CACP,CAAC,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport \"./WindowMenuBar.css\";\n\nexport interface WindowMenuItem {\n disabled?: boolean;\n id: string;\n label: string;\n onClick: () => void;\n}\n\ninterface WindowMenu {\n label: string;\n items: WindowMenuItem[];\n}\n\nexport function WindowMenuBar({ menus }: { menus: WindowMenu[] }) {\n const [openIndex, setOpenIndex] = useState<number | null>(null);\n const barRef = useRef<HTMLDivElement>(null);\n\n const close = useCallback(() => setOpenIndex(null), []);\n\n useEffect(() => {\n if (openIndex === null) return;\n function handleMouseDown(e: MouseEvent) {\n const target = e.target;\n if (!(target instanceof Node)) {\n close();\n return;\n }\n\n if (barRef.current && !barRef.current.contains(target)) {\n close();\n }\n }\n document.addEventListener(\"mousedown\", handleMouseDown);\n return () => document.removeEventListener(\"mousedown\", handleMouseDown);\n }, [openIndex, close]);\n\n return (\n <div ref={barRef} className=\"window-menubar\" role=\"menubar\">\n {menus.map((menu, i) => (\n <div key={menu.label} className=\"window-menubar-item\">\n <button\n type=\"button\"\n role=\"menuitem\"\n aria-haspopup=\"true\"\n aria-expanded={openIndex === i}\n className={\n openIndex === i\n ? \"window-menubar-trigger window-menubar-trigger--active\"\n : \"window-menubar-trigger\"\n }\n onClick={() => setOpenIndex(openIndex === i ? null : i)}\n onMouseEnter={() => {\n if (openIndex !== null) setOpenIndex(i);\n }}\n >\n {menu.label}\n </button>\n {openIndex === i && (\n <div className=\"window-menubar-dropdown\" role=\"menu\">\n {menu.items.map((item) => (\n <button\n key={item.id}\n type=\"button\"\n role=\"menuitem\"\n disabled={item.disabled}\n onClick={() => {\n if (item.disabled) {\n return;\n }\n item.onClick();\n close();\n }}\n >\n {item.label}\n </button>\n ))}\n </div>\n )}\n </div>\n ))}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowMenuBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowMenuBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,qBAAqB,CAAC;AAc7B,MAAM,UAAU,aAAa,CAAC,EAAE,KAAK,EAA2B;IAC9D,MAAM,CAAC,SAAS,EA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GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EACvD,YAAY,EAAE,GAAG,EAAE;wBACjB,IAAI,SAAS,KAAK,IAAI;4BAAE,YAAY,CAAC,CAAC,CAAC,CAAC;oBAC1C,CAAC,YAEA,IAAI,CAAC,KAAK,GACJ,EACR,SAAS,KAAK,CAAC,IAAI,CAClB,cAAK,SAAS,EAAC,yBAAyB,EAAC,IAAI,EAAC,MAAM,YACjD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACxB,iBAEE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,GAAG,EAAE;4BACZ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gCAClB,OAAO;4BACT,CAAC;4BACD,IAAI,CAAC,OAAO,EAAE,CAAC;4BACf,KAAK,EAAE,CAAC;wBACV,CAAC,YAEA,IAAI,CAAC,KAAK,IAZN,IAAI,CAAC,EAAE,CAaL,CACV,CAAC,GACE,CACP,KAtCO,IAAI,CAAC,KAAK,CAuCd,CACP,CAAC,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport \"./WindowMenuBar.css\";\n\nexport interface WindowMenuItem {\n disabled?: boolean;\n id: string;\n label: string;\n onClick: () => void;\n}\n\ninterface WindowMenu {\n label: string;\n items: WindowMenuItem[];\n}\n\nexport function WindowMenuBar({ menus }: { menus: WindowMenu[] }) {\n const [openIndex, setOpenIndex] = useState<number | null>(null);\n const barRef = useRef<HTMLDivElement>(null);\n\n const close = useCallback(() => setOpenIndex(null), []);\n\n useEffect(() => {\n if (openIndex === null) return;\n function handleMouseDown(e: MouseEvent) {\n const target = e.target;\n if (!(target instanceof Node)) {\n close();\n return;\n }\n\n if (barRef.current && !barRef.current.contains(target)) {\n close();\n }\n }\n document.addEventListener(\"mousedown\", handleMouseDown);\n return () => document.removeEventListener(\"mousedown\", handleMouseDown);\n }, [openIndex, close]);\n\n return (\n <div ref={barRef} className=\"window-menubar\" role=\"menubar\">\n {menus.map((menu, i) => (\n <div key={menu.label} className=\"window-menubar-item\">\n <button\n type=\"button\"\n role=\"menuitem\"\n aria-haspopup=\"true\"\n aria-expanded={openIndex === i}\n className={\n openIndex === i\n ? \"window-menubar-trigger window-menubar-trigger--active\"\n : \"window-menubar-trigger\"\n }\n onClick={() => setOpenIndex(openIndex === i ? null : i)}\n onMouseEnter={() => {\n if (openIndex !== null) setOpenIndex(i);\n }}\n >\n {menu.label}\n </button>\n {openIndex === i && (\n <div className=\"window-menubar-dropdown\" role=\"menu\">\n {menu.items.map((item) => (\n <button\n key={item.id}\n type=\"button\"\n role=\"menuitem\"\n disabled={item.disabled}\n onClick={() => {\n if (item.disabled) {\n return;\n }\n item.onClick();\n close();\n }}\n >\n {item.label}\n </button>\n ))}\n </div>\n )}\n </div>\n ))}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowMenuContext.js","sourceRoot":"","sources":["../../../home/a2f0/github/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,M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AAM,CAAC,KAAK,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,KAAK,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 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,CA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E,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 +1 @@
1
- {"version":3,"file":"WindowMinimizeButton.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowMinimizeButton.tsx"],"names":[],"mappings":";AAAA,MAAM,UAAU,oBAAoB,CAAC,EAAE,OAAO,EAA2B;IACvE,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iBAAiB,gBAChB,iBAAiB,EAC5B,KAAK,EAAC,iBAAiB,EACvB,OAAO,EAAE,OAAO,uBAGT,CACV,CAAC;AACJ,CAAC","sourcesContent":["export function WindowMinimizeButton({ onClick }: { onClick: () => void }) {\n return (\n <button\n type=\"button\"\n className=\"window-minimize\"\n aria-label=\"Minimize window\"\n title=\"Minimize window\"\n onClick={onClick}\n >\n &#8211;\n </button>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowMinimizeButton.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowMinimizeButton.tsx"],"names":[],"mappings":";AAAA,MAAM,UAAU,oBAAoB,CAAC,EAAE,OAAO,EAA2B;IACvE,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iBAAiB,gBAChB,iBAAiB,EAC5B,KAAK,EAAC,iBAAiB,EACvB,OAAO,EAAE,OAAO,uBAGT,CACV,CAAC;AACJ,CAAC","sourcesContent":["export function WindowMinimizeButton({ onClick }: { onClick: () => void }) {\n return (\n <button\n type=\"button\"\n className=\"window-minimize\"\n aria-label=\"Minimize window\"\n title=\"Minimize window\"\n onClick={onClick}\n >\n &#8211;\n </button>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowResizeHandle.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowResizeHandle.tsx"],"names":[],"mappings":";AACA,OAAO,0BAA0B,CAAC;AAUlC,6EAA6E;AAC7E,gBAAgB;AAChB,MAAM,YAAY,GAA8B;IAC9C,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC;AAEF,SAAS,kBAAkB,CAAC,EAC1B,IAAI,EACJ,aAAa,GAId;IACC,OAAO,CACL,cACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,gCAAgC,IAAI,EAAE,EACjD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,GACpD,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,EAClC,uBAAuB,GAGxB;IACC,OAAO,CACL,4BACG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC1B,KAAC,kBAAkB,IACjB,IAAI,EAAE,IAAI,EAEV,aAAa,EAAE,uBAAuB,IADjC,IAAI,CAET,CACH,CAAC,GACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import type { PointerEvent as ReactPointerEvent } from \"react\";\nimport \"./WindowResizeHandle.css\";\n\ntype ResizeCorner = \"se\" | \"sw\" | \"ne\" | \"nw\";\ntype ResizeSide = \"n\" | \"e\" | \"s\" | \"w\";\n\n// The compass point a handle drags: a corner moves two edges, a side one.\nexport type ResizeEdge = ResizeCorner | ResizeSide;\n\ntype ResizePointerDown = (event: ReactPointerEvent, edge: ResizeEdge) => void;\n\n// Sides first, so the corners paint over the ends of the sides and win where\n// the two meet.\nconst RESIZE_EDGES: ReadonlyArray<ResizeEdge> = [\n \"n\",\n \"e\",\n \"s\",\n \"w\",\n \"se\",\n \"sw\",\n \"ne\",\n \"nw\",\n];\n\nfunction WindowResizeHandle({\n edge,\n onPointerDown,\n}: {\n edge: ResizeEdge;\n onPointerDown: ResizePointerDown;\n}) {\n return (\n <div\n role=\"none\"\n className={`window-resize window-resize--${edge}`}\n onPointerDown={(event) => onPointerDown(event, edge)}\n />\n );\n}\n\nexport function WindowResizeHandles({\n handleResizePointerDown,\n}: {\n handleResizePointerDown: ResizePointerDown;\n}) {\n return (\n <>\n {RESIZE_EDGES.map((edge) => (\n <WindowResizeHandle\n edge={edge}\n key={edge}\n onPointerDown={handleResizePointerDown}\n />\n ))}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowResizeHandle.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowResizeHandle.tsx"],"names":[],"mappings":";AACA,OAAO,0BAA0B,CAAC;AAUlC,6EAA6E;AAC7E,gBAAgB;AAChB,MAAM,YAAY,GAA8B;IAC9C,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC;AAEF,SAAS,kBAAkB,CAAC,EAC1B,IAAI,EACJ,aAAa,GAId;IACC,OAAO,CACL,cACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,gCAAgC,IAAI,EAAE,EACjD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,GACpD,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,EAClC,uBAAuB,GAGxB;IACC,OAAO,CACL,4BACG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC1B,KAAC,kBAAkB,IACjB,IAAI,EAAE,IAAI,EAEV,aAAa,EAAE,uBAAuB,IADjC,IAAI,CAET,CACH,CAAC,GACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import type { PointerEvent as ReactPointerEvent } from \"react\";\nimport \"./WindowResizeHandle.css\";\n\ntype ResizeCorner = \"se\" | \"sw\" | \"ne\" | \"nw\";\ntype ResizeSide = \"n\" | \"e\" | \"s\" | \"w\";\n\n// The compass point a handle drags: a corner moves two edges, a side one.\nexport type ResizeEdge = ResizeCorner | ResizeSide;\n\ntype ResizePointerDown = (event: ReactPointerEvent, edge: ResizeEdge) => void;\n\n// Sides first, so the corners paint over the ends of the sides and win where\n// the two meet.\nconst RESIZE_EDGES: ReadonlyArray<ResizeEdge> = [\n \"n\",\n \"e\",\n \"s\",\n \"w\",\n \"se\",\n \"sw\",\n \"ne\",\n \"nw\",\n];\n\nfunction WindowResizeHandle({\n edge,\n onPointerDown,\n}: {\n edge: ResizeEdge;\n onPointerDown: ResizePointerDown;\n}) {\n return (\n <div\n role=\"none\"\n className={`window-resize window-resize--${edge}`}\n onPointerDown={(event) => onPointerDown(event, edge)}\n />\n );\n}\n\nexport function WindowResizeHandles({\n handleResizePointerDown,\n}: {\n handleResizePointerDown: ResizePointerDown;\n}) {\n return (\n <>\n {RESIZE_EDGES.map((edge) => (\n <WindowResizeHandle\n edge={edge}\n key={edge}\n onPointerDown={handleResizePointerDown}\n />\n ))}\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowSidebar.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowSidebar.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,qBAAqB,CAAC;AAE7B,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAM,UAAU,aAAa,CAAC,EAC5B,UAAU,EACV,YAAY,GAAG,aAAa,EAC5B,OAAO,EACP,QAAQ,GAKR;IACA,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;IAElD,OAAO,CACL,eAAK,SAAS,EAAC,uBAAuB,aACpC,cACE,SAAS,EAAC,gBAAgB,EAC1B,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,YAAY,EAAE,YAE7C,OAAO,GACJ,EACN,KAAC,mBAAmB,IAClB,SAAS,EAAC,uBAAuB,EACjC,YAAY,EAAE,MAAM,CAAC,aAAa,EAClC,SAAS,EAAE,MAAM,CAAC,aAAa,EAC/B,aAAa,EAAE,MAAM,CAAC,iBAAiB,GACvC,EAGF,cAAK,SAAS,EAAC,wBAAwB,EAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,YACnE,cAAK,SAAS,EAAC,+BAA+B,YAAE,QAAQ,GAAO,GAC3D,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { PropsWithChildren, Ref } from \"react\";\nimport {\n SidebarResizeHandle,\n useSidebarResize,\n} from \"../sidebar/SidebarResize\";\nimport \"./WindowSidebar.css\";\n\nconst DEFAULT_WIDTH = 160;\n\nexport function WindowSidebar({\n contentRef,\n defaultWidth = DEFAULT_WIDTH,\n sidebar,\n children,\n}: PropsWithChildren<{\n contentRef?: Ref<HTMLDivElement> | undefined;\n defaultWidth?: number;\n sidebar?: React.ReactNode;\n}>) {\n const resize = useSidebarResize({ defaultWidth });\n\n return (\n <div className=\"window-sidebar-layout\">\n <div\n className=\"window-sidebar\"\n ref={resize.sidebarRef}\n style={{ width: resize.width ?? defaultWidth }}\n >\n {sidebar}\n </div>\n <SidebarResizeHandle\n className=\"window-sidebar-handle\"\n currentWidth={resize.resolvedWidth}\n onKeyDown={resize.handleKeyDown}\n onPointerDown={resize.handlePointerDown}\n />\n {/* Focusable only to script, like `.window-body-content`: the overlay host\n is where focus lands when an overlay outlives the control that opened it. */}\n <div className=\"window-sidebar-content\" ref={contentRef} tabIndex={-1}>\n <div className=\"window-sidebar-content-scroll\">{children}</div>\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowSidebar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowSidebar.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,qBAAqB,CAAC;AAE7B,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAM,UAAU,aAAa,CAAC,EAC5B,UAAU,EACV,YAAY,GAAG,aAAa,EAC5B,OAAO,EACP,QAAQ,GAKR;IACA,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;IAElD,OAAO,CACL,eAAK,SAAS,EAAC,uBAAuB,aACpC,cACE,SAAS,EAAC,gBAAgB,EAC1B,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,YAAY,EAAE,YAE7C,OAAO,GACJ,EACN,KAAC,mBAAmB,IAClB,SAAS,EAAC,uBAAuB,EACjC,YAAY,EAAE,MAAM,CAAC,aAAa,EAClC,SAAS,EAAE,MAAM,CAAC,aAAa,EAC/B,aAAa,EAAE,MAAM,CAAC,iBAAiB,GACvC,EAGF,cAAK,SAAS,EAAC,wBAAwB,EAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,YACnE,cAAK,SAAS,EAAC,+BAA+B,YAAE,QAAQ,GAAO,GAC3D,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { PropsWithChildren, Ref } from \"react\";\nimport {\n SidebarResizeHandle,\n useSidebarResize,\n} from \"../sidebar/SidebarResize\";\nimport \"./WindowSidebar.css\";\n\nconst DEFAULT_WIDTH = 160;\n\nexport function WindowSidebar({\n contentRef,\n defaultWidth = DEFAULT_WIDTH,\n sidebar,\n children,\n}: PropsWithChildren<{\n contentRef?: Ref<HTMLDivElement> | undefined;\n defaultWidth?: number;\n sidebar?: React.ReactNode;\n}>) {\n const resize = useSidebarResize({ defaultWidth });\n\n return (\n <div className=\"window-sidebar-layout\">\n <div\n className=\"window-sidebar\"\n ref={resize.sidebarRef}\n style={{ width: resize.width ?? defaultWidth }}\n >\n {sidebar}\n </div>\n <SidebarResizeHandle\n className=\"window-sidebar-handle\"\n currentWidth={resize.resolvedWidth}\n onKeyDown={resize.handleKeyDown}\n onPointerDown={resize.handlePointerDown}\n />\n {/* Focusable only to script, like `.window-body-content`: the overlay host\n is where focus lands when an overlay outlives the control that opened it. */}\n <div className=\"window-sidebar-content\" ref={contentRef} tabIndex={-1}>\n <div className=\"window-sidebar-content-scroll\">{children}</div>\n </div>\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowSidebarContext.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowSidebarContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAGb,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAOf,MAAM,oBAAoB,GAAG,aAAa,CAA4B;IACpE,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,UAAU,qBAAqB,CAAC,EAAE,QAAQ,EAAqB;IACnE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAY,IAAI,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAClE,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACxC,QAAQ,GACqB,CACjC,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,kEAAkE;AAClE,MAAM,UAAU,gBAAgB,CAAC,OAAkB;IACjD,OAAO,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EACzC,OAAO,GAAG,IAAI,EACd,UAAU,EACV,OAAO,GAKR;IACC,4EAA4E;IAC5E,2EAA2E;IAC3E,4EAA4E;IAC5E,4CAA4C;IAC5C,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACzC,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC;IAEnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,UAAU,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnC,2EAA2E;IAC3E,qEAAqE;IACrE,uBAAuB;IACvB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC","sourcesContent":["import {\n createContext,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\ninterface WindowSidebarContextValue {\n sidebar: ReactNode;\n setSidebar: (node: ReactNode) => void;\n}\n\nconst WindowSidebarContext = createContext<WindowSidebarContextValue>({\n sidebar: null,\n setSidebar: () => {},\n});\n\nexport function WindowSidebarProvider({ children }: PropsWithChildren) {\n const [sidebar, setSidebar] = useState<ReactNode>(null);\n const value = useMemo(() => ({ sidebar, setSidebar }), [sidebar]);\n return (\n <WindowSidebarContext.Provider value={value}>\n {children}\n </WindowSidebarContext.Provider>\n );\n}\n\n// `sidebar` is a ReactNode, so `false`/`null`/`undefined` all mean \"no\n// sidebar\" while renderable falsy values like `0` or `\"\"` do not.\nexport function hasWindowSidebar(sidebar: ReactNode): boolean {\n return sidebar !== null && sidebar !== undefined && sidebar !== false;\n}\n\nexport function useWindowSidebar() {\n return useContext(WindowSidebarContext);\n}\n\nexport function useRegisteredWindowSidebar({\n enabled = true,\n setSidebar,\n sidebar,\n}: {\n enabled?: boolean;\n setSidebar: (node: ReactNode) => void;\n sidebar: ReactNode;\n}) {\n // The ref keeps the clearing cleanup pinned to [enabled] even when a caller\n // passes a setter that is not referentially stable: with setSidebar in the\n // cleanup's deps, every such render would clear-then-reregister the sidebar\n // and re-render the window shell in a loop.\n const setSidebarRef = useRef(setSidebar);\n setSidebarRef.current = setSidebar;\n\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n setSidebar(sidebar);\n }, [enabled, setSidebar, sidebar]);\n\n // Clearing stays in its own effect so a sidebar-node change swaps the node\n // without a transient null; the cleanup runs only on unmount or when\n // `enabled` flips off.\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n return () => setSidebarRef.current(null);\n }, [enabled]);\n}\n"]}
1
+ {"version":3,"file":"WindowSidebarContext.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowSidebarContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAGb,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAOf,MAAM,oBAAoB,GAAG,aAAa,CAA4B;IACpE,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,UAAU,qBAAqB,CAAC,EAAE,QAAQ,EAAqB;IACnE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAY,IAAI,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAClE,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACxC,QAAQ,GACqB,CACjC,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,kEAAkE;AAClE,MAAM,UAAU,gBAAgB,CAAC,OAAkB;IACjD,OAAO,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EACzC,OAAO,GAAG,IAAI,EACd,UAAU,EACV,OAAO,GAKR;IACC,4EAA4E;IAC5E,2EAA2E;IAC3E,4EAA4E;IAC5E,4CAA4C;IAC5C,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACzC,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC;IAEnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,UAAU,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnC,2EAA2E;IAC3E,qEAAqE;IACrE,uBAAuB;IACvB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC","sourcesContent":["import {\n createContext,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\ninterface WindowSidebarContextValue {\n sidebar: ReactNode;\n setSidebar: (node: ReactNode) => void;\n}\n\nconst WindowSidebarContext = createContext<WindowSidebarContextValue>({\n sidebar: null,\n setSidebar: () => {},\n});\n\nexport function WindowSidebarProvider({ children }: PropsWithChildren) {\n const [sidebar, setSidebar] = useState<ReactNode>(null);\n const value = useMemo(() => ({ sidebar, setSidebar }), [sidebar]);\n return (\n <WindowSidebarContext.Provider value={value}>\n {children}\n </WindowSidebarContext.Provider>\n );\n}\n\n// `sidebar` is a ReactNode, so `false`/`null`/`undefined` all mean \"no\n// sidebar\" while renderable falsy values like `0` or `\"\"` do not.\nexport function hasWindowSidebar(sidebar: ReactNode): boolean {\n return sidebar !== null && sidebar !== undefined && sidebar !== false;\n}\n\nexport function useWindowSidebar() {\n return useContext(WindowSidebarContext);\n}\n\nexport function useRegisteredWindowSidebar({\n enabled = true,\n setSidebar,\n sidebar,\n}: {\n enabled?: boolean;\n setSidebar: (node: ReactNode) => void;\n sidebar: ReactNode;\n}) {\n // The ref keeps the clearing cleanup pinned to [enabled] even when a caller\n // passes a setter that is not referentially stable: with setSidebar in the\n // cleanup's deps, every such render would clear-then-reregister the sidebar\n // and re-render the window shell in a loop.\n const setSidebarRef = useRef(setSidebar);\n setSidebarRef.current = setSidebar;\n\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n setSidebar(sidebar);\n }, [enabled, setSidebar, sidebar]);\n\n // Clearing stays in its own effect so a sidebar-node change swaps the node\n // without a transient null; the cleanup runs only on unmount or when\n // `enabled` flips off.\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n return () => setSidebarRef.current(null);\n }, [enabled]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowStateProvider.js","sourceRoot":"","sources":["../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/WindowStateProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,UAAU,mBAAmB,CAAC,EAAE,QAAQ,EAAqB;IACjE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,EAAE,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,qBAAqB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,EAC1E,CAAC,OAAO,CAAC,CACV,CAAC;IACF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,OAAO;QACP,SAAS;KACV,CAAC,EACF,CAAC,OAAO,EAAE,SAAS,CAAC,CACrB,CAAC;IACF,OAAO,CACL,KAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YACnD,KAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAC9C,QAAQ,GAC2B,GACA,CACzC,CAAC;AACJ,CAAC","sourcesContent":["import { type PropsWithChildren, useMemo, useRef, useState } from \"react\";\nimport { windowActionsContext, windowStateContext } from \"./context\";\nimport type { WindowEntry, WindowStateData } from \"./types\";\nimport { useWindowStateActions } from \"./useWindowStateActions\";\n\nexport function WindowStateProvider({ children }: PropsWithChildren) {\n const [windows, setWindows] = useState<WindowEntry[]>([]);\n const counter = useRef(0);\n const actions = useWindowStateActions({ counter, setWindows });\n const windowMap = useMemo(\n () => new Map(windows.map((windowEntry) => [windowEntry.id, windowEntry])),\n [windows],\n );\n const state = useMemo<WindowStateData>(\n () => ({\n windows,\n windowMap,\n }),\n [windows, windowMap],\n );\n return (\n <windowActionsContext.context.Provider value={actions}>\n <windowStateContext.context.Provider value={state}>\n {children}\n </windowStateContext.context.Provider>\n </windowActionsContext.context.Provider>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowStateProvider.js","sourceRoot":"","sources":["../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/WindowStateProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,UAAU,mBAAmB,CAAC,EAAE,QAAQ,EAAqB;IACjE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,EAAE,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,qBAAqB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,EAC1E,CAAC,OAAO,CAAC,CACV,CAAC;IACF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,OAAO;QACP,SAAS;KACV,CAAC,EACF,CAAC,OAAO,EAAE,SAAS,CAAC,CACrB,CAAC;IACF,OAAO,CACL,KAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YACnD,KAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAC9C,QAAQ,GAC2B,GACA,CACzC,CAAC;AACJ,CAAC","sourcesContent":["import { type PropsWithChildren, useMemo, useRef, useState } from \"react\";\nimport { windowActionsContext, windowStateContext } from \"./context\";\nimport type { WindowEntry, WindowStateData } from \"./types\";\nimport { useWindowStateActions } from \"./useWindowStateActions\";\n\nexport function WindowStateProvider({ children }: PropsWithChildren) {\n const [windows, setWindows] = useState<WindowEntry[]>([]);\n const counter = useRef(0);\n const actions = useWindowStateActions({ counter, setWindows });\n const windowMap = useMemo(\n () => new Map(windows.map((windowEntry) => [windowEntry.id, windowEntry])),\n [windows],\n );\n const state = useMemo<WindowStateData>(\n () => ({\n windows,\n windowMap,\n }),\n [windows, windowMap],\n );\n return (\n <windowActionsContext.context.Provider value={actions}>\n <windowStateContext.context.Provider value={state}>\n {children}\n </windowStateContext.context.Provider>\n </windowActionsContext.context.Provider>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,6BAA6B,CAAC;AAGrC,0EAA0E;AAC1E,4EAA4E;AAC5E,UAAU;AACV,MAAM,CAAC,MAAM,kBAAkB,GAC7B,qBAAqB,CAAC,iDAAiD,CAAC,CAAC;AAE3E,MAAM,CAAC,MAAM,oBAAoB,GAC/B,qBAAqB,CAAC,+CAA+C,CAAC,CAAC","sourcesContent":["import {\n createRequiredContext,\n type RequiredContext,\n} from \"../../createRequiredContext\";\nimport type { WindowStateActions, WindowStateData } from \"./types\";\n\n// Keep state and actions in separate contexts so consumers that only need\n// stable actions like create/restore do not re-render on every window-state\n// change.\nexport const windowStateContext: RequiredContext<WindowStateData> =\n createRequiredContext(\"useWindowStateData requires WindowStateProvider\");\n\nexport const windowActionsContext: RequiredContext<WindowStateActions> =\n createRequiredContext(\"useWindowActions requires WindowStateProvider\");\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,6BAA6B,CAAC;AAGrC,0EAA0E;AAC1E,4EAA4E;AAC5E,UAAU;AACV,MAAM,CAAC,MAAM,kBAAkB,GAC7B,qBAAqB,CAAC,iDAAiD,CAAC,CAAC;AAE3E,MAAM,CAAC,MAAM,oBAAoB,GAC/B,qBAAqB,CAAC,+CAA+C,CAAC,CAAC","sourcesContent":["import {\n createRequiredContext,\n type RequiredContext,\n} from \"../../createRequiredContext\";\nimport type { WindowStateActions, WindowStateData } from \"./types\";\n\n// Keep state and actions in separate contexts so consumers that only need\n// stable actions like create/restore do not re-render on every window-state\n// change.\nexport const windowStateContext: RequiredContext<WindowStateData> =\n createRequiredContext(\"useWindowStateData requires WindowStateProvider\");\n\nexport const windowActionsContext: RequiredContext<WindowStateActions> =\n createRequiredContext(\"useWindowActions requires WindowStateProvider\");\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export type {\n WindowCreateOptions,\n WindowEntry,\n WindowGeometry,\n WindowPosition,\n WindowSize,\n WindowStateActions,\n WindowStateData,\n} from \"./types\";\nexport { useWindowActions } from \"./useWindowActions\";\nexport { useWindowStateData } from \"./useWindowStateData\";\nexport { findTopWindow } from \"./util\";\nexport { WindowStateProvider } from \"./WindowStateProvider\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export type {\n WindowCreateOptions,\n WindowEntry,\n WindowGeometry,\n WindowPosition,\n WindowSize,\n WindowStateActions,\n WindowStateData,\n} from \"./types\";\nexport { useWindowActions } from \"./useWindowActions\";\nexport { useWindowStateData } from \"./useWindowStateData\";\nexport { findTopWindow } from \"./util\";\nexport { WindowStateProvider } from \"./WindowStateProvider\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType } from \"react\";\n\nexport type WindowMoveDirection = \"forward\" | \"backward\";\n\n// Window geometry is relative to the desktop surface a window is rendered in\n// (the window's offset parent), not to the viewport.\nexport interface WindowPosition {\n x: number;\n y: number;\n}\n\nexport interface WindowSize {\n width: number;\n height: number;\n}\n\nexport interface WindowGeometry {\n position: WindowPosition;\n size?: WindowSize | undefined;\n}\n\nexport interface WindowEntry {\n // An opaque key naming the app that owns this window. The window layer only\n // stores and compares it; the host interprets it (see Window's\n // ContentBoundary).\n appId?: string;\n id: string;\n initialShowSidebar?: boolean | undefined;\n pathSegments?: ReadonlyArray<string> | undefined;\n // The window's own Back stack: routes previously visited in this window, the\n // most recent last. A window is not backed by browser history (only the\n // routed shell is), so this is what gives the windowed toolbar a working Back\n // caret. Forward is deliberately not modelled — the toolbar offers Back only.\n routeHistory?: ReadonlyArray<ReadonlyArray<string>> | undefined;\n title: string;\n // Where the window first appears, in viewport coordinates (for example the\n // point a launcher was clicked). Ignored once position is known.\n initialX: number;\n initialY: number;\n // The window's committed geometry. Set when the window is first laid out and\n // whenever a drag or resize ends, so a host can save and restore a layout.\n // Without size the window takes its stylesheet's default size.\n position?: WindowPosition | undefined;\n size?: WindowSize | undefined;\n // maximized and minimized live here rather than inside Window so the taskbar\n // can drive both without reaching into a window's local state.\n maximized: boolean;\n minimized: boolean;\n zIndex: number;\n component?: ComponentType;\n}\n\nexport interface WindowCreateOptions {\n appId?: string;\n initialShowSidebar?: boolean | undefined;\n pathSegments?: ReadonlyArray<string> | undefined;\n // Surface-relative geometry to open with, such as a restored layout. A\n // position takes precedence over create's viewport x/y.\n position?: WindowPosition | undefined;\n size?: WindowSize | undefined;\n}\n\nexport interface WindowStateData {\n // windows is the raw useState array — stable and cheap to iterate for\n // rendering lists. windowMap is derived via useMemo for O(1) lookups by ID.\n // Both are already memoized so neither adds redundant computation.\n windows: WindowEntry[];\n windowMap: Map<string, WindowEntry>;\n}\n\nexport interface WindowStateActions {\n create: (\n title: string,\n x: number,\n y: number,\n component?: ComponentType,\n options?: WindowCreateOptions,\n ) => string;\n close: (id: string) => void;\n maximize: (id: string) => void;\n minimize: (id: string) => void;\n restore: (id: string) => void;\n toggleMaximize: (id: string) => void;\n updateRoute: (\n id: string,\n pathSegments: ReadonlyArray<string>,\n options?: { replace?: boolean | undefined },\n ) => void;\n goBackRoute: (id: string) => void;\n updateTitle: (id: string, title: string) => void;\n moveForward: (id: string) => void;\n moveBackward: (id: string) => void;\n bringToFront: (id: string) => void;\n setGeometry: (id: string, geometry: WindowGeometry) => void;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType } from \"react\";\n\nexport type WindowMoveDirection = \"forward\" | \"backward\";\n\n// Window geometry is relative to the desktop surface a window is rendered in\n// (the window's offset parent), not to the viewport.\nexport interface WindowPosition {\n x: number;\n y: number;\n}\n\nexport interface WindowSize {\n width: number;\n height: number;\n}\n\nexport interface WindowGeometry {\n position: WindowPosition;\n size?: WindowSize | undefined;\n}\n\nexport interface WindowEntry {\n // An opaque key naming the app that owns this window. The window layer only\n // stores and compares it; the host interprets it (see Window's\n // ContentBoundary).\n appId?: string;\n id: string;\n initialShowSidebar?: boolean | undefined;\n pathSegments?: ReadonlyArray<string> | undefined;\n // The window's own Back stack: routes previously visited in this window, the\n // most recent last. A window is not backed by browser history (only the\n // routed shell is), so this is what gives the windowed toolbar a working Back\n // caret. Forward is deliberately not modelled — the toolbar offers Back only.\n routeHistory?: ReadonlyArray<ReadonlyArray<string>> | undefined;\n title: string;\n // Where the window first appears, in viewport coordinates (for example the\n // point a launcher was clicked). Ignored once position is known.\n initialX: number;\n initialY: number;\n // The window's committed geometry. Set when the window is first laid out and\n // whenever a drag or resize ends, so a host can save and restore a layout.\n // Without size the window takes its stylesheet's default size.\n position?: WindowPosition | undefined;\n size?: WindowSize | undefined;\n // maximized and minimized live here rather than inside Window so the taskbar\n // can drive both without reaching into a window's local state.\n maximized: boolean;\n minimized: boolean;\n zIndex: number;\n component?: ComponentType;\n}\n\nexport interface WindowCreateOptions {\n appId?: string;\n initialShowSidebar?: boolean | undefined;\n pathSegments?: ReadonlyArray<string> | undefined;\n // Surface-relative geometry to open with, such as a restored layout. A\n // position takes precedence over create's viewport x/y.\n position?: WindowPosition | undefined;\n size?: WindowSize | undefined;\n}\n\nexport interface WindowStateData {\n // windows is the raw useState array — stable and cheap to iterate for\n // rendering lists. windowMap is derived via useMemo for O(1) lookups by ID.\n // Both are already memoized so neither adds redundant computation.\n windows: WindowEntry[];\n windowMap: Map<string, WindowEntry>;\n}\n\nexport interface WindowStateActions {\n create: (\n title: string,\n x: number,\n y: number,\n component?: ComponentType,\n options?: WindowCreateOptions,\n ) => string;\n close: (id: string) => void;\n maximize: (id: string) => void;\n minimize: (id: string) => void;\n restore: (id: string) => void;\n toggleMaximize: (id: string) => void;\n updateRoute: (\n id: string,\n pathSegments: ReadonlyArray<string>,\n options?: { replace?: boolean | undefined },\n ) => void;\n goBackRoute: (id: string) => void;\n updateTitle: (id: string, title: string) => void;\n moveForward: (id: string) => void;\n moveBackward: (id: string) => void;\n bringToFront: (id: string) => void;\n setGeometry: (id: string, geometry: WindowGeometry) => void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowActions.js","sourceRoot":"","sources":["../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/useWindowActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,WAAW,CAAC","sourcesContent":["import { windowActionsContext } from \"./context\";\n\nexport const useWindowActions = windowActionsContext.useRequired;\n"]}
1
+ {"version":3,"file":"useWindowActions.js","sourceRoot":"","sources":["../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/useWindowActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,WAAW,CAAC","sourcesContent":["import { windowActionsContext } from \"./context\";\n\nexport const useWindowActions = windowActionsContext.useRequired;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowStateActions.js","sourceRoot":"","sources":["../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/useWindowStateActions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAOhB,SAAS,oBAAoB,CAC3B,IAA2B,EAC3B,KAA4B;IA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AAQ;QACR,QAAQ;QACR,YAAY;QACZ,WAAW;QACX,OAAO;QACP,WAAW;QACX,cAAc;QACd,WAAW;QACX,WAAW;KACZ,CAAC,EACF;QACE,YAAY;QACZ,KAAK;QACL,MAAM;QACN,WAAW;QACX,QAAQ;QACR,QAAQ;QACR,YAAY;QACZ,WAAW;QACX,OAAO;QACP,WAAW;QACX,cAAc;QACd,WAAW;QACX,WAAW;KACZ,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ComponentType,\n Dispatch,\n MutableRefObject,\n SetStateAction,\n} from \"react\";\nimport { useCallback, useMemo } from \"react\";\nimport type { WindowCreateOptions, WindowEntry, WindowGeometry } from \"./types\";\nimport {\n bringWindowToFront,\n createWindowEntry,\n getMaxWindowZIndex,\n swapWindowZIndexes,\n updateWindowFlag,\n} from \"./util\";\n\ninterface UseWindowStateActionsParams {\n counter: MutableRefObject<number>;\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>;\n}\n\nfunction arePathSegmentsEqual(\n left: ReadonlyArray<string>,\n right: ReadonlyArray<string>,\n) {\n return (\n left.length === right.length &&\n left.every((segment, index) => segment === right[index])\n );\n}\n\nfunction hasGeometry(entry: WindowEntry, geometry: WindowGeometry) {\n return (\n entry.position?.x === geometry.position.x &&\n entry.position?.y === geometry.position.y &&\n entry.size?.width === geometry.size?.width &&\n entry.size?.height === geometry.size?.height\n );\n}\n\nfunction useSetGeometryAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (id: string, geometry: WindowGeometry) => {\n setWindows((previousWindows) => {\n const targetWindow = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n if (!targetWindow || hasGeometry(targetWindow, geometry)) {\n return previousWindows;\n }\n\n return updateWindowFlag(previousWindows, id, {\n position: { ...geometry.position },\n size: geometry.size ? { ...geometry.size } : undefined,\n });\n });\n },\n [setWindows],\n );\n}\n\nfunction useUpdateRouteAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (\n id: string,\n pathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n setWindows((previousWindows) => {\n const targetWindow = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n if (!targetWindow) {\n return previousWindows;\n }\n\n const currentPathSegments = targetWindow.pathSegments ?? [];\n if (arePathSegmentsEqual(currentPathSegments, pathSegments)) {\n return previousWindows;\n }\n\n // A replacing navigation swaps the current entry rather than stacking on\n // it — the transient step it replaces (a type picker, an unavailable\n // route corrected to the default) must not become a Back destination.\n const nextHistory = options.replace\n ? (targetWindow.routeHistory ?? [])\n : [...(targetWindow.routeHistory ?? []), currentPathSegments];\n\n return previousWindows.map((windowEntry) =>\n windowEntry.id === id\n ? {\n ...windowEntry,\n pathSegments: [...pathSegments],\n routeHistory: nextHistory,\n }\n : windowEntry,\n );\n });\n },\n [setWindows],\n );\n}\n\nfunction useGoBackRouteAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (id: string) => {\n setWindows((previousWindows) => {\n const targetWindow = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n const history = targetWindow?.routeHistory ?? [];\n const previousPathSegments = history[history.length - 1];\n if (!targetWindow || previousPathSegments === undefined) {\n return previousWindows;\n }\n\n return previousWindows.map((windowEntry) =>\n windowEntry.id === id\n ? {\n ...windowEntry,\n pathSegments: [...previousPathSegments],\n routeHistory: history.slice(0, -1),\n }\n : windowEntry,\n );\n });\n },\n [setWindows],\n );\n}\n\nfunction useCloseWindowAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n previousWindows.filter((windowEntry) => windowEntry.id !== id),\n );\n },\n [setWindows],\n );\n}\n\nfunction useWindowMaximizeActions(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n // Maximizing always reveals the window, so it un-minimizes and raises in one\n // step — the taskbar can offer \"Maximize\" on a minimized window directly.\n const maximize = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n updateWindowFlag(bringWindowToFront(previousWindows, id), id, {\n maximized: true,\n minimized: false,\n }),\n );\n },\n [setWindows],\n );\n\n const toggleMaximize = useCallback(\n (id: string) => {\n setWindows((previousWindows) => {\n const target = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n if (!target) {\n return previousWindows;\n }\n\n const maximized = !target.maximized;\n return updateWindowFlag(\n maximized ? bringWindowToFront(previousWindows, id) : previousWindows,\n id,\n { maximized },\n );\n });\n },\n [setWindows],\n );\n\n return { maximize, toggleMaximize };\n}\n\nfunction useWindowZOrderActions(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n const moveForward = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n swapWindowZIndexes(previousWindows, id, \"forward\"),\n );\n },\n [setWindows],\n );\n\n const moveBackward = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n swapWindowZIndexes(previousWindows, id, \"backward\"),\n );\n },\n [setWindows],\n );\n\n const bringToFront = useCallback(\n (id: string) => {\n setWindows((previousWindows) => bringWindowToFront(previousWindows, id));\n },\n [setWindows],\n );\n\n return { bringToFront, moveBackward, moveForward };\n}\n\n// Updates to a single window's own fields: its title and its geometry.\nfunction useWindowFieldActions(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n const updateTitle = useCallback(\n (id: string, title: string) => {\n setWindows((previousWindows) =>\n updateWindowFlag(previousWindows, id, { title }),\n );\n },\n [setWindows],\n );\n const setGeometry = useSetGeometryAction(setWindows);\n\n return { setGeometry, updateTitle };\n}\n\nexport function useWindowStateActions({\n counter,\n setWindows,\n}: UseWindowStateActionsParams) {\n const create = useCallback(\n (\n title: string,\n x: number,\n y: number,\n component?: ComponentType,\n options: WindowCreateOptions = {},\n ) => {\n const id = String(++counter.current);\n setWindows((previousWindows) => {\n const maxZIndex = getMaxWindowZIndex(previousWindows);\n return [\n ...previousWindows,\n createWindowEntry(id, title, x, y, maxZIndex + 1, component, options),\n ];\n });\n return id;\n },\n [counter, setWindows],\n );\n\n const close = useCloseWindowAction(setWindows);\n\n const minimize = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n updateWindowFlag(previousWindows, id, { minimized: true }),\n );\n },\n [setWindows],\n );\n\n const restore = useCallback(\n (id: string) => {\n setWindows((previousWindows) => {\n const frontWindows = bringWindowToFront(previousWindows, id);\n return updateWindowFlag(frontWindows, id, { minimized: false });\n });\n },\n [setWindows],\n );\n\n const { maximize, toggleMaximize } = useWindowMaximizeActions(setWindows);\n\n const updateRoute = useUpdateRouteAction(setWindows);\n const goBackRoute = useGoBackRouteAction(setWindows);\n\n const { setGeometry, updateTitle } = useWindowFieldActions(setWindows);\n\n const { bringToFront, moveBackward, moveForward } =\n useWindowZOrderActions(setWindows);\n\n return useMemo(\n () => ({\n bringToFront,\n close,\n create,\n goBackRoute,\n maximize,\n minimize,\n moveBackward,\n moveForward,\n restore,\n setGeometry,\n toggleMaximize,\n updateRoute,\n updateTitle,\n }),\n [\n bringToFront,\n close,\n create,\n goBackRoute,\n maximize,\n minimize,\n moveBackward,\n moveForward,\n restore,\n setGeometry,\n toggleMaximize,\n updateRoute,\n updateTitle,\n ],\n );\n}\n"]}
1
+ {"version":3,"file":"useWindowStateActions.js","sourceRoot":"","sources":["../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/useWindowStateActions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAOhB,SAAS,oBAAoB,CAC3B,IAA2B,EAC3B,KAA4B;IAE5B,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC5B,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO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,CAAC,EACF;QACE,YAAY;QACZ,KAAK;QACL,MAAM;QACN,WAAW;QACX,QAAQ;QACR,QAAQ;QACR,YAAY;QACZ,WAAW;QACX,OAAO;QACP,WAAW;QACX,cAAc;QACd,WAAW;QACX,WAAW;KACZ,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ComponentType,\n Dispatch,\n MutableRefObject,\n SetStateAction,\n} from \"react\";\nimport { useCallback, useMemo } from \"react\";\nimport type { WindowCreateOptions, WindowEntry, WindowGeometry } from \"./types\";\nimport {\n bringWindowToFront,\n createWindowEntry,\n getMaxWindowZIndex,\n swapWindowZIndexes,\n updateWindowFlag,\n} from \"./util\";\n\ninterface UseWindowStateActionsParams {\n counter: MutableRefObject<number>;\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>;\n}\n\nfunction arePathSegmentsEqual(\n left: ReadonlyArray<string>,\n right: ReadonlyArray<string>,\n) {\n return (\n left.length === right.length &&\n left.every((segment, index) => segment === right[index])\n );\n}\n\nfunction hasGeometry(entry: WindowEntry, geometry: WindowGeometry) {\n return (\n entry.position?.x === geometry.position.x &&\n entry.position?.y === geometry.position.y &&\n entry.size?.width === geometry.size?.width &&\n entry.size?.height === geometry.size?.height\n );\n}\n\nfunction useSetGeometryAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (id: string, geometry: WindowGeometry) => {\n setWindows((previousWindows) => {\n const targetWindow = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n if (!targetWindow || hasGeometry(targetWindow, geometry)) {\n return previousWindows;\n }\n\n return updateWindowFlag(previousWindows, id, {\n position: { ...geometry.position },\n size: geometry.size ? { ...geometry.size } : undefined,\n });\n });\n },\n [setWindows],\n );\n}\n\nfunction useUpdateRouteAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (\n id: string,\n pathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n setWindows((previousWindows) => {\n const targetWindow = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n if (!targetWindow) {\n return previousWindows;\n }\n\n const currentPathSegments = targetWindow.pathSegments ?? [];\n if (arePathSegmentsEqual(currentPathSegments, pathSegments)) {\n return previousWindows;\n }\n\n // A replacing navigation swaps the current entry rather than stacking on\n // it — the transient step it replaces (a type picker, an unavailable\n // route corrected to the default) must not become a Back destination.\n const nextHistory = options.replace\n ? (targetWindow.routeHistory ?? [])\n : [...(targetWindow.routeHistory ?? []), currentPathSegments];\n\n return previousWindows.map((windowEntry) =>\n windowEntry.id === id\n ? {\n ...windowEntry,\n pathSegments: [...pathSegments],\n routeHistory: nextHistory,\n }\n : windowEntry,\n );\n });\n },\n [setWindows],\n );\n}\n\nfunction useGoBackRouteAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (id: string) => {\n setWindows((previousWindows) => {\n const targetWindow = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n const history = targetWindow?.routeHistory ?? [];\n const previousPathSegments = history[history.length - 1];\n if (!targetWindow || previousPathSegments === undefined) {\n return previousWindows;\n }\n\n return previousWindows.map((windowEntry) =>\n windowEntry.id === id\n ? {\n ...windowEntry,\n pathSegments: [...previousPathSegments],\n routeHistory: history.slice(0, -1),\n }\n : windowEntry,\n );\n });\n },\n [setWindows],\n );\n}\n\nfunction useCloseWindowAction(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n return useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n previousWindows.filter((windowEntry) => windowEntry.id !== id),\n );\n },\n [setWindows],\n );\n}\n\nfunction useWindowMaximizeActions(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n // Maximizing always reveals the window, so it un-minimizes and raises in one\n // step — the taskbar can offer \"Maximize\" on a minimized window directly.\n const maximize = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n updateWindowFlag(bringWindowToFront(previousWindows, id), id, {\n maximized: true,\n minimized: false,\n }),\n );\n },\n [setWindows],\n );\n\n const toggleMaximize = useCallback(\n (id: string) => {\n setWindows((previousWindows) => {\n const target = previousWindows.find(\n (windowEntry) => windowEntry.id === id,\n );\n if (!target) {\n return previousWindows;\n }\n\n const maximized = !target.maximized;\n return updateWindowFlag(\n maximized ? bringWindowToFront(previousWindows, id) : previousWindows,\n id,\n { maximized },\n );\n });\n },\n [setWindows],\n );\n\n return { maximize, toggleMaximize };\n}\n\nfunction useWindowZOrderActions(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n const moveForward = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n swapWindowZIndexes(previousWindows, id, \"forward\"),\n );\n },\n [setWindows],\n );\n\n const moveBackward = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n swapWindowZIndexes(previousWindows, id, \"backward\"),\n );\n },\n [setWindows],\n );\n\n const bringToFront = useCallback(\n (id: string) => {\n setWindows((previousWindows) => bringWindowToFront(previousWindows, id));\n },\n [setWindows],\n );\n\n return { bringToFront, moveBackward, moveForward };\n}\n\n// Updates to a single window's own fields: its title and its geometry.\nfunction useWindowFieldActions(\n setWindows: Dispatch<SetStateAction<WindowEntry[]>>,\n) {\n const updateTitle = useCallback(\n (id: string, title: string) => {\n setWindows((previousWindows) =>\n updateWindowFlag(previousWindows, id, { title }),\n );\n },\n [setWindows],\n );\n const setGeometry = useSetGeometryAction(setWindows);\n\n return { setGeometry, updateTitle };\n}\n\nexport function useWindowStateActions({\n counter,\n setWindows,\n}: UseWindowStateActionsParams) {\n const create = useCallback(\n (\n title: string,\n x: number,\n y: number,\n component?: ComponentType,\n options: WindowCreateOptions = {},\n ) => {\n const id = String(++counter.current);\n setWindows((previousWindows) => {\n const maxZIndex = getMaxWindowZIndex(previousWindows);\n return [\n ...previousWindows,\n createWindowEntry(id, title, x, y, maxZIndex + 1, component, options),\n ];\n });\n return id;\n },\n [counter, setWindows],\n );\n\n const close = useCloseWindowAction(setWindows);\n\n const minimize = useCallback(\n (id: string) => {\n setWindows((previousWindows) =>\n updateWindowFlag(previousWindows, id, { minimized: true }),\n );\n },\n [setWindows],\n );\n\n const restore = useCallback(\n (id: string) => {\n setWindows((previousWindows) => {\n const frontWindows = bringWindowToFront(previousWindows, id);\n return updateWindowFlag(frontWindows, id, { minimized: false });\n });\n },\n [setWindows],\n );\n\n const { maximize, toggleMaximize } = useWindowMaximizeActions(setWindows);\n\n const updateRoute = useUpdateRouteAction(setWindows);\n const goBackRoute = useGoBackRouteAction(setWindows);\n\n const { setGeometry, updateTitle } = useWindowFieldActions(setWindows);\n\n const { bringToFront, moveBackward, moveForward } =\n useWindowZOrderActions(setWindows);\n\n return useMemo(\n () => ({\n bringToFront,\n close,\n create,\n goBackRoute,\n maximize,\n minimize,\n moveBackward,\n moveForward,\n restore,\n setGeometry,\n toggleMaximize,\n updateRoute,\n updateTitle,\n }),\n [\n bringToFront,\n close,\n create,\n goBackRoute,\n maximize,\n minimize,\n moveBackward,\n moveForward,\n restore,\n setGeometry,\n toggleMaximize,\n updateRoute,\n updateTitle,\n ],\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowStateData.js","sourceRoot":"","sources":["../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/useWindowStateData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,WAAW,CAAC","sourcesContent":["import { windowStateContext } from \"./context\";\n\nexport const useWindowStateData = windowStateContext.useRequired;\n"]}
1
+ {"version":3,"file":"useWindowStateData.js","sourceRoot":"","sources":["../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/useWindowStateData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,WAAW,CAAC","sourcesContent":["import { windowStateContext } from \"./context\";\n\nexport const useWindowStateData = windowStateContext.useRequired;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bringWindowToFront.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/bringWindowToFront.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,kBAAkB,CAAC,OAAsB,EAAE,EAAU;IACnE,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;QACjC,IAAI,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;YACjC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAC/C,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5D,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\nimport { getMaxWindowZIndex } from \"./getMaxWindowZIndex\";\n\nexport function bringWindowToFront(windows: WindowEntry[], id: string) {\n const target = windows.find((windowEntry) => windowEntry.id === id);\n if (!target) {\n return windows;\n }\n\n const topZIndex = getMaxWindowZIndex(windows);\n if (target.zIndex === topZIndex) {\n return windows;\n }\n\n return windows.map((windowEntry) => {\n if (windowEntry.id === target.id) {\n return { ...windowEntry, zIndex: topZIndex };\n }\n if (windowEntry.zIndex > target.zIndex) {\n return { ...windowEntry, zIndex: windowEntry.zIndex - 1 };\n }\n return windowEntry;\n });\n}\n"]}
1
+ {"version":3,"file":"bringWindowToFront.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/bringWindowToFront.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,kBAAkB,CAAC,OAAsB,EAAE,EAAU;IACnE,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;QACjC,IAAI,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;YACjC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAC/C,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5D,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\nimport { getMaxWindowZIndex } from \"./getMaxWindowZIndex\";\n\nexport function bringWindowToFront(windows: WindowEntry[], id: string) {\n const target = windows.find((windowEntry) => windowEntry.id === id);\n if (!target) {\n return windows;\n }\n\n const topZIndex = getMaxWindowZIndex(windows);\n if (target.zIndex === topZIndex) {\n return windows;\n }\n\n return windows.map((windowEntry) => {\n if (windowEntry.id === target.id) {\n return { ...windowEntry, zIndex: topZIndex };\n }\n if (windowEntry.zIndex > target.zIndex) {\n return { ...windowEntry, zIndex: windowEntry.zIndex - 1 };\n }\n return windowEntry;\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createWindowEntry.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/createWindowEntry.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iBAAiB,CAC/B,EAAU,EACV,KAAa,EACb,CAAS,EACT,CAAS,EACT,MAAc,EACd,SAAyB,EACzB,UAA+B,EAAE;IAEjC,OAAO;QACL,EAAE;QACF,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,GAAG,CAAC,OAAO,CAAC,YAAY;YACtB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,EAAE;YAC7C,CAAC,CAAC,EAAE,CAAC;QACP,KAAK;QACL,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,KAAK;QAChB,MAAM;QACN,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC","sourcesContent":["import type { ComponentType } from \"react\";\nimport type { WindowCreateOptions, WindowEntry } from \"../types\";\n\nexport function createWindowEntry(\n id: string,\n title: string,\n x: number,\n y: number,\n zIndex: number,\n component?: ComponentType,\n options: WindowCreateOptions = {},\n): WindowEntry {\n return {\n id,\n ...(options.appId ? { appId: options.appId } : {}),\n initialShowSidebar: options.initialShowSidebar,\n ...(options.pathSegments\n ? { pathSegments: [...options.pathSegments] }\n : {}),\n title,\n initialX: x,\n initialY: y,\n ...(options.position ? { position: { ...options.position } } : {}),\n ...(options.size ? { size: { ...options.size } } : {}),\n maximized: false,\n minimized: false,\n zIndex,\n ...(component ? { component } : {}),\n };\n}\n"]}
1
+ {"version":3,"file":"createWindowEntry.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/createWindowEntry.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iBAAiB,CAC/B,EAAU,EACV,KAAa,EACb,CAAS,EACT,CAAS,EACT,MAAc,EACd,SAAyB,EACzB,UAA+B,EAAE;IAEjC,OAAO;QACL,EAAE;QACF,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,GAAG,CAAC,OAAO,CAAC,YAAY;YACtB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,EAAE;YAC7C,CAAC,CAAC,EAAE,CAAC;QACP,KAAK;QACL,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,KAAK;QAChB,MAAM;QACN,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC","sourcesContent":["import type { ComponentType } from \"react\";\nimport type { WindowCreateOptions, WindowEntry } from \"../types\";\n\nexport function createWindowEntry(\n id: string,\n title: string,\n x: number,\n y: number,\n zIndex: number,\n component?: ComponentType,\n options: WindowCreateOptions = {},\n): WindowEntry {\n return {\n id,\n ...(options.appId ? { appId: options.appId } : {}),\n initialShowSidebar: options.initialShowSidebar,\n ...(options.pathSegments\n ? { pathSegments: [...options.pathSegments] }\n : {}),\n title,\n initialX: x,\n initialY: y,\n ...(options.position ? { position: { ...options.position } } : {}),\n ...(options.size ? { size: { ...options.size } } : {}),\n maximized: false,\n minimized: false,\n zIndex,\n ...(component ? { component } : {}),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"findAdjacentWindow.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/findAdjacentWindow.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAChC,OAAsB,EACtB,MAAmB,EACnB,SAA8B;IAE9B,IAAI,SAAS,GAAuB,IAAI,CAAC;IAEzC,KAAK,MAAM,WAAW,IAAI,OAAO,EAAE,CAAC;QAClC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACxC,SAAS;YACX,CAAC;YACD,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;gBACxD,SAAS,GAAG,WAAW,CAAC;YAC1B,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACxC,SAAS;QACX,CAAC;QACD,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;YACxD,SAAS,GAAG,WAAW,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { WindowEntry, WindowMoveDirection } from \"../types\";\n\nexport function findAdjacentWindow(\n windows: WindowEntry[],\n target: WindowEntry,\n direction: WindowMoveDirection,\n) {\n let candidate: WindowEntry | null = null;\n\n for (const windowEntry of windows) {\n if (direction === \"forward\") {\n if (windowEntry.zIndex <= target.zIndex) {\n continue;\n }\n if (!candidate || windowEntry.zIndex < candidate.zIndex) {\n candidate = windowEntry;\n }\n continue;\n }\n\n if (windowEntry.zIndex >= target.zIndex) {\n continue;\n }\n if (!candidate || windowEntry.zIndex > candidate.zIndex) {\n candidate = windowEntry;\n }\n }\n\n return candidate;\n}\n"]}
1
+ {"version":3,"file":"findAdjacentWindow.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/findAdjacentWindow.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAChC,OAAsB,EACtB,MAAmB,EACnB,SAA8B;IAE9B,IAAI,SAAS,GAAuB,IAAI,CAAC;IAEzC,KAAK,MAAM,WAAW,IAAI,OAAO,EAAE,CAAC;QAClC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACxC,SAAS;YACX,CAAC;YACD,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;gBACxD,SAAS,GAAG,WAAW,CAAC;YAC1B,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACxC,SAAS;QACX,CAAC;QACD,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;YACxD,SAAS,GAAG,WAAW,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { WindowEntry, WindowMoveDirection } from \"../types\";\n\nexport function findAdjacentWindow(\n windows: WindowEntry[],\n target: WindowEntry,\n direction: WindowMoveDirection,\n) {\n let candidate: WindowEntry | null = null;\n\n for (const windowEntry of windows) {\n if (direction === \"forward\") {\n if (windowEntry.zIndex <= target.zIndex) {\n continue;\n }\n if (!candidate || windowEntry.zIndex < candidate.zIndex) {\n candidate = windowEntry;\n }\n continue;\n }\n\n if (windowEntry.zIndex >= target.zIndex) {\n continue;\n }\n if (!candidate || windowEntry.zIndex > candidate.zIndex) {\n candidate = windowEntry;\n }\n }\n\n return candidate;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"findTopWindow.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/findTopWindow.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAC3B,OAAmC,EACnC,OAA8C;IAE9C,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CACjB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,SAAS,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QAC3D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,GAAG,EACT,IAAI,CACL,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\n\n/** The highest-zIndex window matching `matches`, or null when none do. */\nexport function findTopWindow(\n windows: ReadonlyArray<WindowEntry>,\n matches: (windowEntry: WindowEntry) => boolean,\n): WindowEntry | null {\n return windows.reduce<WindowEntry | null>(\n (top, candidate) =>\n matches(candidate) && (!top || candidate.zIndex > top.zIndex)\n ? candidate\n : top,\n null,\n );\n}\n"]}
1
+ {"version":3,"file":"findTopWindow.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/findTopWindow.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAC3B,OAAmC,EACnC,OAA8C;IAE9C,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CACjB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,SAAS,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QAC3D,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,GAAG,EACT,IAAI,CACL,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\n\n/** The highest-zIndex window matching `matches`, or null when none do. */\nexport function findTopWindow(\n windows: ReadonlyArray<WindowEntry>,\n matches: (windowEntry: WindowEntry) => boolean,\n): WindowEntry | null {\n return windows.reduce<WindowEntry | null>(\n (top, candidate) =>\n matches(candidate) && (!top || candidate.zIndex > top.zIndex)\n ? candidate\n : top,\n null,\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getMaxWindowZIndex.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/getMaxWindowZIndex.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,OAAmC;IACpE,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EACnE,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\n\nexport function getMaxWindowZIndex(windows: ReadonlyArray<WindowEntry>) {\n return windows.reduce(\n (maxZIndex, windowEntry) => Math.max(maxZIndex, windowEntry.zIndex),\n 0,\n );\n}\n"]}
1
+ {"version":3,"file":"getMaxWindowZIndex.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/getMaxWindowZIndex.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,OAAmC;IACpE,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,EACnE,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\n\nexport function getMaxWindowZIndex(windows: ReadonlyArray<WindowEntry>) {\n return windows.reduce(\n (maxZIndex, windowEntry) => Math.max(maxZIndex, windowEntry.zIndex),\n 0,\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { bringWindowToFront } from \"./bringWindowToFront\";\nexport { createWindowEntry } from \"./createWindowEntry\";\nexport { findTopWindow } from \"./findTopWindow\";\nexport { getMaxWindowZIndex } from \"./getMaxWindowZIndex\";\nexport { swapWindowZIndexes } from \"./swapWindowZIndexes\";\nexport { updateWindowFlag } from \"./updateWindowFlag\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { bringWindowToFront } from \"./bringWindowToFront\";\nexport { createWindowEntry } from \"./createWindowEntry\";\nexport { findTopWindow } from \"./findTopWindow\";\nexport { getMaxWindowZIndex } from \"./getMaxWindowZIndex\";\nexport { swapWindowZIndexes } from \"./swapWindowZIndexes\";\nexport { updateWindowFlag } from \"./updateWindowFlag\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"swapWindowZIndexes.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/swapWindowZIndexes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,kBAAkB,CAChC,OAAsB,EACtB,EAAU,EACV,SAA8B;IAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAChE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;QACjC,IAAI,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;YACjC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrD,CAAC;QACD,IAAI,WAAW,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,EAAE,CAAC;YACnC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { WindowEntry, WindowMoveDirection } from \"../types\";\nimport { findAdjacentWindow } from \"./findAdjacentWindow\";\n\nexport function swapWindowZIndexes(\n windows: WindowEntry[],\n id: string,\n direction: WindowMoveDirection,\n) {\n const target = windows.find((windowEntry) => windowEntry.id === id);\n if (!target) {\n return windows;\n }\n\n const swapWith = findAdjacentWindow(windows, target, direction);\n if (!swapWith) {\n return windows;\n }\n\n return windows.map((windowEntry) => {\n if (windowEntry.id === target.id) {\n return { ...windowEntry, zIndex: swapWith.zIndex };\n }\n if (windowEntry.id === swapWith.id) {\n return { ...windowEntry, zIndex: target.zIndex };\n }\n return windowEntry;\n });\n}\n"]}
1
+ {"version":3,"file":"swapWindowZIndexes.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/swapWindowZIndexes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,kBAAkB,CAChC,OAAsB,EACtB,EAAU,EACV,SAA8B;IAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAChE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;QACjC,IAAI,WAAW,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;YACjC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrD,CAAC;QACD,IAAI,WAAW,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,EAAE,CAAC;YACnC,OAAO,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { WindowEntry, WindowMoveDirection } from \"../types\";\nimport { findAdjacentWindow } from \"./findAdjacentWindow\";\n\nexport function swapWindowZIndexes(\n windows: WindowEntry[],\n id: string,\n direction: WindowMoveDirection,\n) {\n const target = windows.find((windowEntry) => windowEntry.id === id);\n if (!target) {\n return windows;\n }\n\n const swapWith = findAdjacentWindow(windows, target, direction);\n if (!swapWith) {\n return windows;\n }\n\n return windows.map((windowEntry) => {\n if (windowEntry.id === target.id) {\n return { ...windowEntry, zIndex: swapWith.zIndex };\n }\n if (windowEntry.id === swapWith.id) {\n return { ...windowEntry, zIndex: target.zIndex };\n }\n return windowEntry;\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"updateWindowFlag.js","sourceRoot":"","sources":["../../../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStateProvider/util/updateWindowFlag.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAC9B,OAAsB,EACtB,EAAU,EACV,KAEC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACjC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CACnE,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\n\nexport function updateWindowFlag(\n windows: WindowEntry[],\n id: string,\n patch: Partial<\n Pick<WindowEntry, \"maximized\" | \"minimized\" | \"position\" | \"size\" | \"title\">\n >,\n) {\n return windows.map((windowEntry) =>\n windowEntry.id === id ? { ...windowEntry, ...patch } : windowEntry,\n );\n}\n"]}
1
+ {"version":3,"file":"updateWindowFlag.js","sourceRoot":"","sources":["../../../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStateProvider/util/updateWindowFlag.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAC9B,OAAsB,EACtB,EAAU,EACV,KAEC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACjC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CACnE,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowEntry } from \"../types\";\n\nexport function updateWindowFlag(\n windows: WindowEntry[],\n id: string,\n patch: Partial<\n Pick<WindowEntry, \"maximized\" | \"minimized\" | \"position\" | \"size\" | \"title\">\n >,\n) {\n return windows.map((windowEntry) =>\n windowEntry.id === id ? { ...windowEntry, ...patch } : windowEntry,\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowStatusBar.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/WindowStatusBar.tsx"],"names":[],"mappings":";AAAA,OAAO,uBAAuB,CAAC;AAE/B,MAAM,UAAU,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,GAAG,IAAI,GAIf;IACC;;;;;;;;;;;OAWG;IACH,OAAO,CACL,cAAK,SAAS,EAAC,uBAAuB,eAAW,QAAQ,EAAC,IAAI,EAAC,QAAQ,YACpE,IAAI,CAAC,CAAC,CAAC,CACN,cACE,SAAS,EACP,OAAO;gBACL,CAAC,CAAC,kBAAkB;gBACpB,CAAC,CAAC,2CAA2C,YAGhD,IAAI,GACD,CACP,CAAC,CAAC,CAAC,IAAI,GACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["import \"./WindowStatusBar.css\";\n\nexport function WindowStatusBar({\n text,\n visible = true,\n}: {\n text?: string;\n visible?: boolean;\n}) {\n /*\n * The live region stays mounted while the visible bar collapses. A `role=\"status\"`\n * region only announces when text changes on an element already in the DOM, so\n * mounting the region together with its first message loses the announcement.\n * The visible bar is skipped when empty because an empty one would hold\n * `--window-bar-height` of `--color-muted` directly above the equally-muted\n * taskbar, reading as a dead grey band rather than window chrome.\n *\n * Hiding the status bar hides only the visible band: the region stays mounted\n * and the message stays in it, visually hidden, so announcements such as the\n * keyboard move and resize instructions still reach assistive technology.\n */\n return (\n <div className=\"window-statusbar-live\" aria-live=\"polite\" role=\"status\">\n {text ? (\n <div\n className={\n visible\n ? \"window-statusbar\"\n : \"window-statusbar window-statusbar--hidden\"\n }\n >\n {text}\n </div>\n ) : null}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowStatusBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowStatusBar.tsx"],"names":[],"mappings":";AAAA,OAAO,uBAAuB,CAAC;AAE/B,MAAM,UAAU,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,GAAG,IAAI,GAIf;IACC;;;;;;;;;;;OAWG;IACH,OAAO,CACL,cAAK,SAAS,EAAC,uBAAuB,eAAW,QAAQ,EAAC,IAAI,EAAC,QAAQ,YACpE,IAAI,CAAC,CAAC,CAAC,CACN,cACE,SAAS,EACP,OAAO;gBACL,CAAC,CAAC,kBAAkB;gBACpB,CAAC,CAAC,2CAA2C,YAGhD,IAAI,GACD,CACP,CAAC,CAAC,CAAC,IAAI,GACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["import \"./WindowStatusBar.css\";\n\nexport function WindowStatusBar({\n text,\n visible = true,\n}: {\n text?: string;\n visible?: boolean;\n}) {\n /*\n * The live region stays mounted while the visible bar collapses. A `role=\"status\"`\n * region only announces when text changes on an element already in the DOM, so\n * mounting the region together with its first message loses the announcement.\n * The visible bar is skipped when empty because an empty one would hold\n * `--window-bar-height` of `--color-muted` directly above the equally-muted\n * taskbar, reading as a dead grey band rather than window chrome.\n *\n * Hiding the status bar hides only the visible band: the region stays mounted\n * and the message stays in it, visually hidden, so announcements such as the\n * keyboard move and resize instructions still reach assistive technology.\n */\n return (\n <div className=\"window-statusbar-live\" aria-live=\"polite\" role=\"status\">\n {text ? (\n <div\n className={\n visible\n ? \"window-statusbar\"\n : \"window-statusbar window-statusbar--hidden\"\n }\n >\n {text}\n </div>\n ) : null}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WindowTitleBar.js","sourceRoot":"","sources":["../../../home/a2f0/github/tearleads/packages/windowing/src/window/Window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AK,EAAE,EAAE;YACvB,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,iBAAiB,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,CAAC,aAED,eAAM,SAAS,EAAC,uBAAuB,EAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,YAC9D,KAAK,GACD,EACP,eAAK,SAAS,EAAC,yBAAyB,aACtC,KAAC,oBAAoB,IAAC,OAAO,EAAE,UAAU,GAAI,EAC7C,KAAC,oBAAoB,IAAC,OAAO,EAAE,UAAU,GAAI,EAC7C,KAAC,iBAAiB,IAAC,KAAK,EAAC,cAAc,EAAC,OAAO,EAAE,OAAO,GAAI,IACxD,EACL,WAAW,IAAI,CACd,MAAC,IAAI,IACH,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAC,MAAM,aAEhB,KAAC,QAAQ,IACP,IAAI,EAAE,WAAW,EACjB,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,aAAa,EACnB,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 { ArrowDownIcon } from \"@phosphor-icons/react/dist/csr/ArrowDown\";\nimport { ArrowUpIcon } from \"@phosphor-icons/react/dist/csr/ArrowUp\";\nimport { type ReactNode, useCallback } from \"react\";\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 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\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={ArrowUpIcon}\n label=\"Move Forward\"\n onClick={() => {\n onMoveForward();\n closeContextMenu();\n }}\n />\n <MenuItem\n icon={ArrowDownIcon}\n label=\"Move Backward\"\n onClick={() => {\n onMoveBackward();\n closeContextMenu();\n }}\n />\n </Menu>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowTitleBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowTitleBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAkB,WAAW,EAAE,MAAM,OAAO,CAAC;AACpD,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;AAW9D,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,EAAE,WAAW,EAAE,iBAAiB,EAAE,GACxD,2BAA2B,EAAE,CAAC;IAEhC,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,CAAqC,EAAE,EAAE;QACxC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC3B,mEAAmE;QACnE,oEAAoE;QACpE,IAAI,MAAM,YAAY,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO;QAClE,aAAa,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,EAC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nimport { ArrowUpIcon } from \"@phosphor-icons/react/dist/csr/ArrowUp\";\nimport { type ReactNode, useCallback } from \"react\";\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 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\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={ArrowUpIcon}\n label=\"Move Forward\"\n onClick={() => {\n onMoveForward();\n closeContextMenu();\n }}\n />\n <MenuItem\n icon={ArrowDownIcon}\n label=\"Move Backward\"\n onClick={() => {\n onMoveBackward();\n closeContextMenu();\n }}\n />\n </Menu>\n )}\n </div>\n );\n}\n"]}