@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,35 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { PROSE, PROSE_BLOCKS, text } from "@slotform/ui-core/variants";
|
|
3
|
+
import { Painted } from "../../lib/paint.tsx";
|
|
4
|
+
|
|
5
|
+
// The loaded column's boxes (Prose's own).
|
|
6
|
+
const COLUMN = "flex flex-col min-w-0";
|
|
7
|
+
const STACK = "flex flex-col";
|
|
8
|
+
// One painted line is a line box of the paragraph, clipped where it ends: the
|
|
9
|
+
// text's length is the data's and unknown, so a bar that wraps would stand
|
|
10
|
+
// taller than the text that lands.
|
|
11
|
+
const PAINTED_LINE = "block overflow-hidden whitespace-nowrap";
|
|
12
|
+
|
|
13
|
+
/** A markdown text that is not here, in the column's box, inert: one paragraph of `lines` clipped lines (a Prose paints `PAINT_ROWS` lines: a text block of unknown length paints that many lines). Outside the package's exports: a Message's reply paints one line of filler. */
|
|
14
|
+
export function PaintedProse({
|
|
15
|
+
lines,
|
|
16
|
+
at = 0,
|
|
17
|
+
}: {
|
|
18
|
+
lines: number;
|
|
19
|
+
/** The filler's place among the painted ones around it (`Painted`'s `at`), so a list's painted messages differ in length. */
|
|
20
|
+
at?: number;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<div inert className={cn(PROSE, COLUMN)}>
|
|
24
|
+
<div className={cn(PROSE_BLOCKS, STACK)}>
|
|
25
|
+
<p className={text({ role: "body" })}>
|
|
26
|
+
{Array.from({ length: lines }, (_, line) => (
|
|
27
|
+
<span key={line} className={PAINTED_LINE}>
|
|
28
|
+
<Painted role="sentence" at={at + line} />
|
|
29
|
+
</span>
|
|
30
|
+
))}
|
|
31
|
+
</p>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type {
|
|
3
|
+
ChipMark,
|
|
4
|
+
RowMark,
|
|
5
|
+
Run,
|
|
6
|
+
StatusMark,
|
|
7
|
+
} from "@slotform/ui-core/descriptors";
|
|
8
|
+
import type { PaintRole } from "@slotform/ui-core/paint";
|
|
9
|
+
import { paintText } from "@slotform/ui-core/paint";
|
|
10
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
11
|
+
import { isCode, partRuns } from "@slotform/ui-core/runs";
|
|
12
|
+
import {
|
|
13
|
+
BADGE,
|
|
14
|
+
BADGE_LINE,
|
|
15
|
+
BADGE_RING,
|
|
16
|
+
BADGE_RING_CENTRE,
|
|
17
|
+
BADGE_WORDS,
|
|
18
|
+
chipDot,
|
|
19
|
+
FIGURES,
|
|
20
|
+
ITEM_PILL_ACT,
|
|
21
|
+
text,
|
|
22
|
+
YIELDS_LAST_EACH,
|
|
23
|
+
} from "@slotform/ui-core/variants";
|
|
24
|
+
import type { ReactNode } from "react";
|
|
25
|
+
import { CodeCut, RunText } from "../../lib/code.tsx";
|
|
26
|
+
import { follow } from "../../lib/navigate.ts";
|
|
27
|
+
import { PAINT_BOX } from "../../lib/paint.tsx";
|
|
28
|
+
import { IconBase } from "../icon/index.tsx";
|
|
29
|
+
import { StatusDot } from "../status/dot.tsx";
|
|
30
|
+
import { flagGlyph, warnGlyph } from "./marks.tsx";
|
|
31
|
+
|
|
32
|
+
// A badge is a flex box of its glyph and its words: the box never breaks, the
|
|
33
|
+
// words are cut inside it. A glyph is one box that keeps its size.
|
|
34
|
+
const FACE = "flex items-center";
|
|
35
|
+
const GLYPH = "flex shrink-0 items-center";
|
|
36
|
+
// A badge that links takes the pointer the line does not, above the row's hit,
|
|
37
|
+
// and rings inset as the hit does; its words are underlined so it reads as a
|
|
38
|
+
// link among plain facts.
|
|
39
|
+
const LINKED = "relative pointer-events-auto focus-visible:-outline-offset-2";
|
|
40
|
+
// A painted badge's parts: laid out at the loaded size, drawn to nothing.
|
|
41
|
+
const UNSEEN = "invisible select-none";
|
|
42
|
+
const LINK_WORDS = "underline decoration-ink-mark";
|
|
43
|
+
|
|
44
|
+
/** One fact in a box that never breaks inside: an optional `glyph` (the only part of a badge that carries colour), then its words, cut with an ellipsis inside the box where the line is out of room; the box is the meta text's line tall on the meta-ink soft ground (`BADGE`). With an `href` it is a link, named by its words; `painted` is its filler at the loaded badge's size. Outside the package's exports. */
|
|
45
|
+
export function Badge(props: {
|
|
46
|
+
glyph?: ReactNode;
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
href?: string;
|
|
49
|
+
/** A badge an element around it links: its words underlined, the hit box's washes on it (a record head's link fact keeps its target's hit box). */
|
|
50
|
+
hit?: true;
|
|
51
|
+
painted?: boolean;
|
|
52
|
+
/** The filler's role and place while `painted`. */
|
|
53
|
+
paint?: { role: PaintRole; at?: number };
|
|
54
|
+
}) {
|
|
55
|
+
const { glyph, children, href, hit, painted, paint } = props;
|
|
56
|
+
const linked = href !== undefined && !painted;
|
|
57
|
+
const filler = paint ?? { role: "phrase" as const };
|
|
58
|
+
// A painted badge is one bar: its box is the filler, and its glyph and its
|
|
59
|
+
// words stand unseen at the loaded size, so no bar nests in a lighter box.
|
|
60
|
+
const face = (
|
|
61
|
+
<>
|
|
62
|
+
{glyph ? (
|
|
63
|
+
<span className={cn(GLYPH, painted && UNSEEN)}>{glyph}</span>
|
|
64
|
+
) : null}
|
|
65
|
+
{painted ||
|
|
66
|
+
(children !== undefined && children !== null && children !== "") ? (
|
|
67
|
+
<span
|
|
68
|
+
aria-hidden={painted || undefined}
|
|
69
|
+
className={cn(
|
|
70
|
+
BADGE_WORDS,
|
|
71
|
+
(linked || hit) && LINK_WORDS,
|
|
72
|
+
painted && UNSEEN,
|
|
73
|
+
)}
|
|
74
|
+
>
|
|
75
|
+
{painted ? paintText(filler.role, filler.at) : children}
|
|
76
|
+
</span>
|
|
77
|
+
) : null}
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
const box = cn(
|
|
81
|
+
BADGE,
|
|
82
|
+
FACE,
|
|
83
|
+
text({ role: "meta" }),
|
|
84
|
+
FIGURES,
|
|
85
|
+
hit && ITEM_PILL_ACT,
|
|
86
|
+
painted && PAINT_BOX,
|
|
87
|
+
);
|
|
88
|
+
if (!linked) return <span className={box}>{face}</span>;
|
|
89
|
+
return (
|
|
90
|
+
<a href={href} onClick={follow} className={cn(box, LINKED)}>
|
|
91
|
+
{face}
|
|
92
|
+
</a>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** A line of badges: whole badges, `badge` apart across and down, with no separator. `wrap` lets them wrap to the next line; without it they stand on one line and the last one is cut inside its badge when the line is out of room; only once it is gone do the earlier ones give way too, each cut inside its own badge with an ellipsis, never clipped flat at the line's edge. The line takes no pointer, a linked badge in it does. Outside the package's exports. */
|
|
97
|
+
export function BadgesLine(props: {
|
|
98
|
+
wrap?: boolean;
|
|
99
|
+
/** The line holds one line of badges and wraps (`row-two-line:`) where the row's container is narrower than its one-line form: the row's `adapts` form. */
|
|
100
|
+
adapts?: boolean;
|
|
101
|
+
className?: string;
|
|
102
|
+
children: ReactNode;
|
|
103
|
+
}) {
|
|
104
|
+
const { wrap = true, adapts = false, className, children } = props;
|
|
105
|
+
return (
|
|
106
|
+
<span
|
|
107
|
+
className={cn(
|
|
108
|
+
"flex items-center pointer-events-none",
|
|
109
|
+
BADGE_LINE,
|
|
110
|
+
// A line that does not wrap gives up its last badge first: it takes the
|
|
111
|
+
// cut, and its words end in an ellipsis. Only when it is gone (a stub of
|
|
112
|
+
// its box) and the earlier ones alone overflow do they give up too, each
|
|
113
|
+
// cut by an ellipsis inside its own box, never clipped flat at the row's
|
|
114
|
+
// edge.
|
|
115
|
+
!wrap &&
|
|
116
|
+
`flex-nowrap overflow-hidden ${YIELDS_LAST_EACH} [&>:last-child]:shrink`,
|
|
117
|
+
adapts && "row-two-line:flex-wrap row-two-line:overflow-visible",
|
|
118
|
+
className,
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</span>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** A boolean mark's glyph: the required ring outlined with its centre filled (never a chip's solid dot), or the flag's icon, in the meta ink. */
|
|
127
|
+
function MarkGlyph({ mark }: { mark: RowMark }) {
|
|
128
|
+
if ("ring" in mark)
|
|
129
|
+
return (
|
|
130
|
+
<span aria-hidden className={cn("flex", BADGE_RING)}>
|
|
131
|
+
<span className={BADGE_RING_CENTRE} />
|
|
132
|
+
</span>
|
|
133
|
+
);
|
|
134
|
+
return flagGlyph(mark.flag);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A status's badge: its tone's mark (the dot, the running dots, the waiting ring), then its word, the tone's own word where it brings none. A status with an empty label is its mark alone, named by the tone's word. `painted` is the mark's box and a word's filler. */
|
|
138
|
+
export function StatusBadge(props: { status: StatusMark; painted?: boolean }) {
|
|
139
|
+
const { status, painted } = props;
|
|
140
|
+
const words = useWords();
|
|
141
|
+
if (painted)
|
|
142
|
+
return <Badge glyph={<StatusDot tone="done" painted />} painted />;
|
|
143
|
+
const word = status.label ?? words[status.tone];
|
|
144
|
+
return (
|
|
145
|
+
<Badge
|
|
146
|
+
glyph={
|
|
147
|
+
<StatusDot
|
|
148
|
+
tone={status.tone}
|
|
149
|
+
label={word === "" ? words[status.tone] : undefined}
|
|
150
|
+
/>
|
|
151
|
+
}
|
|
152
|
+
>
|
|
153
|
+
{word}
|
|
154
|
+
</Badge>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function WarningBadge(props: { warning: string; painted?: boolean }) {
|
|
159
|
+
return (
|
|
160
|
+
<Badge
|
|
161
|
+
glyph={warnGlyph({ painted: props.painted })}
|
|
162
|
+
painted={props.painted}
|
|
163
|
+
>
|
|
164
|
+
{props.warning}
|
|
165
|
+
</Badge>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** A chip's badge: the family's dot (a neutral chip has none) and its value. */
|
|
170
|
+
export function ChipBadge({ chip }: { chip: ChipMark }) {
|
|
171
|
+
return (
|
|
172
|
+
<Badge
|
|
173
|
+
glyph={
|
|
174
|
+
chip.family === "neutral" ? null : (
|
|
175
|
+
<span className={chipDot({ family: chip.family })} />
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
>
|
|
179
|
+
{chip.label}
|
|
180
|
+
</Badge>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A boolean mark with its words as a badge: the ring or the flag's icon and its label. A mark whose words are not drawn is no badge. */
|
|
185
|
+
export function MarkBadge({ mark }: { mark: RowMark }) {
|
|
186
|
+
return <Badge glyph={<MarkGlyph mark={mark} />}>{mark.label}</Badge>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** A row's lock as a badge: the lock glyph and its reason, a link to what holds the fact with an `href`, inert without one. */
|
|
190
|
+
export function LockBadge(props: {
|
|
191
|
+
reason: string;
|
|
192
|
+
href?: string;
|
|
193
|
+
painted?: boolean;
|
|
194
|
+
}) {
|
|
195
|
+
return (
|
|
196
|
+
<Badge
|
|
197
|
+
glyph={
|
|
198
|
+
<IconBase
|
|
199
|
+
name="Lock"
|
|
200
|
+
fit="meta"
|
|
201
|
+
stroke="line"
|
|
202
|
+
painted={props.painted}
|
|
203
|
+
/>
|
|
204
|
+
}
|
|
205
|
+
href={props.href}
|
|
206
|
+
painted={props.painted}
|
|
207
|
+
>
|
|
208
|
+
{props.reason}
|
|
209
|
+
</Badge>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Words as a badge: the runs of one fact, a `{ quoted }` run whole (its badge cuts it), a `{ code }` run in the mono. A fact that is one `{ code }` run (a branch, an id) is cut in its middle where the line is out of room, its tail standing whole, as a value is (`valueCut`): the end of an identifier is what tells it apart. */
|
|
214
|
+
export function WordsBadge({ fact }: { fact: Run }) {
|
|
215
|
+
if (isCode(fact))
|
|
216
|
+
return (
|
|
217
|
+
<Badge>
|
|
218
|
+
<CodeCut code={fact.code} />
|
|
219
|
+
</Badge>
|
|
220
|
+
);
|
|
221
|
+
return (
|
|
222
|
+
<Badge>
|
|
223
|
+
<RunText runs={partRuns(fact)} fit="name" />
|
|
224
|
+
</Badge>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Field } from "@base-ui/react/field";
|
|
2
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
3
|
+
import type { RowLeading } from "@slotform/ui-core/descriptors";
|
|
4
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
5
|
+
import type { ChipFamily, Words } from "@slotform/ui-core/tokens";
|
|
6
|
+
import { rowMark, TREE_BLEED, TREE_RAIL } from "@slotform/ui-core/variants";
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
|
+
import { NOOP } from "../../lib/noop.ts";
|
|
9
|
+
import { AvatarBase } from "../avatar/base.tsx";
|
|
10
|
+
import { IconButtonBase, Named } from "../button/glyph.tsx";
|
|
11
|
+
import { Icon, IconBase } from "../icon/index.tsx";
|
|
12
|
+
import { StatusDot } from "../status/dot.tsx";
|
|
13
|
+
import { HeldCheckbox } from "../switch/checkbox.tsx";
|
|
14
|
+
|
|
15
|
+
// The box one body line tall a part stands in, centred on the first line; a
|
|
16
|
+
// taller part overflows it centred.
|
|
17
|
+
const FIRST_LINE = "flex shrink-0 items-center h-line-body";
|
|
18
|
+
// A named type mark lets the pointer rest on it, above the row's hit; on touch
|
|
19
|
+
// it stays passive.
|
|
20
|
+
const NAMED_LEADING = "relative pointer-events-auto touch:pointer-events-none";
|
|
21
|
+
const GLYPH = "flex text-ink-meta";
|
|
22
|
+
// A tree row's levels and fold lane stand as one box that runs the row's full
|
|
23
|
+
// height, over its padding, so a level's rail is unbroken from row to row.
|
|
24
|
+
const TREE = "flex shrink-0 self-stretch";
|
|
25
|
+
|
|
26
|
+
// A row of a tree Section: its depth (the roots 0), the depth of the row
|
|
27
|
+
// under it, for a branch whether its children are drawn and how to fold them,
|
|
28
|
+
// and whether it is the tree's one tab stop.
|
|
29
|
+
export interface RowTree {
|
|
30
|
+
depth: number;
|
|
31
|
+
/** The depth of the row drawn under it (0 for none): the hairline between the two starts at that row's rail, so a child's indent reads as its parent's and no blank column is ruled. */
|
|
32
|
+
under: number;
|
|
33
|
+
/** The row's place among its siblings (`place` of `size`, from 1), which the rows a window leaves unmounted do not tell. */
|
|
34
|
+
size: number;
|
|
35
|
+
place: number;
|
|
36
|
+
/** The item's key, which the tree's keys find the row by. */
|
|
37
|
+
key: string;
|
|
38
|
+
fold: { open: boolean; onToggle: () => void } | undefined;
|
|
39
|
+
tabbable: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// A part standing on the title's first line while the title wraps whole; in a
|
|
43
|
+
// row centred on its lines, `top` lifts it there.
|
|
44
|
+
const FIRST_TOP = "self-start";
|
|
45
|
+
|
|
46
|
+
export function First(props: {
|
|
47
|
+
on: boolean;
|
|
48
|
+
top?: boolean;
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
}) {
|
|
51
|
+
if (!props.on) return props.children;
|
|
52
|
+
return (
|
|
53
|
+
<span className={cn(FIRST_LINE, props.top && FIRST_TOP)}>
|
|
54
|
+
{props.children}
|
|
55
|
+
</span>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// A tree row's rails: one per level, running the row's full height. A
|
|
60
|
+
// branch's fold act stands in the end group (`treeFold`), so no row reserves
|
|
61
|
+
// a lane for one.
|
|
62
|
+
export function TreeLead(props: { tree: RowTree }) {
|
|
63
|
+
const { tree } = props;
|
|
64
|
+
const levels = Array.from({ length: tree.depth }, (_, level) => level);
|
|
65
|
+
if (levels.length === 0) return null;
|
|
66
|
+
return (
|
|
67
|
+
<span className={cn(TREE, TREE_BLEED)}>
|
|
68
|
+
{levels.map((level) => (
|
|
69
|
+
<span key={level} className={TREE_RAIL} />
|
|
70
|
+
))}
|
|
71
|
+
</span>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// A branch's fold act, first in the row's end group.
|
|
76
|
+
export function treeFold(
|
|
77
|
+
tree: RowTree,
|
|
78
|
+
named: string,
|
|
79
|
+
words: Words,
|
|
80
|
+
): ReactNode {
|
|
81
|
+
const { fold } = tree;
|
|
82
|
+
if (!fold) return null;
|
|
83
|
+
return (
|
|
84
|
+
<IconButtonBase
|
|
85
|
+
icon="ChevronDown"
|
|
86
|
+
open={fold.open}
|
|
87
|
+
label={`${fold.open ? words.collapse : words.expand} ${named}`}
|
|
88
|
+
aria-expanded={fold.open}
|
|
89
|
+
tabIndex={-1}
|
|
90
|
+
onClick={fold.onToggle}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function Leading(props: {
|
|
96
|
+
leading: RowLeading;
|
|
97
|
+
named: string;
|
|
98
|
+
painted: boolean;
|
|
99
|
+
tabIndex?: -1;
|
|
100
|
+
}) {
|
|
101
|
+
const words = useWords();
|
|
102
|
+
const { leading, painted, tabIndex } = props;
|
|
103
|
+
// Painted, the kind is the region's shape; what the marks name is not here.
|
|
104
|
+
if (painted) {
|
|
105
|
+
if ("check" in leading)
|
|
106
|
+
return <HeldCheckbox checked={false} onChange={NOOP} label="" painted />;
|
|
107
|
+
if ("avatar" in leading) return <AvatarBase name="" painted />;
|
|
108
|
+
if ("tone" in leading) return <StatusDot tone="done" painted />;
|
|
109
|
+
if ("mark" in leading)
|
|
110
|
+
return <span aria-hidden className={rowMark({ family: "neutral" })} />;
|
|
111
|
+
return <IconBase name="File" stroke="line" painted />;
|
|
112
|
+
}
|
|
113
|
+
if ("check" in leading)
|
|
114
|
+
return (
|
|
115
|
+
<Field.Root disabled={leading.check.blocked !== undefined}>
|
|
116
|
+
<HeldCheckbox
|
|
117
|
+
checked={leading.check.checked}
|
|
118
|
+
onChange={leading.check.onChange}
|
|
119
|
+
label={props.named}
|
|
120
|
+
tabIndex={tabIndex}
|
|
121
|
+
/>
|
|
122
|
+
</Field.Root>
|
|
123
|
+
);
|
|
124
|
+
if ("avatar" in leading)
|
|
125
|
+
return <AvatarBase name={leading.avatar.name} src={leading.avatar.src} />;
|
|
126
|
+
if ("tone" in leading)
|
|
127
|
+
return (
|
|
128
|
+
<StatusDot
|
|
129
|
+
tone={leading.tone}
|
|
130
|
+
label={leading.label ?? words[leading.tone]}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
if ("mark" in leading) return <TypeMark leading={leading} />;
|
|
134
|
+
return (
|
|
135
|
+
<span className={GLYPH}>
|
|
136
|
+
<Icon name={leading.icon} />
|
|
137
|
+
</span>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// A type's mark: named, with its tooltip, when it has a label; decorative and
|
|
142
|
+
// hidden without one.
|
|
143
|
+
function TypeMark({
|
|
144
|
+
leading,
|
|
145
|
+
}: {
|
|
146
|
+
leading: { mark: string; family: ChipFamily; label?: string };
|
|
147
|
+
}) {
|
|
148
|
+
const { mark, family, label } = leading;
|
|
149
|
+
if (label === undefined)
|
|
150
|
+
return (
|
|
151
|
+
<span aria-hidden className={rowMark({ family })}>
|
|
152
|
+
{mark}
|
|
153
|
+
</span>
|
|
154
|
+
);
|
|
155
|
+
return (
|
|
156
|
+
<Named label={label}>
|
|
157
|
+
<span
|
|
158
|
+
role="img"
|
|
159
|
+
aria-label={label}
|
|
160
|
+
className={cn(rowMark({ family }), NAMED_LEADING)}
|
|
161
|
+
>
|
|
162
|
+
{mark}
|
|
163
|
+
</span>
|
|
164
|
+
</Named>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { LOCK_GLYPH } from "@slotform/ui-core/variants";
|
|
3
|
+
import { IconBase } from "../icon/index.tsx";
|
|
4
|
+
|
|
5
|
+
const MARK = "flex items-center min-w-icon-meta";
|
|
6
|
+
const FIXED = "shrink-0";
|
|
7
|
+
|
|
8
|
+
/** A lock glyph in a table's column head: the meta glyph, inert. A row's lock is a badge with its reason (`LockBadge`). Outside the package's exports. */
|
|
9
|
+
export function LockMark() {
|
|
10
|
+
return (
|
|
11
|
+
<span className={cn(MARK, FIXED)}>
|
|
12
|
+
<span className={cn(LOCK_GLYPH, "flex")}>
|
|
13
|
+
<IconBase name="Lock" fit="meta" stroke="line" />
|
|
14
|
+
</span>
|
|
15
|
+
</span>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type { IconName, RowMark } from "@slotform/ui-core/descriptors";
|
|
3
|
+
import {
|
|
4
|
+
ROW_FLAG,
|
|
5
|
+
ROW_MARKS,
|
|
6
|
+
ROW_RING,
|
|
7
|
+
ROW_RING_FILLED,
|
|
8
|
+
ROW_WARNING,
|
|
9
|
+
text,
|
|
10
|
+
} from "@slotform/ui-core/variants";
|
|
11
|
+
import { Painted } from "../../lib/paint.tsx";
|
|
12
|
+
import { Named } from "../button/glyph.tsx";
|
|
13
|
+
import { IconBase } from "../icon/index.tsx";
|
|
14
|
+
|
|
15
|
+
// A mark's glyph beside its label, the label truncating before the glyph does.
|
|
16
|
+
const MARK = "flex items-center min-w-icon-meta";
|
|
17
|
+
const GLYPH = "flex shrink-0 items-center";
|
|
18
|
+
const LABEL = "truncate";
|
|
19
|
+
// The glyph names the sentence on hover where its label is cut to nothing; on touch
|
|
20
|
+
// it stays passive and a press reaches the row.
|
|
21
|
+
const GLYPH_NAMED = "relative pointer-events-auto touch:pointer-events-none";
|
|
22
|
+
|
|
23
|
+
// The warn glyph in the warn ink, `named` where it takes the pointer for its
|
|
24
|
+
// tooltip; an element, not a component, so a `Named` trigger can wrap it.
|
|
25
|
+
export function warnGlyph(props: { painted?: boolean; named?: boolean }) {
|
|
26
|
+
return (
|
|
27
|
+
<span className={cn(ROW_WARNING, GLYPH, props.named && GLYPH_NAMED)}>
|
|
28
|
+
<IconBase
|
|
29
|
+
name="TriangleAlert"
|
|
30
|
+
fit="meta"
|
|
31
|
+
stroke="line"
|
|
32
|
+
painted={props.painted}
|
|
33
|
+
/>
|
|
34
|
+
</span>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A flag mark's icon in the meta ink.
|
|
39
|
+
export function flagGlyph(flag: IconName) {
|
|
40
|
+
return (
|
|
41
|
+
<span aria-hidden className={cn(ROW_FLAG, GLYPH)}>
|
|
42
|
+
<IconBase name={flag} fit="meta" stroke="line" />
|
|
43
|
+
</span>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** What is wrong, in a table's cell: a warn glyph and its sentence in the meta ink, the sentence truncating; `painted` while the sentence is not here, the glyph's box and a phrase's filler. A row's and a head's warning is a badge (`WarningBadge`). Outside the package's exports. */
|
|
48
|
+
export function WarningMark(props: { label: string; painted?: boolean }) {
|
|
49
|
+
const glyph = warnGlyph({ painted: props.painted, named: !props.painted });
|
|
50
|
+
return (
|
|
51
|
+
<span className={cn(ROW_MARKS, MARK)}>
|
|
52
|
+
{props.painted ? glyph : <Named label={props.label}>{glyph}</Named>}
|
|
53
|
+
<span className={cn(text({ role: "meta" }), LABEL)}>
|
|
54
|
+
{props.painted ? <Painted role="phrase" /> : props.label}
|
|
55
|
+
</span>
|
|
56
|
+
</span>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A boolean mark whose words are not drawn (`words: false`): its glyph alone, a row's end group's first item, named for assistive tech by its label and, on hover, by a tooltip; on touch it stays passive and a press reaches the row. Outside the package's exports. */
|
|
61
|
+
export function EndMark({ mark }: { mark: RowMark }) {
|
|
62
|
+
const glyph =
|
|
63
|
+
"ring" in mark ? (
|
|
64
|
+
<span aria-hidden className={cn(ROW_RING, ROW_RING_FILLED)} />
|
|
65
|
+
) : (
|
|
66
|
+
flagGlyph(mark.flag)
|
|
67
|
+
);
|
|
68
|
+
return (
|
|
69
|
+
<Named label={mark.label}>
|
|
70
|
+
<span
|
|
71
|
+
role="img"
|
|
72
|
+
aria-label={mark.label}
|
|
73
|
+
className={cn("flex items-center shrink-0", GLYPH_NAMED)}
|
|
74
|
+
>
|
|
75
|
+
{glyph}
|
|
76
|
+
</span>
|
|
77
|
+
</Named>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { GROUP } from "@slotform/ui-core/variants";
|
|
3
|
+
import type { ReactNode, RefObject } from "react";
|
|
4
|
+
|
|
5
|
+
const BOX = "shrink-0 overflow-hidden";
|
|
6
|
+
|
|
7
|
+
// A divided sheet's, a form group's and a docked sheet's hairline is a
|
|
8
|
+
// pseudo-element on each row but the last, not the row's border, so it runs
|
|
9
|
+
// straight across the row's whole width under a rounded wash.
|
|
10
|
+
export const DIVIDER =
|
|
11
|
+
"[&>:not(:last-child)]:relative [&>:not(:last-child)]:after:absolute [&>:not(:last-child)]:after:inset-x-0 [&>:not(:last-child)]:after:bottom-0 [&>:not(:last-child)]:after:h-px [&>:not(:last-child)]:after:bg-edge";
|
|
12
|
+
|
|
13
|
+
// A tree's hairline: docs/architecture/ui-core/layout.md, "Trees".
|
|
14
|
+
export const TREE_DIVIDER =
|
|
15
|
+
"[&>:not(:last-child)]:relative [&>:not(:last-child)]:after:absolute [&>:not(:last-child)]:after:end-0 [&>:not(:last-child)]:after:start-[calc(min(var(--rule-depth,0),1)*(var(--spacing-pad)-var(--spacing-hairline))+var(--rule-depth,0)*var(--spacing-stack))] [&>:not(:last-child)]:after:bottom-0 [&>:not(:last-child)]:after:h-px [&>:not(:last-child)]:after:bg-edge";
|
|
16
|
+
|
|
17
|
+
/** The hairline card every Section's rows stand on: the box its entries window in when they are many. Outside the package's exports. */
|
|
18
|
+
export function SheetCard(props: {
|
|
19
|
+
box?: RefObject<HTMLDivElement | null>;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<div ref={props.box} className={cn(GROUP, BOX, DIVIDER)}>
|
|
24
|
+
{props.children}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import {
|
|
3
|
+
BUSY_GLYPHS,
|
|
4
|
+
SPINNER,
|
|
5
|
+
SPINNER_ARC,
|
|
6
|
+
SPINNER_TRACK,
|
|
7
|
+
} from "@slotform/ui-core/variants";
|
|
8
|
+
import { BusyGlyphs, busyScrambles } from "../../lib/scramble.tsx";
|
|
9
|
+
|
|
10
|
+
// It enters by a fade on `fast`, then turns (the loop keeps turning under
|
|
11
|
+
// reduced motion; the fade snaps).
|
|
12
|
+
const BOX = "relative shrink-0 animate-spinner-in";
|
|
13
|
+
const TRACK = "absolute inset-0 border-current";
|
|
14
|
+
// The ink goes ahead of the cell: tailwind-merge drops an earlier
|
|
15
|
+
// `border-t-transparent` under a later border colour, where the cascade
|
|
16
|
+
// keeps it.
|
|
17
|
+
const ARC_INK = "border-current";
|
|
18
|
+
const ARC = "absolute inset-0 animate-spin";
|
|
19
|
+
// Three glyphs wide, the ink of its place.
|
|
20
|
+
const GLYPHS =
|
|
21
|
+
"inline-flex shrink-0 items-center justify-center overflow-hidden animate-spinner-in";
|
|
22
|
+
|
|
23
|
+
/** A turning ring in the ink of its place (currentColor), the size of the glyph it replaces; hidden from assistive tech, since its owner announces the wait. Where the theme scrambles its text (`theme.loading`) it is three mono glyphs cycling at the tick in a box three glyphs wide, `···` under reduced motion. */
|
|
24
|
+
export function Spinner() {
|
|
25
|
+
if (busyScrambles())
|
|
26
|
+
return (
|
|
27
|
+
<span
|
|
28
|
+
aria-hidden
|
|
29
|
+
data-spinner
|
|
30
|
+
style={{ width: "3ch" }}
|
|
31
|
+
className={cn(BUSY_GLYPHS, GLYPHS)}
|
|
32
|
+
>
|
|
33
|
+
<BusyGlyphs />
|
|
34
|
+
</span>
|
|
35
|
+
);
|
|
36
|
+
return (
|
|
37
|
+
<span aria-hidden className={cn(SPINNER, BOX)}>
|
|
38
|
+
<span className={cn(SPINNER_TRACK, TRACK)} />
|
|
39
|
+
<span className={cn(ARC_INK, SPINNER_ARC, ARC)} />
|
|
40
|
+
</span>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
3
|
+
import type { Tone } from "@slotform/ui-core/tokens";
|
|
4
|
+
import {
|
|
5
|
+
STATE_CHIP_LABEL,
|
|
6
|
+
STATUS,
|
|
7
|
+
STATUS_LABEL,
|
|
8
|
+
stateChip,
|
|
9
|
+
} from "@slotform/ui-core/variants";
|
|
10
|
+
import { Painted } from "../../lib/paint.tsx";
|
|
11
|
+
import { StatusDot } from "./dot.tsx";
|
|
12
|
+
|
|
13
|
+
const BOX = "inline-flex items-center min-w-0 max-w-full";
|
|
14
|
+
const WORD = "truncate";
|
|
15
|
+
/** What every status draws: the public `Status`, or `painted` (the dot's box and a word's filler while the status's data is not here, inert). A state chip (a status given its own word) is a chip: the caption line between its hairlines, wherever it stands. Outside the package's exports. */
|
|
16
|
+
export function StatusBase(
|
|
17
|
+
props:
|
|
18
|
+
| {
|
|
19
|
+
tone: Tone;
|
|
20
|
+
label?: string;
|
|
21
|
+
painted?: never;
|
|
22
|
+
}
|
|
23
|
+
| { painted: true },
|
|
24
|
+
) {
|
|
25
|
+
const words = useWords();
|
|
26
|
+
if (props.painted)
|
|
27
|
+
return (
|
|
28
|
+
<span inert className={cn(STATUS, BOX)}>
|
|
29
|
+
<StatusDot tone="done" painted />
|
|
30
|
+
<span className={cn(STATUS_LABEL, WORD)}>
|
|
31
|
+
<Painted role="word" />
|
|
32
|
+
</span>
|
|
33
|
+
</span>
|
|
34
|
+
);
|
|
35
|
+
const label = props.label ?? words[props.tone];
|
|
36
|
+
// A status given its own word is a state chip: the state's dot (the spinner
|
|
37
|
+
// while running) and word on the state's soft fill under its hairline.
|
|
38
|
+
if (props.label !== undefined)
|
|
39
|
+
return (
|
|
40
|
+
<span className={cn(stateChip({ tone: props.tone }), STATUS, BOX)}>
|
|
41
|
+
<StatusDot tone={props.tone} />
|
|
42
|
+
<span className={cn(STATE_CHIP_LABEL, WORD)}>{label}</span>
|
|
43
|
+
</span>
|
|
44
|
+
);
|
|
45
|
+
return (
|
|
46
|
+
<span className={cn(STATUS, BOX)}>
|
|
47
|
+
<StatusDot tone={props.tone} />
|
|
48
|
+
<span className={cn(STATUS_LABEL, WORD)}>{label}</span>
|
|
49
|
+
</span>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type { ChangeKind } from "@slotform/ui-core/descriptors";
|
|
3
|
+
import { CHANGE_GLYPH } from "@slotform/ui-core/list-state";
|
|
4
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
5
|
+
import { changeMark } from "@slotform/ui-core/variants";
|
|
6
|
+
import { Named } from "../button/glyph.tsx";
|
|
7
|
+
import { IconBase } from "../icon/index.tsx";
|
|
8
|
+
|
|
9
|
+
const BOX = "flex shrink-0 items-center justify-center";
|
|
10
|
+
// The glyph names its kind on hover, standing above a row's hit; on touch it
|
|
11
|
+
// stays passive and a press reaches the row.
|
|
12
|
+
const NAMED = "relative pointer-events-auto touch:pointer-events-none";
|
|
13
|
+
|
|
14
|
+
/** Where a row, a fact or a field stands in a change set: its kind's glyph in the kind's ink in a lane one icon wide, named by the kind's word (its accessible name and tooltip). A change set marks every row, its untouched ones `unchanged`, so the names line up. Outside the package's exports. */
|
|
15
|
+
export function ChangeMark(props: { kind: ChangeKind }) {
|
|
16
|
+
const { kind } = props;
|
|
17
|
+
const words = useWords();
|
|
18
|
+
return (
|
|
19
|
+
<Named label={words[kind]}>
|
|
20
|
+
<span
|
|
21
|
+
role="img"
|
|
22
|
+
aria-label={words[kind]}
|
|
23
|
+
className={cn(changeMark({ kind }), BOX, NAMED)}
|
|
24
|
+
>
|
|
25
|
+
<IconBase name={CHANGE_GLYPH[kind]} fit="meta" stroke="mark" />
|
|
26
|
+
</span>
|
|
27
|
+
</Named>
|
|
28
|
+
);
|
|
29
|
+
}
|