@liberation-data/desk 0.40.1 → 0.42.0
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 +61 -8
- package/dist/css/controls.css +21 -2
- package/dist/css/dock.css +1 -1
- package/dist/css/looks.css +50 -4
- package/dist/css/tokens.css +1 -0
- package/dist/css/windows.css +165 -6
- package/dist/desk.css +238 -13
- package/dist/react/Desktop.d.ts +12 -3
- package/dist/react/Desktop.d.ts.map +1 -1
- package/dist/react/Desktop.js +20 -10
- package/dist/react/Desktop.js.map +1 -1
- package/dist/react/MenuBar.d.ts +9 -2
- package/dist/react/MenuBar.d.ts.map +1 -1
- package/dist/react/MenuBar.js +15 -0
- package/dist/react/MenuBar.js.map +1 -1
- package/dist/react/arrange.d.ts +6 -0
- package/dist/react/arrange.d.ts.map +1 -1
- package/dist/react/arrange.js +21 -0
- package/dist/react/arrange.js.map +1 -1
- package/dist/react/hostMenu.d.ts +6 -0
- package/dist/react/hostMenu.d.ts.map +1 -1
- package/dist/react/hostMenu.js +1 -0
- package/dist/react/hostMenu.js.map +1 -1
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/tabs.d.ts +7 -1
- package/dist/react/tabs.d.ts.map +1 -1
- package/dist/react/tabs.js +13 -8
- package/dist/react/tabs.js.map +1 -1
- package/dist/react/widgets.d.ts +33 -0
- package/dist/react/widgets.d.ts.map +1 -0
- package/dist/react/widgets.js +213 -0
- package/dist/react/widgets.js.map +1 -0
- package/llms.txt +33 -7
- package/package.json +2 -2
- package/src/css/controls.css +21 -2
- package/src/css/dock.css +1 -1
- package/src/css/looks.css +50 -4
- package/src/css/tokens.css +1 -0
- package/src/css/windows.css +165 -6
- package/src/react/Desktop.tsx +33 -11
- package/src/react/MenuBar.tsx +20 -2
- package/src/react/arrange.ts +23 -0
- package/src/react/hostMenu.ts +7 -0
- package/src/react/index.ts +3 -1
- package/src/react/tabs.tsx +23 -10
- package/src/react/widgets.tsx +265 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
3
|
+
import { STAGE_ATTRIBUTE, WINDOW_ATTRIBUTE, windowElement } from '../core/commands.js';
|
|
4
|
+
import { focusedId } from '../core/desk.js';
|
|
5
|
+
import { useDesk } from './context.js';
|
|
6
|
+
/*
|
|
7
|
+
* Which widgets the person keeps in front of the windows: their choice, remembered in this browser under
|
|
8
|
+
* `desk.widgets.<id>`, as a split remembers its size. Behind is the default, so only "front" is written.
|
|
9
|
+
*/
|
|
10
|
+
const storageKey = (id) => `desk.widgets.${id}`;
|
|
11
|
+
const listeners = new Set();
|
|
12
|
+
let version = 0;
|
|
13
|
+
const changed = () => {
|
|
14
|
+
version++;
|
|
15
|
+
listeners.forEach(listener => listener());
|
|
16
|
+
};
|
|
17
|
+
/** Whether the person has asked for this widget to stay in front of the windows. */
|
|
18
|
+
export function isWidgetInFront(id) {
|
|
19
|
+
try {
|
|
20
|
+
return globalThis.localStorage?.getItem(storageKey(id)) === 'front';
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Keeps a widget in front of the windows, or sends it back behind them, and remembers which. */
|
|
27
|
+
export function setWidgetInFront(id, front) {
|
|
28
|
+
try {
|
|
29
|
+
if (front)
|
|
30
|
+
globalThis.localStorage?.setItem(storageKey(id), 'front');
|
|
31
|
+
else
|
|
32
|
+
globalThis.localStorage?.removeItem(storageKey(id));
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Private windows and full storage: it still comes forward, just not after a reload.
|
|
36
|
+
}
|
|
37
|
+
changed();
|
|
38
|
+
}
|
|
39
|
+
// Another tab of the same app ticking one.
|
|
40
|
+
const fromAnotherTab = (event) => {
|
|
41
|
+
if (event.key === null || event.key.startsWith('desk.widgets.'))
|
|
42
|
+
changed();
|
|
43
|
+
};
|
|
44
|
+
function subscribe(listener) {
|
|
45
|
+
if (listeners.size === 0 && typeof window !== 'undefined')
|
|
46
|
+
window.addEventListener('storage', fromAnotherTab);
|
|
47
|
+
listeners.add(listener);
|
|
48
|
+
return () => {
|
|
49
|
+
listeners.delete(listener);
|
|
50
|
+
if (listeners.size === 0 && typeof window !== 'undefined')
|
|
51
|
+
window.removeEventListener('storage', fromAnotherTab);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Re-renders when a widget is brought in front or sent back, here or in another tab; returns `isWidgetInFront`. */
|
|
55
|
+
export function useWidgetsInFront() {
|
|
56
|
+
const now = useSyncExternalStore(subscribe, () => version, () => -1);
|
|
57
|
+
// A new function each time the answer may have changed, so it can be a dependency.
|
|
58
|
+
return useCallback((id) => now >= 0 && isWidgetInFront(id), [now]);
|
|
59
|
+
}
|
|
60
|
+
const overlaps = (a, b) => a.width > 0 && a.height > 0 && b.width > 0 && b.height > 0 &&
|
|
61
|
+
a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
|
62
|
+
const sameSet = (a, b) => a.size === b.size && [...a].every(id => b.has(id));
|
|
63
|
+
/** Drawn by `Desktop`, inside the stage: that is what keeps them clear of the dock on every side. */
|
|
64
|
+
export function Widgets({ widgets, corner }) {
|
|
65
|
+
const desk = useDesk();
|
|
66
|
+
const inFront = useWidgetsInFront();
|
|
67
|
+
const box = useRef(null);
|
|
68
|
+
const list = useRef(null);
|
|
69
|
+
/*
|
|
70
|
+
* Behind the windows, a widget a window covers is out of reach: inert, so Tab and a screen reader pass
|
|
71
|
+
* it by as the eye does. One the desk shows, with no window over it, can still be clicked and tabbed to.
|
|
72
|
+
*/
|
|
73
|
+
const [covered, setCovered] = useState(() => new Set());
|
|
74
|
+
const reachable = (id) => inFront(id) || !covered.has(id);
|
|
75
|
+
// One tab stop: the widget last focused while it is there to press, else the first that can be.
|
|
76
|
+
const [current, setCurrent] = useState(null);
|
|
77
|
+
/*
|
|
78
|
+
* Those kept in front stand nearest the corner, the rest beyond them, in the order given otherwise: so
|
|
79
|
+
* the room Arrange leaves the ones in front holds none behind, and a widget behind is never half out
|
|
80
|
+
* from under a window. The document follows the order drawn, so Tab and the arrows do too.
|
|
81
|
+
*/
|
|
82
|
+
const top = !corner.startsWith('bottom');
|
|
83
|
+
const ordered = [...widgets.filter(w => inFront(w.id) === top), ...widgets.filter(w => inFront(w.id) !== top)];
|
|
84
|
+
const stops = ordered.filter(w => w.onSelect && reachable(w.id)).map(w => w.id);
|
|
85
|
+
const stop = current !== null && stops.includes(current) ? current : stops[0];
|
|
86
|
+
const focusWindow = () => {
|
|
87
|
+
const key = focusedId(desk.getState());
|
|
88
|
+
const window = key === null ? null : windowElement(document, key);
|
|
89
|
+
if (window instanceof HTMLElement)
|
|
90
|
+
window.focus({ preventScroll: true });
|
|
91
|
+
};
|
|
92
|
+
const buttons = () => [...(list.current?.querySelectorAll(':scope > button:not([inert])') ?? [])];
|
|
93
|
+
// Which widgets are under a window: measured after every render, and whenever the desk changes size.
|
|
94
|
+
const measure = () => {
|
|
95
|
+
const element = list.current;
|
|
96
|
+
const stage = element?.closest(`[${STAGE_ATTRIBUTE}]`);
|
|
97
|
+
if (!element || !stage)
|
|
98
|
+
return;
|
|
99
|
+
const windows = [...stage.querySelectorAll(`[${WINDOW_ATTRIBUTE}]:not([data-hidden])`)].map(w => w.getBoundingClientRect());
|
|
100
|
+
const next = new Set();
|
|
101
|
+
for (const child of element.querySelectorAll(':scope > [data-widget]')) {
|
|
102
|
+
const box = child.getBoundingClientRect();
|
|
103
|
+
if (windows.some(w => overlaps(box, w)))
|
|
104
|
+
next.add(child.dataset.widget);
|
|
105
|
+
}
|
|
106
|
+
// A window came over the widget that had the keyboard: it goes to the key window, not to nowhere.
|
|
107
|
+
const holder = document.activeElement?.closest('[data-widget]')?.dataset.widget;
|
|
108
|
+
if (holder !== undefined && next.has(holder) && !inFront(holder) && element.contains(document.activeElement))
|
|
109
|
+
focusWindow();
|
|
110
|
+
setCovered(was => (sameSet(was, next) ? was : next));
|
|
111
|
+
};
|
|
112
|
+
const latest = useRef(measure);
|
|
113
|
+
latest.current = measure;
|
|
114
|
+
useLayoutEffect(() => latest.current());
|
|
115
|
+
const shown = widgets.length > 0;
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
if (!shown || !box.current || typeof ResizeObserver === 'undefined')
|
|
118
|
+
return undefined;
|
|
119
|
+
const observer = new ResizeObserver(() => latest.current());
|
|
120
|
+
observer.observe(box.current);
|
|
121
|
+
return () => observer.disconnect();
|
|
122
|
+
}, [shown]);
|
|
123
|
+
// Taken away while it had the keyboard, a widget hands it to the one after it, the one before, or the key window.
|
|
124
|
+
const held = useRef(null);
|
|
125
|
+
const order = ordered.map(w => w.id);
|
|
126
|
+
const before = useRef(order);
|
|
127
|
+
useLayoutEffect(() => {
|
|
128
|
+
const was = before.current;
|
|
129
|
+
before.current = order;
|
|
130
|
+
const id = held.current;
|
|
131
|
+
if (id === null || list.current?.contains(document.activeElement))
|
|
132
|
+
return;
|
|
133
|
+
held.current = null;
|
|
134
|
+
// Something else has taken focus already: a dialog the widget opened.
|
|
135
|
+
if (document.activeElement && document.activeElement !== document.body)
|
|
136
|
+
return;
|
|
137
|
+
const at = was.indexOf(id);
|
|
138
|
+
const next = [...was.slice(at + 1), ...was.slice(0, at).reverse()].find(other => stops.includes(other));
|
|
139
|
+
if (next === undefined)
|
|
140
|
+
focusWindow();
|
|
141
|
+
else
|
|
142
|
+
buttons()[stops.indexOf(next)]?.focus({ preventScroll: true });
|
|
143
|
+
});
|
|
144
|
+
const onKeyDown = (event) => {
|
|
145
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
146
|
+
return;
|
|
147
|
+
// Escape goes back to the key window, from a control in the content too, though not from something that control opened elsewhere.
|
|
148
|
+
if (event.key === 'Escape' && event.currentTarget.contains(event.target))
|
|
149
|
+
return focusWindow();
|
|
150
|
+
const all = buttons();
|
|
151
|
+
const at = all.indexOf(event.target);
|
|
152
|
+
if (at < 0)
|
|
153
|
+
return;
|
|
154
|
+
const next = event.key === 'ArrowDown' ? all[(at + 1) % all.length]
|
|
155
|
+
: event.key === 'ArrowUp' ? all[(at - 1 + all.length) % all.length]
|
|
156
|
+
: event.key === 'Home' ? all[0]
|
|
157
|
+
: event.key === 'End' ? all.at(-1)
|
|
158
|
+
: undefined;
|
|
159
|
+
if (!next)
|
|
160
|
+
return;
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
next.focus();
|
|
163
|
+
};
|
|
164
|
+
const onBlur = ({ target }) => {
|
|
165
|
+
// Another tab or application came forward: this still has the keyboard when the browser comes back.
|
|
166
|
+
if (document.activeElement === target)
|
|
167
|
+
return;
|
|
168
|
+
held.current = null;
|
|
169
|
+
// The desk was made too small to show them.
|
|
170
|
+
if (target.checkVisibility?.() === false)
|
|
171
|
+
focusWindow();
|
|
172
|
+
};
|
|
173
|
+
if (!widgets.length)
|
|
174
|
+
return null;
|
|
175
|
+
return (_jsxs("div", { ref: box, className: "desk-widgets", "data-corner": corner, children: [_jsx("div", { ref: list, className: "desk-widget-list", role: stops.length ? 'toolbar' : 'group', "aria-label": "Widgets", "aria-orientation": stops.length ? 'vertical' : undefined, onKeyDown: onKeyDown, onBlur: onBlur, children: ordered.map(({ id, label, content, onSelect }) => {
|
|
176
|
+
const shared = {
|
|
177
|
+
'data-widget': id,
|
|
178
|
+
'data-front': inFront(id) || undefined,
|
|
179
|
+
inert: !reachable(id) || undefined,
|
|
180
|
+
};
|
|
181
|
+
return onSelect ? (_jsxs("button", { type: "button", className: "desk-widget", ...shared, tabIndex: id === stop ? 0 : -1, onFocus: () => {
|
|
182
|
+
held.current = id;
|
|
183
|
+
setCurrent(id);
|
|
184
|
+
}, onClick: () => onSelect(), children: [_jsx("span", { className: "desk-widget-unseen", children: label }), ' ', _jsx("span", { className: "desk-widget-surface", children: content })] }, id)) : (_jsx("div", { className: "desk-widget", ...shared, role: "group", "aria-label": label, onFocus: () => (held.current = id), children: _jsx("div", { className: "desk-widget-surface", children: content }) }, id));
|
|
185
|
+
}) }), _jsx("div", { className: "desk-widget-unseen", "aria-live": "polite", children: widgets.map(({ id, announce }) => announce && _jsx("p", { children: announce }, id)) })] }));
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The corner of the stage that Arrange leaves to the widgets kept in front, in stage coordinates: from the
|
|
189
|
+
* stage's corner to the far side of the last one, and a gap beyond. `null` when none is in front, or shown.
|
|
190
|
+
*/
|
|
191
|
+
export function widgetsKeptClear(stage, gap) {
|
|
192
|
+
const box = stage.querySelector(':scope > .desk-widgets');
|
|
193
|
+
const drawn = (selector) => [...(box?.querySelectorAll(selector) ?? [])].map(w => w.getBoundingClientRect()).filter(r => r.width > 0 && r.height > 0);
|
|
194
|
+
const front = drawn('.desk-widget[data-front]');
|
|
195
|
+
const behind = drawn('.desk-widget:not([data-front])');
|
|
196
|
+
if (!box || !front.length)
|
|
197
|
+
return null;
|
|
198
|
+
const origin = stage.getBoundingClientRect();
|
|
199
|
+
const corner = box.dataset.corner ?? 'top-right';
|
|
200
|
+
const left = Math.min(...front.map(r => r.left)) - origin.left - gap;
|
|
201
|
+
const right = Math.max(...front.map(r => r.right)) - origin.left + gap;
|
|
202
|
+
const [first, last] = [Math.min(...front.map(r => r.top)), Math.max(...front.map(r => r.bottom))];
|
|
203
|
+
// No further than the widgets behind, which stand beyond them: the windows then cover those whole.
|
|
204
|
+
const top = Math.max(first - gap, ...behind.map(r => r.bottom).filter(edge => edge <= first)) - origin.top;
|
|
205
|
+
const bottom = Math.min(last + gap, ...behind.map(r => r.top).filter(edge => edge >= last)) - origin.top;
|
|
206
|
+
const [vertical, horizontal] = corner.split('-');
|
|
207
|
+
const x = horizontal === 'left' ? 0 : Math.max(0, left);
|
|
208
|
+
const y = vertical === 'top' ? 0 : Math.max(0, top);
|
|
209
|
+
const width = horizontal === 'left' ? right : stage.clientWidth - x;
|
|
210
|
+
const height = vertical === 'top' ? bottom : stage.clientHeight - y;
|
|
211
|
+
return { x, y, width, height };
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=widgets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgets.js","sourceRoot":"","sources":["../../src/react/widgets.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAE5F,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAiBtC;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAAA;AACvD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AACvC,IAAI,OAAO,GAAG,CAAC,CAAA;AAEf,MAAM,OAAO,GAAG,GAAG,EAAE;IACnB,OAAO,EAAE,CAAA;IACT,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;AAC3C,CAAC,CAAA;AAED,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,CAAA;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,gBAAgB,CAAC,EAAU,EAAE,KAAc;IACzD,IAAI,CAAC;QACH,IAAI,KAAK;YAAE,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,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAA;IACnE,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAA;IACnE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAChC,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @liberation-data/desk
|
|
2
2
|
|
|
3
|
-
A desktop for
|
|
3
|
+
A desktop environment for React apps: windows that fill the desk, layered, and arrange when asked, with a dock, a menu bar,
|
|
4
4
|
commands routed to whoever is responsible, and the controls to fill the windows. Apache-2.0.
|
|
5
5
|
|
|
6
6
|
This file is the whole public surface in one place, for a coding agent. Prose for people:
|
|
@@ -268,7 +268,7 @@ useWindowInfo(info: ReactNode): boolean // this view's (i) in place
|
|
|
268
268
|
renderWindow={(id) => ReactNode} // memoised: chrome re-renders, content does not
|
|
269
269
|
title={(id) => ReactNode}
|
|
270
270
|
note?={(id) => ReactNode} // quiet text in the title bar: what this window is looking at
|
|
271
|
-
info?={(id) => ReactNode} // an (i)
|
|
271
|
+
info?={(id) => ReactNode} // an (i) on the bar's far edge from the controls (end on mac, start on gnome/windows): what this window IS
|
|
272
272
|
limits?={(id) => ({ maxWidth?, maxHeight?, minWidth?, minHeight? } | null)} // a window with a natural
|
|
273
273
|
// size is never stretched past it; filled, it centres
|
|
274
274
|
actions?={(id) => ReactNode} // window-wide controls in the title bar
|
|
@@ -276,10 +276,35 @@ useWindowInfo(info: ReactNode): boolean // this view's (i) in place
|
|
|
276
276
|
failed?={(id, error, reload) => ReactNode} // inside a window that could not open
|
|
277
277
|
empty?={ReactNode}
|
|
278
278
|
layout?={'auto' | 'desktop' | 'fullscreen'} // auto: touch screens get one window at a time
|
|
279
|
+
widgets?={Widget[]} // glances in a corner of the desk, behind the windows unless kept in front
|
|
280
|
+
widgetCorner?={'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'} // default top-right
|
|
279
281
|
className?={string}
|
|
280
282
|
/>
|
|
281
283
|
```
|
|
282
284
|
|
|
285
|
+
### Widgets
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
interface Widget { id: string; label: string; content: ReactNode; onSelect?: () => void; announce?: string }
|
|
289
|
+
widgetMenuItems(widgets): MenuItem[] // [] for none; else header "Widgets in front" + a checkable item each
|
|
290
|
+
isWidgetInFront(id): boolean
|
|
291
|
+
setWidgetInFront(id, front: boolean): void // remembered in localStorage under `desk.widgets.<id>`
|
|
292
|
+
useWidgetsInFront(): (id) => boolean // re-renders when a tick changes, here or in another tab
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
`<Desktop widgets>` stacks them in order, in one corner, clear of the dock and of each other, **behind the
|
|
296
|
+
windows**. Only the person brings one in front: put `...(widgets.length ? [menuSeparator(), ...widgetMenuItems(widgets)] : [])`
|
|
297
|
+
in the Window menu; a tick keeps that widget in front (a dock-glass frame round an opaque surface; those in front stand nearest the
|
|
298
|
+
corner, ahead of those behind, in DOM order too), and Arrange then lays the windows out
|
|
299
|
+
around its corner (a column or a strip, whichever leaves more room). Widgets behind take no room from Arrange.
|
|
300
|
+
A widget behind that a window covers is `inert`: out of Tab order and the accessibility tree. `onSelect` makes one
|
|
301
|
+
a button (so no controls in `content`) and should open the window it is about; without it, it only shows. `label`
|
|
302
|
+
is read before the content and not drawn (don't repeat it in the content), and names it in the menu. Content
|
|
303
|
+
changes are not announced; `announce` is said politely when it changes. The buttons within reach are one tab stop
|
|
304
|
+
(Up/Down, Home/End; Escape to the key window). Not shown in the fullscreen layout, or when the stage is at most
|
|
305
|
+
640px wide or 400px tall, so never the only place something is said. Width: `--desk-widget-width`. Too many for
|
|
306
|
+
the height scroll.
|
|
307
|
+
|
|
283
308
|
### Loading and failing, per window
|
|
284
309
|
|
|
285
310
|
```tsx
|
|
@@ -338,9 +363,9 @@ Pins: the app stores kept items and passes them back as entries. A drop on the d
|
|
|
338
363
|
<MenuBar menus={Menu[]} status?={Menu[]} leading?={ReactNode} trailing?={ReactNode} shortcuts?={true} host?={MenuHost} />
|
|
339
364
|
// host: a native menu bar (Electron, Tauri). The bar draws nothing and publishes menus + status as data:
|
|
340
365
|
interface MenuHost { publish(menus: HostMenu[]): void; onSelect(listener: (id: string) => void): () => void; ownsShortcut?(s: string): boolean }
|
|
341
|
-
interface HostMenu { id; label; primary?; status?; items: { type: 'item'|'separator'|'header'; id?; label?; detail?; shortcut?; enabled?; checked? }[] }
|
|
366
|
+
interface HostMenu { id; label; primary?; status?; items: { type: 'item'|'separator'|'header'; id?; label?; detail?; shortcut?; showOnly?; enabled?; checked? }[] }
|
|
342
367
|
// leading/trailing do not cross; a status menu crosses with its label, not its title. Default: host owns `mod` shortcuts.
|
|
343
|
-
// An action's shortcut
|
|
368
|
+
// An action's shortcut crosses showOnly: the host shows it, the app binds it, as with the drawn bar. shortcuts={false} stops the page binding, not the host.
|
|
344
369
|
// Republished on render and focus move only; a choice is re-checked before it runs.
|
|
345
370
|
hostMenuModel(menus, status, canPerform): { model: HostMenu[]; run: Map<id, MenuItem> } // the same data, for a host built by hand
|
|
346
371
|
hasModKey(shortcut): boolean // the default ownsShortcut: has `mod` in it
|
|
@@ -350,6 +375,7 @@ menuCommand(label, command, { shortcut?, checked?, detail?, args? })
|
|
|
350
375
|
menuAction(label, onSelect, { disabled?, shortcut?, checked?, detail? })
|
|
351
376
|
menuSeparator(); menuHeader(label)
|
|
352
377
|
windowMenuItems(state, focus, title): MenuItem[]
|
|
378
|
+
widgetMenuItems(widgets): MenuItem[] // "Widgets in front" + a checkable item per widget; [] for none (see Widgets)
|
|
353
379
|
|
|
354
380
|
const { target, menu, open } = useContextMenu({ label, items: () => MenuItem[], disabled? })
|
|
355
381
|
// spread `target` (onContextMenu, onKeyDown) on the element; render `menu` anywhere (portal).
|
|
@@ -449,7 +475,7 @@ SearchCommand = 'desk.search' // a menu item can open i
|
|
|
449
475
|
// on dark it is the surface lightened and tinted 14% with the accent;
|
|
450
476
|
// --desk-segment-thumb replaces its fill
|
|
451
477
|
// track is 32px tall (26 small), 4 more than a button
|
|
452
|
-
<Tabs tabs={{value,label,badge?,disabled
|
|
478
|
+
<Tabs tabs={{value,label,badge?,disabled?: true | "why"}[]} value onChange label actions?>{selected view}</Tabs>
|
|
453
479
|
// switches the view below; a segmented control chooses
|
|
454
480
|
<Toggle checked onChange label? description? disabled? aria-label? /> // applies at once
|
|
455
481
|
<Checkbox checked indeterminate? onChange label? description? disabled? /> // waits for Save
|
|
@@ -598,7 +624,7 @@ Every value reads a `--desk-*` token; redefine tokens, never override selectors.
|
|
|
598
624
|
`--desk-ok|warn|bad`, `--desk-on-accent`. Spacing `--desk-space-1..7` = 4, 8, 12, 16, 24, 32, 48 px. Also
|
|
599
625
|
`--desk-radius`, `--desk-control-height`, `--desk-control-radius`, `--desk-font`, `--desk-font-mono`,
|
|
600
626
|
`--desk-ease`, `--desk-dock-size`, `--desk-dock-glass`, `--desk-dock-offset`, `--desk-dock-room`,
|
|
601
|
-
`--desk-inset-bottom`, `--desk-wizard-height`, `--desk-field-gap`. Code colours (`CodeBlock`, on `--desk-page`):
|
|
627
|
+
`--desk-widget-width`, `--desk-inset-bottom`, `--desk-wizard-height`, `--desk-field-gap`. Code colours (`CodeBlock`, on `--desk-page`):
|
|
602
628
|
`--desk-code-comment|string|keyword|number|key`, 4.5:1 in light and dark.
|
|
603
629
|
|
|
604
630
|
Light and dark follow `prefers-color-scheme`; `data-theme="light" | "dark"` on the root wins. The look is
|
|
@@ -644,7 +670,7 @@ in the accessibility tree.
|
|
|
644
670
|
- A `DeskProvider` already carries an event bus; `BusProvider` is only for supplying or sharing one.
|
|
645
671
|
- `renderWindow` must be stable (module scope or `useCallback`) for the memoisation to hold.
|
|
646
672
|
- `parse`/`syncWithLocation` warn once when no `isKnown` is given: unknown ids from a URL are then trusted.
|
|
647
|
-
- `npm run size` enforces a gzipped budget: core 16 KiB, react
|
|
673
|
+
- `npm run size` enforces a gzipped budget: core 16 KiB, react 76 KiB, css 24 KiB, fx 5 KiB.
|
|
648
674
|
- `fx.play` never resumes audio itself: outside a press a browser's resume may never settle. Call
|
|
649
675
|
`fx.unlock()` at startup, or nothing sounds until a press after the sound was due.
|
|
650
676
|
- The package is ESM only, with `"sideEffects": ["**/*.css"]`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liberation-data/desk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A desktop
|
|
3
|
+
"version": "0.42.0",
|
|
4
|
+
"description": "A desktop environment for React apps: windows, a dock, menus and commands, controls, tours and setup assistants.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"desktop",
|
package/src/css/controls.css
CHANGED
|
@@ -815,7 +815,7 @@
|
|
|
815
815
|
transition: background .12s var(--desk-ease), color .12s var(--desk-ease);
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
.desk-tab:hover:not(:disabled):not([aria-selected="true"]) {
|
|
818
|
+
.desk-tab:hover:not(:disabled):not([aria-disabled="true"]):not([aria-selected="true"]) {
|
|
819
819
|
background: color-mix(in srgb, var(--desk-ink) 6%, transparent);
|
|
820
820
|
color: var(--desk-ink);
|
|
821
821
|
}
|
|
@@ -831,11 +831,30 @@
|
|
|
831
831
|
outline-offset: -2px;
|
|
832
832
|
}
|
|
833
833
|
|
|
834
|
-
.desk-tab:disabled
|
|
834
|
+
.desk-tab:disabled,
|
|
835
|
+
.desk-tab[aria-disabled="true"] {
|
|
835
836
|
opacity: .45;
|
|
836
837
|
cursor: default;
|
|
837
838
|
}
|
|
838
839
|
|
|
840
|
+
/* An unavailable tab the arrows stop on: the ring is drawn in full, the label stays dimmed. */
|
|
841
|
+
.desk-tab[aria-disabled="true"]:focus-visible {
|
|
842
|
+
opacity: 1;
|
|
843
|
+
color: color-mix(in srgb, var(--desk-muted) 45%, transparent);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/* Why a tab is unavailable: read by a screen reader, shown to a pointer as the tab's title. */
|
|
847
|
+
.desk-tab-why {
|
|
848
|
+
position: absolute;
|
|
849
|
+
width: 1px;
|
|
850
|
+
height: 1px;
|
|
851
|
+
margin: -1px;
|
|
852
|
+
padding: 0;
|
|
853
|
+
overflow: hidden;
|
|
854
|
+
clip-path: inset(50%);
|
|
855
|
+
white-space: nowrap;
|
|
856
|
+
}
|
|
857
|
+
|
|
839
858
|
.desk-tab-badge {
|
|
840
859
|
min-width: 18px;
|
|
841
860
|
padding: 0 5px;
|
package/src/css/dock.css
CHANGED
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
height: 100%;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
/* A dot for "a window is open", brighter when it has focus. */
|
|
223
|
+
/* A dot for "a window is open", brighter when it has focus: a 4px dot 2px off its tile. */
|
|
224
224
|
.desk-dock-item[data-running]::after {
|
|
225
225
|
content: "";
|
|
226
226
|
position: absolute;
|
package/src/css/looks.css
CHANGED
|
@@ -49,11 +49,20 @@
|
|
|
49
49
|
font-size: var(--desk-text-small);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/*
|
|
53
|
-
|
|
52
|
+
/*
|
|
53
|
+
* The end of the bar is the controls', so the (i) is at its start, on the far edge (it is first in the
|
|
54
|
+
* document). It takes the spare room after it, and nothing else in the bar reaches for any: an auto
|
|
55
|
+
* margin on both sides of it would centre it in the room, under the heading.
|
|
56
|
+
*/
|
|
57
|
+
[data-look="gnome"] .desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
|
|
58
|
+
margin-left: 0;
|
|
54
59
|
margin-right: auto;
|
|
55
60
|
}
|
|
56
61
|
|
|
62
|
+
[data-look="gnome"] .desk-window-actions {
|
|
63
|
+
margin-left: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
/*
|
|
58
67
|
* The middle is the heading's, so the count waits at the end of the bar, before the controls, and
|
|
59
68
|
* the heading keeps clear of both. A narrow bar keeps the count and lets the track go.
|
|
@@ -61,6 +70,7 @@
|
|
|
61
70
|
[data-look="gnome"] .desk-window-progress {
|
|
62
71
|
position: static;
|
|
63
72
|
transform: none;
|
|
73
|
+
margin-left: 0;
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
[data-look="gnome"] .desk-titlebar[data-progress] .desk-titlebar-heading {
|
|
@@ -138,6 +148,11 @@
|
|
|
138
148
|
height: 5px;
|
|
139
149
|
}
|
|
140
150
|
|
|
151
|
+
/* The (i) is first in the document, at the start of the bar: the end is the controls'. */
|
|
152
|
+
[data-look="windows"] .desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
|
|
153
|
+
margin-left: 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
141
156
|
[data-look="windows"] .desk-title {
|
|
142
157
|
flex: 1 1 auto;
|
|
143
158
|
font-size: var(--desk-text-small);
|
|
@@ -190,7 +205,8 @@
|
|
|
190
205
|
* inside them, come out dark too — as the shell's own menus do.
|
|
191
206
|
*/
|
|
192
207
|
[data-look="gnome"] .desk-menubar,
|
|
193
|
-
[data-look="gnome"] .desk-dock
|
|
208
|
+
[data-look="gnome"] .desk-dock,
|
|
209
|
+
[data-look="gnome"] .desk-widget[data-front] {
|
|
194
210
|
--desk-ink: #ffffff;
|
|
195
211
|
--desk-muted: rgb(255 255 255 / 68%);
|
|
196
212
|
--desk-surface: #2a2a2a;
|
|
@@ -225,8 +241,13 @@
|
|
|
225
241
|
color: var(--desk-ink);
|
|
226
242
|
}
|
|
227
243
|
|
|
228
|
-
|
|
244
|
+
/* A widget kept in front is the dash's material too. */
|
|
245
|
+
[data-look="gnome"] .desk-dock,
|
|
246
|
+
[data-look="gnome"] .desk-widget[data-front] {
|
|
229
247
|
--desk-dock-glass: rgb(24 24 24 / 86%);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
[data-look="gnome"] .desk-dock {
|
|
230
251
|
border-radius: 20px;
|
|
231
252
|
}
|
|
232
253
|
|
|
@@ -235,6 +256,31 @@
|
|
|
235
256
|
border-radius: 12px;
|
|
236
257
|
}
|
|
237
258
|
|
|
259
|
+
/*
|
|
260
|
+
* The running dot by the glyph, as GNOME's dash has it: its tiles are transparent, so 3px off a tile no one sees is out
|
|
261
|
+
* by the dock's edge. The glyph is 46% of its item, centred (a stack's 72%), so its edge is 27% (14%) in; the 4px dot
|
|
262
|
+
* stands 4px off that, on whichever side the dock is.
|
|
263
|
+
*/
|
|
264
|
+
[data-look="gnome"] .desk-dock {
|
|
265
|
+
--desk-dock-dot-glyph: calc(27% - 8px);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
[data-look="gnome"] .desk-dock .desk-dock-item[data-stack] {
|
|
269
|
+
--desk-dock-dot-glyph: calc(14% - 8px);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
[data-look="gnome"] .desk-dock[data-side="bottom"] .desk-dock-item[data-running]::after {
|
|
273
|
+
bottom: var(--desk-dock-dot-glyph);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
[data-look="gnome"] .desk-dock[data-side="left"] .desk-dock-item[data-running]::after {
|
|
277
|
+
left: var(--desk-dock-dot-glyph);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
[data-look="gnome"] .desk-dock[data-side="right"] .desk-dock-item[data-running]::after {
|
|
281
|
+
right: var(--desk-dock-dot-glyph);
|
|
282
|
+
}
|
|
283
|
+
|
|
238
284
|
/* No magnification: GNOME's dash lights an item up rather than growing it. */
|
|
239
285
|
[data-look="gnome"] .desk-dock .desk-dock-item:hover:not(:disabled),
|
|
240
286
|
[data-look="windows"] .desk-dock .desk-dock-item:hover:not(:disabled) {
|
package/src/css/tokens.css
CHANGED
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
--desk-dock-icon: linear-gradient(160deg, #ffffff, #eceff5);
|
|
85
85
|
--desk-badge: #ef4444;
|
|
86
86
|
--desk-badge-ink: #ffffff;
|
|
87
|
+
--desk-widget-width: 200px;
|
|
87
88
|
/* Room the stage leaves at the bottom for something of the app's own. An overlay dock makes its own. */
|
|
88
89
|
--desk-inset-bottom: 0px;
|
|
89
90
|
}
|