@labpane/os 1.3.0 → 1.4.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.
- package/README.md +41 -0
- package/dist/index.js +98 -43
- package/dist/index.js.map +2 -2
- package/dist/os/context.d.ts +2 -1
- package/dist/os/icons.d.ts +1 -0
- package/dist/os/pwa.d.ts +12 -0
- package/dist/os/surface.d.ts +3 -1
- package/dist/os/workspace.d.ts +3 -0
- package/dist/pwa.js +61 -0
- package/dist/pwa.js.map +7 -0
- package/dist/styles.css +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -109,6 +109,41 @@ type Layout = Pane | Split;
|
|
|
109
109
|
|
|
110
110
|
## Desktop windows
|
|
111
111
|
|
|
112
|
+
### Installed PWAs
|
|
113
|
+
|
|
114
|
+
Enable the browser's window-controls overlay in your web app manifest:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"display": "standalone",
|
|
119
|
+
"display_override": ["window-controls-overlay", "standalone"]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Then opt your top-level workspace into the available title-bar area:
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { Workspace } from "@labpane/os";
|
|
127
|
+
import { useWindowControlsOverlay } from "@labpane/os/pwa";
|
|
128
|
+
|
|
129
|
+
function App() {
|
|
130
|
+
const overlay = useWindowControlsOverlay();
|
|
131
|
+
return <Workspace windowControlsOverlay={overlay} {...workspaceProps} />;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The PWA browser integration is a separate entry point. Importing `Workspace` or using `@labpane/ui` alone does not include that module. Pass `false` to the hook to temporarily disable the integration; it then installs no observers or event listeners.
|
|
136
|
+
|
|
137
|
+
Place the workspace at the top of the viewport; remove any separate title-bar spacer. When the installed browser reports a visible overlay, Labpane places the top row of tabs inside its safe rectangle, leaving room for the browser's real window buttons on either side. Panel content keeps the full width. Geometry changes update the layout, and dense tabs get a minimum height sufficient to clear the native title bar. All pane headers share that minimum height while the overlay is active.
|
|
138
|
+
|
|
139
|
+
Set the app's manifest `theme_color` and document `<meta name="theme-color">` to the workspace background color. Update the meta value when the app changes theme so the browser's caption area matches. The generated starter reads `--lab-background` on theme changes; the library leaves document metadata to the application.
|
|
140
|
+
|
|
141
|
+
The blank toolbar area drags the window. Tabs, toolbar actions, and leading/trailing slots remain interactive. Mark a noninteractive leading element with `data-window-drag` if it should also drag; use `data-window-no-drag` for custom interactive content. Don't render `WindowControls` or supply a `WindowHost` for this path: the installed browser owns window actions and caption buttons.
|
|
142
|
+
|
|
143
|
+
Ordinary browser tabs, unsupported browsers, disabled overlays, and fullscreen use the normal layout. The browser controls whether the overlay is enabled; Chromium may require the user to choose **Hide title bar**. A workspace below the title-bar area is left alone. Installability, service workers, and the manifest remain application responsibilities. See the [browser platform documentation](https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps/how-to/window-controls-overlay) and [PWA test fixture](../../e2e/consumer/README.md).
|
|
144
|
+
|
|
145
|
+
### Native shells
|
|
146
|
+
|
|
112
147
|
To run the workspace in a frameless desktop window (Wails, Tauri, Electron, or your own shell), describe the window as a `WindowHost` and the workspace becomes its title bar:
|
|
113
148
|
|
|
114
149
|
```tsx
|
|
@@ -144,8 +179,14 @@ function App() {
|
|
|
144
179
|
- `useWindowFrame` moves the window when an empty part of a toolbar is dragged, maximises it on a double click, resizes it from its edges, and toggles full screen with F11, or Ctrl+Cmd+F on macOS. Add `data-window-drag` to other elements that should move the window.
|
|
145
180
|
- `useFullscreen(host)` returns `[fullscreen, setFullscreen]`. Without a host it uses the browser's Fullscreen API.
|
|
146
181
|
|
|
182
|
+
The host interface has no Wails, Go, Tauri, or Electron dependency. Applications own their shell and adapt its public APIs to these callbacks. If the shell already handles dragging and edge resizing, omit `drag` and `resize` to avoid sending duplicate commands. The [native desktop fixture](../../e2e/wails/README.md) demonstrates this boundary and checks real window actions with Wails. Its shell is test code, not part of this package.
|
|
183
|
+
|
|
147
184
|
## Keyboard
|
|
148
185
|
|
|
186
|
+
On touch devices, swipe the tab bar to scroll it and tap a tab to select it. An overflowing bar also has a native tab picker at its end. Swiping does not reorder or split tabs. If you supply a `menu`, touch and hold a tab to use its move and split actions. Mouse dragging and keyboard actions remain available.
|
|
187
|
+
|
|
188
|
+
Workspace panels scroll their content independently. Make page headers and action rows wrap, use `min-width: 0` for flex children, and keep wide tables or code blocks in their own scroll containers. A fixed `min-width` on application content can still make a panel scroll sideways even when the document fits the screen.
|
|
189
|
+
|
|
149
190
|
- Left and Right move between tabs, Home and End jump to the first and last, and Space selects
|
|
150
191
|
- Alt+Left and Alt+Right move the focused tab
|
|
151
192
|
- Alt+Shift+Left, Right, or Down split the focused tab into a new pane on that side
|
package/dist/index.js
CHANGED
|
@@ -63,10 +63,15 @@ function densitySize(density) {
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
var WorkspaceDensity = createContext(100);
|
|
66
|
+
var MinimumTabHeight = createContext(0);
|
|
66
67
|
var fitTabWidth = (width, available, count) => Math.min(width, Math.max(128, (available - 16) / Math.max(1, count)));
|
|
67
68
|
function useTabSize() {
|
|
68
69
|
const density = useContext(WorkspaceDensity);
|
|
69
|
-
|
|
70
|
+
const minimumHeight = useContext(MinimumTabHeight);
|
|
71
|
+
return useMemo(() => {
|
|
72
|
+
const size = densitySize(density);
|
|
73
|
+
return { ...size, height: Math.max(size.height, minimumHeight) };
|
|
74
|
+
}, [density, minimumHeight]);
|
|
70
75
|
}
|
|
71
76
|
function useWorkspaceIds() {
|
|
72
77
|
const prefix = useContext(WorkspaceId);
|
|
@@ -334,7 +339,8 @@ function WorkspaceSurface({
|
|
|
334
339
|
change,
|
|
335
340
|
header,
|
|
336
341
|
content,
|
|
337
|
-
menu
|
|
342
|
+
menu,
|
|
343
|
+
titlebarArea
|
|
338
344
|
}) {
|
|
339
345
|
const ids = useWorkspaceIds();
|
|
340
346
|
const {
|
|
@@ -541,31 +547,42 @@ function WorkspaceSurface({
|
|
|
541
547
|
minHeight: required.y
|
|
542
548
|
},
|
|
543
549
|
children: [
|
|
544
|
-
regions.map(({ pane, box }, index) =>
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
550
|
+
regions.map(({ pane, box }, index) => {
|
|
551
|
+
const overlay = titlebarArea && box.y < titlebarArea.height;
|
|
552
|
+
const left = overlay ? Math.max(box.x, titlebarArea.left) : box.x;
|
|
553
|
+
const right = overlay ? Math.min(box.x + box.width, titlebarArea.right) : box.x + box.width;
|
|
554
|
+
return /* @__PURE__ */ jsx(
|
|
555
|
+
"div",
|
|
556
|
+
{
|
|
557
|
+
"data-pane-header": pane.id,
|
|
558
|
+
"data-top": box.y === 0 || void 0,
|
|
559
|
+
className: "lab-pane-header",
|
|
560
|
+
"data-titlebar-overlay": overlay ? "" : void 0,
|
|
561
|
+
style: {
|
|
562
|
+
...position({
|
|
563
|
+
...box,
|
|
564
|
+
x: left,
|
|
565
|
+
width: Math.max(0, right - left),
|
|
566
|
+
height: tabHeight
|
|
567
|
+
}),
|
|
568
|
+
transitionDuration: transition && !overlay ? "var(--workspace-duration, 180ms)" : "0ms"
|
|
569
|
+
},
|
|
570
|
+
children: /* @__PURE__ */ jsx(
|
|
571
|
+
PaneHeader,
|
|
572
|
+
{
|
|
573
|
+
pane,
|
|
574
|
+
first: index === 0,
|
|
575
|
+
last: pane.id === topRight,
|
|
576
|
+
docking: stableDocking,
|
|
577
|
+
insertion: preview?.pane === pane.id ? preview.index : void 0,
|
|
578
|
+
board,
|
|
579
|
+
render: header
|
|
580
|
+
}
|
|
581
|
+
)
|
|
553
582
|
},
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
pane,
|
|
558
|
-
first: index === 0,
|
|
559
|
-
last: pane.id === topRight,
|
|
560
|
-
docking: stableDocking,
|
|
561
|
-
insertion: preview?.pane === pane.id ? preview.index : void 0,
|
|
562
|
-
board,
|
|
563
|
-
render: header
|
|
564
|
-
}
|
|
565
|
-
)
|
|
566
|
-
},
|
|
567
|
-
pane.id
|
|
568
|
-
)),
|
|
583
|
+
pane.id
|
|
584
|
+
);
|
|
585
|
+
}),
|
|
569
586
|
content(regions, transition, lifted),
|
|
570
587
|
dividers.map(({ split, bounds, ratio, low, high, ...box }) => {
|
|
571
588
|
const axis = split.axis, horizontal = axis === "x", dimension = horizontal ? "width" : "height";
|
|
@@ -697,6 +714,7 @@ var icon = (strokeWidth, ...paths) => function Icon(props) {
|
|
|
697
714
|
};
|
|
698
715
|
var ChevronLeftIcon = icon(4 / 3, "M10 4 6 8l4 4");
|
|
699
716
|
var ChevronRightIcon = icon(4 / 3, "m6 4 4 4-4 4");
|
|
717
|
+
var ChevronDownIcon = icon(4 / 3, "m4 6 4 4 4-4");
|
|
700
718
|
var XIcon = icon(7 / 6, "m12 4-8 8", "m4 4 8 8");
|
|
701
719
|
|
|
702
720
|
// frame.tsx
|
|
@@ -1056,6 +1074,7 @@ function WorkspaceTabs({
|
|
|
1056
1074
|
if (element) element.inert = true;
|
|
1057
1075
|
}, []);
|
|
1058
1076
|
const frameRef = React.useRef(null);
|
|
1077
|
+
const frameLayer = dragBoundary?.closest(".lab-board");
|
|
1059
1078
|
const maskedSheet = React.useRef(null);
|
|
1060
1079
|
const maskedOutline = React.useRef(null);
|
|
1061
1080
|
const restoreFrame = () => {
|
|
@@ -1622,6 +1641,7 @@ function WorkspaceTabs({
|
|
|
1622
1641
|
onKeyDown: (event) => keyDown(event, key2, index),
|
|
1623
1642
|
onPointerDown: (event) => {
|
|
1624
1643
|
if (event.button !== 0 || !event.isPrimary) return;
|
|
1644
|
+
if (event.pointerType === "touch") return;
|
|
1625
1645
|
if (event.pointerType === "mouse") event.preventDefault();
|
|
1626
1646
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1627
1647
|
event.currentTarget.focus({ preventScroll: true });
|
|
@@ -1671,23 +1691,40 @@ function WorkspaceTabs({
|
|
|
1671
1691
|
}
|
|
1672
1692
|
),
|
|
1673
1693
|
scrollButton(1),
|
|
1694
|
+
metrics.overflow && /* @__PURE__ */ jsxs3("label", { className: "lab-tab-picker", title: "Switch tab", children: [
|
|
1695
|
+
/* @__PURE__ */ jsx4(ChevronDownIcon, { className: "lab-icon" }),
|
|
1696
|
+
/* @__PURE__ */ jsx4(
|
|
1697
|
+
"select",
|
|
1698
|
+
{
|
|
1699
|
+
"aria-label": "Switch tab",
|
|
1700
|
+
value: active,
|
|
1701
|
+
onChange: (event) => {
|
|
1702
|
+
onSelect(event.currentTarget.value);
|
|
1703
|
+
},
|
|
1704
|
+
children: links.map(([key2, label]) => /* @__PURE__ */ jsx4("option", { value: key2, children: label }, key2))
|
|
1705
|
+
}
|
|
1706
|
+
)
|
|
1707
|
+
] }),
|
|
1674
1708
|
/* @__PURE__ */ jsx4("span", { className: "lab-sr-only", "aria-live": "polite", children: announcement }),
|
|
1675
1709
|
/* @__PURE__ */ jsxs3("span", { id: helpId, className: "lab-sr-only", children: [
|
|
1676
1710
|
"Arrow keys switch tabs. Home and End select the first and last tab. Delete closes a tab. Alt plus Left or Right reorders. Alt plus Shift and Left, Right, or Down splits a pane. F6 moves between panes; Shift plus F6 moves back.",
|
|
1677
1711
|
menu && " Right-click or press Shift plus F10 for tab actions without dragging."
|
|
1678
1712
|
] }),
|
|
1679
|
-
active &&
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1713
|
+
active && frameLayer && createPortal(
|
|
1714
|
+
/* @__PURE__ */ jsx4(
|
|
1715
|
+
"svg",
|
|
1716
|
+
{
|
|
1717
|
+
ref: frameRef,
|
|
1718
|
+
"aria-hidden": "true",
|
|
1719
|
+
"data-pane-frame": true,
|
|
1720
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1721
|
+
strokeWidth: size.borderWidth,
|
|
1722
|
+
style: { width, height },
|
|
1723
|
+
className: "lab-pane-frame",
|
|
1724
|
+
children: /* @__PURE__ */ jsx4("path", { className: "lab-outline" })
|
|
1725
|
+
}
|
|
1726
|
+
),
|
|
1727
|
+
frameLayer
|
|
1691
1728
|
),
|
|
1692
1729
|
dragging && createPortal(
|
|
1693
1730
|
/* @__PURE__ */ jsxs3(
|
|
@@ -2025,6 +2062,7 @@ function WorkspaceContent({
|
|
|
2025
2062
|
leading,
|
|
2026
2063
|
trailing,
|
|
2027
2064
|
titleBar,
|
|
2065
|
+
windowControlsOverlay,
|
|
2028
2066
|
toolbar,
|
|
2029
2067
|
menu,
|
|
2030
2068
|
confirmClose,
|
|
@@ -2040,7 +2078,11 @@ function WorkspaceContent({
|
|
|
2040
2078
|
() => new Map(tabs.map((tab) => [tab.key, tab])),
|
|
2041
2079
|
[tabs]
|
|
2042
2080
|
);
|
|
2043
|
-
const {
|
|
2081
|
+
const {
|
|
2082
|
+
height: tabHeight,
|
|
2083
|
+
contentHeight,
|
|
2084
|
+
logoSize
|
|
2085
|
+
} = useMemo3(() => densitySize(density), [density]);
|
|
2044
2086
|
const corner2 = useRef9(null);
|
|
2045
2087
|
const [reserve, setReserve] = useState5(0);
|
|
2046
2088
|
const hasTrailing = !!trailing;
|
|
@@ -2051,7 +2093,8 @@ function WorkspaceContent({
|
|
|
2051
2093
|
observer2.observe(element);
|
|
2052
2094
|
return () => observer2.disconnect();
|
|
2053
2095
|
}, [hasTrailing]);
|
|
2054
|
-
const
|
|
2096
|
+
const ownRoot = useRef9(null);
|
|
2097
|
+
const root = windowControlsOverlay?.root ?? ownRoot;
|
|
2055
2098
|
const [inset, setInset] = useState5(0);
|
|
2056
2099
|
useLayoutEffect8(() => {
|
|
2057
2100
|
if (!titleBar) return setInset(0);
|
|
@@ -2059,7 +2102,9 @@ function WorkspaceContent({
|
|
|
2059
2102
|
measure();
|
|
2060
2103
|
addEventListener("resize", measure);
|
|
2061
2104
|
return () => removeEventListener("resize", measure);
|
|
2062
|
-
}, [titleBar]);
|
|
2105
|
+
}, [titleBar, root]);
|
|
2106
|
+
const titlebarArea = windowControlsOverlay?.area;
|
|
2107
|
+
const height = Math.max(tabHeight, titlebarArea?.height ?? 0);
|
|
2063
2108
|
const preferredPane = useRef9(void 0);
|
|
2064
2109
|
const visibleLayout = reconcileLayout(
|
|
2065
2110
|
layout,
|
|
@@ -2123,7 +2168,7 @@ function WorkspaceContent({
|
|
|
2123
2168
|
active: pane.active,
|
|
2124
2169
|
focus: links.focus
|
|
2125
2170
|
});
|
|
2126
|
-
return /* @__PURE__ */ jsx6(
|
|
2171
|
+
return /* @__PURE__ */ jsx6(MinimumTabHeight.Provider, { value: titlebarArea?.height ?? 0, children: /* @__PURE__ */ jsxs5(
|
|
2127
2172
|
"div",
|
|
2128
2173
|
{
|
|
2129
2174
|
ref: root,
|
|
@@ -2131,6 +2176,7 @@ function WorkspaceContent({
|
|
|
2131
2176
|
"aria-label": "Workspace",
|
|
2132
2177
|
"data-density": density,
|
|
2133
2178
|
"data-title-bar": titleBar || void 0,
|
|
2179
|
+
"data-window-controls-overlay": titlebarArea ? "" : void 0,
|
|
2134
2180
|
style: {
|
|
2135
2181
|
"--lab-tab-height": `${height}px`,
|
|
2136
2182
|
"--lab-tab-content-height": `${contentHeight}px`,
|
|
@@ -2155,10 +2201,19 @@ function WorkspaceContent({
|
|
|
2155
2201
|
selected[(index + (event.shiftKey ? selected.length - 1 : 1)) % selected.length]?.focus();
|
|
2156
2202
|
},
|
|
2157
2203
|
children: [
|
|
2158
|
-
trailing && /* @__PURE__ */ jsx6(
|
|
2204
|
+
trailing && /* @__PURE__ */ jsx6(
|
|
2205
|
+
"div",
|
|
2206
|
+
{
|
|
2207
|
+
ref: corner2,
|
|
2208
|
+
className: "lab-trailing",
|
|
2209
|
+
style: { height, right: titlebarArea?.insetRight },
|
|
2210
|
+
children: trailing
|
|
2211
|
+
}
|
|
2212
|
+
),
|
|
2159
2213
|
/* @__PURE__ */ jsx6(
|
|
2160
2214
|
WorkspaceSurface,
|
|
2161
2215
|
{
|
|
2216
|
+
titlebarArea,
|
|
2162
2217
|
layout: visibleLayout,
|
|
2163
2218
|
change,
|
|
2164
2219
|
menu,
|