@crowandraven/evalkeeper 0.18.0 → 0.19.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/decisions.js +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/drafts.d.ts +2 -0
- package/dist/drafts.js +1 -1
- package/dist/drafts.js.map +1 -1
- package/dist/glossary.d.ts +25 -14
- package/dist/glossary.js +25 -14
- package/dist/glossary.js.map +1 -1
- package/dist/health.js +2 -2
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memoryStore.d.ts +2 -1
- package/dist/memoryStore.js +9 -0
- package/dist/memoryStore.js.map +1 -1
- package/dist/next/actions.js +58 -3
- package/dist/next/actions.js.map +1 -1
- package/dist/prisma/contracts.d.ts +5 -2
- package/dist/prisma/contracts.js +7 -1
- package/dist/prisma/contracts.js.map +1 -1
- package/dist/prisma/index.d.ts +40 -1
- package/dist/prisma/index.js +37 -1
- package/dist/prisma/index.js.map +1 -1
- package/dist/prune.d.ts +5 -2
- package/dist/prune.js +7 -4
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.js +11 -5
- package/dist/react/AddCase.js.map +1 -1
- package/dist/react/AnswerKey.js +7 -4
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/CaseMenu.d.ts +2 -2
- package/dist/react/CaseMenu.js +10 -31
- package/dist/react/CaseMenu.js.map +1 -1
- package/dist/react/CompareView.js +3 -3
- package/dist/react/CompareView.js.map +1 -1
- package/dist/react/ConfirmAnswer.js +1 -1
- package/dist/react/ConfirmAnswer.js.map +1 -1
- package/dist/react/Drawer.d.ts +32 -0
- package/dist/react/Drawer.js +60 -0
- package/dist/react/Drawer.js.map +1 -0
- package/dist/react/HubSections.d.ts +31 -18
- package/dist/react/HubSections.js +104 -103
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/Menu.d.ts +37 -0
- package/dist/react/Menu.js +51 -0
- package/dist/react/Menu.js.map +1 -0
- package/dist/react/ModelMenu.d.ts +1 -1
- package/dist/react/ModelMenu.js +8 -32
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/RunView.js +24 -4
- package/dist/react/RunView.js.map +1 -1
- package/dist/react/Spending.d.ts +25 -0
- package/dist/react/Spending.js +51 -0
- package/dist/react/Spending.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +25 -6
- package/dist/react/SuiteSections.js +233 -75
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/app.d.ts +18 -0
- package/dist/react/app.js.map +1 -1
- package/dist/react/format.d.ts +13 -0
- package/dist/react/format.js +13 -0
- package/dist/react/format.js.map +1 -1
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/pieces.d.ts +21 -8
- package/dist/react/pieces.js +44 -14
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.d.ts +15 -1
- package/dist/runner.js +89 -13
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +18 -0
- package/dist/settings.js.map +1 -1
- package/dist/spending.d.ts +100 -0
- package/dist/spending.js +133 -0
- package/dist/spending.js.map +1 -0
- package/dist/stats.d.ts +3 -1
- package/dist/stats.js +6 -2
- package/dist/stats.js.map +1 -1
- package/dist/store.d.ts +5 -0
- package/dist/suggest.js +17 -12
- package/dist/suggest.js.map +1 -1
- package/dist/suiteSettings.d.ts +78 -0
- package/dist/suiteSettings.js +142 -0
- package/dist/suiteSettings.js.map +1 -0
- package/dist/suites/crisisRisk.js +3 -3
- package/dist/suites/crisisRisk.js.map +1 -1
- package/dist/suites/hopelessness.js +6 -6
- package/dist/suites/hopelessness.js.map +1 -1
- package/dist/suites/injection.js +2 -2
- package/dist/suites/injection.js.map +1 -1
- package/dist/summary.d.ts +41 -4
- package/dist/summary.js +46 -8
- package/dist/summary.js.map +1 -1
- package/dist/testing.d.ts +19 -0
- package/dist/testing.js +61 -0
- package/dist/testing.js.map +1 -1
- package/dist/todo.d.ts +146 -0
- package/dist/todo.js +198 -0
- package/dist/todo.js.map +1 -0
- package/dist/types.d.ts +40 -7
- package/dist/types.js +28 -4
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/schema/evalkeeper.prisma +13 -0
- package/src/decisions.ts +1 -1
- package/src/drafts.ts +3 -1
- package/src/glossary.ts +35 -14
- package/src/health.ts +3 -2
- package/src/index.ts +3 -0
- package/src/memoryStore.ts +15 -1
- package/src/next/actions.ts +67 -2
- package/src/prisma/contracts.ts +16 -1
- package/src/prisma/index.ts +68 -1
- package/src/prune.ts +7 -2
- package/src/react/AddCase.tsx +13 -11
- package/src/react/AnswerKey.tsx +17 -5
- package/src/react/CaseMenu.tsx +23 -77
- package/src/react/CompareView.tsx +4 -10
- package/src/react/ConfirmAnswer.tsx +1 -1
- package/src/react/Drawer.tsx +130 -0
- package/src/react/HubSections.tsx +180 -414
- package/src/react/Menu.tsx +155 -0
- package/src/react/ModelMenu.tsx +23 -74
- package/src/react/RunView.tsx +46 -3
- package/src/react/Spending.tsx +200 -0
- package/src/react/SuiteSections.tsx +579 -175
- package/src/react/app.ts +18 -0
- package/src/react/format.ts +15 -0
- package/src/react/index.ts +3 -0
- package/src/react/pieces.tsx +57 -18
- package/src/runner.ts +122 -12
- package/src/settings.ts +20 -0
- package/src/spending.ts +209 -0
- package/src/stats.ts +8 -2
- package/src/store.ts +5 -0
- package/src/suggest.ts +21 -14
- package/src/suiteSettings.ts +201 -0
- package/src/suites/crisisRisk.ts +3 -3
- package/src/suites/hopelessness.ts +6 -6
- package/src/suites/injection.ts +2 -2
- package/src/summary.ts +59 -8
- package/src/testing.ts +77 -0
- package/src/todo.ts +318 -0
- package/src/types.ts +57 -9
- package/starter/index.ts +7 -0
- package/templates/lib/evalkeeper/actions.ts +20 -0
package/src/react/AnswerKey.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
EXPERT_REVIEWED,
|
|
20
20
|
FROM_BASE_CASE,
|
|
21
21
|
isShippedReview,
|
|
22
|
+
replacedStarters,
|
|
22
23
|
} from "../index.js";
|
|
23
24
|
import { Check, ChevronRight, CircleAlert, Eye, X } from "lucide-react";
|
|
24
25
|
import type { EvalAppConfig } from "./app.js";
|
|
@@ -108,6 +109,11 @@ export async function AnswerKey({
|
|
|
108
109
|
byCase.set(o.caseId, list);
|
|
109
110
|
}
|
|
110
111
|
const fields = suite.fields;
|
|
112
|
+
// Starters a starter update replaced: marked, so nobody retires the
|
|
113
|
+
// current ones by mistake.
|
|
114
|
+
const replaced = new Set(
|
|
115
|
+
readOnly ? [] : replacedStarters(suite, cases).map((c) => c.id),
|
|
116
|
+
);
|
|
111
117
|
|
|
112
118
|
return (
|
|
113
119
|
<div className="space-y-4">
|
|
@@ -243,6 +249,7 @@ export async function AnswerKey({
|
|
|
243
249
|
suite={suite}
|
|
244
250
|
c={c}
|
|
245
251
|
results={byCase.get(c.id) ?? []}
|
|
252
|
+
replaced={replaced.has(c.id)}
|
|
246
253
|
/>
|
|
247
254
|
))}
|
|
248
255
|
{!cases.length && <p className="text-sm text-muted">No cases yet.</p>}
|
|
@@ -257,11 +264,14 @@ function CaseItem({
|
|
|
257
264
|
suite,
|
|
258
265
|
c,
|
|
259
266
|
results,
|
|
267
|
+
replaced = false,
|
|
260
268
|
}: {
|
|
261
269
|
app: EvalAppConfig;
|
|
262
270
|
readOnly: boolean;
|
|
263
271
|
suite: AnySuite;
|
|
264
272
|
c: CaseRecord;
|
|
273
|
+
/** A starter a starter update replaced (`replacedStarters`). */
|
|
274
|
+
replaced?: boolean;
|
|
265
275
|
results: {
|
|
266
276
|
model: string;
|
|
267
277
|
output: { scores: unknown; error: string | null; output?: unknown };
|
|
@@ -393,7 +403,7 @@ function CaseItem({
|
|
|
393
403
|
>
|
|
394
404
|
{/* The chips keep their place on the right; a long title wraps
|
|
395
405
|
beside them (below them only on a phone). */}
|
|
396
|
-
<summary className="flex cursor-pointer list-none flex-wrap items-start justify-between gap-2 p-3 text-sm sm:flex-nowrap">
|
|
406
|
+
<summary className="flex cursor-pointer list-none flex-wrap [&::-webkit-details-marker]:hidden items-start justify-between gap-2 p-3 text-sm sm:flex-nowrap">
|
|
397
407
|
<span className="flex min-w-0 flex-1 items-start pt-0.5 font-medium">
|
|
398
408
|
<ChevronRight
|
|
399
409
|
aria-hidden
|
|
@@ -408,14 +418,16 @@ function CaseItem({
|
|
|
408
418
|
confirmed={CONFIRMED_STATUS}
|
|
409
419
|
id={`status-${c.id}`}
|
|
410
420
|
/>
|
|
421
|
+
{replaced && (
|
|
422
|
+
<Tip term="replacedStarter" id={`replaced-${c.id}`} align="end">
|
|
423
|
+
<Chip tone="warn">No longer a starter</Chip>
|
|
424
|
+
</Tip>
|
|
425
|
+
)}
|
|
411
426
|
{shipped && (
|
|
412
|
-
<Tip term={shipped.term} id={`reviewed-${c.id}`}>
|
|
427
|
+
<Tip term={shipped.term} id={`reviewed-${c.id}`} align="end">
|
|
413
428
|
<Chip tone="neutral">{shipped.text}</Chip>
|
|
414
429
|
</Tip>
|
|
415
430
|
)}
|
|
416
|
-
<Tip term={c.split === "TEST" ? "test" : "dev"} id={`split-${c.id}`}>
|
|
417
|
-
<Chip tone="neutral">{c.split === "TEST" ? "Test" : "Dev"}</Chip>
|
|
418
|
-
</Tip>
|
|
419
431
|
{results.length > 0 && (
|
|
420
432
|
<Tip
|
|
421
433
|
text={`Right on ${right} of ${results.length} models' latest tests.`}
|
package/src/react/CaseMenu.tsx
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
import { QUIET_BUTTON } from "./format.js";
|
|
4
4
|
|
|
5
5
|
import { Button } from "./pieces.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { Menu, MenuButton, MenuForm } from "./Menu.js";
|
|
8
|
+
import { CloseButton } from "./InfoPopover.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A case's menu, in the top right of the open case: edit its answer (the
|
|
11
|
-
* form opens below the menu's row) and retire it.
|
|
12
|
-
*
|
|
12
|
+
* form opens below the menu's row) and retire it. The eval pages' one
|
|
13
|
+
* `Menu`.
|
|
13
14
|
*/
|
|
14
15
|
export function CaseMenu({
|
|
15
16
|
suite,
|
|
@@ -36,79 +37,28 @@ export function CaseMenu({
|
|
|
36
37
|
*/
|
|
37
38
|
review?: React.ReactNode;
|
|
38
39
|
}) {
|
|
39
|
-
const [open, setOpen] = useState(false);
|
|
40
40
|
const [editing, setEditing] = useState(startEditing);
|
|
41
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (!open) return;
|
|
45
|
-
const close = (e: MouseEvent | KeyboardEvent) => {
|
|
46
|
-
if (
|
|
47
|
-
e instanceof KeyboardEvent
|
|
48
|
-
? e.key === "Escape"
|
|
49
|
-
: !ref.current?.contains(e.target as Node)
|
|
50
|
-
)
|
|
51
|
-
setOpen(false);
|
|
52
|
-
};
|
|
53
|
-
document.addEventListener("mousedown", close);
|
|
54
|
-
document.addEventListener("keydown", close);
|
|
55
|
-
return () => {
|
|
56
|
-
document.removeEventListener("mousedown", close);
|
|
57
|
-
document.removeEventListener("keydown", close);
|
|
58
|
-
};
|
|
59
|
-
}, [open]);
|
|
60
|
-
|
|
61
|
-
const item =
|
|
62
|
-
"block w-full rounded px-3 py-1.5 text-left text-sm hover:bg-tint";
|
|
63
41
|
|
|
64
42
|
return (
|
|
65
43
|
<>
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
className="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted hover:bg-tint hover:text-ink"
|
|
77
|
-
>
|
|
78
|
-
<EllipsisVertical aria-hidden className="h-4 w-4" />
|
|
79
|
-
</Button>
|
|
80
|
-
{open && (
|
|
81
|
-
<div
|
|
82
|
-
role="menu"
|
|
83
|
-
className="absolute right-0 mt-1 w-44 rounded-md border border-line bg-card p-1 shadow-lg"
|
|
44
|
+
<Menu
|
|
45
|
+
label="Case actions"
|
|
46
|
+
width="w-44"
|
|
47
|
+
className="absolute right-3 top-0 z-10"
|
|
48
|
+
>
|
|
49
|
+
{editLabel && (
|
|
50
|
+
<MenuButton
|
|
51
|
+
onSelect={() => {
|
|
52
|
+
setEditing(true);
|
|
53
|
+
}}
|
|
84
54
|
>
|
|
85
|
-
{editLabel
|
|
86
|
-
|
|
87
|
-
type="button"
|
|
88
|
-
role="menuitem"
|
|
89
|
-
className={item}
|
|
90
|
-
onClick={() => {
|
|
91
|
-
setEditing(true);
|
|
92
|
-
setOpen(false);
|
|
93
|
-
}}
|
|
94
|
-
>
|
|
95
|
-
{editLabel}
|
|
96
|
-
</Button>
|
|
97
|
-
)}
|
|
98
|
-
<form action={retire}>
|
|
99
|
-
<input type="hidden" name="suite" value={suite} />
|
|
100
|
-
<input type="hidden" name="case" value={caseId} />
|
|
101
|
-
<Button
|
|
102
|
-
type="submit"
|
|
103
|
-
role="menuitem"
|
|
104
|
-
className={`${item} text-bad`}
|
|
105
|
-
>
|
|
106
|
-
Retire case
|
|
107
|
-
</Button>
|
|
108
|
-
</form>
|
|
109
|
-
</div>
|
|
55
|
+
{editLabel}
|
|
56
|
+
</MenuButton>
|
|
110
57
|
)}
|
|
111
|
-
|
|
58
|
+
<MenuForm action={retire} fields={{ suite, case: caseId }} danger>
|
|
59
|
+
Retire case
|
|
60
|
+
</MenuForm>
|
|
61
|
+
</Menu>
|
|
112
62
|
{review && !editing && (
|
|
113
63
|
<div className="flex flex-wrap items-center gap-2">
|
|
114
64
|
{review}
|
|
@@ -129,15 +79,11 @@ export function CaseMenu({
|
|
|
129
79
|
<div className="space-y-3 rounded-md bg-tint p-3">
|
|
130
80
|
<div className="flex items-center justify-between gap-2">
|
|
131
81
|
<h4 className="text-sm font-medium">{editLabel}</h4>
|
|
132
|
-
<
|
|
133
|
-
type="button"
|
|
82
|
+
<CloseButton
|
|
134
83
|
onClick={() => {
|
|
135
84
|
setEditing(false);
|
|
136
85
|
}}
|
|
137
|
-
|
|
138
|
-
>
|
|
139
|
-
Cancel
|
|
140
|
-
</Button>
|
|
86
|
+
/>
|
|
141
87
|
</div>
|
|
142
88
|
{edit}
|
|
143
89
|
</div>
|
|
@@ -3,7 +3,7 @@ import { evalsPath, type EvalAppConfig } from "./app.js";
|
|
|
3
3
|
import {
|
|
4
4
|
BackLink,
|
|
5
5
|
Card,
|
|
6
|
-
|
|
6
|
+
SeverityChip,
|
|
7
7
|
InfoTip,
|
|
8
8
|
Link,
|
|
9
9
|
Tip,
|
|
@@ -177,8 +177,8 @@ export async function CompareView({
|
|
|
177
177
|
</Tip>
|
|
178
178
|
</th>
|
|
179
179
|
<th className="p-3 font-normal">
|
|
180
|
-
<Tip term="
|
|
181
|
-
|
|
180
|
+
<Tip term="aim" side="bottom" align="end">
|
|
181
|
+
Aim
|
|
182
182
|
</Tip>
|
|
183
183
|
</th>
|
|
184
184
|
</tr>
|
|
@@ -199,13 +199,7 @@ export async function CompareView({
|
|
|
199
199
|
id={`severity-${c.key}`}
|
|
200
200
|
side="bottom"
|
|
201
201
|
>
|
|
202
|
-
<
|
|
203
|
-
tone={
|
|
204
|
-
c.severity === "serious" ? "serious" : "neutral"
|
|
205
|
-
}
|
|
206
|
-
>
|
|
207
|
-
{c.severity}
|
|
208
|
-
</Chip>
|
|
202
|
+
<SeverityChip severity={c.severity} />
|
|
209
203
|
</Tip>
|
|
210
204
|
</span>
|
|
211
205
|
</td>
|
|
@@ -53,7 +53,7 @@ export function CaseStatusChip({
|
|
|
53
53
|
}) {
|
|
54
54
|
const now = useConfirmedHere(labelId ?? "") && labelId ? confirmed : status;
|
|
55
55
|
return (
|
|
56
|
-
<Tip term={now.term} id={id}>
|
|
56
|
+
<Tip term={now.term} id={id} align="end">
|
|
57
57
|
<Chip tone={now.tone}>{now.text}</Chip>
|
|
58
58
|
</Tip>
|
|
59
59
|
);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
4
|
+
import { CloseButton } from "./InfoPopover.js";
|
|
5
|
+
import { Menu, MenuButton } from "./Menu.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A panel that slides in from the right over the page, for a form that
|
|
9
|
+
* belongs to the whole page (Suite settings, Spending and daily limits):
|
|
10
|
+
* one form, one primary Save. Closes with its X, Escape, or a click on
|
|
11
|
+
* the page behind it, and returns focus to what opened it.
|
|
12
|
+
*/
|
|
13
|
+
export function Drawer({
|
|
14
|
+
title,
|
|
15
|
+
open,
|
|
16
|
+
onClose,
|
|
17
|
+
children,
|
|
18
|
+
}: {
|
|
19
|
+
/** The drawer's heading, and its accessible name. */
|
|
20
|
+
title: string;
|
|
21
|
+
open: boolean;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}) {
|
|
25
|
+
const panel = useRef<HTMLDivElement>(null);
|
|
26
|
+
// The latest onClose, so a parent's new function each render doesn't
|
|
27
|
+
// move focus back to the panel.
|
|
28
|
+
const close = useRef(onClose);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
close.current = onClose;
|
|
31
|
+
});
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!open) return;
|
|
34
|
+
const back =
|
|
35
|
+
document.activeElement instanceof HTMLElement
|
|
36
|
+
? document.activeElement
|
|
37
|
+
: null;
|
|
38
|
+
panel.current?.focus();
|
|
39
|
+
const onKey = (e: KeyboardEvent) => {
|
|
40
|
+
if (e.key === "Escape") close.current();
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("keydown", onKey);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener("keydown", onKey);
|
|
45
|
+
back?.focus();
|
|
46
|
+
};
|
|
47
|
+
}, [open]);
|
|
48
|
+
if (!open) return null;
|
|
49
|
+
return (
|
|
50
|
+
<div className="fixed inset-0 z-40">
|
|
51
|
+
<div
|
|
52
|
+
aria-hidden
|
|
53
|
+
className="absolute inset-0 bg-ink/30"
|
|
54
|
+
onClick={onClose}
|
|
55
|
+
/>
|
|
56
|
+
<div
|
|
57
|
+
ref={panel}
|
|
58
|
+
role="dialog"
|
|
59
|
+
aria-modal="true"
|
|
60
|
+
aria-label={title}
|
|
61
|
+
tabIndex={-1}
|
|
62
|
+
// Saved: the page shows the new values, so the drawer goes.
|
|
63
|
+
onSubmit={() =>
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
close.current();
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
className="absolute inset-y-0 right-0 flex w-full max-w-md flex-col overflow-y-auto border-l border-line bg-card shadow-xl focus:outline-none"
|
|
69
|
+
>
|
|
70
|
+
<div className="flex items-start justify-between gap-3 p-4 pb-0">
|
|
71
|
+
<h2 className="text-lg font-semibold">{title}</h2>
|
|
72
|
+
<CloseButton onClick={onClose} />
|
|
73
|
+
</div>
|
|
74
|
+
<div className="space-y-4 p-4 text-sm">{children}</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** One entry in a page's menu: its words, and the drawer it opens. */
|
|
81
|
+
export type PageMenuEntry = {
|
|
82
|
+
/** A stable name, for the drawer's state. */
|
|
83
|
+
key: string;
|
|
84
|
+
/** The menu item's words, and the drawer's title. */
|
|
85
|
+
label: string;
|
|
86
|
+
/** What the drawer holds: a form, usually. */
|
|
87
|
+
body: ReactNode;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The menu beside a page's title: each entry opens its own drawer.
|
|
92
|
+
* Renders nothing without entries.
|
|
93
|
+
*/
|
|
94
|
+
export function PageMenu({
|
|
95
|
+
label,
|
|
96
|
+
entries,
|
|
97
|
+
}: {
|
|
98
|
+
/** The menu button's accessible name. */
|
|
99
|
+
label: string;
|
|
100
|
+
entries: readonly PageMenuEntry[];
|
|
101
|
+
}) {
|
|
102
|
+
const [open, setOpen] = useState<string | null>(null);
|
|
103
|
+
if (!entries.length) return null;
|
|
104
|
+
const shown = entries.find((e) => e.key === open);
|
|
105
|
+
return (
|
|
106
|
+
<>
|
|
107
|
+
<Menu label={label}>
|
|
108
|
+
{entries.map((e) => (
|
|
109
|
+
<MenuButton
|
|
110
|
+
key={e.key}
|
|
111
|
+
onSelect={() => {
|
|
112
|
+
setOpen(e.key);
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{e.label}
|
|
116
|
+
</MenuButton>
|
|
117
|
+
))}
|
|
118
|
+
</Menu>
|
|
119
|
+
<Drawer
|
|
120
|
+
title={shown?.label ?? ""}
|
|
121
|
+
open={shown !== undefined}
|
|
122
|
+
onClose={() => {
|
|
123
|
+
setOpen(null);
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
{shown?.body}
|
|
127
|
+
</Drawer>
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
}
|