@liberation-data/desk 0.41.0 → 0.43.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 +152 -9
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/scheme.d.ts +12 -0
- package/dist/core/scheme.d.ts.map +1 -0
- package/dist/core/scheme.js +15 -0
- package/dist/core/scheme.js.map +1 -0
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/css/apps.css +149 -0
- package/dist/css/controls.css +21 -2
- package/dist/css/dock.css +1 -1
- package/dist/css/looks.css +50 -4
- package/dist/css/overlays.css +6 -0
- package/dist/css/tokens.css +1 -0
- package/dist/css/windows.css +173 -5
- package/dist/desk.css +401 -12
- package/dist/react/Desktop.d.ts +12 -3
- package/dist/react/Desktop.d.ts.map +1 -1
- package/dist/react/Desktop.js +29 -9
- package/dist/react/Desktop.js.map +1 -1
- package/dist/react/Dock.d.ts +6 -1
- package/dist/react/Dock.d.ts.map +1 -1
- package/dist/react/Dock.js +9 -1
- package/dist/react/Dock.js.map +1 -1
- package/dist/react/MenuBar.d.ts +8 -1
- package/dist/react/MenuBar.d.ts.map +1 -1
- package/dist/react/MenuBar.js +34 -5
- package/dist/react/MenuBar.js.map +1 -1
- package/dist/react/app.d.ts +174 -0
- package/dist/react/app.d.ts.map +1 -0
- package/dist/react/app.js +146 -0
- package/dist/react/app.js.map +1 -0
- package/dist/react/appPanels.d.ts +22 -0
- package/dist/react/appPanels.d.ts.map +1 -0
- package/dist/react/appPanels.js +114 -0
- package/dist/react/appPanels.js.map +1 -0
- package/dist/react/appearance.d.ts +55 -0
- package/dist/react/appearance.d.ts.map +1 -0
- package/dist/react/appearance.js +140 -0
- package/dist/react/appearance.js.map +1 -0
- 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/codeBlock.d.ts.map +1 -1
- package/dist/react/codeBlock.js +6 -60
- package/dist/react/codeBlock.js.map +1 -1
- package/dist/react/context.d.ts +9 -1
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js +47 -3
- package/dist/react/context.js.map +1 -1
- package/dist/react/copy.d.ts +22 -0
- package/dist/react/copy.d.ts.map +1 -0
- package/dist/react/copy.js +68 -0
- package/dist/react/copy.js.map +1 -0
- package/dist/react/documentTitle.d.ts.map +1 -1
- package/dist/react/documentTitle.js +4 -1
- package/dist/react/documentTitle.js.map +1 -1
- package/dist/react/index.d.ts +10 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +7 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/layers.d.ts.map +1 -1
- package/dist/react/layers.js +7 -2
- package/dist/react/layers.js.map +1 -1
- package/dist/react/overlays.d.ts.map +1 -1
- package/dist/react/overlays.js +29 -12
- package/dist/react/overlays.js.map +1 -1
- package/dist/react/shell.d.ts +4 -1
- package/dist/react/shell.d.ts.map +1 -1
- package/dist/react/shell.js +2 -2
- package/dist/react/shell.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 +75 -8
- package/package.json +1 -1
- package/src/core/index.ts +2 -0
- package/src/core/scheme.ts +21 -0
- package/src/core/types.ts +6 -0
- package/src/css/apps.css +149 -0
- package/src/css/controls.css +21 -2
- package/src/css/dock.css +1 -1
- package/src/css/looks.css +50 -4
- package/src/css/overlays.css +6 -0
- package/src/css/tokens.css +1 -0
- package/src/css/windows.css +173 -5
- package/src/react/Desktop.tsx +50 -12
- package/src/react/Dock.tsx +11 -1
- package/src/react/MenuBar.tsx +38 -5
- package/src/react/app.tsx +284 -0
- package/src/react/appPanels.tsx +197 -0
- package/src/react/appearance.tsx +204 -0
- package/src/react/arrange.ts +23 -0
- package/src/react/codeBlock.tsx +7 -65
- package/src/react/context.tsx +55 -3
- package/src/react/copy.ts +81 -0
- package/src/react/documentTitle.ts +4 -1
- package/src/react/index.ts +30 -1
- package/src/react/layers.ts +7 -2
- package/src/react/overlays.tsx +30 -12
- package/src/react/shell.tsx +5 -2
- package/src/react/tabs.tsx +23 -10
- package/src/react/widgets.tsx +265 -0
package/src/css/windows.css
CHANGED
|
@@ -185,16 +185,18 @@
|
|
|
185
185
|
color: var(--desk-muted);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
/* The note gives up the spare room; the (i) keeps its place at the end of the bar. */
|
|
189
188
|
/*
|
|
190
|
-
* The (i) is the bar's
|
|
191
|
-
*
|
|
189
|
+
* The (i) is on the bar's far edge, opposite the controls: here, on a Mac, it is the bar's last word, after
|
|
190
|
+
* the note and the actions. Whatever comes before it takes the spare room, and it follows. It sits in its
|
|
191
|
+
* popover's anchor, so the anchor is what the bar lays out: a margin on the button inside it would move
|
|
192
|
+
* nothing. The other looks put it first, and say so in looks.css.
|
|
192
193
|
*/
|
|
193
194
|
.desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
|
|
194
195
|
margin-left: auto;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
.desk-window-note ~ .desk-popover-anchor:has(> .desk-window-info)
|
|
198
|
+
.desk-window-note ~ .desk-popover-anchor:has(> .desk-window-info),
|
|
199
|
+
.desk-window-actions ~ .desk-popover-anchor:has(> .desk-window-info) {
|
|
198
200
|
margin-left: var(--desk-space-2);
|
|
199
201
|
}
|
|
200
202
|
|
|
@@ -243,6 +245,12 @@
|
|
|
243
245
|
margin-left: var(--desk-space-3);
|
|
244
246
|
}
|
|
245
247
|
|
|
248
|
+
/* The count has taken the spare room, so what follows it keeps to it rather than splitting the room. */
|
|
249
|
+
.desk-window-progress ~ .desk-window-actions,
|
|
250
|
+
.desk-window-progress ~ .desk-popover-anchor:has(> .desk-window-info) {
|
|
251
|
+
margin-left: var(--desk-space-2);
|
|
252
|
+
}
|
|
253
|
+
|
|
246
254
|
.desk-titlebar[data-progress] .desk-title,
|
|
247
255
|
.desk-titlebar[data-progress] .desk-window-note {
|
|
248
256
|
max-width: none;
|
|
@@ -270,7 +278,13 @@
|
|
|
270
278
|
.desk-window-progress-fill { transition: none; }
|
|
271
279
|
}
|
|
272
280
|
|
|
273
|
-
|
|
281
|
+
/* Narrower still, the count keeps its words and lets the track go, so the bar's far edge stays on the bar. */
|
|
282
|
+
@container (max-width: 400px) {
|
|
283
|
+
.desk-window-progress-track {
|
|
284
|
+
display: none;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
274
288
|
.desk-window-note + .desk-window-actions {
|
|
275
289
|
margin-left: var(--desk-space-1);
|
|
276
290
|
}
|
|
@@ -411,6 +425,139 @@
|
|
|
411
425
|
right: var(--desk-padding);
|
|
412
426
|
}
|
|
413
427
|
|
|
428
|
+
/* ── Widgets: glances in a corner of the stage, behind the windows unless the person keeps one in front ── */
|
|
429
|
+
|
|
430
|
+
/* As big as the stage, to ask its size. No z-index, so each widget stands behind or in front on its own. */
|
|
431
|
+
.desk-widgets {
|
|
432
|
+
container: desk-widgets / size;
|
|
433
|
+
position: absolute;
|
|
434
|
+
inset: 0;
|
|
435
|
+
pointer-events: none;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/*
|
|
439
|
+
* A margin of padding for the focus ring, which a list that scrolls would clip. Too many for the desk, and it
|
|
440
|
+
* scrolls: it takes the pointer, as a scroller without it is passed over by the wheel, a finger and its scrollbar.
|
|
441
|
+
*/
|
|
442
|
+
.desk-widget-list {
|
|
443
|
+
position: absolute;
|
|
444
|
+
pointer-events: auto;
|
|
445
|
+
box-sizing: border-box;
|
|
446
|
+
width: calc(var(--desk-widget-width) + 2 * var(--desk-space-1));
|
|
447
|
+
max-height: calc(100% - 2 * (var(--desk-padding) - var(--desk-space-1)) - var(--desk-inset-bottom));
|
|
448
|
+
padding: var(--desk-space-1);
|
|
449
|
+
display: flex;
|
|
450
|
+
flex-direction: column;
|
|
451
|
+
gap: var(--desk-space-2);
|
|
452
|
+
overflow: hidden auto;
|
|
453
|
+
scrollbar-width: thin;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.desk-widgets[data-corner^="top"] > .desk-widget-list {
|
|
457
|
+
top: calc(var(--desk-padding) - var(--desk-space-1));
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.desk-widgets[data-corner^="bottom"] > .desk-widget-list {
|
|
461
|
+
bottom: calc(var(--desk-padding) - var(--desk-space-1) + var(--desk-inset-bottom));
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.desk-widgets[data-corner$="left"] > .desk-widget-list {
|
|
465
|
+
left: calc(var(--desk-padding) - var(--desk-space-1));
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.desk-widgets[data-corner$="right"] > .desk-widget-list {
|
|
469
|
+
right: calc(var(--desk-padding) - var(--desk-space-1));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/* Behind: on the desk surface, over what the app draws on an empty desk; windows start at 10. */
|
|
473
|
+
.desk-widget {
|
|
474
|
+
flex: none;
|
|
475
|
+
box-sizing: border-box;
|
|
476
|
+
position: relative;
|
|
477
|
+
z-index: 1;
|
|
478
|
+
min-height: 44px;
|
|
479
|
+
padding: 0;
|
|
480
|
+
border: 1px solid var(--desk-rule);
|
|
481
|
+
border-radius: var(--desk-radius);
|
|
482
|
+
background: var(--desk-surface);
|
|
483
|
+
color: var(--desk-ink);
|
|
484
|
+
font-family: var(--desk-font);
|
|
485
|
+
font-size: var(--desk-text-body);
|
|
486
|
+
text-align: start;
|
|
487
|
+
overflow: clip;
|
|
488
|
+
overflow-wrap: anywhere;
|
|
489
|
+
user-select: none;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/* Its words, on an opaque surface. */
|
|
493
|
+
.desk-widget-surface {
|
|
494
|
+
display: block;
|
|
495
|
+
box-sizing: border-box;
|
|
496
|
+
min-height: 42px;
|
|
497
|
+
padding: var(--desk-space-2) var(--desk-space-3);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/* In front, by choice: a frame of the dock's glass round that surface, as a stack's panel. No shadow: the list clips it. */
|
|
501
|
+
.desk-widget[data-front] {
|
|
502
|
+
z-index: 800;
|
|
503
|
+
padding: var(--desk-space-1);
|
|
504
|
+
background: var(--desk-dock-glass);
|
|
505
|
+
backdrop-filter: blur(28px) saturate(170%);
|
|
506
|
+
-webkit-backdrop-filter: blur(28px) saturate(170%);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.desk-widget[data-front] > .desk-widget-surface {
|
|
510
|
+
/* The frame comes out of the padding: ticking one keeps its size. */
|
|
511
|
+
min-height: calc(42px - 2 * var(--desk-space-1));
|
|
512
|
+
padding: calc(var(--desk-space-2) - var(--desk-space-1)) calc(var(--desk-space-3) - var(--desk-space-1));
|
|
513
|
+
border-radius: max(0px, calc(var(--desk-radius) - var(--desk-space-1)));
|
|
514
|
+
background: var(--desk-surface);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
button.desk-widget {
|
|
518
|
+
cursor: pointer;
|
|
519
|
+
transition: border-color .12s var(--desk-ease);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
button.desk-widget:hover {
|
|
523
|
+
border-color: color-mix(in srgb, var(--desk-accent) 45%, var(--desk-rule));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.desk-widget:focus-visible {
|
|
527
|
+
outline: 2px solid var(--desk-accent);
|
|
528
|
+
outline-offset: 2px;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/* A tour pointing at them moves nothing, and its ring fits in that margin too. */
|
|
532
|
+
.desk-widget-list[data-desk-tour-pointed] {
|
|
533
|
+
position: absolute;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.desk-widget[data-desk-tour-pointed] {
|
|
537
|
+
outline-offset: 2px;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.desk-widget-unseen {
|
|
541
|
+
position: absolute;
|
|
542
|
+
width: 1px;
|
|
543
|
+
height: 1px;
|
|
544
|
+
overflow: hidden;
|
|
545
|
+
clip-path: inset(50%);
|
|
546
|
+
white-space: nowrap;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/* A desk this small belongs to the windows. */
|
|
550
|
+
@container desk-widgets (max-width: 640px) or (max-height: 400px) {
|
|
551
|
+
.desk-widget-list,
|
|
552
|
+
.desk-widgets > .desk-widget-unseen {
|
|
553
|
+
display: none;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
@media (forced-colors: active) {
|
|
558
|
+
button.desk-widget:hover { border-color: Highlight; }
|
|
559
|
+
}
|
|
560
|
+
|
|
414
561
|
/* ── The inside of a window: controls that stay, content that scrolls ── */
|
|
415
562
|
|
|
416
563
|
/* Two panels in one window, and the edge between them that moves. */
|
|
@@ -599,6 +746,27 @@
|
|
|
599
746
|
overflow: hidden;
|
|
600
747
|
}
|
|
601
748
|
|
|
749
|
+
/*
|
|
750
|
+
* A centred window that fits its content (`fitContent`) is as tall as what is in it, up to its max-height.
|
|
751
|
+
* Its height comes from its content rather than the content from its height, so a pane in it is not 100% of
|
|
752
|
+
* anything: it takes its own height and gives way, with the middle scrolling, once the window is at its cap.
|
|
753
|
+
*/
|
|
754
|
+
.desk-window[data-fit] {
|
|
755
|
+
height: fit-content;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
.desk-window[data-fit] > .desk-body {
|
|
759
|
+
flex: 0 1 auto;
|
|
760
|
+
display: flex;
|
|
761
|
+
flex-direction: column;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
.desk-window[data-fit] > .desk-body > * {
|
|
765
|
+
flex: 0 1 auto;
|
|
766
|
+
height: auto;
|
|
767
|
+
min-height: 0;
|
|
768
|
+
}
|
|
769
|
+
|
|
602
770
|
.desk-toolbar {
|
|
603
771
|
display: flex;
|
|
604
772
|
align-items: center;
|
package/src/react/Desktop.tsx
CHANGED
|
@@ -5,9 +5,14 @@ import { focusedId, isMinimized, onDesk } from '../core/desk.js'
|
|
|
5
5
|
import type { Desk } from '../core/desk.js'
|
|
6
6
|
import type { Look } from '../core/look.js'
|
|
7
7
|
import type { DeskWindow, Frame, WindowId, WindowLimits } from '../core/types.js'
|
|
8
|
-
import {
|
|
8
|
+
import { Widgets, widgetsKeptClear } from './widgets.js'
|
|
9
|
+
import type { Widget, WidgetCorner } from './widgets.js'
|
|
10
|
+
import { arrangement, areaAround } from './arrange.js'
|
|
9
11
|
import { InfoTip } from './infoTip.js'
|
|
10
12
|
import { useDesk, useDeskState, useLook, WindowContext } from './context.js'
|
|
13
|
+
import type { DeskApp } from './app.js'
|
|
14
|
+
import { ABOUT_WINDOW, appWindowLimits, appWindowTitle, desksWindow, SETTINGS_WINDOW, useDeskApp } from './app.js'
|
|
15
|
+
import { AboutContent, SettingsContent } from './appPanels.js'
|
|
11
16
|
import { WindowBoundary } from './windowBoundary.js'
|
|
12
17
|
import { TitleProgress } from './windowProgress.js'
|
|
13
18
|
import type { WindowProgress } from './windowProgress.js'
|
|
@@ -32,8 +37,8 @@ export interface DesktopProps {
|
|
|
32
37
|
*/
|
|
33
38
|
readonly limits?: (id: WindowId) => WindowLimits | null
|
|
34
39
|
/**
|
|
35
|
-
* What this window is, behind an (i)
|
|
36
|
-
* so a person who wonders what they are looking at always knows where to ask. Explanation only: a
|
|
40
|
+
* What this window is, behind an (i) on the far edge of its title bar, opposite the controls — the
|
|
41
|
+
* same place in every window, so a person who wonders what they are looking at always knows where to ask. Explanation only: a
|
|
37
42
|
* warning, or anything that changes what someone is about to do, belongs in the window itself.
|
|
38
43
|
*/
|
|
39
44
|
readonly info?: (id: WindowId) => ReactNode
|
|
@@ -50,9 +55,19 @@ export interface DesktopProps {
|
|
|
50
55
|
* window at a time; anything with a pointer gets the layered `desktop`.
|
|
51
56
|
*/
|
|
52
57
|
readonly layout?: DeskLayout | 'auto'
|
|
58
|
+
/**
|
|
59
|
+
* Glances stacked in a corner of the desk, clear of the dock: behind the windows, unless the person keeps
|
|
60
|
+
* one in front from the Window menu (`widgetMenuItems`). Not shown in the fullscreen layout, or on a desk
|
|
61
|
+
* too small to spare the room.
|
|
62
|
+
*/
|
|
63
|
+
readonly widgets?: readonly Widget[]
|
|
64
|
+
/** The corner they stand in: `top-right` unless said. Keep it clear in the app's default layout. */
|
|
65
|
+
readonly widgetCorner?: WidgetCorner
|
|
53
66
|
readonly className?: string
|
|
54
67
|
}
|
|
55
68
|
|
|
69
|
+
const NO_WIDGETS: readonly Widget[] = []
|
|
70
|
+
|
|
56
71
|
/** Touch-first: a coarse pointer that cannot hover. A tablet with a trackpad reports otherwise. */
|
|
57
72
|
const TOUCH = '(pointer: coarse) and (hover: none)'
|
|
58
73
|
|
|
@@ -88,18 +103,32 @@ function arrangementArea(stage: HTMLElement) {
|
|
|
88
103
|
return { x: left, y: top, width: stage.clientWidth - left - right, height: stage.clientHeight - top - bottom, gap }
|
|
89
104
|
}
|
|
90
105
|
|
|
106
|
+
const systemLimits = (app: DeskApp | null, id: WindowId): WindowLimits | null => {
|
|
107
|
+
const which = desksWindow(app, id)
|
|
108
|
+
return which ? appWindowLimits(app, which) : null
|
|
109
|
+
}
|
|
110
|
+
|
|
91
111
|
const halfFrame = (stage: HTMLElement, side: 'start' | 'end'): Frame => {
|
|
92
112
|
const area = arrangementArea(stage)
|
|
93
113
|
const width = (area.width - area.gap) / 2
|
|
94
114
|
return { x: side === 'start' ? area.x : area.x + width + area.gap, y: area.y, width, height: area.height }
|
|
95
115
|
}
|
|
96
116
|
|
|
97
|
-
export function Desktop({ renderWindow, title, note, info, actions, limits, empty, loading, failed, layout = 'auto', className }: DesktopProps) {
|
|
117
|
+
export function Desktop({ renderWindow, title, note, info, actions, limits, empty, loading, failed, layout = 'auto', widgets = NO_WIDGETS, widgetCorner = 'top-right', className }: DesktopProps) {
|
|
98
118
|
const desk = useDesk()
|
|
99
119
|
const state = useDeskState()
|
|
100
120
|
const stage = useRef<HTMLDivElement>(null)
|
|
101
121
|
const touch = useMediaQuery(TOUCH)
|
|
102
122
|
const mode: DeskLayout = layout === 'auto' ? (touch ? 'fullscreen' : 'desktop') : layout
|
|
123
|
+
// About and Settings, when the app has declared itself: Desk draws them, unless the app's Settings is its own.
|
|
124
|
+
const app = useDeskApp()
|
|
125
|
+
const ownsAbout = app !== null
|
|
126
|
+
const ownsSettings = desksWindow(app, SETTINGS_WINDOW) !== null
|
|
127
|
+
const render = useCallback(
|
|
128
|
+
(id: WindowId): ReactNode =>
|
|
129
|
+
ownsAbout && id === ABOUT_WINDOW ? <AboutContent /> : ownsSettings && id === SETTINGS_WINDOW ? <SettingsContent /> : renderWindow(id),
|
|
130
|
+
[renderWindow, ownsAbout, ownsSettings],
|
|
131
|
+
)
|
|
103
132
|
|
|
104
133
|
useLayoutEffect(() => {
|
|
105
134
|
desk.setStage(() => ({ width: stage.current?.clientWidth ?? 1024, height: stage.current?.clientHeight ?? 768 }))
|
|
@@ -189,6 +218,8 @@ export function Desktop({ renderWindow, title, note, info, actions, limits, empt
|
|
|
189
218
|
data-layout={mode}
|
|
190
219
|
{...{ [STAGE_ATTRIBUTE]: '' }}
|
|
191
220
|
>
|
|
221
|
+
{/* Still there with none to draw, so one taken away while it had the keyboard can hand it on. */}
|
|
222
|
+
<Widgets widgets={mode === 'desktop' ? widgets : NO_WIDGETS} corner={widgetCorner} />
|
|
192
223
|
{onDesk(state).length === 0 && empty}
|
|
193
224
|
{state.windows.map(window => (
|
|
194
225
|
<WindowView
|
|
@@ -201,15 +232,15 @@ export function Desktop({ renderWindow, title, note, info, actions, limits, empt
|
|
|
201
232
|
// touch, and minimizing, are the same thing to everything below this line.
|
|
202
233
|
hidden={(mode === 'fullscreen' && window.id !== focused) || isMinimized(state, window.id)}
|
|
203
234
|
minimized={isMinimized(state, window.id)}
|
|
204
|
-
title={title(window.id)}
|
|
235
|
+
title={appWindowTitle(app, window.id) ?? title(window.id)}
|
|
205
236
|
note={note?.(window.id)}
|
|
206
237
|
info={info?.(window.id)}
|
|
207
|
-
limits={limits?.(window.id) ??
|
|
238
|
+
limits={limits?.(window.id) ?? systemLimits(app, window.id)}
|
|
208
239
|
actions={actions?.(window.id)}
|
|
209
240
|
>
|
|
210
241
|
{/* Memoised on the id and the render function: moving or focusing a window
|
|
211
242
|
re-renders its chrome, never the app's content inside it. */}
|
|
212
|
-
<WindowContent id={window.id} render={
|
|
243
|
+
<WindowContent id={window.id} render={render} loading={loading} failed={failed} />
|
|
213
244
|
</WindowView>
|
|
214
245
|
))}
|
|
215
246
|
</div>
|
|
@@ -328,7 +359,10 @@ function arrangeNow(desk: Desk, element: HTMLElement) {
|
|
|
328
359
|
const windows = onDesk(state)
|
|
329
360
|
const stack = state.stack.filter(id => !isMinimized(state, id))
|
|
330
361
|
const [focused, previous] = [stack.at(-1), stack.at(-2)]
|
|
331
|
-
|
|
362
|
+
// Widgets kept in front have their corner; the windows are laid out in the rest.
|
|
363
|
+
const area = arrangementArea(element)
|
|
364
|
+
const clear = widgetsKeptClear(element, area.gap)
|
|
365
|
+
if (windows.length === 1 && !clear) {
|
|
332
366
|
if (focused) desk.fill(focused)
|
|
333
367
|
return
|
|
334
368
|
}
|
|
@@ -336,7 +370,7 @@ function arrangeNow(desk: Desk, element: HTMLElement) {
|
|
|
336
370
|
windows.map(w => w.id),
|
|
337
371
|
focused ?? null,
|
|
338
372
|
previous ?? null,
|
|
339
|
-
|
|
373
|
+
clear ? areaAround(area, clear) : area,
|
|
340
374
|
{ minWidth: MIN_WIDTH, minHeight: MIN_HEIGHT },
|
|
341
375
|
)
|
|
342
376
|
desk.placeAll(frames)
|
|
@@ -490,7 +524,11 @@ function WindowView({ window, layout, hidden, minimized, depth, focused, title,
|
|
|
490
524
|
)
|
|
491
525
|
const windowNote = note != null && note !== false && <p className="desk-window-note">{note}</p>
|
|
492
526
|
|
|
493
|
-
|
|
527
|
+
/*
|
|
528
|
+
* The (i) is on the bar's far edge, opposite the controls: last on a Mac bar, whose start is the
|
|
529
|
+
* controls', and first on the others, whose end is. It is put there in the document, not moved there
|
|
530
|
+
* by CSS, so Tab reaches it where it is seen, and it is in the same corner of every window of a look.
|
|
531
|
+
*/
|
|
494
532
|
const windowInfo = info != null && info !== false && (
|
|
495
533
|
<InfoTip
|
|
496
534
|
className="desk-window-info"
|
|
@@ -510,6 +548,7 @@ function WindowView({ window, layout, hidden, minimized, depth, focused, title,
|
|
|
510
548
|
className="desk-window"
|
|
511
549
|
data-mode={layout === 'fullscreen' ? 'fullscreen' : live ? 'floating' : window.mode}
|
|
512
550
|
data-centred={centred || undefined}
|
|
551
|
+
data-fit={(centred && limits?.fitContent) || undefined}
|
|
513
552
|
data-hidden={hidden || undefined}
|
|
514
553
|
data-minimized={minimized || undefined}
|
|
515
554
|
inert={hidden || undefined}
|
|
@@ -547,9 +586,8 @@ function WindowView({ window, layout, hidden, minimized, depth, focused, title,
|
|
|
547
586
|
{windowNote}
|
|
548
587
|
</>
|
|
549
588
|
)}
|
|
550
|
-
{look === 'mac' && windowInfo}
|
|
551
589
|
{actions && <div className="desk-window-actions">{actions}</div>}
|
|
552
|
-
{look
|
|
590
|
+
{look === 'mac' ? windowInfo : controls}
|
|
553
591
|
</header>
|
|
554
592
|
<div className="desk-body">{children}</div>
|
|
555
593
|
{layout === 'desktop' && (
|
package/src/react/Dock.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react'
|
|
|
2
2
|
import type { KeyboardEvent, ReactNode } from 'react'
|
|
3
3
|
import { focusedId, instancesOf, isMinimized, windowType } from '../core/desk.js'
|
|
4
4
|
import type { DeskState, WindowId } from '../core/types.js'
|
|
5
|
+
import { ABOUT_WINDOW, openPanel, openSettings, placeAppDockItems, useDeskApp } from './app.js'
|
|
5
6
|
import { useDesk, useDeskState } from './context.js'
|
|
6
7
|
import { useContextMenu } from './contextMenu.js'
|
|
7
8
|
import { useDragSource, useDropTarget } from './dnd.js'
|
|
@@ -59,6 +60,8 @@ export type DockEntry =
|
|
|
59
60
|
| ({ readonly type: 'item' } & DockItem)
|
|
60
61
|
| ({ readonly type: 'stack' } & DockStack)
|
|
61
62
|
| { readonly type: 'separator'; readonly id: string }
|
|
63
|
+
/** Where the app wants its Settings item: see `dockSettings()`. */
|
|
64
|
+
| { readonly type: 'settings'; readonly id: string }
|
|
62
65
|
|
|
63
66
|
export const dockItem = (item: DockItem): DockEntry => ({ type: 'item', ...item })
|
|
64
67
|
export const dockStack = (stack: DockStack): DockEntry => ({ type: 'stack', ...stack })
|
|
@@ -119,8 +122,15 @@ function roveFocus(event: KeyboardEvent<HTMLElement>, keys: { next: string[]; pr
|
|
|
119
122
|
target.focus()
|
|
120
123
|
}
|
|
121
124
|
|
|
122
|
-
export function Dock({ entries, label = 'Dock', placement = 'overlay', side = 'left', className, pins }: DockProps) {
|
|
125
|
+
export function Dock({ entries: given, label = 'Dock', placement = 'overlay', side = 'left', className, pins }: DockProps) {
|
|
123
126
|
const vertical = side !== 'bottom'
|
|
127
|
+
const desk = useDesk()
|
|
128
|
+
const app = useDeskApp()
|
|
129
|
+
// Settings and About, where every Desk app has them, when the app has declared itself.
|
|
130
|
+
const entries = placeAppDockItems(given, app, {
|
|
131
|
+
settings: () => openSettings(desk, app),
|
|
132
|
+
about: () => openPanel(desk, ABOUT_WINDOW),
|
|
133
|
+
})
|
|
124
134
|
const [openStack, setOpenStack] = useState<string | null>(null)
|
|
125
135
|
const firstFocusable = entries.find(e => e.type !== 'separator')?.id
|
|
126
136
|
const { dropProps } = useDropTarget({
|
package/src/react/MenuBar.tsx
CHANGED
|
@@ -7,8 +7,11 @@ import { bindShortcuts, formatShortcut, isApplePlatform } from '../core/shortcut
|
|
|
7
7
|
import type { Keymap } from '../core/shortcuts.js'
|
|
8
8
|
import type { Desk } from '../core/desk.js'
|
|
9
9
|
import type { DeskState, WindowId } from '../core/types.js'
|
|
10
|
+
import { ABOUT_WINDOW, boundByDesk, hostOwnsShortcuts, openPanel, placeAppMenuItems, useDeskApp } from './app.js'
|
|
10
11
|
import { useDesk, useDeskState } from './context.js'
|
|
11
12
|
import { hasModKey, hostMenuModel, sameHostModel } from './hostMenu.js'
|
|
13
|
+
import { isWidgetInFront, setWidgetInFront, useWidgetsInFront } from './widgets.js'
|
|
14
|
+
import type { Widget } from './widgets.js'
|
|
12
15
|
import type { HostMenu, MenuHost } from './hostMenu.js'
|
|
13
16
|
|
|
14
17
|
/*
|
|
@@ -77,6 +80,21 @@ export function windowMenuItems(state: DeskState, focus: (id: WindowId) => void,
|
|
|
77
80
|
)
|
|
78
81
|
}
|
|
79
82
|
|
|
83
|
+
/**
|
|
84
|
+
* "Widgets in front", and an item for each widget, ticked while it is kept in front of the windows: the
|
|
85
|
+
* section a Window menu carries, after a separator. Nothing at all when the app has no widgets, so the
|
|
86
|
+
* section is not there either. Choosing one brings it in front or sends it back, and that is remembered.
|
|
87
|
+
*/
|
|
88
|
+
export function widgetMenuItems(widgets: readonly Widget[]): MenuItem[] {
|
|
89
|
+
if (!widgets.length) return []
|
|
90
|
+
return [
|
|
91
|
+
menuHeader('Widgets in front'),
|
|
92
|
+
...widgets.map(({ id, label }) =>
|
|
93
|
+
menuAction(label, () => setWidgetInFront(id, !isWidgetInFront(id)), { checked: () => isWidgetInFront(id) }),
|
|
94
|
+
),
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
|
|
80
98
|
export interface MenuBarProps {
|
|
81
99
|
/** Menus on the leading side, in order. The first is conventionally the app's own. */
|
|
82
100
|
readonly menus: readonly Menu[]
|
|
@@ -160,15 +178,27 @@ export const typeAhead = (items: readonly Resolved[], from: number, letter: stri
|
|
|
160
178
|
return -1
|
|
161
179
|
}
|
|
162
180
|
|
|
163
|
-
/**
|
|
181
|
+
/**
|
|
182
|
+
* The shortcut of every command item in these menus, as `bindShortcuts` takes them; `keep` leaves some out.
|
|
183
|
+
* So do those Desk binds on the command itself (⌘, for Settings): the item shows it, and binding it here too would be twice.
|
|
184
|
+
*/
|
|
164
185
|
const menuKeymap = (menus: readonly Menu[], keep: (shortcut: string) => boolean = () => true): Keymap =>
|
|
165
186
|
Object.fromEntries(
|
|
166
187
|
menus
|
|
167
188
|
.flatMap(m => (typeof m.items === 'function' ? m.items() : m.items))
|
|
168
|
-
.flatMap(i => (i.type === 'command' && i.shortcut && keep(i.shortcut) ? [[i.shortcut, i.command] as const] : [])),
|
|
189
|
+
.flatMap(i => (i.type === 'command' && i.shortcut && !boundByDesk(i.shortcut, i.command) && keep(i.shortcut) ? [[i.shortcut, i.command] as const] : [])),
|
|
169
190
|
)
|
|
170
191
|
|
|
171
|
-
|
|
192
|
+
/** Whether a host gives this shortcut a key of its own: those it says, or else every one with `mod` in it. */
|
|
193
|
+
const ownedBy = (host: MenuHost) => (shortcut: string) => (host.ownsShortcut ? host.ownsShortcut(shortcut) : hasModKey(shortcut))
|
|
194
|
+
|
|
195
|
+
export function MenuBar(given: MenuBarProps) {
|
|
196
|
+
const desk = useDesk()
|
|
197
|
+
const app = useDeskApp()
|
|
198
|
+
// About and Settings at the top of the app menu, before either bar sees the menus: drawn or in a host's
|
|
199
|
+
// menu bar, they are there once. The item shows ⌘,; Desk binds it on the command, or the host owns it.
|
|
200
|
+
const menus = useMemo(() => placeAppMenuItems(given.menus, app, () => openPanel(desk, ABOUT_WINDOW)), [given.menus, app, desk])
|
|
201
|
+
const props = app ? { ...given, menus } : given
|
|
172
202
|
return props.host ? <HostedMenuBar {...props} host={props.host} /> : <DrawnMenuBar {...props} />
|
|
173
203
|
}
|
|
174
204
|
|
|
@@ -182,6 +212,7 @@ export function MenuBar(props: MenuBarProps) {
|
|
|
182
212
|
function HostedMenuBar({ menus, status = [], host, shortcuts = true }: MenuBarProps & { readonly host: MenuHost }) {
|
|
183
213
|
const desk = useDesk()
|
|
184
214
|
useDeskState() // a menu that lists the open windows changes when they do
|
|
215
|
+
useWidgetsInFront() // and one that ticks the widgets in front, when one is ticked
|
|
185
216
|
const apple = useMemo(isApplePlatform, [])
|
|
186
217
|
const model = hostMenuModel(menus, status, command => canPerform(desk, command))
|
|
187
218
|
|
|
@@ -242,10 +273,12 @@ function HostedMenuBar({ menus, status = [], host, shortcuts = true }: MenuBarPr
|
|
|
242
273
|
}
|
|
243
274
|
}, [desk, host, publish, refresh])
|
|
244
275
|
|
|
245
|
-
// The host gives its own shortcuts a key; the page binds the rest, read at each key press.
|
|
276
|
+
// The host gives its own shortcuts a key; the page binds the rest, read at each key press. Desk's own
|
|
277
|
+
// shortcuts (⌘,) step aside for the host's too, while it is up.
|
|
278
|
+
useEffect(() => hostOwnsShortcuts(desk, ownedBy(host)), [desk, host])
|
|
246
279
|
useEffect(() => {
|
|
247
280
|
if (!shortcuts) return undefined
|
|
248
|
-
const owns = (
|
|
281
|
+
const owns = ownedBy(host)
|
|
249
282
|
return bindShortcuts(desk, () => menuKeymap([...latest.current.menus, ...latest.current.status], shortcut => !owns(shortcut)), { apple })
|
|
250
283
|
}, [desk, host, shortcuts, apple])
|
|
251
284
|
|