@gemboss/ui 0.61.0 → 0.64.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/CHANGELOG.md +153 -0
- package/README.md +163 -2
- package/catalog/editor.html +1 -1
- package/catalog/index.html +3 -3
- package/gemboss-ui.css +3 -3
- package/package.json +15 -1
- package/parts/components.css +3 -3
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/app-nav.css +1 -0
- package/src/app-nav.tsx +236 -0
- package/src/assistant/chat.tsx +67 -4
- package/src/assistant/dictation.ts +292 -0
- package/src/assistant/index.ts +4 -1
- package/src/audiences-table.css +1 -0
- package/src/audiences-table.tsx +167 -0
- package/src/chat-voice.css +1 -0
- package/src/editor/frame-context.ts +9 -0
- package/src/editor/index.ts +8 -0
- package/src/editor/inspector-frame.tsx +285 -0
- package/src/editor/label-side.ts +79 -0
- package/src/editor/panel.tsx +23 -6
- package/src/editor/repeater.tsx +9 -3
- package/src/editor-inspector-frame.css +1 -0
- package/src/editor.css +1 -1
- package/src/email-editor/editor.tsx +434 -0
- package/src/email-editor/index.ts +16 -0
- package/src/email-editor/model.ts +357 -0
- package/src/email-editor/preview.tsx +208 -0
- package/src/email-editor.css +1 -0
- package/src/gem-at-work.css +1 -0
- package/src/gem-at-work.ts +1165 -0
- package/src/index.ts +17 -1
- package/src/kit-plain.css +1 -1
- package/src/rail-mini.css +1 -0
- package/src/report-charts.css +1 -0
- package/src/shell.tsx +36 -8
- package/src/skill-feedback.css +1 -0
- package/src/skill-feedback.tsx +67 -0
- package/src/skill-history.css +1 -0
- package/src/skill-history.tsx +116 -0
- package/src/skill-pages.css +1 -0
- package/src/skill-pages.tsx +204 -0
- package/src/skill-tabs-group.tsx +45 -0
- package/src/skill-view.tsx +7 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Skills page's own pages — @gemboss/ui, unreleased (07/11/2026, Chris: "content radar hiện tại nó có thể trích xuất ra gemboss ui
|
|
3
|
+
* ntn để tái sử dụng và đồng bộ bên gemboss admin"). Lifted from content-radar's /v2/skills (SkillsTabs.jsx, rules/page.jsx,
|
|
4
|
+
* library/[doc]/page.jsx, library/DocHistory.client.jsx) so content-radar and GemBoss admin (Assistant › Skills, S4) draw the same:
|
|
5
|
+
*
|
|
6
|
+
* - SkillsTabs: the page's tabs (Skills · Rules · Building blocks…); a tab with `items` is a group, a <details> menu that names the
|
|
7
|
+
* page it is on ("Building blocks · Voices"), opened from the keyboard without script.
|
|
8
|
+
* - The Rules book: SkillRuleSummary (counts that jump to their section), SkillRuleSection (a titled block with a lead and a note),
|
|
9
|
+
* SkillGuardGroups (a card per group of hard rules: its code, name, each rule with what holds it), SkillCheckTable (the checks:
|
|
10
|
+
* what is counted, the rule, Blocks / Warns, which skills set their own numbers), SkillRuleLevel and SkillRuleChip (its chips).
|
|
11
|
+
* How a rule is held in GemBoss's words is SkillRuleHoldChip (skill-view.tsx), the one owner of that look.
|
|
12
|
+
* - Building blocks: SkillLayerList (each layer of shared files: voices, styles, frameworks, craft, with links), SkillDocJump (the
|
|
13
|
+
* files of one page), SkillDoc (one file's text) and SkillDocHistory (its versions, folded until opened).
|
|
14
|
+
*
|
|
15
|
+
* Presentational only: no fetching, no state. The surface owns the data, the words and its links (`renderLink`: content-radar's
|
|
16
|
+
* PendingLink, GemBoss's next/link); labels are props with English defaults, as SkillStats does.
|
|
17
|
+
*/
|
|
18
|
+
import "./skill-pages.css";
|
|
19
|
+
import React, { type ReactNode } from "react";
|
|
20
|
+
import { SkillsTabGroup } from "./skill-tabs-group";
|
|
21
|
+
|
|
22
|
+
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
23
|
+
|
|
24
|
+
/** The surface's link: a router link, or a plain <a> by default. */
|
|
25
|
+
export type SkillLinkRender = (props: { href: string; className?: string; current?: boolean; children: ReactNode }) => ReactNode;
|
|
26
|
+
const plainLink: SkillLinkRender = ({ href, className, current, children }) => (
|
|
27
|
+
<a href={href} className={className} aria-current={current ? "page" : undefined}>{children}</a>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// ── Tabs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
export interface SkillsTabLink { key: string; label: ReactNode; href: string }
|
|
33
|
+
export type SkillsTab = SkillsTabLink | { key: string; label: string; items: readonly SkillsTabLink[] };
|
|
34
|
+
|
|
35
|
+
export function SkillsTabs({ tabs, current, renderLink = plainLink, label = "Skills" }: {
|
|
36
|
+
tabs: readonly SkillsTab[]; current: string; renderLink?: SkillLinkRender; label?: string;
|
|
37
|
+
}) {
|
|
38
|
+
return (
|
|
39
|
+
<nav className="ui-tabs ui-skillstabs" aria-label={label}>
|
|
40
|
+
{tabs.map((t) => {
|
|
41
|
+
if (!("items" in t)) return <React.Fragment key={t.key}>{renderLink({ href: t.href, current: t.key === current, children: t.label })}</React.Fragment>;
|
|
42
|
+
const here = t.items.find((i) => i.key === current);
|
|
43
|
+
return (
|
|
44
|
+
<SkillsTabGroup key={t.key} current={!!here} summary={here ? <>{t.label} · {here.label}</> : t.label}>
|
|
45
|
+
{t.items.map((i) => <React.Fragment key={i.key}>{renderLink({ href: i.href, current: i.key === current, children: i.label })}</React.Fragment>)}
|
|
46
|
+
</SkillsTabGroup>
|
|
47
|
+
);
|
|
48
|
+
})}
|
|
49
|
+
</nav>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── The Rules book ──────────────────────────────────────────────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
/** Counts at the top of the book, each a jump to its section; `alert` marks one that needs a person (rules that disagree). */
|
|
56
|
+
export function SkillRuleSummary({ items, label = "On this page" }: {
|
|
57
|
+
items: ReadonlyArray<{ key: string; href: string; count: number; label: ReactNode; alert?: boolean }>; label?: string;
|
|
58
|
+
}) {
|
|
59
|
+
return (
|
|
60
|
+
<nav className="ui-rulebook__sum" aria-label={label}>
|
|
61
|
+
{items.map((i) => <a key={i.key} href={i.href} className={i.alert ? "is-open" : undefined}><strong>{i.count}</strong> {i.label}</a>)}
|
|
62
|
+
</nav>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** One section of the book: a heading (with an action beside it, such as "Source file"), a lead, the body, an optional note. */
|
|
67
|
+
export function SkillRuleSection({ id, title, action, lead, note, children }: {
|
|
68
|
+
id: string; title: ReactNode; action?: ReactNode; lead?: ReactNode; note?: ReactNode; children?: ReactNode;
|
|
69
|
+
}) {
|
|
70
|
+
return (
|
|
71
|
+
<section id={id} className="ui-rulebook__sec" aria-labelledby={`${id}-h`}>
|
|
72
|
+
<div className="ui-rulebook__head"><h2 id={`${id}-h`}>{title}</h2>{action}</div>
|
|
73
|
+
{lead ? <p className="ui-rulebook__lead">{lead}</p> : null}
|
|
74
|
+
{children}
|
|
75
|
+
{note ? <p className="ui-rulebook__note">{note}</p> : null}
|
|
76
|
+
</section>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A chip naming what holds a rule: a machine check, a judge, or a plain word. With `href` it jumps there. */
|
|
81
|
+
export function SkillRuleChip({ tone = "plain", href, children }: { tone?: "machine" | "judge" | "plain"; href?: string; children: ReactNode }) {
|
|
82
|
+
const className = cx("ui-rulebook__chip", tone !== "plain" && `is-${tone}`);
|
|
83
|
+
return href ? <a className={className} href={href}>{children}</a> : <span className={className}>{children}</span>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** What breaking a rule does: Blocks, Warns, Blocks or warns, or a plain word ("Prompt only"). */
|
|
87
|
+
export function SkillRuleLevel({ tone, children }: { tone: "block" | "warn" | "both" | "plain"; children: ReactNode }) {
|
|
88
|
+
return <span className={`ui-rulebook__lvl is-${tone}`}>{children}</span>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface SkillGuardGroup {
|
|
92
|
+
key: string;
|
|
93
|
+
/** The card's anchor (a check's chip links to it). */
|
|
94
|
+
id?: string;
|
|
95
|
+
/** "G1", "C", a pack's letter. Left out (or null): no chip. */
|
|
96
|
+
code?: ReactNode;
|
|
97
|
+
name: ReactNode;
|
|
98
|
+
/** A second name, smaller. */
|
|
99
|
+
title?: ReactNode;
|
|
100
|
+
items: ReadonlyArray<{ key: string; text: ReactNode; by?: ReactNode }>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The hard rules, a card per group: each rule with the chips of what holds it. */
|
|
104
|
+
export function SkillGuardGroups({ groups }: { groups: readonly SkillGuardGroup[] }) {
|
|
105
|
+
return (
|
|
106
|
+
<div className="ui-rulebook__guards">
|
|
107
|
+
{groups.map((g) => (
|
|
108
|
+
<article key={g.key} id={g.id} className="ui-rulebook__guard">
|
|
109
|
+
<h3>{g.code != null && g.code !== "" ? <span className="ui-rulebook__code">{g.code}</span> : null}{g.name}{g.title ? <small>{g.title}</small> : null}</h3>
|
|
110
|
+
<ul>
|
|
111
|
+
{g.items.map((it) => (
|
|
112
|
+
<li key={it.key}>
|
|
113
|
+
<span>{it.text}</span>
|
|
114
|
+
{it.by ? <span className="ui-rulebook__by">{it.by}</span> : null}
|
|
115
|
+
</li>
|
|
116
|
+
))}
|
|
117
|
+
</ul>
|
|
118
|
+
</article>
|
|
119
|
+
))}
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface SkillCheckRow { key: string; id?: string; check: ReactNode; rule: ReactNode; level: ReactNode; skills: ReactNode }
|
|
125
|
+
|
|
126
|
+
/** The checks, one row each: what is counted, the rule, what breaking it does, which skills set their own numbers. `wide`: the
|
|
127
|
+
* column that holds the long text (content-radar: the rule's words; GemBoss: the check's sentence, its rule a short code). */
|
|
128
|
+
export function SkillCheckTable({ rows, label = "Checks", wide = "rule", headers = { check: "Check", rule: "Rule", level: "Level", skills: "Skills with their own numbers" } }: {
|
|
129
|
+
rows: readonly SkillCheckRow[]; label?: string; wide?: "check" | "rule"; headers?: { check: ReactNode; rule: ReactNode; level: ReactNode; skills: ReactNode };
|
|
130
|
+
}) {
|
|
131
|
+
return (
|
|
132
|
+
<div className={wide === "check" ? "ui-rulebook__table is-wide-check" : "ui-rulebook__table"} role="table" aria-label={label}>
|
|
133
|
+
<div role="row" className="is-head">
|
|
134
|
+
<span role="columnheader">{headers.check}</span><span role="columnheader">{headers.rule}</span>
|
|
135
|
+
<span role="columnheader">{headers.level}</span><span role="columnheader">{headers.skills}</span>
|
|
136
|
+
</div>
|
|
137
|
+
{rows.map((r) => (
|
|
138
|
+
<div role="row" key={r.key} id={r.id}>
|
|
139
|
+
<span role="cell">{r.check}</span><span role="cell">{r.rule}</span><span role="cell">{r.level}</span><span role="cell">{r.skills}</span>
|
|
140
|
+
</div>
|
|
141
|
+
))}
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ── Building blocks ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
147
|
+
|
|
148
|
+
export interface SkillLayer {
|
|
149
|
+
key: string;
|
|
150
|
+
label: ReactNode;
|
|
151
|
+
/** One line: what this layer is for. */
|
|
152
|
+
what?: ReactNode;
|
|
153
|
+
docs: ReadonlyArray<{ key: string; title: ReactNode; href: string; sections?: readonly string[]; aside?: ReactNode }>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The layers of shared files, a card each, every file a link (with its sections, or who reads it, under it). */
|
|
157
|
+
export function SkillLayerList({ layers, renderLink = plainLink }: { layers: readonly SkillLayer[]; renderLink?: SkillLinkRender }) {
|
|
158
|
+
return (
|
|
159
|
+
<div className="ui-skilllayers">
|
|
160
|
+
{layers.map((l) => (
|
|
161
|
+
<article key={l.key} className="ui-skilllayers__layer">
|
|
162
|
+
<h3>{l.label}</h3>
|
|
163
|
+
{l.what ? <p className="ui-skilllayers__what">{l.what}</p> : null}
|
|
164
|
+
<ul>
|
|
165
|
+
{l.docs.map((d) => (
|
|
166
|
+
<li key={d.key}>
|
|
167
|
+
{renderLink({ href: d.href, children: <strong>{d.title}</strong> })}
|
|
168
|
+
{d.sections?.length ? <span className="ui-skilllayers__secs">{d.sections.join(" · ")}</span> : null}
|
|
169
|
+
{d.aside ? <span className="ui-skilllayers__secs">{d.aside}</span> : null}
|
|
170
|
+
</li>
|
|
171
|
+
))}
|
|
172
|
+
</ul>
|
|
173
|
+
</article>
|
|
174
|
+
))}
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** The files of one page, as pills that jump to each. */
|
|
180
|
+
export function SkillDocJump({ items, label = "Sections" }: { items: ReadonlyArray<{ key: string; href: string; label: ReactNode }>; label?: string }) {
|
|
181
|
+
if (items.length < 2) return null;
|
|
182
|
+
return <nav className="ui-skilldoc__jump" aria-label={label}>{items.map((i) => <a key={i.key} href={i.href}>{i.label}</a>)}</nav>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** One shared file: its text (the surface renders the Markdown), then its history. */
|
|
186
|
+
export function SkillDoc({ id, children, history, meta }: { id?: string; children: ReactNode; history?: ReactNode; meta?: ReactNode }) {
|
|
187
|
+
return (
|
|
188
|
+
<section id={id} className="ui-skilldoc">
|
|
189
|
+
{meta ? <p className="ui-skilldoc__meta">{meta}</p> : null}
|
|
190
|
+
<div className="ui-skilldoc__md">{children}</div>
|
|
191
|
+
{history}
|
|
192
|
+
</section>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** A file's versions, folded: `summary` is the line ("History · voices/founder.md"), `onOpen` loads them the first time it opens. */
|
|
197
|
+
export function SkillDocHistory({ summary, onOpen, children }: { summary: ReactNode; onOpen?: () => void; children?: ReactNode }) {
|
|
198
|
+
return (
|
|
199
|
+
<details className="ui-skilldoc__hist" onToggle={onOpen ? (e) => { if (e.currentTarget.open) onOpen(); } : undefined}>
|
|
200
|
+
<summary>{summary}</summary>
|
|
201
|
+
{children}
|
|
202
|
+
</details>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/**
|
|
3
|
+
* SkillsTabGroup: one group of SkillsTabs (07/11/2026, review of the kit's Skills pages). A <details>, so it opens from the keyboard
|
|
4
|
+
* and with no script at all, as content-radar's tab groups do; with the script it also closes as the kit's Menu does: on Escape (focus
|
|
5
|
+
* back on its summary), on a press outside it, and once one of its links is chosen. Its own client file, so SkillsTabs stays a
|
|
6
|
+
* server component; a surface whose tabs have no group (GemBoss admin) mounts none. A mounted group listens at the document all the
|
|
7
|
+
* time and each handler returns at once while it is closed. Listening only while open (from the toggle event) was tried and lost
|
|
8
|
+
* Escape: closed by a press outside and reopened within one turn, Chrome fires one toggle, the close, after it is open again.
|
|
9
|
+
*/
|
|
10
|
+
import "./skill-pages.css";
|
|
11
|
+
import React, { useEffect, useRef, type ReactNode } from "react";
|
|
12
|
+
|
|
13
|
+
export function SkillsTabGroup({ summary, current, children }: { summary: ReactNode; current: boolean; children: ReactNode }) {
|
|
14
|
+
const ref = useRef<HTMLDetailsElement>(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const d = ref.current;
|
|
17
|
+
if (!d) return;
|
|
18
|
+
const close = (focusSummary: boolean) => {
|
|
19
|
+
if (!d.open) return;
|
|
20
|
+
d.open = false;
|
|
21
|
+
if (focusSummary) d.querySelector("summary")?.focus();
|
|
22
|
+
};
|
|
23
|
+
const onDown = (e: PointerEvent) => { if (!d.contains(e.target as Node)) close(false); };
|
|
24
|
+
const onKey = (e: KeyboardEvent) => {
|
|
25
|
+
if (e.key !== "Escape" || !d.open) return;
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
close(d.contains(document.activeElement));
|
|
28
|
+
};
|
|
29
|
+
const onClick = (e: MouseEvent) => { if ((e.target as Element | null)?.closest?.("a")) close(false); };
|
|
30
|
+
document.addEventListener("pointerdown", onDown);
|
|
31
|
+
document.addEventListener("keydown", onKey);
|
|
32
|
+
d.addEventListener("click", onClick);
|
|
33
|
+
return () => {
|
|
34
|
+
document.removeEventListener("pointerdown", onDown);
|
|
35
|
+
document.removeEventListener("keydown", onKey);
|
|
36
|
+
d.removeEventListener("click", onClick);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
return (
|
|
40
|
+
<details ref={ref} className="ui-skillstabs__group">
|
|
41
|
+
<summary aria-current={current ? "page" : undefined}>{summary}</summary>
|
|
42
|
+
<div className="ui-skillstabs__menu gemboss-popover-surface">{children}</div>
|
|
43
|
+
</details>
|
|
44
|
+
);
|
|
45
|
+
}
|
package/src/skill-view.tsx
CHANGED
|
@@ -214,6 +214,12 @@ const HOLD_CLASS: Record<SkillRuleHold, string> = {
|
|
|
214
214
|
declared: "ui-skillview__hold ui-skillview__hold--declared",
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
+
/** How a rule is held, as a chip: a filled dot when the system checks it, an accent dot when it is put on the page from the start,
|
|
218
|
+
* an empty ring when it is only declared. The one owner of that look: SkillRuleList and the Rules book (skill-pages.tsx) draw it. */
|
|
219
|
+
export function SkillRuleHoldChip({ hold, children }: { hold: SkillRuleHold; children: ReactNode }) {
|
|
220
|
+
return <span className={HOLD_CLASS[hold] ?? HOLD_CLASS.declared}><i aria-hidden="true" />{children}</span>;
|
|
221
|
+
}
|
|
222
|
+
|
|
217
223
|
/** A skill's rules, one row each: the code, the rule, one line, and how it is held as a chip (a filled dot when the system checks
|
|
218
224
|
* it, an empty ring when it is only declared). */
|
|
219
225
|
export function SkillRuleList({ rules, className }: { rules: readonly SkillRule[]; className?: string }) {
|
|
@@ -227,7 +233,7 @@ export function SkillRuleList({ rules, className }: { rules: readonly SkillRule[
|
|
|
227
233
|
<b className="ui-skillview__ruletitle">{r.title}</b>
|
|
228
234
|
{r.line ? <span className="ui-skillview__ruleline">{r.line}</span> : null}
|
|
229
235
|
</span>
|
|
230
|
-
<
|
|
236
|
+
<SkillRuleHoldChip hold={r.hold}>{r.holdLabel}</SkillRuleHoldChip>
|
|
231
237
|
</li>
|
|
232
238
|
))}
|
|
233
239
|
</ul>
|