@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,54 @@
1
+ // Window geometry math shared by the pointer, keyboard, and layout hooks. All
2
+ // positions and sizes are relative to the desktop surface.
3
+ export const MIN_WIDTH = 200;
4
+ export const MIN_HEIGHT = 100;
5
+ // Clamps against the size the window is about to render at when it is known,
6
+ // so a position committed with a new size is not measured at the old one.
7
+ export function clampWindowPosition(element, x, y, size) {
8
+ const container = element?.parentElement;
9
+ if (!element || !container) {
10
+ return { x, y };
11
+ }
12
+ // A requested size renders no smaller than the stylesheet's minimums.
13
+ const width = size ? Math.max(MIN_WIDTH, size.width) : element.offsetWidth;
14
+ const height = size
15
+ ? Math.max(MIN_HEIGHT, size.height)
16
+ : element.offsetHeight;
17
+ return {
18
+ x: Math.max(0, Math.min(x, container.clientWidth - width)),
19
+ y: Math.max(0, Math.min(y, container.clientHeight - height)),
20
+ };
21
+ }
22
+ export function resizeWindowWithinContainer(resizeState, clientX, clientY, container) {
23
+ const deltaX = clientX - resizeState.startX;
24
+ const deltaY = clientY - resizeState.startY;
25
+ const movesLeft = resizeState.corner.includes("w");
26
+ const movesUp = resizeState.corner.includes("n");
27
+ let width = Math.max(MIN_WIDTH, resizeState.startWidth + deltaX * (movesLeft ? -1 : 1));
28
+ let height = Math.max(MIN_HEIGHT, resizeState.startHeight + deltaY * (movesUp ? -1 : 1));
29
+ let x = movesLeft
30
+ ? resizeState.startLeft + resizeState.startWidth - width
31
+ : resizeState.startLeft;
32
+ let y = movesUp
33
+ ? resizeState.startTop + resizeState.startHeight - height
34
+ : resizeState.startTop;
35
+ if (container) {
36
+ if (x < 0) {
37
+ width += x;
38
+ x = 0;
39
+ }
40
+ if (y < 0) {
41
+ height += y;
42
+ y = 0;
43
+ }
44
+ width = Math.min(width, container.clientWidth - x - resizeState.borderX);
45
+ height = Math.min(height, container.clientHeight - y - resizeState.borderY);
46
+ width = Math.max(MIN_WIDTH, width);
47
+ height = Math.max(MIN_HEIGHT, height);
48
+ }
49
+ return {
50
+ position: { x, y },
51
+ size: { width, height },
52
+ };
53
+ }
54
+ //# sourceMappingURL=windowGeometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"windowGeometry.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/windowGeometry.ts"],"names":[],"mappings":"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","sourcesContent":["import type { ResizeCorner } from \"./WindowResizeHandle\";\nimport type { WindowPosition, WindowSize } from \"./WindowStateProvider\";\n\n// Window geometry math shared by the pointer, keyboard, and layout hooks. All\n// positions and sizes are relative to the desktop surface.\n\nexport const MIN_WIDTH = 200;\nexport const MIN_HEIGHT = 100;\n\nexport interface WindowDragState {\n offsetX: number;\n offsetY: number;\n pointerId: number;\n}\n\nexport interface WindowResizeState {\n corner: ResizeCorner;\n pointerId: number;\n startHeight: number;\n startLeft: number;\n startTop: number;\n startWidth: number;\n startX: number;\n startY: number;\n borderX: number;\n borderY: number;\n}\n\nexport interface LiveGeometry {\n position: WindowPosition | null;\n size: WindowSize | null;\n}\n\n// Clamps against the size the window is about to render at when it is known,\n// so a position committed with a new size is not measured at the old one.\nexport function clampWindowPosition(\n element: HTMLElement | null,\n x: number,\n y: number,\n size: WindowSize | null,\n): WindowPosition {\n const container = element?.parentElement;\n if (!element || !container) {\n return { x, y };\n }\n // A requested size renders no smaller than the stylesheet's minimums.\n const width = size ? Math.max(MIN_WIDTH, size.width) : element.offsetWidth;\n const height = size\n ? Math.max(MIN_HEIGHT, size.height)\n : element.offsetHeight;\n\n return {\n x: Math.max(0, Math.min(x, container.clientWidth - width)),\n y: Math.max(0, Math.min(y, container.clientHeight - height)),\n };\n}\n\nexport function resizeWindowWithinContainer(\n resizeState: WindowResizeState,\n clientX: number,\n clientY: number,\n container: HTMLElement | null,\n) {\n const deltaX = clientX - resizeState.startX;\n const deltaY = clientY - resizeState.startY;\n const movesLeft = resizeState.corner.includes(\"w\");\n const movesUp = resizeState.corner.includes(\"n\");\n let width = Math.max(\n MIN_WIDTH,\n resizeState.startWidth + deltaX * (movesLeft ? -1 : 1),\n );\n let height = Math.max(\n MIN_HEIGHT,\n resizeState.startHeight + deltaY * (movesUp ? -1 : 1),\n );\n let x = movesLeft\n ? resizeState.startLeft + resizeState.startWidth - width\n : resizeState.startLeft;\n let y = movesUp\n ? resizeState.startTop + resizeState.startHeight - height\n : resizeState.startTop;\n\n if (container) {\n if (x < 0) {\n width += x;\n x = 0;\n }\n if (y < 0) {\n height += y;\n y = 0;\n }\n width = Math.min(width, container.clientWidth - x - resizeState.borderX);\n height = Math.min(height, container.clientHeight - y - resizeState.borderY);\n width = Math.max(MIN_WIDTH, width);\n height = Math.max(MIN_HEIGHT, height);\n }\n\n return {\n position: { x, y },\n size: { width, height },\n };\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { WindowMenuItem } from "./WindowMenuBar.js";
2
+ export declare const REFRESH_LABEL = "Refresh";
3
+ export interface RegisteredWindowMenuItem {
4
+ disabled: boolean;
5
+ id: string;
6
+ label: string;
7
+ onClick: () => unknown;
8
+ priority: number;
9
+ }
10
+ export interface RegisteredWindowRefreshMenuItem {
11
+ disabled: boolean;
12
+ label: string;
13
+ onRefresh: () => unknown;
14
+ priority: number;
15
+ refreshing: boolean;
16
+ }
17
+ export declare function createMenuItems(items: ReadonlyMap<object, RegisteredWindowMenuItem>): WindowMenuItem[];
18
+ export declare function createRefreshMenuItem(item: RegisteredWindowRefreshMenuItem | null): WindowMenuItem | null;
@@ -0,0 +1,34 @@
1
+ /*
2
+ * The shapes a mini-app's menu registration takes, and the pure projections
3
+ * from a registry map to the items a menu bar (or the routed app bar) renders.
4
+ * The React seams — the context, the provider, and the register/read hooks —
5
+ * live in WindowMenuContext.tsx.
6
+ */
7
+ export const REFRESH_LABEL = "Refresh";
8
+ const REFRESHING_LABEL = "Refreshing...";
9
+ export function createMenuItems(items) {
10
+ return Array.from(items.values())
11
+ .sort((left, right) => right.priority - left.priority)
12
+ .map((item) => ({
13
+ disabled: item.disabled,
14
+ id: item.id,
15
+ label: item.label,
16
+ onClick: () => {
17
+ void item.onClick();
18
+ },
19
+ }));
20
+ }
21
+ export function createRefreshMenuItem(item) {
22
+ if (!item) {
23
+ return null;
24
+ }
25
+ return {
26
+ disabled: item.disabled || item.refreshing,
27
+ id: "window-refresh",
28
+ label: item.refreshing ? REFRESHING_LABEL : item.label,
29
+ onClick: () => {
30
+ void item.onRefresh();
31
+ },
32
+ };
33
+ }
34
+ //# sourceMappingURL=windowMenuRegistrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"windowMenuRegistrations.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/windowMenuRegistrations.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAkBzC,MAAM,UAAU,eAAe,CAC7B,KAAoD;IAEpD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;SAC9B,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;SACrD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;KACF,CAAC,CAAC,CAAC;AACR,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAA4C;IAE5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU;QAC1C,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;QACtD,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowMenuItem } from \"./WindowMenuBar\";\n\n/*\n * The shapes a mini-app's menu registration takes, and the pure projections\n * from a registry map to the items a menu bar (or the routed app bar) renders.\n * The React seams — the context, the provider, and the register/read hooks —\n * live in WindowMenuContext.tsx.\n */\n\nexport const REFRESH_LABEL = \"Refresh\";\nconst REFRESHING_LABEL = \"Refreshing...\";\n\nexport interface RegisteredWindowMenuItem {\n disabled: boolean;\n id: string;\n label: string;\n onClick: () => unknown;\n priority: number;\n}\n\nexport interface RegisteredWindowRefreshMenuItem {\n disabled: boolean;\n label: string;\n onRefresh: () => unknown;\n priority: number;\n refreshing: boolean;\n}\n\nexport function createMenuItems(\n items: ReadonlyMap<object, RegisteredWindowMenuItem>,\n): WindowMenuItem[] {\n return Array.from(items.values())\n .sort((left, right) => right.priority - left.priority)\n .map((item) => ({\n disabled: item.disabled,\n id: item.id,\n label: item.label,\n onClick: () => {\n void item.onClick();\n },\n }));\n}\n\nexport function createRefreshMenuItem(\n item: RegisteredWindowRefreshMenuItem | null,\n): WindowMenuItem | null {\n if (!item) {\n return null;\n }\n\n return {\n disabled: item.disabled || item.refreshing,\n id: \"window-refresh\",\n label: item.refreshing ? REFRESHING_LABEL : item.label,\n onClick: () => {\n void item.onRefresh();\n },\n };\n}\n"]}