@astra-spec/ui 0.0.5 → 0.0.7
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 +47 -4
- package/blocks.css +1 -0
- package/components.css +6 -0
- package/dist/blocks/analysis-tree.d.ts.map +1 -1
- package/dist/blocks/analysis-tree.js +4 -7
- package/dist/blocks/analysis-tree.js.map +1 -1
- package/dist/blocks/decisions-list.d.ts.map +1 -1
- package/dist/blocks/decisions-list.js +1 -1
- package/dist/blocks/decisions-list.js.map +1 -1
- package/dist/blocks/findings-list.d.ts.map +1 -1
- package/dist/blocks/findings-list.js +2 -4
- package/dist/blocks/findings-list.js.map +1 -1
- package/dist/blocks/index.d.ts +2 -4
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +1 -2
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/outputs-list.d.ts +2 -7
- package/dist/blocks/outputs-list.d.ts.map +1 -1
- package/dist/blocks/outputs-list.js +11 -21
- package/dist/blocks/outputs-list.js.map +1 -1
- package/dist/blocks/papers-list.d.ts.map +1 -1
- package/dist/blocks/papers-list.js +3 -3
- package/dist/blocks/papers-list.js.map +1 -1
- package/dist/components/figure-zoom.d.ts +6 -0
- package/dist/components/figure-zoom.d.ts.map +1 -0
- package/dist/components/figure-zoom.js +28 -0
- package/dist/components/figure-zoom.js.map +1 -0
- package/dist/components/finding-detail.d.ts +4 -2
- package/dist/components/finding-detail.d.ts.map +1 -1
- package/dist/components/finding-detail.js +41 -25
- package/dist/components/finding-detail.js.map +1 -1
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/insight-trigger.js +2 -2
- package/dist/components/insight-trigger.js.map +1 -1
- package/dist/components/output-card.d.ts +13 -0
- package/dist/components/output-card.d.ts.map +1 -0
- package/dist/components/output-card.js +12 -0
- package/dist/components/output-card.js.map +1 -0
- package/dist/components/output-detail.d.ts +6 -2
- package/dist/components/output-detail.d.ts.map +1 -1
- package/dist/components/output-detail.js +49 -13
- package/dist/components/output-detail.js.map +1 -1
- package/dist/components/output-dialog.d.ts +6 -1
- package/dist/components/output-dialog.d.ts.map +1 -1
- package/dist/components/output-dialog.js +2 -2
- package/dist/components/output-dialog.js.map +1 -1
- package/dist/components/output-entry.d.ts +17 -0
- package/dist/components/output-entry.d.ts.map +1 -0
- package/dist/components/output-entry.js +21 -0
- package/dist/components/output-entry.js.map +1 -0
- package/dist/components/output-provenance.d.ts +6 -0
- package/dist/components/output-provenance.d.ts.map +1 -0
- package/dist/components/output-provenance.js +16 -0
- package/dist/components/output-provenance.js.map +1 -0
- package/dist/components/output-status.d.ts +8 -0
- package/dist/components/output-status.d.ts.map +1 -0
- package/dist/components/output-status.js +17 -0
- package/dist/components/output-status.js.map +1 -0
- package/dist/components/paper-detail.d.ts.map +1 -1
- package/dist/components/paper-detail.js +11 -15
- package/dist/components/paper-detail.js.map +1 -1
- package/dist/components/paper-row.d.ts +9 -0
- package/dist/components/paper-row.d.ts.map +1 -0
- package/dist/components/paper-row.js +11 -0
- package/dist/components/paper-row.js.map +1 -0
- package/dist/components/record-dialog.d.ts +5 -1
- package/dist/components/record-dialog.d.ts.map +1 -1
- package/dist/components/record-dialog.js +7 -4
- package/dist/components/record-dialog.js.map +1 -1
- package/dist/lib/labels.d.ts +34 -2
- package/dist/lib/labels.d.ts.map +1 -1
- package/dist/lib/labels.js +35 -4
- package/dist/lib/labels.js.map +1 -1
- package/dist/model/index.d.ts +4 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/kind.d.ts +1 -1
- package/dist/model/kind.d.ts.map +1 -1
- package/dist/model/kind.js +0 -1
- package/dist/model/kind.js.map +1 -1
- package/dist/model/output-provenance.d.ts +17 -0
- package/dist/model/output-provenance.d.ts.map +1 -0
- package/dist/model/output-provenance.js +2 -0
- package/dist/model/output-provenance.js.map +1 -0
- package/dist/model/output-status.d.ts +17 -0
- package/dist/model/output-status.d.ts.map +1 -0
- package/dist/model/output-status.js +2 -0
- package/dist/model/output-status.js.map +1 -0
- package/dist/model/relations.d.ts +37 -12
- package/dist/model/relations.d.ts.map +1 -1
- package/dist/model/relations.js +76 -23
- package/dist/model/relations.js.map +1 -1
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +9 -1
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/output-status-glyph.d.ts +8 -0
- package/dist/primitives/output-status-glyph.d.ts.map +1 -0
- package/dist/primitives/output-status-glyph.js +13 -0
- package/dist/primitives/output-status-glyph.js.map +1 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.d.ts.map +1 -0
- package/dist/primitives/tooltip.js +31 -0
- package/dist/primitives/tooltip.js.map +1 -0
- package/dist/views/inventory.d.ts +12 -1
- package/dist/views/inventory.d.ts.map +1 -1
- package/dist/views/inventory.js +23 -17
- package/dist/views/inventory.js.map +1 -1
- package/package.json +3 -2
- package/primitives.css +1 -0
- package/src/blocks/analysis-tree.tsx +4 -30
- package/src/blocks/decisions-list.tsx +5 -3
- package/src/blocks/findings-list.tsx +8 -7
- package/src/blocks/index.ts +2 -4
- package/src/blocks/outputs-list.tsx +43 -106
- package/src/blocks/papers-list.tsx +2 -18
- package/src/components/figure-zoom.tsx +72 -0
- package/src/components/finding-detail.tsx +106 -30
- package/src/components/index.ts +13 -0
- package/src/components/insight-trigger.tsx +2 -2
- package/src/components/output-card.tsx +51 -0
- package/src/components/output-detail.tsx +69 -21
- package/src/components/output-dialog.tsx +9 -0
- package/src/components/output-entry.tsx +61 -0
- package/src/components/output-provenance.tsx +86 -0
- package/src/components/output-status.tsx +38 -0
- package/src/components/paper-detail.tsx +52 -54
- package/src/components/paper-row.tsx +41 -0
- package/src/components/record-dialog.tsx +13 -1
- package/src/lib/labels.tsx +69 -6
- package/src/model/index.ts +6 -2
- package/src/model/kind.ts +1 -2
- package/src/model/output-provenance.ts +18 -0
- package/src/model/output-status.ts +18 -0
- package/src/model/relations.ts +92 -26
- package/src/primitives/dialog.tsx +7 -1
- package/src/primitives/index.ts +2 -0
- package/src/primitives/output-status-glyph.tsx +37 -0
- package/src/primitives/tooltip.tsx +51 -0
- package/src/views/inventory.tsx +54 -22
- package/styles/base.css +2 -1
- package/styles/blocks/analysis-tree.css +22 -25
- package/styles/blocks/findings-list.css +50 -0
- package/styles/blocks/outputs-list.css +0 -421
- package/styles/blocks/papers-list.css +4 -70
- package/styles/components/evidence.css +1 -18
- package/styles/components/figure-zoom.css +62 -0
- package/styles/components/finding-detail.css +62 -0
- package/styles/components/insight-list.css +0 -4
- package/styles/components/insight-trigger.css +8 -6
- package/styles/components/output-card.css +290 -0
- package/styles/components/output-detail.css +91 -3
- package/styles/components/output-entry.css +141 -0
- package/styles/components/output-provenance.css +94 -0
- package/styles/components/output-status.css +31 -0
- package/styles/components/paper-detail.css +112 -59
- package/styles/components/paper-row.css +72 -0
- package/styles/primitives/dialog.css +4 -22
- package/styles/primitives/tooltip.css +22 -0
- package/styles/views/inventory.css +35 -2
- package/dist/blocks/prior-insights-list.d.ts +0 -9
- package/dist/blocks/prior-insights-list.d.ts.map +0 -1
- package/dist/blocks/prior-insights-list.js +0 -29
- package/dist/blocks/prior-insights-list.js.map +0 -1
- package/src/blocks/prior-insights-list.tsx +0 -52
package/dist/views/inventory.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { indexAnalysis, } from '@astra-spec/sdk';
|
|
3
|
-
import { forwardRef, useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { collectInventoryPapers, findPaper, paperForDoi } from '../model/papers.js';
|
|
5
5
|
import { locateRecord } from '../model/locate-record.js';
|
|
6
6
|
import { cn } from '../lib/cn.js';
|
|
@@ -9,14 +9,14 @@ import { RecordDialog } from '../components/record-dialog.js';
|
|
|
9
9
|
import { useDetailStack } from '../lib/detail-stack.js';
|
|
10
10
|
import { DialogProvider } from '../primitives/dialog.js';
|
|
11
11
|
import { DecisionsList } from '../blocks/decisions-list.js';
|
|
12
|
+
import { AnalysisTree } from '../blocks/analysis-tree.js';
|
|
12
13
|
import { FindingsList } from '../blocks/findings-list.js';
|
|
13
14
|
import { InputsList } from '../blocks/inputs-list.js';
|
|
14
15
|
import { OutputsList } from '../blocks/outputs-list.js';
|
|
15
16
|
import { PapersList } from '../blocks/papers-list.js';
|
|
16
|
-
import { PriorInsightsList } from '../blocks/prior-insights-list.js';
|
|
17
17
|
import { InventoryOutline, InventorySection } from '../blocks/section.js';
|
|
18
18
|
import { sectionKind } from '../model/kind.js';
|
|
19
|
-
export const DEFAULT_SECTIONS = ['outputs', 'decisions', 'inputs', 'findings', '
|
|
19
|
+
export const DEFAULT_SECTIONS = ['outputs', 'decisions', 'inputs', 'findings', 'papers'];
|
|
20
20
|
const EMPTY_PAPER_METADATA = {};
|
|
21
21
|
function entryLabel(entry, papers) {
|
|
22
22
|
return entry.kind === 'paper'
|
|
@@ -31,10 +31,20 @@ function entryLabel(entry, papers) {
|
|
|
31
31
|
export const Inventory = forwardRef(function Inventory({ labels, ...props }, ref) {
|
|
32
32
|
return (_jsx(LabelsProvider, { labels: labels, children: _jsx(ExplorerBody, { ...props, ref: ref }) }));
|
|
33
33
|
});
|
|
34
|
-
const ExplorerBody = forwardRef(function ExplorerBody({ document, index: providedIndex, analysisPath
|
|
34
|
+
const ExplorerBody = forwardRef(function ExplorerBody({ document, index: providedIndex, analysisPath, onSelectAnalysis, sections = DEFAULT_SECTIONS, idPrefix = '', showOutline = true, showHierarchy = true, renderArtifact, renderProvenance, getOutputStatus, renderCodeLink, renderText, loadPdfJs, onOpenPaperFile, onOpenArtifact, paperMetadata = EMPTY_PAPER_METADATA, onFetchPaper, decisionTagLabels = {}, detailMode = 'modal', detail, defaultDetail, onDetailChange, className, children, ...rest }, ref) {
|
|
35
35
|
const labels = useLabels();
|
|
36
36
|
const index = useMemo(() => providedIndex ?? indexAnalysis(document), [document, providedIndex]);
|
|
37
|
-
const
|
|
37
|
+
const [internalAnalysisPath, setInternalAnalysisPath] = useState('$');
|
|
38
|
+
// Reset a removed selection so reintroducing that path does not navigate back.
|
|
39
|
+
if (analysisPath === undefined && internalAnalysisPath !== '$' && !index.analysisByPath.has(internalAnalysisPath)) {
|
|
40
|
+
setInternalAnalysisPath('$');
|
|
41
|
+
}
|
|
42
|
+
const analysis = index.analysisByPath.get(analysisPath ?? internalAnalysisPath) ?? document.analysis;
|
|
43
|
+
const selectAnalysis = (path) => {
|
|
44
|
+
if (analysisPath === undefined)
|
|
45
|
+
setInternalAnalysisPath(path);
|
|
46
|
+
onSelectAnalysis?.(path);
|
|
47
|
+
};
|
|
38
48
|
const papers = useMemo(() => collectInventoryPapers(document, index, analysis, paperMetadata), [analysis, document, index, paperMetadata]);
|
|
39
49
|
const stack = useDetailStack({ value: detail, defaultValue: defaultDetail, onChange: onDetailChange });
|
|
40
50
|
// Switching analysis closes any open detail (uncontrolled stacks only), and
|
|
@@ -68,7 +78,7 @@ const ExplorerBody = forwardRef(function ExplorerBody({ document, index: provide
|
|
|
68
78
|
const sectionContent = {
|
|
69
79
|
outputs: {
|
|
70
80
|
count: analysis.outputs.length,
|
|
71
|
-
content: _jsx(OutputsList, { analysis: analysis, renderArtifact: renderArtifact, onOpenRecord: openRecord }),
|
|
81
|
+
content: _jsx(OutputsList, { analysis: analysis, getOutputStatus: getOutputStatus, renderArtifact: renderArtifact, onOpenRecord: openRecord }),
|
|
72
82
|
},
|
|
73
83
|
decisions: {
|
|
74
84
|
count: analysis.decisions.length,
|
|
@@ -82,21 +92,17 @@ const ExplorerBody = forwardRef(function ExplorerBody({ document, index: provide
|
|
|
82
92
|
count: analysis.findings.length,
|
|
83
93
|
content: _jsx(FindingsList, { analysis: analysis, onOpenRecord: openRecord }),
|
|
84
94
|
},
|
|
85
|
-
prior_insights: {
|
|
86
|
-
count: analysis.prior_insights.length,
|
|
87
|
-
content: _jsx(PriorInsightsList, { analysis: analysis, onOpenRecord: openRecord }),
|
|
88
|
-
},
|
|
89
95
|
papers: {
|
|
90
96
|
count: papers.length,
|
|
91
97
|
content: (_jsx(PapersList, { papers: papers, analysis: analysis, onOpenPaper: (paper, owner) => { stack.openPaper(paper.doi, owner); } })),
|
|
92
98
|
},
|
|
93
99
|
};
|
|
94
|
-
const anchorId = (section) => `${idPrefix}${section
|
|
95
|
-
return (_jsxs("div", { "data-slot": "inventory", ...rest, ref: ref, className: cn('astra-inventory', className), children: [_jsxs("div", { className: "astra-inventory__layout", children: [_jsxs("div", { className: "astra-inventory__sections", children: [sections.map((section) => (_jsx(InventorySection, { id: anchorId(section), section: section, title: labels.sections[section], count: sectionContent[section].count, countLabel: labels.sectionCount(section, sectionContent[section].count), children: sectionContent[section].content }, section))), children] }), showOutline ? (_jsx(InventoryOutline, { entries: sections.map((section) => ({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
const anchorId = (section) => `${idPrefix}${section}`;
|
|
101
|
+
return (_jsxs("div", { "data-slot": "inventory", ...rest, ref: ref, className: cn('astra-inventory', className), children: [_jsxs("div", { className: "astra-inventory__layout", "data-sidebar": showOutline || showHierarchy ? '' : undefined, children: [_jsxs("div", { className: "astra-inventory__sections", children: [sections.map((section) => (_jsx(InventorySection, { id: anchorId(section), section: section, title: labels.sections[section], count: sectionContent[section].count, countLabel: labels.sectionCount(section, sectionContent[section].count), children: sectionContent[section].content }, section))), children] }), showOutline || showHierarchy ? (_jsxs("div", { className: "astra-inventory__sidebar", "data-has-tree": showHierarchy ? '' : undefined, children: [showOutline ? _jsx(InventoryOutline, { entries: sections.map((section) => ({
|
|
102
|
+
id: anchorId(section),
|
|
103
|
+
label: labels.sections[section],
|
|
104
|
+
count: sectionContent[section].count,
|
|
105
|
+
kind: sectionKind(section),
|
|
106
|
+
})) }) : null, showHierarchy ? (_jsx(AnalysisTree, { document: document, analysisPath: analysis.canonicalPath, onSelectAnalysis: selectAnalysis })) : null] })) : null] }), stack.active ? (_jsx(DialogProvider, { mode: detailMode, backText: stack.previous ? entryLabel(stack.previous, papers) : undefined, children: _jsx(RecordDialog, { entry: stack.active, fallback: _jsx("p", { children: labels.notFound }), document: document, index: index, papers: papers, paperMetadata: paperMetadata, renderArtifact: renderArtifact, renderProvenance: renderProvenance, renderCodeLink: renderCodeLink, renderText: renderText, loadPdfJs: loadPdfJs, onOpenPaperFile: onOpenPaperFile, onOpenArtifact: onOpenArtifact, onFetchPaper: onFetchPaper, onOpenRecord: stack.pushRecord, onOpenPaper: stack.pushPaper, onBack: stack.previous ? stack.back : undefined, onClose: stack.close }) })) : null] }));
|
|
101
107
|
});
|
|
102
108
|
//# sourceMappingURL=inventory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../src/views/inventory.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,GAMd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAuC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../src/views/inventory.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,GAMd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAuC,MAAM,OAAO,CAAC;AAC9G,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,WAAW,EAAuD,MAAM,oBAAo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AAC,MAAM,EACnB,QAAQ,EAAE,sBAAI,MAAM,CAAC,QAAQ,GAAK,EAClC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,KAAK,CAAC,UAAU,EAC9B,WAAW,EAAE,KAAK,CAAC,SAAS,EAC5B,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC/C,OAAO,EAAE,KAAK,CAAC,KAAK,GACpB,GACa,CAClB,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astra-spec/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "React components for rendering resolved ASTRA analyses",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"homepage": "https://github.com/LightconeResearch/astra-ui#readme",
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
],
|
|
136
136
|
"dependencies": {
|
|
137
137
|
"@floating-ui/react": "^0.27.20",
|
|
138
|
-
"katex": "^0.16.47"
|
|
138
|
+
"katex": "^0.16.47",
|
|
139
|
+
"react-zoom-pan-pinch": "^4.2.0"
|
|
139
140
|
}
|
|
140
141
|
}
|
package/primitives.css
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
@import "./styles/primitives/badge.css";
|
|
8
8
|
@import "./styles/primitives/button.css";
|
|
9
9
|
@import "./styles/primitives/preview-popover.css";
|
|
10
|
+
@import "./styles/primitives/tooltip.css";
|
|
10
11
|
@import "./styles/primitives/dialog.css";
|
|
11
12
|
@import "./styles/primitives/detail-layout.css";
|
|
12
13
|
@import "./styles/primitives/relation-list.css";
|
|
@@ -13,49 +13,25 @@ export interface AnalysisTreeProps extends Omit<HTMLAttributes<HTMLElement>, 'ch
|
|
|
13
13
|
showHeading?: boolean | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function ProjectDocumentIcon() {
|
|
17
|
-
return (
|
|
18
|
-
<svg
|
|
19
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
20
|
-
fill="none"
|
|
21
|
-
viewBox="0 0 24 24"
|
|
22
|
-
strokeWidth={1.5}
|
|
23
|
-
stroke="currentColor"
|
|
24
|
-
aria-hidden="true"
|
|
25
|
-
width="1.25rem"
|
|
26
|
-
height="1.25rem"
|
|
27
|
-
>
|
|
28
|
-
<path
|
|
29
|
-
strokeLinecap="round"
|
|
30
|
-
strokeLinejoin="round"
|
|
31
|
-
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25M9 16.5v.75m3-3v3M15 12v5.25m-4.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"
|
|
32
|
-
/>
|
|
33
|
-
</svg>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
16
|
function AnalysisNode({
|
|
38
17
|
analysis,
|
|
39
18
|
selectedPath,
|
|
40
|
-
depth,
|
|
41
19
|
onSelectAnalysis,
|
|
42
20
|
}: {
|
|
43
21
|
analysis: ResolvedAnalysisNode;
|
|
44
22
|
selectedPath: string;
|
|
45
|
-
depth: number;
|
|
46
23
|
onSelectAnalysis: (canonicalPath: string) => void;
|
|
47
24
|
}) {
|
|
48
|
-
const
|
|
25
|
+
const title = analysisTitle(analysis);
|
|
49
26
|
return (
|
|
50
27
|
<li>
|
|
51
28
|
<button
|
|
52
29
|
type="button"
|
|
53
|
-
|
|
54
|
-
aria-current={
|
|
30
|
+
className="astra-analysis-tree__select"
|
|
31
|
+
aria-current={analysis.canonicalPath === selectedPath ? 'page' : undefined}
|
|
55
32
|
onClick={() => { onSelectAnalysis(analysis.canonicalPath); }}
|
|
56
33
|
>
|
|
57
|
-
<
|
|
58
|
-
<span>{analysisTitle(analysis)}</span>
|
|
34
|
+
<span>{title}</span>
|
|
59
35
|
</button>
|
|
60
36
|
{analysis.analyses.length ? (
|
|
61
37
|
<ul>
|
|
@@ -64,7 +40,6 @@ function AnalysisNode({
|
|
|
64
40
|
key={child.canonicalPath}
|
|
65
41
|
analysis={child}
|
|
66
42
|
selectedPath={selectedPath}
|
|
67
|
-
depth={depth + 1}
|
|
68
43
|
onSelectAnalysis={onSelectAnalysis}
|
|
69
44
|
/>
|
|
70
45
|
))}
|
|
@@ -100,7 +75,6 @@ export const AnalysisTree = forwardRef<HTMLElement, AnalysisTreeProps>(function
|
|
|
100
75
|
<AnalysisNode
|
|
101
76
|
analysis={document.analysis}
|
|
102
77
|
selectedPath={analysisPath}
|
|
103
|
-
depth={0}
|
|
104
78
|
onSelectAnalysis={onSelectAnalysis}
|
|
105
79
|
/>
|
|
106
80
|
</ul>
|
|
@@ -96,9 +96,11 @@ export const DecisionsList = forwardRef<HTMLDivElement, DecisionsListProps>(func
|
|
|
96
96
|
cells: [
|
|
97
97
|
<RecordIdentity kind="decision" title={recordTitle(record)} />,
|
|
98
98
|
<span className="astra-record-list__selected">{selectedOptionLabel(record)}</span>,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
record.tags?.[0] ? (
|
|
100
|
+
<span className="astra-record-list__tag">
|
|
101
|
+
{decisionTagLabel(record.tags[0], tagLabels)}
|
|
102
|
+
</span>
|
|
103
|
+
) : null,
|
|
102
104
|
<span aria-hidden="true">→</span>,
|
|
103
105
|
],
|
|
104
106
|
}))}
|
|
@@ -31,10 +31,9 @@ export const FindingsList = forwardRef<HTMLDivElement, FindingsListProps>(functi
|
|
|
31
31
|
<InventoryRecords {...props} ref={ref} kind="finding" className={className}>
|
|
32
32
|
<RecordList
|
|
33
33
|
label={labels.sections.findings}
|
|
34
|
-
columnTemplate="minmax(
|
|
34
|
+
columnTemplate="minmax(0, 1fr) 1.5rem"
|
|
35
35
|
columns={[
|
|
36
36
|
{ label: 'Finding', className: 'astra-record-list__primary' },
|
|
37
|
-
{ label: 'Evidence', className: 'astra-record-list__count astra-record-list__secondary' },
|
|
38
37
|
{ className: 'astra-record-list__arrow' },
|
|
39
38
|
]}
|
|
40
39
|
rows={records.map((record) => {
|
|
@@ -44,14 +43,16 @@ export const FindingsList = forwardRef<HTMLDivElement, FindingsListProps>(functi
|
|
|
44
43
|
accessibleLabel: `${recordTitle(record)}: ${record.claim} ${evidenceLabel(count)}`,
|
|
45
44
|
onOpen: () => { onOpenRecord(record, analysis); },
|
|
46
45
|
cells: [
|
|
47
|
-
<span className="astra-record-list__name
|
|
46
|
+
<span className="astra-record-list__name astra-findings-list__entry">
|
|
48
47
|
<KindGlyph className="astra-record-list__glyph" kind="finding" />
|
|
49
|
-
<span>
|
|
50
|
-
|
|
51
|
-
<
|
|
48
|
+
<span className="astra-findings-list__copy">
|
|
49
|
+
<span className="astra-findings-list__claim">{record.claim}</span>
|
|
50
|
+
<span className="astra-findings-list__meta">
|
|
51
|
+
<span className="astra-findings-list__name">{recordTitle(record)}</span>
|
|
52
|
+
<span className="astra-record-list__count">{evidenceLabel(count)}</span>
|
|
53
|
+
</span>
|
|
52
54
|
</span>
|
|
53
55
|
</span>,
|
|
54
|
-
<span>{evidenceLabel(count)}</span>,
|
|
55
56
|
<span aria-hidden="true">→</span>,
|
|
56
57
|
],
|
|
57
58
|
};
|
package/src/blocks/index.ts
CHANGED
|
@@ -8,15 +8,13 @@ export type {
|
|
|
8
8
|
InventoryRecordsProps,
|
|
9
9
|
InventorySectionProps,
|
|
10
10
|
} from './section.js';
|
|
11
|
-
export {
|
|
12
|
-
export type {
|
|
11
|
+
export { OutputsList } from './outputs-list.js';
|
|
12
|
+
export type { OutputsListProps } from './outputs-list.js';
|
|
13
13
|
export { ALL_TAGS, DecisionsList } from './decisions-list.js';
|
|
14
14
|
export type { DecisionsListProps } from './decisions-list.js';
|
|
15
15
|
export { InputsList } from './inputs-list.js';
|
|
16
16
|
export type { InputsListProps } from './inputs-list.js';
|
|
17
17
|
export { FindingsList } from './findings-list.js';
|
|
18
18
|
export type { FindingsListProps } from './findings-list.js';
|
|
19
|
-
export { PriorInsightsList } from './prior-insights-list.js';
|
|
20
|
-
export type { PriorInsightsListProps } from './prior-insights-list.js';
|
|
21
19
|
export { PaperRows, PapersList } from './papers-list.js';
|
|
22
20
|
export type { PaperRowsProps, PapersListProps } from './papers-list.js';
|
|
@@ -1,98 +1,38 @@
|
|
|
1
1
|
import type { ResolvedAnalysisNode, ResolvedOutput } from '@astra-spec/sdk';
|
|
2
2
|
import { forwardRef, useId, type HTMLAttributes } from 'react';
|
|
3
|
-
import { recordTitle } from '../model/records.js';
|
|
4
3
|
import { cn } from '../lib/cn.js';
|
|
5
4
|
import { useLabels } from '../lib/labels.js';
|
|
5
|
+
import type { OutputStatusLookup } from '../model/output-status.js';
|
|
6
6
|
import type { ArtifactRenderer } from '../components/artifact-preview.js';
|
|
7
7
|
import { EmptyState } from '../primitives/record-list.js';
|
|
8
|
-
import {
|
|
8
|
+
import { OutputCard } from '../components/output-card.js';
|
|
9
|
+
import { OutputEntry } from '../components/output-entry.js';
|
|
9
10
|
|
|
10
11
|
export interface OutputsListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
11
12
|
analysis: ResolvedAnalysisNode;
|
|
12
13
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
14
|
+
getOutputStatus?: OutputStatusLookup | undefined;
|
|
13
15
|
onOpenRecord: (output: ResolvedOutput, analysis: ResolvedAnalysisNode) => void;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/** A gallery card: compact preview and title, with a type label for non-figures. */
|
|
23
|
-
export const OutputCard = forwardRef<HTMLButtonElement, OutputCardProps>(function OutputCard({
|
|
24
|
-
output,
|
|
25
|
-
renderArtifact,
|
|
26
|
-
onOpen,
|
|
27
|
-
className,
|
|
28
|
-
onClick,
|
|
29
|
-
'aria-label': hostLabel,
|
|
30
|
-
...props
|
|
31
|
-
}, ref) {
|
|
32
|
-
return (
|
|
33
|
-
<button
|
|
34
|
-
data-slot="output-card"
|
|
35
|
-
{...props}
|
|
36
|
-
ref={ref}
|
|
37
|
-
type="button"
|
|
38
|
-
aria-label={hostLabel ?? `Open ${output.type}: ${recordTitle(output)}`}
|
|
39
|
-
className={cn('astra-output-card', className)}
|
|
40
|
-
onClick={(event) => { onClick?.(event); onOpen(); }}
|
|
41
|
-
>
|
|
42
|
-
<span className="astra-output-card__preview">
|
|
43
|
-
<OutputPreview output={output} compact renderArtifact={renderArtifact} />
|
|
44
|
-
<span className="astra-output-card__open" aria-hidden="true">Open ↗</span>
|
|
45
|
-
</span>
|
|
46
|
-
<span className="astra-output-card__body">
|
|
47
|
-
{output.type !== 'figure' ? <span className="astra-output-card__kind">{output.type}</span> : null}
|
|
48
|
-
<strong>{recordTitle(output)}</strong>
|
|
49
|
-
{output.label ? <code>{output.id}</code> : null}
|
|
50
|
-
</span>
|
|
51
|
-
</button>
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
function OutputGallery({
|
|
56
|
-
title,
|
|
57
|
-
outputs,
|
|
58
|
-
renderArtifact,
|
|
59
|
-
onOpen,
|
|
60
|
-
}: {
|
|
61
|
-
title: string;
|
|
62
|
-
outputs: ResolvedOutput[];
|
|
63
|
-
renderArtifact?: ArtifactRenderer | undefined;
|
|
64
|
-
onOpen: (output: ResolvedOutput) => void;
|
|
65
|
-
}) {
|
|
66
|
-
const id = useId();
|
|
67
|
-
if (!outputs.length) return null;
|
|
68
|
-
return (
|
|
69
|
-
<section className="astra-inventory-outputs__group" aria-labelledby={id}>
|
|
70
|
-
<h3 id={id} className="astra-inventory-outputs__group-heading">
|
|
71
|
-
<span>{title}</span>
|
|
72
|
-
</h3>
|
|
73
|
-
<div className="astra-inventory-outputs__gallery">
|
|
74
|
-
{outputs.map((output) => (
|
|
75
|
-
<OutputCard
|
|
76
|
-
key={output.canonicalPath}
|
|
77
|
-
output={output}
|
|
78
|
-
renderArtifact={renderArtifact}
|
|
79
|
-
onOpen={() => { onOpen(output); }}
|
|
80
|
-
/>
|
|
81
|
-
))}
|
|
82
|
-
</div>
|
|
83
|
-
</section>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function CompactOutputs({
|
|
18
|
+
/**
|
|
19
|
+
* One titled run of outputs. A gallery frames each output as a card with its
|
|
20
|
+
* preview; the compact form lists them as entries, which is what a metric or a
|
|
21
|
+
* plain file is worth. Everything else about a group is the same either way.
|
|
22
|
+
*/
|
|
23
|
+
function OutputGroup({
|
|
88
24
|
title,
|
|
89
25
|
outputs,
|
|
26
|
+
variant,
|
|
90
27
|
renderArtifact,
|
|
28
|
+
getOutputStatus,
|
|
91
29
|
onOpen,
|
|
92
30
|
}: {
|
|
93
31
|
title: string;
|
|
94
32
|
outputs: ResolvedOutput[];
|
|
33
|
+
variant: 'gallery' | 'compact';
|
|
95
34
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
35
|
+
getOutputStatus?: OutputStatusLookup | undefined;
|
|
96
36
|
onOpen: (output: ResolvedOutput) => void;
|
|
97
37
|
}) {
|
|
98
38
|
const id = useId();
|
|
@@ -102,36 +42,32 @@ function CompactOutputs({
|
|
|
102
42
|
<h3 id={id} className="astra-inventory-outputs__group-heading">
|
|
103
43
|
<span>{title}</span>
|
|
104
44
|
</h3>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
45
|
+
{variant === 'gallery' ? (
|
|
46
|
+
<div className="astra-inventory-outputs__gallery">
|
|
47
|
+
{outputs.map((output) => (
|
|
48
|
+
<OutputCard
|
|
49
|
+
key={output.canonicalPath}
|
|
50
|
+
output={output}
|
|
51
|
+
status={getOutputStatus?.(output)}
|
|
52
|
+
renderArtifact={renderArtifact}
|
|
53
|
+
onOpen={() => { onOpen(output); }}
|
|
54
|
+
/>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
) : (
|
|
58
|
+
<ul className="astra-inventory-outputs__compact-grid" data-layout={outputs[0]?.type === 'metric' ? 'tiles' : 'grid'}>
|
|
59
|
+
{outputs.map((output) => (
|
|
110
60
|
<li key={output.canonicalPath}>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
>
|
|
118
|
-
<span className="astra-output-entry__name">
|
|
119
|
-
{recordTitle(output)}
|
|
120
|
-
{!metric && status ? <span className="astra-output-entry__status">{status}</span> : null}
|
|
121
|
-
</span>
|
|
122
|
-
{metric ? (
|
|
123
|
-
<span className="astra-output-entry__value">
|
|
124
|
-
{renderArtifact?.(output, { compact: true })
|
|
125
|
-
?? <span className="astra-output-entry__status">{status ?? 'Preview unavailable'}</span>}
|
|
126
|
-
</span>
|
|
127
|
-
) : (
|
|
128
|
-
<span className="astra-output-entry__format">{output.format ? output.format.replace(/^\./, '').toUpperCase() : 'FILE'}</span>
|
|
129
|
-
)}
|
|
130
|
-
</button>
|
|
61
|
+
<OutputEntry
|
|
62
|
+
output={output}
|
|
63
|
+
status={getOutputStatus?.(output)}
|
|
64
|
+
renderArtifact={renderArtifact}
|
|
65
|
+
onOpen={() => { onOpen(output); }}
|
|
66
|
+
/>
|
|
131
67
|
</li>
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
|
|
68
|
+
))}
|
|
69
|
+
</ul>
|
|
70
|
+
)}
|
|
135
71
|
</section>
|
|
136
72
|
);
|
|
137
73
|
}
|
|
@@ -142,6 +78,7 @@ const GROUPED_TYPES = new Set<ResolvedOutput['type']>(['figure', 'table', 'metri
|
|
|
142
78
|
export const OutputsList = forwardRef<HTMLDivElement, OutputsListProps>(function OutputsList({
|
|
143
79
|
analysis,
|
|
144
80
|
renderArtifact,
|
|
81
|
+
getOutputStatus,
|
|
145
82
|
onOpenRecord,
|
|
146
83
|
className,
|
|
147
84
|
...props
|
|
@@ -157,10 +94,10 @@ export const OutputsList = forwardRef<HTMLDivElement, OutputsListProps>(function
|
|
|
157
94
|
const open = (output: ResolvedOutput) => { onOpenRecord(output, analysis); };
|
|
158
95
|
return (
|
|
159
96
|
<div data-slot="outputs-list" {...props} ref={ref} className={cn('astra-inventory-outputs', className)}>
|
|
160
|
-
<
|
|
161
|
-
<
|
|
162
|
-
<
|
|
163
|
-
<
|
|
97
|
+
<OutputGroup variant="gallery" title="Figures" outputs={figures} renderArtifact={renderArtifact} getOutputStatus={getOutputStatus} onOpen={open} />
|
|
98
|
+
<OutputGroup variant="gallery" title="Tables" outputs={tables} renderArtifact={renderArtifact} getOutputStatus={getOutputStatus} onOpen={open} />
|
|
99
|
+
<OutputGroup variant="compact" title="Metrics" outputs={metrics} renderArtifact={renderArtifact} getOutputStatus={getOutputStatus} onOpen={open} />
|
|
100
|
+
<OutputGroup variant="compact" title="Output files" outputs={files} getOutputStatus={getOutputStatus} onOpen={open} />
|
|
164
101
|
</div>
|
|
165
102
|
);
|
|
166
103
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ResolvedAnalysisNode } from '@astra-spec/sdk';
|
|
2
2
|
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
3
|
import type { InventoryPaper } from '../model/papers.js';
|
|
4
|
-
import { countLabel } from '../model/records.js';
|
|
5
4
|
import { cn } from '../lib/cn.js';
|
|
6
5
|
import { useLabels } from '../lib/labels.js';
|
|
6
|
+
import { PaperRow } from '../components/paper-row.js';
|
|
7
7
|
import { EmptyState } from '../primitives/record-list.js';
|
|
8
8
|
import { InventoryRecords } from './section.js';
|
|
9
9
|
|
|
@@ -24,23 +24,7 @@ export const PaperRows = forwardRef<HTMLDivElement, PaperRowsProps>(function Pap
|
|
|
24
24
|
return (
|
|
25
25
|
<div data-slot="paper-list" {...props} ref={ref} className={cn('astra-paper-list', className)} role="group" aria-label={labels.sections.papers}>
|
|
26
26
|
{papers.map((paper) => (
|
|
27
|
-
<
|
|
28
|
-
key={paper.doi}
|
|
29
|
-
type="button"
|
|
30
|
-
aria-label={`${paper.title}, ${paper.doi}, ${countLabel(paper.insights.length, 'insight')}, ${countLabel(paper.decisions.length, 'decision')}`}
|
|
31
|
-
onClick={() => { onOpen(paper); }}
|
|
32
|
-
>
|
|
33
|
-
<span className="astra-paper-list__thumbnail" aria-hidden="true">p.1</span>
|
|
34
|
-
<span className="astra-paper-list__copy">
|
|
35
|
-
<strong>{paper.title}</strong>
|
|
36
|
-
<small>{[paper.authors, paper.doi].filter(Boolean).join(' · ')}</small>
|
|
37
|
-
</span>
|
|
38
|
-
<span className="astra-paper-list__meta">
|
|
39
|
-
{countLabel(paper.insights.length, 'insight')} ·{' '}
|
|
40
|
-
{countLabel(paper.decisions.length, 'decision')}
|
|
41
|
-
</span>
|
|
42
|
-
<span className="astra-paper-list__arrow" aria-hidden="true">→</span>
|
|
43
|
-
</button>
|
|
27
|
+
<PaperRow key={paper.doi} paper={paper} onOpen={() => { onOpen(paper); }} />
|
|
44
28
|
))}
|
|
45
29
|
</div>
|
|
46
30
|
);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { TransformComponent, TransformWrapper, useControls, useTransformComponent } from 'react-zoom-pan-pinch';
|
|
3
|
+
import { useLabels } from '../lib/labels.js';
|
|
4
|
+
import { Button } from '../primitives/button.js';
|
|
5
|
+
|
|
6
|
+
const MIN_SCALE = 1;
|
|
7
|
+
const MAX_SCALE = 4;
|
|
8
|
+
const ZOOM_STEP = 0.25;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A step that reaches a bound disables its own button. A natively disabled
|
|
12
|
+
* button cannot hold focus, so the keyboard user who pressed it would be
|
|
13
|
+
* dropped to the document; `aria-disabled` keeps the button focusable and
|
|
14
|
+
* announced as unavailable while the handler ignores the press.
|
|
15
|
+
*/
|
|
16
|
+
function ZoomButton({ label, unavailable, onPress, children }: {
|
|
17
|
+
label: string;
|
|
18
|
+
unavailable: boolean;
|
|
19
|
+
onPress: () => void;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<Button
|
|
24
|
+
aria-label={label}
|
|
25
|
+
title={label}
|
|
26
|
+
aria-disabled={unavailable || undefined}
|
|
27
|
+
onClick={unavailable ? undefined : onPress}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</Button>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function FigureControls() {
|
|
35
|
+
const { figure: labels } = useLabels();
|
|
36
|
+
const { zoomIn, zoomOut } = useControls();
|
|
37
|
+
const scale = useTransformComponent(({ state }) => state.scale);
|
|
38
|
+
return (
|
|
39
|
+
<div className="astra-figure-zoom__controls">
|
|
40
|
+
<ZoomButton label={labels.zoomIn} unavailable={scale >= MAX_SCALE} onPress={() => { void zoomIn(ZOOM_STEP, 0); }}>+</ZoomButton>
|
|
41
|
+
<ZoomButton label={labels.zoomOut} unavailable={scale <= MIN_SCALE} onPress={() => { void zoomOut(ZOOM_STEP, 0); }}>−</ZoomButton>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The gesture library magnifies the host's fitted figure; the host still owns its artifact. */
|
|
47
|
+
export function FigureZoom({ children }: { children: ReactNode }) {
|
|
48
|
+
const { figure: labels } = useLabels();
|
|
49
|
+
return (
|
|
50
|
+
<TransformWrapper
|
|
51
|
+
minScale={MIN_SCALE}
|
|
52
|
+
maxScale={MAX_SCALE}
|
|
53
|
+
disablePadding
|
|
54
|
+
keyboard={{ disabled: false, zoomStep: ZOOM_STEP, animationTime: 0 }}
|
|
55
|
+
panning={{ velocityDisabled: true, excluded: ['button', 'a', 'input', 'select', 'textarea'] }}
|
|
56
|
+
doubleClick={{ mode: 'toggle', step: 1, animationTime: 0 }}
|
|
57
|
+
>
|
|
58
|
+
<div className="astra-figure-zoom" role="group" aria-label={labels.controls}>
|
|
59
|
+
<TransformComponent
|
|
60
|
+
wrapperClass="astra-figure-zoom__viewport"
|
|
61
|
+
contentClass="astra-figure-zoom__canvas"
|
|
62
|
+
wrapperStyle={{ width: '100%', height: '100%' }}
|
|
63
|
+
contentStyle={{ width: '100%', height: '100%' }}
|
|
64
|
+
wrapperProps={{ role: 'region', 'aria-label': labels.viewport }}
|
|
65
|
+
>
|
|
66
|
+
<div className="astra-output-detail__preview">{children}</div>
|
|
67
|
+
</TransformComponent>
|
|
68
|
+
<FigureControls />
|
|
69
|
+
</div>
|
|
70
|
+
</TransformWrapper>
|
|
71
|
+
);
|
|
72
|
+
}
|