@tearleads/windowing 0.2.28 → 0.2.30
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/docs/appearance.md +15 -9
- package/docs/launcher.md +12 -4
- package/docs/publishing.md +25 -13
- package/package.json +1 -1
- package/window/WindowToolBar.js +12 -8
- package/window/WindowToolBar.js.map +1 -1
package/docs/appearance.md
CHANGED
|
@@ -46,8 +46,8 @@ id; `useOptionalTheme` returns `null` outside a provider.
|
|
|
46
46
|
|
|
47
47
|
Mount one provider above everything themed. It stamps the attributes before
|
|
48
48
|
the browser paints and removes them on unmount; under a dark scheme,
|
|
49
|
-
`tokens.css` sets `color-scheme: dark`. Tearleads sets its themes per
|
|
50
|
-
profile in `packages/app/src/host/AppHostConfig.ts
|
|
49
|
+
[`tokens.css`][tokens] sets `color-scheme: dark`. Tearleads sets its themes per
|
|
50
|
+
host profile in [`packages/app/src/host/AppHostConfig.ts`][host-profile].
|
|
51
51
|
|
|
52
52
|
## Wallpapers and Display Properties
|
|
53
53
|
|
|
@@ -118,14 +118,15 @@ chrome's look without rendering a window.
|
|
|
118
118
|
|
|
119
119
|
The stylesheets read design tokens (colors, spacing, radii, shadows, and the
|
|
120
120
|
`--window-bar-*` and `--tearleads-window-titlebar-*` chrome tokens). The package
|
|
121
|
-
entry imports `tokens.css
|
|
121
|
+
entry imports [`tokens.css`][tokens], which defines every one of them under
|
|
122
122
|
`:where(:root)`, so a page that defines none still renders a complete light
|
|
123
123
|
window. That rule has zero specificity: any `:root` rule, theme, or scoped block
|
|
124
124
|
the host writes overrides it. Tearleads overrides them with its own themes in
|
|
125
|
-
`packages/ui/src/styles.css` and
|
|
125
|
+
[`packages/ui/src/styles.css`][ui-styles] and
|
|
126
|
+
[`packages/app/src/shell/layout/AppChrome.css`][app-chrome].
|
|
126
127
|
The routed shell also reads the screen's safe areas (`--safe-area-*`) and, under
|
|
127
128
|
`:root[data-navigation-mode="routed"]`, a 44px `--control-height` and 24px
|
|
128
|
-
`--control-icon-size`, which `tokens.css` defines the same way.
|
|
129
|
+
`--control-icon-size`, which [`tokens.css`][tokens] defines the same way.
|
|
129
130
|
|
|
130
131
|
Several defaults derive from `--color-dark`, the foreground: the window edge
|
|
131
132
|
(`--border-strong-color`), the hover and selection chip (`--emphasis-surface`
|
|
@@ -134,8 +135,8 @@ and `--emphasis-text`), and `--color-hairline`. A dark theme that sets only the
|
|
|
134
135
|
Tearleads' dark theme does.
|
|
135
136
|
|
|
136
137
|
The window, menus, and routed shell draw thin scrollbars in `--scrollbar-thumb`
|
|
137
|
-
over `--scrollbar-track`. `tokens.css` leaves both unset, so the thumb
|
|
138
|
-
back to `--color-dark` at 32%, mixed on each surface so it follows the theme
|
|
138
|
+
over `--scrollbar-track`. [`tokens.css`][tokens] leaves both unset, so the thumb
|
|
139
|
+
falls back to `--color-dark` at 32%, mixed on each surface so it follows the theme
|
|
139
140
|
there, including a scoped one, and the track to transparent. They use the
|
|
140
141
|
standard `scrollbar-width` and
|
|
141
142
|
`scrollbar-color` properties, which Firefox, Chromium 121, and Safari 26.2
|
|
@@ -145,8 +146,8 @@ scrolls the same way: `scrollbar-color` inherits from the surface, and
|
|
|
145
146
|
specificity, so any host rule wins.
|
|
146
147
|
|
|
147
148
|
The window paints its background, behind its body and sidebar, with
|
|
148
|
-
`--window-background`. `tokens.css` leaves it unset, so it falls back
|
|
149
|
-
`--color-light` wherever that is set, including a scoped theme. Content sets
|
|
149
|
+
`--window-background`. [`tokens.css`][tokens] leaves it unset, so it falls back
|
|
150
|
+
to `--color-light` wherever that is set, including a scoped theme. Content sets
|
|
150
151
|
its own window's background with `useWindowBackground`, while it is mounted;
|
|
151
152
|
`undefined` keeps the default. A document viewer can use it to set its page
|
|
152
153
|
apart from the window around it:
|
|
@@ -165,3 +166,8 @@ Windows and menus lay out `border-box`, the box model their sizes assume. Since
|
|
|
165
166
|
`box-sizing` does not inherit, a zero-specificity rule sets it on the window or
|
|
166
167
|
menu and everything inside, including window content; any host rule overrides
|
|
167
168
|
it.
|
|
169
|
+
|
|
170
|
+
[tokens]: https://github.com/a2f0/tearleads/blob/main/packages/windowing/src/tokens.css
|
|
171
|
+
[host-profile]: https://github.com/a2f0/tearleads/blob/main/packages/app/src/host/AppHostConfig.ts
|
|
172
|
+
[ui-styles]: https://github.com/a2f0/tearleads/blob/main/packages/ui/src/styles.css
|
|
173
|
+
[app-chrome]: https://github.com/a2f0/tearleads/blob/main/packages/app/src/shell/layout/AppChrome.css
|
package/docs/launcher.md
CHANGED
|
@@ -27,11 +27,12 @@ receives where the menu opened, for placing a new window near it:
|
|
|
27
27
|
The button is named "Menu" unless `label` says otherwise, and announces its
|
|
28
28
|
menu with `aria-haspopup` and `aria-expanded`. By default it is a square,
|
|
29
29
|
borderless control the height of the bar's controls, lit while hovered,
|
|
30
|
-
focused, or open (`StartMenu.css`). A `className` replaces
|
|
30
|
+
focused, or open ([`StartMenu.css`][start-menu-styles]). A `className` replaces
|
|
31
|
+
that styling, so a
|
|
31
32
|
host's own button styles apply alone. A menu that needs more than a list passes
|
|
32
33
|
`renderMenu`, which renders the open menu itself and receives its `position`
|
|
33
34
|
and a `close` callback. Tearleads' footer does this in
|
|
34
|
-
`packages/app/src/shell/pane/footer/PaneFooter.tsx
|
|
35
|
+
[`packages/app/src/shell/pane/footer/PaneFooter.tsx`][pane-footer].
|
|
35
36
|
|
|
36
37
|
## Launching mini-apps
|
|
37
38
|
|
|
@@ -124,7 +125,9 @@ writes one JSON string, so the host chooses where it lives:
|
|
|
124
125
|
`createOpfsDesktopStateStorage` keeps a file in the origin private file system,
|
|
125
126
|
`createMemoryDesktopStateStorage` keeps it in memory (the default), and a host
|
|
126
127
|
can wrap its own store, as Tearleads wraps each identity's encrypted blob store
|
|
127
|
-
in
|
|
128
|
+
in
|
|
129
|
+
[`packages/app/src/shell/pane/shell/usePaneDesktopStateStorage.ts`][desktop-storage].
|
|
130
|
+
Keep the
|
|
128
131
|
adapter stable: a new adapter reloads the layout from what it holds. Moves made
|
|
129
132
|
before the load finishes win and are saved with the stored layout; when the
|
|
130
133
|
read fails, moves stay in memory and nothing is written.
|
|
@@ -160,4 +163,9 @@ offers, such as to those the session may see, and
|
|
|
160
163
|
Overlays that should fill the content pane rather than the screen portal into
|
|
161
164
|
`useRoutedPaneOverlayHost().host`. The shell sizes to the box its host gives
|
|
162
165
|
`.routed-pane`, as a grid item or a block with a height. Tearleads dresses it in
|
|
163
|
-
`packages/app/src/shell/layout/routed/AppRoutedPane.tsx
|
|
166
|
+
[`packages/app/src/shell/layout/routed/AppRoutedPane.tsx`][app-routed-pane].
|
|
167
|
+
|
|
168
|
+
[start-menu-styles]: https://github.com/a2f0/tearleads/blob/main/packages/windowing/src/menu/StartMenu.css
|
|
169
|
+
[pane-footer]: https://github.com/a2f0/tearleads/blob/main/packages/app/src/shell/pane/footer/PaneFooter.tsx
|
|
170
|
+
[desktop-storage]: https://github.com/a2f0/tearleads/blob/main/packages/app/src/shell/pane/shell/usePaneDesktopStateStorage.ts
|
|
171
|
+
[app-routed-pane]: https://github.com/a2f0/tearleads/blob/main/packages/app/src/shell/layout/routed/AppRoutedPane.tsx
|
package/docs/publishing.md
CHANGED
|
@@ -15,25 +15,28 @@ bun run --cwd packages/windowing package:smoke # pack, install, render, typeche
|
|
|
15
15
|
The built package is ES modules with declarations and source maps, plus every
|
|
16
16
|
stylesheet. React and react-dom are peer dependencies from 19.2, the first
|
|
17
17
|
release with `useEffectEvent`; Phosphor icons is its one dependency. The
|
|
18
|
-
stylesheets and the entry module (which imports `tokens.css`) are
|
|
19
|
-
effects, so bundlers that trust `sideEffects` keep the token
|
|
20
|
-
`src/publishedPackage.test.ts` checks the built
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
stylesheets and the entry module (which imports [`tokens.css`][tokens]) are
|
|
19
|
+
declared side effects, so bundlers that trust `sideEffects` keep the token
|
|
20
|
+
defaults. [`src/publishedPackage.test.ts`][package-tests] checks the built
|
|
21
|
+
manifest, documentation links, and that no module reaches outside the package,
|
|
22
|
+
so a new workspace import fails the package's tests rather than the publish.
|
|
23
|
+
The declarations drop the stylesheet imports tsc keeps
|
|
23
24
|
in them, which a consumer's typecheck could not resolve. The smoke script
|
|
24
25
|
installs the lowest React the peer range admits, typechecks against the
|
|
25
26
|
declarations with TypeScript's defaults, and bundles a named import with webpack.
|
|
26
27
|
|
|
27
|
-
Merging to `main` publishes. When `packages/windowing` changes
|
|
28
|
-
`.github/workflows/windowing-publish.yml` publishes
|
|
29
|
-
`package.json` if it is a stable `x.y.z`
|
|
28
|
+
Merging to `main` publishes. When [`packages/windowing`][windowing-source] changes
|
|
29
|
+
there, [`.github/workflows/windowing-publish.yml`][windowing-publish] publishes
|
|
30
|
+
the version in [`package.json`][workspace-manifest] if it is a stable `x.y.z`
|
|
31
|
+
newer than npm's `latest`; a merge that
|
|
30
32
|
leaves the version alone, a re-run, or a run that finishes after a newer release
|
|
31
33
|
succeeds without publishing, as decided by `agent-tool release plan`.
|
|
32
34
|
The workflow authenticates with
|
|
33
35
|
[npm trusted publishing](https://docs.npmjs.com/trusted-publishers): npm accepts
|
|
34
36
|
the job's GitHub OIDC token instead of an npm token, and attaches provenance to
|
|
35
37
|
each version. On npmjs.com the package's trusted publisher names the `a2f0`
|
|
36
|
-
owner, the `tearleads` repository, the
|
|
38
|
+
owner, the `tearleads` repository, the
|
|
39
|
+
[`windowing-publish.yml`][windowing-publish] workflow, and
|
|
37
40
|
the `npm` environment, which the repository restricts to `main`. Renaming the
|
|
38
41
|
workflow or the environment breaks publishing until that setting matches.
|
|
39
42
|
|
|
@@ -48,8 +51,9 @@ bun run publish:npm windowing
|
|
|
48
51
|
|
|
49
52
|
Windowing has no workspace dependencies, and its React peers and Phosphor
|
|
50
53
|
dependency already exist on npm, so it publishes on its own.
|
|
51
|
-
`scripts/release/publishNpmPackage.sh` publishes each npm
|
|
52
|
-
directory name; `bun run --cwd packages/windowing publish:npm`
|
|
54
|
+
[`scripts/release/publishNpmPackage.sh`][publish-npm-package] publishes each npm
|
|
55
|
+
package by its directory name; `bun run --cwd packages/windowing publish:npm`
|
|
56
|
+
runs it for
|
|
53
57
|
windowing, and the workflow runs it too.
|
|
54
58
|
|
|
55
59
|
The command rebuilds into a fresh temporary directory, publishes its generated
|
|
@@ -68,7 +72,15 @@ Run `package:smoke` separately before a release to verify the packed package in
|
|
|
68
72
|
an external consumer. It needs the network to install the consumer dependencies.
|
|
69
73
|
|
|
70
74
|
`ship-pr` bumps changed workspace packages before review and merge; the generated
|
|
71
|
-
manifest copies `version` from `package.json
|
|
72
|
-
bump the version yourself before publishing. The manifest
|
|
75
|
+
manifest copies `version` from [`package.json`][workspace-manifest]. For a release
|
|
76
|
+
outside that flow, bump the version yourself before publishing. The manifest
|
|
77
|
+
names this repository,
|
|
73
78
|
which npm requires of a version with provenance, and declares
|
|
74
79
|
`"license": "UNLICENSED"`.
|
|
80
|
+
|
|
81
|
+
[tokens]: https://github.com/a2f0/tearleads/blob/main/packages/windowing/src/tokens.css
|
|
82
|
+
[package-tests]: https://github.com/a2f0/tearleads/blob/main/packages/windowing/src/publishedPackage.test.ts
|
|
83
|
+
[windowing-source]: https://github.com/a2f0/tearleads/tree/main/packages/windowing
|
|
84
|
+
[windowing-publish]: https://github.com/a2f0/tearleads/blob/main/.github/workflows/windowing-publish.yml
|
|
85
|
+
[workspace-manifest]: https://github.com/a2f0/tearleads/blob/main/packages/windowing/package.json
|
|
86
|
+
[publish-npm-package]: https://github.com/a2f0/tearleads/blob/main/scripts/release/publishNpmPackage.sh
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tearleads/windowing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.30",
|
|
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": {
|
package/window/WindowToolBar.js
CHANGED
|
@@ -5,6 +5,15 @@ import "./WindowToolBar.css";
|
|
|
5
5
|
import { WindowTitleBarActionButtons } from "./WindowChromeActions.js";
|
|
6
6
|
import { useWindowBackActionValue, useWindowRefreshMenuItemValue, useWindowTitleBarActions, useWindowToolbarReservationReleased, useWindowToolbarReserved, } from "./WindowMenuContext.js";
|
|
7
7
|
import { WindowRefreshButton } from "./WindowRefreshButton.js";
|
|
8
|
+
/**
|
|
9
|
+
* Latch: once an app has shown toolbar chrome the row stays reserved, rather
|
|
10
|
+
* than collapsing on a transient empty, until its reservation is released.
|
|
11
|
+
*/
|
|
12
|
+
function latchedToolbarChrome(hasChrome, reservationReleased, hasShownChrome) {
|
|
13
|
+
if (hasChrome)
|
|
14
|
+
return true;
|
|
15
|
+
return hasShownChrome && !reservationReleased;
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* The window's toolbar row, sitting below the File/View menu bar and above the
|
|
10
19
|
* body. It renders the same actions the routed app bar shows — the registered
|
|
@@ -56,14 +65,9 @@ export function WindowToolBar({ canGoBack = false, onGoBack, showHistoryBack = f
|
|
|
56
65
|
// latch during render at all; the render-phase set below catches chrome that
|
|
57
66
|
// first appears after mount, without an effect's extra committed render pass.
|
|
58
67
|
const [hasShownChrome, setHasShownChrome] = useState(hasChrome);
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
setHasShownChrome(
|
|
62
|
-
latchedChrome = true;
|
|
63
|
-
}
|
|
64
|
-
else if (!hasChrome && reservationReleased && latchedChrome) {
|
|
65
|
-
setHasShownChrome(false);
|
|
66
|
-
latchedChrome = false;
|
|
68
|
+
const latchedChrome = latchedToolbarChrome(hasChrome, reservationReleased, hasShownChrome);
|
|
69
|
+
if (latchedChrome !== hasShownChrome) {
|
|
70
|
+
setHasShownChrome(latchedChrome);
|
|
67
71
|
}
|
|
68
72
|
if (!hasChrome && !latchedChrome && !reserved) {
|
|
69
73
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WindowToolBar.js","sour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AS,CAAC,CAAC;IAChE,
|
|
1
|
+
{"version":3,"file":"WindowToolBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/WindowToolBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,wBAAwB,EACxB,mCAAmC,EACnC,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,SAAS,oBAAoB,CAC3B,SAAkB,EAClB,mBAA4B,EAC5B,cAAuB;IAEvB,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,cAAc,IAAI,CAAC,mBAAmB,CAAC;AAChD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,SAAS,GAAG,KAAK,EACjB,QAAQ,EACR,eAAe,GAAG,KAAK,MAKrB,EAAE;IACJ,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAC/C,MAAM,UAAU,GAAG,wBAAwB,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAC;IAC3C,MAAM,WAAW,GAAG,6BAA6B,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;IAC5C,MAAM,mBAAmB,GAAG,mCAAmC,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,UAAU,KAAK,IAAI,IAAI,CAAC,eAAe,IAAI,SAAS,CAAC,CAAC;IACvE,MAAM,SAAS,GACb,U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EAChB,SAAS,EAAC,uBAAuB,GACjC,EACD,WAAW,IAAI,CACd,KAAC,mBAAmB,IAClB,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAE,WAAW,GACjB,CACH,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { useWindowingIcons } from \"../icons/WindowingIcons\";\nimport \"./WindowToolBar.css\";\nimport { WindowTitleBarActionButtons } from \"./WindowChromeActions\";\nimport {\n useWindowBackActionValue,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarActions,\n useWindowToolbarReservationReleased,\n useWindowToolbarReserved,\n} from \"./WindowMenuContext\";\nimport { WindowRefreshButton } from \"./WindowRefreshButton\";\n\n/**\n * Latch: once an app has shown toolbar chrome the row stays reserved, rather\n * than collapsing on a transient empty, until its reservation is released.\n */\nfunction latchedToolbarChrome(\n hasChrome: boolean,\n reservationReleased: boolean,\n hasShownChrome: boolean,\n): boolean {\n if (hasChrome) return true;\n return hasShownChrome && !reservationReleased;\n}\n\n/**\n * The window's toolbar row, sitting below the File/View menu bar and above the\n * body. It renders the same actions the routed app bar shows — the registered\n * {@link useWindowBackAction} on the left and {@link useWindowTitleBarAction}\n * icon buttons followed by Refresh on the right — so a window gets the same\n * toolbar chrome it gets in the routed shell.\n *\n * The left slot resolves exactly as `RoutedPaneAppBar` does: a registered back\n * action wins, and otherwise the button steps back through the host's own\n * history. `showHistoryBack` turns that fallback on for a window hosting a\n * routed mini-app, whose history is the window's Back stack (windows are not\n * backed by browser history); the fallback is omitted when that stack is empty.\n * Unlike the routed shell's paired Back/Forward controls, the window has no\n * adjacent history control whose stable placement would justify a disabled\n * Back button.\n *\n * Both surfaces read one shared registry (WindowMenuContext), so a mini-app\n * registers its actions once and they appear wherever it is hosted.\n *\n * A window whose app never registers toolbar chrome keeps a flush menu bar/body\n * (the row renders nothing). But once an app HAS shown chrome, the row stays\n * mounted and reserves its {@link WindowToolBar.css} min-height even when the\n * action set momentarily clears — on an action-less sub-route or a loading tick\n * where the app's `show` conditions are briefly false. Unmounting the row in\n * those windows would drop a full bar-height out of the flex column and shift\n * the body up, then back down when the actions re-register (visible flicker).\n *\n * An app that wants the row on every route — a blank bar where a route carries\n * no actions, rather than one that only appears after some route first shows\n * chrome — reserves it via {@link useWindowToolbarReservation} (the reserved row\n * still mounts a commit late, once that hook's effect registers, as all window\n * chrome does).\n */\nexport function WindowToolBar({\n canGoBack = false,\n onGoBack,\n showHistoryBack = false,\n}: {\n canGoBack?: boolean;\n onGoBack?: (() => void) | undefined;\n showHistoryBack?: boolean;\n} = {}) {\n const { back: BackIcon } = useWindowingIcons();\n const backAction = useWindowBackActionValue();\n const actions = useWindowTitleBarActions();\n const refreshItem = useWindowRefreshMenuItemValue();\n const reserved = useWindowToolbarReserved();\n const reservationReleased = useWindowToolbarReservationReleased();\n const showBack = backAction !== null || (showHistoryBack && canGoBack);\n const hasChrome =\n backAction !== null ||\n showHistoryBack ||\n actions.length > 0 ||\n refreshItem !== null;\n // Latch: this window's app has shown toolbar chrome at least once, so keep the\n // row reserved from here on rather than collapsing it on a transient empty.\n // Seed from the mount-time value so a window that already has chrome does not\n // latch during render at all; the render-phase set below catches chrome that\n // first appears after mount, without an effect's extra committed render pass.\n const [hasShownChrome, setHasShownChrome] = useState(hasChrome);\n const latchedChrome = latchedToolbarChrome(\n hasChrome,\n reservationReleased,\n hasShownChrome,\n );\n if (latchedChrome !== hasShownChrome) {\n setHasShownChrome(latchedChrome);\n }\n\n if (!hasChrome && !latchedChrome && !reserved) {\n return null;\n }\n\n const backLabel = backAction?.label ?? \"Back\";\n\n return (\n <div aria-label=\"Toolbar\" className=\"window-toolbar\" role=\"toolbar\">\n <div className=\"window-toolbar-primary\">\n {showBack && (\n <button\n aria-label={backLabel}\n className=\"window-toolbar-button\"\n disabled={backAction?.disabled ?? false}\n title={backLabel}\n type=\"button\"\n onClick={backAction?.onClick ?? onGoBack}\n >\n <BackIcon aria-hidden size={18} />\n <span className=\"window-toolbar-back-label\">{backLabel}</span>\n </button>\n )}\n </div>\n <div className=\"window-toolbar-spacer\" />\n {(actions.length > 0 || refreshItem !== null) && (\n <div className=\"window-toolbar-actions\">\n <WindowTitleBarActionButtons\n actions={actions}\n className=\"window-toolbar-button\"\n />\n {refreshItem && (\n <WindowRefreshButton\n className=\"window-toolbar-button\"\n item={refreshItem}\n />\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
|