@tearleads/windowing 0.1.1

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 (148) hide show
  1. package/README.md +155 -0
  2. package/createRequiredContext.d.ts +16 -0
  3. package/createRequiredContext.js +22 -0
  4. package/createRequiredContext.js.map +1 -0
  5. package/index.d.ts +13 -0
  6. package/index.js +17 -0
  7. package/index.js.map +1 -0
  8. package/menu/Menu.css +105 -0
  9. package/menu/Menu.d.ts +11 -0
  10. package/menu/Menu.js +175 -0
  11. package/menu/Menu.js.map +1 -0
  12. package/menu/MenuItem.d.ts +9 -0
  13. package/menu/MenuItem.js +5 -0
  14. package/menu/MenuItem.js.map +1 -0
  15. package/menu/useContextMenuState.d.ts +20 -0
  16. package/menu/useContextMenuState.js +45 -0
  17. package/menu/useContextMenuState.js.map +1 -0
  18. package/menu/useMenuKeyboard.d.ts +2 -0
  19. package/menu/useMenuKeyboard.js +90 -0
  20. package/menu/useMenuKeyboard.js.map +1 -0
  21. package/package.json +27 -0
  22. package/sidebar/SidebarResize.css +31 -0
  23. package/sidebar/SidebarResize.d.ts +18 -0
  24. package/sidebar/SidebarResize.js +115 -0
  25. package/sidebar/SidebarResize.js.map +1 -0
  26. package/tokens.css +63 -0
  27. package/window/CurrentWindowContext.d.ts +27 -0
  28. package/window/CurrentWindowContext.js +31 -0
  29. package/window/CurrentWindowContext.js.map +1 -0
  30. package/window/Window.css +32 -0
  31. package/window/Window.d.ts +11 -0
  32. package/window/Window.js +206 -0
  33. package/window/Window.js.map +1 -0
  34. package/window/WindowBody.css +21 -0
  35. package/window/WindowBody.d.ts +8 -0
  36. package/window/WindowBody.js +10 -0
  37. package/window/WindowBody.js.map +1 -0
  38. package/window/WindowChromeActions.d.ts +55 -0
  39. package/window/WindowChromeActions.js +61 -0
  40. package/window/WindowChromeActions.js.map +1 -0
  41. package/window/WindowCloseButton.d.ts +6 -0
  42. package/window/WindowCloseButton.js +9 -0
  43. package/window/WindowCloseButton.js.map +1 -0
  44. package/window/WindowMaximizeButton.d.ts +3 -0
  45. package/window/WindowMaximizeButton.js +5 -0
  46. package/window/WindowMaximizeButton.js.map +1 -0
  47. package/window/WindowMenuBar.css +63 -0
  48. package/window/WindowMenuBar.d.ts +14 -0
  49. package/window/WindowMenuBar.js +37 -0
  50. package/window/WindowMenuBar.js.map +1 -0
  51. package/window/WindowMenuContext.d.ts +46 -0
  52. package/window/WindowMenuContext.js +208 -0
  53. package/window/WindowMenuContext.js.map +1 -0
  54. package/window/WindowMinimizeButton.d.ts +3 -0
  55. package/window/WindowMinimizeButton.js +5 -0
  56. package/window/WindowMinimizeButton.js.map +1 -0
  57. package/window/WindowResizeHandle.css +65 -0
  58. package/window/WindowResizeHandle.d.ts +5 -0
  59. package/window/WindowResizeHandle.js +6 -0
  60. package/window/WindowResizeHandle.js.map +1 -0
  61. package/window/WindowSidebar.css +37 -0
  62. package/window/WindowSidebar.d.ts +6 -0
  63. package/window/WindowSidebar.js +9 -0
  64. package/window/WindowSidebar.js.map +1 -0
  65. package/window/WindowSidebarContext.d.ts +14 -0
  66. package/window/WindowSidebarContext.js +43 -0
  67. package/window/WindowSidebarContext.js.map +1 -0
  68. package/window/WindowStateProvider/WindowStateProvider.d.ts +2 -0
  69. package/window/WindowStateProvider/WindowStateProvider.js +16 -0
  70. package/window/WindowStateProvider/WindowStateProvider.js.map +1 -0
  71. package/window/WindowStateProvider/context.d.ts +4 -0
  72. package/window/WindowStateProvider/context.js +7 -0
  73. package/window/WindowStateProvider/context.js.map +1 -0
  74. package/window/WindowStateProvider/index.d.ts +5 -0
  75. package/window/WindowStateProvider/index.js +5 -0
  76. package/window/WindowStateProvider/index.js.map +1 -0
  77. package/window/WindowStateProvider/types.d.ts +58 -0
  78. package/window/WindowStateProvider/types.js +2 -0
  79. package/window/WindowStateProvider/types.js.map +1 -0
  80. package/window/WindowStateProvider/useWindowActions.d.ts +1 -0
  81. package/window/WindowStateProvider/useWindowActions.js +3 -0
  82. package/window/WindowStateProvider/useWindowActions.js.map +1 -0
  83. package/window/WindowStateProvider/useWindowStateActions.d.ts +24 -0
  84. package/window/WindowStateProvider/useWindowStateActions.js +176 -0
  85. package/window/WindowStateProvider/useWindowStateActions.js.map +1 -0
  86. package/window/WindowStateProvider/useWindowStateData.d.ts +1 -0
  87. package/window/WindowStateProvider/useWindowStateData.js +3 -0
  88. package/window/WindowStateProvider/useWindowStateData.js.map +1 -0
  89. package/window/WindowStateProvider/util/bringWindowToFront.d.ts +2 -0
  90. package/window/WindowStateProvider/util/bringWindowToFront.js +21 -0
  91. package/window/WindowStateProvider/util/bringWindowToFront.js.map +1 -0
  92. package/window/WindowStateProvider/util/createWindowEntry.d.ts +3 -0
  93. package/window/WindowStateProvider/util/createWindowEntry.js +20 -0
  94. package/window/WindowStateProvider/util/createWindowEntry.js.map +1 -0
  95. package/window/WindowStateProvider/util/findAdjacentWindow.d.ts +2 -0
  96. package/window/WindowStateProvider/util/findAdjacentWindow.js +22 -0
  97. package/window/WindowStateProvider/util/findAdjacentWindow.js.map +1 -0
  98. package/window/WindowStateProvider/util/findTopWindow.d.ts +3 -0
  99. package/window/WindowStateProvider/util/findTopWindow.js +7 -0
  100. package/window/WindowStateProvider/util/findTopWindow.js.map +1 -0
  101. package/window/WindowStateProvider/util/getMaxWindowZIndex.d.ts +2 -0
  102. package/window/WindowStateProvider/util/getMaxWindowZIndex.js +4 -0
  103. package/window/WindowStateProvider/util/getMaxWindowZIndex.js.map +1 -0
  104. package/window/WindowStateProvider/util/index.d.ts +6 -0
  105. package/window/WindowStateProvider/util/index.js +7 -0
  106. package/window/WindowStateProvider/util/index.js.map +1 -0
  107. package/window/WindowStateProvider/util/swapWindowZIndexes.d.ts +2 -0
  108. package/window/WindowStateProvider/util/swapWindowZIndexes.js +21 -0
  109. package/window/WindowStateProvider/util/swapWindowZIndexes.js.map +1 -0
  110. package/window/WindowStateProvider/util/updateWindowFlag.d.ts +2 -0
  111. package/window/WindowStateProvider/util/updateWindowFlag.js +4 -0
  112. package/window/WindowStateProvider/util/updateWindowFlag.js.map +1 -0
  113. package/window/WindowStatusBar.css +40 -0
  114. package/window/WindowStatusBar.d.ts +4 -0
  115. package/window/WindowStatusBar.js +20 -0
  116. package/window/WindowStatusBar.js.map +1 -0
  117. package/window/WindowTitleBar.css +88 -0
  118. package/window/WindowTitleBar.d.ts +18 -0
  119. package/window/WindowTitleBar.js +36 -0
  120. package/window/WindowTitleBar.js.map +1 -0
  121. package/window/WindowToolBar.css +75 -0
  122. package/window/WindowToolBar.d.ts +38 -0
  123. package/window/WindowToolBar.js +68 -0
  124. package/window/WindowToolBar.js.map +1 -0
  125. package/window/useWindowGeometry.d.ts +16 -0
  126. package/window/useWindowGeometry.js +243 -0
  127. package/window/useWindowGeometry.js.map +1 -0
  128. package/window/useWindowItemRegistration.d.ts +10 -0
  129. package/window/useWindowItemRegistration.js +46 -0
  130. package/window/useWindowItemRegistration.js.map +1 -0
  131. package/window/useWindowItemRegistry.d.ts +12 -0
  132. package/window/useWindowItemRegistry.js +45 -0
  133. package/window/useWindowItemRegistry.js.map +1 -0
  134. package/window/useWindowKeyboardGeometry.d.ts +21 -0
  135. package/window/useWindowKeyboardGeometry.js +139 -0
  136. package/window/useWindowKeyboardGeometry.js.map +1 -0
  137. package/window/useWindowLayout.d.ts +18 -0
  138. package/window/useWindowLayout.js +115 -0
  139. package/window/useWindowLayout.js.map +1 -0
  140. package/window/useWindowToolbarReservationRegistry.d.ts +8 -0
  141. package/window/useWindowToolbarReservationRegistry.js +19 -0
  142. package/window/useWindowToolbarReservationRegistry.js.map +1 -0
  143. package/window/windowGeometry.d.ts +36 -0
  144. package/window/windowGeometry.js +54 -0
  145. package/window/windowGeometry.js.map +1 -0
  146. package/window/windowMenuRegistrations.d.ts +18 -0
  147. package/window/windowMenuRegistrations.js +34 -0
  148. package/window/windowMenuRegistrations.js.map +1 -0
@@ -0,0 +1,46 @@
1
+ import { type PropsWithChildren } from "react";
2
+ import { type WindowBackAction, type WindowBackActionInput, type WindowTitleBarActionInput } from "./WindowChromeActions.js";
3
+ import type { WindowMenuItem } from "./WindowMenuBar.js";
4
+ import type { WindowTitleBarAction } from "./WindowTitleBar.js";
5
+ interface WindowRefreshMenuItemInput {
6
+ disabled?: boolean;
7
+ label?: string;
8
+ onRefresh: () => unknown;
9
+ priority?: number;
10
+ refreshing?: boolean;
11
+ }
12
+ interface WindowFileMenuItemInput {
13
+ disabled?: boolean;
14
+ id: string;
15
+ label: string;
16
+ onClick: () => unknown;
17
+ priority?: number;
18
+ }
19
+ export declare function WindowMenuProvider({ children }: PropsWithChildren): import("react").JSX.Element;
20
+ export declare function useWindowFileMenuItems(): WindowMenuItem[];
21
+ export declare function useWindowViewMenuItems(): WindowMenuItem[];
22
+ export declare function useWindowRefreshMenuItemValue(): WindowMenuItem | null;
23
+ export declare function useWindowTitleBarActions(): WindowTitleBarAction[];
24
+ export declare function useWindowBackActionValue(): WindowBackAction | null;
25
+ export declare function useWindowToolbarReserved(): boolean;
26
+ export declare function useWindowToolbarReservationReleased(): boolean;
27
+ export declare function useWindowFileMenuItem(item: WindowFileMenuItemInput | null): void;
28
+ export declare function useWindowViewMenuItem(item: WindowFileMenuItemInput | null): void;
29
+ /**
30
+ * Registers an action in the current window's title bar.
31
+ *
32
+ * Keep `item` and its `icon` reference-stable, such as by memoizing them with
33
+ * `useMemo`, so the window does not re-register the action on every render.
34
+ */
35
+ export declare function useWindowTitleBarAction(item: WindowTitleBarActionInput | null): void;
36
+ export declare function useWindowBackAction(item: WindowBackActionInput | null): void;
37
+ /**
38
+ * Keeps this window's toolbar row reserved (rendered) while the caller is
39
+ * mounted, even when it registers no title-bar or back actions. A mini-app that
40
+ * wants explorer-style chrome on every route — a blank bar on the routes that
41
+ * have no actions rather than a collapsing/reappearing row — calls this once.
42
+ * Pass `reserve = false` to release the reservation without unmounting.
43
+ */
44
+ export declare function useWindowToolbarReservation(reserve?: boolean): void;
45
+ export declare function useWindowRefreshMenuItem(item: WindowRefreshMenuItemInput | null): void;
46
+ export {};
@@ -0,0 +1,208 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useEffect, useMemo, useRef, } from "react";
3
+ import { useWindowItemRegistration } from "./useWindowItemRegistration.js";
4
+ import { sameWindowItem, selectHighestPriorityItem, useWindowItemRegistry, } from "./useWindowItemRegistry.js";
5
+ import { useWindowToolbarReservationRegistry } from "./useWindowToolbarReservationRegistry.js";
6
+ import { createBackAction, createRegisteredBackAction, createRegisteredTitleBarAction, createTitleBarActions, } from "./WindowChromeActions.js";
7
+ import { createMenuItems, createRefreshMenuItem, REFRESH_LABEL, } from "./windowMenuRegistrations.js";
8
+ function createRegisteredMenuItem(item, onClick) {
9
+ return {
10
+ disabled: item.disabled ?? false,
11
+ id: item.id,
12
+ label: item.label,
13
+ onClick,
14
+ priority: item.priority ?? 0,
15
+ };
16
+ }
17
+ function createRegisteredRefreshMenuItem(item, onRefresh) {
18
+ return {
19
+ disabled: item.disabled ?? false,
20
+ label: item.label ?? REFRESH_LABEL,
21
+ onRefresh,
22
+ priority: item.priority ?? 0,
23
+ refreshing: item.refreshing ?? false,
24
+ };
25
+ }
26
+ const WindowMenuContext = createContext({
27
+ fileMenuItems: [],
28
+ viewMenuItems: [],
29
+ refreshMenuItem: null,
30
+ titleBarActions: [],
31
+ backAction: null,
32
+ toolbarReserved: false,
33
+ toolbarReservationReleased: false,
34
+ registerFileMenuItem: () => { },
35
+ unregisterFileMenuItem: () => { },
36
+ registerViewMenuItem: () => { },
37
+ unregisterViewMenuItem: () => { },
38
+ registerTitleBarAction: () => { },
39
+ unregisterTitleBarAction: () => { },
40
+ registerBackAction: () => { },
41
+ unregisterBackAction: () => { },
42
+ registerRefreshMenuItem: () => { },
43
+ unregisterRefreshMenuItem: () => { },
44
+ registerToolbarReservation: () => { },
45
+ unregisterToolbarReservation: () => { },
46
+ });
47
+ function useWindowMenuContextValue() {
48
+ const fileMenu = useWindowItemRegistry(sameWindowItem);
49
+ const viewMenu = useWindowItemRegistry(sameWindowItem);
50
+ const titleBar = useWindowItemRegistry(sameWindowItem);
51
+ const back = useWindowItemRegistry(sameWindowItem);
52
+ const refresh = useWindowItemRegistry(sameWindowItem);
53
+ const toolbarReservation = useWindowToolbarReservationRegistry();
54
+ const fileMenuItemList = useMemo(() => createMenuItems(fileMenu.items), [fileMenu.items]);
55
+ const refreshMenuItem = useMemo(() => createRefreshMenuItem(selectHighestPriorityItem(refresh.items)), [refresh.items]);
56
+ const viewMenuItemList = useMemo(() => [
57
+ ...createMenuItems(viewMenu.items),
58
+ ...(refreshMenuItem ? [refreshMenuItem] : []),
59
+ ], [refreshMenuItem, viewMenu.items]);
60
+ const titleBarActionList = useMemo(() => createTitleBarActions(titleBar.items), [titleBar.items]);
61
+ const backAction = useMemo(() => createBackAction(selectHighestPriorityItem(back.items)), [back.items]);
62
+ const value = useMemo(() => ({
63
+ fileMenuItems: fileMenuItemList,
64
+ viewMenuItems: viewMenuItemList,
65
+ refreshMenuItem,
66
+ titleBarActions: titleBarActionList,
67
+ backAction,
68
+ toolbarReserved: toolbarReservation.reserved,
69
+ toolbarReservationReleased: toolbarReservation.released,
70
+ registerFileMenuItem: fileMenu.registerItem,
71
+ unregisterFileMenuItem: fileMenu.unregisterItem,
72
+ registerViewMenuItem: viewMenu.registerItem,
73
+ unregisterViewMenuItem: viewMenu.unregisterItem,
74
+ registerTitleBarAction: titleBar.registerItem,
75
+ unregisterTitleBarAction: titleBar.unregisterItem,
76
+ registerBackAction: back.registerItem,
77
+ unregisterBackAction: back.unregisterItem,
78
+ registerRefreshMenuItem: refresh.registerItem,
79
+ unregisterRefreshMenuItem: refresh.unregisterItem,
80
+ registerToolbarReservation: toolbarReservation.register,
81
+ unregisterToolbarReservation: toolbarReservation.unregister,
82
+ }), [
83
+ fileMenuItemList,
84
+ viewMenuItemList,
85
+ refreshMenuItem,
86
+ titleBarActionList,
87
+ backAction,
88
+ toolbarReservation,
89
+ fileMenu.registerItem,
90
+ fileMenu.unregisterItem,
91
+ viewMenu.registerItem,
92
+ viewMenu.unregisterItem,
93
+ titleBar.registerItem,
94
+ titleBar.unregisterItem,
95
+ back.registerItem,
96
+ back.unregisterItem,
97
+ refresh.registerItem,
98
+ refresh.unregisterItem,
99
+ ]);
100
+ return value;
101
+ }
102
+ export function WindowMenuProvider({ children }) {
103
+ const value = useWindowMenuContextValue();
104
+ return (_jsx(WindowMenuContext.Provider, { value: value, children: children }));
105
+ }
106
+ export function useWindowFileMenuItems() {
107
+ return useContext(WindowMenuContext).fileMenuItems;
108
+ }
109
+ export function useWindowViewMenuItems() {
110
+ return useContext(WindowMenuContext).viewMenuItems;
111
+ }
112
+ export function useWindowRefreshMenuItemValue() {
113
+ return useContext(WindowMenuContext).refreshMenuItem;
114
+ }
115
+ export function useWindowTitleBarActions() {
116
+ return useContext(WindowMenuContext).titleBarActions;
117
+ }
118
+ export function useWindowBackActionValue() {
119
+ return useContext(WindowMenuContext).backAction;
120
+ }
121
+ export function useWindowToolbarReserved() {
122
+ return useContext(WindowMenuContext).toolbarReserved;
123
+ }
124
+ export function useWindowToolbarReservationReleased() {
125
+ return useContext(WindowMenuContext).toolbarReservationReleased;
126
+ }
127
+ function useRegisteredWindowMenuItem(item, registerMenuItem, unregisterMenuItem) {
128
+ useWindowItemRegistration({
129
+ action: item?.onClick ?? null,
130
+ createRegisteredItem: createRegisteredMenuItem,
131
+ input: item,
132
+ registerItem: registerMenuItem,
133
+ unregisterItem: unregisterMenuItem,
134
+ });
135
+ }
136
+ export function useWindowFileMenuItem(item) {
137
+ const { registerFileMenuItem, unregisterFileMenuItem } = useContext(WindowMenuContext);
138
+ useRegisteredWindowMenuItem(item, registerFileMenuItem, unregisterFileMenuItem);
139
+ }
140
+ export function useWindowViewMenuItem(item) {
141
+ const { registerViewMenuItem, unregisterViewMenuItem } = useContext(WindowMenuContext);
142
+ useRegisteredWindowMenuItem(item, registerViewMenuItem, unregisterViewMenuItem);
143
+ }
144
+ /**
145
+ * Registers an action in the current window's title bar.
146
+ *
147
+ * Keep `item` and its `icon` reference-stable, such as by memoizing them with
148
+ * `useMemo`, so the window does not re-register the action on every render.
149
+ */
150
+ export function useWindowTitleBarAction(item) {
151
+ const { registerTitleBarAction, unregisterTitleBarAction } = useContext(WindowMenuContext);
152
+ useWindowItemRegistration({
153
+ action: item?.onClick ?? null,
154
+ createRegisteredItem: createRegisteredTitleBarAction,
155
+ input: item,
156
+ registerItem: registerTitleBarAction,
157
+ unregisterItem: unregisterTitleBarAction,
158
+ });
159
+ }
160
+ export function useWindowBackAction(item) {
161
+ const { registerBackAction, unregisterBackAction } = useContext(WindowMenuContext);
162
+ useWindowItemRegistration({
163
+ action: item?.onClick ?? null,
164
+ createRegisteredItem: createRegisteredBackAction,
165
+ input: item,
166
+ registerItem: registerBackAction,
167
+ unregisterItem: unregisterBackAction,
168
+ });
169
+ }
170
+ /**
171
+ * Keeps this window's toolbar row reserved (rendered) while the caller is
172
+ * mounted, even when it registers no title-bar or back actions. A mini-app that
173
+ * wants explorer-style chrome on every route — a blank bar on the routes that
174
+ * have no actions rather than a collapsing/reappearing row — calls this once.
175
+ * Pass `reserve = false` to release the reservation without unmounting.
176
+ */
177
+ export function useWindowToolbarReservation(reserve = true) {
178
+ const { registerToolbarReservation, unregisterToolbarReservation } = useContext(WindowMenuContext);
179
+ const idRef = useRef({});
180
+ const hasEverReservedRef = useRef(false);
181
+ useEffect(() => {
182
+ const id = idRef.current;
183
+ if (reserve) {
184
+ hasEverReservedRef.current = true;
185
+ registerToolbarReservation(id, true);
186
+ return () => unregisterToolbarReservation(id);
187
+ }
188
+ if (!hasEverReservedRef.current) {
189
+ return;
190
+ }
191
+ // A caller that previously reserved the row is now explicitly releasing it.
192
+ // This lets WindowToolBar clear its latched blank row while callers that
193
+ // never opted into reservations keep the older latch-once behavior.
194
+ registerToolbarReservation(id, false);
195
+ return () => unregisterToolbarReservation(id);
196
+ }, [reserve, registerToolbarReservation, unregisterToolbarReservation]);
197
+ }
198
+ export function useWindowRefreshMenuItem(item) {
199
+ const { registerRefreshMenuItem, unregisterRefreshMenuItem } = useContext(WindowMenuContext);
200
+ useWindowItemRegistration({
201
+ action: item?.onRefresh ?? null,
202
+ createRegisteredItem: createRegisteredRefreshMenuItem,
203
+ input: item,
204
+ registerItem: registerRefreshMenuItem,
205
+ unregisterItem: unregisterRefreshMenuItem,
206
+ });
207
+ }
208
+ //# sourceMappingURL=WindowMenuContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowMenuContext.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/WindowMenuContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,GAMtB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,GAGd,MAAM,2BAA2B,CAAC;AAkBnC,SAAS,wBAAwB,CAC/B,IAA6B,EAC7B,OAAsB;IAEtB,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO;QACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B,CACtC,IAAgC,EAChC,SAAwB;IAExB,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,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;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"]}
@@ -0,0 +1,3 @@
1
+ export declare function WindowMinimizeButton({ onClick }: {
2
+ onClick: () => void;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function WindowMinimizeButton({ onClick }) {
3
+ return (_jsx("button", { type: "button", className: "window-minimize", "aria-label": "Minimize window", title: "Minimize window", onClick: onClick, children: "\u2013" }));
4
+ }
5
+ //# sourceMappingURL=WindowMinimizeButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowMinimizeButton.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/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"]}
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Corner resize affordance. Each handle is an invisible hit target pinned to a
3
+ * window corner; on hover it paints an L-shaped bracket that hugs that corner —
4
+ * only the two outward-facing edges — so the corner itself lights up (not just
5
+ * the cursor), signalling it can be dragged.
6
+ * The bracket is drawn in --color-dark, the theme's foreground primitive, so it
7
+ * reads as the window's own edge lit up and stays crisp in both themes (a
8
+ * charcoal bracket on the light surface, a near-white one on the dark surface).
9
+ * Each bracket follows the rounded window corner while its hit target stays
10
+ * square, keeping the outermost corner easy to grab.
11
+ */
12
+ .window-resize {
13
+ position: absolute;
14
+ width: 14px;
15
+ height: 14px;
16
+ touch-action: none;
17
+ border: 0 solid transparent;
18
+ transition: border-color var(--transition);
19
+ }
20
+
21
+ /* Gate the highlight behind a true-hover pointer. On coarse (touch) pointers a
22
+ tap triggers :hover and it stays stuck until the next tap elsewhere; scoping
23
+ the rule to fine pointers means it simply never applies there. Corner-drag
24
+ resize is a pointer affordance anyway, so touch loses nothing. */
25
+ @media (hover: hover) {
26
+ .window-resize:hover {
27
+ border-color: var(--color-dark);
28
+ }
29
+ }
30
+
31
+ .window-resize--se {
32
+ border-bottom-right-radius: var(--app-radius-surface);
33
+ right: 0;
34
+ bottom: 0;
35
+ cursor: se-resize;
36
+ border-right-width: 2px;
37
+ border-bottom-width: 2px;
38
+ }
39
+
40
+ .window-resize--sw {
41
+ border-bottom-left-radius: var(--app-radius-surface);
42
+ bottom: 0;
43
+ left: 0;
44
+ cursor: sw-resize;
45
+ border-bottom-width: 2px;
46
+ border-left-width: 2px;
47
+ }
48
+
49
+ .window-resize--ne {
50
+ border-top-right-radius: var(--app-radius-surface);
51
+ top: 0;
52
+ right: 0;
53
+ cursor: ne-resize;
54
+ border-top-width: 2px;
55
+ border-right-width: 2px;
56
+ }
57
+
58
+ .window-resize--nw {
59
+ border-top-left-radius: var(--app-radius-surface);
60
+ top: 0;
61
+ left: 0;
62
+ cursor: nw-resize;
63
+ border-top-width: 2px;
64
+ border-left-width: 2px;
65
+ }
@@ -0,0 +1,5 @@
1
+ export type ResizeCorner = "se" | "sw" | "ne" | "nw";
2
+ export declare function WindowResizeHandle({ corner, onPointerDown, }: {
3
+ corner: ResizeCorner;
4
+ onPointerDown: (e: React.PointerEvent, corner: ResizeCorner) => void;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "./WindowResizeHandle.css";
3
+ export function WindowResizeHandle({ corner, onPointerDown, }) {
4
+ return (_jsx("div", { role: "none", className: `window-resize window-resize--${corner}`, onPointerDown: (e) => onPointerDown(e, corner) }));
5
+ }
6
+ //# sourceMappingURL=WindowResizeHandle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowResizeHandle.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/WindowResizeHandle.tsx"],"names":[],"mappings":";AAAA,OAAO,0BAA0B,CAAC;AAIlC,MAAM,UAAU,kBAAkB,CAAC,EACjC,MAAM,EACN,aAAa,GAId;IACC,OAAO,CACL,cACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,gCAAgC,MAAM,EAAE,EACnD,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,GAC9C,CACH,CAAC;AACJ,CAAC","sourcesContent":["import \"./WindowResizeHandle.css\";\n\nexport type ResizeCorner = \"se\" | \"sw\" | \"ne\" | \"nw\";\n\nexport function WindowResizeHandle({\n corner,\n onPointerDown,\n}: {\n corner: ResizeCorner;\n onPointerDown: (e: React.PointerEvent, corner: ResizeCorner) => void;\n}) {\n return (\n <div\n role=\"none\"\n className={`window-resize window-resize--${corner}`}\n onPointerDown={(e) => onPointerDown(e, corner)}\n />\n );\n}\n"]}
@@ -0,0 +1,37 @@
1
+ .window-sidebar-layout {
2
+ display: flex;
3
+ flex: 1;
4
+ min-height: 0;
5
+ height: 100%;
6
+ overflow: hidden;
7
+ }
8
+
9
+ .window-sidebar {
10
+ overflow: auto;
11
+ scrollbar-gutter: var(--scrollbar-gutter);
12
+ flex-shrink: 0;
13
+ min-width: 5rem;
14
+ }
15
+
16
+ .window-sidebar-handle {
17
+ width: 6px;
18
+ margin: 0 -2px;
19
+ }
20
+
21
+ .window-sidebar-handle::before {
22
+ left: 2px;
23
+ }
24
+
25
+ .window-sidebar-content {
26
+ position: relative;
27
+ flex: 1;
28
+ min-width: 0;
29
+ min-height: 0;
30
+ overflow: hidden;
31
+ }
32
+
33
+ .window-sidebar-content-scroll {
34
+ height: 100%;
35
+ overflow: auto;
36
+ scrollbar-gutter: var(--scrollbar-gutter);
37
+ }
@@ -0,0 +1,6 @@
1
+ import type { PropsWithChildren, Ref } from "react";
2
+ export declare function WindowSidebar({ contentRef, defaultWidth, sidebar, children, }: PropsWithChildren<{
3
+ contentRef?: Ref<HTMLDivElement> | undefined;
4
+ defaultWidth?: number;
5
+ sidebar?: React.ReactNode;
6
+ }>): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SidebarResizeHandle, useSidebarResize, } from "../sidebar/SidebarResize.js";
3
+ import "./WindowSidebar.css";
4
+ const DEFAULT_WIDTH = 160;
5
+ export function WindowSidebar({ contentRef, defaultWidth = DEFAULT_WIDTH, sidebar, children, }) {
6
+ const resize = useSidebarResize({ defaultWidth });
7
+ return (_jsxs("div", { className: "window-sidebar-layout", children: [_jsx("div", { className: "window-sidebar", ref: resize.sidebarRef, style: { width: resize.width ?? defaultWidth }, children: sidebar }), _jsx(SidebarResizeHandle, { className: "window-sidebar-handle", currentWidth: resize.resolvedWidth, onKeyDown: resize.handleKeyDown, onPointerDown: resize.handlePointerDown }), _jsx("div", { className: "window-sidebar-content", ref: contentRef, tabIndex: -1, children: _jsx("div", { className: "window-sidebar-content-scroll", children: children }) })] }));
8
+ }
9
+ //# sourceMappingURL=WindowSidebar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowSidebar.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/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"]}
@@ -0,0 +1,14 @@
1
+ import { type PropsWithChildren, type ReactNode } from "react";
2
+ interface WindowSidebarContextValue {
3
+ sidebar: ReactNode;
4
+ setSidebar: (node: ReactNode) => void;
5
+ }
6
+ export declare function WindowSidebarProvider({ children }: PropsWithChildren): import("react").JSX.Element;
7
+ export declare function hasWindowSidebar(sidebar: ReactNode): boolean;
8
+ export declare function useWindowSidebar(): WindowSidebarContextValue;
9
+ export declare function useRegisteredWindowSidebar({ enabled, setSidebar, sidebar, }: {
10
+ enabled?: boolean;
11
+ setSidebar: (node: ReactNode) => void;
12
+ sidebar: ReactNode;
13
+ }): void;
14
+ export {};
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useEffect, useMemo, useRef, useState, } from "react";
3
+ const WindowSidebarContext = createContext({
4
+ sidebar: null,
5
+ setSidebar: () => { },
6
+ });
7
+ export function WindowSidebarProvider({ children }) {
8
+ const [sidebar, setSidebar] = useState(null);
9
+ const value = useMemo(() => ({ sidebar, setSidebar }), [sidebar]);
10
+ return (_jsx(WindowSidebarContext.Provider, { value: value, children: children }));
11
+ }
12
+ // `sidebar` is a ReactNode, so `false`/`null`/`undefined` all mean "no
13
+ // sidebar" while renderable falsy values like `0` or `""` do not.
14
+ export function hasWindowSidebar(sidebar) {
15
+ return sidebar !== null && sidebar !== undefined && sidebar !== false;
16
+ }
17
+ export function useWindowSidebar() {
18
+ return useContext(WindowSidebarContext);
19
+ }
20
+ export function useRegisteredWindowSidebar({ enabled = true, setSidebar, sidebar, }) {
21
+ // The ref keeps the clearing cleanup pinned to [enabled] even when a caller
22
+ // passes a setter that is not referentially stable: with setSidebar in the
23
+ // cleanup's deps, every such render would clear-then-reregister the sidebar
24
+ // and re-render the window shell in a loop.
25
+ const setSidebarRef = useRef(setSidebar);
26
+ setSidebarRef.current = setSidebar;
27
+ useEffect(() => {
28
+ if (!enabled) {
29
+ return;
30
+ }
31
+ setSidebar(sidebar);
32
+ }, [enabled, setSidebar, sidebar]);
33
+ // Clearing stays in its own effect so a sidebar-node change swaps the node
34
+ // without a transient null; the cleanup runs only on unmount or when
35
+ // `enabled` flips off.
36
+ useEffect(() => {
37
+ if (!enabled) {
38
+ return;
39
+ }
40
+ return () => setSidebarRef.current(null);
41
+ }, [enabled]);
42
+ }
43
+ //# sourceMappingURL=WindowSidebarContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowSidebarContext.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/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,G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;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"]}
@@ -0,0 +1,2 @@
1
+ import { type PropsWithChildren } from "react";
2
+ export declare function WindowStateProvider({ children }: PropsWithChildren): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useState } from "react";
3
+ import { windowActionsContext, windowStateContext } from "./context.js";
4
+ import { useWindowStateActions } from "./useWindowStateActions.js";
5
+ export function WindowStateProvider({ children }) {
6
+ const [windows, setWindows] = useState([]);
7
+ const counter = useRef(0);
8
+ const actions = useWindowStateActions({ counter, setWindows });
9
+ const windowMap = useMemo(() => new Map(windows.map((windowEntry) => [windowEntry.id, windowEntry])), [windows]);
10
+ const state = useMemo(() => ({
11
+ windows,
12
+ windowMap,
13
+ }), [windows, windowMap]);
14
+ return (_jsx(windowActionsContext.context.Provider, { value: actions, children: _jsx(windowStateContext.context.Provider, { value: state, children: children }) }));
15
+ }
16
+ //# sourceMappingURL=WindowStateProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowStateProvider.js","sourceRoot":"","sources":["../../../../../../../../Users/a2f0/github/tearleads5/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"]}
@@ -0,0 +1,4 @@
1
+ import { type RequiredContext } from "../../createRequiredContext.js";
2
+ import type { WindowStateActions, WindowStateData } from "./types.js";
3
+ export declare const windowStateContext: RequiredContext<WindowStateData>;
4
+ export declare const windowActionsContext: RequiredContext<WindowStateActions>;
@@ -0,0 +1,7 @@
1
+ import { createRequiredContext, } from "../../createRequiredContext.js";
2
+ // Keep state and actions in separate contexts so consumers that only need
3
+ // stable actions like create/restore do not re-render on every window-state
4
+ // change.
5
+ export const windowStateContext = createRequiredContext("useWindowStateData requires WindowStateProvider");
6
+ export const windowActionsContext = createRequiredContext("useWindowActions requires WindowStateProvider");
7
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../../../Users/a2f0/github/tearleads5/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"]}
@@ -0,0 +1,5 @@
1
+ export type { WindowCreateOptions, WindowEntry, WindowGeometry, WindowPosition, WindowSize, WindowStateActions, WindowStateData, } from "./types.js";
2
+ export { useWindowActions } from "./useWindowActions.js";
3
+ export { useWindowStateData } from "./useWindowStateData.js";
4
+ export { findTopWindow } from "./util/index.js";
5
+ export { WindowStateProvider } from "./WindowStateProvider.js";
@@ -0,0 +1,5 @@
1
+ export { useWindowActions } from "./useWindowActions.js";
2
+ export { useWindowStateData } from "./useWindowStateData.js";
3
+ export { findTopWindow } from "./util/index.js";
4
+ export { WindowStateProvider } from "./WindowStateProvider.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../Users/a2f0/github/tearleads5/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"]}