@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,399 @@
|
|
|
1
|
+
import { endedItems, type Offered, offered } from "@slotform/ui-core/acts";
|
|
2
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
3
|
+
import type {
|
|
4
|
+
IconLinkAct,
|
|
5
|
+
LinkAct,
|
|
6
|
+
Route,
|
|
7
|
+
Run,
|
|
8
|
+
} from "@slotform/ui-core/descriptors";
|
|
9
|
+
import { BACK_GLYPH } from "@slotform/ui-core/list-state";
|
|
10
|
+
import { actsSplit, trailSplit } from "@slotform/ui-core/overflow";
|
|
11
|
+
import {
|
|
12
|
+
type Frame,
|
|
13
|
+
useDrawsFailure,
|
|
14
|
+
useSelections,
|
|
15
|
+
} from "@slotform/ui-core/react/read";
|
|
16
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
17
|
+
import {
|
|
18
|
+
type Datum,
|
|
19
|
+
endedReason,
|
|
20
|
+
isEnded,
|
|
21
|
+
paints,
|
|
22
|
+
} from "@slotform/ui-core/read";
|
|
23
|
+
import type { TrailPart } from "@slotform/ui-core/route";
|
|
24
|
+
import { isCode, partRuns, partText } from "@slotform/ui-core/runs";
|
|
25
|
+
import type { Tone } from "@slotform/ui-core/tokens";
|
|
26
|
+
import {
|
|
27
|
+
ITEM_OVERLINE,
|
|
28
|
+
PAGE_CONTEXT,
|
|
29
|
+
PAGE_HEAD,
|
|
30
|
+
PAGE_TITLE_FLOOR,
|
|
31
|
+
PAGE_TOP_BAR,
|
|
32
|
+
PAGE_WITHIN,
|
|
33
|
+
PAGE_WITHIN_SEP,
|
|
34
|
+
TITLE_CODE,
|
|
35
|
+
text,
|
|
36
|
+
} from "@slotform/ui-core/variants";
|
|
37
|
+
import { Fragment, use } from "react";
|
|
38
|
+
import { IconButtonBase, IconButtonLink } from "../../atoms/button/glyph.tsx";
|
|
39
|
+
import { type IconAct, type MenuEntry, wiringOf } from "../../lib/act.ts";
|
|
40
|
+
import { RunText } from "../../lib/code.tsx";
|
|
41
|
+
import { ShellMenu } from "../../lib/container.ts";
|
|
42
|
+
import { useTouch } from "../../lib/media.ts";
|
|
43
|
+
import { follow, isPage } from "../../lib/navigate.ts";
|
|
44
|
+
import { Painted } from "../../lib/paint.tsx";
|
|
45
|
+
import { TrailLine } from "../../lib/parts-line.tsx";
|
|
46
|
+
import { BusyMark, FrameLine } from "../../lib/read.tsx";
|
|
47
|
+
import { IconActFace } from "../button/face.tsx";
|
|
48
|
+
import { Button } from "../button/index.tsx";
|
|
49
|
+
import { drawsNoName } from "../item-header/base.tsx";
|
|
50
|
+
import { MenuBase } from "../menu/base.tsx";
|
|
51
|
+
import { HeldPicker } from "../picker/base.tsx";
|
|
52
|
+
import type { PickOneProps } from "../picker/index.tsx";
|
|
53
|
+
|
|
54
|
+
// A record's Back, Close and Expand: docs/architecture/ui-core/layout.md, "Panes".
|
|
55
|
+
const ALONE = "[display:var(--pane-back,flex)]";
|
|
56
|
+
const SPACE_BACK = "flex";
|
|
57
|
+
const BESIDE = "[display:var(--pane-close,none)]";
|
|
58
|
+
const EXPAND = "[display:var(--pane-expand,none)]";
|
|
59
|
+
const HEAD = "flex flex-col";
|
|
60
|
+
// On touch the head carries a step of block padding, and the back act or the
|
|
61
|
+
// menu act reaches the page inset by its start, the acts by their end. The row
|
|
62
|
+
// is one line at every width: the title truncates and keeps its floor (two
|
|
63
|
+
// fifths of the row, a structural fraction, never a width), the first act
|
|
64
|
+
// stands and the rest stand in the more menu (`actsSplit`).
|
|
65
|
+
const ROW = "flex items-center";
|
|
66
|
+
const START = "touch:-ms-icon-inset";
|
|
67
|
+
// The title keeps its floor against the context pick, a pick or none: the pick
|
|
68
|
+
// keeps its content up to three fifths of the row (`PAGE_CONTEXT`) and less where
|
|
69
|
+
// the title's two fifths need the room, its label then truncating, the dot and the
|
|
70
|
+
// chevron whole, at every width.
|
|
71
|
+
const PILL = "flex min-w-0";
|
|
72
|
+
const ACTS = "flex shrink-0 items-center gap-gap ms-auto touch:-me-icon-inset";
|
|
73
|
+
// The title's line: the trail, then the heading, the busy mark after the
|
|
74
|
+
// title. The line's floor is `PAGE_TITLE_FLOOR`'s min-width: a `min-w-0` here
|
|
75
|
+
// would replace it, so the title would give way to the switcher or the acts to
|
|
76
|
+
// nothing. On touch a place's Pane under other places stands its trail as an
|
|
77
|
+
// overline over the heading.
|
|
78
|
+
const TITLE = "flex grow items-center gap-gap";
|
|
79
|
+
const TITLE_UNDER = "touch:flex-col touch:items-stretch touch:gap-0";
|
|
80
|
+
const HEADING = "flex min-w-0 grow items-center gap-gap";
|
|
81
|
+
const OVERLINE = "hidden touch:flex";
|
|
82
|
+
const NAME = "min-w-0 truncate";
|
|
83
|
+
// A record's name under the bar on touch: docs/architecture/ui-core/layout.md, "Record head".
|
|
84
|
+
const NAME_WAITS = "touch:record-name-waits";
|
|
85
|
+
// The trail stands whole beside the title: it keeps its own width up to three
|
|
86
|
+
// fifths of the line, and the name, which the body's head repeats whole, gives
|
|
87
|
+
// way first, so a name that waits (its filler) never cuts a place's word. The
|
|
88
|
+
// top place and the current one stand; the places between stand from
|
|
89
|
+
// `trailWhole` of the Pane (`trail-whole:`) and below it fold into one act,
|
|
90
|
+
// the trail's split (`trailSplit`). Each slash is a part of its own that is
|
|
91
|
+
// never cut. On touch the bar holds the back act and the name alone, as
|
|
92
|
+
// the phone's holds one part, so the name is never cut to a few letters; a
|
|
93
|
+
// record whose name will not come (its read ended) keeps its trail there.
|
|
94
|
+
const WITHIN = "flex shrink-0 items-center max-w-3/5";
|
|
95
|
+
const WITHIN_WIDE = "touch:hidden";
|
|
96
|
+
const WITHIN_SEP = "shrink-0";
|
|
97
|
+
const TRAIL_WHOLE = "hidden trail-whole:contents";
|
|
98
|
+
const TRAIL_FOLDED = "contents trail-whole:hidden";
|
|
99
|
+
const CRUMB = "min-w-0 truncate";
|
|
100
|
+
const CRUMB_LINK = "hover:text-ink-body active:text-ink-body";
|
|
101
|
+
|
|
102
|
+
/** A Pane's bar: the back act, the title, the context pick, the acts and more, and the line of its read's state. The bar is one line: the first act stands as its icon and the rest stand in the more menu, before its own items, at every width; the title keeps two fifths of the row, and the context pick's label truncates before the title is cut below it. It subscribes to the title and the acts itself, so a title or an act's read landing renders the bar and nothing under the Pane's body. A record's bar whose read failed or answered not found draws its trail at every density, then the record's kind after the slash (its `noun`, else "Failed" or "Not found"), and none of the acts; its back act stands where the Pane stands alone, and its close act only where the read failed, a missing record's way back being its Back. Outside the package's exports. */
|
|
103
|
+
export function PaneHead(props: {
|
|
104
|
+
/** The places above the Pane's own, the top first: on the desktop each drawn before the title in the meta ink, a slash apart (a place that is a page a link to it, a folder text), the top standing and the rest standing where the Pane is `trailWhole` wide or more, below it folded into one act whose menu lists the pages among them; on touch a place's Pane draws them as an overline over its title, cut at its start. */
|
|
105
|
+
trail?: readonly TrailPart[];
|
|
106
|
+
/** Where a record lives, drawn after the trail and before its name, parted from it by a slash, on the desktop; on touch the bar holds the name alone, the trail and the place standing at the start of the head's overline, and in the bar only once the record's read ended. */
|
|
107
|
+
within?: TrailPart;
|
|
108
|
+
/** The id of the heading the title stands in, which names the Pane while the title is no filler. A record's Pane (`headed`) leaves it to its head, which holds the heading; the bar holds the id, as a paragraph, only where the name is empty and the head draws none. */
|
|
109
|
+
titleId?: string;
|
|
110
|
+
/** What the bar draws: the Pane's title, or the place of a record. */
|
|
111
|
+
title: Datum<Run>;
|
|
112
|
+
/** A record's way back, to the place's Pane as it stood: Back or Close. The place's Pane has none. */
|
|
113
|
+
back?: Route;
|
|
114
|
+
/** A record's Expand act, which folds the place's Pane away and, `expanded`, stands as Collapse. */
|
|
115
|
+
expand?: { expanded: boolean; onAct: () => void };
|
|
116
|
+
/** The Pane stands in a room Panes, alone. */
|
|
117
|
+
far?: boolean;
|
|
118
|
+
acts?: readonly Offered<IconAct | IconLinkAct>[];
|
|
119
|
+
more?: Offered<readonly MenuEntry[]>;
|
|
120
|
+
/** The context the page reads in, drawn as a pill after the title. */
|
|
121
|
+
context?: Omit<PickOneProps<string | null>, "fit">;
|
|
122
|
+
/** The tone of the context the page reads in, the dot before the pick's label. */
|
|
123
|
+
state?: Tone;
|
|
124
|
+
/** The Pane's frame, whose busy mark and state line the bar draws. */
|
|
125
|
+
frame: Frame;
|
|
126
|
+
/** The body's head shows the record's name: on touch the bar's waits until the head's scrolls up under the bar. */
|
|
127
|
+
headed?: boolean;
|
|
128
|
+
/** The kind of record the Pane shows, which a missing read's bar names. */
|
|
129
|
+
noun?: string;
|
|
130
|
+
}) {
|
|
131
|
+
const {
|
|
132
|
+
trail = [],
|
|
133
|
+
within,
|
|
134
|
+
titleId,
|
|
135
|
+
title,
|
|
136
|
+
back,
|
|
137
|
+
expand,
|
|
138
|
+
far,
|
|
139
|
+
acts,
|
|
140
|
+
more,
|
|
141
|
+
context,
|
|
142
|
+
state,
|
|
143
|
+
frame,
|
|
144
|
+
headed,
|
|
145
|
+
noun,
|
|
146
|
+
} = props;
|
|
147
|
+
// A Pane whose own read failed or answered not found draws none of its acts:
|
|
148
|
+
// the page below the bar is the failed or missing shape, whose Retry (or way
|
|
149
|
+
// back) is the one act, and an act of the read that ended would only stand
|
|
150
|
+
// blocked beside it. A record's bar keeps where it lived and the way back.
|
|
151
|
+
const gone = isEnded(frame.shape);
|
|
152
|
+
const touch = useTouch();
|
|
153
|
+
const words = useWords();
|
|
154
|
+
const menu = use(ShellMenu);
|
|
155
|
+
const moreOf = offered<readonly MenuEntry[]>(more);
|
|
156
|
+
const actsOf = (acts ?? []).map((one) => offered<IconAct | IconLinkAct>(one));
|
|
157
|
+
const [name, overflowAt, ...actionAt] = useSelections([
|
|
158
|
+
title,
|
|
159
|
+
moreOf,
|
|
160
|
+
...actsOf,
|
|
161
|
+
]);
|
|
162
|
+
useDrawsFailure([moreOf, ...actsOf]);
|
|
163
|
+
const goBack =
|
|
164
|
+
back === undefined ? null : (
|
|
165
|
+
<span className={cn(far ? SPACE_BACK : ALONE, START)}>
|
|
166
|
+
<IconButtonLink icon={BACK_GLYPH} label={words.back} href={back} />
|
|
167
|
+
</span>
|
|
168
|
+
);
|
|
169
|
+
// On touch the shell's menu act (the way to its places) leads a Pane with
|
|
170
|
+
// no way back; on the desktop the places stand in the sidebar.
|
|
171
|
+
const pick =
|
|
172
|
+
touch && menu && back === undefined ? (
|
|
173
|
+
<span className={START}>
|
|
174
|
+
<Button
|
|
175
|
+
glyph
|
|
176
|
+
icon={menu.icon}
|
|
177
|
+
label={menu.label}
|
|
178
|
+
onAct={menu.onAct}
|
|
179
|
+
{...wiringOf(menu)}
|
|
180
|
+
/>
|
|
181
|
+
</span>
|
|
182
|
+
) : null;
|
|
183
|
+
// An act is painted, inert, while its own datum waits; a selection's shape
|
|
184
|
+
// is unknown until it lands, so its paint is a bare glyph. One whose read
|
|
185
|
+
// ended stands blocked with the sentence for its name, never a false yes.
|
|
186
|
+
const built = actionAt.map((one, at) => {
|
|
187
|
+
if (!one.painted) {
|
|
188
|
+
return <IconActFace key={one.value.label} act={one.value} />;
|
|
189
|
+
}
|
|
190
|
+
const ended = endedReason(words, one.phase);
|
|
191
|
+
return (
|
|
192
|
+
<IconButtonBase
|
|
193
|
+
key={at}
|
|
194
|
+
icon={ended ? "CircleAlert" : "Ellipsis"}
|
|
195
|
+
label={ended ?? ""}
|
|
196
|
+
disabled={ended !== undefined}
|
|
197
|
+
painted={ended === undefined}
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
const overflowEnded = overflowAt.painted
|
|
202
|
+
? endedReason(words, overflowAt.phase)
|
|
203
|
+
: undefined;
|
|
204
|
+
const own = overflowEnded
|
|
205
|
+
? endedItems(words, overflowEnded)
|
|
206
|
+
: overflowAt.painted
|
|
207
|
+
? []
|
|
208
|
+
: (overflowAt.value ?? []);
|
|
209
|
+
const { standing } = actsSplit(built);
|
|
210
|
+
// The acts folded into the menu stand before its own, in their order; one
|
|
211
|
+
// whose read waits has no name yet and one whose read ended stands blocked.
|
|
212
|
+
const folded = actsSplit(actionAt).folded.flatMap(
|
|
213
|
+
(one): readonly MenuEntry[] => {
|
|
214
|
+
if (!one.painted) return [one.value];
|
|
215
|
+
const ended = endedReason(words, one.phase);
|
|
216
|
+
return ended ? endedItems(words, ended) : [];
|
|
217
|
+
},
|
|
218
|
+
);
|
|
219
|
+
const items: readonly MenuEntry[] = [...folded, ...own];
|
|
220
|
+
// The touch sheet of the more menu is titled by the Pane's record, its
|
|
221
|
+
// title (a record's name), as a row's is by the row; the act keeps "More"
|
|
222
|
+
// as its name. A title that waits or ended leaves the sheet "More".
|
|
223
|
+
const named = name.painted ? "" : partText(name.value);
|
|
224
|
+
// A Pane whose read answered not found has its way back in the missing
|
|
225
|
+
// form, Back under its sentence, so the bar draws no Close beside it: one
|
|
226
|
+
// way out, not two.
|
|
227
|
+
const close =
|
|
228
|
+
far || back === undefined || frame.shape === "missing" ? null : (
|
|
229
|
+
<span className={BESIDE}>
|
|
230
|
+
<IconButtonLink icon="X" label={words.close} href={back} />
|
|
231
|
+
</span>
|
|
232
|
+
);
|
|
233
|
+
// A record whose read ended has nothing to read wider.
|
|
234
|
+
const widen =
|
|
235
|
+
far || expand === undefined || gone ? null : (
|
|
236
|
+
<span className={EXPAND}>
|
|
237
|
+
<IconButtonBase
|
|
238
|
+
icon={expand.expanded ? "Minimize2" : "Maximize2"}
|
|
239
|
+
label={expand.expanded ? words.collapse : words.expand}
|
|
240
|
+
onClick={expand.onAct}
|
|
241
|
+
/>
|
|
242
|
+
</span>
|
|
243
|
+
);
|
|
244
|
+
const overflow =
|
|
245
|
+
!gone && (overflowAt.painted || items.length) ? (
|
|
246
|
+
<MenuBase
|
|
247
|
+
label={words.more}
|
|
248
|
+
title={named === "" ? words.more : named}
|
|
249
|
+
items={items}
|
|
250
|
+
painted={
|
|
251
|
+
overflowAt.painted &&
|
|
252
|
+
overflowEnded === undefined &&
|
|
253
|
+
folded.length === 0
|
|
254
|
+
}
|
|
255
|
+
/>
|
|
256
|
+
) : null;
|
|
257
|
+
const nameless = drawsNoName(name);
|
|
258
|
+
// A Pane whose read answered not found has no name to draw, no back act (the
|
|
259
|
+
// missing shape's Back is its one way out) and no acts, and beside another its
|
|
260
|
+
// bar stands the line its neighbours' bars do: it names what is missing, the
|
|
261
|
+
// record's kind, else "Not found". A record's bar whose name will not come
|
|
262
|
+
// (its read failed, or the name landed empty) names its kind too, after its
|
|
263
|
+
// trail and its slash, so the record's line (and the region it names)
|
|
264
|
+
// is never the place's Pane's alone.
|
|
265
|
+
const kind =
|
|
266
|
+
nameless && (within !== undefined || frame.shape === "missing")
|
|
267
|
+
? kindWord(noun, frame, words)
|
|
268
|
+
: undefined;
|
|
269
|
+
// The title is the Pane's heading in every form it draws: a waiting title
|
|
270
|
+
// paints inside it, named by the waiting word since its filler is hidden,
|
|
271
|
+
// so the page keeps its heading while the title loads. A title whose read
|
|
272
|
+
// ended draws nothing, the body's failed or missing shape standing as the
|
|
273
|
+
// heading, and a record's place is no heading: each stands as a paragraph of
|
|
274
|
+
// the title's own look.
|
|
275
|
+
// A record's head holds the heading (and the id), the bar's title a paragraph;
|
|
276
|
+
// the bar holds the id when the head has no name to carry it (empty, or its read ended).
|
|
277
|
+
const holds = titleId !== undefined && (!headed || nameless);
|
|
278
|
+
// A nameless record's bar names its kind, which stands as the heading.
|
|
279
|
+
const Title =
|
|
280
|
+
holds && (!nameless || kind !== undefined) ? ("h2" as const) : "p";
|
|
281
|
+
const waits = holds && paints(name);
|
|
282
|
+
// The top place stands; the places between stand where the bar holds the
|
|
283
|
+
// whole trail and fold below it, their pages listed in the fold's menu (a
|
|
284
|
+
// folder there leads nowhere).
|
|
285
|
+
const { top, between } = trailSplit(trail);
|
|
286
|
+
const pages = between.flatMap((one): readonly LinkAct[] =>
|
|
287
|
+
isPage(one.route) ? [{ label: one.label, href: one.route }] : [],
|
|
288
|
+
);
|
|
289
|
+
const overlined = within === undefined && trail.length > 0;
|
|
290
|
+
const sep = <span aria-hidden className={cn(PAGE_WITHIN_SEP, WITHIN_SEP)} />;
|
|
291
|
+
const crumb = (part: TrailPart, at: number) => (
|
|
292
|
+
<Fragment key={part.route ?? at}>
|
|
293
|
+
<Crumb part={part} />
|
|
294
|
+
{sep}
|
|
295
|
+
</Fragment>
|
|
296
|
+
);
|
|
297
|
+
const nav =
|
|
298
|
+
trail.length > 0 || within ? (
|
|
299
|
+
<nav
|
|
300
|
+
aria-label={words.breadcrumb}
|
|
301
|
+
className={cn(
|
|
302
|
+
text({ role: "body" }),
|
|
303
|
+
PAGE_WITHIN,
|
|
304
|
+
WITHIN,
|
|
305
|
+
(within === undefined || !(gone || nameless)) && WITHIN_WIDE,
|
|
306
|
+
)}
|
|
307
|
+
>
|
|
308
|
+
{top.map(crumb)}
|
|
309
|
+
{between.length > 0 ? (
|
|
310
|
+
<span className={TRAIL_WHOLE}>{between.map(crumb)}</span>
|
|
311
|
+
) : null}
|
|
312
|
+
{pages.length > 0 ? (
|
|
313
|
+
<span className={TRAIL_FOLDED}>
|
|
314
|
+
<MenuBase
|
|
315
|
+
label={words.morePlaces}
|
|
316
|
+
title={words.morePlaces}
|
|
317
|
+
items={pages}
|
|
318
|
+
/>
|
|
319
|
+
{sep}
|
|
320
|
+
</span>
|
|
321
|
+
) : null}
|
|
322
|
+
{within ? crumb(within, trail.length) : null}
|
|
323
|
+
</nav>
|
|
324
|
+
) : null;
|
|
325
|
+
// The head is one tree on both densities, so crossing the density line
|
|
326
|
+
// keeps its acts and their focus.
|
|
327
|
+
return (
|
|
328
|
+
<header className={cn(PAGE_HEAD, HEAD)}>
|
|
329
|
+
<div className={cn(PAGE_TOP_BAR, ROW)}>
|
|
330
|
+
{goBack}
|
|
331
|
+
{pick}
|
|
332
|
+
<div className={cn(PAGE_TITLE_FLOOR, TITLE, overlined && TITLE_UNDER)}>
|
|
333
|
+
{nav}
|
|
334
|
+
{overlined ? (
|
|
335
|
+
<TrailLine
|
|
336
|
+
trail={trail.map((one) => one.label)}
|
|
337
|
+
className={cn(ITEM_OVERLINE, OVERLINE)}
|
|
338
|
+
/>
|
|
339
|
+
) : null}
|
|
340
|
+
<Title
|
|
341
|
+
id={holds ? titleId : undefined}
|
|
342
|
+
aria-label={waits ? words.waiting : undefined}
|
|
343
|
+
className={cn(text({ role: "heading" }), HEADING)}
|
|
344
|
+
>
|
|
345
|
+
<span className={cn(NAME, headed && NAME_WAITS)}>
|
|
346
|
+
{paints(name) ? (
|
|
347
|
+
<Painted role="title" />
|
|
348
|
+
) : name.painted || kind !== undefined ? (
|
|
349
|
+
kind
|
|
350
|
+
) : isCode(name.value) ? (
|
|
351
|
+
<code className={TITLE_CODE}>{name.value.code}</code>
|
|
352
|
+
) : (
|
|
353
|
+
<RunText runs={partRuns(name.value)} fit="name" />
|
|
354
|
+
)}
|
|
355
|
+
</span>
|
|
356
|
+
<BusyMark frame={frame} />
|
|
357
|
+
</Title>
|
|
358
|
+
</div>
|
|
359
|
+
{context ? (
|
|
360
|
+
<span className={cn(PILL, PAGE_CONTEXT)}>
|
|
361
|
+
<HeldPicker {...context} fit="pill" state={state} />
|
|
362
|
+
</span>
|
|
363
|
+
) : null}
|
|
364
|
+
<span className={ACTS}>
|
|
365
|
+
{gone ? null : standing}
|
|
366
|
+
{overflow}
|
|
367
|
+
{widen}
|
|
368
|
+
{close}
|
|
369
|
+
</span>
|
|
370
|
+
</div>
|
|
371
|
+
<FrameLine frame={frame} />
|
|
372
|
+
</header>
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// The word a nameless record's bar names it by: its kind, else what ended it.
|
|
377
|
+
function kindWord(
|
|
378
|
+
noun: string | undefined,
|
|
379
|
+
frame: Frame,
|
|
380
|
+
words: ReturnType<typeof useWords>,
|
|
381
|
+
): string {
|
|
382
|
+
if (noun !== undefined)
|
|
383
|
+
return `${noun.charAt(0).toUpperCase()}${noun.slice(1)}`;
|
|
384
|
+
if (frame.shape === "failed") return words.failed;
|
|
385
|
+
return words.notFound;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// A place of the trail: a link to it where it is a page, else (a folder, a
|
|
389
|
+
// place outside a Shell) its words.
|
|
390
|
+
function Crumb({ part }: { part: TrailPart }) {
|
|
391
|
+
const label = <RunText runs={partRuns(part.label)} fit="name" />;
|
|
392
|
+
return isPage(part.route) ? (
|
|
393
|
+
<a href={part.route} onClick={follow} className={cn(CRUMB, CRUMB_LINK)}>
|
|
394
|
+
{label}
|
|
395
|
+
</a>
|
|
396
|
+
) : (
|
|
397
|
+
<span className={CRUMB}>{label}</span>
|
|
398
|
+
);
|
|
399
|
+
}
|