@slotform/react-ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +44 -2
- package/dist/density.d.ts +4 -0
- package/dist/density.d.ts.map +1 -0
- package/dist/density.js +8 -0
- package/dist/density.js.map +1 -0
- package/dist/index.d.ts +400 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/dist/node/canvas.d.ts +3 -0
- package/dist/node/canvas.d.ts.map +1 -0
- package/dist/node/canvas.js +13 -0
- package/dist/node/canvas.js.map +1 -0
- package/dist/node/codegen.d.ts +6 -0
- package/dist/node/codegen.d.ts.map +1 -0
- package/dist/node/codegen.js +70 -0
- package/dist/node/codegen.js.map +1 -0
- package/dist/node/css-escape.d.ts +8 -0
- package/dist/node/css-escape.d.ts.map +1 -0
- package/dist/node/css-escape.js +12 -0
- package/dist/node/css-escape.js.map +1 -0
- package/dist/node/fonts.d.ts +6 -0
- package/dist/node/fonts.d.ts.map +1 -0
- package/dist/node/fonts.js +219 -0
- package/dist/node/fonts.js.map +1 -0
- package/dist/node/lint.d.ts +3 -0
- package/dist/node/lint.d.ts.map +1 -0
- package/dist/node/lint.js +23 -0
- package/dist/node/lint.js.map +1 -0
- package/dist/node/mode.d.ts +9 -0
- package/dist/node/mode.d.ts.map +1 -0
- package/dist/node/mode.js +38 -0
- package/dist/node/mode.js.map +1 -0
- package/dist/node/theme.d.ts +13 -0
- package/dist/node/theme.d.ts.map +1 -0
- package/dist/node/theme.js +160 -0
- package/dist/node/theme.js.map +1 -0
- package/dist/types.d.ts +250 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +80 -0
- package/dist/types.js.map +1 -0
- package/guide/acts.md +61 -0
- package/guide/audio.md +77 -0
- package/guide/blocks.md +82 -0
- package/guide/canvas-choosing.md +34 -0
- package/guide/canvas-editing.md +36 -0
- package/guide/canvas-layout.md +46 -0
- package/guide/canvas-opening.md +47 -0
- package/guide/canvas-overview.md +24 -0
- package/guide/canvas-states.md +37 -0
- package/guide/canvas-view.md +46 -0
- package/guide/canvas.md +94 -0
- package/guide/containers.md +60 -0
- package/guide/content.md +40 -0
- package/guide/controls.md +89 -0
- package/guide/density.md +48 -0
- package/guide/dock.md +42 -0
- package/guide/drag.md +38 -0
- package/guide/figures.md +25 -0
- package/guide/forms.md +82 -0
- package/guide/pane-bar.md +11 -0
- package/guide/pane.md +50 -0
- package/guide/reference.md +74 -0
- package/guide/rules.md +109 -0
- package/guide/section.md +29 -0
- package/guide/shell.md +26 -0
- package/guide/shots.md +37 -0
- package/guide/sidebar.md +30 -0
- package/guide/table.md +119 -0
- package/lint/no-arbitrary-value.grit +9 -0
- package/lint/no-class-on-component.grit +12 -0
- package/lint/no-density.grit +8 -0
- package/lint/no-host-look.grit +38 -0
- package/lint/no-img.grit +10 -0
- package/lint/no-navigate-act.grit +22 -0
- package/lint/no-raw-style.grit +8 -0
- package/package.json +150 -3
- package/src/density.ts +9 -0
- package/src/index.ts +503 -0
- package/src/node/canvas.ts +14 -0
- package/src/node/codegen.ts +100 -0
- package/src/node/css-escape.ts +27 -0
- package/src/node/fonts.ts +260 -0
- package/src/node/lint.ts +25 -0
- package/src/node/mode.ts +64 -0
- package/src/node/theme.ts +232 -0
- package/src/types.ts +120 -0
- package/src/ui/atoms/avatar/base.tsx +42 -0
- package/src/ui/atoms/button/glyph.tsx +244 -0
- package/src/ui/atoms/button/link.tsx +81 -0
- package/src/ui/atoms/button/look.ts +32 -0
- package/src/ui/atoms/button/reason.tsx +69 -0
- package/src/ui/atoms/chip/base.tsx +85 -0
- package/src/ui/atoms/count/base.tsx +27 -0
- package/src/ui/atoms/icon/index.tsx +51 -0
- package/src/ui/atoms/message/waiting.tsx +19 -0
- package/src/ui/atoms/prose/painted.tsx +35 -0
- package/src/ui/atoms/row/badges.tsx +226 -0
- package/src/ui/atoms/row/leading.tsx +166 -0
- package/src/ui/atoms/row/lock.tsx +17 -0
- package/src/ui/atoms/row/marks.tsx +79 -0
- package/src/ui/atoms/section/card.tsx +27 -0
- package/src/ui/atoms/spinner/index.tsx +42 -0
- package/src/ui/atoms/status/base.tsx +51 -0
- package/src/ui/atoms/status/change.tsx +29 -0
- package/src/ui/atoms/status/dot.tsx +45 -0
- package/src/ui/atoms/switch/checkbox.tsx +121 -0
- package/src/ui/atoms/turn.tsx +28 -0
- package/src/ui/components/action-bar/base.tsx +276 -0
- package/src/ui/components/action-bar/index.tsx +20 -0
- package/src/ui/components/avatar/index.tsx +21 -0
- package/src/ui/components/banner/index.tsx +207 -0
- package/src/ui/components/banner/pending.tsx +109 -0
- package/src/ui/components/bar-chart/index.tsx +701 -0
- package/src/ui/components/button/base.tsx +214 -0
- package/src/ui/components/button/face.tsx +84 -0
- package/src/ui/components/button/index.tsx +206 -0
- package/src/ui/components/canvas/connection.tsx +26 -0
- package/src/ui/components/canvas/edges.tsx +116 -0
- package/src/ui/components/canvas/elk.ts +260 -0
- package/src/ui/components/canvas/floor.ts +173 -0
- package/src/ui/components/canvas/geometry.ts +772 -0
- package/src/ui/components/canvas/ground.tsx +97 -0
- package/src/ui/components/canvas/group.tsx +156 -0
- package/src/ui/components/canvas/hit.ts +40 -0
- package/src/ui/components/canvas/index.tsx +497 -0
- package/src/ui/components/canvas/label.tsx +53 -0
- package/src/ui/components/canvas/layout.ts +543 -0
- package/src/ui/components/canvas/lift.ts +272 -0
- package/src/ui/components/canvas/look.ts +129 -0
- package/src/ui/components/canvas/node.tsx +689 -0
- package/src/ui/components/canvas/open.ts +243 -0
- package/src/ui/components/canvas/opening.ts +240 -0
- package/src/ui/components/canvas/view.ts +621 -0
- package/src/ui/components/canvas/viewport.ts +417 -0
- package/src/ui/components/canvas/zoom.tsx +113 -0
- package/src/ui/components/card/index.tsx +20 -0
- package/src/ui/components/chip/index.tsx +24 -0
- package/src/ui/components/code/frame.ts +2 -0
- package/src/ui/components/code/index.tsx +234 -0
- package/src/ui/components/columns/index.tsx +51 -0
- package/src/ui/components/count/index.tsx +17 -0
- package/src/ui/components/diff/index.tsx +249 -0
- package/src/ui/components/diff/word.tsx +104 -0
- package/src/ui/components/dock/index.tsx +262 -0
- package/src/ui/components/file-row/index.tsx +213 -0
- package/src/ui/components/form/base.tsx +280 -0
- package/src/ui/components/form/derive.tsx +269 -0
- package/src/ui/components/form/index.tsx +49 -0
- package/src/ui/components/form/saved.tsx +39 -0
- package/src/ui/components/form-field/index.tsx +658 -0
- package/src/ui/components/gallery/index.tsx +83 -0
- package/src/ui/components/gate/index.tsx +183 -0
- package/src/ui/components/image/base.tsx +245 -0
- package/src/ui/components/image/index.tsx +58 -0
- package/src/ui/components/input/base.tsx +246 -0
- package/src/ui/components/input/code.tsx +108 -0
- package/src/ui/components/input/drop.ts +37 -0
- package/src/ui/components/input/file.tsx +154 -0
- package/src/ui/components/input/index.tsx +132 -0
- package/src/ui/components/input/prose.tsx +107 -0
- package/src/ui/components/input/refusal.tsx +30 -0
- package/src/ui/components/item-header/base.tsx +410 -0
- package/src/ui/components/menu/base.tsx +319 -0
- package/src/ui/components/message/attachments.tsx +101 -0
- package/src/ui/components/message/base.tsx +266 -0
- package/src/ui/components/message-input/index.tsx +377 -0
- package/src/ui/components/missing/base.tsx +45 -0
- package/src/ui/components/pane/head.tsx +399 -0
- package/src/ui/components/pane/index.tsx +325 -0
- package/src/ui/components/picker/base.tsx +1551 -0
- package/src/ui/components/picker/index.tsx +224 -0
- package/src/ui/components/picker/list.tsx +423 -0
- package/src/ui/components/picker/segments.tsx +183 -0
- package/src/ui/components/prose/index.tsx +259 -0
- package/src/ui/components/qr-code/index.tsx +65 -0
- package/src/ui/components/row/acts.tsx +126 -0
- package/src/ui/components/row/fact.tsx +54 -0
- package/src/ui/components/row/index.tsx +1370 -0
- package/src/ui/components/row/progress.tsx +38 -0
- package/src/ui/components/row/status.tsx +54 -0
- package/src/ui/components/row/title.ts +7 -0
- package/src/ui/components/rules/index.tsx +290 -0
- package/src/ui/components/section/band.tsx +39 -0
- package/src/ui/components/section/head.tsx +267 -0
- package/src/ui/components/section/index.tsx +409 -0
- package/src/ui/components/section/rows.tsx +356 -0
- package/src/ui/components/sheet/base.tsx +272 -0
- package/src/ui/components/sheet/confirm.tsx +79 -0
- package/src/ui/components/sheet/docked.tsx +218 -0
- package/src/ui/components/sheet/form.tsx +76 -0
- package/src/ui/components/sheet/head.tsx +120 -0
- package/src/ui/components/sheet/index.tsx +45 -0
- package/src/ui/components/sheet/layer.tsx +168 -0
- package/src/ui/components/sheet/outlet.tsx +58 -0
- package/src/ui/components/sheet/task.tsx +41 -0
- package/src/ui/components/shell/cut.tsx +116 -0
- package/src/ui/components/shell/drag.tsx +45 -0
- package/src/ui/components/shell/host.tsx +71 -0
- package/src/ui/components/shell/index.tsx +737 -0
- package/src/ui/components/shell/panes.tsx +76 -0
- package/src/ui/components/shell/preview.ts +230 -0
- package/src/ui/components/shell/rail.tsx +163 -0
- package/src/ui/components/shell/row.ts +11 -0
- package/src/ui/components/shell/switcher.tsx +143 -0
- package/src/ui/components/shell/tree.tsx +252 -0
- package/src/ui/components/slider/base.tsx +139 -0
- package/src/ui/components/slider/index.tsx +57 -0
- package/src/ui/components/stages/index.tsx +198 -0
- package/src/ui/components/stats/count-links.tsx +47 -0
- package/src/ui/components/stats/index.tsx +203 -0
- package/src/ui/components/stats/meter.tsx +213 -0
- package/src/ui/components/stats/parts.ts +10 -0
- package/src/ui/components/step-count/index.tsx +45 -0
- package/src/ui/components/switch/base.tsx +86 -0
- package/src/ui/components/switch/index.tsx +38 -0
- package/src/ui/components/table/columns.tsx +131 -0
- package/src/ui/components/table/index.tsx +2215 -0
- package/src/ui/components/text/index.tsx +37 -0
- package/src/ui/components/thread/index.tsx +503 -0
- package/src/ui/components/thread/latest.tsx +59 -0
- package/src/ui/components/toast/index.tsx +113 -0
- package/src/ui/components/toast/layer.tsx +26 -0
- package/src/ui/components/toolbar/filters.tsx +161 -0
- package/src/ui/components/toolbar/index.tsx +125 -0
- package/src/ui/components/waveform/index.tsx +205 -0
- package/src/ui/globals.css +427 -0
- package/src/ui/lib/act.ts +60 -0
- package/src/ui/lib/age.ts +49 -0
- package/src/ui/lib/bound.ts +16 -0
- package/src/ui/lib/canvas-layout.ts +11 -0
- package/src/ui/lib/caret.ts +9 -0
- package/src/ui/lib/chip-lines.ts +3 -0
- package/src/ui/lib/closed.ts +8 -0
- package/src/ui/lib/code.tsx +184 -0
- package/src/ui/lib/columns.ts +39 -0
- package/src/ui/lib/commit.ts +24 -0
- package/src/ui/lib/container.ts +112 -0
- package/src/ui/lib/copy.ts +29 -0
- package/src/ui/lib/drag.ts +575 -0
- package/src/ui/lib/empty.tsx +85 -0
- package/src/ui/lib/field.ts +39 -0
- package/src/ui/lib/focus.ts +175 -0
- package/src/ui/lib/folds.ts +67 -0
- package/src/ui/lib/follow.ts +220 -0
- package/src/ui/lib/form.ts +19 -0
- package/src/ui/lib/guards.ts +38 -0
- package/src/ui/lib/heading.ts +14 -0
- package/src/ui/lib/ink.ts +26 -0
- package/src/ui/lib/lang.ts +7 -0
- package/src/ui/lib/leave.ts +14 -0
- package/src/ui/lib/lockup.tsx +145 -0
- package/src/ui/lib/measure.ts +22 -0
- package/src/ui/lib/media.ts +63 -0
- package/src/ui/lib/modality.ts +69 -0
- package/src/ui/lib/moment.ts +13 -0
- package/src/ui/lib/more.tsx +76 -0
- package/src/ui/lib/navigate.ts +210 -0
- package/src/ui/lib/noop.ts +3 -0
- package/src/ui/lib/not-found.tsx +40 -0
- package/src/ui/lib/paint.tsx +55 -0
- package/src/ui/lib/parts-line.tsx +54 -0
- package/src/ui/lib/picked.ts +18 -0
- package/src/ui/lib/player-store.ts +38 -0
- package/src/ui/lib/player.ts +139 -0
- package/src/ui/lib/portal.ts +12 -0
- package/src/ui/lib/read.tsx +269 -0
- package/src/ui/lib/region.tsx +49 -0
- package/src/ui/lib/reorder.ts +154 -0
- package/src/ui/lib/rest.ts +16 -0
- package/src/ui/lib/saved.ts +29 -0
- package/src/ui/lib/scramble.tsx +147 -0
- package/src/ui/lib/scrolls.ts +70 -0
- package/src/ui/lib/style.ts +6 -0
- package/src/ui/lib/swap.tsx +107 -0
- package/src/ui/lib/toast.ts +39 -0
- package/src/ui/lib/walk-classes.ts +16 -0
- package/src/ui/lib/window.tsx +376 -0
- package/src/ui/worker.d.ts +4 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import type { Offered } from "@slotform/ui-core/acts";
|
|
2
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
3
|
+
import type { IconLinkAct, Run } from "@slotform/ui-core/descriptors";
|
|
4
|
+
import type { ProcedureCall } from "@slotform/ui-core/form";
|
|
5
|
+
import {
|
|
6
|
+
FrameHolds,
|
|
7
|
+
hasBody,
|
|
8
|
+
useFrame,
|
|
9
|
+
usePainted,
|
|
10
|
+
} from "@slotform/ui-core/react/read";
|
|
11
|
+
import {
|
|
12
|
+
type Datum,
|
|
13
|
+
isEnded,
|
|
14
|
+
NO_HOLDS,
|
|
15
|
+
type Selection,
|
|
16
|
+
} from "@slotform/ui-core/read";
|
|
17
|
+
import { type TrailPart, trailEnds } from "@slotform/ui-core/route";
|
|
18
|
+
import type { Tone } from "@slotform/ui-core/tokens";
|
|
19
|
+
import {
|
|
20
|
+
FOOT_DOCKED,
|
|
21
|
+
PAGE_BODY,
|
|
22
|
+
PAGE_BODY_OVER_FOOT,
|
|
23
|
+
PAGE_BODY_UNDER_TOAST,
|
|
24
|
+
PAGE_HEAD_SPACE,
|
|
25
|
+
ROWS_MEASURED,
|
|
26
|
+
} from "@slotform/ui-core/variants";
|
|
27
|
+
import {
|
|
28
|
+
type ReactNode,
|
|
29
|
+
use,
|
|
30
|
+
useId,
|
|
31
|
+
useLayoutEffect,
|
|
32
|
+
useRef,
|
|
33
|
+
useState,
|
|
34
|
+
} from "react";
|
|
35
|
+
import type { IconAct, MenuEntry } from "../../lib/act.ts";
|
|
36
|
+
import type { Closed } from "../../lib/closed.ts";
|
|
37
|
+
import {
|
|
38
|
+
BackRoute,
|
|
39
|
+
InPane,
|
|
40
|
+
PageTitle,
|
|
41
|
+
PanesContainer,
|
|
42
|
+
PlaceTrail,
|
|
43
|
+
useFootRegion,
|
|
44
|
+
} from "../../lib/container.ts";
|
|
45
|
+
import type { Empty } from "../../lib/empty.tsx";
|
|
46
|
+
import { useFootFocus, usePaneFocus } from "../../lib/focus.ts";
|
|
47
|
+
import { HeadingContext } from "../../lib/heading.ts";
|
|
48
|
+
import { DistanceContext } from "../../lib/media.ts";
|
|
49
|
+
import { useParentRoute, useReturnRoute } from "../../lib/navigate.ts";
|
|
50
|
+
import { FrameBody, stillOf } from "../../lib/read.tsx";
|
|
51
|
+
import { useScrolls } from "../../lib/scrolls.ts";
|
|
52
|
+
import { Scroller, useScroller } from "../../lib/window.tsx";
|
|
53
|
+
import { ItemHeaderBase, type ItemHeaderParts } from "../item-header/base.tsx";
|
|
54
|
+
import type { PickOneProps } from "../picker/index.tsx";
|
|
55
|
+
import { SheetDocked } from "../sheet/docked.tsx";
|
|
56
|
+
import type { SheetProps } from "../sheet/index.tsx";
|
|
57
|
+
import { PaneHead } from "./head.tsx";
|
|
58
|
+
|
|
59
|
+
// A Pane is a column of its place's row: docs/architecture/ui-core/layout.md, "Panes".
|
|
60
|
+
const PANE =
|
|
61
|
+
"@container/page group/pane flex flex-col min-h-0 grow basis-0 min-w-0";
|
|
62
|
+
// A record's head names a view timeline: docs/architecture/ui-core/layout.md, "Record head".
|
|
63
|
+
const RECORD_SCOPE = "record-scope";
|
|
64
|
+
// The body scrolls under the fixed head: docs/architecture/ui-core/layout.md, "Body".
|
|
65
|
+
const BODY = "grow min-h-0 overflow-y-auto focus-visible:-outline-offset-2";
|
|
66
|
+
const GRID = "auto-rows-max content-start";
|
|
67
|
+
const FLEX = "flex flex-col";
|
|
68
|
+
// A subgrid draws in its parent's columns: docs/architecture/ui-core/layout.md, "Rows grid".
|
|
69
|
+
const MEASURED =
|
|
70
|
+
"*:max-w-reading [&>[data-wide]]:max-w-none [&>:has([data-wide])]:max-w-none";
|
|
71
|
+
// What the body and the docked foot share: the head stands outside it, so the
|
|
72
|
+
// foot's bound is the whole of it and the body keeps the rest. With a foot its
|
|
73
|
+
// measurement bounds a docked sheet's body.
|
|
74
|
+
const REGION = "flex flex-col grow min-h-0";
|
|
75
|
+
// The docked foot is the toasts' anchor: docs/architecture/plugins/react-ui.md, "Toast anchor and stacking".
|
|
76
|
+
const DOCKED =
|
|
77
|
+
"flex flex-col items-center shrink-0 empty:hidden [anchor-name:--docked-foot]";
|
|
78
|
+
// A chosen bar stands at the body's column: docs/architecture/ui-core/layout.md, "Foot".
|
|
79
|
+
const FOOT_WIDE = "has-[[data-wide]]:[--foot-column:100%]";
|
|
80
|
+
|
|
81
|
+
export type { RecordFact } from "@slotform/ui-core/descriptors";
|
|
82
|
+
|
|
83
|
+
/** A record's head in its Pane: the parts of the head under the bar (the overline, the facts, the description, the image). Where the record lives is the place's name, which the Pane draws before the record's in the bar on the desktop and at the start of the overline on touch, so `overline` never repeats it. */
|
|
84
|
+
export type RecordHead<V extends string | null = string> = ItemHeaderParts<V>;
|
|
85
|
+
|
|
86
|
+
/** What kind of Pane it is, which its props say: the place's own, titled by the place's name, or a record's, titled by the record's name and standing after the place's. A Panes holds one of each at most. */
|
|
87
|
+
type PaneKindProps<V extends string | null> =
|
|
88
|
+
| {
|
|
89
|
+
/** The place's Pane takes the place's name (the sidebar's label) as its title, so it gives none. */
|
|
90
|
+
title?: never;
|
|
91
|
+
record?: undefined;
|
|
92
|
+
}
|
|
93
|
+
| {
|
|
94
|
+
/** The record's name (a short phrase; a name whose read failed with no fallback, or that landed empty, draws nothing, no empty heading, the bar keeping its height and its way back, and the body says why), given as a selection of the record's read: it paints while the record loads, and the Pane carries no name until it lands. In the bar, after the place's name and a slash, it is one line at every width, truncating, never under two fifths of the bar; it stands whole, wrapping, in the head at the body's top, as the Pane's `h2` (its Sections start at `h3`; the page's one `h1` is the Panes's, the name of the place you are in). */
|
|
95
|
+
title: Datum<Run>;
|
|
96
|
+
/** The record's head: the body opens with the title, at the Pane's heading level, between the overline and the facts, with the `description` as body text under the facts (a string, or runs whose `{ code }` stands boxed in the mono). Its bar holds the place's name, the record's, the Expand act (which folds the place's Pane away and turns to Collapse) and Close, which goes back to the place's Pane as it stood (its tab and filters, which the address's query holds); where the record's Pane stands alone (below `tablet` of its Panes) Back stands at the bar's start instead of Close. */
|
|
97
|
+
record: RecordHead<V>;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
interface PaneBase<P extends ProcedureCall> extends Closed {
|
|
101
|
+
/** The kind of record the Pane shows (a short lowercase noun: "project"). Its `read` answering not found fills the page with "Couldn't find this project." and the way back to the page above; without one the sentence is "Couldn't find this." */
|
|
102
|
+
noun?: string;
|
|
103
|
+
/** The sentence the Pane's page says when its read answers not found, in place of the one `noun` words ("No report for that month."); `noun` still names the kind in the bar. A sentence, ending in a full stop. */
|
|
104
|
+
missing?: string;
|
|
105
|
+
/** Icon acts after the title, ordered by weight: the primary act first, so it is the last to fold. Those that do not fit beside the title's floor fold into the bar's more menu, the last first, and return when there is room; a create act is one of them, and on a record's Pane the record's acts. An act is live whatever the `read` does, but on a record's Pane whose `read` failed or answered not found the bar draws none of them: the page below it is the failed or missing shape. One given as a selection paints, inert, while its own read waits or stands still, and stands blocked, the failed sentence its name, once that read failed or is missing. An act's `label` and `blocked` may be selections on their own, which paint it the same way. While the Pane's own `read` failed or is missing the bar draws no action and no more menu. */
|
|
106
|
+
acts?: readonly Offered<IconAct | IconLinkAct>[];
|
|
107
|
+
/** The acts past the acts, in a menu under the more act, named "More", whose touch sheet is titled by the Pane's title (a record's name), "More" while it waits; the more act paints and stands blocked as an action does. A record's Pane whose `read` failed or answered not found draws no more act. */
|
|
108
|
+
more?: Offered<readonly MenuEntry[]>;
|
|
109
|
+
/** The scope the page reads in, picked in the bar: an outlined pill at the control height after the title, before the acts, its label truncating at three fifths of the row at every width, its label its name and tooltip. The title keeps its floor of two fifths. A selection paints, inert, until its read lands. */
|
|
110
|
+
context?: Omit<PickOneProps<string | null>, "fit">;
|
|
111
|
+
/** The tone of the scope the page reads in: a dot in the state's colour before the context pick's label; the app chooses the tone. */
|
|
112
|
+
state?: Tone;
|
|
113
|
+
/** What docks at the Pane's foot, the body scrolling under it: the route gives it, so the Pane decides it from its props. A `Table`'s chosen bar is an `ActionBar` with `chosen` (its acts and its count of the rows the `Table`'s `choose` ticks), standing at the body's column (the reading width, the body's width where the body holds wide content) and start; a `Thread` standing among the Pane's sections docks its composer here as a `Composer` (the Thread then draws none of its own), with its `sheet` given as this Pane's. */
|
|
114
|
+
foot?: ReactNode;
|
|
115
|
+
/** A task over the foot: while it is `open` the sheet docks there in the foot's place (the foot gives way to it), the body scrolling above it, and closing hands focus back to the foot's input. */
|
|
116
|
+
sheet?: SheetProps<P>;
|
|
117
|
+
/** The body's one child is a filler (a `Thread` or a `Canvas`) that takes the body's free height: the body is a flex column, and the Sections in it keep their own label columns. Without it the body is the two-column grid every Section's definition rows align to. */
|
|
118
|
+
fill?: boolean;
|
|
119
|
+
/** The Pane's sections, a sections gap apart; none stand while the `read` is empty and the Pane declares an `empty`; without one the sections draw their own. */
|
|
120
|
+
children?: ReactNode;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A column of a `Panes`: the place's own, or a record's (`title` and `record` given together). `empty` belongs to the `read` it answers for, so a Pane given one without the other does not type-check. */
|
|
124
|
+
export type PaneProps<
|
|
125
|
+
V extends string | null = string,
|
|
126
|
+
P extends ProcedureCall = ProcedureCall,
|
|
127
|
+
> = PaneBase<P> &
|
|
128
|
+
PaneKindProps<V> &
|
|
129
|
+
(
|
|
130
|
+
| {
|
|
131
|
+
read?: undefined;
|
|
132
|
+
empty?: never;
|
|
133
|
+
}
|
|
134
|
+
| {
|
|
135
|
+
/** What the Pane's page holds, read once for the frame: while it waits the loaded tree paints, its failure and a missing record fill the page in place of the body, and an empty selection draws `empty`, which only a Pane that declares one replaces its body with. It holds the reads of `read` that no enclosing frame holds: those draw their failure and say they are busy; the rest only wait and empty. */
|
|
136
|
+
read: Selection<unknown>;
|
|
137
|
+
/** What the page says when the `read` is empty: this stands in place of the body, centred in what the body leaves. */
|
|
138
|
+
empty?: Empty;
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
/** A column of a Panes, of two kinds, one of each at most: the place's own Pane, titled by the place's name, and a record's after it, titled by the record's name (the Panes throws on a second of a kind, so a record linked from a record opens in its own place). A bar over one hairline (on touch the shell's switcher leading the place's Pane; before the title the places above the Pane's own (the trail: the top place, then the places between, which fold into one act below `trailWhole` of the Pane, then on a record's Pane the record's place, a slash after each, a page a link to it and a folder text, in a `nav` named by the breadcrumb word; on touch a place's Pane stands them as an overline over its title, cut at its start, and a record's head leads its overline with them); on a record's Pane the record's name, the Expand act and Close, Back at the start instead of Close where it stands alone; the title, the context pick, the acts and more, one line at every width) and a body that scrolls, its children a sections gap apart within the reading width at its start, wide content (a Table, a line Diff, a code block, a Canvas, a chart) at the body's width, the definition lists of its Sections sharing one label column, and a Thread or a Canvas in it filling it when the Pane takes `fill`; a `foot` docks under the body (on touch, a Thread among the sections docks its composer there), a `sheet` in its place while it is open, and the `empty` of its `read` stands in place of the children. Alone, the place's Pane takes the Panes; with a record's beside it, it holds the list width, giving way to its floor, and the record's takes the rest, unless the place's Pane fills with a Canvas, which takes the spare room while the record holds the list width. Below `tablet` of its Panes only the last stands. The record's Expand act folds the place's Pane away, mounted, the record taking the Panes, and turns to Collapse, which brings it back; Close goes back to the place's Pane as it stood. On a record's Pane the acts and more are the record's acts; its `record` puts the name, whole and wrapping, between the overline and the facts of a head at the body's top, and a `read` that fails or answers not found fills the page with the failed or missing shape in place of the head (the missing sentence worded by `noun`, its way back the page above, which stands there and not as the bar's Close), and the bar then keeps its trail and names the record's kind after its slash (its `noun`, else "Not found" or "Failed"), with none of the record's acts. An empty `read` keeps the head, the empty shape standing under it. Every Pane's name is an `h2` and its Sections start at `h3`, whatever Panes stand before or after it: the page's one `h1` is the Panes's, so a Pane is written the same alone and among others and reads nothing of its siblings. */
|
|
143
|
+
export function Pane<
|
|
144
|
+
V extends string | null = string,
|
|
145
|
+
P extends ProcedureCall = ProcedureCall,
|
|
146
|
+
>({
|
|
147
|
+
title: name,
|
|
148
|
+
record,
|
|
149
|
+
noun,
|
|
150
|
+
missing,
|
|
151
|
+
acts,
|
|
152
|
+
more,
|
|
153
|
+
context,
|
|
154
|
+
state,
|
|
155
|
+
foot,
|
|
156
|
+
sheet,
|
|
157
|
+
read,
|
|
158
|
+
empty,
|
|
159
|
+
fill,
|
|
160
|
+
children,
|
|
161
|
+
}: PaneProps<V, P>) {
|
|
162
|
+
const titleId = useId();
|
|
163
|
+
// A Pane in a room Panes stands its head off the top on the table.
|
|
164
|
+
const far = use(DistanceContext);
|
|
165
|
+
const place = use(PanesContainer);
|
|
166
|
+
const kind = record === undefined ? "place" : "record";
|
|
167
|
+
useLayoutEffect(() => place?.stand(kind), [place?.stand, kind]);
|
|
168
|
+
// The place's Pane is titled by the place's name; a record's draws it
|
|
169
|
+
// before the record's. Both draw the places above it (the Shell's trail
|
|
170
|
+
// less its last, the current place).
|
|
171
|
+
const title = name ?? place?.name ?? "";
|
|
172
|
+
const trail = use(PlaceTrail);
|
|
173
|
+
const { above, here: current } = trailEnds(trail);
|
|
174
|
+
const here: TrailPart = {
|
|
175
|
+
label: place?.name ?? "",
|
|
176
|
+
route: current?.route,
|
|
177
|
+
};
|
|
178
|
+
const within = record ? here : undefined;
|
|
179
|
+
// Only a record's Pane has a way back in its bar, to the place's Pane as it
|
|
180
|
+
// stood; a missing read of the place's Pane leads to the page above.
|
|
181
|
+
const parent = useParentRoute();
|
|
182
|
+
const returns = useReturnRoute();
|
|
183
|
+
const toward = record ? returns : parent;
|
|
184
|
+
const [expanded, setExpanded] = useState(false);
|
|
185
|
+
const held = useFrame(read);
|
|
186
|
+
// A Pane that declares no `empty` leaves an empty read to its Sections, which
|
|
187
|
+
// draw their own; only a Pane's own `empty` replaces its body.
|
|
188
|
+
const frame =
|
|
189
|
+
held.shape === "empty" && empty === undefined
|
|
190
|
+
? { ...held, shape: "ready" as const }
|
|
191
|
+
: held;
|
|
192
|
+
// The bar owns the title's subscription; the Pane asks only whether it is
|
|
193
|
+
// still filler, which is what names the region.
|
|
194
|
+
const filler = usePainted([title]);
|
|
195
|
+
const [paneNode, setPaneNode] = useState<HTMLElement | null>(null);
|
|
196
|
+
usePaneFocus(paneNode);
|
|
197
|
+
const body = useRef<HTMLDivElement | null>(null);
|
|
198
|
+
const scroll = useScroller(body);
|
|
199
|
+
useScrolls(scroll.node);
|
|
200
|
+
const dock = useRef<HTMLDivElement | null>(null);
|
|
201
|
+
// The foot is what the route gave: its `sheet` while open, else its `foot`.
|
|
202
|
+
const task = sheet?.open ? sheet : undefined;
|
|
203
|
+
// The body keeps a log's floor above a docked foot, and its insets: a
|
|
204
|
+
// Thread in it gives way to a docked sheet only down to two rows.
|
|
205
|
+
const region = useFootRegion(task !== undefined, dock, body);
|
|
206
|
+
useFootFocus(dock);
|
|
207
|
+
// The foot and the docked sheet stand whatever the page's read does: they
|
|
208
|
+
// draw nothing of it. A docked sheet takes the foot's place, bars and all.
|
|
209
|
+
const docked = task ? <SheetDocked {...task} region={region.value} /> : foot;
|
|
210
|
+
const footed = Boolean(docked);
|
|
211
|
+
// The Pane's own forms and a filler take the body's free height.
|
|
212
|
+
const flexed =
|
|
213
|
+
fill === true || isEnded(frame.shape) || frame.shape === "empty";
|
|
214
|
+
const named = filler ? undefined : titleId;
|
|
215
|
+
// A record's head opens the body, in the frame's body: a failed or missing
|
|
216
|
+
// read draws its form and not the head, and the bar's title is then the
|
|
217
|
+
// Pane's heading. An empty read is a record with nothing in it: its head
|
|
218
|
+
// stands, whole and wrapping, and the empty shape under it.
|
|
219
|
+
const head = record ? (
|
|
220
|
+
<ItemHeaderBase
|
|
221
|
+
name={title}
|
|
222
|
+
nameId={named}
|
|
223
|
+
trail={[...above, here].map((one) => one.label)}
|
|
224
|
+
overline={record.overline}
|
|
225
|
+
facts={record.facts}
|
|
226
|
+
description={record.description}
|
|
227
|
+
image={record.image}
|
|
228
|
+
/>
|
|
229
|
+
) : null;
|
|
230
|
+
const content = record ? (
|
|
231
|
+
<>
|
|
232
|
+
{head}
|
|
233
|
+
{children}
|
|
234
|
+
</>
|
|
235
|
+
) : (
|
|
236
|
+
children
|
|
237
|
+
);
|
|
238
|
+
// A page with nothing to draw in its body has none: an empty one is only its padding.
|
|
239
|
+
const bodied = hasBody(frame, content);
|
|
240
|
+
return (
|
|
241
|
+
<BackRoute value={toward}>
|
|
242
|
+
<InPane value>
|
|
243
|
+
<PageTitle value={named}>
|
|
244
|
+
<HeadingContext value={3}>
|
|
245
|
+
<section
|
|
246
|
+
ref={setPaneNode}
|
|
247
|
+
// The title names the region; a record's overline is text beside it.
|
|
248
|
+
aria-labelledby={named}
|
|
249
|
+
aria-busy={
|
|
250
|
+
(frame.holds && frame.shape === "waiting") || undefined
|
|
251
|
+
}
|
|
252
|
+
data-still={stillOf(frame)}
|
|
253
|
+
data-page=""
|
|
254
|
+
data-expanded={expanded ? "" : undefined}
|
|
255
|
+
data-fill={fill ? "" : undefined}
|
|
256
|
+
className={cn(
|
|
257
|
+
PANE,
|
|
258
|
+
far && PAGE_HEAD_SPACE,
|
|
259
|
+
record && RECORD_SCOPE,
|
|
260
|
+
)}
|
|
261
|
+
>
|
|
262
|
+
<PaneHead
|
|
263
|
+
trail={above}
|
|
264
|
+
within={within}
|
|
265
|
+
titleId={titleId}
|
|
266
|
+
title={title}
|
|
267
|
+
back={record ? toward : undefined}
|
|
268
|
+
expand={
|
|
269
|
+
record
|
|
270
|
+
? { expanded, onAct: () => setExpanded((was) => !was) }
|
|
271
|
+
: undefined
|
|
272
|
+
}
|
|
273
|
+
far={far}
|
|
274
|
+
acts={acts}
|
|
275
|
+
more={more}
|
|
276
|
+
context={context}
|
|
277
|
+
state={state}
|
|
278
|
+
frame={frame}
|
|
279
|
+
headed={record !== undefined && !isEnded(frame.shape)}
|
|
280
|
+
noun={noun}
|
|
281
|
+
/>
|
|
282
|
+
{bodied || footed ? (
|
|
283
|
+
<div
|
|
284
|
+
ref={footed ? region.ref : undefined}
|
|
285
|
+
className={cn(REGION, FOOT_WIDE)}
|
|
286
|
+
>
|
|
287
|
+
{bodied ? (
|
|
288
|
+
<div
|
|
289
|
+
ref={scroll.ref}
|
|
290
|
+
className={cn(
|
|
291
|
+
PAGE_BODY,
|
|
292
|
+
flexed ? FLEX : [ROWS_MEASURED, GRID],
|
|
293
|
+
BODY,
|
|
294
|
+
MEASURED,
|
|
295
|
+
footed ? PAGE_BODY_OVER_FOOT : PAGE_BODY_UNDER_TOAST,
|
|
296
|
+
)}
|
|
297
|
+
>
|
|
298
|
+
<Scroller value={scroll}>
|
|
299
|
+
{frame.shape === "empty" ? head : null}
|
|
300
|
+
<FrameBody
|
|
301
|
+
frame={frame}
|
|
302
|
+
empty={empty}
|
|
303
|
+
noun={noun}
|
|
304
|
+
missing={missing}
|
|
305
|
+
headed
|
|
306
|
+
>
|
|
307
|
+
{content}
|
|
308
|
+
</FrameBody>
|
|
309
|
+
</Scroller>
|
|
310
|
+
</div>
|
|
311
|
+
) : null}
|
|
312
|
+
{footed ? (
|
|
313
|
+
<div ref={dock} className={cn(FOOT_DOCKED, DOCKED)}>
|
|
314
|
+
<FrameHolds holds={NO_HOLDS}>{docked}</FrameHolds>
|
|
315
|
+
</div>
|
|
316
|
+
) : null}
|
|
317
|
+
</div>
|
|
318
|
+
) : null}
|
|
319
|
+
</section>
|
|
320
|
+
</HeadingContext>
|
|
321
|
+
</PageTitle>
|
|
322
|
+
</InPane>
|
|
323
|
+
</BackRoute>
|
|
324
|
+
);
|
|
325
|
+
}
|