@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,427 @@
|
|
|
1
|
+
/* The parts of the sheet only the web owns. The token contract — the `@theme`
|
|
2
|
+
map, the per-mode colors and the shadow utilities — is emitted into
|
|
3
|
+
`.slotform/app.css` from `@slotform/ui-core`, which also imports `tailwindcss`
|
|
4
|
+
before this file. Importing it again here would emit preflight twice. */
|
|
5
|
+
|
|
6
|
+
/* `.slotform/app.css` imports `tailwindcss` with `source(none)`, so no automatic
|
|
7
|
+
content detection runs; the component sources are declared explicitly,
|
|
8
|
+
relative to this file. */
|
|
9
|
+
@source "./";
|
|
10
|
+
|
|
11
|
+
/* The variant matrices are class strings inside `@slotform/ui-core`, and a cva
|
|
12
|
+
composes them at runtime, so a build that never scans that package emits
|
|
13
|
+
nothing for a cell no component also spells literally. Two paths are listed
|
|
14
|
+
because the package sits one level away in an install and four in a
|
|
15
|
+
workspace checkout; Tailwind ignores a source path that does not exist. */
|
|
16
|
+
@source "../../../ui-core/src";
|
|
17
|
+
@source "../../../../packages/ui-core/src";
|
|
18
|
+
|
|
19
|
+
@layer base {
|
|
20
|
+
:root {
|
|
21
|
+
color-scheme: light;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
*,
|
|
25
|
+
*::before,
|
|
26
|
+
*::after {
|
|
27
|
+
border-color: var(--color-edge);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* A scroller draws a thin thumb in the strong hairline over no track, the
|
|
31
|
+
boundary that holds 3:1 on every ground. Every element declares it:
|
|
32
|
+
`scrollbar-width` does not inherit, and `scrollbar-color` inherits the
|
|
33
|
+
color computed where it is declared, so each element resolves the token
|
|
34
|
+
itself and a mode scope (the sidebar's `dark` rail) draws its own. */
|
|
35
|
+
* {
|
|
36
|
+
scrollbar-width: thin;
|
|
37
|
+
scrollbar-color: var(--color-edge-strong) transparent;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
html {
|
|
41
|
+
font-family: var(--font-sans);
|
|
42
|
+
font-optical-sizing: auto;
|
|
43
|
+
font-synthesis: none;
|
|
44
|
+
-webkit-text-size-adjust: 100%;
|
|
45
|
+
text-size-adjust: 100%;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
body {
|
|
49
|
+
background-color: var(--color-canvas);
|
|
50
|
+
color: var(--color-ink-body);
|
|
51
|
+
font-size: var(--text-body);
|
|
52
|
+
line-height: var(--leading-body);
|
|
53
|
+
-webkit-font-smoothing: antialiased;
|
|
54
|
+
-moz-osx-font-smoothing: grayscale;
|
|
55
|
+
/* A word longer than its box breaks anywhere rather than pushing the box
|
|
56
|
+
past its parent; the property inherits, so no region spells it. A lane that
|
|
57
|
+
must hold its figures sets `wrap-normal`; a single line truncates. */
|
|
58
|
+
overflow-wrap: anywhere;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
h1,
|
|
62
|
+
h2,
|
|
63
|
+
h3 {
|
|
64
|
+
text-wrap: balance;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
p {
|
|
68
|
+
text-wrap: pretty;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* The ring is drawn for the keyboard alone (`lib/modality.ts`), outside the
|
|
72
|
+
box at an offset, so it never covers the control's own edge. Components
|
|
73
|
+
spell nothing for it; a control inside a control rings inset with
|
|
74
|
+
`focus-visible:-outline-offset-2`. A bordered box that takes typing or
|
|
75
|
+
choosing rings on its edge instead (`--focus-ring-edge-offset`). A
|
|
76
|
+
component that draws a ring of its own spells it under
|
|
77
|
+
`in-data-[modality=keyboard]`. */
|
|
78
|
+
:root[data-modality="keyboard"] :focus-visible {
|
|
79
|
+
outline: var(--focus-ring) solid var(--color-ring);
|
|
80
|
+
outline-offset: var(--focus-ring-offset);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@keyframes content-show {
|
|
85
|
+
from {
|
|
86
|
+
opacity: 0;
|
|
87
|
+
transform: scale(0.96);
|
|
88
|
+
}
|
|
89
|
+
to {
|
|
90
|
+
opacity: 1;
|
|
91
|
+
transform: scale(1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@keyframes content-hide {
|
|
96
|
+
from {
|
|
97
|
+
opacity: 1;
|
|
98
|
+
transform: scale(1);
|
|
99
|
+
}
|
|
100
|
+
to {
|
|
101
|
+
opacity: 0;
|
|
102
|
+
transform: scale(0.96);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* The page slides from where it stood as the sidebar docks or folds
|
|
107
|
+
(`SHELL_PAGE_SLIDE`), `--page-from` away; written `from` alone, so a setup
|
|
108
|
+
that switches animations off draws the page at its rest. */
|
|
109
|
+
@keyframes page-slide {
|
|
110
|
+
from {
|
|
111
|
+
translate: var(--page-from);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* A message that arrives at the end of a log rises a pair as it fades in
|
|
116
|
+
(`STREAM_IN`). */
|
|
117
|
+
@keyframes stream-in {
|
|
118
|
+
from {
|
|
119
|
+
opacity: 0;
|
|
120
|
+
translate: 0 var(--spacing-gap);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* The paint (`lib/paint.tsx`): a painted part's fill, drawn after the read has
|
|
125
|
+
run `--wait-delay`, so a read answered at once paints nothing. It fades in
|
|
126
|
+
(`paint-in`), then breathes (`pulse-fill`, the `PULSE` cell): the fill's own
|
|
127
|
+
alpha moves, never the box's opacity, so the fade and the breath do not
|
|
128
|
+
fight over it and the glyphs a text fill sits behind are not dimmed. All
|
|
129
|
+
fills share one phase (`lib/paint.tsx`). The delay holds under reduced
|
|
130
|
+
motion; the fade snaps there and the breath is `none`. */
|
|
131
|
+
@media (prefers-reduced-motion: reduce) {
|
|
132
|
+
:root {
|
|
133
|
+
--pulse-name: none;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* A frame whose read is idle or paused with no data stands still (`data-still`):
|
|
138
|
+
its painted shape is drawn, but nothing is coming, so nothing breathes. */
|
|
139
|
+
[data-still] {
|
|
140
|
+
--pulse-name: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* A scrambled region (`lib/scramble.tsx`, `theme.loading`) stands as the still
|
|
144
|
+
bar where nothing is coming: its generated glyphs are hidden and the fill
|
|
145
|
+
the scramble leaves off returns. Under reduced motion the same happens
|
|
146
|
+
through the cell's own `motion-safe` and the glyphs' `motion-reduce`. */
|
|
147
|
+
[data-still] [data-scramble] {
|
|
148
|
+
background-color: var(--color-skeleton);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
[data-still] [data-scrambling] {
|
|
152
|
+
display: none;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@keyframes paint-in {
|
|
156
|
+
from {
|
|
157
|
+
opacity: 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@keyframes pulse-fill {
|
|
162
|
+
50% {
|
|
163
|
+
background-color: color-mix(
|
|
164
|
+
in oklab,
|
|
165
|
+
var(--color-skeleton) var(--pulse-low),
|
|
166
|
+
transparent
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* A value that changes while shown (`lib/swap.tsx`, the SWAP cells): the new
|
|
172
|
+
one enters and the old leaves, each by opacity and a move the site names,
|
|
173
|
+
`--swap-y` the share of its own height (a figure's roll: 1 rises from below
|
|
174
|
+
and the old leaves up, -1 the reverse) and `--swap-scale` the size a mark
|
|
175
|
+
grows from. The rung is 0 under reduced motion, so the old one is gone and
|
|
176
|
+
the new one stands at once.
|
|
177
|
+
|
|
178
|
+
Both animate toward the box's own style: the new one `from` its start, the
|
|
179
|
+
old one `from` its rest toward `swap-gone`, the style it keeps once it has
|
|
180
|
+
left. So where animations are switched off (a stable-shot setup that
|
|
181
|
+
injects `animation: none`) the new one stands and the old one is already
|
|
182
|
+
gone, never the two drawn together; an exit written `to` an end state would
|
|
183
|
+
leave the old one at rest until it is removed. */
|
|
184
|
+
@keyframes swap-in {
|
|
185
|
+
from {
|
|
186
|
+
opacity: 0;
|
|
187
|
+
translate: 0 calc(var(--swap-y, 0) * 100%);
|
|
188
|
+
scale: var(--swap-scale, 1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@keyframes swap-out {
|
|
193
|
+
from {
|
|
194
|
+
opacity: 1;
|
|
195
|
+
translate: 0 0;
|
|
196
|
+
scale: 1;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@utility swap-gone {
|
|
201
|
+
opacity: 0;
|
|
202
|
+
translate: 0 calc(var(--swap-y, 0) * -100%);
|
|
203
|
+
scale: var(--swap-scale, 1);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@theme {
|
|
207
|
+
--animate-paint: paint-in var(--transition-duration-base) var(--ease-out)
|
|
208
|
+
var(--wait-delay) both;
|
|
209
|
+
--animate-spinner-in: paint-in var(--transition-duration-fast) var(--ease-out)
|
|
210
|
+
both;
|
|
211
|
+
--animate-act-in: act-in var(--transition-duration-base) var(--ease-out)
|
|
212
|
+
var(--act-delay) both;
|
|
213
|
+
--animate-act-out: act-out var(--transition-duration-base) var(--ease-out)
|
|
214
|
+
var(--act-delay) both;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* An act's pending look (`components/button`, `icon-button`): the act is inert
|
|
218
|
+
at the press and draws nothing until `--act-delay` has run, so an act the
|
|
219
|
+
server answers at once never flashes a spinner. Then the pending fill and
|
|
220
|
+
the spinner fade in (`act-in`) as the label and glyph fade out (`act-out`).
|
|
221
|
+
The delay holds under reduced motion; the fades snap there. What fades out
|
|
222
|
+
is hidden in its own style (`opacity-0`) and animates `from` its rest, and
|
|
223
|
+
what fades in animates `from` hidden, so a setup that switches animations
|
|
224
|
+
off draws the pending look at once, the spinner alone, never the spinner
|
|
225
|
+
over the glyph it replaces. */
|
|
226
|
+
@keyframes act-in {
|
|
227
|
+
from {
|
|
228
|
+
opacity: 0;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@keyframes act-out {
|
|
233
|
+
from {
|
|
234
|
+
opacity: 1;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* A pending bar's fill (`components/banner/pending.tsx`): the track's full width
|
|
239
|
+
scaled from `--from` (the share the run begins at) to full over `--ms`
|
|
240
|
+
milliseconds, at a constant pace, so the fill moves on the compositor and
|
|
241
|
+
holds full at the end. Inline, so `--ms` is read on the fill, not on the
|
|
242
|
+
root. Reduced motion has no animation: the bar sets the share itself. */
|
|
243
|
+
@keyframes pending-fill {
|
|
244
|
+
from {
|
|
245
|
+
scale: var(--from) 1;
|
|
246
|
+
}
|
|
247
|
+
to {
|
|
248
|
+
scale: 1 1;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@theme inline {
|
|
253
|
+
--animate-pending-fill: pending-fill calc(var(--ms) * 1ms) linear forwards;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* A painted text clips at its region's edge where a loaded one ends in an
|
|
257
|
+
ellipsis: the filler is no words to be cut short, and a visible "…" on it
|
|
258
|
+
reads as data. `Painted` sits directly in its region's text element. Unlayered,
|
|
259
|
+
so it stands over the `truncate` utility. */
|
|
260
|
+
:has(> [data-painted]) {
|
|
261
|
+
text-overflow: clip;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* A painted text in a region that holds its line to one (`truncate`, or
|
|
265
|
+
`whitespace-nowrap` with its own clip; not one that sets itself back to
|
|
266
|
+
wrapping, or clamps its lines) is a box of its own no wider than the region, so a filler
|
|
267
|
+
longer than the region ends in the bar's rounded corner, never cut flat at the
|
|
268
|
+
region's edge. Inline, the bar would run past the region and the region's clip
|
|
269
|
+
would cut it; a region that wraps keeps the inline bars of its lines. `clip`
|
|
270
|
+
keeps the text's baseline (a scrolling box would take its bottom edge), and
|
|
271
|
+
the box's own `normal` line height is the bar the inline fill drew, so the
|
|
272
|
+
lines of a painted text keep the air between them. The filler stands in the
|
|
273
|
+
region, or in the plain span a line of parts (`PartsLine`) wraps each part in.
|
|
274
|
+
Unlayered like the rule above. */
|
|
275
|
+
:is(.truncate, .whitespace-nowrap):not(
|
|
276
|
+
.whitespace-normal,
|
|
277
|
+
[class*="line-clamp-"]
|
|
278
|
+
)
|
|
279
|
+
> [data-painted],
|
|
280
|
+
:is(.truncate, .whitespace-nowrap):not(
|
|
281
|
+
.whitespace-normal,
|
|
282
|
+
[class*="line-clamp-"]
|
|
283
|
+
)
|
|
284
|
+
> span[class=""]
|
|
285
|
+
> [data-painted] {
|
|
286
|
+
display: inline-block;
|
|
287
|
+
max-width: 100%;
|
|
288
|
+
overflow: clip;
|
|
289
|
+
line-height: normal;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/* A role whose leading is under `normal` (a figure's, 1.2) stands its bar at
|
|
293
|
+
the region's own line, so the waiting shape is no taller than the loaded one.
|
|
294
|
+
After the rule above, at the same weight. */
|
|
295
|
+
:is(.truncate, .whitespace-nowrap):not(
|
|
296
|
+
.whitespace-normal,
|
|
297
|
+
[class*="line-clamp-"]
|
|
298
|
+
)
|
|
299
|
+
> [data-painted][data-flush],
|
|
300
|
+
:is(.truncate, .whitespace-nowrap):not(
|
|
301
|
+
.whitespace-normal,
|
|
302
|
+
[class*="line-clamp-"]
|
|
303
|
+
)
|
|
304
|
+
> span[class=""]
|
|
305
|
+
> [data-painted][data-flush] {
|
|
306
|
+
line-height: inherit;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/* A record's name on touch stands whole in the head under the Pane's bar, so
|
|
310
|
+
the bar's own waits until the head's has scrolled up under the bar (no
|
|
311
|
+
script measures it). The head's name (`record-name`) names a view timeline
|
|
312
|
+
on the body that scrolls it; the Pane (`record-scope`) lifts that name over
|
|
313
|
+
the bar, a sibling of the body; the bar's name (`record-name-waits`) hides
|
|
314
|
+
until the timeline's last hundredth, when the head's name is under the
|
|
315
|
+
bar's foot, and stands from there. Where the browser draws no scroll-driven
|
|
316
|
+
animation, or no head's name is there to name a timeline, the bar's name
|
|
317
|
+
stands all the while, cut to its box.
|
|
318
|
+
|
|
319
|
+
This animation carries a state (is the name standing?), not motion, so it
|
|
320
|
+
must run where motion is switched off: a stable-shot setup that injects
|
|
321
|
+
`*{transition:none!important;animation:none!important}` (unlayered) would
|
|
322
|
+
otherwise leave every shot the fallback, the name always standing. Its
|
|
323
|
+
declarations are `!important` and stand in a cascade layer (`@utility` emits
|
|
324
|
+
into `utilities`): an important declaration in a layer beats an unlayered
|
|
325
|
+
important one, so the setup's rule does not reach it, and no setup has to
|
|
326
|
+
know it by name. Reduced motion does not stop it either: it has no duration
|
|
327
|
+
to zero. */
|
|
328
|
+
@keyframes name-stands {
|
|
329
|
+
from {
|
|
330
|
+
visibility: hidden;
|
|
331
|
+
}
|
|
332
|
+
to {
|
|
333
|
+
visibility: visible;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
@utility record-name {
|
|
338
|
+
view-timeline: --record-name block;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
@utility record-scope {
|
|
342
|
+
timeline-scope: --record-name;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@utility record-name-waits {
|
|
346
|
+
@supports (animation-timeline: view()) {
|
|
347
|
+
/* biome-ignore lint/complexity/noImportantStyles: the animation carries state, not motion; a layered important declaration beats a setup's unlayered `animation: none !important` */
|
|
348
|
+
animation: name-stands linear both !important;
|
|
349
|
+
/* biome-ignore lint/complexity/noImportantStyles: the animation carries state, not motion; a layered important declaration beats a setup's unlayered `animation: none !important` */
|
|
350
|
+
animation-timeline: --record-name !important;
|
|
351
|
+
/* biome-ignore lint/complexity/noImportantStyles: the animation carries state, not motion; a layered important declaration beats a setup's unlayered `animation: none !important` */
|
|
352
|
+
animation-range: exit 99% exit 100% !important;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* A track that scrolls sideways with no scrollbar says so at the edge that has
|
|
357
|
+
more: it fades there over `--spacing-control`, from the scroll position alone
|
|
358
|
+
(a scroll-driven animation of the two fade lengths, which the mask reads), so
|
|
359
|
+
no script measures anything. The start fades once it has scrolled, the end
|
|
360
|
+
until it has scrolled to the end, each in proportion to the content that side
|
|
361
|
+
hides up to the full fade (ranges in lengths, never shares of the
|
|
362
|
+
range): a track whose content overflows by a rounding stands
|
|
363
|
+
with no visible fade on either side, and one that fits scrolls nowhere, its
|
|
364
|
+
timeline is inactive and no fade stands. Where the browser draws no
|
|
365
|
+
scroll-driven animation the track keeps its cut label as the cue. Like
|
|
366
|
+
`record-name-waits` this carries state, not motion, so its animation runs
|
|
367
|
+
where motion is switched off. */
|
|
368
|
+
@property --fade-start {
|
|
369
|
+
syntax: "<length>";
|
|
370
|
+
inherits: false;
|
|
371
|
+
initial-value: 0px;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
@property --fade-end {
|
|
375
|
+
syntax: "<length>";
|
|
376
|
+
inherits: false;
|
|
377
|
+
initial-value: 0px;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
@keyframes fade-start {
|
|
381
|
+
from {
|
|
382
|
+
--fade-start: 0px;
|
|
383
|
+
}
|
|
384
|
+
to {
|
|
385
|
+
--fade-start: var(--spacing-control);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
@keyframes fade-end {
|
|
390
|
+
from {
|
|
391
|
+
--fade-end: var(--spacing-control);
|
|
392
|
+
}
|
|
393
|
+
to {
|
|
394
|
+
--fade-end: 0px;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
@utility scroll-fade-x {
|
|
399
|
+
@supports (animation-timeline: scroll()) {
|
|
400
|
+
mask-image: linear-gradient(
|
|
401
|
+
to right,
|
|
402
|
+
transparent,
|
|
403
|
+
#000 var(--fade-start),
|
|
404
|
+
#000 calc(100% - var(--fade-end)),
|
|
405
|
+
transparent
|
|
406
|
+
);
|
|
407
|
+
&:dir(rtl) {
|
|
408
|
+
mask-image: linear-gradient(
|
|
409
|
+
to left,
|
|
410
|
+
transparent,
|
|
411
|
+
#000 var(--fade-start),
|
|
412
|
+
#000 calc(100% - var(--fade-end)),
|
|
413
|
+
transparent
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
--fade-animation: fade-start linear both, fade-end linear both;
|
|
417
|
+
/* The fade is `--spacing-control` long at each end, as the keyframes grow it. */
|
|
418
|
+
--fade-range:
|
|
419
|
+
0px var(--spacing-control), calc(100% - var(--spacing-control)) 100%;
|
|
420
|
+
/* biome-ignore lint/complexity/noImportantStyles: the animation carries state, not motion; a layered important declaration beats a setup's unlayered `animation: none !important` */
|
|
421
|
+
animation: var(--fade-animation) !important;
|
|
422
|
+
/* biome-ignore lint/complexity/noImportantStyles: the animation carries state, not motion; a layered important declaration beats a setup's unlayered `animation: none !important` */
|
|
423
|
+
animation-timeline: scroll(self inline) !important;
|
|
424
|
+
/* biome-ignore lint/complexity/noImportantStyles: the animation carries state, not motion; a layered important declaration beats a setup's unlayered `animation: none !important` */
|
|
425
|
+
animation-range: var(--fade-range) !important;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Act as ActData,
|
|
3
|
+
Decision,
|
|
4
|
+
IconName,
|
|
5
|
+
LinkAct,
|
|
6
|
+
} from "@slotform/ui-core/descriptors";
|
|
7
|
+
import type { ProcedureCall } from "@slotform/ui-core/form";
|
|
8
|
+
import { createActs } from "@slotform/ui-core/react/acts";
|
|
9
|
+
import type { ActSheetProps } from "../components/sheet/index.tsx";
|
|
10
|
+
import { navigate } from "./navigate.ts";
|
|
11
|
+
import { toast } from "./toast.ts";
|
|
12
|
+
|
|
13
|
+
export type { ActSheetProps };
|
|
14
|
+
|
|
15
|
+
/** A sheet for an act's `sheet`, typed by the procedure its form submits: `P` is read off the form's `act`, so `onDone` hears that procedure's output and the fields are checked against its input. An act's region holds acts of different procedures, which a type cannot follow, so the sheet leaves here as the procedure-less `ActSheetProps` the region takes. */
|
|
16
|
+
export function sheetOf<P extends ProcedureCall>(
|
|
17
|
+
sheet: ActSheetProps<P>,
|
|
18
|
+
): ActSheetProps {
|
|
19
|
+
// The one place the procedure is forgotten: the sheet outlet draws it through
|
|
20
|
+
// `Sheet`, which reads the form's own procedure, never this type's.
|
|
21
|
+
return sheet as unknown as ActSheetProps;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** What an act does when pressed, exclusively: it runs (`onAct`) or it opens a modal task (`sheet`: the press opens it in the sheet outlet with the props it holds then, and it closes on dismiss or once the sheet's submit resolves). A press that opens a sheet runs nothing. */
|
|
25
|
+
type Pressed<F> =
|
|
26
|
+
| { onAct: F; sheet?: never }
|
|
27
|
+
| { sheet: ActSheetProps; onAct?: never };
|
|
28
|
+
|
|
29
|
+
/** An act as the platform draws it: the ui-core act with its `onAct` or the `sheet` it opens. */
|
|
30
|
+
export type Act = Omit<ActData, "onAct"> & Pressed<ActData["onAct"]>;
|
|
31
|
+
/** A descriptor's acts as the platform draws them: each act (one, or a list of them) widened with the `sheet` it may open. */
|
|
32
|
+
export type Sheeted<T> = T extends readonly (infer E)[]
|
|
33
|
+
? readonly Sheeted<E>[]
|
|
34
|
+
: T extends { onAct: infer F }
|
|
35
|
+
? Omit<T, "onAct"> & Pressed<F>
|
|
36
|
+
: T;
|
|
37
|
+
/** An act of a region that requires its glyph. */
|
|
38
|
+
export type IconAct = Act & { icon: IconName };
|
|
39
|
+
/** What a menu holds: acts that run and links that go. */
|
|
40
|
+
export type MenuEntry = Act | LinkAct;
|
|
41
|
+
|
|
42
|
+
/** The wiring an act carries beside its `onAct`, which a host hands to the control that draws it. */
|
|
43
|
+
interface Wiring {
|
|
44
|
+
confirm?: Decision;
|
|
45
|
+
done?: string;
|
|
46
|
+
to?: string;
|
|
47
|
+
sheet?: ActSheetProps;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** An act's wiring, as a host hands it to the control that draws the act. */
|
|
51
|
+
export function wiringOf(act: Wiring): Wiring {
|
|
52
|
+
return {
|
|
53
|
+
confirm: act.confirm,
|
|
54
|
+
done: act.done,
|
|
55
|
+
to: act.to,
|
|
56
|
+
sheet: act.sheet,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const { useAct, useHeldDraft } = createActs({ toast, open: navigate });
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ageLongest,
|
|
3
|
+
ageWords,
|
|
4
|
+
ageShort as shortOf,
|
|
5
|
+
} from "@slotform/ui-core/clock";
|
|
6
|
+
import { formatterFor } from "@slotform/ui-core/format";
|
|
7
|
+
import { pageLang } from "./lang.ts";
|
|
8
|
+
|
|
9
|
+
// An ISO moment as its age from `now` ("2 minutes ago", "yesterday"), in the
|
|
10
|
+
// document's language through the platform's own relative-time words, so
|
|
11
|
+
// no word of it lives in `words`. A part that draws one reads `now` from
|
|
12
|
+
// the shared clock (`useClock`), so the age ticks on its own.
|
|
13
|
+
export function age(moment: string, now = Date.now()): string {
|
|
14
|
+
const format = formatterFor("relative", pageLang(), { numeric: "auto" });
|
|
15
|
+
return ageWords(moment, now, format);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// An ISO moment as its short age ("2 min", "16 sec"), the form a row's
|
|
19
|
+
// trailing age and an item header's meta read in; a moment after `now` keeps
|
|
20
|
+
// the long form.
|
|
21
|
+
export function ageShort(moment: string, now = Date.now()): string {
|
|
22
|
+
const lang = pageLang();
|
|
23
|
+
return shortOf(
|
|
24
|
+
moment,
|
|
25
|
+
now,
|
|
26
|
+
(unit) =>
|
|
27
|
+
formatterFor("number", lang, {
|
|
28
|
+
style: "unit",
|
|
29
|
+
unit,
|
|
30
|
+
unitDisplay: "short",
|
|
31
|
+
}),
|
|
32
|
+
formatterFor("relative", lang, { numeric: "auto" }),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const longest = new Map<string, number>();
|
|
37
|
+
|
|
38
|
+
// The characters of the longest age in the document's language ("59 seconds
|
|
39
|
+
// ago"), found once per language from the words themselves: an age column
|
|
40
|
+
// stands at this width.
|
|
41
|
+
export function ageWidest(): number {
|
|
42
|
+
const lang = pageLang();
|
|
43
|
+
let known = longest.get(lang ?? "");
|
|
44
|
+
if (known === undefined) {
|
|
45
|
+
known = ageLongest(formatterFor("relative", lang, { numeric: "auto" }));
|
|
46
|
+
longest.set(lang ?? "", known);
|
|
47
|
+
}
|
|
48
|
+
return known;
|
|
49
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Where a text may not break at a hyphen. A browser breaks after a hyphen and
|
|
2
|
+
// never before one, which is the break a name of hyphens wants (a long repo
|
|
3
|
+
// name wraps as `a-repository-` / `with-a-name`), so a hyphen inside a word is
|
|
4
|
+
// left to it. Only a hyphen that leads a word binds to the word after it: a
|
|
5
|
+
// flag (`--bg`) is one piece, since a break between its hyphens and its name
|
|
6
|
+
// would read as two words. A piece is wrapped in a nowrap box, and the hyphen
|
|
7
|
+
// that ends the piece goes inside it (`--bg-`), so the break after that hyphen
|
|
8
|
+
// stands at the piece's end and no line ever starts on a hyphen; a hyphen
|
|
9
|
+
// before a digit (`webauthn-3`, `--x-3`) stays with the digit, as the break
|
|
10
|
+
// rules keep it.
|
|
11
|
+
const BOUND = /((?<!\S)-+[^\s-]+(?:-+\d[^\s-]*)*-*)/;
|
|
12
|
+
|
|
13
|
+
/** A text split into the pieces that stay whole: the odd entries are a flag and its trailing hyphens, the even ones are text the browser breaks as it does (after a hyphen, never before one). */
|
|
14
|
+
export function boundPieces(code: string): string[] {
|
|
15
|
+
return code.split(BOUND);
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference path="../worker.d.ts" />
|
|
2
|
+
import ELK, { type ElkNode } from "elkjs/lib/elk-api.js";
|
|
3
|
+
import ElkWorker from "elkjs/lib/elk-worker.min.js?worker";
|
|
4
|
+
|
|
5
|
+
// The only module that touches the worker: docs/architecture/plugins/react-ui.md, "Canvas serving".
|
|
6
|
+
let elk: InstanceType<typeof ELK> | undefined;
|
|
7
|
+
|
|
8
|
+
export function layoutElk(graph: ElkNode): Promise<ElkNode> {
|
|
9
|
+
elk ??= new ELK({ workerFactory: () => new ElkWorker() });
|
|
10
|
+
return elk.layout(graph);
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// A field that opens for editing in place of what the viewer read ends its text
|
|
2
|
+
// under the caret; a programmatic focus leaves a textarea's at the start. A
|
|
3
|
+
// type with no selection (`email`, `number`) reports a null `selectionStart`.
|
|
4
|
+
export function caretAtEnd(
|
|
5
|
+
field: HTMLInputElement | HTMLTextAreaElement | null,
|
|
6
|
+
) {
|
|
7
|
+
if (field?.selectionStart == null) return;
|
|
8
|
+
field.setSelectionRange(field.value.length, field.value.length);
|
|
9
|
+
}
|