@tearleads/windowing 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  App-agnostic window management for React: window state (open, focus order,
4
4
  minimize/maximize, a per-window route and Back stack), window chrome (title
5
- bar, menu bar, toolbar, sidebar, status bar, resize handles), and the menu and
6
- sidebar primitives that chrome renders with.
5
+ bar, menu bar, toolbar, sidebar, status bar, resize handles), the menu and
6
+ sidebar primitives that chrome renders with, and a taskbar's start menu.
7
7
 
8
8
  The package knows nothing about the applications that run inside its windows.
9
- It depends only on React, react-dom, and Phosphor icons.
9
+ It depends only on React, react-dom, and Phosphor icons, which draw the
10
+ chrome's own icons unless a host passes its own (see [Icons](#icons)).
10
11
 
11
12
  ## Composing a desktop
12
13
 
@@ -123,6 +124,67 @@ row is reserved from the start. An app that never routes passes
123
124
  first registers toolbar actions. From then on the row stays, as in any window,
124
125
  so the body does not shift when actions come and go.
125
126
 
127
+ ## Icons
128
+
129
+ Icons are components, from any icon set. `MenuItem`, `StartMenu` items, and the
130
+ chrome take a `WindowingIcon`: a component that accepts `WindowingIconProps`
131
+ (`aria-hidden`, `className`, `focusable`, and `size`), as Phosphor and Lucide
132
+ icons do. A menu item renders its icon at 16 pixels:
133
+
134
+ ```tsx
135
+ import { NotePencilIcon } from "@phosphor-icons/react";
136
+
137
+ <MenuItem icon={NotePencilIcon} label="Notes" onClick={openNotes} />;
138
+ ```
139
+
140
+ Toolbar actions take a rendered `icon` element instead, as shown above.
141
+
142
+ The chrome draws three icons of its own, from Phosphor: the toolbar's Back
143
+ caret and the title bar menu's Move Forward and Move Backward arrows.
144
+ `WindowingIconsProvider` replaces them for the chrome inside it. An icon it
145
+ leaves out keeps the one from the nearest provider above, or the default:
146
+
147
+ ```tsx
148
+ import { ArrowDown, ArrowUp, ChevronLeft } from "lucide-react";
149
+
150
+ <WindowingIconsProvider
151
+ icons={{ back: ChevronLeft, moveBackward: ArrowDown, moveForward: ArrowUp }}
152
+ >
153
+ <Desktop />
154
+ </WindowingIconsProvider>;
155
+ ```
156
+
157
+ ## Start menu
158
+
159
+ `StartMenu` is a taskbar's start button: place it at the bar's leading edge,
160
+ give it an `icon` to show (a logo or an icon element), and the menu opens above
161
+ the button's top-left corner. Its `items` each take an `id`, `label`, optional
162
+ `icon` and `disabled`, and `onSelect`, which runs after the menu closes and
163
+ receives where the menu opened, for placing a new window near it:
164
+
165
+ ```tsx
166
+ <StartMenu
167
+ icon={<Logo />}
168
+ items={[
169
+ {
170
+ icon: NotePencilIcon,
171
+ id: "notes",
172
+ label: "Notes",
173
+ onSelect: ({ x }) => create("Notes", x, 80, NotesApp),
174
+ },
175
+ ]}
176
+ />
177
+ ```
178
+
179
+ The button is named "Menu" unless `label` says otherwise, and announces its
180
+ menu with `aria-haspopup` and `aria-expanded`. By default it is a square,
181
+ borderless control the height of the bar's controls, lit while hovered,
182
+ focused, or open (`StartMenu.css`). A `className` replaces that styling, so a
183
+ host's own button styles apply alone. A menu that needs more than a list passes
184
+ `renderMenu`, which renders the open menu itself and receives its `position`
185
+ and a `close` callback. Tearleads' footer does this in
186
+ `packages/app/src/shell/pane/footer/PaneFooter.tsx`.
187
+
126
188
  ## Styles
127
189
 
128
190
  Each component imports its own stylesheet, so a bundler that handles CSS imports
@@ -206,27 +268,26 @@ owns the `@tearleads` npm scope:
206
268
 
207
269
  ```sh
208
270
  npm login --registry https://registry.npmjs.org
209
- bun run publish:npm:dry-run
210
- bun run publish:npm
271
+ bun run publish:npm:dry-run windowing
272
+ bun run publish:npm windowing
211
273
  ```
212
274
 
213
- `scripts/publishNpmModules.sh` publishes every Tearleads module required for the
214
- standalone windowing extraction. That set is only `@tearleads/windowing`: it has
215
- no workspace dependencies, and its React peers and Phosphor dependency already
216
- exist on npm. `scripts/publishWindowing.sh` is the package-specific command,
217
- also available as `bun run --cwd packages/windowing publish:npm`; the workflow
218
- runs it too.
275
+ Windowing has no workspace dependencies, and its React peers and Phosphor
276
+ dependency already exist on npm, so it publishes on its own.
277
+ `scripts/publishNpmPackage.sh` publishes each npm package by its directory name;
278
+ `bun run --cwd packages/windowing publish:npm` runs it for windowing, and the
279
+ workflow runs it too.
219
280
 
220
- Both commands rebuild into a fresh temporary directory, publish its generated
221
- consumer manifest with public access to `https://registry.npmjs.org`, and remove
222
- the directory on success or failure. A temporary `.npmrc` overrides any
281
+ The command rebuilds into a fresh temporary directory, publishes its generated
282
+ consumer manifest with public access to `https://registry.npmjs.org`, and
283
+ removes the directory on success or failure. A temporary `.npmrc` overrides any
223
284
  scope-specific registry without changing your npm configuration. A dry run
224
- builds and previews the same package without uploading. They accept `--dry-run`,
225
- `--tag <tag>` (default `latest`), and `--otp <code>`; for example:
285
+ builds and previews the same package without uploading. It accepts
286
+ `--dry-run`, `--tag <tag>` (default `latest`), and `--otp <code>`; for example:
226
287
 
227
288
  ```sh
228
- bun run publish:npm --dry-run --tag next
229
- bun run publish:npm --tag next --otp 123456
289
+ bun run publish:npm windowing --dry-run --tag next
290
+ bun run publish:npm windowing --tag next --otp 123456
230
291
  ```
231
292
 
232
293
  Run `package:smoke` separately before a release to verify the packed package in
@@ -0,0 +1,21 @@
1
+ import { type PropsWithChildren } from "react";
2
+ import type { WindowingIcon } from "./windowingIcon.js";
3
+ /** The icons the window chrome draws on its own. */
4
+ export interface WindowingIcons {
5
+ /** The toolbar's Back button. */
6
+ back: WindowingIcon;
7
+ /** Move Backward, in a title bar's context menu. */
8
+ moveBackward: WindowingIcon;
9
+ /** Move Forward, in a title bar's context menu. */
10
+ moveForward: WindowingIcon;
11
+ }
12
+ /** The chrome's icons: Phosphor's, unless a provider replaces them. */
13
+ export declare function useWindowingIcons(): WindowingIcons;
14
+ /**
15
+ * Draws the chrome inside it with `icons` in place of its Phosphor defaults, so
16
+ * the chrome can match a host's icon set. An icon left out keeps the one from
17
+ * the nearest provider above, or the default.
18
+ */
19
+ export declare function WindowingIconsProvider({ children, icons, }: PropsWithChildren<{
20
+ icons: Partial<WindowingIcons>;
21
+ }>): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ArrowDownIcon } from "@phosphor-icons/react/dist/csr/ArrowDown";
3
+ import { ArrowUpIcon } from "@phosphor-icons/react/dist/csr/ArrowUp";
4
+ import { CaretLeftIcon } from "@phosphor-icons/react/dist/csr/CaretLeft";
5
+ import { createContext, useContext, useMemo, } from "react";
6
+ const PHOSPHOR_ICONS = {
7
+ back: CaretLeftIcon,
8
+ moveBackward: ArrowDownIcon,
9
+ moveForward: ArrowUpIcon,
10
+ };
11
+ const WindowingIconsContext = createContext(PHOSPHOR_ICONS);
12
+ /** The chrome's icons: Phosphor's, unless a provider replaces them. */
13
+ export function useWindowingIcons() {
14
+ return useContext(WindowingIconsContext);
15
+ }
16
+ /**
17
+ * Draws the chrome inside it with `icons` in place of its Phosphor defaults, so
18
+ * the chrome can match a host's icon set. An icon left out keeps the one from
19
+ * the nearest provider above, or the default.
20
+ */
21
+ export function WindowingIconsProvider({ children, icons, }) {
22
+ const inherited = useWindowingIcons();
23
+ const { back, moveBackward, moveForward } = icons;
24
+ const value = useMemo(() => ({
25
+ back: back ?? inherited.back,
26
+ moveBackward: moveBackward ?? inherited.moveBackward,
27
+ moveForward: moveForward ?? inherited.moveForward,
28
+ }), [back, inherited, moveBackward, moveForward]);
29
+ return (_jsx(WindowingIconsContext.Provider, { value: value, children: children }));
30
+ }
31
+ //# sourceMappingURL=WindowingIcons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WindowingIcons.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/icons/WindowingIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EACL,aAAa,EAEb,UAAU,EACV,OAAO,GACR,MAAM,OAAO,CAAC;AAaf,MAAM,cAAc,GAAmB;IACrC,IAAI,EAAE,aAAa;IACnB,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,WAAW;CACzB,CAAC;AAEF,MAAM,qBAAqB,GAAG,aAAa,CAAiB,cAAc,CAAC,CAAC;AAE5E,uEAAuE;AACvE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,EACR,KAAK,GACiD;IACtD,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAC;IACtC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAClD,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC,IAAI;QAC5B,YAAY,EAAE,YAAY,IAAI,SAAS,CAAC,YAAY;QACpD,WAAW,EAAE,WAAW,IAAI,SAAS,CAAC,WAAW;KAClD,CAAC,EACF,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC,CAC7C,CAAC;IACF,OAAO,CACL,KAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACzC,QAAQ,GACsB,CAClC,CAAC;AACJ,CAAC","sourcesContent":["import { ArrowDownIcon } from \"@phosphor-icons/react/dist/csr/ArrowDown\";\nimport { ArrowUpIcon } from \"@phosphor-icons/react/dist/csr/ArrowUp\";\nimport { CaretLeftIcon } from \"@phosphor-icons/react/dist/csr/CaretLeft\";\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useMemo,\n} from \"react\";\nimport type { WindowingIcon } from \"./windowingIcon\";\n\n/** The icons the window chrome draws on its own. */\nexport interface WindowingIcons {\n /** The toolbar's Back button. */\n back: WindowingIcon;\n /** Move Backward, in a title bar's context menu. */\n moveBackward: WindowingIcon;\n /** Move Forward, in a title bar's context menu. */\n moveForward: WindowingIcon;\n}\n\nconst PHOSPHOR_ICONS: WindowingIcons = {\n back: CaretLeftIcon,\n moveBackward: ArrowDownIcon,\n moveForward: ArrowUpIcon,\n};\n\nconst WindowingIconsContext = createContext<WindowingIcons>(PHOSPHOR_ICONS);\n\n/** The chrome's icons: Phosphor's, unless a provider replaces them. */\nexport function useWindowingIcons(): WindowingIcons {\n return useContext(WindowingIconsContext);\n}\n\n/**\n * Draws the chrome inside it with `icons` in place of its Phosphor defaults, so\n * the chrome can match a host's icon set. An icon left out keeps the one from\n * the nearest provider above, or the default.\n */\nexport function WindowingIconsProvider({\n children,\n icons,\n}: PropsWithChildren<{ icons: Partial<WindowingIcons> }>) {\n const inherited = useWindowingIcons();\n const { back, moveBackward, moveForward } = icons;\n const value = useMemo(\n () => ({\n back: back ?? inherited.back,\n moveBackward: moveBackward ?? inherited.moveBackward,\n moveForward: moveForward ?? inherited.moveForward,\n }),\n [back, inherited, moveBackward, moveForward],\n );\n return (\n <WindowingIconsContext.Provider value={value}>\n {children}\n </WindowingIconsContext.Provider>\n );\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { ComponentType } from "react";
2
+ /**
3
+ * The props the window chrome renders an icon with. Phosphor and Lucide icons
4
+ * accept them, as does any component that draws an SVG from them.
5
+ */
6
+ export interface WindowingIconProps {
7
+ "aria-hidden"?: boolean | "true" | "false";
8
+ className?: string;
9
+ focusable?: boolean | "true" | "false";
10
+ size?: number | string;
11
+ }
12
+ /** An icon from any icon set, as a component the chrome renders. */
13
+ export type WindowingIcon = ComponentType<WindowingIconProps>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=windowingIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"windowingIcon.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/icons/windowingIcon.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType } from \"react\";\n\n/**\n * The props the window chrome renders an icon with. Phosphor and Lucide icons\n * accept them, as does any component that draws an SVG from them.\n */\nexport interface WindowingIconProps {\n \"aria-hidden\"?: boolean | \"true\" | \"false\";\n className?: string;\n focusable?: boolean | \"true\" | \"false\";\n size?: number | string;\n}\n\n/** An icon from any icon set, as a component the chrome renders. */\nexport type WindowingIcon = ComponentType<WindowingIconProps>;\n"]}
package/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export { createRequiredContext, type RequiredContext, } from "./createRequiredContext.js";
2
+ export { type WindowingIcons, WindowingIconsProvider, } from "./icons/WindowingIcons.js";
3
+ export type { WindowingIcon, WindowingIconProps } from "./icons/windowingIcon.js";
2
4
  export { Menu, type MenuPosition } from "./menu/Menu.js";
3
5
  export { MenuItem, type MenuItemProps } from "./menu/MenuItem.js";
6
+ export { StartMenu, type StartMenuItem, type StartMenuProps, } from "./menu/StartMenu.js";
4
7
  export { type ContextMenuState, useContextMenuPositionState, useContextMenuState, } from "./menu/useContextMenuState.js";
5
8
  export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
6
9
  export { CurrentWindowProvider, useCurrentWindow, useSuppressWindowToolbar, useWindowBackground, useWindowContentSize, } from "./window/CurrentWindowContext.js";
package/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import "./tokens.css";
2
2
  // The public windowing API: window state, window chrome and its registration
3
- // hooks, and the menu and sidebar primitives the chrome renders with.
3
+ // hooks, the menu and sidebar primitives the chrome renders with, a taskbar's
4
+ // start menu, and the icons the chrome draws.
4
5
  export { createRequiredContext, } from "./createRequiredContext.js";
6
+ export { WindowingIconsProvider, } from "./icons/WindowingIcons.js";
5
7
  export { Menu } from "./menu/Menu.js";
6
8
  export { MenuItem } from "./menu/MenuItem.js";
9
+ export { StartMenu, } from "./menu/StartMenu.js";
7
10
  export { useContextMenuPositionState, useContextMenuState, } from "./menu/useContextMenuState.js";
8
11
  export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
9
12
  export { CurrentWindowProvider, useCurrentWindow, useSuppressWindowToolbar, useWindowBackground, useWindowContentSize, } from "./window/CurrentWindowContext.js";
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,sEAAsE;AACtE,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAqB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAsB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAEL,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAA8B,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAQlB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import \"./tokens.css\";\n\n// The public windowing API: window state, window chrome and its registration\n// hooks, and the menu and sidebar primitives the chrome renders with.\nexport {\n createRequiredContext,\n type RequiredContext,\n} from \"./createRequiredContext\";\nexport { Menu, type MenuPosition } from \"./menu/Menu\";\nexport { MenuItem, type MenuItemProps } from \"./menu/MenuItem\";\nexport {\n type ContextMenuState,\n useContextMenuPositionState,\n useContextMenuState,\n} from \"./menu/useContextMenuState\";\nexport { SidebarResizeHandle, useSidebarResize } from \"./sidebar/SidebarResize\";\nexport {\n CurrentWindowProvider,\n useCurrentWindow,\n useSuppressWindowToolbar,\n useWindowBackground,\n useWindowContentSize,\n} from \"./window/CurrentWindowContext\";\nexport { Window, type WindowContentBoundary } from \"./window/Window\";\nexport { WindowTitleBarActionButtons } from \"./window/WindowChromeActions\";\nexport { WindowCloseButton } from \"./window/WindowCloseButton\";\nexport {\n useWindowBackAction,\n useWindowBackActionValue,\n useWindowFileMenuItem,\n useWindowRefreshMenuItem,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarAction,\n useWindowTitleBarActions,\n useWindowToolbarReservation,\n useWindowViewMenuItem,\n WindowMenuProvider,\n} from \"./window/WindowMenuContext\";\nexport {\n hasWindowSidebar,\n useRegisteredWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"./window/WindowSidebarContext\";\nexport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowCreateOptions,\n type WindowEntry,\n type WindowGeometry,\n type WindowPosition,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n WindowStateProvider,\n} from \"./window/WindowStateProvider\";\nexport { WindowToolBar } from \"./window/WindowToolBar\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,8EAA8E;AAC9E,8CAA8C;AAC9C,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAqB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAsB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,SAAS,GAGV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAA8B,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAQlB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import \"./tokens.css\";\n\n// The public windowing API: window state, window chrome and its registration\n// hooks, the menu and sidebar primitives the chrome renders with, a taskbar's\n// start menu, and the icons the chrome draws.\nexport {\n createRequiredContext,\n type RequiredContext,\n} from \"./createRequiredContext\";\nexport {\n type WindowingIcons,\n WindowingIconsProvider,\n} from \"./icons/WindowingIcons\";\nexport type { WindowingIcon, WindowingIconProps } from \"./icons/windowingIcon\";\nexport { Menu, type MenuPosition } from \"./menu/Menu\";\nexport { MenuItem, type MenuItemProps } from \"./menu/MenuItem\";\nexport {\n StartMenu,\n type StartMenuItem,\n type StartMenuProps,\n} from \"./menu/StartMenu\";\nexport {\n type ContextMenuState,\n useContextMenuPositionState,\n useContextMenuState,\n} from \"./menu/useContextMenuState\";\nexport { SidebarResizeHandle, useSidebarResize } from \"./sidebar/SidebarResize\";\nexport {\n CurrentWindowProvider,\n useCurrentWindow,\n useSuppressWindowToolbar,\n useWindowBackground,\n useWindowContentSize,\n} from \"./window/CurrentWindowContext\";\nexport { Window, type WindowContentBoundary } from \"./window/Window\";\nexport { WindowTitleBarActionButtons } from \"./window/WindowChromeActions\";\nexport { WindowCloseButton } from \"./window/WindowCloseButton\";\nexport {\n useWindowBackAction,\n useWindowBackActionValue,\n useWindowFileMenuItem,\n useWindowRefreshMenuItem,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarAction,\n useWindowTitleBarActions,\n useWindowToolbarReservation,\n useWindowViewMenuItem,\n WindowMenuProvider,\n} from \"./window/WindowMenuContext\";\nexport {\n hasWindowSidebar,\n useRegisteredWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"./window/WindowSidebarContext\";\nexport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowCreateOptions,\n type WindowEntry,\n type WindowGeometry,\n type WindowPosition,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n WindowStateProvider,\n} from \"./window/WindowStateProvider\";\nexport { WindowToolBar } from \"./window/WindowToolBar\";\n"]}
@@ -1,9 +1,10 @@
1
- import type { Icon } from "@phosphor-icons/react";
2
1
  import type { MouseEventHandler } from "react";
2
+ import type { WindowingIcon } from "../icons/windowingIcon.js";
3
3
  export interface MenuItemProps {
4
- icon?: Icon;
4
+ /** Any icon component, such as a Phosphor or Lucide icon. */
5
+ icon?: WindowingIcon | undefined;
5
6
  label: string;
6
- disabled?: boolean;
7
+ disabled?: boolean | undefined;
7
8
  onClick: MouseEventHandler<HTMLButtonElement>;
8
9
  }
9
10
  export declare function MenuItem({ icon: IconComponent, label, disabled, onClick, }: MenuItemProps): import("react").JSX.Element;
package/menu/MenuItem.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  export function MenuItem({ icon: IconComponent, label, disabled, onClick, }) {
3
- return (_jsxs("button", { type: "button", disabled: disabled, onClick: onClick, children: [IconComponent && (_jsx(IconComponent, { "aria-hidden": "true", className: "menu-item-icon", focusable: "false", size: 16, weight: "regular" })), _jsx("span", { className: "menu-item-label", children: label })] }));
3
+ return (_jsxs("button", { type: "button", disabled: disabled, onClick: onClick, children: [IconComponent && (_jsx(IconComponent, { "aria-hidden": "true", className: "menu-item-icon", focusable: "false", size: 16 })), _jsx("span", { className: "menu-item-label", children: label })] }));
4
4
  }
5
5
  //# sourceMappingURL=MenuItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/MenuItem.tsx"],"names":[],"mappings":";AAUA,MAAM,UAAU,QAAQ,CAAC,EACvB,IAAI,EAAE,aAAa,EACnB,KAAK,EACL,QAAQ,EACR,OAAO,GACO;IACd,OAAO,CACL,kBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,aACvD,aAAa,IAAI,CAChB,KAAC,aAAa,mBACA,MAAM,EAClB,SAAS,EAAC,gBAAgB,EAC1B,SAAS,EAAC,OAAO,EACjB,IAAI,EAAE,EAAE,EACR,MAAM,EAAC,SAAS,GAChB,CACH,EACD,eAAM,SAAS,EAAC,iBAAiB,YAAE,KAAK,GAAQ,IACzC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { Icon } from \"@phosphor-icons/react\";\nimport type { MouseEventHandler } from \"react\";\n\nexport interface MenuItemProps {\n icon?: Icon;\n label: string;\n disabled?: boolean;\n onClick: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport function MenuItem({\n icon: IconComponent,\n label,\n disabled,\n onClick,\n}: MenuItemProps) {\n return (\n <button type=\"button\" disabled={disabled} onClick={onClick}>\n {IconComponent && (\n <IconComponent\n aria-hidden=\"true\"\n className=\"menu-item-icon\"\n focusable=\"false\"\n size={16}\n weight=\"regular\"\n />\n )}\n <span className=\"menu-item-label\">{label}</span>\n </button>\n );\n}\n"]}
1
+ {"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/MenuItem.tsx"],"names":[],"mappings":";AAWA,MAAM,UAAU,QAAQ,CAAC,EACvB,IAAI,EAAE,aAAa,EACnB,KAAK,EACL,QAAQ,EACR,OAAO,GACO;IACd,OAAO,CACL,kBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,aACvD,aAAa,IAAI,CAChB,KAAC,aAAa,mBACA,MAAM,EAClB,SAAS,EAAC,gBAAgB,EAC1B,SAAS,EAAC,OAAO,EACjB,IAAI,EAAE,EAAE,GACR,CACH,EACD,eAAM,SAAS,EAAC,iBAAiB,YAAE,KAAK,GAAQ,IACzC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { MouseEventHandler } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\n\nexport interface MenuItemProps {\n /** Any icon component, such as a Phosphor or Lucide icon. */\n icon?: WindowingIcon | undefined;\n label: string;\n disabled?: boolean | undefined;\n onClick: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport function MenuItem({\n icon: IconComponent,\n label,\n disabled,\n onClick,\n}: MenuItemProps) {\n return (\n <button type=\"button\" disabled={disabled} onClick={onClick}>\n {IconComponent && (\n <IconComponent\n aria-hidden=\"true\"\n className=\"menu-item-icon\"\n focusable=\"false\"\n size={16}\n />\n )}\n <span className=\"menu-item-label\">{label}</span>\n </button>\n );\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The start menu button's default look: a square, borderless control the
3
+ * height of the bar's other controls, lit while hovered, focused, or open. A
4
+ * host that passes its own classes replaces this class, and with it these rules.
5
+ */
6
+ .start-menu-button {
7
+ display: inline-flex;
8
+ flex: 0 0 auto;
9
+ align-items: center;
10
+ justify-content: center;
11
+ width: var(--control-height);
12
+ height: var(--control-height);
13
+ padding: 0;
14
+ border: 0;
15
+ border-radius: var(--app-radius-control);
16
+ background: transparent;
17
+ color: inherit;
18
+ cursor: pointer;
19
+ }
20
+
21
+ .start-menu-button:hover,
22
+ .start-menu-button:focus-visible,
23
+ .start-menu-button[aria-expanded="true"] {
24
+ background: var(--emphasis-surface);
25
+ color: var(--emphasis-text);
26
+ }
@@ -0,0 +1,42 @@
1
+ import type { ReactNode } from "react";
2
+ import type { WindowingIcon } from "../icons/windowingIcon.js";
3
+ import { type MenuPosition } from "./Menu.js";
4
+ /** One entry in a {@link StartMenu}. */
5
+ export interface StartMenuItem {
6
+ disabled?: boolean | undefined;
7
+ icon?: WindowingIcon | undefined;
8
+ id: string;
9
+ label: string;
10
+ /**
11
+ * Runs when the item is chosen, after the menu closes. `position` is where
12
+ * the menu opened, for placing what the item opens near it.
13
+ */
14
+ onSelect: (position: MenuPosition) => void;
15
+ }
16
+ export interface StartMenuProps {
17
+ /**
18
+ * Classes for the button. They replace the default `start-menu-button`
19
+ * styling, so a host's own button styles apply alone.
20
+ */
21
+ className?: string | undefined;
22
+ /** What the button shows, such as a logo or an icon. */
23
+ icon: ReactNode;
24
+ /** The menu's entries, in order. Ignored when `renderMenu` is given. */
25
+ items?: readonly StartMenuItem[] | undefined;
26
+ /** The button's accessible name. */
27
+ label?: string | undefined;
28
+ /**
29
+ * Renders the open menu itself, such as a `Menu` whose content needs more
30
+ * than a list of items, in place of `items`. Call `close` to close it.
31
+ */
32
+ renderMenu?: ((menu: {
33
+ close: () => void;
34
+ position: MenuPosition;
35
+ }) => ReactNode) | undefined;
36
+ }
37
+ /**
38
+ * A taskbar's start menu: a button, usually at the bar's leading edge, that
39
+ * opens a menu above its top-left corner. Give it `items` for a list of
40
+ * entries, or `renderMenu` to render the menu yourself.
41
+ */
42
+ export declare function StartMenu({ className, icon, items, label, renderMenu, }: StartMenuProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Menu } from "./Menu.js";
3
+ import { MenuItem } from "./MenuItem.js";
4
+ import "./StartMenu.css";
5
+ import { useContextMenuPositionState } from "./useContextMenuState.js";
6
+ /**
7
+ * A taskbar's start menu: a button, usually at the bar's leading edge, that
8
+ * opens a menu above its top-left corner. Give it `items` for a list of
9
+ * entries, or `renderMenu` to render the menu yourself.
10
+ */
11
+ export function StartMenu({ className, icon, items = [], label = "Menu", renderMenu, }) {
12
+ const { closeContextMenu: close, contextMenu: position, openContextMenuAt, } = useContextMenuPositionState();
13
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: className ?? "start-menu-button", "aria-label": label, "aria-haspopup": "menu", "aria-expanded": position !== null, onClick: (event) => {
14
+ const bounds = event.currentTarget.getBoundingClientRect();
15
+ openContextMenuAt({ x: bounds.left, y: bounds.top });
16
+ }, children: icon }), position &&
17
+ (renderMenu ? (renderMenu({ close, position })) : (_jsx(Menu, { position: position, onClose: close, children: items.map((item) => (_jsx(MenuItem, { disabled: item.disabled, icon: item.icon, label: item.label, onClick: () => {
18
+ close();
19
+ item.onSelect(position);
20
+ } }, item.id))) })))] }));
21
+ }
22
+ //# sourceMappingURL=StartMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartMenu.js","sourceR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IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE;4BACZ,KAAK,EAAE,CAAC;4BACR,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;wBAC1B,CAAC,IAPI,IAAI,CAAC,EAAE,CAQZ,CACH,CAAC,GACG,CACR,CAAC,IACH,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { Menu, type MenuPosition } from \"./Menu\";\nimport { MenuItem } from \"./MenuItem\";\nimport \"./StartMenu.css\";\nimport { useContextMenuPositionState } from \"./useContextMenuState\";\n\n/** One entry in a {@link StartMenu}. */\nexport interface StartMenuItem {\n disabled?: boolean | undefined;\n icon?: WindowingIcon | undefined;\n id: string;\n label: string;\n /**\n * Runs when the item is chosen, after the menu closes. `position` is where\n * the menu opened, for placing what the item opens near it.\n */\n onSelect: (position: MenuPosition) => void;\n}\n\nexport interface StartMenuProps {\n /**\n * Classes for the button. They replace the default `start-menu-button`\n * styling, so a host's own button styles apply alone.\n */\n className?: string | undefined;\n /** What the button shows, such as a logo or an icon. */\n icon: ReactNode;\n /** The menu's entries, in order. Ignored when `renderMenu` is given. */\n items?: readonly StartMenuItem[] | undefined;\n /** The button's accessible name. */\n label?: string | undefined;\n /**\n * Renders the open menu itself, such as a `Menu` whose content needs more\n * than a list of items, in place of `items`. Call `close` to close it.\n */\n renderMenu?:\n | ((menu: { close: () => void; position: MenuPosition }) => ReactNode)\n | undefined;\n}\n\n/**\n * A taskbar's start menu: a button, usually at the bar's leading edge, that\n * opens a menu above its top-left corner. Give it `items` for a list of\n * entries, or `renderMenu` to render the menu yourself.\n */\nexport function StartMenu({\n className,\n icon,\n items = [],\n label = \"Menu\",\n renderMenu,\n}: StartMenuProps) {\n const {\n closeContextMenu: close,\n contextMenu: position,\n openContextMenuAt,\n } = useContextMenuPositionState();\n\n return (\n <>\n <button\n type=\"button\"\n className={className ?? \"start-menu-button\"}\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={position !== null}\n onClick={(event) => {\n const bounds = event.currentTarget.getBoundingClientRect();\n openContextMenuAt({ x: bounds.left, y: bounds.top });\n }}\n >\n {icon}\n </button>\n {position &&\n (renderMenu ? (\n renderMenu({ close, position })\n ) : (\n <Menu position={position} onClose={close}>\n {items.map((item) => (\n <MenuItem\n key={item.id}\n disabled={item.disabled}\n icon={item.icon}\n label={item.label}\n onClick={() => {\n close();\n item.onSelect(position);\n }}\n />\n ))}\n </Menu>\n ))}\n </>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tearleads/windowing",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "App-agnostic window management for React: window state, window chrome, and the menu and sidebar primitives it renders with.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -1 +1 @@
1
- export declare const useWindowActions: () => import("./types").WindowStateActions;
1
+ export declare const useWindowActions: () => import("./types.js").WindowStateActions;
@@ -1 +1 @@
1
- export declare const useWindowStateData: () => import("./types").WindowStateData;
1
+ export declare const useWindowStateData: () => import("./types.js").WindowStateData;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ArrowDownIcon } from "@phosphor-icons/react/dist/csr/ArrowDown";
3
- import { ArrowUpIcon } from "@phosphor-icons/react/dist/csr/ArrowUp";
4
2
  import { useCallback } from "react";
3
+ import { useWindowingIcons } from "../icons/WindowingIcons.js";
5
4
  import { Menu } from "../menu/Menu.js";
6
5
  import { MenuItem } from "../menu/MenuItem.js";
7
6
  import { useContextMenuPositionState } from "../menu/useContextMenuState.js";
@@ -11,6 +10,7 @@ import { WindowMaximizeButton } from "./WindowMaximizeButton.js";
11
10
  import { WindowMinimizeButton } from "./WindowMinimizeButton.js";
12
11
  export function WindowTitleBar({ title, titleId, onPointerDown, onMinimize, onMaximize, onClose, onMoveForward, onMoveBackward, }) {
13
12
  const { closeContextMenu, contextMenu, openContextMenuAt } = useContextMenuPositionState();
13
+ const icons = useWindowingIcons();
14
14
  const handlePointerDown = useCallback((e) => {
15
15
  const target = e.target;
16
16
  if (e.button !== 0)
@@ -25,10 +25,10 @@ export function WindowTitleBar({ title, titleId, onPointerDown, onMinimize, onMa
25
25
  event.preventDefault();
26
26
  event.stopPropagation();
27
27
  openContextMenuAt({ x: event.clientX, y: event.clientY });
28
- }, children: [_jsx("span", { className: "window-titlebar-title", id: titleId, title: title, children: title }), _jsxs("div", { className: "window-titlebar-buttons", children: [_jsx(WindowMinimizeButton, { onClick: onMinimize }), _jsx(WindowMaximizeButton, { onClick: onMaximize }), _jsx(WindowCloseButton, { label: "Close window", onClick: onClose })] }), contextMenu && (_jsxs(Menu, { position: contextMenu, onClose: closeContextMenu, direction: "down", children: [_jsx(MenuItem, { icon: ArrowUpIcon, label: "Move Forward", onClick: () => {
28
+ }, children: [_jsx("span", { className: "window-titlebar-title", id: titleId, title: title, children: title }), _jsxs("div", { className: "window-titlebar-buttons", children: [_jsx(WindowMinimizeButton, { onClick: onMinimize }), _jsx(WindowMaximizeButton, { onClick: onMaximize }), _jsx(WindowCloseButton, { label: "Close window", onClick: onClose })] }), contextMenu && (_jsxs(Menu, { position: contextMenu, onClose: closeContextMenu, direction: "down", children: [_jsx(MenuItem, { icon: icons.moveForward, label: "Move Forward", onClick: () => {
29
29
  onMoveForward();
30
30
  closeContextMenu();
31
- } }), _jsx(MenuItem, { icon: ArrowDownIcon, label: "Move Backward", onClick: () => {
31
+ } }), _jsx(MenuItem, { icon: icons.moveBackward, label: "Move Backward", onClick: () => {
32
32
  onMoveBackward();
33
33
  closeContextMenu();
34
34
  } })] }))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"WindowTitleBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowTitleBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,a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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,EAAkB,WAAW,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;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;IAChC,MAAM,KAAK,GAAG,iBAAiB,EAAE,CAAC;IAElC,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,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,OAAO,CACL,eACE,IAAI,EAAC,SAAS,gBACH,iBAAiB,EAC5B,SAAS,EAAC,iBAAiB,EAC3B,aAAa,EAAE,iBAAiB,EAChC,aAAa,EAAE,CAAC,KAAK,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,KAAK,CAAC,WAAW,EACvB,KAAK,EAAC,cAAc,EACpB,OAAO,EAAE,GAAG,EAAE;4BACZ,aAAa,EAAE,CAAC;4BAChB,gBAAgB,EAAE,CAAC;wBACrB,CAAC,GACD,EACF,KAAC,QAAQ,IACP,IAAI,EAAE,KAAK,CAAC,YAAY,EACxB,KAAK,EAAC,eAAe,EACrB,OAAO,EAAE,GAAG,EAAE;4BACZ,cAAc,EAAE,CAAC;4BACjB,gBAAgB,EAAE,CAAC;wBACrB,CAAC,GACD,IACG,CACR,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { type ReactNode, useCallback } from \"react\";\nimport { useWindowingIcons } from \"../icons/WindowingIcons\";\nimport { Menu } from \"../menu/Menu\";\nimport { MenuItem } from \"../menu/MenuItem\";\nimport { useContextMenuPositionState } from \"../menu/useContextMenuState\";\nimport \"./WindowTitleBar.css\";\nimport { WindowCloseButton } from \"./WindowCloseButton\";\nimport { WindowMaximizeButton } from \"./WindowMaximizeButton\";\nimport { WindowMinimizeButton } from \"./WindowMinimizeButton\";\n\nexport interface WindowTitleBarAction {\n disabled?: boolean;\n icon: ReactNode;\n id: string;\n label: string;\n onClick: () => void;\n pressed?: boolean;\n}\n\nexport function WindowTitleBar({\n title,\n titleId,\n onPointerDown,\n onMinimize,\n onMaximize,\n onClose,\n onMoveForward,\n onMoveBackward,\n}: {\n title: string;\n titleId?: string | undefined;\n onPointerDown: (e: React.PointerEvent) => void;\n onMinimize: () => void;\n onMaximize: () => void;\n onClose: () => void;\n onMoveForward: () => void;\n onMoveBackward: () => void;\n}) {\n const { closeContextMenu, contextMenu, openContextMenuAt } =\n useContextMenuPositionState();\n const icons = useWindowingIcons();\n\n const handlePointerDown = useCallback(\n (e: React.PointerEvent<HTMLDivElement>) => {\n const target = e.target;\n if (e.button !== 0) return;\n // Element, not HTMLElement: an icon inside a button (including the\n // portaled context menu, whose events bubble through React) is SVG.\n if (target instanceof Element && target.closest(\"button\")) return;\n onPointerDown(e);\n },\n [onPointerDown],\n );\n\n return (\n <div\n role=\"toolbar\"\n aria-label=\"Window controls\"\n className=\"window-titlebar\"\n onPointerDown={handlePointerDown}\n onContextMenu={(event) => {\n event.preventDefault();\n event.stopPropagation();\n openContextMenuAt({ x: event.clientX, y: event.clientY });\n }}\n >\n <span className=\"window-titlebar-title\" id={titleId} title={title}>\n {title}\n </span>\n <div className=\"window-titlebar-buttons\">\n <WindowMinimizeButton onClick={onMinimize} />\n <WindowMaximizeButton onClick={onMaximize} />\n <WindowCloseButton label=\"Close window\" onClick={onClose} />\n </div>\n {contextMenu && (\n <Menu\n position={contextMenu}\n onClose={closeContextMenu}\n direction=\"down\"\n >\n <MenuItem\n icon={icons.moveForward}\n label=\"Move Forward\"\n onClick={() => {\n onMoveForward();\n closeContextMenu();\n }}\n />\n <MenuItem\n icon={icons.moveBackward}\n label=\"Move Backward\"\n onClick={() => {\n onMoveBackward();\n closeContextMenu();\n }}\n />\n </Menu>\n )}\n </div>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CaretLeftIcon } from "@phosphor-icons/react/dist/csr/CaretLeft";
3
2
  import { useState } from "react";
3
+ import { useWindowingIcons } from "../icons/WindowingIcons.js";
4
4
  import "./WindowToolBar.css";
5
5
  import { WindowTitleBarActionButtons } from "./WindowChromeActions.js";
6
6
  import { useWindowBackActionValue, useWindowTitleBarActions, useWindowToolbarReservationReleased, useWindowToolbarReserved, } from "./WindowMenuContext.js";
@@ -38,6 +38,7 @@ import { useWindowBackActionValue, useWindowTitleBarActions, useWindowToolbarRes
38
38
  * chrome does).
39
39
  */
40
40
  export function WindowToolBar({ canGoBack = false, onGoBack, showHistoryBack = false, } = {}) {
41
+ const { back: BackIcon } = useWindowingIcons();
41
42
  const backAction = useWindowBackActionValue();
42
43
  const actions = useWindowTitleBarActions();
43
44
  const reserved = useWindowToolbarReserved();
@@ -63,6 +64,6 @@ export function WindowToolBar({ canGoBack = false, onGoBack, showHistoryBack = f
63
64
  return null;
64
65
  }
65
66
  const backLabel = backAction?.label ?? "Back";
66
- return (_jsxs("div", { "aria-label": "Toolbar", className: "window-toolbar", role: "toolbar", children: [_jsx("div", { className: "window-toolbar-primary", children: showBack && (_jsxs("button", { "aria-label": backLabel, className: "window-toolbar-button", disabled: backAction?.disabled ?? false, title: backLabel, type: "button", onClick: backAction?.onClick ?? onGoBack, children: [_jsx(CaretLeftIcon, { "aria-hidden": true, size: 18 }), _jsx("span", { className: "window-toolbar-back-label", children: backLabel })] })) }), _jsx("div", { className: "window-toolbar-spacer" }), actions.length > 0 && (_jsx("div", { className: "window-toolbar-actions", children: _jsx(WindowTitleBarActionButtons, { actions: actions, className: "window-toolbar-button" }) }))] }));
67
+ return (_jsxs("div", { "aria-label": "Toolbar", className: "window-toolbar", role: "toolbar", children: [_jsx("div", { className: "window-toolbar-primary", children: showBack && (_jsxs("button", { "aria-label": backLabel, className: "window-toolbar-button", disabled: backAction?.disabled ?? false, title: backLabel, type: "button", onClick: backAction?.onClick ?? onGoBack, children: [_jsx(BackIcon, { "aria-hidden": true, size: 18 }), _jsx("span", { className: "window-toolbar-back-label", children: backLabel })] })) }), _jsx("div", { className: "window-toolbar-spacer" }), actions.length > 0 && (_jsx("div", { className: "window-toolbar-actions", children: _jsx(WindowTitleBarActionButtons, { actions: actions, className: "window-toolbar-button" }) }))] }));
67
68
  }
68
69
  //# sourceMappingURL=WindowToolBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WindowToolBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowToolBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,SAAS,GAAG,KAAK,EACjB,QAAQ,EACR,eAAe,GAAG,KAAK,MAKrB,EAAE;IACJ,MAAM,UAAU,GAAG,wBAAwB,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;IAC5C,MAAM,mBAAmB,GAAG,mCAAmC,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,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ACG,EACN,cAAK,SAAS,EAAC,uBAAuB,GAAG,EACxC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,cAAK,SAAS,EAAC,wBAAwB,YACrC,KAAC,2BAA2B,IAC1B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,uBAAuB,GACjC,GACE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { CaretLeftIcon } from \"@phosphor-icons/react/dist/csr/CaretLeft\";\nimport { useState } from \"react\";\nimport \"./WindowToolBar.css\";\nimport { WindowTitleBarActionButtons } from \"./WindowChromeActions\";\nimport {\n useWindowBackActionValue,\n useWindowTitleBarActions,\n useWindowToolbarReservationReleased,\n useWindowToolbarReserved,\n} from \"./WindowMenuContext\";\n\n/**\n * The window's toolbar row, sitting below the File/View menu bar and above the\n * body. It renders the same actions the routed app bar shows — the registered\n * {@link useWindowBackAction} on the left and {@link useWindowTitleBarAction}\n * icon buttons on the right — so a mini-app hosted in a window gets the same\n * toolbar chrome it gets in the routed shell.\n *\n * The left slot resolves exactly as `RoutedPaneAppBar` does: a registered back\n * action wins, and otherwise the button steps back through the host's own\n * history. `showHistoryBack` turns that fallback on for a window hosting a\n * routed mini-app, whose history is the window's Back stack (windows are not\n * backed by browser history); the fallback is omitted when that stack is empty.\n * Unlike the routed shell's paired Back/Forward controls, the window has no\n * adjacent history control whose stable placement would justify a disabled\n * Back button.\n *\n * Both surfaces read one shared registry (WindowMenuContext), so a mini-app\n * registers its actions once and they appear wherever it is hosted.\n *\n * A window whose app never registers toolbar chrome keeps a flush menu bar/body\n * (the row renders nothing). But once an app HAS shown chrome, the row stays\n * mounted and reserves its {@link WindowToolBar.css} min-height even when the\n * action set momentarily clears — on an action-less sub-route or a loading tick\n * where the app's `show` conditions are briefly false. Unmounting the row in\n * those windows would drop a full bar-height out of the flex column and shift\n * the body up, then back down when the actions re-register (visible flicker).\n *\n * An app that wants the row on every route — a blank bar where a route carries\n * no actions, rather than one that only appears after some route first shows\n * chrome — reserves it via {@link useWindowToolbarReservation} (the reserved row\n * still mounts a commit late, once that hook's effect registers, as all window\n * chrome does).\n */\nexport function WindowToolBar({\n canGoBack = false,\n onGoBack,\n showHistoryBack = false,\n}: {\n canGoBack?: boolean;\n onGoBack?: (() => void) | undefined;\n showHistoryBack?: boolean;\n} = {}) {\n const backAction = useWindowBackActionValue();\n const actions = useWindowTitleBarActions();\n const reserved = useWindowToolbarReserved();\n const reservationReleased = useWindowToolbarReservationReleased();\n const showBack = backAction !== null || (showHistoryBack && canGoBack);\n const hasChrome =\n backAction !== null || showHistoryBack || actions.length > 0;\n // Latch: this window's app has shown toolbar chrome at least once, so keep the\n // row reserved from here on rather than collapsing it on a transient empty.\n // Seed from the mount-time value so a window that already has chrome does not\n // latch during render at all; the render-phase set below catches chrome that\n // first appears after mount, without an effect's extra committed render pass.\n const [hasShownChrome, setHasShownChrome] = useState(hasChrome);\n let latchedChrome = hasShownChrome;\n if (hasChrome && !latchedChrome) {\n setHasShownChrome(true);\n latchedChrome = true;\n } else if (!hasChrome && reservationReleased && latchedChrome) {\n setHasShownChrome(false);\n latchedChrome = false;\n }\n\n if (!hasChrome && !latchedChrome && !reserved) {\n return null;\n }\n\n const backLabel = backAction?.label ?? \"Back\";\n\n return (\n <div aria-label=\"Toolbar\" className=\"window-toolbar\" role=\"toolbar\">\n <div className=\"window-toolbar-primary\">\n {showBack && (\n <button\n aria-label={backLabel}\n className=\"window-toolbar-button\"\n disabled={backAction?.disabled ?? false}\n title={backLabel}\n type=\"button\"\n onClick={backAction?.onClick ?? onGoBack}\n >\n <CaretLeftIcon aria-hidden size={18} />\n <span className=\"window-toolbar-back-label\">{backLabel}</span>\n </button>\n )}\n </div>\n <div className=\"window-toolbar-spacer\" />\n {actions.length > 0 && (\n <div className=\"window-toolbar-actions\">\n <WindowTitleBarActionButtons\n actions={actions}\n className=\"window-toolbar-button\"\n />\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"WindowToolBar.js","sourceRo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ACxB,aAAa,GAAG,IAAI,CAAC;IACvB,CAAC;SAAM,IAAI,CAAC,SAAS,IAAI,mBAAmB,IAAI,aAAa,EAAE,CAAC;QAC9D,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACzB,aAAa,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,SAAS,IAAI,CAAC,aAAa,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,UAAU,EAAE,KAAK,IAAI,MAAM,CAAC;IAE9C,OAAO,CACL,6BAAgB,SAAS,EAAC,SAAS,EAAC,gBAAgB,EAAC,IAAI,EAAC,SAAS,aACjE,cAAK,SAAS,EAAC,wBAAwB,YACpC,QAAQ,IAAI,CACX,gCACc,SAAS,EACrB,SAAS,EAAC,uBAAuB,EACjC,QAAQ,EAAE,UAAU,EAAE,QAAQ,IAAI,KAAK,EACvC,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,QAAQ,aAExC,KAAC,QAAQ,yBAAa,IAAI,EAAE,EAAE,GAAI,EAClC,eAAM,SAAS,EAAC,2BAA2B,YAAE,SAAS,GAAQ,IACvD,CACV,GACG,EACN,cAAK,SAAS,EAAC,uBAAuB,GAAG,EACxC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,cAAK,SAAS,EAAC,wBAAwB,YACrC,KAAC,2BAA2B,IAC1B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,uBAAuB,GACjC,GACE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { useWindowingIcons } from \"../icons/WindowingIcons\";\nimport \"./WindowToolBar.css\";\nimport { WindowTitleBarActionButtons } from \"./WindowChromeActions\";\nimport {\n useWindowBackActionValue,\n useWindowTitleBarActions,\n useWindowToolbarReservationReleased,\n useWindowToolbarReserved,\n} from \"./WindowMenuContext\";\n\n/**\n * The window's toolbar row, sitting below the File/View menu bar and above the\n * body. It renders the same actions the routed app bar shows — the registered\n * {@link useWindowBackAction} on the left and {@link useWindowTitleBarAction}\n * icon buttons on the right — so a mini-app hosted in a window gets the same\n * toolbar chrome it gets in the routed shell.\n *\n * The left slot resolves exactly as `RoutedPaneAppBar` does: a registered back\n * action wins, and otherwise the button steps back through the host's own\n * history. `showHistoryBack` turns that fallback on for a window hosting a\n * routed mini-app, whose history is the window's Back stack (windows are not\n * backed by browser history); the fallback is omitted when that stack is empty.\n * Unlike the routed shell's paired Back/Forward controls, the window has no\n * adjacent history control whose stable placement would justify a disabled\n * Back button.\n *\n * Both surfaces read one shared registry (WindowMenuContext), so a mini-app\n * registers its actions once and they appear wherever it is hosted.\n *\n * A window whose app never registers toolbar chrome keeps a flush menu bar/body\n * (the row renders nothing). But once an app HAS shown chrome, the row stays\n * mounted and reserves its {@link WindowToolBar.css} min-height even when the\n * action set momentarily clears — on an action-less sub-route or a loading tick\n * where the app's `show` conditions are briefly false. Unmounting the row in\n * those windows would drop a full bar-height out of the flex column and shift\n * the body up, then back down when the actions re-register (visible flicker).\n *\n * An app that wants the row on every route — a blank bar where a route carries\n * no actions, rather than one that only appears after some route first shows\n * chrome — reserves it via {@link useWindowToolbarReservation} (the reserved row\n * still mounts a commit late, once that hook's effect registers, as all window\n * chrome does).\n */\nexport function WindowToolBar({\n canGoBack = false,\n onGoBack,\n showHistoryBack = false,\n}: {\n canGoBack?: boolean;\n onGoBack?: (() => void) | undefined;\n showHistoryBack?: boolean;\n} = {}) {\n const { back: BackIcon } = useWindowingIcons();\n const backAction = useWindowBackActionValue();\n const actions = useWindowTitleBarActions();\n const reserved = useWindowToolbarReserved();\n const reservationReleased = useWindowToolbarReservationReleased();\n const showBack = backAction !== null || (showHistoryBack && canGoBack);\n const hasChrome =\n backAction !== null || showHistoryBack || actions.length > 0;\n // Latch: this window's app has shown toolbar chrome at least once, so keep the\n // row reserved from here on rather than collapsing it on a transient empty.\n // Seed from the mount-time value so a window that already has chrome does not\n // latch during render at all; the render-phase set below catches chrome that\n // first appears after mount, without an effect's extra committed render pass.\n const [hasShownChrome, setHasShownChrome] = useState(hasChrome);\n let latchedChrome = hasShownChrome;\n if (hasChrome && !latchedChrome) {\n setHasShownChrome(true);\n latchedChrome = true;\n } else if (!hasChrome && reservationReleased && latchedChrome) {\n setHasShownChrome(false);\n latchedChrome = false;\n }\n\n if (!hasChrome && !latchedChrome && !reserved) {\n return null;\n }\n\n const backLabel = backAction?.label ?? \"Back\";\n\n return (\n <div aria-label=\"Toolbar\" className=\"window-toolbar\" role=\"toolbar\">\n <div className=\"window-toolbar-primary\">\n {showBack && (\n <button\n aria-label={backLabel}\n className=\"window-toolbar-button\"\n disabled={backAction?.disabled ?? false}\n title={backLabel}\n type=\"button\"\n onClick={backAction?.onClick ?? onGoBack}\n >\n <BackIcon aria-hidden size={18} />\n <span className=\"window-toolbar-back-label\">{backLabel}</span>\n </button>\n )}\n </div>\n <div className=\"window-toolbar-spacer\" />\n {actions.length > 0 && (\n <div className=\"window-toolbar-actions\">\n <WindowTitleBarActionButtons\n actions={actions}\n className=\"window-toolbar-button\"\n />\n </div>\n )}\n </div>\n );\n}\n"]}