@astra-spec/ui 0.0.5 → 0.0.6

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.
Files changed (161) hide show
  1. package/README.md +47 -4
  2. package/blocks.css +1 -0
  3. package/components.css +6 -0
  4. package/dist/blocks/analysis-tree.d.ts.map +1 -1
  5. package/dist/blocks/analysis-tree.js +4 -7
  6. package/dist/blocks/analysis-tree.js.map +1 -1
  7. package/dist/blocks/decisions-list.d.ts.map +1 -1
  8. package/dist/blocks/decisions-list.js +1 -1
  9. package/dist/blocks/decisions-list.js.map +1 -1
  10. package/dist/blocks/findings-list.d.ts.map +1 -1
  11. package/dist/blocks/findings-list.js +2 -4
  12. package/dist/blocks/findings-list.js.map +1 -1
  13. package/dist/blocks/index.d.ts +2 -4
  14. package/dist/blocks/index.d.ts.map +1 -1
  15. package/dist/blocks/index.js +1 -2
  16. package/dist/blocks/index.js.map +1 -1
  17. package/dist/blocks/outputs-list.d.ts +2 -7
  18. package/dist/blocks/outputs-list.d.ts.map +1 -1
  19. package/dist/blocks/outputs-list.js +11 -21
  20. package/dist/blocks/outputs-list.js.map +1 -1
  21. package/dist/blocks/papers-list.d.ts.map +1 -1
  22. package/dist/blocks/papers-list.js +3 -3
  23. package/dist/blocks/papers-list.js.map +1 -1
  24. package/dist/components/figure-zoom.d.ts +6 -0
  25. package/dist/components/figure-zoom.d.ts.map +1 -0
  26. package/dist/components/figure-zoom.js +28 -0
  27. package/dist/components/figure-zoom.js.map +1 -0
  28. package/dist/components/finding-detail.d.ts +4 -2
  29. package/dist/components/finding-detail.d.ts.map +1 -1
  30. package/dist/components/finding-detail.js +41 -25
  31. package/dist/components/finding-detail.js.map +1 -1
  32. package/dist/components/index.d.ts +9 -0
  33. package/dist/components/index.d.ts.map +1 -1
  34. package/dist/components/index.js +5 -0
  35. package/dist/components/index.js.map +1 -1
  36. package/dist/components/output-card.d.ts +13 -0
  37. package/dist/components/output-card.d.ts.map +1 -0
  38. package/dist/components/output-card.js +12 -0
  39. package/dist/components/output-card.js.map +1 -0
  40. package/dist/components/output-detail.d.ts +6 -2
  41. package/dist/components/output-detail.d.ts.map +1 -1
  42. package/dist/components/output-detail.js +49 -13
  43. package/dist/components/output-detail.js.map +1 -1
  44. package/dist/components/output-dialog.d.ts +6 -1
  45. package/dist/components/output-dialog.d.ts.map +1 -1
  46. package/dist/components/output-dialog.js +2 -2
  47. package/dist/components/output-dialog.js.map +1 -1
  48. package/dist/components/output-entry.d.ts +17 -0
  49. package/dist/components/output-entry.d.ts.map +1 -0
  50. package/dist/components/output-entry.js +21 -0
  51. package/dist/components/output-entry.js.map +1 -0
  52. package/dist/components/output-provenance.d.ts +6 -0
  53. package/dist/components/output-provenance.d.ts.map +1 -0
  54. package/dist/components/output-provenance.js +16 -0
  55. package/dist/components/output-provenance.js.map +1 -0
  56. package/dist/components/output-status.d.ts +8 -0
  57. package/dist/components/output-status.d.ts.map +1 -0
  58. package/dist/components/output-status.js +17 -0
  59. package/dist/components/output-status.js.map +1 -0
  60. package/dist/components/paper-row.d.ts +9 -0
  61. package/dist/components/paper-row.d.ts.map +1 -0
  62. package/dist/components/paper-row.js +11 -0
  63. package/dist/components/paper-row.js.map +1 -0
  64. package/dist/components/record-dialog.d.ts +5 -1
  65. package/dist/components/record-dialog.d.ts.map +1 -1
  66. package/dist/components/record-dialog.js +7 -4
  67. package/dist/components/record-dialog.js.map +1 -1
  68. package/dist/lib/labels.d.ts +34 -2
  69. package/dist/lib/labels.d.ts.map +1 -1
  70. package/dist/lib/labels.js +35 -4
  71. package/dist/lib/labels.js.map +1 -1
  72. package/dist/model/index.d.ts +4 -2
  73. package/dist/model/index.d.ts.map +1 -1
  74. package/dist/model/index.js +1 -1
  75. package/dist/model/index.js.map +1 -1
  76. package/dist/model/kind.d.ts +1 -1
  77. package/dist/model/kind.d.ts.map +1 -1
  78. package/dist/model/kind.js +0 -1
  79. package/dist/model/kind.js.map +1 -1
  80. package/dist/model/output-provenance.d.ts +17 -0
  81. package/dist/model/output-provenance.d.ts.map +1 -0
  82. package/dist/model/output-provenance.js +2 -0
  83. package/dist/model/output-provenance.js.map +1 -0
  84. package/dist/model/output-status.d.ts +17 -0
  85. package/dist/model/output-status.d.ts.map +1 -0
  86. package/dist/model/output-status.js +2 -0
  87. package/dist/model/output-status.js.map +1 -0
  88. package/dist/model/relations.d.ts +37 -12
  89. package/dist/model/relations.d.ts.map +1 -1
  90. package/dist/model/relations.js +76 -23
  91. package/dist/model/relations.js.map +1 -1
  92. package/dist/primitives/dialog.d.ts.map +1 -1
  93. package/dist/primitives/dialog.js +9 -1
  94. package/dist/primitives/dialog.js.map +1 -1
  95. package/dist/primitives/index.d.ts +2 -0
  96. package/dist/primitives/index.d.ts.map +1 -1
  97. package/dist/primitives/index.js +1 -0
  98. package/dist/primitives/index.js.map +1 -1
  99. package/dist/primitives/output-status-glyph.d.ts +8 -0
  100. package/dist/primitives/output-status-glyph.d.ts.map +1 -0
  101. package/dist/primitives/output-status-glyph.js +13 -0
  102. package/dist/primitives/output-status-glyph.js.map +1 -0
  103. package/dist/primitives/tooltip.d.ts +7 -0
  104. package/dist/primitives/tooltip.d.ts.map +1 -0
  105. package/dist/primitives/tooltip.js +31 -0
  106. package/dist/primitives/tooltip.js.map +1 -0
  107. package/dist/views/inventory.d.ts +12 -1
  108. package/dist/views/inventory.d.ts.map +1 -1
  109. package/dist/views/inventory.js +23 -17
  110. package/dist/views/inventory.js.map +1 -1
  111. package/package.json +3 -2
  112. package/primitives.css +1 -0
  113. package/src/blocks/analysis-tree.tsx +4 -30
  114. package/src/blocks/decisions-list.tsx +5 -3
  115. package/src/blocks/findings-list.tsx +8 -7
  116. package/src/blocks/index.ts +2 -4
  117. package/src/blocks/outputs-list.tsx +43 -106
  118. package/src/blocks/papers-list.tsx +2 -18
  119. package/src/components/figure-zoom.tsx +72 -0
  120. package/src/components/finding-detail.tsx +106 -30
  121. package/src/components/index.ts +13 -0
  122. package/src/components/output-card.tsx +51 -0
  123. package/src/components/output-detail.tsx +69 -21
  124. package/src/components/output-dialog.tsx +9 -0
  125. package/src/components/output-entry.tsx +61 -0
  126. package/src/components/output-provenance.tsx +86 -0
  127. package/src/components/output-status.tsx +38 -0
  128. package/src/components/paper-row.tsx +41 -0
  129. package/src/components/record-dialog.tsx +13 -1
  130. package/src/lib/labels.tsx +69 -6
  131. package/src/model/index.ts +6 -2
  132. package/src/model/kind.ts +1 -2
  133. package/src/model/output-provenance.ts +18 -0
  134. package/src/model/output-status.ts +18 -0
  135. package/src/model/relations.ts +92 -26
  136. package/src/primitives/dialog.tsx +7 -1
  137. package/src/primitives/index.ts +2 -0
  138. package/src/primitives/output-status-glyph.tsx +37 -0
  139. package/src/primitives/tooltip.tsx +51 -0
  140. package/src/views/inventory.tsx +54 -22
  141. package/styles/base.css +2 -1
  142. package/styles/blocks/analysis-tree.css +22 -25
  143. package/styles/blocks/findings-list.css +50 -0
  144. package/styles/blocks/outputs-list.css +0 -421
  145. package/styles/blocks/papers-list.css +4 -70
  146. package/styles/components/figure-zoom.css +62 -0
  147. package/styles/components/finding-detail.css +62 -0
  148. package/styles/components/output-card.css +290 -0
  149. package/styles/components/output-detail.css +91 -3
  150. package/styles/components/output-entry.css +141 -0
  151. package/styles/components/output-provenance.css +94 -0
  152. package/styles/components/output-status.css +31 -0
  153. package/styles/components/paper-row.css +72 -0
  154. package/styles/primitives/dialog.css +4 -22
  155. package/styles/primitives/tooltip.css +22 -0
  156. package/styles/views/inventory.css +35 -2
  157. package/dist/blocks/prior-insights-list.d.ts +0 -9
  158. package/dist/blocks/prior-insights-list.d.ts.map +0 -1
  159. package/dist/blocks/prior-insights-list.js +0 -29
  160. package/dist/blocks/prior-insights-list.js.map +0 -1
  161. package/src/blocks/prior-insights-list.tsx +0 -52
@@ -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 active = analysis.canonicalPath === selectedPath;
25
+ const title = analysisTitle(analysis);
49
26
  return (
50
27
  <li>
51
28
  <button
52
29
  type="button"
53
- style={{ paddingInlineStart: `${Math.min(depth, 4) * 1.25}rem` }}
54
- aria-current={active ? 'page' : undefined}
30
+ className="astra-analysis-tree__select"
31
+ aria-current={analysis.canonicalPath === selectedPath ? 'page' : undefined}
55
32
  onClick={() => { onSelectAnalysis(analysis.canonicalPath); }}
56
33
  >
57
- <ProjectDocumentIcon />
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
- <span className="astra-record-list__tag">
100
- {record.tags?.[0] ? decisionTagLabel(record.tags[0], tagLabels) : '—'}
101
- </span>,
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(18rem, 1fr) 7rem 1.5rem"
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" data-variant="claim">
46
+ <span className="astra-record-list__name astra-findings-list__entry">
48
47
  <KindGlyph className="astra-record-list__glyph" kind="finding" />
49
- <span>
50
- {record.label ? <small>{record.label}</small> : null}
51
- <strong>{record.claim}</strong>
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
  };
@@ -8,15 +8,13 @@ export type {
8
8
  InventoryRecordsProps,
9
9
  InventorySectionProps,
10
10
  } from './section.js';
11
- export { OutputCard, OutputsList } from './outputs-list.js';
12
- export type { OutputCardProps, OutputsListProps } from './outputs-list.js';
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 { OutputPreview } from '../components/output-detail.js';
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
- export interface OutputCardProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'children'> {
17
- output: ResolvedOutput;
18
- renderArtifact?: ArtifactRenderer | undefined;
19
- onOpen: () => void;
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
- <ul className="astra-inventory-outputs__compact-grid" data-layout={outputs[0]?.type === 'metric' ? 'tiles' : 'grid'}>
106
- {outputs.map((output) => {
107
- const metric = output.type === 'metric';
108
- const status = !output.active ? 'Inactive' : !output.artifact ? 'Not yet generated' : undefined;
109
- return (
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
- <button
112
- type="button"
113
- className="astra-output-entry"
114
- data-kind={metric ? 'metric' : 'file'}
115
- aria-label={`Open ${output.type}: ${recordTitle(output)}`}
116
- onClick={() => { onOpen(output); }}
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
- </ul>
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
- <OutputGallery title="Figures" outputs={figures} renderArtifact={renderArtifact} onOpen={open} />
161
- <OutputGallery title="Tables" outputs={tables} renderArtifact={renderArtifact} onOpen={open} />
162
- <CompactOutputs title="Metrics" outputs={metrics} renderArtifact={renderArtifact} onOpen={open} />
163
- <CompactOutputs title="Output files" outputs={files} onOpen={open} />
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
- <button
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
+ }
@@ -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 { findingLiterature, type FindingEvidenceLink } from '../model/relations.js';
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 { RelationList } from '../primitives/relation-list.js';
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
- /** Notes, the supporting results a finding cites, and its literature sources. */
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
- <RelationList
43
- className="astra-finding-detail__results"
44
- title="Supporting results"
45
- empty="No supporting results are linked to this finding."
46
- items={evidence.map((item, index) => {
47
- const title = item.output
48
- ? recordTitle(item.output)
49
- : item.evidence.artifact ?? `Result ${index + 1}`;
50
- const { output, analysis } = item;
51
- return {
52
- key: `${item.evidence.resolvedOutputPath ?? item.evidence.artifact ?? 'result'}-${index}`,
53
- label: title,
54
- identifier: output?.canonicalPath ?? item.evidence.artifact,
55
- detail: output?.type ?? 'Unavailable',
56
- kind: 'output' as const,
57
- accessibleLabel: output ? `View supporting result: ${title}` : undefined,
58
- onOpen: output && analysis && onOpenRecord ? () => { onOpenRecord(output, analysis); } : undefined,
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.claim}
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
  }
@@ -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';