@liberation-data/desk 0.37.0 → 0.38.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 CHANGED
@@ -293,6 +293,28 @@ and a terminal's grey in a dark one. A trace of the accent is mixed into it, `--
293
293
  sheet belongs to the theme it is read in; set that to `0%` for the neutral alone. `fill` makes it at least as tall as the room it is given, so a short
294
294
  section is still a whole sheet.
295
295
 
296
+ ### Two sections of one app: a split
297
+
298
+ ```tsx
299
+ import { Split } from '@liberation-data/desk/react'
300
+
301
+ <Split side={<Catalogue />} remember="studio.explore">
302
+ <Canvas />
303
+ </Split>
304
+ ```
305
+
306
+ A picker and the canvas it fills, or a list and its detail, are one app, so they are one window. Two windows
307
+ placed side by side drift apart and can be pulled apart. In a split they open, close and move together, and
308
+ only the edge between them moves. Drag the edge, or focus it and use the arrow keys. Home makes the side
309
+ section as narrow as it goes, and Enter or a double-click puts it back. With `remember`, the width is kept
310
+ in this browser, so the section opens the way it was left.
311
+
312
+ `size` is where the side section starts (280px), `min` the narrowest it goes (200px), and `max` the most of
313
+ the window it may take, as CSS (`50%`), so a width remembered from a big screen still leaves room on a
314
+ small one. `at="end"` puts it on the right. Dragging from one section to the other is the ordinary
315
+ `useDragSource` and `useDropTarget` (see [Dragging between windows](#dragging-between-windows)), which
316
+ works the same inside one window. The garage sample's Workshop window is Service beside Rides.
317
+
296
318
  `InfoTip` is an (i) holding what the view would explain if asked, so a window does not open with a
297
319
  paragraph everyone reads once. Explanation only: a warning belongs in front of people, not behind a
298
320
  disclosure.
@@ -502,6 +524,8 @@ content: the steps are the app's.
502
524
 
503
525
  ## Dragging between windows
504
526
 
527
+ The same hooks drag between the sections of one window, such as from a `Split`'s side section to the rest.
528
+
505
529
  ```tsx
506
530
  // In the list — one source, because a hook cannot be called per row
507
531
  const rides = useDragSource<Ride>({ type: 'ride' })
@@ -402,6 +402,58 @@
402
402
 
403
403
  /* ── The inside of a window: controls that stay, content that scrolls ── */
404
404
 
405
+ /* Two panels in one window, and the edge between them that moves. */
406
+ .desk-split {
407
+ display: grid;
408
+ grid-template-columns: var(--desk-split-size) auto minmax(0, 1fr);
409
+ height: 100%;
410
+ min-height: 0;
411
+ }
412
+
413
+ .desk-split[data-at="end"] {
414
+ grid-template-columns: minmax(0, 1fr) auto var(--desk-split-size);
415
+ }
416
+
417
+ .desk-split[data-dragging] {
418
+ user-select: none;
419
+ cursor: col-resize;
420
+ }
421
+
422
+ .desk-split-panel {
423
+ display: flex;
424
+ flex-direction: column;
425
+ min-width: 0;
426
+ min-height: 0;
427
+ overflow: hidden;
428
+ }
429
+
430
+ /* A hairline to see, and a wider strip either side of it to catch. */
431
+ .desk-split-edge {
432
+ position: relative;
433
+ width: 1px;
434
+ background: var(--desk-rule);
435
+ cursor: col-resize;
436
+ touch-action: none;
437
+ outline: none;
438
+ /* Above the panels, so the strip it catches with is not covered by something positioned in them. */
439
+ z-index: 1;
440
+ }
441
+
442
+ /* 13px to catch with: a hairline you can see, and enough either side that you need not aim for it. */
443
+ .desk-split-edge::before {
444
+ content: "";
445
+ position: absolute;
446
+ inset: 0 -6px;
447
+ }
448
+
449
+ .desk-split-edge:hover,
450
+ .desk-split-edge:focus-visible,
451
+ .desk-split[data-dragging] > .desk-split-edge {
452
+ background: var(--desk-accent);
453
+ box-shadow: 0 0 0 1px var(--desk-accent);
454
+ }
455
+
456
+
405
457
  .desk-pane {
406
458
  display: flex;
407
459
  flex-direction: column;
package/dist/desk.css CHANGED
@@ -555,6 +555,58 @@
555
555
 
556
556
  /* ── The inside of a window: controls that stay, content that scrolls ── */
557
557
 
558
+ /* Two panels in one window, and the edge between them that moves. */
559
+ .desk-split {
560
+ display: grid;
561
+ grid-template-columns: var(--desk-split-size) auto minmax(0, 1fr);
562
+ height: 100%;
563
+ min-height: 0;
564
+ }
565
+
566
+ .desk-split[data-at="end"] {
567
+ grid-template-columns: minmax(0, 1fr) auto var(--desk-split-size);
568
+ }
569
+
570
+ .desk-split[data-dragging] {
571
+ user-select: none;
572
+ cursor: col-resize;
573
+ }
574
+
575
+ .desk-split-panel {
576
+ display: flex;
577
+ flex-direction: column;
578
+ min-width: 0;
579
+ min-height: 0;
580
+ overflow: hidden;
581
+ }
582
+
583
+ /* A hairline to see, and a wider strip either side of it to catch. */
584
+ .desk-split-edge {
585
+ position: relative;
586
+ width: 1px;
587
+ background: var(--desk-rule);
588
+ cursor: col-resize;
589
+ touch-action: none;
590
+ outline: none;
591
+ /* Above the panels, so the strip it catches with is not covered by something positioned in them. */
592
+ z-index: 1;
593
+ }
594
+
595
+ /* 13px to catch with: a hairline you can see, and enough either side that you need not aim for it. */
596
+ .desk-split-edge::before {
597
+ content: "";
598
+ position: absolute;
599
+ inset: 0 -6px;
600
+ }
601
+
602
+ .desk-split-edge:hover,
603
+ .desk-split-edge:focus-visible,
604
+ .desk-split[data-dragging] > .desk-split-edge {
605
+ background: var(--desk-accent);
606
+ box-shadow: 0 0 0 1px var(--desk-accent);
607
+ }
608
+
609
+
558
610
  .desk-pane {
559
611
  display: flex;
560
612
  flex-direction: column;
@@ -30,6 +30,8 @@ export { PageDots, pageWindow } from './pageDots.js';
30
30
  export type { PageDot, PageDotsProps } from './pageDots.js';
31
31
  export type { LedColor, LedProps } from './led.js';
32
32
  export { Page, Pane, PaneHeader, Section, Toolbar } from './pane.js';
33
+ export { Split } from './split.js';
34
+ export type { SplitProps } from './split.js';
33
35
  export type { PageProps, PaneHeaderProps, PaneProps, SectionProps, ToolbarProps } from './pane.js';
34
36
  export { InfoTip } from './infoTip.js';
35
37
  export type { InfoTipProps } from './infoTip.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC1E,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,YAAY,EAA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,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC/E,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
@@ -15,6 +15,7 @@ export { useWindowInfo, useWindowNote } from './windowDescription.js';
15
15
  export { Led } from './led.js';
16
16
  export { PageDots, pageWindow } from './pageDots.js';
17
17
  export { Page, Pane, PaneHeader, Section, Toolbar } from './pane.js';
18
+ export { Split } from './split.js';
18
19
  export { InfoTip } from './infoTip.js';
19
20
  export { Checklist, useTasks } from './tasks.js';
20
21
  export { localSetupStore, useSetupProgress } from './setupProgress.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAWhG,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAExG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEnF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,UAAU,EAAE,eAAe,E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AE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAErG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE9E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface SplitProps {
3
+ /** The panel at the edge: a list, a picker, an outline. */
4
+ readonly side: ReactNode;
5
+ /** The rest of the window: what the side panel chooses for. */
6
+ readonly children: ReactNode;
7
+ /** Which edge the side panel stands at. Default `start`. */
8
+ readonly at?: 'start' | 'end';
9
+ /** The side panel's width, in px, until it is dragged. Default 280. */
10
+ readonly size?: number;
11
+ /** The narrowest it can be dragged to. Default 200. */
12
+ readonly min?: number;
13
+ /**
14
+ * The most of the window it may take, as CSS: `50%` (the default), `420px`. A width remembered from
15
+ * a big screen never leaves a small one without room for the rest.
16
+ */
17
+ readonly max?: string;
18
+ /** Remembers the width in this browser under this key, so the panel opens at the width it was left at. */
19
+ readonly remember?: string;
20
+ /** What the edge is called to assistive technology. Default "Resize". */
21
+ readonly label?: string;
22
+ readonly className?: string;
23
+ }
24
+ export declare function Split({ side, children, at, size, min, max, remember, label, className }: SplitProps): import("react").JSX.Element;
25
+ //# sourceMappingURL=split.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/react/split.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYvG,MAAM,WAAW,UAAU;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,uDAAuD;IACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,0GAA0G;IAC1G,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AA2BD,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAY,EAAE,IAAU,EAAE,GAAS,EAAE,GAAW,EAAE,QAAQ,EAAE,KAAgB,EAAE,SAAS,EAAE,EAAE,UAAU,+BAmG5I"}
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef, useState } from 'react';
3
+ /** How far an arrow key moves the edge. */
4
+ const STEP = 16;
5
+ const key = (name) => `desk.split.${name}`;
6
+ function recall(name, fallback, min) {
7
+ if (!name)
8
+ return fallback;
9
+ try {
10
+ const stored = Number(globalThis.localStorage?.getItem(key(name)));
11
+ // Storage is outside the program: anything that is not a usable width is none.
12
+ return Number.isFinite(stored) && stored >= min ? stored : fallback;
13
+ }
14
+ catch {
15
+ return fallback;
16
+ }
17
+ }
18
+ function keep(name, width) {
19
+ if (!name)
20
+ return;
21
+ try {
22
+ globalThis.localStorage?.setItem(key(name), String(width));
23
+ }
24
+ catch {
25
+ // Private windows and full storage: the panel still resizes, it just opens at its default.
26
+ }
27
+ }
28
+ export function Split({ side, children, at = 'start', size = 280, min = 200, max = '50%', remember, label = 'Resize', className }) {
29
+ const initial = Math.max(min, size);
30
+ const [width, setWidth] = useState(() => recall(remember, initial, min));
31
+ const root = useRef(null);
32
+ const panel = useRef(null);
33
+ const length = (px) => `min(${px}px, ${max})`;
34
+ const commit = (next) => {
35
+ const clamped = Math.max(min, Math.round(next));
36
+ setWidth(clamped);
37
+ keep(remember, clamped);
38
+ };
39
+ /*
40
+ * While dragging, only the variable on this element changes, so the panels follow the pointer
41
+ * without re-rendering what is in them; the width is committed once, on release. It starts from
42
+ * the width as drawn, which `max` may have capped, so the edge never lags behind the pointer.
43
+ */
44
+ const startDrag = (event) => {
45
+ if (event.button !== 0)
46
+ return;
47
+ event.preventDefault();
48
+ const handle = event.currentTarget;
49
+ const element = root.current;
50
+ const origin = panel.current?.getBoundingClientRect().width ?? width;
51
+ const startX = event.clientX;
52
+ let next = origin;
53
+ handle.setPointerCapture?.(event.pointerId);
54
+ if (element)
55
+ element.dataset.dragging = '';
56
+ const onMove = (move) => {
57
+ // Towards the middle is wider, whichever edge the panel is at.
58
+ const pulled = at === 'start' ? move.clientX - startX : startX - move.clientX;
59
+ next = Math.max(min, origin + pulled);
60
+ element?.style.setProperty('--desk-split-size', length(next));
61
+ };
62
+ const onUp = () => {
63
+ handle.removeEventListener('pointermove', onMove);
64
+ handle.removeEventListener('pointerup', onUp);
65
+ handle.removeEventListener('pointercancel', onUp);
66
+ if (element)
67
+ delete element.dataset.dragging;
68
+ // Back to what React drew, so the commit is what draws the new width, and a click draws nothing.
69
+ element?.style.setProperty('--desk-split-size', length(width));
70
+ if (Math.round(next) !== Math.round(origin))
71
+ commit(next);
72
+ };
73
+ handle.addEventListener('pointermove', onMove);
74
+ handle.addEventListener('pointerup', onUp);
75
+ handle.addEventListener('pointercancel', onUp);
76
+ };
77
+ // The edge is a separator that can be focused, so the width can be set without a pointer.
78
+ const onKeyDown = (event) => {
79
+ const wider = at === 'start' ? 'ArrowRight' : 'ArrowLeft';
80
+ const narrower = at === 'start' ? 'ArrowLeft' : 'ArrowRight';
81
+ const drawn = panel.current?.getBoundingClientRect().width || width;
82
+ if (event.key === wider)
83
+ commit(drawn + STEP);
84
+ else if (event.key === narrower)
85
+ commit(drawn - STEP);
86
+ else if (event.key === 'Home')
87
+ commit(min);
88
+ else if (event.key === 'Enter')
89
+ commit(initial);
90
+ else
91
+ return;
92
+ event.preventDefault();
93
+ };
94
+ const sidePanel = (_jsx("div", { ref: panel, className: "desk-split-panel", "data-side": "", children: side }, "side"));
95
+ const edge = (_jsx("div", { role: "separator", "aria-orientation": "vertical", "aria-label": label, "aria-valuenow": width, "aria-valuemin": min, tabIndex: 0, className: "desk-split-edge", onPointerDown: startDrag, onKeyDown: onKeyDown,
96
+ // Back to the width it started at, as a double-click on a divider does on a Mac.
97
+ onDoubleClick: () => commit(initial) }, "edge"));
98
+ const main = (_jsx("div", { className: "desk-split-panel", children: children }, "main"));
99
+ return (_jsx("div", { ref: root, className: ['desk-split', className].filter(Boolean).join(' '), "data-at": at, style: { '--desk-split-size': length(width) }, children: at === 'start' ? [sidePanel, edge, main] : [main, edge, sidePanel] }));
100
+ }
101
+ //# sourceMappingURL=split.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.js","sourceRoot":"","sources":["../../src/react/split.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAoCxC,2CAA2C;AAC3C,MAAM,IAAI,GAAG,EAAE,CAAA;AAEf,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,cAAc,IAAI,EAAE,CAAA;AAElD,SAAS,MAAM,CAAC,IAAwB,EAAE,QAAgB,EAAE,GAAW;IACrE,IAAI,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAA;IAC1B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAClE,+EAA+E;QAC/E,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAA;IACjB,CAAC;AACH,CAAC;AAED,SAAS,IAAI,CAAC,IAAwB,EAAE,KAAa;IACnD,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,IAAI,CAAC;QACH,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,2FAA2F;IAC7F,CAAC;AACH,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,KAAK,EAAE,QAAQ,EAAE,KAA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,kBAAkB,YACzC,QAAQ,IADF,MAAM,CAET,CACP,CAAA;IAED,OAAO,CACL,cACE,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aACrD,EAAE,EACX,KAAK,EAAE,EAAE,mBAAmB,EAAE,MAAM,CAAC,KAAK,CAAC,EAAmB,YAG7D,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,GAC/D,CACP,CAAA;AACH,CAAC"}
package/llms.txt CHANGED
@@ -299,6 +299,10 @@ window; `lazyWindow` retries its import on reload, unlike `React.lazy`, which ca
299
299
  <PaneHeader title={ReactNode} actions?={ReactNode} /> // the pane's title and its Refresh, on one row
300
300
  <Section title={ReactNode} actions?={ReactNode}>{content}</Section> // a titled group inside a pane
301
301
  <Toolbar label?={string} trailing?={ReactNode}>{controls}</Toolbar> // className="desk-grow" takes spare room
302
+ <Split side={ReactNode} at?={'start'|'end'} size?={280} min?={200} max?={'50%'} remember?={key} label?={string}>{rest}</Split>
303
+ // two sections of one app in one window, with a draggable edge between them (arrow keys, Home, Enter or
304
+ // double-click to reset); remember keeps the width in localStorage. Drag and drop between the sections is
305
+ // useDragSource/useDropTarget as anywhere else. One app, one window: use this, not two windows side by side.
302
306
  <Page label?={string} fill?>{long text}</Page> // a sheet for text read at length, on --desk-page; fill = at least the room's height
303
307
  // --desk-page-tint (4% light, 5% dark) is how much --desk-accent is mixed into the page; 0% for the neutral alone.
304
308
  // text size by class, never px: desk-text-body | desk-text-small | desk-text-caption, plus desk-text-muted.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liberation-data/desk",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "A desktop for the web, for React: windows, a dock, menus and commands, controls, tours and setup assistants.",
5
5
  "keywords": [
6
6
  "react",
@@ -401,6 +401,58 @@
401
401
 
402
402
  /* ── The inside of a window: controls that stay, content that scrolls ── */
403
403
 
404
+ /* Two panels in one window, and the edge between them that moves. */
405
+ .desk-split {
406
+ display: grid;
407
+ grid-template-columns: var(--desk-split-size) auto minmax(0, 1fr);
408
+ height: 100%;
409
+ min-height: 0;
410
+ }
411
+
412
+ .desk-split[data-at="end"] {
413
+ grid-template-columns: minmax(0, 1fr) auto var(--desk-split-size);
414
+ }
415
+
416
+ .desk-split[data-dragging] {
417
+ user-select: none;
418
+ cursor: col-resize;
419
+ }
420
+
421
+ .desk-split-panel {
422
+ display: flex;
423
+ flex-direction: column;
424
+ min-width: 0;
425
+ min-height: 0;
426
+ overflow: hidden;
427
+ }
428
+
429
+ /* A hairline to see, and a wider strip either side of it to catch. */
430
+ .desk-split-edge {
431
+ position: relative;
432
+ width: 1px;
433
+ background: var(--desk-rule);
434
+ cursor: col-resize;
435
+ touch-action: none;
436
+ outline: none;
437
+ /* Above the panels, so the strip it catches with is not covered by something positioned in them. */
438
+ z-index: 1;
439
+ }
440
+
441
+ /* 13px to catch with: a hairline you can see, and enough either side that you need not aim for it. */
442
+ .desk-split-edge::before {
443
+ content: "";
444
+ position: absolute;
445
+ inset: 0 -6px;
446
+ }
447
+
448
+ .desk-split-edge:hover,
449
+ .desk-split-edge:focus-visible,
450
+ .desk-split[data-dragging] > .desk-split-edge {
451
+ background: var(--desk-accent);
452
+ box-shadow: 0 0 0 1px var(--desk-accent);
453
+ }
454
+
455
+
404
456
  .desk-pane {
405
457
  display: flex;
406
458
  flex-direction: column;
@@ -52,6 +52,8 @@ export { PageDots, pageWindow } from './pageDots.js'
52
52
  export type { PageDot, PageDotsProps } from './pageDots.js'
53
53
  export type { LedColor, LedProps } from './led.js'
54
54
  export { Page, Pane, PaneHeader, Section, Toolbar } from './pane.js'
55
+ export { Split } from './split.js'
56
+ export type { SplitProps } from './split.js'
55
57
  export type { PageProps, PaneHeaderProps, PaneProps, SectionProps, ToolbarProps } from './pane.js'
56
58
  export { InfoTip } from './infoTip.js'
57
59
  export type { InfoTipProps } from './infoTip.js'
@@ -0,0 +1,161 @@
1
+ import { useRef, useState } from 'react'
2
+ import type { CSSProperties, KeyboardEvent, PointerEvent as ReactPointerEvent, ReactNode } from 'react'
3
+
4
+ /*
5
+ * Two panels in one window, with the edge between them to drag: a list beside its detail, a picker
6
+ * beside the canvas it fills.
7
+ *
8
+ * They are one app, so they are one window: they open, close, minimize and move together, and
9
+ * nothing can pull them apart. Only the edge between them moves, and it is remembered, so the side
10
+ * panel opens at the width it was left at. Dragging things from one panel to the other is the
11
+ * ordinary drag and drop (`useDragSource`, `useDropTarget`), which does not care where its ends are.
12
+ */
13
+
14
+ export interface SplitProps {
15
+ /** The panel at the edge: a list, a picker, an outline. */
16
+ readonly side: ReactNode
17
+ /** The rest of the window: what the side panel chooses for. */
18
+ readonly children: ReactNode
19
+ /** Which edge the side panel stands at. Default `start`. */
20
+ readonly at?: 'start' | 'end'
21
+ /** The side panel's width, in px, until it is dragged. Default 280. */
22
+ readonly size?: number
23
+ /** The narrowest it can be dragged to. Default 200. */
24
+ readonly min?: number
25
+ /**
26
+ * The most of the window it may take, as CSS: `50%` (the default), `420px`. A width remembered from
27
+ * a big screen never leaves a small one without room for the rest.
28
+ */
29
+ readonly max?: string
30
+ /** Remembers the width in this browser under this key, so the panel opens at the width it was left at. */
31
+ readonly remember?: string
32
+ /** What the edge is called to assistive technology. Default "Resize". */
33
+ readonly label?: string
34
+ readonly className?: string
35
+ }
36
+
37
+ /** How far an arrow key moves the edge. */
38
+ const STEP = 16
39
+
40
+ const key = (name: string) => `desk.split.${name}`
41
+
42
+ function recall(name: string | undefined, fallback: number, min: number): number {
43
+ if (!name) return fallback
44
+ try {
45
+ const stored = Number(globalThis.localStorage?.getItem(key(name)))
46
+ // Storage is outside the program: anything that is not a usable width is none.
47
+ return Number.isFinite(stored) && stored >= min ? stored : fallback
48
+ } catch {
49
+ return fallback
50
+ }
51
+ }
52
+
53
+ function keep(name: string | undefined, width: number) {
54
+ if (!name) return
55
+ try {
56
+ globalThis.localStorage?.setItem(key(name), String(width))
57
+ } catch {
58
+ // Private windows and full storage: the panel still resizes, it just opens at its default.
59
+ }
60
+ }
61
+
62
+ export function Split({ side, children, at = 'start', size = 280, min = 200, max = '50%', remember, label = 'Resize', className }: SplitProps) {
63
+ const initial = Math.max(min, size)
64
+ const [width, setWidth] = useState(() => recall(remember, initial, min))
65
+ const root = useRef<HTMLDivElement>(null)
66
+ const panel = useRef<HTMLDivElement>(null)
67
+ const length = (px: number) => `min(${px}px, ${max})`
68
+
69
+ const commit = (next: number) => {
70
+ const clamped = Math.max(min, Math.round(next))
71
+ setWidth(clamped)
72
+ keep(remember, clamped)
73
+ }
74
+
75
+ /*
76
+ * While dragging, only the variable on this element changes, so the panels follow the pointer
77
+ * without re-rendering what is in them; the width is committed once, on release. It starts from
78
+ * the width as drawn, which `max` may have capped, so the edge never lags behind the pointer.
79
+ */
80
+ const startDrag = (event: ReactPointerEvent<HTMLDivElement>) => {
81
+ if (event.button !== 0) return
82
+ event.preventDefault()
83
+ const handle = event.currentTarget
84
+ const element = root.current
85
+ const origin = panel.current?.getBoundingClientRect().width ?? width
86
+ const startX = event.clientX
87
+ let next = origin
88
+ handle.setPointerCapture?.(event.pointerId)
89
+ if (element) element.dataset.dragging = ''
90
+ const onMove = (move: PointerEvent) => {
91
+ // Towards the middle is wider, whichever edge the panel is at.
92
+ const pulled = at === 'start' ? move.clientX - startX : startX - move.clientX
93
+ next = Math.max(min, origin + pulled)
94
+ element?.style.setProperty('--desk-split-size', length(next))
95
+ }
96
+ const onUp = () => {
97
+ handle.removeEventListener('pointermove', onMove)
98
+ handle.removeEventListener('pointerup', onUp)
99
+ handle.removeEventListener('pointercancel', onUp)
100
+ if (element) delete element.dataset.dragging
101
+ // Back to what React drew, so the commit is what draws the new width, and a click draws nothing.
102
+ element?.style.setProperty('--desk-split-size', length(width))
103
+ if (Math.round(next) !== Math.round(origin)) commit(next)
104
+ }
105
+ handle.addEventListener('pointermove', onMove)
106
+ handle.addEventListener('pointerup', onUp)
107
+ handle.addEventListener('pointercancel', onUp)
108
+ }
109
+
110
+ // The edge is a separator that can be focused, so the width can be set without a pointer.
111
+ const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
112
+ const wider = at === 'start' ? 'ArrowRight' : 'ArrowLeft'
113
+ const narrower = at === 'start' ? 'ArrowLeft' : 'ArrowRight'
114
+ const drawn = panel.current?.getBoundingClientRect().width || width
115
+ if (event.key === wider) commit(drawn + STEP)
116
+ else if (event.key === narrower) commit(drawn - STEP)
117
+ else if (event.key === 'Home') commit(min)
118
+ else if (event.key === 'Enter') commit(initial)
119
+ else return
120
+ event.preventDefault()
121
+ }
122
+
123
+ const sidePanel = (
124
+ <div key="side" ref={panel} className="desk-split-panel" data-side="">
125
+ {side}
126
+ </div>
127
+ )
128
+ const edge = (
129
+ <div
130
+ key="edge"
131
+ role="separator"
132
+ aria-orientation="vertical"
133
+ aria-label={label}
134
+ aria-valuenow={width}
135
+ aria-valuemin={min}
136
+ tabIndex={0}
137
+ className="desk-split-edge"
138
+ onPointerDown={startDrag}
139
+ onKeyDown={onKeyDown}
140
+ // Back to the width it started at, as a double-click on a divider does on a Mac.
141
+ onDoubleClick={() => commit(initial)}
142
+ />
143
+ )
144
+ const main = (
145
+ <div key="main" className="desk-split-panel">
146
+ {children}
147
+ </div>
148
+ )
149
+
150
+ return (
151
+ <div
152
+ ref={root}
153
+ className={['desk-split', className].filter(Boolean).join(' ')}
154
+ data-at={at}
155
+ style={{ '--desk-split-size': length(width) } as CSSProperties}
156
+ >
157
+ {/* In reading order, so Tab walks the panels the way they are drawn. */}
158
+ {at === 'start' ? [sidePanel, edge, main] : [main, edge, sidePanel]}
159
+ </div>
160
+ )
161
+ }