@crowandraven/evalkeeper 0.14.0 → 0.16.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/dist/glossary.d.ts +1 -0
- package/dist/glossary.js +1 -0
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +24 -0
- package/dist/health.js +61 -7
- package/dist/health.js.map +1 -1
- package/dist/react/HubSections.d.ts +4 -1
- package/dist/react/HubSections.js +30 -12
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/InfoPopover.d.ts +19 -0
- package/dist/react/InfoPopover.js +46 -0
- package/dist/react/InfoPopover.js.map +1 -0
- package/dist/react/PriorityPicker.js +6 -20
- package/dist/react/PriorityPicker.js.map +1 -1
- package/dist/react/SettingsHistory.d.ts +2 -1
- package/dist/react/SettingsHistory.js +32 -24
- package/dist/react/SettingsHistory.js.map +1 -1
- package/dist/react/ShowEarlier.d.ts +11 -0
- package/dist/react/ShowEarlier.js +19 -0
- package/dist/react/ShowEarlier.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +6 -8
- package/dist/react/SuiteSections.js +45 -25
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/WeeklyCheck.js +2 -2
- package/dist/react/WeeklyCheck.js.map +1 -1
- package/dist/react/app.d.ts +3 -1
- package/dist/react/app.js.map +1 -1
- package/dist/react/pieces.d.ts +18 -1
- package/dist/react/pieces.js +29 -0
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.js +7 -1
- package/dist/runner.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.js.map +1 -1
- package/dist/weekly.js +4 -2
- package/dist/weekly.js.map +1 -1
- package/package.json +1 -1
- package/src/glossary.ts +2 -0
- package/src/health.ts +81 -9
- package/src/react/HubSections.tsx +124 -40
- package/src/react/InfoPopover.tsx +100 -0
- package/src/react/PriorityPicker.tsx +6 -27
- package/src/react/SettingsHistory.tsx +112 -74
- package/src/react/ShowEarlier.tsx +57 -0
- package/src/react/SuiteSections.tsx +146 -96
- package/src/react/WeeklyCheck.tsx +14 -3
- package/src/react/app.ts +3 -2
- package/src/react/pieces.tsx +37 -1
- package/src/runner.ts +7 -1
- package/src/types.ts +2 -1
- package/src/weekly.ts +7 -2
package/src/health.ts
CHANGED
|
@@ -18,6 +18,31 @@ import {
|
|
|
18
18
|
export type HealthStatus =
|
|
19
19
|
"untested" | "stale" | "few" | "improve" | "change" | "fair" | "good";
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Where a suite stands, in one of four words a card can be colored by:
|
|
23
|
+
* `risk` (a serious check is under its bar), `improve` (something would
|
|
24
|
+
* help: a minor check under its bar, a better model, a retest), `healthy`
|
|
25
|
+
* (meets every bar), or `unknown` (not tested, or too few cases to trust a
|
|
26
|
+
* score). The hub groups suites by it, at-risk first.
|
|
27
|
+
*/
|
|
28
|
+
export type HealthStanding = "risk" | "improve" | "healthy" | "unknown";
|
|
29
|
+
|
|
30
|
+
/** The order the hub shows standings in: what needs you first. */
|
|
31
|
+
export const STANDING_ORDER: readonly HealthStanding[] = [
|
|
32
|
+
"risk",
|
|
33
|
+
"improve",
|
|
34
|
+
"healthy",
|
|
35
|
+
"unknown",
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
/** What each standing is called on the hub. */
|
|
39
|
+
export const STANDING_LABEL: Readonly<Record<HealthStanding, string>> = {
|
|
40
|
+
risk: "At risk",
|
|
41
|
+
improve: "Can improve",
|
|
42
|
+
healthy: "Healthy",
|
|
43
|
+
unknown: "Can't tell yet",
|
|
44
|
+
};
|
|
45
|
+
|
|
21
46
|
/**
|
|
22
47
|
* One reason a suite stands where it does, for a chip on its card. A suite
|
|
23
48
|
* can have several: checks under their bar and a suggestion, say.
|
|
@@ -39,6 +64,13 @@ export type HealthFlag =
|
|
|
39
64
|
*/
|
|
40
65
|
export type Health = {
|
|
41
66
|
status: HealthStatus;
|
|
67
|
+
/** Which of the four groups the suite belongs in, for its color. */
|
|
68
|
+
standing: HealthStanding;
|
|
69
|
+
/**
|
|
70
|
+
* The live model's check furthest under its bar (serious first), to
|
|
71
|
+
* show how far off it is; null when every check meets its bar.
|
|
72
|
+
*/
|
|
73
|
+
worst: { label: string; rate: number; bar: number; serious: boolean } | null;
|
|
42
74
|
/** Each reason behind the status, most important first, for chips. */
|
|
43
75
|
flags: HealthFlag[];
|
|
44
76
|
title: string;
|
|
@@ -51,6 +83,27 @@ export type Health = {
|
|
|
51
83
|
|
|
52
84
|
const pct = (x: number) => `${Math.round(x * 100)}%`;
|
|
53
85
|
|
|
86
|
+
/**
|
|
87
|
+
* The standing for a status: a serious check under its bar is a risk even
|
|
88
|
+
* on few cases (a fuzzy score that low still deserves a look); otherwise
|
|
89
|
+
* too few cases means no one can tell yet.
|
|
90
|
+
*/
|
|
91
|
+
function standingOf(status: HealthStatus, serious: number): HealthStanding {
|
|
92
|
+
if (serious > 0) return "risk";
|
|
93
|
+
switch (status) {
|
|
94
|
+
case "untested":
|
|
95
|
+
case "few":
|
|
96
|
+
return "unknown";
|
|
97
|
+
case "stale":
|
|
98
|
+
case "improve":
|
|
99
|
+
case "change":
|
|
100
|
+
return "improve";
|
|
101
|
+
case "fair":
|
|
102
|
+
case "good":
|
|
103
|
+
return "healthy";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
54
107
|
/**
|
|
55
108
|
* Where a suite stands, for its card on the hub, from the same board and suggestion its
|
|
56
109
|
* page shows.
|
|
@@ -81,13 +134,14 @@ export function suiteHealth(
|
|
|
81
134
|
const t = liveRow?.test;
|
|
82
135
|
const live =
|
|
83
136
|
liveRow && t ? { label: liveRow.label, rate: t.right / t.total } : null;
|
|
84
|
-
const base = { live, testedModels };
|
|
137
|
+
const base = { live, testedModels, worst: null };
|
|
85
138
|
const fewer = cases < TARGET_CASES ? `${cases} of ${TARGET_CASES} cases` : "";
|
|
86
139
|
|
|
87
140
|
if (!t)
|
|
88
141
|
return {
|
|
89
142
|
...base,
|
|
90
143
|
status: "untested",
|
|
144
|
+
standing: "unknown",
|
|
91
145
|
flags: [{ kind: "untested" }],
|
|
92
146
|
title: "Not tested yet",
|
|
93
147
|
details: [
|
|
@@ -98,16 +152,13 @@ export function suiteHealth(
|
|
|
98
152
|
return {
|
|
99
153
|
...base,
|
|
100
154
|
status: "stale",
|
|
155
|
+
standing: "improve",
|
|
101
156
|
flags: [{ kind: "stale" }],
|
|
102
157
|
title: "Test again",
|
|
103
158
|
details: ["Cases, answers, or instructions changed since the last test."],
|
|
104
159
|
};
|
|
105
160
|
|
|
106
161
|
const details: string[] = [];
|
|
107
|
-
if (provisional)
|
|
108
|
-
details.push(
|
|
109
|
-
`${provisional} of ${cases} answers are provisional: review them before trusting these scores.`,
|
|
110
|
-
);
|
|
111
162
|
// Live checks under their bars, serious first.
|
|
112
163
|
const below = checks
|
|
113
164
|
.map((c) => ({ c, rate: t.byCheck[c.key]?.rate ?? null }))
|
|
@@ -139,9 +190,26 @@ export function suiteHealth(
|
|
|
139
190
|
);
|
|
140
191
|
if (testedModels < 2)
|
|
141
192
|
details.push("Only one model tested: test others to compare.");
|
|
193
|
+
// Last: a standing choice, not a problem, so it never leads.
|
|
194
|
+
if (provisional)
|
|
195
|
+
details.push(
|
|
196
|
+
`${provisional} of ${cases} answers are provisional: review them before trusting these scores.`,
|
|
197
|
+
);
|
|
142
198
|
|
|
143
199
|
const confidence = confidenceFor(cases, live?.rate ?? 0.5);
|
|
144
200
|
const serious = below.filter((x) => x.c.severity === "serious").length;
|
|
201
|
+
const w = below[0];
|
|
202
|
+
const scored = {
|
|
203
|
+
...base,
|
|
204
|
+
worst: w
|
|
205
|
+
? {
|
|
206
|
+
label: w.c.label,
|
|
207
|
+
rate: w.rate,
|
|
208
|
+
bar: checkBar(w.c),
|
|
209
|
+
serious: w.c.severity === "serious",
|
|
210
|
+
}
|
|
211
|
+
: null,
|
|
212
|
+
};
|
|
145
213
|
const flags: HealthFlag[] = [];
|
|
146
214
|
if (below.length)
|
|
147
215
|
flags.push({ kind: "below", serious, minor: below.length - serious });
|
|
@@ -159,8 +227,9 @@ export function suiteHealth(
|
|
|
159
227
|
flags.push({ kind: "addCases", cases, target: TARGET_CASES });
|
|
160
228
|
if (confidence.level === "too-few")
|
|
161
229
|
return {
|
|
162
|
-
...
|
|
230
|
+
...scored,
|
|
163
231
|
status: "few",
|
|
232
|
+
standing: standingOf("few", serious),
|
|
164
233
|
flags,
|
|
165
234
|
title: "Too few cases to trust",
|
|
166
235
|
details: [
|
|
@@ -172,8 +241,9 @@ export function suiteHealth(
|
|
|
172
241
|
// suggestion, even when the live model meets every bar.
|
|
173
242
|
if (below.length || change)
|
|
174
243
|
return {
|
|
175
|
-
...
|
|
244
|
+
...scored,
|
|
176
245
|
status: below.length ? "improve" : "change",
|
|
246
|
+
standing: standingOf(below.length ? "improve" : "change", serious),
|
|
177
247
|
flags,
|
|
178
248
|
title: below.length ? "Room to improve" : "Change suggested",
|
|
179
249
|
details: fewer
|
|
@@ -182,8 +252,9 @@ export function suiteHealth(
|
|
|
182
252
|
};
|
|
183
253
|
if (confidence.level === "rough")
|
|
184
254
|
return {
|
|
185
|
-
...
|
|
255
|
+
...scored,
|
|
186
256
|
status: "fair",
|
|
257
|
+
standing: "healthy",
|
|
187
258
|
flags,
|
|
188
259
|
title: "Good so far",
|
|
189
260
|
details: [
|
|
@@ -192,8 +263,9 @@ export function suiteHealth(
|
|
|
192
263
|
],
|
|
193
264
|
};
|
|
194
265
|
return {
|
|
195
|
-
...
|
|
266
|
+
...scored,
|
|
196
267
|
status: "good",
|
|
268
|
+
standing: "healthy",
|
|
197
269
|
flags: flags.length ? flags : [{ kind: "good" }],
|
|
198
270
|
title: "In good shape",
|
|
199
271
|
details: details.length ? details : ["Meets every bar on enough cases."],
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
perAnswer,
|
|
6
6
|
priorityOf,
|
|
7
7
|
seconds,
|
|
8
|
+
STANDING_LABEL,
|
|
9
|
+
STANDING_ORDER,
|
|
8
10
|
suiteHealth,
|
|
9
11
|
thumbsSummary,
|
|
10
12
|
type GlossaryTerm,
|
|
@@ -12,7 +14,14 @@ import {
|
|
|
12
14
|
type Settings,
|
|
13
15
|
type SettingsVersion,
|
|
14
16
|
} from "../index.js";
|
|
15
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
Link,
|
|
19
|
+
Card,
|
|
20
|
+
InfoTip,
|
|
21
|
+
LocalDate,
|
|
22
|
+
StandingBadge,
|
|
23
|
+
HealthReasons,
|
|
24
|
+
} from "./pieces.js";
|
|
16
25
|
import { pct } from "./format.js";
|
|
17
26
|
import { HistoryEntries } from "./SettingsHistory.js";
|
|
18
27
|
import {
|
|
@@ -152,45 +161,66 @@ export function HubStats({ data }: { data: HubData }) {
|
|
|
152
161
|
);
|
|
153
162
|
}
|
|
154
163
|
|
|
155
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* One card per feature, grouped by standing with what needs you first: at
|
|
166
|
+
* risk, can improve, healthy, and can't tell yet. An injection suite's results show on its base feature's card.
|
|
167
|
+
*/
|
|
156
168
|
export function SuiteList({ data }: { data: HubData }) {
|
|
157
169
|
const { app, histories, attacksOn, cards } = data;
|
|
170
|
+
const all = cards.map(({ b, i }) => {
|
|
171
|
+
const attacked = attacksOn(b.suite.key);
|
|
172
|
+
const [history, current] = histories[i] ?? [[], null];
|
|
173
|
+
const health = suiteHealth(
|
|
174
|
+
b.rows,
|
|
175
|
+
b.suite.checks,
|
|
176
|
+
priorityOf(b.suite, current?.settings),
|
|
177
|
+
b.cases,
|
|
178
|
+
b.provisional,
|
|
179
|
+
app.models,
|
|
180
|
+
{ attacks: attacksFrom(attacked) },
|
|
181
|
+
);
|
|
182
|
+
return { b, attacked, history, current, health };
|
|
183
|
+
});
|
|
184
|
+
const card = (c: (typeof all)[number]) => (
|
|
185
|
+
<SuiteCard
|
|
186
|
+
app={app}
|
|
187
|
+
key={c.b.suite.key}
|
|
188
|
+
board={c.b}
|
|
189
|
+
attacked={c.attacked}
|
|
190
|
+
health={c.health}
|
|
191
|
+
history={c.history}
|
|
192
|
+
current={c.current}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
158
195
|
return (
|
|
159
|
-
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
current={current}
|
|
188
|
-
/>
|
|
189
|
-
);
|
|
190
|
-
})}
|
|
191
|
-
</div>
|
|
192
|
-
</section>
|
|
193
|
-
</>
|
|
196
|
+
<section aria-labelledby="suites" className="space-y-3">
|
|
197
|
+
<h2 id="suites" className="text-lg font-semibold">
|
|
198
|
+
Suites
|
|
199
|
+
<InfoTip term="suites" />
|
|
200
|
+
</h2>
|
|
201
|
+
{cards.length === 0 && <NoSuites />}
|
|
202
|
+
{STANDING_ORDER.map((standing) => {
|
|
203
|
+
const group = all.filter((c) => c.health.standing === standing);
|
|
204
|
+
if (!group.length) return null;
|
|
205
|
+
const heading = (
|
|
206
|
+
<span className="flex items-center gap-2 text-sm text-muted">
|
|
207
|
+
<StandingBadge standing={standing} />
|
|
208
|
+
{group.length} {group.length === 1 ? "suite" : "suites"}
|
|
209
|
+
</span>
|
|
210
|
+
);
|
|
211
|
+
return (
|
|
212
|
+
<div
|
|
213
|
+
key={standing}
|
|
214
|
+
role="group"
|
|
215
|
+
aria-label={STANDING_LABEL[standing]}
|
|
216
|
+
className="space-y-3 pt-2"
|
|
217
|
+
>
|
|
218
|
+
{heading}
|
|
219
|
+
<div className="space-y-4">{group.map(card)}</div>
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
})}
|
|
223
|
+
</section>
|
|
194
224
|
);
|
|
195
225
|
}
|
|
196
226
|
|
|
@@ -259,6 +289,44 @@ function Stat({
|
|
|
259
289
|
|
|
260
290
|
type Board = Awaited<ReturnType<Runner["board"]>>;
|
|
261
291
|
|
|
292
|
+
/**
|
|
293
|
+
* The live model's check furthest under its bar, as a bar with a tick at
|
|
294
|
+
* the bar, so a card shows how far off it is, not only that it is.
|
|
295
|
+
*/
|
|
296
|
+
function WorstCheck({
|
|
297
|
+
worst: w,
|
|
298
|
+
}: {
|
|
299
|
+
worst: NonNullable<ReturnType<typeof suiteHealth>["worst"]>;
|
|
300
|
+
}) {
|
|
301
|
+
return (
|
|
302
|
+
<div className="flex flex-wrap items-center gap-3 text-sm text-muted">
|
|
303
|
+
<span>
|
|
304
|
+
{w.label}
|
|
305
|
+
{w.serious ? " (serious)" : ""}{" "}
|
|
306
|
+
<span
|
|
307
|
+
className={`font-semibold ${w.serious ? "text-bad" : "text-warn"}`}
|
|
308
|
+
>
|
|
309
|
+
{pct(w.rate)}
|
|
310
|
+
</span>
|
|
311
|
+
</span>
|
|
312
|
+
<span aria-hidden className="relative h-1.5 w-40 rounded-full bg-tint">
|
|
313
|
+
<span
|
|
314
|
+
className={`absolute inset-y-0 left-0 rounded-full ${w.serious ? "bg-bad" : "bg-warn"}`}
|
|
315
|
+
style={{ width: `${Math.round(w.rate * 100)}%` }}
|
|
316
|
+
/>
|
|
317
|
+
<span
|
|
318
|
+
className="absolute -inset-y-1 w-px bg-ink"
|
|
319
|
+
style={{ left: `${Math.round(w.bar * 100)}%` }}
|
|
320
|
+
/>
|
|
321
|
+
</span>
|
|
322
|
+
<span>
|
|
323
|
+
bar {pct(w.bar)}
|
|
324
|
+
<InfoTip term="bar" />
|
|
325
|
+
</span>
|
|
326
|
+
</div>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
262
330
|
/** Green at 95% and up, amber from 80%, red below. */
|
|
263
331
|
const scoreTone = (rate: number) =>
|
|
264
332
|
rate >= 0.95 ? "text-good" : rate >= 0.8 ? "text-warn" : "text-bad";
|
|
@@ -309,8 +377,10 @@ function SuiteCard({
|
|
|
309
377
|
{b.suite.label}
|
|
310
378
|
</Link>
|
|
311
379
|
</h2>
|
|
312
|
-
<
|
|
380
|
+
<StandingBadge standing={h.standing} />
|
|
381
|
+
<InfoTip term="standing" />
|
|
313
382
|
</div>
|
|
383
|
+
<HealthReasons flags={h.flags} />
|
|
314
384
|
<p className="readable text-sm text-muted">{b.suite.description}</p>
|
|
315
385
|
</div>
|
|
316
386
|
{t && (
|
|
@@ -362,6 +432,7 @@ function SuiteCard({
|
|
|
362
432
|
)}{" "}
|
|
363
433
|
· {b.cases} cases · {h.testedModels} models tested
|
|
364
434
|
</p>
|
|
435
|
+
{h.worst && <WorstCheck worst={h.worst} />}
|
|
365
436
|
</div>
|
|
366
437
|
|
|
367
438
|
{h.details.length > 0 && (
|
|
@@ -450,9 +521,22 @@ export function NoEvalYet({ data }: { data: HubData }) {
|
|
|
450
521
|
No eval yet
|
|
451
522
|
</h2>
|
|
452
523
|
<p className="readable text-sm text-muted">
|
|
453
|
-
{
|
|
454
|
-
|
|
524
|
+
Nothing tells you yet whether{" "}
|
|
525
|
+
{gaps.length === 1 ? "this feature" : "these features"} got worse.
|
|
455
526
|
</p>
|
|
527
|
+
{/* One slim card per feature, like the suites above. */}
|
|
528
|
+
<ul className="space-y-3">
|
|
529
|
+
{gaps.map((f) => (
|
|
530
|
+
<li key={f.operation}>
|
|
531
|
+
<Card className="space-y-1 py-3">
|
|
532
|
+
<p className="font-semibold">{f.label}</p>
|
|
533
|
+
{f.description && (
|
|
534
|
+
<p className="readable text-sm text-muted">{f.description}</p>
|
|
535
|
+
)}
|
|
536
|
+
</Card>
|
|
537
|
+
</li>
|
|
538
|
+
))}
|
|
539
|
+
</ul>
|
|
456
540
|
</section>
|
|
457
541
|
);
|
|
458
542
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState, type RefObject } from "react";
|
|
4
|
+
import { Info, X } from "lucide-react";
|
|
5
|
+
import { Button } from "./pieces.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Closes a popup on Escape or a click outside `ref`, while it's open.
|
|
9
|
+
*/
|
|
10
|
+
export function useDismiss(
|
|
11
|
+
open: boolean,
|
|
12
|
+
setOpen: (open: boolean) => void,
|
|
13
|
+
ref: RefObject<HTMLElement | null>,
|
|
14
|
+
) {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!open) return;
|
|
17
|
+
const onEvent = (e: MouseEvent | KeyboardEvent) => {
|
|
18
|
+
if (
|
|
19
|
+
e instanceof KeyboardEvent
|
|
20
|
+
? e.key === "Escape"
|
|
21
|
+
: !ref.current?.contains(e.target as Node)
|
|
22
|
+
)
|
|
23
|
+
setOpen(false);
|
|
24
|
+
};
|
|
25
|
+
document.addEventListener("mousedown", onEvent);
|
|
26
|
+
document.addEventListener("keydown", onEvent);
|
|
27
|
+
return () => {
|
|
28
|
+
document.removeEventListener("mousedown", onEvent);
|
|
29
|
+
document.removeEventListener("keydown", onEvent);
|
|
30
|
+
};
|
|
31
|
+
}, [open, setOpen, ref]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The X that closes a popup. */
|
|
35
|
+
export function CloseButton({ onClick }: { onClick: () => void }) {
|
|
36
|
+
return (
|
|
37
|
+
<Button
|
|
38
|
+
type="button"
|
|
39
|
+
aria-label="Close"
|
|
40
|
+
title="Close"
|
|
41
|
+
onClick={onClick}
|
|
42
|
+
className="-mr-1 -mt-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
|
|
43
|
+
>
|
|
44
|
+
<X aria-hidden className="h-4 w-4" />
|
|
45
|
+
</Button>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* An info button that opens more than a tooltip holds: a list, steps, a
|
|
51
|
+
* guide. Opens on press, closes with its X, Escape, or a click outside.
|
|
52
|
+
* For a sentence or two, use InfoTip.
|
|
53
|
+
*/
|
|
54
|
+
export function InfoPopover({
|
|
55
|
+
label,
|
|
56
|
+
children,
|
|
57
|
+
}: {
|
|
58
|
+
/** What the popup is, for screen readers: "About the answer key". */
|
|
59
|
+
label: string;
|
|
60
|
+
children: React.ReactNode;
|
|
61
|
+
}) {
|
|
62
|
+
const [open, setOpen] = useState(false);
|
|
63
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
64
|
+
useDismiss(open, setOpen, ref);
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
ref={ref}
|
|
68
|
+
className="relative ml-1 inline-flex align-middle text-sm font-normal"
|
|
69
|
+
>
|
|
70
|
+
<Button
|
|
71
|
+
type="button"
|
|
72
|
+
aria-haspopup="dialog"
|
|
73
|
+
aria-expanded={open}
|
|
74
|
+
aria-label={label}
|
|
75
|
+
onClick={() => {
|
|
76
|
+
setOpen(!open);
|
|
77
|
+
}}
|
|
78
|
+
className="inline-flex h-4 w-4 items-center justify-center rounded-full text-muted hover:text-ink"
|
|
79
|
+
>
|
|
80
|
+
<Info aria-hidden className="h-3.5 w-3.5" />
|
|
81
|
+
</Button>
|
|
82
|
+
{open && (
|
|
83
|
+
<div
|
|
84
|
+
role="dialog"
|
|
85
|
+
aria-label={label}
|
|
86
|
+
className="absolute left-0 top-full z-20 mt-2 max-h-[70vh] w-[min(28rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-line bg-card p-4 shadow-lg"
|
|
87
|
+
>
|
|
88
|
+
<div className="flex items-start gap-3">
|
|
89
|
+
<div className="min-w-0 flex-1 space-y-3">{children}</div>
|
|
90
|
+
<CloseButton
|
|
91
|
+
onClick={() => {
|
|
92
|
+
setOpen(false);
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { ChevronDown
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { CloseButton, useDismiss } from "./InfoPopover.js";
|
|
5
6
|
import { Button, Select, Submit, TextInput } from "./pieces.js";
|
|
6
7
|
import type { FormAction } from "./app.js";
|
|
7
8
|
import type { SuitePriority } from "../types.js";
|
|
@@ -42,23 +43,7 @@ export function PriorityPicker({
|
|
|
42
43
|
const [open, setOpen] = useState(false);
|
|
43
44
|
const ref = useRef<HTMLDivElement>(null);
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
if (!open) return;
|
|
47
|
-
const close = (e: MouseEvent | KeyboardEvent) => {
|
|
48
|
-
if (
|
|
49
|
-
e instanceof KeyboardEvent
|
|
50
|
-
? e.key === "Escape"
|
|
51
|
-
: !ref.current?.contains(e.target as Node)
|
|
52
|
-
)
|
|
53
|
-
setOpen(false);
|
|
54
|
-
};
|
|
55
|
-
document.addEventListener("mousedown", close);
|
|
56
|
-
document.addEventListener("keydown", close);
|
|
57
|
-
return () => {
|
|
58
|
-
document.removeEventListener("mousedown", close);
|
|
59
|
-
document.removeEventListener("keydown", close);
|
|
60
|
-
};
|
|
61
|
-
}, [open]);
|
|
46
|
+
useDismiss(open, setOpen, ref);
|
|
62
47
|
|
|
63
48
|
return (
|
|
64
49
|
<div ref={ref} className="relative text-sm font-normal">
|
|
@@ -82,17 +67,11 @@ export function PriorityPicker({
|
|
|
82
67
|
>
|
|
83
68
|
<div className="flex items-start justify-between gap-3">
|
|
84
69
|
<p className="text-muted">{why}</p>
|
|
85
|
-
<
|
|
86
|
-
type="button"
|
|
87
|
-
aria-label="Close"
|
|
88
|
-
title="Close"
|
|
70
|
+
<CloseButton
|
|
89
71
|
onClick={() => {
|
|
90
72
|
setOpen(false);
|
|
91
73
|
}}
|
|
92
|
-
|
|
93
|
-
>
|
|
94
|
-
<X aria-hidden className="h-4 w-4" />
|
|
95
|
-
</Button>
|
|
74
|
+
/>
|
|
96
75
|
</div>
|
|
97
76
|
<form
|
|
98
77
|
action={action}
|