@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
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import type { ResolvedInsight } from '@astra-spec/sdk';
|
|
2
|
-
import { Fragment, forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
-
import { recordTitle } from '../model/records.js';
|
|
1
|
+
import type { ResolvedAnalysisNode, ResolvedInsight, ResolvedOutput } from '@astra-spec/sdk';
|
|
2
|
+
import { Fragment, forwardRef, useId, type HTMLAttributes, type ReactNode } from 'react';
|
|
4
3
|
import { doiHref } from '../model/doi.js';
|
|
5
|
-
import {
|
|
4
|
+
import { recordTitle } from '../model/records.js';
|
|
5
|
+
import {
|
|
6
|
+
findingLiterature,
|
|
7
|
+
groupFindingEvidence,
|
|
8
|
+
type FindingEvidenceGroup,
|
|
9
|
+
type FindingEvidenceLink,
|
|
10
|
+
} from '../model/relations.js';
|
|
6
11
|
import { cn } from '../lib/cn.js';
|
|
7
12
|
import { useLabels } from '../lib/labels.js';
|
|
8
|
-
import { DetailLayout, DetailMain } from '../primitives/detail-layout.js';
|
|
13
|
+
import { CountHeading, DetailLayout, DetailMain, DetailSection } from '../primitives/detail-layout.js';
|
|
9
14
|
import { DetailDialog, type DetailDialogProps } from '../primitives/dialog.js';
|
|
10
15
|
import { Prose } from '../primitives/prose.js';
|
|
11
16
|
import type { TextRenderer } from '../lib/prose.js';
|
|
12
|
-
import {
|
|
17
|
+
import type { ArtifactRenderer } from './artifact-preview.js';
|
|
18
|
+
import { OutputCard } from './output-card.js';
|
|
19
|
+
import { OutputEntry } from './output-entry.js';
|
|
13
20
|
import type { OpenRecordHandler } from '../lib/detail-stack.js';
|
|
14
21
|
|
|
15
22
|
export interface FindingDetailProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
@@ -17,48 +24,117 @@ export interface FindingDetailProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
17
24
|
/** Artifact-backed evidence resolved to outputs; see `findingEvidence()`. */
|
|
18
25
|
evidence: FindingEvidenceLink[];
|
|
19
26
|
renderText?: TextRenderer | undefined;
|
|
27
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
20
28
|
onOpenRecord?: OpenRecordHandler | undefined;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
/**
|
|
31
|
+
/** A resolved group, narrowed to the ones a result renderer can draw. */
|
|
32
|
+
type ResolvedGroup = FindingEvidenceGroup & { output: ResolvedOutput; analysis: ResolvedAnalysisNode };
|
|
33
|
+
|
|
34
|
+
const isResolved = (group: FindingEvidenceGroup): group is ResolvedGroup =>
|
|
35
|
+
Boolean(group.output && group.analysis);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* One run of results of a kind. The label only earns its space when a finding
|
|
39
|
+
* rests on more than one kind: with a single run, what they are is evident.
|
|
40
|
+
*/
|
|
41
|
+
function ResultRun({ label, labelled, children }: { label: string; labelled: boolean; children: ReactNode }) {
|
|
42
|
+
const id = useId();
|
|
43
|
+
if (!labelled) return <>{children}</>;
|
|
44
|
+
return (
|
|
45
|
+
<section aria-labelledby={id}>
|
|
46
|
+
<h5 id={id} className="astra-finding-detail__group-heading">{label}</h5>
|
|
47
|
+
{children}
|
|
48
|
+
</section>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The claim, the results it rests on, and the literature it cites. */
|
|
24
53
|
export const FindingDetail = forwardRef<HTMLDivElement, FindingDetailProps>(function FindingDetail({
|
|
25
54
|
record,
|
|
26
55
|
evidence,
|
|
27
56
|
renderText,
|
|
57
|
+
renderArtifact,
|
|
28
58
|
onOpenRecord,
|
|
29
59
|
className,
|
|
30
60
|
...props
|
|
31
61
|
}, ref) {
|
|
32
62
|
const literature = findingLiterature(record);
|
|
63
|
+
const results = groupFindingEvidence(evidence);
|
|
64
|
+
// Grouped the way the inventory groups an analysis's outputs, so a result
|
|
65
|
+
// looks the same wherever it is met. Unresolved artifacts have no record to
|
|
66
|
+
// draw, so they keep their name and nothing more.
|
|
67
|
+
const resolved = results.filter(isResolved);
|
|
68
|
+
const ofType = (type: ResolvedOutput['type']) => resolved.filter(({ output }) => output.type === type);
|
|
69
|
+
const figures = ofType('figure');
|
|
70
|
+
const tables = ofType('table');
|
|
71
|
+
const metrics = ofType('metric');
|
|
72
|
+
const files = resolved.filter(({ output }) => !['figure', 'table', 'metric'].includes(output.type));
|
|
73
|
+
const unresolved = results.filter((group) => !isResolved(group));
|
|
74
|
+
// Labels only appear once a finding rests on more than one kind of result.
|
|
75
|
+
const runs = [figures.length, tables.length, metrics.length, files.length + unresolved.length];
|
|
76
|
+
const labelled = runs.filter(Boolean).length > 1;
|
|
77
|
+
const open = (group: ResolvedGroup) => () => { onOpenRecord?.(group.output, group.analysis); };
|
|
78
|
+
// Say what the result is to this finding; the card's own name would only
|
|
79
|
+
// say what kind of artifact it is.
|
|
80
|
+
const resultLabel = (group: ResolvedGroup) => `View supporting result: ${recordTitle(group.output)}`;
|
|
33
81
|
return (
|
|
34
82
|
<DetailLayout data-slot="finding-detail" {...props} ref={ref} layout="single" className={cn('astra-finding-detail', className)}>
|
|
35
83
|
<DetailMain>
|
|
84
|
+
<DetailSection label="Claim" heading="section">
|
|
85
|
+
<Prose text={record.claim} field="claim" renderText={renderText} />
|
|
86
|
+
</DetailSection>
|
|
36
87
|
{record.notes ? (
|
|
37
88
|
<section className="astra-finding-detail__notes">
|
|
38
89
|
<h4>Notes</h4>
|
|
39
90
|
<div><Prose text={record.notes} field="notes" renderText={renderText} /></div>
|
|
40
91
|
</section>
|
|
41
92
|
) : null}
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
93
|
+
<section className="astra-finding-detail__results">
|
|
94
|
+
<CountHeading title="Supporting results" count={results.length} />
|
|
95
|
+
{results.length ? (
|
|
96
|
+
<>
|
|
97
|
+
{([['Figures', figures], ['Tables', tables]] as const).map(([label, groups]) => (
|
|
98
|
+
groups.length ? (
|
|
99
|
+
<ResultRun key={label} label={label} labelled={labelled}>
|
|
100
|
+
<div className="astra-finding-detail__gallery">
|
|
101
|
+
{groups.map((group) => (
|
|
102
|
+
<OutputCard key={group.key} output={group.output} renderArtifact={renderArtifact} aria-label={resultLabel(group)} onOpen={open(group)} />
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
</ResultRun>
|
|
106
|
+
) : null
|
|
107
|
+
))}
|
|
108
|
+
{metrics.length ? (
|
|
109
|
+
<ResultRun label="Metrics" labelled={labelled}>
|
|
110
|
+
<ul className="astra-finding-detail__tiles">
|
|
111
|
+
{metrics.map((group) => (
|
|
112
|
+
<li key={group.key}>
|
|
113
|
+
<OutputEntry output={group.output} renderArtifact={renderArtifact} aria-label={resultLabel(group)} onOpen={open(group)} />
|
|
114
|
+
</li>
|
|
115
|
+
))}
|
|
116
|
+
</ul>
|
|
117
|
+
</ResultRun>
|
|
118
|
+
) : null}
|
|
119
|
+
{files.length || unresolved.length ? (
|
|
120
|
+
<ResultRun label="Output files" labelled={labelled}>
|
|
121
|
+
<ul className="astra-finding-detail__files">
|
|
122
|
+
{files.map((group) => (
|
|
123
|
+
<li key={group.key}>
|
|
124
|
+
<OutputEntry output={group.output} aria-label={resultLabel(group)} onOpen={open(group)} />
|
|
125
|
+
</li>
|
|
126
|
+
))}
|
|
127
|
+
{unresolved.map((group) => (
|
|
128
|
+
<li key={group.key} className="astra-finding-detail__unresolved">
|
|
129
|
+
{group.artifact ?? group.key}
|
|
130
|
+
</li>
|
|
131
|
+
))}
|
|
132
|
+
</ul>
|
|
133
|
+
</ResultRun>
|
|
134
|
+
) : null}
|
|
135
|
+
</>
|
|
136
|
+
) : <p>No supporting results are linked to this finding.</p>}
|
|
137
|
+
</section>
|
|
62
138
|
{literature.map((source, index) => {
|
|
63
139
|
const doi = source.doi ?? '';
|
|
64
140
|
const location = source.location?.page ? ` · page ${source.location.page}` : '';
|
|
@@ -84,17 +160,17 @@ export const FindingDetail = forwardRef<HTMLDivElement, FindingDetailProps>(func
|
|
|
84
160
|
|
|
85
161
|
export interface FindingDialogProps extends Pick<DetailDialogProps, 'mode' | 'backText' | 'className' | 'onBack' | 'onClose'>, Omit<FindingDetailProps, 'className'> {}
|
|
86
162
|
|
|
87
|
-
export function FindingDialog({ record, evidence, renderText, onOpenRecord, ...dialog }: FindingDialogProps) {
|
|
163
|
+
export function FindingDialog({ record, evidence, renderText, renderArtifact, onOpenRecord, ...dialog }: FindingDialogProps) {
|
|
88
164
|
const labels = useLabels();
|
|
89
165
|
return (
|
|
90
166
|
<DetailDialog
|
|
91
167
|
{...dialog}
|
|
92
168
|
kind="finding"
|
|
93
169
|
kindLabel={labels.kinds.finding}
|
|
94
|
-
title={record
|
|
170
|
+
title={recordTitle(record)}
|
|
95
171
|
closeLabel={labels.closeRecord(labels.kinds.finding)}
|
|
96
172
|
>
|
|
97
|
-
<FindingDetail record={record} evidence={evidence} renderText={renderText} onOpenRecord={onOpenRecord} />
|
|
173
|
+
<FindingDetail record={record} evidence={evidence} renderText={renderText} renderArtifact={renderArtifact} onOpenRecord={onOpenRecord} />
|
|
98
174
|
</DetailDialog>
|
|
99
175
|
);
|
|
100
176
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -32,3 +32,16 @@ export type { ArtifactPreviewProps, ArtifactRenderOptions, ArtifactRenderer } fr
|
|
|
32
32
|
|
|
33
33
|
export { PaperPdfViewer } from './paper-pdf-viewer.js';
|
|
34
34
|
export type { PaperPdfViewerProps, PdfLoadState, PdfPassage } from './paper-pdf-viewer.js';
|
|
35
|
+
|
|
36
|
+
export { OutputCard } from './output-card.js';
|
|
37
|
+
export type { OutputCardProps } from './output-card.js';
|
|
38
|
+
export { OutputEntry } from './output-entry.js';
|
|
39
|
+
export type { OutputEntryProps } from './output-entry.js';
|
|
40
|
+
|
|
41
|
+
export { PaperRow } from './paper-row.js';
|
|
42
|
+
export type { PaperRowProps } from './paper-row.js';
|
|
43
|
+
|
|
44
|
+
export { OutputStatusIndicator } from './output-status.js';
|
|
45
|
+
export type { OutputStatusIndicatorProps } from './output-status.js';
|
|
46
|
+
|
|
47
|
+
export { OutputProvenance, type OutputProvenanceProps } from './output-provenance.js';
|
|
@@ -21,7 +21,7 @@ export interface InsightEvidenceTitleProps {
|
|
|
21
21
|
export function InsightEvidenceTitle({ name, tag }: InsightEvidenceTitleProps) {
|
|
22
22
|
return (
|
|
23
23
|
<span className="astra-evidence__title">
|
|
24
|
-
<KindGlyph
|
|
24
|
+
<KindGlyph kind="prior_insight" />
|
|
25
25
|
<span className="astra-evidence__name">{name}</span>
|
|
26
26
|
{tag ? <span className="astra-evidence__tag">{tag}</span> : null}
|
|
27
27
|
</span>
|
|
@@ -79,7 +79,7 @@ export const InsightTrigger = forwardRef<HTMLElement, InsightTriggerProps>(funct
|
|
|
79
79
|
onClick={open}
|
|
80
80
|
onKeyDown={keyOpen}
|
|
81
81
|
>
|
|
82
|
-
<KindGlyph className="astra-
|
|
82
|
+
<KindGlyph className="astra-insight-trigger__glyph" kind="prior_insight" />
|
|
83
83
|
<div className="astra-insight-trigger__claim">
|
|
84
84
|
<Prose text={insight.claim} field="claim" renderText={renderText} />
|
|
85
85
|
</div>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ResolvedOutput } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import type { OutputStatus } from '../model/output-status.js';
|
|
4
|
+
import { OutputStatusIndicator } from './output-status.js';
|
|
5
|
+
import { recordTitle } from '../model/records.js';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import type { ArtifactRenderer } from './artifact-preview.js';
|
|
8
|
+
import { OutputPreview } from './output-detail.js';
|
|
9
|
+
|
|
10
|
+
export interface OutputCardProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
11
|
+
output: ResolvedOutput;
|
|
12
|
+
status?: OutputStatus | undefined;
|
|
13
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
14
|
+
onOpen: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A gallery card: compact preview and title, with a type label for non-figures. */
|
|
18
|
+
export const OutputCard = forwardRef<HTMLButtonElement, OutputCardProps>(function OutputCard({
|
|
19
|
+
output,
|
|
20
|
+
status,
|
|
21
|
+
renderArtifact,
|
|
22
|
+
onOpen,
|
|
23
|
+
className,
|
|
24
|
+
onClick,
|
|
25
|
+
'aria-label': hostLabel,
|
|
26
|
+
...props
|
|
27
|
+
}, ref) {
|
|
28
|
+
const title = recordTitle(output);
|
|
29
|
+
return (
|
|
30
|
+
<button
|
|
31
|
+
data-slot="output-card"
|
|
32
|
+
{...props}
|
|
33
|
+
ref={ref}
|
|
34
|
+
type="button"
|
|
35
|
+
className={cn('astra-output-card', className)}
|
|
36
|
+
aria-label={hostLabel ?? `Open ${output.type}: ${title}`}
|
|
37
|
+
onClick={(event) => { onClick?.(event); onOpen(); }}
|
|
38
|
+
>
|
|
39
|
+
<OutputStatusIndicator status={status} />
|
|
40
|
+
<span className="astra-output-card__preview">
|
|
41
|
+
<OutputPreview output={output} compact renderArtifact={renderArtifact} />
|
|
42
|
+
<span className="astra-output-card__open" aria-hidden="true">Open ↗</span>
|
|
43
|
+
</span>
|
|
44
|
+
<span className="astra-output-card__body">
|
|
45
|
+
{output.type !== 'figure' ? <span className="astra-output-card__kind">{output.type}</span> : null}
|
|
46
|
+
<strong>{title}</strong>
|
|
47
|
+
{output.label ? <code>{output.id}</code> : null}
|
|
48
|
+
</span>
|
|
49
|
+
</button>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
@@ -10,6 +10,7 @@ import { Prose } from '../primitives/prose.js';
|
|
|
10
10
|
import type { TextRenderer } from '../lib/prose.js';
|
|
11
11
|
import { RelationList } from '../primitives/relation-list.js';
|
|
12
12
|
import { relationItemsForLinks } from './relation-items.js';
|
|
13
|
+
import { FigureZoom } from './figure-zoom.js';
|
|
13
14
|
import type { OpenRecordHandler } from '../lib/detail-stack.js';
|
|
14
15
|
|
|
15
16
|
export interface OutputPreviewProps {
|
|
@@ -26,19 +27,28 @@ export function OutputPreview({ output, compact = false, renderArtifact }: Outpu
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
|
-
* What the detail shows in its artifact box:
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* What the detail shows in its artifact box: only a figure or a table has a
|
|
31
|
+
* picture to frame, rendered by the host when it supplies a renderer. A data
|
|
32
|
+
* file or a metric gets no box — an empty reader column is all whitespace —
|
|
33
|
+
* so the host renderer is not consulted for them here; `OutputPreview` still
|
|
34
|
+
* asks it for the compact preview of any type, and a metric's value is asked
|
|
35
|
+
* for as a compact rendering below.
|
|
32
36
|
*/
|
|
33
37
|
function artifactNode(output: ResolvedOutput, renderArtifact: ArtifactRenderer | undefined): ReactNode {
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
38
|
+
if (!isVisualOutput(output)) return null;
|
|
39
|
+
return renderArtifact
|
|
40
|
+
? renderArtifact(output, { compact: false })
|
|
41
|
+
: <ArtifactPreview output={output} compact={false} />;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export interface OutputDetailProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
39
45
|
record: ResolvedOutput;
|
|
40
46
|
relations: OutputRelations;
|
|
41
47
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
48
|
+
/** Recorded execution information, shown below Recipe. */
|
|
49
|
+
renderProvenance?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
50
|
+
/** Host-provided link to the current code file, shown beside Recipe. */
|
|
51
|
+
renderCodeLink?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
42
52
|
renderText?: TextRenderer | undefined;
|
|
43
53
|
onOpenRecord?: OpenRecordHandler | undefined;
|
|
44
54
|
/** Full-screen artifact state (controlled). */
|
|
@@ -46,11 +56,42 @@ export interface OutputDetailProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
46
56
|
onExpandedChange?: ((expanded: boolean) => void) | undefined;
|
|
47
57
|
}
|
|
48
58
|
|
|
59
|
+
/**
|
|
60
|
+
* One decision per row. A decision the output declares reads plainly; one it
|
|
61
|
+
* inherits says which upstream output carries it, so a list that mixes the two
|
|
62
|
+
* still shows where each came from.
|
|
63
|
+
*/
|
|
64
|
+
function decisionDependencyItems(relations: OutputRelations, onOpenRecord: OpenRecordHandler | undefined) {
|
|
65
|
+
return relationItemsForLinks(relations.decisions, onOpenRecord).map((item, index) => {
|
|
66
|
+
const via = relations.decisions[index]?.via;
|
|
67
|
+
const origins = via?.map(({ record, canonicalPath }) => record ? recordTitle(record) : canonicalPath);
|
|
68
|
+
if (!origins?.length) return item;
|
|
69
|
+
const detail = `via ${origins.join(', ')}`;
|
|
70
|
+
return {
|
|
71
|
+
...item,
|
|
72
|
+
// The truncated text is for sighted readers; assistive technology gets
|
|
73
|
+
// the full list, whether or not the row becomes a navigation trigger
|
|
74
|
+
// (only a trigger carries `accessibleLabel`).
|
|
75
|
+
detail: origins.length > 1
|
|
76
|
+
? (
|
|
77
|
+
<span title={detail}>
|
|
78
|
+
<span aria-hidden="true">via {origins[0]} +{origins.length - 1} more</span>
|
|
79
|
+
<span className="astra-output-detail__visually-hidden">{detail}</span>
|
|
80
|
+
</span>
|
|
81
|
+
)
|
|
82
|
+
: detail,
|
|
83
|
+
accessibleLabel: item.accessibleLabel ? `${item.accessibleLabel}, ${detail}` : undefined,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
49
88
|
/** Artifact preview with provenance: description, recipe, alias, decisions, and inputs. */
|
|
50
89
|
export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(function OutputDetail({
|
|
51
90
|
record: output,
|
|
52
91
|
relations,
|
|
53
92
|
renderArtifact,
|
|
93
|
+
renderProvenance,
|
|
94
|
+
renderCodeLink,
|
|
54
95
|
renderText,
|
|
55
96
|
onOpenRecord,
|
|
56
97
|
expanded = false,
|
|
@@ -60,6 +101,10 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
60
101
|
}, ref) {
|
|
61
102
|
const labels = useLabels();
|
|
62
103
|
const artifact = artifactNode(output, renderArtifact);
|
|
104
|
+
// A metric's whole artifact is one number: it reads as a pill at the head of
|
|
105
|
+
// the provenance, above the description, not as a figure stretched across a
|
|
106
|
+
// reader column.
|
|
107
|
+
const metric = output.type === 'metric' ? renderArtifact?.(output, { compact: true }) : null;
|
|
63
108
|
// Reader layout (artifact column + details rail) only when there is an
|
|
64
109
|
// artifact to frame: a host renderer may opt out of a figure or table by
|
|
65
110
|
// returning null, and the details then take the single column instead.
|
|
@@ -110,6 +155,12 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
110
155
|
|
|
111
156
|
const supportingDetails = (
|
|
112
157
|
<aside className="astra-output-detail__provenance" aria-label="Output provenance and dependencies">
|
|
158
|
+
{metric ? (
|
|
159
|
+
<section className="astra-output-detail__metric">
|
|
160
|
+
<h4>Metric</h4>
|
|
161
|
+
<div className="astra-output-detail__metric-pill">{metric}</div>
|
|
162
|
+
</section>
|
|
163
|
+
) : null}
|
|
113
164
|
{output.description ? (
|
|
114
165
|
<section className="astra-output-detail__description">
|
|
115
166
|
<h4>Description</h4>
|
|
@@ -129,17 +180,9 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
129
180
|
<RelationList
|
|
130
181
|
className="astra-detail__relations"
|
|
131
182
|
title="Decision dependencies"
|
|
132
|
-
items={
|
|
133
|
-
empty="No
|
|
183
|
+
items={decisionDependencyItems(relations, onOpenRecord)}
|
|
184
|
+
empty="No decisions affect this output."
|
|
134
185
|
/>
|
|
135
|
-
{relations.indirectDecisions?.length ? (
|
|
136
|
-
<RelationList
|
|
137
|
-
className="astra-detail__relations"
|
|
138
|
-
title="Indirect decision dependencies"
|
|
139
|
-
items={relationItemsForLinks(relations.indirectDecisions, onOpenRecord)}
|
|
140
|
-
empty={null}
|
|
141
|
-
/>
|
|
142
|
-
) : null}
|
|
143
186
|
<RelationList
|
|
144
187
|
className="astra-detail__relations"
|
|
145
188
|
title="Inputs and upstream outputs"
|
|
@@ -150,13 +193,17 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
150
193
|
/>
|
|
151
194
|
{output.recipe?.command ? (
|
|
152
195
|
<section className="astra-output-detail__recipe">
|
|
153
|
-
<
|
|
196
|
+
<div className="astra-output-detail__recipe-heading">
|
|
197
|
+
<h4>Recipe</h4>
|
|
198
|
+
{renderCodeLink?.(output)}
|
|
199
|
+
</div>
|
|
154
200
|
<pre><code>{output.recipe.command}</code></pre>
|
|
155
201
|
{output.recipe.container
|
|
156
202
|
? <p>Container: <code>{output.recipe.container}</code></p>
|
|
157
203
|
: null}
|
|
158
204
|
</section>
|
|
159
205
|
) : null}
|
|
206
|
+
{renderProvenance?.(output)}
|
|
160
207
|
</aside>
|
|
161
208
|
);
|
|
162
209
|
|
|
@@ -191,7 +238,9 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
191
238
|
</div>
|
|
192
239
|
) : null}
|
|
193
240
|
<div className="astra-output-detail__preview" data-type={output.type}>
|
|
194
|
-
{
|
|
241
|
+
{output.type === 'figure'
|
|
242
|
+
? <FigureZoom key={output.canonicalPath}>{artifact}</FigureZoom>
|
|
243
|
+
: artifact}
|
|
195
244
|
</div>
|
|
196
245
|
</div>
|
|
197
246
|
) : null}
|
|
@@ -209,10 +258,10 @@ export interface OutputDialogActionsProps {
|
|
|
209
258
|
onExpandedChange: (expanded: boolean) => void;
|
|
210
259
|
}
|
|
211
260
|
|
|
212
|
-
/** Header actions
|
|
261
|
+
/** Header actions: open the artifact in the host, or expand a table. */
|
|
213
262
|
export function OutputDialogActions({ record: output, onOpenArtifact, expanded, onExpandedChange }: OutputDialogActionsProps) {
|
|
214
263
|
const labels = useLabels();
|
|
215
|
-
const
|
|
264
|
+
const canExpand = output.type === 'table';
|
|
216
265
|
return (
|
|
217
266
|
<>
|
|
218
267
|
{onOpenArtifact && output.artifact ? (
|
|
@@ -221,7 +270,7 @@ export function OutputDialogActions({ record: output, onOpenArtifact, expanded,
|
|
|
221
270
|
<span>{labels.actions.openArtifact}</span>
|
|
222
271
|
</DialogAction>
|
|
223
272
|
) : null}
|
|
224
|
-
{
|
|
273
|
+
{canExpand ? (
|
|
225
274
|
<DialogAction
|
|
226
275
|
aria-label={`View ${output.type} full screen`}
|
|
227
276
|
aria-expanded={expanded}
|
|
@@ -234,4 +283,3 @@ export function OutputDialogActions({ record: output, onOpenArtifact, expanded,
|
|
|
234
283
|
</>
|
|
235
284
|
);
|
|
236
285
|
}
|
|
237
|
-
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { ResolvedOutput } from '@astra-spec/sdk';
|
|
2
3
|
import type { OutputRelations } from '../model/relations.js';
|
|
3
4
|
import { isVisualOutput, recordTitle } from '../model/records.js';
|
|
@@ -13,6 +14,10 @@ export interface OutputDialogProps extends Pick<DetailDialogProps, 'mode' | 'bac
|
|
|
13
14
|
record: ResolvedOutput;
|
|
14
15
|
relations: OutputRelations;
|
|
15
16
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
17
|
+
/** Host renderer for recorded output provenance, shown below Recipe. */
|
|
18
|
+
renderProvenance?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
19
|
+
/** Host-provided link to the current code file, shown beside Recipe. */
|
|
20
|
+
renderCodeLink?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
16
21
|
renderText?: TextRenderer | undefined;
|
|
17
22
|
onOpenArtifact?: ((output: ResolvedOutput) => void | Promise<void>) | undefined;
|
|
18
23
|
onOpenRecord?: OpenRecordHandler | undefined;
|
|
@@ -24,6 +29,8 @@ export function OutputDialog({
|
|
|
24
29
|
record: output,
|
|
25
30
|
relations,
|
|
26
31
|
renderArtifact,
|
|
32
|
+
renderProvenance,
|
|
33
|
+
renderCodeLink,
|
|
27
34
|
renderText,
|
|
28
35
|
onOpenArtifact,
|
|
29
36
|
onOpenRecord,
|
|
@@ -54,6 +61,8 @@ export function OutputDialog({
|
|
|
54
61
|
record={output}
|
|
55
62
|
relations={relations}
|
|
56
63
|
renderArtifact={renderArtifact}
|
|
64
|
+
renderProvenance={renderProvenance}
|
|
65
|
+
renderCodeLink={renderCodeLink}
|
|
57
66
|
renderText={renderText}
|
|
58
67
|
onOpenRecord={onOpenRecord}
|
|
59
68
|
expanded={expanded}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ResolvedOutput } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import type { OutputStatus } from '../model/output-status.js';
|
|
4
|
+
import { OutputStatusIndicator } from './output-status.js';
|
|
5
|
+
import { recordTitle } from '../model/records.js';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import type { ArtifactRenderer } from './artifact-preview.js';
|
|
8
|
+
|
|
9
|
+
export interface OutputEntryProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
10
|
+
output: ResolvedOutput;
|
|
11
|
+
status?: OutputStatus | undefined;
|
|
12
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
13
|
+
onOpen: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One output at a glance, for the types a gallery card would waste space on: a
|
|
18
|
+
* metric reads as its value over its name, anything else as its name. The row
|
|
19
|
+
* it wraps in decides how a run of these is laid out.
|
|
20
|
+
*/
|
|
21
|
+
export const OutputEntry = forwardRef<HTMLButtonElement, OutputEntryProps>(function OutputEntry({
|
|
22
|
+
output,
|
|
23
|
+
status,
|
|
24
|
+
renderArtifact,
|
|
25
|
+
onOpen,
|
|
26
|
+
className,
|
|
27
|
+
onClick,
|
|
28
|
+
'aria-label': hostLabel,
|
|
29
|
+
...props
|
|
30
|
+
}, ref) {
|
|
31
|
+
const title = recordTitle(output);
|
|
32
|
+
const metric = output.type === 'metric';
|
|
33
|
+
// Why the document itself has nothing to show, before any host status.
|
|
34
|
+
const absenceNote = !output.active ? 'Inactive' : !output.artifact ? 'Not yet generated' : undefined;
|
|
35
|
+
return (
|
|
36
|
+
<button
|
|
37
|
+
data-slot="output-entry"
|
|
38
|
+
{...props}
|
|
39
|
+
ref={ref}
|
|
40
|
+
type="button"
|
|
41
|
+
className={cn('astra-output-entry', className)}
|
|
42
|
+
data-kind={metric ? 'metric' : 'file'}
|
|
43
|
+
aria-label={hostLabel ?? `Open ${output.type}: ${title}`}
|
|
44
|
+
onClick={(event) => { onClick?.(event); onOpen(); }}
|
|
45
|
+
>
|
|
46
|
+
<OutputStatusIndicator status={status} />
|
|
47
|
+
<span className="astra-output-entry__name">
|
|
48
|
+
{title}
|
|
49
|
+
{!metric && absenceNote && !status ? <span className="astra-output-entry__status">{absenceNote}</span> : null}
|
|
50
|
+
</span>
|
|
51
|
+
{metric ? (
|
|
52
|
+
<span className="astra-output-entry__value">
|
|
53
|
+
{status?.state === 'stale' && !output.artifact
|
|
54
|
+
? <span className="astra-artifact__metric-value" aria-label="No value">–</span>
|
|
55
|
+
: renderArtifact?.(output, { compact: true })
|
|
56
|
+
?? <span className="astra-output-entry__status">{absenceNote ?? 'Preview unavailable'}</span>}
|
|
57
|
+
</span>
|
|
58
|
+
) : null}
|
|
59
|
+
</button>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { forwardRef, useState, type HTMLAttributes } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import { useLabels } from '../lib/labels.js';
|
|
4
|
+
import type { OutputProvenanceData } from '../model/output-provenance.js';
|
|
5
|
+
import { DetailDialog } from '../primitives/dialog.js';
|
|
6
|
+
import { OutputStatusGlyph } from '../primitives/output-status-glyph.js';
|
|
7
|
+
|
|
8
|
+
export type OutputProvenanceProps = HTMLAttributes<HTMLDivElement> & OutputProvenanceData;
|
|
9
|
+
|
|
10
|
+
/** Compact run summary with the full execution metadata in a detail dialog. */
|
|
11
|
+
export const OutputProvenance = forwardRef<HTMLDivElement, OutputProvenanceProps>(function OutputProvenance({
|
|
12
|
+
status, run, error, className, ...props
|
|
13
|
+
}, ref) {
|
|
14
|
+
const labels = useLabels();
|
|
15
|
+
const copy = labels.provenance;
|
|
16
|
+
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
17
|
+
const stateLabel = status ? labels.status[status.state] : copy.unknown;
|
|
18
|
+
const finished = run ? new Date(run.finishedAt) : null;
|
|
19
|
+
return (
|
|
20
|
+
<div data-slot="output-provenance" {...props} ref={ref} className={cn('astra-output-provenance', className)}>
|
|
21
|
+
<div className="astra-output-provenance__heading">
|
|
22
|
+
<h4>{copy.title}</h4>
|
|
23
|
+
{run ? <button type="button" aria-haspopup="dialog" onClick={() => { setDetailsOpen(true); }}>{copy.details}</button> : null}
|
|
24
|
+
</div>
|
|
25
|
+
<dl className="astra-output-provenance__summary">
|
|
26
|
+
<div>
|
|
27
|
+
<dt>{copy.status}</dt>
|
|
28
|
+
<dd>
|
|
29
|
+
<span className="astra-output-provenance__status">
|
|
30
|
+
{status ? (
|
|
31
|
+
<span className="astra-output-provenance__icon" data-state={status.state} aria-hidden="true">
|
|
32
|
+
<OutputStatusGlyph state={status.state} />
|
|
33
|
+
</span>
|
|
34
|
+
) : null}
|
|
35
|
+
{stateLabel}
|
|
36
|
+
</span>
|
|
37
|
+
{status?.detail ? <p className="astra-output-provenance__reason">{status.detail}</p> : null}
|
|
38
|
+
</dd>
|
|
39
|
+
</div>
|
|
40
|
+
{run ? <>
|
|
41
|
+
<div>
|
|
42
|
+
<dt>{copy.lastRun}</dt>
|
|
43
|
+
<dd><time dateTime={run.finishedAt}>{finished && !Number.isNaN(finished.getTime()) ? finished.toLocaleString() : run.finishedAt}</time></dd>
|
|
44
|
+
</div>
|
|
45
|
+
<div>
|
|
46
|
+
<dt>{copy.revision}</dt>
|
|
47
|
+
<dd><code title={run.gitRevision}>{run.gitRevision.slice(0, 8)}</code></dd>
|
|
48
|
+
</div>
|
|
49
|
+
</> : null}
|
|
50
|
+
</dl>
|
|
51
|
+
{error ? <p role="alert">{error}</p> : run === undefined ? <p role="status">{copy.loading}</p> : run === null ? <p>{copy.noRun}</p> : null}
|
|
52
|
+
{detailsOpen && run ? (
|
|
53
|
+
<DetailDialog
|
|
54
|
+
mode="modal"
|
|
55
|
+
title={copy.runDetails}
|
|
56
|
+
closeLabel={copy.closeDetails}
|
|
57
|
+
onClose={() => { setDetailsOpen(false); }}
|
|
58
|
+
panelClassName="astra-output-provenance__dialog-panel"
|
|
59
|
+
>
|
|
60
|
+
<div className="astra-output-provenance__details">
|
|
61
|
+
<section>
|
|
62
|
+
<h4>{copy.recipe}</h4>
|
|
63
|
+
<pre><code>{run.recipe}</code></pre>
|
|
64
|
+
</section>
|
|
65
|
+
<section>
|
|
66
|
+
<h4>{copy.inputs}</h4>
|
|
67
|
+
{Object.keys(run.inputVersions).length ? (
|
|
68
|
+
<dl>{Object.entries(run.inputVersions).map(([name, version]) => (
|
|
69
|
+
<div key={name}><dt>{name}</dt><dd><code>{version}</code></dd></div>
|
|
70
|
+
))}</dl>
|
|
71
|
+
) : <p>{copy.noInputs}</p>}
|
|
72
|
+
</section>
|
|
73
|
+
<section>
|
|
74
|
+
<h4>{copy.environment}</h4>
|
|
75
|
+
<p><code>{run.environment}</code></p>
|
|
76
|
+
</section>
|
|
77
|
+
<section>
|
|
78
|
+
<h4>{copy.cliVersion}</h4>
|
|
79
|
+
<p>{run.cliVersion}</p>
|
|
80
|
+
</section>
|
|
81
|
+
</div>
|
|
82
|
+
</DetailDialog>
|
|
83
|
+
) : null}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
});
|