@slotform/react-ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,42 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { initials } from "@slotform/ui-core/format";
|
|
3
|
+
import { avatar, avatarLabel, avatarStep } from "@slotform/ui-core/variants";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { PAINT_BOX } from "../../lib/paint.tsx";
|
|
6
|
+
|
|
7
|
+
const CIRCLE =
|
|
8
|
+
"inline-flex items-center justify-center shrink-0 overflow-hidden";
|
|
9
|
+
const IMAGE = "shrink-0 object-cover";
|
|
10
|
+
|
|
11
|
+
/** The image, else (none, or one that failed to load) the name's initials on the fill step its hash picks, so one name keeps one fill. `painted` is the circle while its person is not here: its box filled, nothing drawn in it. Outside the package's exports. */
|
|
12
|
+
export function AvatarBase({
|
|
13
|
+
name,
|
|
14
|
+
src,
|
|
15
|
+
painted,
|
|
16
|
+
}: {
|
|
17
|
+
name: string;
|
|
18
|
+
src?: string;
|
|
19
|
+
painted?: boolean;
|
|
20
|
+
}) {
|
|
21
|
+
const [failed, setFailed] = useState<string>();
|
|
22
|
+
const step = avatarStep(name);
|
|
23
|
+
if (painted)
|
|
24
|
+
return <span aria-hidden className={cn(avatar(), CIRCLE, PAINT_BOX)} />;
|
|
25
|
+
// Keyed by the URL that failed, so a new src is tried again.
|
|
26
|
+
if (src && src !== failed)
|
|
27
|
+
return (
|
|
28
|
+
<img
|
|
29
|
+
src={src}
|
|
30
|
+
alt={name}
|
|
31
|
+
onError={() => setFailed(src)}
|
|
32
|
+
className={cn(avatar(), IMAGE)}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
return (
|
|
36
|
+
<span role="img" aria-label={name} className={cn(avatar({ step }), CIRCLE)}>
|
|
37
|
+
<span aria-hidden className={avatarLabel({ step })}>
|
|
38
|
+
{initials(name)}
|
|
39
|
+
</span>
|
|
40
|
+
</span>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Button as BaseButton } from "@base-ui/react/button";
|
|
2
|
+
import { Tooltip } from "@base-ui/react/tooltip";
|
|
3
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
4
|
+
import type { IconName } from "@slotform/ui-core/descriptors";
|
|
5
|
+
import { FieldDisabled } from "@slotform/ui-core/react/field";
|
|
6
|
+
import {
|
|
7
|
+
ICON_BUTTON_DESTRUCTIVE,
|
|
8
|
+
ICON_BUTTON_PRIMARY,
|
|
9
|
+
type IconButtonFit,
|
|
10
|
+
iconButton,
|
|
11
|
+
LAYER_TOOLTIP,
|
|
12
|
+
TOOLTIP,
|
|
13
|
+
TOOLTIP_CUT,
|
|
14
|
+
} from "@slotform/ui-core/variants";
|
|
15
|
+
import { type ReactElement, type ReactNode, use, useContext } from "react";
|
|
16
|
+
import { spacing } from "../../lib/measure.ts";
|
|
17
|
+
import { useTouch } from "../../lib/media.ts";
|
|
18
|
+
import { follow } from "../../lib/navigate.ts";
|
|
19
|
+
import { PAINT_BOX } from "../../lib/paint.tsx";
|
|
20
|
+
import { PortalContainer } from "../../lib/portal.ts";
|
|
21
|
+
import { hid } from "../../lib/rest.ts";
|
|
22
|
+
import { Swap } from "../../lib/swap.tsx";
|
|
23
|
+
import { Icon } from "../icon/index.tsx";
|
|
24
|
+
import { Spinner } from "../spinner/index.tsx";
|
|
25
|
+
import { Turn } from "../turn.tsx";
|
|
26
|
+
import { BLOCKED, FADE_IN, FADE_OUT, type Handed, PRESS } from "./look.ts";
|
|
27
|
+
|
|
28
|
+
const BOX = "relative inline-flex items-center justify-center shrink-0";
|
|
29
|
+
// Inside a field or a clipping frame the ring is drawn inset.
|
|
30
|
+
const INSET = "focus-visible:-outline-offset-2";
|
|
31
|
+
// A trigger stays pressed while its popup is open: docs/architecture/plugins/react-ui.md, "Icon acts".
|
|
32
|
+
const GLYPH_PRESS =
|
|
33
|
+
"hover:bg-wash-hover hover:text-ink-body active:bg-wash-press active:text-ink-body aria-expanded:bg-wash-press aria-expanded:text-ink-body";
|
|
34
|
+
// A disclosure (a branch's fold) is expanded while its body shows, which is no
|
|
35
|
+
// popup: its chevron stands bare in the meta ink open or closed, as a
|
|
36
|
+
// Section's fold toggle's does, and only turns.
|
|
37
|
+
const DISCLOSE =
|
|
38
|
+
"hover:bg-wash-hover hover:text-ink-body active:bg-wash-press active:text-ink-body";
|
|
39
|
+
const SPINNER_LAYER = cn(
|
|
40
|
+
"absolute inset-0 flex items-center justify-center",
|
|
41
|
+
FADE_IN,
|
|
42
|
+
);
|
|
43
|
+
// Painted, the glyph keeps its place and is filled in its own box, the button
|
|
44
|
+
// around it staying as bare as the loaded one: an icon act is a glyph, so its
|
|
45
|
+
// waiting shape is a glyph's worth of fill where it will stand, never a filled
|
|
46
|
+
// button.
|
|
47
|
+
const PAINT_GLYPH = cn(PAINT_BOX, "rounded-chip *:invisible");
|
|
48
|
+
// The name draws over a sheet's scrim and under the toasts, with the popovers.
|
|
49
|
+
const POSITIONER = "z-(--layer-popover)";
|
|
50
|
+
// The hover rest before the name shows, a beat longer than a pointer passing
|
|
51
|
+
// over the act and short enough that a rested pointer is answered.
|
|
52
|
+
export const SHOW_AFTER = 500;
|
|
53
|
+
|
|
54
|
+
/** The icon act every Button's icon form and every popup trigger renders. Outside the package's exports: a molecule hands it to a trigger's `render`. */
|
|
55
|
+
export function IconButtonBase({
|
|
56
|
+
icon,
|
|
57
|
+
fit,
|
|
58
|
+
label,
|
|
59
|
+
pending,
|
|
60
|
+
inset: framed,
|
|
61
|
+
painted,
|
|
62
|
+
open,
|
|
63
|
+
destructive,
|
|
64
|
+
primary,
|
|
65
|
+
blocked,
|
|
66
|
+
...handed
|
|
67
|
+
}: Handed & {
|
|
68
|
+
icon: IconName;
|
|
69
|
+
fit?: IconButtonFit;
|
|
70
|
+
label: string;
|
|
71
|
+
// An act that removes or ends something: the danger ink.
|
|
72
|
+
destructive?: boolean;
|
|
73
|
+
// The act the bar is for: the accent fill.
|
|
74
|
+
primary?: boolean;
|
|
75
|
+
// The act is running: inert at once, then (after `tuned.actDelay`) its glyph swapped for the spinner.
|
|
76
|
+
pending?: boolean;
|
|
77
|
+
// Its frame clips (a Code's): the focus ring is drawn inset, so the clip never cuts it.
|
|
78
|
+
inset?: boolean;
|
|
79
|
+
// Its data is not here: the glyph's box filled, the glyph not drawn, inert.
|
|
80
|
+
painted?: boolean;
|
|
81
|
+
// A disclosure: the glyph is the chevron down, turned a quarter while it is closed, so it turns where a swapped glyph would pop.
|
|
82
|
+
open?: boolean;
|
|
83
|
+
// Blocked under a host that draws the reason: the blocked look and no run, but the press still lands, so the host can say why.
|
|
84
|
+
blocked?: boolean;
|
|
85
|
+
}) {
|
|
86
|
+
// Inert inside a disabled field, or when its holder says so (a sheet's
|
|
87
|
+
// close while its act pends), or while it runs.
|
|
88
|
+
const disabled =
|
|
89
|
+
useContext(FieldDisabled) || handed.disabled === true || pending === true;
|
|
90
|
+
const inset = framed || fit === "field";
|
|
91
|
+
// The primary glyph's fill answers the pointer and reads blocked as a
|
|
92
|
+
// primary Button's does; any other glyph as a secondary one.
|
|
93
|
+
const kind = primary ? "primary" : "secondary";
|
|
94
|
+
const rest = open === undefined ? GLYPH_PRESS : DISCLOSE;
|
|
95
|
+
const look = painted
|
|
96
|
+
? undefined
|
|
97
|
+
: disabled || blocked
|
|
98
|
+
? BLOCKED[kind]
|
|
99
|
+
: primary
|
|
100
|
+
? PRESS.primary
|
|
101
|
+
: rest;
|
|
102
|
+
return (
|
|
103
|
+
<Named label={label}>
|
|
104
|
+
<BaseButton
|
|
105
|
+
{...handed}
|
|
106
|
+
aria-label={label}
|
|
107
|
+
aria-busy={pending || undefined}
|
|
108
|
+
aria-disabled={blocked || undefined}
|
|
109
|
+
inert={painted || undefined}
|
|
110
|
+
disabled={disabled}
|
|
111
|
+
focusableWhenDisabled
|
|
112
|
+
className={cn(
|
|
113
|
+
iconButton({ fit }),
|
|
114
|
+
destructive && ICON_BUTTON_DESTRUCTIVE,
|
|
115
|
+
primary && ICON_BUTTON_PRIMARY,
|
|
116
|
+
BOX,
|
|
117
|
+
inset && INSET,
|
|
118
|
+
// A running act keeps the rest ink under its spinner and takes no wash.
|
|
119
|
+
pending ? undefined : look,
|
|
120
|
+
)}
|
|
121
|
+
>
|
|
122
|
+
<span
|
|
123
|
+
className={cn(
|
|
124
|
+
"inline-flex",
|
|
125
|
+
pending && FADE_OUT,
|
|
126
|
+
painted && PAINT_GLYPH,
|
|
127
|
+
)}
|
|
128
|
+
>
|
|
129
|
+
{open === undefined ? (
|
|
130
|
+
// A glyph swapped while shown (a copy act's check) is a mark change.
|
|
131
|
+
<Swap id={icon} scale>
|
|
132
|
+
<Icon name={icon} fit="control" />
|
|
133
|
+
</Swap>
|
|
134
|
+
) : (
|
|
135
|
+
<Turn
|
|
136
|
+
name="ChevronDown"
|
|
137
|
+
fit="control"
|
|
138
|
+
turned={!open}
|
|
139
|
+
by="quarter"
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
</span>
|
|
143
|
+
{pending ? (
|
|
144
|
+
<span className={SPINNER_LAYER}>
|
|
145
|
+
<Spinner />
|
|
146
|
+
</span>
|
|
147
|
+
) : null}
|
|
148
|
+
</BaseButton>
|
|
149
|
+
</Named>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// The act's name in a tooltip: docs/architecture/plugins/react-ui.md, "Icon acts".
|
|
154
|
+
function handedByDialog(event: Event): boolean {
|
|
155
|
+
if (!(event instanceof FocusEvent) || !(event.target instanceof Element))
|
|
156
|
+
return false;
|
|
157
|
+
const dialog = event.target.closest('[role="dialog"]');
|
|
158
|
+
if (!dialog) return false;
|
|
159
|
+
return !(
|
|
160
|
+
event.relatedTarget instanceof Node && dialog.contains(event.relatedTarget)
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** The tooltip's popup: a name in the popover's ground, standing a pair off its anchor (the trigger inside a `Tooltip.Root`, else the `anchor` it is given). Outside the package's exports; the cut-text tooltip draws it too. */
|
|
165
|
+
export function NamePopup(props: {
|
|
166
|
+
anchor?: Element;
|
|
167
|
+
// Cut text's whole text, which may grow past an icon name's short measure.
|
|
168
|
+
cut?: boolean;
|
|
169
|
+
// It shows with no fade: it opened with no rest, within the last's `RECENT`.
|
|
170
|
+
instant?: boolean;
|
|
171
|
+
children: ReactNode;
|
|
172
|
+
}) {
|
|
173
|
+
const container = use(PortalContainer);
|
|
174
|
+
return (
|
|
175
|
+
<Tooltip.Portal container={container}>
|
|
176
|
+
<Tooltip.Positioner
|
|
177
|
+
anchor={props.anchor}
|
|
178
|
+
className={POSITIONER}
|
|
179
|
+
sideOffset={() => spacing("gap")}
|
|
180
|
+
>
|
|
181
|
+
<Tooltip.Popup
|
|
182
|
+
{...(props.instant ? { "data-instant": "delay" } : {})}
|
|
183
|
+
className={cn(props.cut ? TOOLTIP_CUT : TOOLTIP, LAYER_TOOLTIP)}
|
|
184
|
+
>
|
|
185
|
+
{props.children}
|
|
186
|
+
</Tooltip.Popup>
|
|
187
|
+
</Tooltip.Positioner>
|
|
188
|
+
</Tooltip.Portal>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** A name shown as a tooltip over its trigger, off on touch, or while `off` (a trigger that wears the name only some of the time keeps its place in the tree). Outside the package's exports; a row's marks wear it too. */
|
|
193
|
+
export function Named(props: {
|
|
194
|
+
label: string;
|
|
195
|
+
off?: boolean;
|
|
196
|
+
children: ReactElement;
|
|
197
|
+
}) {
|
|
198
|
+
const touch = useTouch();
|
|
199
|
+
return (
|
|
200
|
+
<Tooltip.Root
|
|
201
|
+
disabled={touch || props.off}
|
|
202
|
+
disableHoverablePopup
|
|
203
|
+
onOpenChange={(open, details) => {
|
|
204
|
+
if (!open) hid();
|
|
205
|
+
if (
|
|
206
|
+
open &&
|
|
207
|
+
details.reason === "trigger-focus" &&
|
|
208
|
+
handedByDialog(details.event)
|
|
209
|
+
)
|
|
210
|
+
details.cancel();
|
|
211
|
+
// Escape hides the name and still reaches what the act sits in: a
|
|
212
|
+
// sheet opened on its close act closes on the one press.
|
|
213
|
+
if (!open && details.reason === "escape-key")
|
|
214
|
+
details.allowPropagation();
|
|
215
|
+
}}
|
|
216
|
+
>
|
|
217
|
+
<Tooltip.Trigger delay={SHOW_AFTER} render={props.children} />
|
|
218
|
+
<NamePopup>{props.label}</NamePopup>
|
|
219
|
+
</Tooltip.Root>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The icon act that goes to a route: an anchor in the icon form's look, for a back or close act. Outside the package's exports. */
|
|
224
|
+
export function IconButtonLink(props: {
|
|
225
|
+
icon: IconName;
|
|
226
|
+
fit?: IconButtonFit;
|
|
227
|
+
label: string;
|
|
228
|
+
href: string;
|
|
229
|
+
tabIndex?: -1;
|
|
230
|
+
}) {
|
|
231
|
+
return (
|
|
232
|
+
<Named label={props.label}>
|
|
233
|
+
<a
|
|
234
|
+
href={props.href}
|
|
235
|
+
onClick={follow}
|
|
236
|
+
tabIndex={props.tabIndex}
|
|
237
|
+
aria-label={props.label}
|
|
238
|
+
className={cn(iconButton({ fit: props.fit }), BOX, GLYPH_PRESS)}
|
|
239
|
+
>
|
|
240
|
+
<Icon name={props.icon} fit="control" />
|
|
241
|
+
</a>
|
|
242
|
+
</Named>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type { IconName } from "@slotform/ui-core/descriptors";
|
|
3
|
+
import {
|
|
4
|
+
type ButtonAct,
|
|
5
|
+
type ButtonFit,
|
|
6
|
+
button,
|
|
7
|
+
buttonLabel,
|
|
8
|
+
LINK_TARGET,
|
|
9
|
+
link,
|
|
10
|
+
} from "@slotform/ui-core/variants";
|
|
11
|
+
import type { ReactNode } from "react";
|
|
12
|
+
import { follow } from "../../lib/navigate.ts";
|
|
13
|
+
import { Icon } from "../icon/index.tsx";
|
|
14
|
+
import { BOX, LABEL, PRESS } from "./look.ts";
|
|
15
|
+
|
|
16
|
+
// An act's anchor keeps to its words in a stretching parent (a Gate's step), as a Button does in its stack; the `field` fit that spans its container comes after it and wins.
|
|
17
|
+
const KEEPS = "w-fit";
|
|
18
|
+
const GLYPH = "shrink-0";
|
|
19
|
+
|
|
20
|
+
// The accent anchor: inline is underlined at rest and plain under the pointer;
|
|
21
|
+
// on its own the other way round, on the target height. The line is always
|
|
22
|
+
// there and its colour comes and goes, which the link's answer eases (a line
|
|
23
|
+
// switched on and off would pop). A standalone anchor's box keeps to its words
|
|
24
|
+
// in a stretching parent.
|
|
25
|
+
export const TEXT_PRESS = {
|
|
26
|
+
inline: "hover:decoration-transparent active:decoration-transparent",
|
|
27
|
+
standalone: cn(
|
|
28
|
+
LINK_TARGET,
|
|
29
|
+
"inline-flex items-center w-fit underline decoration-transparent hover:decoration-current active:decoration-current",
|
|
30
|
+
),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** An anchor to a route or an external URL. A plain click opens a route through the router, and a new tab, a copied link and a middle click stay the browser's. It runs nothing, so it never pends and is never blocked. With an `act` it draws in that Button's look (a way back, a Section's or a row's act that navigates; `ink` is the text class a quiet act draws in); with none, in accent ink, in the type of the line it sits in, its words the `label` or the `children` (a markdown link's runs). Outside the package's exports: the Button draws it, or a molecule whose words are nodes. */
|
|
34
|
+
export function ButtonLink(props: {
|
|
35
|
+
act?: ButtonAct;
|
|
36
|
+
fit?: ButtonFit | "inline";
|
|
37
|
+
icon?: IconName;
|
|
38
|
+
label?: string;
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
href: string;
|
|
41
|
+
/** `-1` where the act's host holds the tab stop (a tree's row). */
|
|
42
|
+
tabIndex?: -1;
|
|
43
|
+
}) {
|
|
44
|
+
const tab = props.tabIndex === undefined ? {} : { tabIndex: props.tabIndex };
|
|
45
|
+
if (props.act === undefined) {
|
|
46
|
+
const place = props.fit === "inline" ? "inline" : "standalone";
|
|
47
|
+
return (
|
|
48
|
+
<a
|
|
49
|
+
href={props.href}
|
|
50
|
+
onClick={follow}
|
|
51
|
+
{...tab}
|
|
52
|
+
className={cn(link({ fit: place }), TEXT_PRESS[place])}
|
|
53
|
+
>
|
|
54
|
+
{props.children ?? props.label}
|
|
55
|
+
</a>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const kind = props.act;
|
|
59
|
+
return (
|
|
60
|
+
<a
|
|
61
|
+
href={props.href}
|
|
62
|
+
onClick={follow}
|
|
63
|
+
{...tab}
|
|
64
|
+
className={cn(
|
|
65
|
+
KEEPS,
|
|
66
|
+
button({ act: kind, fit: props.fit === "inline" ? "body" : props.fit }),
|
|
67
|
+
BOX,
|
|
68
|
+
PRESS[kind],
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
{props.icon ? (
|
|
72
|
+
<span className={GLYPH}>
|
|
73
|
+
<Icon name={props.icon} fit="control" />
|
|
74
|
+
</span>
|
|
75
|
+
) : null}
|
|
76
|
+
<span className={cn(buttonLabel({ act: kind }), LABEL)}>
|
|
77
|
+
{props.children ?? props.label}
|
|
78
|
+
</span>
|
|
79
|
+
</a>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ButtonAct, PRESS_WASH } from "@slotform/ui-core/variants";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
import type { Closed } from "../../lib/closed.ts";
|
|
4
|
+
|
|
5
|
+
// The press a public Button maps from `onAct`, or the props a Base UI trigger
|
|
6
|
+
// hands through its `render` (a popup's trigger): never a style channel.
|
|
7
|
+
export type Handed = Omit<ComponentProps<"button">, keyof Closed | "children">;
|
|
8
|
+
|
|
9
|
+
export const BOX =
|
|
10
|
+
"relative inline-flex items-center justify-center max-w-full min-w-0";
|
|
11
|
+
export const LABEL = "truncate";
|
|
12
|
+
|
|
13
|
+
export const PRESS: Record<ButtonAct, string> = {
|
|
14
|
+
primary: "hover:bg-act-accent-hover active:bg-act-accent-press",
|
|
15
|
+
danger: "hover:bg-act-danger-hover active:bg-act-danger-press",
|
|
16
|
+
secondary: PRESS_WASH,
|
|
17
|
+
destructive: PRESS_WASH,
|
|
18
|
+
quiet: PRESS_WASH,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const BLOCKED: Record<ButtonAct, string> = {
|
|
22
|
+
primary: "aria-disabled:bg-fill-disabled aria-disabled:text-ink-meta",
|
|
23
|
+
danger: "aria-disabled:bg-fill-disabled aria-disabled:text-ink-meta",
|
|
24
|
+
secondary: "aria-disabled:text-ink-disabled",
|
|
25
|
+
destructive: "aria-disabled:text-ink-disabled",
|
|
26
|
+
quiet: "aria-disabled:text-ink-disabled",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Pending, the act's content fades out and its spinner in once `--act-delay`
|
|
30
|
+
// has run (`globals.css`).
|
|
31
|
+
export const FADE_OUT = "opacity-0 animate-act-out";
|
|
32
|
+
export const FADE_IN = "animate-act-in";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { markedRuns } from "@slotform/ui-core/form";
|
|
3
|
+
import { useReasonShown } from "@slotform/ui-core/react/reason";
|
|
4
|
+
import { partRuns } from "@slotform/ui-core/runs";
|
|
5
|
+
import { FIELD_ERROR_LINE, FLOW_IN, text } from "@slotform/ui-core/variants";
|
|
6
|
+
import { RunText } from "../../lib/code.tsx";
|
|
7
|
+
|
|
8
|
+
// At the line's end under an act at the row's end; `desktop` under an act
|
|
9
|
+
// that stands under its line on touch, so the reason starts there.
|
|
10
|
+
const END = "text-end";
|
|
11
|
+
const END_DESKTOP = "text-end touch:text-start";
|
|
12
|
+
// A kept line holds its height while the reason is unshown.
|
|
13
|
+
const KEPT = "invisible";
|
|
14
|
+
|
|
15
|
+
/** A blocked act's reason, drawn once `shown`: a line, so it fades in on `fast` and pushes what follows at once, and leaves at once. A `kept` line holds its place while unshown, so showing it moves nothing: its words stand invisible there and fade in when shown, and a changed reason fades in the same way. A `failed` line is the sentence an act's run failed with, in the field error's cell and ink, where a span between backticks is a `{ code }` run (`markedRuns`), so a machine name the server words into a refusal stands boxed in the mono and wraps whole, as a field's error does. Outside the package's exports: the Button draws it, or the host that draws it on its own line. */
|
|
16
|
+
export function Reason(props: {
|
|
17
|
+
shown: boolean;
|
|
18
|
+
kept?: boolean;
|
|
19
|
+
failed?: boolean;
|
|
20
|
+
end?: boolean | "desktop";
|
|
21
|
+
children: string;
|
|
22
|
+
}) {
|
|
23
|
+
if (!(props.shown || props.kept)) return null;
|
|
24
|
+
const end = props.end === "desktop" ? END_DESKTOP : props.end && END;
|
|
25
|
+
// A failed sentence is the server's: its backticked spans are code.
|
|
26
|
+
const words = props.children;
|
|
27
|
+
const said = props.failed ? partRuns(markedRuns(words)) : [words];
|
|
28
|
+
const drawn =
|
|
29
|
+
said.length === 1 && typeof said[0] === "string" ? (
|
|
30
|
+
words
|
|
31
|
+
) : (
|
|
32
|
+
<RunText runs={said} whole />
|
|
33
|
+
);
|
|
34
|
+
return (
|
|
35
|
+
<p
|
|
36
|
+
role={props.failed && props.shown ? "alert" : undefined}
|
|
37
|
+
className={cn(
|
|
38
|
+
props.failed ? FIELD_ERROR_LINE : text({ role: "meta" }),
|
|
39
|
+
end,
|
|
40
|
+
!props.shown && KEPT,
|
|
41
|
+
)}
|
|
42
|
+
>
|
|
43
|
+
{props.shown ? (
|
|
44
|
+
<span key={words} className={FLOW_IN}>
|
|
45
|
+
{drawn}
|
|
46
|
+
</span>
|
|
47
|
+
) : (
|
|
48
|
+
drawn
|
|
49
|
+
)}
|
|
50
|
+
</p>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// A blocked act's reason drawn on its host's own line, so the act keeps its
|
|
55
|
+
// place: the act is handed the `host`, and the `line` shows once the act was
|
|
56
|
+
// pressed while blocked, or its form is touched.
|
|
57
|
+
export function useReasonLine(
|
|
58
|
+
blocked: string | undefined,
|
|
59
|
+
end?: boolean | "desktop",
|
|
60
|
+
) {
|
|
61
|
+
const { host, reason } = useReasonShown(blocked);
|
|
62
|
+
const line =
|
|
63
|
+
reason === undefined ? null : (
|
|
64
|
+
<Reason shown end={end}>
|
|
65
|
+
{reason}
|
|
66
|
+
</Reason>
|
|
67
|
+
);
|
|
68
|
+
return { host, line };
|
|
69
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Button as BaseButton } from "@base-ui/react/button";
|
|
2
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
3
|
+
import { paintText } from "@slotform/ui-core/paint";
|
|
4
|
+
import { useWords } from "@slotform/ui-core/react/words";
|
|
5
|
+
import type { ChipFamily } from "@slotform/ui-core/tokens";
|
|
6
|
+
import {
|
|
7
|
+
BLOCK_IN,
|
|
8
|
+
CHIP_LABEL,
|
|
9
|
+
chip,
|
|
10
|
+
chipDot,
|
|
11
|
+
REMOVE_HIT,
|
|
12
|
+
} from "@slotform/ui-core/variants";
|
|
13
|
+
import { PAINT_BOX } from "../../lib/paint.tsx";
|
|
14
|
+
import { Icon } from "../icon/index.tsx";
|
|
15
|
+
|
|
16
|
+
const BOX = "inline-flex items-center min-w-0 whitespace-nowrap";
|
|
17
|
+
const LABEL = "truncate";
|
|
18
|
+
// The remove act is a hit box the target's size (28 floor, 44 touch) pulled
|
|
19
|
+
// back on every side by what it has over the chip's caption line, so the chip
|
|
20
|
+
// keeps its height and the act takes a line's square of it; the disc inside is
|
|
21
|
+
// that line, a circle, and carries the washes and the focus ring.
|
|
22
|
+
const REMOVE =
|
|
23
|
+
"group inline-flex items-center justify-center shrink-0 min-h-target min-w-target -m-[calc((var(--spacing-target)-1lh)/2)] text-caption leading-caption focus-visible:outline-none";
|
|
24
|
+
const DISC =
|
|
25
|
+
"h-lh w-lh group-hover:bg-wash-hover group-active:bg-wash-press in-data-[modality=keyboard]:group-focus-visible:outline-2 group-focus-visible:-outline-offset-2 group-focus-visible:outline-ring";
|
|
26
|
+
|
|
27
|
+
/** The pill every Chip renders: outlined on the surface, a dot in the family's hue, then the label in the body ink; the neutral family, which has no hue, draws the label alone on its soft ground with no edge, so a dotless box never reads as a control. It has no height of its own: its caption line between its hairlines, whatever holds it. `painted` is the pill while its value is not here: its box filled at a word's length, inert. A removable pill is a block: it fades in as it mounts, and the viewer's remove runs in the page's block move, so the pill fades out on `fast` and its row closes up. Outside the package's exports. */
|
|
28
|
+
export function ChipBase({
|
|
29
|
+
label,
|
|
30
|
+
family,
|
|
31
|
+
onRemove,
|
|
32
|
+
painted,
|
|
33
|
+
quiet,
|
|
34
|
+
}: {
|
|
35
|
+
label: string;
|
|
36
|
+
family: ChipFamily;
|
|
37
|
+
onRemove?: () => void;
|
|
38
|
+
painted?: boolean;
|
|
39
|
+
/** The label in the meta ink, the quietest a word has: a chip on a dimmed edge. */
|
|
40
|
+
quiet?: boolean;
|
|
41
|
+
}) {
|
|
42
|
+
const words = useWords();
|
|
43
|
+
const hued = family !== "neutral";
|
|
44
|
+
const ground = hued ? "edge" : "soft";
|
|
45
|
+
if (painted)
|
|
46
|
+
return (
|
|
47
|
+
<span
|
|
48
|
+
inert
|
|
49
|
+
aria-hidden
|
|
50
|
+
className={cn(chip({ trailing: "none", ground }), BOX, PAINT_BOX)}
|
|
51
|
+
>
|
|
52
|
+
{hued ? (
|
|
53
|
+
<span className={cn(chipDot({ family }), "invisible")} />
|
|
54
|
+
) : null}
|
|
55
|
+
<span className={cn(CHIP_LABEL, LABEL, "invisible")}>
|
|
56
|
+
{paintText("word")}
|
|
57
|
+
</span>
|
|
58
|
+
</span>
|
|
59
|
+
);
|
|
60
|
+
return (
|
|
61
|
+
<span
|
|
62
|
+
className={cn(
|
|
63
|
+
chip({ trailing: onRemove ? "remove" : "none", ground }),
|
|
64
|
+
BOX,
|
|
65
|
+
onRemove && BLOCK_IN,
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
{hued ? <span className={chipDot({ family })} /> : null}
|
|
69
|
+
<span className={cn(CHIP_LABEL, LABEL, quiet && "text-ink-meta")}>
|
|
70
|
+
{label}
|
|
71
|
+
</span>
|
|
72
|
+
{onRemove ? (
|
|
73
|
+
<BaseButton
|
|
74
|
+
aria-label={`${words.remove} ${label}`}
|
|
75
|
+
onClick={onRemove}
|
|
76
|
+
className={REMOVE}
|
|
77
|
+
>
|
|
78
|
+
<span className={cn(REMOVE_HIT, DISC)}>
|
|
79
|
+
<Icon name="X" fit="meta" />
|
|
80
|
+
</span>
|
|
81
|
+
</BaseButton>
|
|
82
|
+
) : null}
|
|
83
|
+
</span>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { COUNT, COUNT_LABEL } from "@slotform/ui-core/variants";
|
|
3
|
+
import { Decoded } from "../../lib/region.tsx";
|
|
4
|
+
|
|
5
|
+
// The page breaks a word anywhere; a badge keeps its figures whole.
|
|
6
|
+
const HOLD = "wrap-normal";
|
|
7
|
+
|
|
8
|
+
/** The number every Count and every Button's count renders. `inAct` draws it in the ink of the act it stands in, not the meta one. `painted` is the number while its data is not here: a figure's filler, inert. Outside the package's exports. */
|
|
9
|
+
export function CountBase(props: {
|
|
10
|
+
value: number | string;
|
|
11
|
+
inAct?: boolean;
|
|
12
|
+
painted?: boolean;
|
|
13
|
+
}) {
|
|
14
|
+
return (
|
|
15
|
+
<span
|
|
16
|
+
inert={props.painted || undefined}
|
|
17
|
+
className={cn(props.inAct ? COUNT_LABEL : cn(COUNT, COUNT_LABEL), HOLD)}
|
|
18
|
+
>
|
|
19
|
+
<Decoded
|
|
20
|
+
role="figure"
|
|
21
|
+
painted={props.painted}
|
|
22
|
+
text={String(props.value)}
|
|
23
|
+
of={Number.parseFloat(String(props.value))}
|
|
24
|
+
/>
|
|
25
|
+
</span>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import type { IconName } from "@slotform/ui-core/descriptors";
|
|
3
|
+
import { ICON_STROKE, type IconStroke } from "@slotform/ui-core/tokens";
|
|
4
|
+
import { type IconFit, icon } from "@slotform/ui-core/variants";
|
|
5
|
+
import * as lucide from "lucide-react";
|
|
6
|
+
import type { Closed } from "../../lib/closed.ts";
|
|
7
|
+
import { PAINT_BOX } from "../../lib/paint.tsx";
|
|
8
|
+
|
|
9
|
+
const GLYPH = "shrink-0";
|
|
10
|
+
|
|
11
|
+
// Every Lucide name to its glyph; the annotation fails the build when the
|
|
12
|
+
// package lacks a name ui-core's `lucide` carries.
|
|
13
|
+
const GLYPHS: Record<IconName, lucide.LucideIcon> = lucide;
|
|
14
|
+
|
|
15
|
+
/** A Lucide glyph. */
|
|
16
|
+
interface IconProps extends Closed {
|
|
17
|
+
/** The glyph's Lucide name. */
|
|
18
|
+
name: IconName;
|
|
19
|
+
/** What it sits beside, which picks its size: `meta` text, `body` text (the default), or the inside of a `control`. */
|
|
20
|
+
fit?: IconFit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** What every icon draws: the public `Icon` at the line weight, or a mark that carries meaning (a change mark) at the mark weight. `painted` is the glyph's box while its data is not here, nothing drawn in it. Outside the package's exports. */
|
|
24
|
+
export function IconBase({
|
|
25
|
+
name,
|
|
26
|
+
fit,
|
|
27
|
+
stroke,
|
|
28
|
+
painted,
|
|
29
|
+
}: IconProps & { stroke: IconStroke; painted?: boolean }) {
|
|
30
|
+
const Glyph = GLYPHS[name];
|
|
31
|
+
if (painted)
|
|
32
|
+
return (
|
|
33
|
+
<span
|
|
34
|
+
aria-hidden
|
|
35
|
+
className={cn(icon({ fit: fit ?? "body" }), GLYPH, PAINT_BOX)}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
// Decorative: the text beside it or the control around it names it.
|
|
39
|
+
return (
|
|
40
|
+
<Glyph
|
|
41
|
+
className={cn(icon({ fit: fit ?? "body" }), GLYPH)}
|
|
42
|
+
strokeWidth={ICON_STROKE[stroke]}
|
|
43
|
+
aria-hidden
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A glyph in the ink of its place (currentColor), at the size of what it sits beside. */
|
|
49
|
+
export function Icon({ name, fit }: IconProps) {
|
|
50
|
+
return <IconBase name={name} fit={fit} stroke="line" />;
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cn } from "@slotform/ui-core/cn";
|
|
2
|
+
import { message, STREAM_IN, text } from "@slotform/ui-core/variants";
|
|
3
|
+
import { Painted } from "../../lib/paint.tsx";
|
|
4
|
+
|
|
5
|
+
const STACK = "flex flex-col";
|
|
6
|
+
|
|
7
|
+
/** The waiting shape of a reply that is on its way: the unbubbled reply it becomes, with no author line, one line of paint at the body line height. `arrives` is one that came on its own, which rises in. Outside the package's exports: a Thread draws it for `replying`. */
|
|
8
|
+
export function WaitingReply({ arrives }: { arrives?: boolean }) {
|
|
9
|
+
return (
|
|
10
|
+
<article
|
|
11
|
+
aria-busy
|
|
12
|
+
className={cn(message({ author: "other" }), STACK, arrives && STREAM_IN)}
|
|
13
|
+
>
|
|
14
|
+
<p className={text({ role: "body" })}>
|
|
15
|
+
<Painted role="phrase" />
|
|
16
|
+
</p>
|
|
17
|
+
</article>
|
|
18
|
+
);
|
|
19
|
+
}
|