@sdxc/ui 2026.11.10 → 2026.11.14
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/README.md +92 -45
- package/dist/app/app-shell-toggle.d.ts +2 -0
- package/dist/app/app-shell-toggle.js +5 -2
- package/dist/app/app-shell.d.ts +25 -1
- package/dist/app/app-shell.js +73 -38
- package/dist/app/auto-refresh.d.ts +2 -0
- package/dist/app/auto-refresh.js +3 -3
- package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
- package/dist/app/behaviors/refresh-schedule.js +4 -3
- package/dist/app/board.d.ts +123 -0
- package/dist/app/board.js +224 -0
- package/dist/app/chart.d.ts +2 -2
- package/dist/app/chart.js +7 -3
- package/dist/app/check-runs.d.ts +116 -0
- package/dist/app/check-runs.js +201 -0
- package/dist/app/code-view.d.ts +172 -0
- package/dist/app/code-view.js +414 -0
- package/dist/app/command-palette.d.ts +38 -3
- package/dist/app/command-palette.js +53 -5
- package/dist/app/contribution-graph.d.ts +106 -0
- package/dist/app/contribution-graph.js +289 -0
- package/dist/app/detail-sheet.d.ts +7 -0
- package/dist/app/detail-sheet.js +7 -7
- package/dist/app/diff.d.ts +200 -0
- package/dist/app/diff.js +702 -0
- package/dist/app/filter-bar.d.ts +20 -0
- package/dist/app/filter-bar.js +35 -15
- package/dist/app/filter-menu.d.ts +144 -0
- package/dist/app/filter-menu.js +480 -0
- package/dist/app/gantt.d.ts +108 -0
- package/dist/app/gantt.js +420 -0
- package/dist/app/index.d.ts +19 -0
- package/dist/app/index.js +19 -0
- package/dist/app/log-viewer.d.ts +120 -0
- package/dist/app/log-viewer.js +384 -0
- package/dist/app/merge-box.d.ts +97 -0
- package/dist/app/merge-box.js +227 -0
- package/dist/app/mixins/app-shell-controls.d.ts +4 -1
- package/dist/app/mixins/app-shell-controls.js +64 -4
- package/dist/app/mixins/auto-refresh.d.ts +5 -2
- package/dist/app/mixins/auto-refresh.js +9 -3
- package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
- package/dist/app/mixins/close-popover-on-submit.js +32 -0
- package/dist/app/mixins/code-view-selection.d.ts +60 -0
- package/dist/app/mixins/code-view-selection.js +276 -0
- package/dist/app/mixins/command-palette.d.ts +15 -4
- package/dist/app/mixins/command-palette.js +94 -6
- package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
- package/dist/app/mixins/contribution-graph-keys.js +155 -0
- package/dist/app/mixins/diff-interactions.d.ts +72 -0
- package/dist/app/mixins/diff-interactions.js +269 -0
- package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
- package/dist/app/mixins/filter-menu-keys.js +91 -0
- package/dist/app/mixins/gantt-today.d.ts +17 -0
- package/dist/app/mixins/gantt-today.js +50 -0
- package/dist/app/mixins/log-viewer.d.ts +29 -0
- package/dist/app/mixins/log-viewer.js +333 -0
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
- package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
- package/dist/app/mixins/save-bar-sync.d.ts +7 -1
- package/dist/app/mixins/save-bar-sync.js +23 -4
- package/dist/app/mixins/save-status-sync.js +23 -1
- package/dist/app/mixins/split-view.js +1 -1
- package/dist/app/mixins/submit-on-close.d.ts +17 -0
- package/dist/app/mixins/submit-on-close.js +52 -0
- package/dist/app/mixins/tree-filter.d.ts +44 -0
- package/dist/app/mixins/tree-filter.js +111 -0
- package/dist/app/mixins/tree-navigation.d.ts +50 -0
- package/dist/app/mixins/tree-navigation.js +216 -0
- package/dist/app/optimistic-toggle.d.ts +8 -0
- package/dist/app/optimistic-toggle.js +3 -2
- package/dist/app/page-header.d.ts +18 -3
- package/dist/app/page-header.js +105 -50
- package/dist/app/review-thread.d.ts +115 -0
- package/dist/app/review-thread.js +116 -0
- package/dist/app/save-bar.d.ts +5 -0
- package/dist/app/save-bar.js +1 -1
- package/dist/app/settings-layout.d.ts +5 -0
- package/dist/app/settings-layout.js +5 -5
- package/dist/app/skeleton.d.ts +9 -0
- package/dist/app/skeleton.js +28 -0
- package/dist/app/split-view.d.ts +4 -0
- package/dist/app/split-view.js +3 -3
- package/dist/app/styles/code-tokens.d.ts +24 -0
- package/dist/app/styles/code-tokens.js +47 -0
- package/dist/app/tab-bar.d.ts +59 -0
- package/dist/app/tab-bar.js +111 -0
- package/dist/app/tree.d.ts +111 -14
- package/dist/app/tree.js +202 -15
- package/dist/app/utils/ansi.d.ts +55 -0
- package/dist/app/utils/ansi.js +157 -0
- package/dist/app/utils/diff-rows.d.ts +82 -0
- package/dist/app/utils/diff-rows.js +209 -0
- package/dist/app/utils/fuzzy-path.d.ts +58 -0
- package/dist/app/utils/fuzzy-path.js +202 -0
- package/dist/app/utils/line-range.d.ts +48 -0
- package/dist/app/utils/line-range.js +61 -0
- package/dist/app/utils/log-lines.d.ts +107 -0
- package/dist/app/utils/log-lines.js +170 -0
- package/dist/app/utils/tree-filter.d.ts +19 -0
- package/dist/app/utils/tree-filter.js +26 -0
- package/dist/app/view-options.d.ts +2 -0
- package/dist/app/view-options.js +2 -2
- package/dist/chat/activity.d.ts +72 -0
- package/dist/chat/activity.js +184 -0
- package/dist/chat/composer-submit.d.ts +38 -0
- package/dist/chat/composer-submit.js +44 -0
- package/dist/chat/composer.d.ts +47 -0
- package/dist/chat/composer.js +100 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/index.js +6 -0
- package/dist/chat/mixins/composer-send.d.ts +32 -0
- package/dist/chat/mixins/composer-send.js +121 -0
- package/dist/chat/mixins/reveal-stream.d.ts +68 -0
- package/dist/chat/mixins/reveal-stream.js +184 -0
- package/dist/chat/mixins/stream-target.d.ts +18 -0
- package/dist/chat/mixins/stream-target.js +38 -0
- package/dist/components/button.js +7 -1
- package/dist/components/character-count.d.ts +44 -0
- package/dist/components/character-count.js +68 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/label-chip.d.ts +42 -0
- package/dist/components/label-chip.js +86 -0
- package/dist/components/property-list.d.ts +9 -2
- package/dist/components/property-list.js +11 -6
- package/dist/components/textarea.js +6 -1
- package/dist/components/timeline.d.ts +62 -5
- package/dist/components/timeline.js +124 -5
- package/dist/docs/code-block.js +8 -31
- package/dist/docs/file-tree.js +3 -48
- package/dist/landing/case-study.d.ts +79 -0
- package/dist/landing/case-study.js +162 -0
- package/dist/landing/contributor-wall.d.ts +72 -0
- package/dist/landing/contributor-wall.js +129 -0
- package/dist/landing/countdown.d.ts +88 -0
- package/dist/landing/countdown.js +91 -0
- package/dist/landing/episode-player.d.ts +87 -0
- package/dist/landing/episode-player.js +113 -0
- package/dist/landing/faq-band.d.ts +3 -2
- package/dist/landing/faq-band.js +4 -3
- package/dist/landing/feature-band.d.ts +8 -0
- package/dist/landing/feature-band.js +9 -3
- package/dist/landing/index.d.ts +9 -0
- package/dist/landing/index.js +9 -0
- package/dist/landing/landing-header.js +15 -4
- package/dist/landing/mixins/countdown-tick.d.ts +29 -0
- package/dist/landing/mixins/countdown-tick.js +65 -0
- package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
- package/dist/landing/mixins/usage-estimate-live.js +120 -0
- package/dist/landing/phone-fan.d.ts +38 -0
- package/dist/landing/phone-fan.js +89 -0
- package/dist/landing/phone-frame.d.ts +48 -0
- package/dist/landing/phone-frame.js +41 -0
- package/dist/landing/price-list.d.ts +68 -0
- package/dist/landing/price-list.js +125 -0
- package/dist/landing/scroll-scene.d.ts +59 -0
- package/dist/landing/scroll-scene.js +70 -0
- package/dist/landing/sponsor-wall.d.ts +30 -6
- package/dist/landing/sponsor-wall.js +70 -14
- package/dist/landing/typed-terminal.d.ts +24 -6
- package/dist/landing/typed-terminal.js +22 -14
- package/dist/landing/usage-estimate.d.ts +127 -0
- package/dist/landing/usage-estimate.js +164 -0
- package/dist/landing/utils/countdown.d.ts +33 -0
- package/dist/landing/utils/countdown.js +42 -0
- package/dist/landing/utils/pause-toggle.d.ts +2 -1
- package/dist/mixins/character-count.d.ts +62 -0
- package/dist/mixins/character-count.js +139 -0
- package/dist/mixins/index.d.ts +6 -2
- package/dist/mixins/index.js +6 -2
- package/dist/mixins/invoker-fields.d.ts +18 -0
- package/dist/mixins/invoker-fields.js +60 -0
- package/dist/mixins/media-sync.d.ts +58 -0
- package/dist/mixins/media-sync.js +102 -0
- package/dist/mixins/menu-keys.d.ts +11 -0
- package/dist/mixins/menu-keys.js +79 -70
- package/dist/mixins/sortable.d.ts +96 -0
- package/dist/mixins/sortable.js +433 -0
- package/dist/utils/code-lines.d.ts +26 -0
- package/dist/utils/code-lines.js +29 -0
- package/dist/utils/file-icon.d.ts +31 -0
- package/dist/utils/file-icon.js +60 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/write-cookie.d.ts +15 -15
- package/dist/utils/write-cookie.js +10 -16
- package/dist/video/index.d.ts +11 -0
- package/dist/video/index.js +11 -0
- package/dist/video/mixins/video-player-sync.d.ts +27 -0
- package/dist/video/mixins/video-player-sync.js +413 -0
- package/dist/video/utils/timeline.d.ts +55 -0
- package/dist/video/utils/timeline.js +90 -0
- package/dist/video/video-player.d.ts +261 -0
- package/dist/video/video-player.js +927 -0
- package/package.json +6 -3
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape of a CI log before it is drawn: workflow markers (`##[group]`, `##[error]`…) read
|
|
3
|
+
* off each line, groups nested into a tree, and the tree cut into chunks the browser can skip
|
|
4
|
+
* painting. Shared by the server render and the island that appends streamed lines.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { parseAnsiLine } from "./ansi.js";
|
|
10
|
+
/**
|
|
11
|
+
* A line number no real log reaches, passed to a line-link builder so the link's shape can be
|
|
12
|
+
* read back as a template, with `{n}` where the number goes, for lines that stream in later.
|
|
13
|
+
*/
|
|
14
|
+
export const LOG_LINE_PLACEHOLDER = 987_654_321;
|
|
15
|
+
/** The workflow markers a line may start with, and what each makes it. */
|
|
16
|
+
const MARKERS = {
|
|
17
|
+
group: "group",
|
|
18
|
+
endgroup: "endgroup",
|
|
19
|
+
error: "danger",
|
|
20
|
+
warning: "warning",
|
|
21
|
+
notice: "notice",
|
|
22
|
+
command: "command",
|
|
23
|
+
debug: "muted",
|
|
24
|
+
};
|
|
25
|
+
/** `##[name]` at the start of a line, after any escapes that precede it. */
|
|
26
|
+
// oxlint-disable-next-line no-control-regex -- a marker may follow the ESC sequences that colour it
|
|
27
|
+
const MARKER = /^((?:\u001b\[[0-9;]*m)*)##\[(\w+)\]/;
|
|
28
|
+
/** An ISO 8601 timestamp and the space after it, the way raw CI logs prefix every line. */
|
|
29
|
+
const TIMESTAMP = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z) /;
|
|
30
|
+
/**
|
|
31
|
+
* Reads a line's leading workflow marker, returning it with the marker removed from the text.
|
|
32
|
+
*
|
|
33
|
+
* @param text The raw line.
|
|
34
|
+
* @returns The marker (or `undefined`) and the text to draw.
|
|
35
|
+
* @example readMarker("##[error]Process completed with exit code 1.") // { marker: "danger", text: "Process completed…" }
|
|
36
|
+
*/
|
|
37
|
+
export function readMarker(text) {
|
|
38
|
+
let match = MARKER.exec(text);
|
|
39
|
+
let marker = match === null ? undefined : MARKERS[match[2].toLowerCase()];
|
|
40
|
+
if (match === null || marker === undefined)
|
|
41
|
+
return { marker: undefined, text };
|
|
42
|
+
return { marker, text: match[1] + text.slice(match[0].length) };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Splits a raw streamed line into its ISO timestamp and the text after it.
|
|
46
|
+
*
|
|
47
|
+
* @param raw A line as a CI runner writes it.
|
|
48
|
+
* @returns The timestamp, when the line starts with one, and the text.
|
|
49
|
+
* @example splitTimestamp("2026-11-13T09:00:01.123Z Run tests") // { ts: "2026-11-13T09:00:01.123Z", text: "Run tests" }
|
|
50
|
+
*/
|
|
51
|
+
export function splitTimestamp(raw) {
|
|
52
|
+
let match = TIMESTAMP.exec(raw);
|
|
53
|
+
return match === null ? { text: raw } : { ts: match[1], text: raw.slice(match[0].length) };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The time a line shows: an ISO timestamp as `HH:MM:SS` UTC, anything else as given, so the
|
|
57
|
+
* server's lines and streamed ones read alike.
|
|
58
|
+
*
|
|
59
|
+
* @param ts The line's timestamp.
|
|
60
|
+
* @returns The time to draw beside the line.
|
|
61
|
+
* @example formatLogTime("2026-11-13T09:00:01.123Z") // "09:00:01"
|
|
62
|
+
*/
|
|
63
|
+
export function formatLogTime(ts) {
|
|
64
|
+
return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(ts) ? ts.slice(11, 19) : ts;
|
|
65
|
+
}
|
|
66
|
+
/** What a line makes of the log: its explicit `group` field wins over its text's marker. */
|
|
67
|
+
function lineKind(line, marker) {
|
|
68
|
+
if (line.group === "start")
|
|
69
|
+
return "group";
|
|
70
|
+
if (line.group === "end")
|
|
71
|
+
return "endgroup";
|
|
72
|
+
return marker;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Nests a step's lines into folds: a `##[group]` line (or `group: "start"`) opens a fold
|
|
76
|
+
* titled by its text, `##[endgroup]` (or `group: "end"`) closes the innermost one and is not
|
|
77
|
+
* drawn, and a fold still open at the end closes there.
|
|
78
|
+
*
|
|
79
|
+
* @param lines The step's lines in order.
|
|
80
|
+
* @returns The top-level nodes.
|
|
81
|
+
* @example buildLogTree([{ n: 1, text: "##[group]Install" }, { n: 2, text: "ok" }, { n: 3, text: "##[endgroup]" }])
|
|
82
|
+
*/
|
|
83
|
+
export function buildLogTree(lines) {
|
|
84
|
+
let root = [];
|
|
85
|
+
let stack = [];
|
|
86
|
+
let siblings = () => stack.at(-1)?.children ?? root;
|
|
87
|
+
let style = {};
|
|
88
|
+
for (let line of lines) {
|
|
89
|
+
let { marker, text } = readMarker(line.text);
|
|
90
|
+
let kind = lineKind(line, marker);
|
|
91
|
+
let parsed = parseAnsiLine(text, style);
|
|
92
|
+
style = parsed.state;
|
|
93
|
+
if (kind === "endgroup") {
|
|
94
|
+
stack.pop();
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
let entry = { n: line.n, spans: parsed.spans, ts: line.ts };
|
|
98
|
+
if (kind !== undefined && kind !== "group")
|
|
99
|
+
entry.tone = kind;
|
|
100
|
+
for (let open of stack)
|
|
101
|
+
open.lines++;
|
|
102
|
+
if (kind === "group") {
|
|
103
|
+
let group = {
|
|
104
|
+
kind: "group",
|
|
105
|
+
entry,
|
|
106
|
+
children: [],
|
|
107
|
+
lines: 1,
|
|
108
|
+
hasError: false,
|
|
109
|
+
};
|
|
110
|
+
siblings().push(group);
|
|
111
|
+
stack.push(group);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (entry.tone === "danger")
|
|
115
|
+
for (let open of stack)
|
|
116
|
+
open.hasError = true;
|
|
117
|
+
siblings().push({ kind: "line", entry });
|
|
118
|
+
}
|
|
119
|
+
return root;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Cuts sibling nodes into runs of about `size` lines, a fold counting all of its lines, so
|
|
123
|
+
* each run can be skipped as one box while off screen. A fold is never split.
|
|
124
|
+
*
|
|
125
|
+
* @param nodes Sibling nodes in order.
|
|
126
|
+
* @param size The lines a run aims for.
|
|
127
|
+
* @returns The runs, in order.
|
|
128
|
+
* @example chunkLogNodes(buildLogTree(lines), 200)
|
|
129
|
+
*/
|
|
130
|
+
export function chunkLogNodes(nodes, size) {
|
|
131
|
+
let chunks = [];
|
|
132
|
+
let current = [];
|
|
133
|
+
let weight = 0;
|
|
134
|
+
for (let node of nodes) {
|
|
135
|
+
current.push(node);
|
|
136
|
+
weight += node.kind === "group" ? node.lines : 1;
|
|
137
|
+
if (weight >= size) {
|
|
138
|
+
chunks.push(current);
|
|
139
|
+
current = [];
|
|
140
|
+
weight = 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (current.length > 0)
|
|
144
|
+
chunks.push(current);
|
|
145
|
+
return chunks;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The attributes a styled span carries, which the viewer's stylesheet tones; the same names
|
|
149
|
+
* serve the server's markup and the lines the island appends.
|
|
150
|
+
*
|
|
151
|
+
* @param style The span's ANSI style.
|
|
152
|
+
* @returns `data-fg`, `data-bg`, `data-b`, `data-dim`, `data-i` and `data-u`, where set.
|
|
153
|
+
* @example ansiAttributes({ fg: "red", bold: true }) // { "data-fg": "red", "data-b": "" }
|
|
154
|
+
*/
|
|
155
|
+
export function ansiAttributes(style) {
|
|
156
|
+
let attributes = {};
|
|
157
|
+
if (style.fg !== undefined)
|
|
158
|
+
attributes["data-fg"] = style.fg;
|
|
159
|
+
if (style.bg !== undefined)
|
|
160
|
+
attributes["data-bg"] = style.bg;
|
|
161
|
+
if (style.bold)
|
|
162
|
+
attributes["data-b"] = "";
|
|
163
|
+
if (style.dim)
|
|
164
|
+
attributes["data-dim"] = "";
|
|
165
|
+
if (style.italic)
|
|
166
|
+
attributes["data-i"] = "";
|
|
167
|
+
if (style.underline)
|
|
168
|
+
attributes["data-u"] = "";
|
|
169
|
+
return attributes;
|
|
170
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The match rule a file tree's filter applies, shared by the server that renders a narrowed
|
|
3
|
+
* tree for `?filter=` and the island that narrows it as the reader types, so both keep the
|
|
4
|
+
* same files for the same query.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Whether a file's path matches a filter query: every whitespace-separated term appears in
|
|
11
|
+
* the path, ignoring case, so `ui tree` finds `packages/ui/src/app/tree.tsx`. An empty or
|
|
12
|
+
* blank query matches every path.
|
|
13
|
+
*
|
|
14
|
+
* @param path The file's path or name.
|
|
15
|
+
* @param query What the reader typed.
|
|
16
|
+
* @returns Whether the file stays in the tree.
|
|
17
|
+
* @example paths.filter((path) => treeFilterMatches(path, url.searchParams.get("filter") ?? ""))
|
|
18
|
+
*/
|
|
19
|
+
export declare function treeFilterMatches(path: string, query: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The match rule a file tree's filter applies, shared by the server that renders a narrowed
|
|
3
|
+
* tree for `?filter=` and the island that narrows it as the reader types, so both keep the
|
|
4
|
+
* same files for the same query.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Whether a file's path matches a filter query: every whitespace-separated term appears in
|
|
11
|
+
* the path, ignoring case, so `ui tree` finds `packages/ui/src/app/tree.tsx`. An empty or
|
|
12
|
+
* blank query matches every path.
|
|
13
|
+
*
|
|
14
|
+
* @param path The file's path or name.
|
|
15
|
+
* @param query What the reader typed.
|
|
16
|
+
* @returns Whether the file stays in the tree.
|
|
17
|
+
* @example paths.filter((path) => treeFilterMatches(path, url.searchParams.get("filter") ?? ""))
|
|
18
|
+
*/
|
|
19
|
+
export function treeFilterMatches(path, query) {
|
|
20
|
+
let haystack = path.toLowerCase();
|
|
21
|
+
return query
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.split(/\s+/)
|
|
24
|
+
.filter((term) => term !== "")
|
|
25
|
+
.every((term) => haystack.includes(term));
|
|
26
|
+
}
|
|
@@ -58,6 +58,8 @@ export declare namespace ViewOptions {
|
|
|
58
58
|
url?: URL | string;
|
|
59
59
|
/** Where Apply submits. Defaults to the current path. */
|
|
60
60
|
action?: string;
|
|
61
|
+
/** The named `<Frame>` Apply loads into, so only that frame reloads; unset loads the page. */
|
|
62
|
+
target?: string;
|
|
61
63
|
/** @default name "layout" */
|
|
62
64
|
layout?: Field;
|
|
63
65
|
/** @default name "group" */
|
package/dist/app/view-options.js
CHANGED
|
@@ -43,7 +43,7 @@ const DEFAULT_NAMES = {
|
|
|
43
43
|
*/
|
|
44
44
|
export function ViewOptions(handle) {
|
|
45
45
|
return () => {
|
|
46
|
-
let { id, url = DEFAULT_URL, action, layout, grouping, ordering, density, properties, setDefault, inline, labels, mix, ...rest } = handle.props;
|
|
46
|
+
let { id, url = DEFAULT_URL, action, target, layout, grouping, ordering, density, properties, setDefault, inline, labels, mix, ...rest } = handle.props;
|
|
47
47
|
let popoverId = `${id}-popover`;
|
|
48
48
|
let names = {
|
|
49
49
|
layout: layout?.name ?? DEFAULT_NAMES.layout,
|
|
@@ -59,7 +59,7 @@ export function ViewOptions(handle) {
|
|
|
59
59
|
density ? names.density : null,
|
|
60
60
|
properties ? names.properties : null,
|
|
61
61
|
].filter((name) => name !== null);
|
|
62
|
-
let form = (_jsxs("form", { method: "get", action: action, "aria-label": inline ? labels.trigger : undefined, mix: [vstack({ gap: 3 })], children: [carriedParams(url, owned).map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }))), layout ? (_jsx(Segmented, { name: names.layout, label: labels.layout, field: layout, value: chosen(url, names.layout, layout) })) : null, grouping ? (_jsx(SelectRow, { id: `${id}-grouping`, name: names.grouping, label: labels.grouping, field: grouping, value: chosen(url, names.grouping, grouping) })) : null, ordering ? (_jsx(SelectRow, { id: `${id}-ordering`, name: names.ordering, label: labels.ordering, field: ordering, value: chosen(url, names.ordering, ordering) })) : null, density ? (_jsx(Segmented, { name: names.density, label: labels.density, field: density, value: chosen(url, names.density, density) })) : null, properties ? (_jsx(PropertyChips, { name: names.properties, label: labels.properties, field: properties, selected: shownProperties(url, names.properties, properties) })) : null, _jsxs("div", { mix: [flex(), items("center"), justify("end"), gap(2)], children: [setDefault ? (_jsx(Button, { type: "submit", variant: "ghost", size: "sm", formMethod: "post", formAction: setDefault.action, "data-slot": "view-options-default", children: labels.setDefault })) : null, _jsx(Button, { type: "submit", size: "sm", color: "brand", "data-slot": "view-options-apply", children: labels.apply })] })] }));
|
|
62
|
+
let form = (_jsxs("form", { method: "get", action: action, "data-rmx-target": target, "aria-label": inline ? labels.trigger : undefined, mix: [vstack({ gap: 3 })], children: [carriedParams(url, owned).map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }))), layout ? (_jsx(Segmented, { name: names.layout, label: labels.layout, field: layout, value: chosen(url, names.layout, layout) })) : null, grouping ? (_jsx(SelectRow, { id: `${id}-grouping`, name: names.grouping, label: labels.grouping, field: grouping, value: chosen(url, names.grouping, grouping) })) : null, ordering ? (_jsx(SelectRow, { id: `${id}-ordering`, name: names.ordering, label: labels.ordering, field: ordering, value: chosen(url, names.ordering, ordering) })) : null, density ? (_jsx(Segmented, { name: names.density, label: labels.density, field: density, value: chosen(url, names.density, density) })) : null, properties ? (_jsx(PropertyChips, { name: names.properties, label: labels.properties, field: properties, selected: shownProperties(url, names.properties, properties) })) : null, _jsxs("div", { mix: [flex(), items("center"), justify("end"), gap(2)], children: [setDefault ? (_jsx(Button, { type: "submit", variant: "ghost", size: "sm", formMethod: "post", formAction: setDefault.action, "data-slot": "view-options-default", children: labels.setDefault })) : null, _jsx(Button, { type: "submit", size: "sm", color: "brand", "data-slot": "view-options-apply", children: labels.apply })] })] }));
|
|
63
63
|
if (inline) {
|
|
64
64
|
return (_jsx("div", { ...rest, "data-slot": "view-options", "data-inline": "", mix: mergeMix([minIs(0)], mix), children: form }));
|
|
65
65
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an assistant did before it answered: a collapsible "Thinking" disclosure holding its
|
|
3
|
+
* narration and a list of steps (searched, read, ran a command), each able to open onto its
|
|
4
|
+
* own output. Native `<details>` throughout, so it opens and closes without script.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link Activity} and its compound parts. */
|
|
11
|
+
export declare namespace Activity {
|
|
12
|
+
/** Props accepted by {@link Activity}: every native `<details>` attribute. */
|
|
13
|
+
interface Props extends TagProps<"details"> {
|
|
14
|
+
/** An {@link Activity.Summary}, then an optional {@link Activity.Note} and {@link Activity.Steps}. */
|
|
15
|
+
children: RemixNode;
|
|
16
|
+
}
|
|
17
|
+
/** Props accepted by {@link Activity.Summary}. */
|
|
18
|
+
interface SummaryProps extends TagProps<"summary"> {
|
|
19
|
+
/** What the summary says once the work is done, such as "Thought for 8s". */
|
|
20
|
+
children: RemixNode;
|
|
21
|
+
/**
|
|
22
|
+
* What it says while the reply around it is busy (`aria-busy="true"`), such as
|
|
23
|
+
* "Thinking"; it shimmers until the reply settles.
|
|
24
|
+
*/
|
|
25
|
+
busy?: RemixNode;
|
|
26
|
+
}
|
|
27
|
+
/** Props accepted by {@link Activity.Note}. */
|
|
28
|
+
interface NoteProps extends TagProps<"p"> {
|
|
29
|
+
/** The assistant's own words on what it is about to do. */
|
|
30
|
+
children: RemixNode;
|
|
31
|
+
}
|
|
32
|
+
/** Props accepted by {@link Activity.Steps}. */
|
|
33
|
+
interface StepsProps extends TagProps<"ol"> {
|
|
34
|
+
/** {@link Activity.Step} rows in the order they happened. */
|
|
35
|
+
children: RemixNode;
|
|
36
|
+
/** Frames the list with dividers, for a run of similar steps inside another step. */
|
|
37
|
+
boxed?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Props accepted by {@link Activity.Step}. */
|
|
40
|
+
interface StepProps extends Omit<TagProps<"li">, "title"> {
|
|
41
|
+
/** What happened, in the past tense ("Searched the web"), or the present while `running`. */
|
|
42
|
+
children: RemixNode;
|
|
43
|
+
/** A 16px glyph for the kind of step; a step that only marks progress goes without. */
|
|
44
|
+
icon?: RemixNode;
|
|
45
|
+
/** What the step opens onto: a command's output, or a {@link Activity.Steps} `boxed` run. */
|
|
46
|
+
detail?: RemixNode;
|
|
47
|
+
/** Draws the step as still in progress, with moving dots in place of its icon. */
|
|
48
|
+
running?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* How long a streamed replay dwells on this step, in milliseconds, so a search or a command
|
|
51
|
+
* reads as taking time; while it dwells the step shows the moving dots.
|
|
52
|
+
*/
|
|
53
|
+
duration?: number;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Renders the disclosure. Pass `open` while the reply streams so its steps show as they
|
|
58
|
+
* arrive; a replay folds it once the answer starts, and history leaves it closed.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* <Activity open>
|
|
62
|
+
* <Activity.Summary busy="Thinking">Thought for 8s</Activity.Summary>
|
|
63
|
+
* <Activity.Steps><Activity.Step icon={<GlobeIcon />}>Searched the web</Activity.Step></Activity.Steps>
|
|
64
|
+
* </Activity>
|
|
65
|
+
*/
|
|
66
|
+
export declare function Activity(handle: Handle<Activity.Props>): () => import("remix/component").RemixElement;
|
|
67
|
+
export declare namespace Activity {
|
|
68
|
+
var Summary: (handle: Handle<Activity.SummaryProps>) => () => import("remix/component").RemixElement;
|
|
69
|
+
var Note: (handle: Handle<Activity.NoteProps>) => () => import("remix/component").RemixElement;
|
|
70
|
+
var Steps: (handle: Handle<Activity.StepsProps>) => () => import("remix/component").RemixElement;
|
|
71
|
+
var Step: (handle: Handle<Activity.StepProps>) => () => import("remix/component").RemixElement;
|
|
72
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon, ChevronRightIcon } from "@sdxc/icons";
|
|
3
|
+
import { keyframes } from "@sdxc/u/animation";
|
|
4
|
+
import { fg } from "@sdxc/u/color";
|
|
5
|
+
import { listStyle, mergeMix, raw } from "@sdxc/u/general";
|
|
6
|
+
import { media } from "@sdxc/u/responsive";
|
|
7
|
+
import { m, p } from "@sdxc/u/size";
|
|
8
|
+
import { open, when } from "@sdxc/u/state";
|
|
9
|
+
import { rotate } from "@sdxc/u/transform";
|
|
10
|
+
import { text } from "@sdxc/u/typography";
|
|
11
|
+
/** The attribute a reply carries while its text streams in, which turns the summary live. */
|
|
12
|
+
const BUSY_SELECTOR = ':where([aria-busy="true"])';
|
|
13
|
+
/** The activity once a replay folded it, whose summary says what was done again. */
|
|
14
|
+
const COLLAPSED_SELECTOR = ":where([data-stream-collapsed])";
|
|
15
|
+
/** Text a streaming replay leaves whole, so the summary never types itself out. */
|
|
16
|
+
const STREAM_SKIP = { "data-stream-skip": "" };
|
|
17
|
+
/** Keyframes for the busy label's light sweep. */
|
|
18
|
+
const SHIMMER = "ui-activity-shimmer";
|
|
19
|
+
/** Keyframes for the running step's dots. */
|
|
20
|
+
const DOTS = "ui-activity-dots";
|
|
21
|
+
/**
|
|
22
|
+
* Renders the disclosure. Pass `open` while the reply streams so its steps show as they
|
|
23
|
+
* arrive; a replay folds it once the answer starts, and history leaves it closed.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <Activity open>
|
|
27
|
+
* <Activity.Summary busy="Thinking">Thought for 8s</Activity.Summary>
|
|
28
|
+
* <Activity.Steps><Activity.Step icon={<GlobeIcon />}>Searched the web</Activity.Step></Activity.Steps>
|
|
29
|
+
* </Activity>
|
|
30
|
+
*/
|
|
31
|
+
export function Activity(handle) {
|
|
32
|
+
return () => {
|
|
33
|
+
let { children, mix, ...rest } = handle.props;
|
|
34
|
+
return (_jsx("details", { ...rest, "data-slot": "activity", "data-stream-collapse": "", mix: mergeMix([
|
|
35
|
+
raw({ display: "block", marginBlockEnd: "1rem" }),
|
|
36
|
+
open(when("& > summary > svg", rotate(180))),
|
|
37
|
+
open(when("& > summary", raw({ marginBlockEnd: "0.625rem" }))),
|
|
38
|
+
], mix), children: children }));
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** The disclosure's line: the done label, or the shimmering busy one while the reply streams. */
|
|
42
|
+
Activity.Summary = function ActivitySummary(handle) {
|
|
43
|
+
return () => {
|
|
44
|
+
let { busy, children, mix, ...rest } = handle.props;
|
|
45
|
+
return (_jsxs("summary", { ...rest, ...STREAM_SKIP, "data-slot": "activity-summary", mix: mergeMix([
|
|
46
|
+
keyframes(SHIMMER, {
|
|
47
|
+
"0%": { backgroundPosition: "100% 0" },
|
|
48
|
+
"100%": { backgroundPosition: "-100% 0" },
|
|
49
|
+
}),
|
|
50
|
+
text("sm"),
|
|
51
|
+
fg("neutral.fg-muted"),
|
|
52
|
+
raw({
|
|
53
|
+
display: "inline-flex",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
gap: "0.25rem",
|
|
56
|
+
inlineSize: "fit-content",
|
|
57
|
+
cursor: "pointer",
|
|
58
|
+
listStyle: "none",
|
|
59
|
+
"&::-webkit-details-marker": { display: "none" },
|
|
60
|
+
"&:hover": { color: "var(--ui-neutral-fg-emphasis)" },
|
|
61
|
+
"&:focus-visible": {
|
|
62
|
+
outline: "2px solid var(--ui-brand-ring)",
|
|
63
|
+
outlineOffset: "2px",
|
|
64
|
+
borderRadius: "var(--ui-radius-sm, 0.25rem)",
|
|
65
|
+
},
|
|
66
|
+
"& [data-activity-label=busy]": { display: "none" },
|
|
67
|
+
[`${BUSY_SELECTOR} & [data-activity-label=busy]`]: { display: "inline" },
|
|
68
|
+
[`${BUSY_SELECTOR} & [data-activity-label=done]`]: { display: "none" },
|
|
69
|
+
[`${COLLAPSED_SELECTOR} & [data-activity-label=busy]`]: { display: "none" },
|
|
70
|
+
[`${COLLAPSED_SELECTOR} & [data-activity-label=done]`]: { display: "inline" },
|
|
71
|
+
}),
|
|
72
|
+
media("(prefers-reduced-motion: no-preference)", raw({
|
|
73
|
+
[`${BUSY_SELECTOR} & [data-activity-label=busy]`]: {
|
|
74
|
+
backgroundImage: "linear-gradient(90deg, var(--ui-neutral-fg-muted) 35%, var(--ui-neutral-fg-emphasis) 50%, var(--ui-neutral-fg-muted) 65%)",
|
|
75
|
+
backgroundSize: "200% 100%",
|
|
76
|
+
backgroundClip: "text",
|
|
77
|
+
WebkitBackgroundClip: "text",
|
|
78
|
+
color: "transparent",
|
|
79
|
+
animationName: SHIMMER,
|
|
80
|
+
animationDuration: "1.6s",
|
|
81
|
+
animationTimingFunction: "linear",
|
|
82
|
+
animationIterationCount: "infinite",
|
|
83
|
+
},
|
|
84
|
+
})),
|
|
85
|
+
], mix), children: [busy === undefined ? null : _jsx("span", { "data-activity-label": "busy", children: busy }), _jsx("span", { "data-activity-label": "done", children: children }), _jsx(ChevronDownIcon, { size: 14, "aria-hidden": "true" })] }));
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** The assistant's narration, set as body text above its steps. */
|
|
89
|
+
Activity.Note = function ActivityNote(handle) {
|
|
90
|
+
return () => {
|
|
91
|
+
let { children, mix, ...rest } = handle.props;
|
|
92
|
+
return (_jsx("p", { ...rest, "data-slot": "activity-note", mix: mergeMix([raw({ margin: "0 0 0.75rem", lineHeight: "1.6" }), fg("neutral.fg-emphasis")], mix), children: children }));
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/** The steps, in order; `boxed` frames a run of them with dividers. */
|
|
96
|
+
Activity.Steps = function ActivitySteps(handle) {
|
|
97
|
+
return () => {
|
|
98
|
+
let { boxed = false, children, mix, ...rest } = handle.props;
|
|
99
|
+
return (_jsx("ol", { ...rest, "data-slot": "activity-steps", "data-boxed": boxed ? "" : undefined, mix: mergeMix([
|
|
100
|
+
m(0),
|
|
101
|
+
p(0),
|
|
102
|
+
listStyle(),
|
|
103
|
+
raw({
|
|
104
|
+
display: "grid",
|
|
105
|
+
gap: "0.5rem",
|
|
106
|
+
"&[data-boxed]": {
|
|
107
|
+
gap: "0",
|
|
108
|
+
border: "1px solid var(--ui-neutral-border)",
|
|
109
|
+
borderRadius: "var(--ui-radius-lg, 0.75rem)",
|
|
110
|
+
overflow: "hidden",
|
|
111
|
+
},
|
|
112
|
+
"&[data-boxed] > li": { paddingBlock: "0.5rem", paddingInline: "0.875rem" },
|
|
113
|
+
"&[data-boxed] > li + li": { borderBlockStart: "1px solid var(--ui-neutral-border)" },
|
|
114
|
+
}),
|
|
115
|
+
], mix), children: children }));
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
/** The four dots a running step shows in place of its icon. */
|
|
119
|
+
function RunningDots() {
|
|
120
|
+
return () => (_jsxs("span", { "aria-hidden": "true", mix: [
|
|
121
|
+
keyframes(DOTS, {
|
|
122
|
+
"0%, 100%": { opacity: "1" },
|
|
123
|
+
"50%": { opacity: "0.25" },
|
|
124
|
+
}),
|
|
125
|
+
raw({
|
|
126
|
+
display: "inline-grid",
|
|
127
|
+
gridTemplateColumns: "repeat(2, 4px)",
|
|
128
|
+
gap: "3px",
|
|
129
|
+
inlineSize: "16px",
|
|
130
|
+
placeContent: "center",
|
|
131
|
+
"& > i": {
|
|
132
|
+
inlineSize: "4px",
|
|
133
|
+
blockSize: "4px",
|
|
134
|
+
borderRadius: "999px",
|
|
135
|
+
backgroundColor: "var(--ui-brand-fg)",
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
media("(prefers-reduced-motion: no-preference)", raw({
|
|
139
|
+
"& > i": {
|
|
140
|
+
animationName: DOTS,
|
|
141
|
+
animationDuration: "1.2s",
|
|
142
|
+
animationIterationCount: "infinite",
|
|
143
|
+
},
|
|
144
|
+
"& > i:nth-child(2)": { animationDelay: "0.3s" },
|
|
145
|
+
"& > i:nth-child(4)": { animationDelay: "0.6s" },
|
|
146
|
+
"& > i:nth-child(3)": { animationDelay: "0.9s" },
|
|
147
|
+
})),
|
|
148
|
+
], children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* One step: its glyph and words in a muted line. With `detail` the line is a nested
|
|
152
|
+
* disclosure that opens onto the step's output.
|
|
153
|
+
*/
|
|
154
|
+
Activity.Step = function ActivityStep(handle) {
|
|
155
|
+
return () => {
|
|
156
|
+
let { children, detail, duration, icon, running = false, mix, ...rest } = handle.props;
|
|
157
|
+
let line = (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "activity-dots", mix: [raw({ flexShrink: 0 })], children: _jsx(RunningDots, {}) }), icon === undefined ? null : (_jsx("span", { "data-slot": "activity-icon", mix: [raw({ flexShrink: 0 })], children: icon })), _jsx("span", { mix: [raw({ minInlineSize: 0 })], children: children })] }));
|
|
158
|
+
let lineMix = raw({ display: "flex", alignItems: "center", gap: "0.5rem" });
|
|
159
|
+
return (_jsx("li", { ...rest, "data-slot": "activity-step", "data-running": running ? "" : undefined, "data-stream-pause": duration, mix: mergeMix([
|
|
160
|
+
text("sm"),
|
|
161
|
+
fg("neutral.fg-muted"),
|
|
162
|
+
raw({
|
|
163
|
+
"& [data-slot=activity-icon]": { display: "inline-flex" },
|
|
164
|
+
"& [data-slot=activity-dots]": { display: "none" },
|
|
165
|
+
"&[data-running] [data-slot=activity-dots]": { display: "inline-flex" },
|
|
166
|
+
"&[data-running] [data-slot=activity-icon]": { display: "none" },
|
|
167
|
+
[`${BUSY_SELECTOR} &:is([data-stream-current], :has([data-stream-current])) [data-slot=activity-dots]`]: { display: "inline-flex" },
|
|
168
|
+
[`${BUSY_SELECTOR} &:is([data-stream-current], :has([data-stream-current])) [data-slot=activity-icon]`]: { display: "none" },
|
|
169
|
+
}),
|
|
170
|
+
], mix), children: detail === undefined ? (_jsx("div", { mix: [lineMix], children: line })) : (_jsxs("details", { mix: [
|
|
171
|
+
raw({ "& > :not(summary)": { marginBlockStart: "0.5rem" } }),
|
|
172
|
+
open(when("& > summary > svg", rotate(90))),
|
|
173
|
+
], children: [_jsxs("summary", { mix: [
|
|
174
|
+
lineMix,
|
|
175
|
+
raw({
|
|
176
|
+
cursor: "pointer",
|
|
177
|
+
listStyle: "none",
|
|
178
|
+
inlineSize: "fit-content",
|
|
179
|
+
"&::-webkit-details-marker": { display: "none" },
|
|
180
|
+
"&:hover": { color: "var(--ui-neutral-fg-emphasis)" },
|
|
181
|
+
}),
|
|
182
|
+
], children: [line, _jsx(ChevronRightIcon, { size: 14, "aria-hidden": "true" })] }), detail] })) }));
|
|
183
|
+
};
|
|
184
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Island holding a composer's send control. Hydrated, Enter sends and Shift+Enter writes a
|
|
3
|
+
* new line, and when the page just answered a message it replays that reply as a stream,
|
|
4
|
+
* turning Send into Stop until the reply finishes. Without script it is a submit button.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent } from "remix/component";
|
|
10
|
+
/** Prop types for {@link ComposerSubmit}. */
|
|
11
|
+
export declare namespace ComposerSubmit {
|
|
12
|
+
/** Plain data only, since the props cross into the browser with the island. */
|
|
13
|
+
type Props = {
|
|
14
|
+
/** The buttons' accessible names, such as "Send message" and "Stop response". */
|
|
15
|
+
labels: {
|
|
16
|
+
send: string;
|
|
17
|
+
stop: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The `id` of a reply the page just answered with, marked `data-stream-pending` and
|
|
21
|
+
* styled with `streamTarget()`; it replays as a stream, or shows at once under
|
|
22
|
+
* reduced motion.
|
|
23
|
+
*/
|
|
24
|
+
stream?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Changes with every new reply, so a page answered in place by client navigation
|
|
27
|
+
* replays a reply that reuses the previous one's `id`.
|
|
28
|
+
*/
|
|
29
|
+
streamKey?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders Send, or Stop while a reply streams. Enter sends a non-empty message unless an
|
|
34
|
+
* input method is composing; Escape stops a streaming reply.
|
|
35
|
+
*
|
|
36
|
+
* @example <ComposerSubmit labels={{ send: "Send message", stop: "Stop response" }} stream="reply-7" />
|
|
37
|
+
*/
|
|
38
|
+
export declare const ComposerSubmit: EntryComponent<ComposerSubmit.Props>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
|
+
import { ArrowUpIcon, SquareIcon } from "@sdxc/icons";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { raw } from "@sdxc/u/general";
|
|
5
|
+
import { shrink } from "@sdxc/u/layout";
|
|
6
|
+
import { bs, is, minBs, minIs, pb, pi } from "@sdxc/u/size";
|
|
7
|
+
import { clientEntry } from "remix/component";
|
|
8
|
+
import { Button } from "../components/button.js";
|
|
9
|
+
import { COMPOSER_STOP_SLOT, composerSend } from "./mixins/composer-send.js";
|
|
10
|
+
/** The round shape both buttons share, so swapping Send for Stop never moves the row. */
|
|
11
|
+
function buttonShape() {
|
|
12
|
+
return [
|
|
13
|
+
is("2.25rem"),
|
|
14
|
+
bs("2.25rem"),
|
|
15
|
+
minIs("2.25rem"),
|
|
16
|
+
minBs("2.25rem"),
|
|
17
|
+
pi(0),
|
|
18
|
+
pb(0),
|
|
19
|
+
rounded("full"),
|
|
20
|
+
shrink(0),
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Renders Send, or Stop while a reply streams. Enter sends a non-empty message unless an
|
|
25
|
+
* input method is composing; Escape stops a streaming reply.
|
|
26
|
+
*
|
|
27
|
+
* @example <ComposerSubmit labels={{ send: "Send message", stop: "Stop response" }} stream="reply-7" />
|
|
28
|
+
*/
|
|
29
|
+
export const ComposerSubmit = clientEntry("@sdxc/ui/chat/composer-submit#ComposerSubmit", function ComposerSubmit(handle) {
|
|
30
|
+
let streaming = false;
|
|
31
|
+
/** Swaps Send for Stop while the reply replays, and back when it ends. */
|
|
32
|
+
function onStreamingChange(next) {
|
|
33
|
+
streaming = next;
|
|
34
|
+
if (!handle.signal.aborted)
|
|
35
|
+
void handle.update();
|
|
36
|
+
}
|
|
37
|
+
return () => {
|
|
38
|
+
let { labels, stream, streamKey } = handle.props;
|
|
39
|
+
return (_jsx("span", { "data-slot": "composer-submit", mix: [
|
|
40
|
+
raw({ display: "contents" }),
|
|
41
|
+
composerSend({ stream, streamKey, onStreamingChange }),
|
|
42
|
+
], children: streaming ? (_jsx(Button, { type: "button", color: "neutral", "aria-label": labels.stop, title: labels.stop, "aria-keyshortcuts": "Escape", "data-slot": COMPOSER_STOP_SLOT, mix: buttonShape(), children: _jsx(SquareIcon, { size: 14, fill: "currentColor", "aria-hidden": "true" }) })) : (_jsx(Button, { type: "submit", color: "brand", "aria-label": labels.send, title: labels.send, "aria-keyshortcuts": "Enter", "data-slot": "composer-send", mix: buttonShape(), children: _jsx(ArrowUpIcon, { size: 18, "aria-hidden": "true" }) })) }));
|
|
43
|
+
};
|
|
44
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The box a person writes a chat message in: a form whose text field grows with what is
|
|
3
|
+
* typed up to a cap and then scrolls, over a toolbar for attaching files, picking options and
|
|
4
|
+
* sending. It is a plain form, so a message posts before any script loads.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** The slot the text field carries, which `ComposerSubmit` finds to send on Enter. */
|
|
11
|
+
export declare const COMPOSER_INPUT_SLOT = "composer-input";
|
|
12
|
+
/** Prop types for {@link Composer} and its compound parts. */
|
|
13
|
+
export declare namespace Composer {
|
|
14
|
+
/** Props accepted by {@link Composer}: every native `<form>` attribute. */
|
|
15
|
+
interface Props extends TagProps<"form"> {
|
|
16
|
+
/** Attachments, the {@link Composer.Input} and a {@link Composer.Toolbar}, in that order. */
|
|
17
|
+
children: RemixNode;
|
|
18
|
+
}
|
|
19
|
+
/** Props accepted by {@link Composer.Input}: every native `<textarea>` attribute. */
|
|
20
|
+
type InputProps = TagProps<"textarea">;
|
|
21
|
+
/** Props accepted by {@link Composer.Toolbar}. */
|
|
22
|
+
interface ToolbarProps extends TagProps<"div"> {
|
|
23
|
+
/** Attach and option controls first, then a {@link Composer.Hint} and the send control. */
|
|
24
|
+
children: RemixNode;
|
|
25
|
+
}
|
|
26
|
+
/** Props accepted by {@link Composer.Hint}. */
|
|
27
|
+
interface HintProps extends TagProps<"p"> {
|
|
28
|
+
/** How to send, such as `<Keyboard>Enter</Keyboard> to send`. */
|
|
29
|
+
children: RemixNode;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders the composer's surface: one rounded box that draws the focus ring for the field
|
|
34
|
+
* inside it, so the field, its attachments and its toolbar read as a single control.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* <Composer method="post" action="/chat">
|
|
38
|
+
* <Composer.Input name="prompt" aria-label="Message" required />
|
|
39
|
+
* <Composer.Toolbar><ComposerSubmit labels={{ send: "Send", stop: "Stop" }} /></Composer.Toolbar>
|
|
40
|
+
* </Composer>
|
|
41
|
+
*/
|
|
42
|
+
export declare function Composer(handle: Handle<Composer.Props>): () => import("remix/component").RemixElement;
|
|
43
|
+
export declare namespace Composer {
|
|
44
|
+
var Input: (handle: Handle<Composer.InputProps>) => () => import("remix/component").RemixElement;
|
|
45
|
+
var Toolbar: (handle: Handle<Composer.ToolbarProps>) => () => import("remix/component").RemixElement;
|
|
46
|
+
var Hint: (handle: Handle<Composer.HintProps>) => () => import("remix/component").RemixElement;
|
|
47
|
+
}
|