@astra-spec/ui 0.0.2 → 0.0.4
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 +231 -20
- package/TOKENS.md +10 -3
- package/components.css +2 -0
- package/dist/blocks/decisions-list.d.ts +0 -1
- package/dist/blocks/decisions-list.d.ts.map +1 -1
- package/dist/blocks/decisions-list.js +1 -5
- package/dist/blocks/decisions-list.js.map +1 -1
- package/dist/blocks/index.d.ts +3 -3
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +2 -2
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/inputs-list.js +1 -1
- package/dist/blocks/inputs-list.js.map +1 -1
- package/dist/blocks/outputs-list.d.ts +2 -2
- package/dist/blocks/outputs-list.d.ts.map +1 -1
- package/dist/blocks/outputs-list.js +15 -19
- package/dist/blocks/outputs-list.js.map +1 -1
- package/dist/blocks/section.d.ts +1 -4
- package/dist/blocks/section.d.ts.map +1 -1
- package/dist/blocks/section.js +1 -12
- package/dist/blocks/section.js.map +1 -1
- package/dist/components/artifact-preview.d.ts +2 -54
- package/dist/components/artifact-preview.d.ts.map +1 -1
- package/dist/components/artifact-preview.js +2 -107
- package/dist/components/artifact-preview.js.map +1 -1
- package/dist/components/decision-detail.d.ts +1 -1
- package/dist/components/decision-detail.d.ts.map +1 -1
- package/dist/components/decision-detail.js.map +1 -1
- package/dist/components/finding-detail.d.ts +2 -2
- package/dist/components/finding-detail.d.ts.map +1 -1
- package/dist/components/finding-detail.js.map +1 -1
- package/dist/components/index.d.ts +11 -13
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +7 -8
- package/dist/components/index.js.map +1 -1
- package/dist/components/input-detail.d.ts +1 -2
- package/dist/components/input-detail.d.ts.map +1 -1
- package/dist/components/input-detail.js +0 -3
- package/dist/components/input-detail.js.map +1 -1
- package/dist/components/insight-detail.d.ts +2 -8
- package/dist/components/insight-detail.d.ts.map +1 -1
- package/dist/components/insight-detail.js +5 -11
- package/dist/components/insight-detail.js.map +1 -1
- package/dist/components/insight-trigger.d.ts +1 -1
- package/dist/components/insight-trigger.d.ts.map +1 -1
- package/dist/components/insight-trigger.js.map +1 -1
- package/dist/components/output-detail.d.ts +2 -7
- package/dist/components/output-detail.d.ts.map +1 -1
- package/dist/components/output-detail.js +3 -30
- package/dist/components/output-detail.js.map +1 -1
- package/dist/components/output-dialog.d.ts +2 -2
- package/dist/components/output-dialog.d.ts.map +1 -1
- package/dist/components/output-dialog.js +2 -1
- package/dist/components/output-dialog.js.map +1 -1
- package/dist/components/paper-detail.d.ts +14 -14
- package/dist/components/paper-detail.d.ts.map +1 -1
- package/dist/components/paper-detail.js +49 -29
- package/dist/components/paper-detail.js.map +1 -1
- package/dist/components/paper-pdf-viewer.d.ts +19 -0
- package/dist/components/paper-pdf-viewer.d.ts.map +1 -0
- package/dist/components/paper-pdf-viewer.js +250 -0
- package/dist/components/paper-pdf-viewer.js.map +1 -0
- package/dist/components/record-dialog.d.ts +7 -5
- package/dist/components/record-dialog.d.ts.map +1 -1
- package/dist/components/record-dialog.js +7 -5
- package/dist/components/record-dialog.js.map +1 -1
- package/dist/components/record-preview.d.ts +61 -0
- package/dist/components/record-preview.d.ts.map +1 -0
- package/dist/components/record-preview.js +177 -0
- package/dist/components/record-preview.js.map +1 -0
- package/dist/components/relation-items.d.ts +1 -1
- package/dist/components/relation-items.d.ts.map +1 -1
- package/dist/components/relation-items.js +10 -3
- package/dist/components/relation-items.js.map +1 -1
- package/dist/{components/use-detail-stack.d.ts → lib/detail-stack.d.ts} +17 -2
- package/dist/lib/detail-stack.d.ts.map +1 -0
- package/dist/{components/use-detail-stack.js → lib/detail-stack.js} +15 -2
- package/dist/lib/detail-stack.js.map +1 -0
- package/dist/lib/index.d.ts +14 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/labels.d.ts +32 -0
- package/dist/lib/labels.d.ts.map +1 -1
- package/dist/lib/labels.js +32 -0
- package/dist/lib/labels.js.map +1 -1
- package/dist/lib/pdf-quote.d.ts +47 -0
- package/dist/lib/pdf-quote.d.ts.map +1 -0
- package/dist/lib/pdf-quote.js +154 -0
- package/dist/lib/pdf-quote.js.map +1 -0
- package/dist/lib/pdf-runtime.d.ts +102 -0
- package/dist/lib/pdf-runtime.d.ts.map +1 -0
- package/dist/lib/pdf-runtime.js +48 -0
- package/dist/lib/pdf-runtime.js.map +1 -0
- package/dist/lib/preview-data.d.ts +55 -0
- package/dist/lib/preview-data.d.ts.map +1 -0
- package/dist/lib/preview-data.js +108 -0
- package/dist/lib/preview-data.js.map +1 -0
- package/dist/lib/prose.d.ts +37 -0
- package/dist/lib/prose.d.ts.map +1 -0
- package/dist/lib/prose.js +60 -0
- package/dist/lib/prose.js.map +1 -0
- package/dist/lib/use-isomorphic-layout-effect.d.ts +4 -0
- package/dist/lib/use-isomorphic-layout-effect.d.ts.map +1 -0
- package/dist/lib/use-isomorphic-layout-effect.js +4 -0
- package/dist/lib/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/lib/use-output-expanded.d.ts +7 -0
- package/dist/lib/use-output-expanded.d.ts.map +1 -0
- package/dist/lib/use-output-expanded.js +29 -0
- package/dist/lib/use-output-expanded.js.map +1 -0
- package/dist/model/index.d.ts +5 -3
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -2
- package/dist/model/index.js.map +1 -1
- package/dist/{primitives → model}/kind.d.ts +3 -0
- package/dist/model/kind.d.ts.map +1 -0
- package/dist/model/kind.js +25 -0
- package/dist/model/kind.js.map +1 -0
- package/dist/model/papers.d.ts +6 -6
- package/dist/model/papers.d.ts.map +1 -1
- package/dist/model/papers.js +8 -0
- package/dist/model/papers.js.map +1 -1
- package/dist/model/records.d.ts +5 -1
- package/dist/model/records.d.ts.map +1 -1
- package/dist/model/records.js +9 -0
- package/dist/model/records.js.map +1 -1
- package/dist/primitives/badge.d.ts +1 -1
- package/dist/primitives/badge.d.ts.map +1 -1
- package/dist/primitives/button.js +1 -1
- package/dist/primitives/button.js.map +1 -1
- package/dist/primitives/dialog.d.ts +1 -1
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +3 -3
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/index.d.ts +6 -9
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +3 -5
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/preview-popover.d.ts +30 -0
- package/dist/primitives/preview-popover.d.ts.map +1 -0
- package/dist/primitives/preview-popover.js +132 -0
- package/dist/primitives/preview-popover.js.map +1 -0
- package/dist/primitives/prose.d.ts +1 -29
- package/dist/primitives/prose.d.ts.map +1 -1
- package/dist/primitives/prose.js +2 -50
- package/dist/primitives/prose.js.map +1 -1
- package/dist/primitives/record-list.d.ts +1 -1
- package/dist/primitives/record-list.d.ts.map +1 -1
- package/dist/primitives/record-list.js +1 -1
- package/dist/primitives/record-list.js.map +1 -1
- package/dist/primitives/relation-list.d.ts +1 -1
- package/dist/primitives/relation-list.d.ts.map +1 -1
- package/dist/primitives/relation-list.js +1 -1
- package/dist/primitives/relation-list.js.map +1 -1
- package/dist/primitives/slot.d.ts.map +1 -0
- package/dist/{lib → primitives}/slot.js +1 -1
- package/dist/primitives/slot.js.map +1 -0
- package/dist/primitives/surface-header.d.ts +1 -1
- package/dist/primitives/surface-header.d.ts.map +1 -1
- package/dist/views/inventory.d.ts +7 -5
- package/dist/views/inventory.d.ts.map +1 -1
- package/dist/views/inventory.js +5 -4
- package/dist/views/inventory.js.map +1 -1
- package/package.json +12 -1
- package/primitives.css +1 -0
- package/src/blocks/decisions-list.tsx +1 -6
- package/src/blocks/index.ts +2 -3
- package/src/blocks/inputs-list.tsx +1 -1
- package/src/blocks/outputs-list.tsx +53 -30
- package/src/blocks/section.tsx +1 -14
- package/src/components/artifact-preview.tsx +6 -161
- package/src/components/decision-detail.tsx +2 -1
- package/src/components/finding-detail.tsx +3 -2
- package/src/components/index.ts +19 -29
- package/src/components/input-detail.tsx +2 -5
- package/src/components/insight-detail.tsx +20 -35
- package/src/components/insight-trigger.tsx +2 -1
- package/src/components/output-detail.tsx +17 -38
- package/src/components/output-dialog.tsx +4 -3
- package/src/components/paper-detail.tsx +121 -66
- package/src/components/paper-pdf-viewer.tsx +319 -0
- package/src/components/record-dialog.tsx +15 -10
- package/src/components/record-preview.tsx +762 -0
- package/src/components/relation-items.ts +15 -5
- package/src/{components/use-detail-stack.ts → lib/detail-stack.ts} +24 -1
- package/src/lib/index.ts +22 -0
- package/src/lib/labels.tsx +67 -0
- package/src/lib/pdf-quote.ts +189 -0
- package/src/lib/pdf-runtime.ts +131 -0
- package/src/lib/preview-data.ts +155 -0
- package/src/lib/prose.tsx +87 -0
- package/src/lib/use-isomorphic-layout-effect.ts +4 -0
- package/src/lib/use-output-expanded.ts +27 -0
- package/src/model/index.ts +4 -2
- package/src/{primitives → model}/kind.ts +14 -0
- package/src/model/papers.ts +9 -7
- package/src/model/records.ts +12 -0
- package/src/primitives/badge.tsx +1 -1
- package/src/primitives/button.tsx +1 -1
- package/src/primitives/dialog.tsx +3 -5
- package/src/primitives/index.ts +9 -9
- package/src/primitives/preview-popover.tsx +278 -0
- package/src/primitives/prose.tsx +1 -63
- package/src/primitives/record-list.tsx +1 -1
- package/src/primitives/relation-list.tsx +1 -1
- package/src/{lib → primitives}/slot.tsx +1 -1
- package/src/primitives/surface-header.tsx +1 -1
- package/src/views/inventory.tsx +12 -8
- package/styles/blocks/analysis-tree.css +2 -2
- package/styles/blocks/decisions-list.css +4 -4
- package/styles/blocks/outputs-list.css +246 -19
- package/styles/blocks/papers-list.css +2 -2
- package/styles/components/artifact-preview.css +6 -6
- package/styles/components/decision-detail.css +2 -2
- package/styles/components/evidence.css +2 -2
- package/styles/components/input-detail.css +4 -4
- package/styles/components/insight-detail.css +56 -94
- package/styles/components/insight-list.css +3 -3
- package/styles/components/insight-trigger.css +1 -4
- package/styles/components/output-detail.css +25 -140
- package/styles/components/paper-detail.css +76 -95
- package/styles/components/paper-doi.css +3 -12
- package/styles/components/paper-pdf-viewer.css +120 -0
- package/styles/components/record-preview.css +316 -0
- package/styles/primitives/badge.css +1 -1
- package/styles/primitives/count-heading.css +2 -2
- package/styles/primitives/detail-layout.css +5 -5
- package/styles/primitives/dialog.css +9 -9
- package/styles/primitives/preview-popover.css +76 -0
- package/styles/primitives/record-list.css +17 -17
- package/styles/primitives/relation-list.css +6 -6
- package/styles/primitives/surface-header.css +5 -5
- package/styles/tokens.css +16 -3
- package/styles/views/inventory.css +3 -3
- package/dist/components/detail-entry.d.ts +0 -15
- package/dist/components/detail-entry.d.ts.map +0 -1
- package/dist/components/detail-entry.js +0 -14
- package/dist/components/detail-entry.js.map +0 -1
- package/dist/components/use-detail-stack.d.ts.map +0 -1
- package/dist/components/use-detail-stack.js.map +0 -1
- package/dist/lib/slot.d.ts.map +0 -1
- package/dist/lib/slot.js.map +0 -1
- package/dist/primitives/kind.d.ts.map +0 -1
- package/dist/primitives/kind.js +0 -14
- package/dist/primitives/kind.js.map +0 -1
- package/src/components/detail-entry.ts +0 -19
- /package/dist/{lib → primitives}/slot.d.ts +0 -0
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnalysisIndex,
|
|
3
|
+
ResolvedAnalysisDocument,
|
|
4
|
+
ResolvedAnalysisNode,
|
|
5
|
+
ResolvedDecision,
|
|
6
|
+
ResolvedEvidence,
|
|
7
|
+
ResolvedInput,
|
|
8
|
+
ResolvedInsight,
|
|
9
|
+
ResolvedOutput,
|
|
10
|
+
ResolvedRecord,
|
|
11
|
+
} from '@astra-spec/sdk';
|
|
12
|
+
import {
|
|
13
|
+
forwardRef,
|
|
14
|
+
type HTMLAttributes,
|
|
15
|
+
type ReactElement,
|
|
16
|
+
type ReactNode,
|
|
17
|
+
} from 'react';
|
|
18
|
+
import { cn } from '../lib/cn.js';
|
|
19
|
+
import { useLabels } from '../lib/labels.js';
|
|
20
|
+
import { doiHref } from '../model/doi.js';
|
|
21
|
+
import { analysisTitle, recordTitle } from '../model/records.js';
|
|
22
|
+
import { decisionInsights } from '../model/relations.js';
|
|
23
|
+
import { Prose } from '../primitives/prose.js';
|
|
24
|
+
import type { TextRenderer } from '../lib/prose.js';
|
|
25
|
+
import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
|
|
26
|
+
import { SurfaceHeader } from '../primitives/surface-header.js';
|
|
27
|
+
import type { ArtifactRenderer } from './artifact-preview.js';
|
|
28
|
+
import { primaryLiteratureEvidence } from '../model/papers.js';
|
|
29
|
+
import type { OpenRecordHandler } from '../lib/detail-stack.js';
|
|
30
|
+
|
|
31
|
+
export interface RecordPreviewTarget {
|
|
32
|
+
record: ResolvedRecord;
|
|
33
|
+
analysis: ResolvedAnalysisNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RecordPreviewReference {
|
|
37
|
+
target: RecordPreviewTarget;
|
|
38
|
+
/** Default record trigger. A host may wrap it in another PreviewPopover. */
|
|
39
|
+
trigger: ReactElement;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type RecordPreviewReferenceRenderer = (
|
|
43
|
+
reference: RecordPreviewReference,
|
|
44
|
+
) => ReactNode;
|
|
45
|
+
|
|
46
|
+
export interface RecordPreviewCitationContext {
|
|
47
|
+
evidence: ResolvedEvidence;
|
|
48
|
+
record: ResolvedInsight;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type RecordPreviewCitationRenderer = (
|
|
52
|
+
doi: string,
|
|
53
|
+
context: RecordPreviewCitationContext,
|
|
54
|
+
) => ReactNode;
|
|
55
|
+
|
|
56
|
+
export type RecordPreviewEntry =
|
|
57
|
+
| {
|
|
58
|
+
kind: 'record';
|
|
59
|
+
record: ResolvedRecord;
|
|
60
|
+
analysis: ResolvedAnalysisNode;
|
|
61
|
+
}
|
|
62
|
+
| {
|
|
63
|
+
kind: 'analysis';
|
|
64
|
+
analysis: ResolvedAnalysisNode;
|
|
65
|
+
href?: string | undefined;
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
kind: 'value';
|
|
69
|
+
record: ResolvedOutput | ResolvedDecision;
|
|
70
|
+
analysis: ResolvedAnalysisNode;
|
|
71
|
+
value: ReactNode;
|
|
72
|
+
unit?: string | undefined;
|
|
73
|
+
column?: string | undefined;
|
|
74
|
+
filter?: string | undefined;
|
|
75
|
+
product?: string | undefined;
|
|
76
|
+
selection?: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export interface RecordPreviewProps
|
|
80
|
+
extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
81
|
+
entry: RecordPreviewEntry;
|
|
82
|
+
document: ResolvedAnalysisDocument;
|
|
83
|
+
index: AnalysisIndex;
|
|
84
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
85
|
+
renderText?: TextRenderer | undefined;
|
|
86
|
+
renderCitation?: RecordPreviewCitationRenderer | undefined;
|
|
87
|
+
/** Opens the full record surface when a related-record trigger is activated. */
|
|
88
|
+
onOpenRecord?: OpenRecordHandler | undefined;
|
|
89
|
+
/** Optional navigation for an analysis preview. The callback receives only a safe HTTP(S) or relative href. */
|
|
90
|
+
onOpenAnalysis?: ((analysis: ResolvedAnalysisNode, href?: string) => void) | undefined;
|
|
91
|
+
/** Wraps related-record triggers, for example in a nested PreviewPopover. */
|
|
92
|
+
renderRecordReference?: RecordPreviewReferenceRenderer | undefined;
|
|
93
|
+
/** Compact decision previews show this many supporting insights before a remaining count. */
|
|
94
|
+
maxSupportingInsights?: number | undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function claimExcerpt(claim: string): string {
|
|
98
|
+
const text = claim.trim().replace(/\s+/g, ' ');
|
|
99
|
+
const sentence = /^.{10,90}?[.!?](?=\s|$)/.exec(text)?.[0];
|
|
100
|
+
if (sentence) return sentence;
|
|
101
|
+
if (text.length <= 90) return text;
|
|
102
|
+
return `${text.slice(0, 80).replace(/\s+\S*$/, '')}…`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function relationTitle(record: ResolvedRecord): string {
|
|
106
|
+
if (
|
|
107
|
+
(record.kind === 'finding' || record.kind === 'prior_insight') &&
|
|
108
|
+
!record.label
|
|
109
|
+
) {
|
|
110
|
+
return claimExcerpt(record.claim) || record.id;
|
|
111
|
+
}
|
|
112
|
+
return recordTitle(record);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function KindEyebrow({ kind, label }: { kind: SurfaceKind; label: ReactNode }) {
|
|
116
|
+
return (
|
|
117
|
+
<span className="astra-record-preview__kind">
|
|
118
|
+
<span aria-hidden="true">{surfaceGlyph(kind)}</span>
|
|
119
|
+
{label}
|
|
120
|
+
</span>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function PreviewHeader({
|
|
125
|
+
kind,
|
|
126
|
+
kindLabel,
|
|
127
|
+
title,
|
|
128
|
+
}: {
|
|
129
|
+
kind: SurfaceKind;
|
|
130
|
+
kindLabel: ReactNode;
|
|
131
|
+
title?: ReactNode | undefined;
|
|
132
|
+
}) {
|
|
133
|
+
return (
|
|
134
|
+
<SurfaceHeader
|
|
135
|
+
density="compact"
|
|
136
|
+
kind={kind}
|
|
137
|
+
titleAs="h3"
|
|
138
|
+
eyebrow={<KindEyebrow kind={kind} label={kindLabel} />}
|
|
139
|
+
title={title}
|
|
140
|
+
className="astra-record-preview__header"
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function Citation({
|
|
146
|
+
evidence,
|
|
147
|
+
record,
|
|
148
|
+
renderCitation,
|
|
149
|
+
}: {
|
|
150
|
+
evidence: ResolvedEvidence;
|
|
151
|
+
record: ResolvedInsight;
|
|
152
|
+
renderCitation?: RecordPreviewCitationRenderer | undefined;
|
|
153
|
+
}) {
|
|
154
|
+
const doi = evidence.doi;
|
|
155
|
+
if (!doi) return null;
|
|
156
|
+
return (
|
|
157
|
+
<div className="astra-record-preview__citation">
|
|
158
|
+
{renderCitation ? (
|
|
159
|
+
renderCitation(doi, { evidence, record })
|
|
160
|
+
) : (
|
|
161
|
+
<a href={doiHref(doi)} target="_blank" rel="noreferrer">
|
|
162
|
+
{doi} <span aria-hidden="true">↗</span>
|
|
163
|
+
</a>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function RelatedRecord({
|
|
170
|
+
record,
|
|
171
|
+
index,
|
|
172
|
+
onOpenRecord,
|
|
173
|
+
renderRecordReference,
|
|
174
|
+
detail,
|
|
175
|
+
}: {
|
|
176
|
+
record: ResolvedRecord;
|
|
177
|
+
index: AnalysisIndex;
|
|
178
|
+
onOpenRecord?: OpenRecordHandler | undefined;
|
|
179
|
+
renderRecordReference?: RecordPreviewReferenceRenderer | undefined;
|
|
180
|
+
detail?: ReactNode | undefined;
|
|
181
|
+
}) {
|
|
182
|
+
const labels = useLabels();
|
|
183
|
+
const analysis = index.analysisByRecordPath.get(record.canonicalPath);
|
|
184
|
+
const label = relationTitle(record);
|
|
185
|
+
const copy = (
|
|
186
|
+
<>
|
|
187
|
+
<span className="astra-record-preview__relation-glyph" aria-hidden="true">
|
|
188
|
+
{surfaceGlyph(record.kind)}
|
|
189
|
+
</span>
|
|
190
|
+
<span className="astra-record-preview__relation-label">{label}</span>
|
|
191
|
+
{detail != null ? (
|
|
192
|
+
<small className="astra-record-preview__relation-detail">{detail}</small>
|
|
193
|
+
) : null}
|
|
194
|
+
</>
|
|
195
|
+
);
|
|
196
|
+
const trigger = analysis && onOpenRecord ? (
|
|
197
|
+
<button
|
|
198
|
+
type="button"
|
|
199
|
+
className="astra-record-preview__relation-trigger"
|
|
200
|
+
data-kind={record.kind}
|
|
201
|
+
aria-label={labels.preview.openRecord(labels.kinds[record.kind], label)}
|
|
202
|
+
onClick={() => {
|
|
203
|
+
onOpenRecord(record, analysis);
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
{copy}
|
|
207
|
+
</button>
|
|
208
|
+
) : (
|
|
209
|
+
<span className="astra-record-preview__relation-trigger" data-kind={record.kind}>
|
|
210
|
+
{copy}
|
|
211
|
+
</span>
|
|
212
|
+
);
|
|
213
|
+
if (!analysis || !renderRecordReference) return trigger;
|
|
214
|
+
return renderRecordReference({ target: { record, analysis }, trigger });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
interface SharedPreviewProps {
|
|
218
|
+
document: ResolvedAnalysisDocument;
|
|
219
|
+
index: AnalysisIndex;
|
|
220
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
221
|
+
renderText?: TextRenderer | undefined;
|
|
222
|
+
renderCitation?: RecordPreviewCitationRenderer | undefined;
|
|
223
|
+
onOpenRecord?: OpenRecordHandler | undefined;
|
|
224
|
+
renderRecordReference?: RecordPreviewReferenceRenderer | undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function DecisionPreview({
|
|
228
|
+
record,
|
|
229
|
+
index,
|
|
230
|
+
renderText,
|
|
231
|
+
onOpenRecord,
|
|
232
|
+
renderRecordReference,
|
|
233
|
+
maxSupportingInsights,
|
|
234
|
+
}: SharedPreviewProps & {
|
|
235
|
+
record: ResolvedDecision;
|
|
236
|
+
maxSupportingInsights: number;
|
|
237
|
+
}) {
|
|
238
|
+
const labels = useLabels();
|
|
239
|
+
const supporting = decisionInsights(index, record);
|
|
240
|
+
const shown = supporting.slice(0, maxSupportingInsights);
|
|
241
|
+
const remaining = supporting.length - shown.length;
|
|
242
|
+
return (
|
|
243
|
+
<>
|
|
244
|
+
<PreviewHeader
|
|
245
|
+
kind="decision"
|
|
246
|
+
kindLabel={labels.kinds.decision}
|
|
247
|
+
title={recordTitle(record)}
|
|
248
|
+
/>
|
|
249
|
+
<div className="astra-record-preview__body">
|
|
250
|
+
{record.rationale ? (
|
|
251
|
+
<div className="astra-record-preview__description">
|
|
252
|
+
<Prose
|
|
253
|
+
text={record.rationale}
|
|
254
|
+
field="rationale"
|
|
255
|
+
renderText={renderText}
|
|
256
|
+
/>
|
|
257
|
+
</div>
|
|
258
|
+
) : null}
|
|
259
|
+
{record.options.length ? (
|
|
260
|
+
<section className="astra-record-preview__section">
|
|
261
|
+
<h4>{labels.preview.optionDetail}</h4>
|
|
262
|
+
<ul className="astra-record-preview__options">
|
|
263
|
+
{record.options.map((option) => {
|
|
264
|
+
const selected = option.id === record.selectedOptionId;
|
|
265
|
+
return (
|
|
266
|
+
<li
|
|
267
|
+
key={option.id}
|
|
268
|
+
data-selected={selected ? '' : undefined}
|
|
269
|
+
data-unselected={selected ? undefined : ''}
|
|
270
|
+
data-excluded={option.excluded ? '' : undefined}
|
|
271
|
+
>
|
|
272
|
+
<span aria-hidden="true">{selected ? '●' : '○'}</span>
|
|
273
|
+
<span className="astra-record-preview__option-status">
|
|
274
|
+
{labels.preview.optionStatus(selected, Boolean(option.excluded))}
|
|
275
|
+
</span>
|
|
276
|
+
<strong>{option.label}</strong>
|
|
277
|
+
</li>
|
|
278
|
+
);
|
|
279
|
+
})}
|
|
280
|
+
</ul>
|
|
281
|
+
</section>
|
|
282
|
+
) : null}
|
|
283
|
+
{supporting.length ? (
|
|
284
|
+
<section className="astra-record-preview__section">
|
|
285
|
+
<h4>{labels.preview.supportedBy}</h4>
|
|
286
|
+
<ul className="astra-record-preview__relations">
|
|
287
|
+
{shown.map((insight) => (
|
|
288
|
+
<li key={insight.canonicalPath} data-kind={insight.kind}>
|
|
289
|
+
<RelatedRecord
|
|
290
|
+
record={insight}
|
|
291
|
+
index={index}
|
|
292
|
+
onOpenRecord={onOpenRecord}
|
|
293
|
+
renderRecordReference={renderRecordReference}
|
|
294
|
+
/>
|
|
295
|
+
</li>
|
|
296
|
+
))}
|
|
297
|
+
{remaining > 0 ? (
|
|
298
|
+
<li className="astra-record-preview__remaining">
|
|
299
|
+
{labels.preview.remainingDecisionDetails(remaining)}
|
|
300
|
+
</li>
|
|
301
|
+
) : null}
|
|
302
|
+
</ul>
|
|
303
|
+
</section>
|
|
304
|
+
) : null}
|
|
305
|
+
</div>
|
|
306
|
+
</>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function FindingPreview({
|
|
311
|
+
record,
|
|
312
|
+
index,
|
|
313
|
+
renderArtifact,
|
|
314
|
+
renderText,
|
|
315
|
+
renderCitation,
|
|
316
|
+
onOpenRecord,
|
|
317
|
+
renderRecordReference,
|
|
318
|
+
}: SharedPreviewProps & { record: ResolvedInsight }) {
|
|
319
|
+
const labels = useLabels();
|
|
320
|
+
return (
|
|
321
|
+
<>
|
|
322
|
+
<PreviewHeader
|
|
323
|
+
kind="finding"
|
|
324
|
+
kindLabel={labels.kinds.finding}
|
|
325
|
+
title={recordTitle(record)}
|
|
326
|
+
/>
|
|
327
|
+
<div className="astra-record-preview__body">
|
|
328
|
+
<div className="astra-record-preview__claim">
|
|
329
|
+
<Prose text={record.claim} field="claim" renderText={renderText} />
|
|
330
|
+
</div>
|
|
331
|
+
{record.scope ? (
|
|
332
|
+
<span className="astra-record-preview__scope">
|
|
333
|
+
<Prose text={record.scope} renderText={renderText} />
|
|
334
|
+
</span>
|
|
335
|
+
) : null}
|
|
336
|
+
{record.notes ? (
|
|
337
|
+
<div className="astra-record-preview__description">
|
|
338
|
+
<Prose text={record.notes} field="notes" renderText={renderText} />
|
|
339
|
+
</div>
|
|
340
|
+
) : null}
|
|
341
|
+
{record.evidence.length ? (
|
|
342
|
+
<section className="astra-record-preview__section">
|
|
343
|
+
<h4>{labels.preview.evidence}</h4>
|
|
344
|
+
<ul className="astra-record-preview__evidence">
|
|
345
|
+
{record.evidence.map((evidence, indexInRecord) => {
|
|
346
|
+
const candidate = evidence.resolvedOutputPath
|
|
347
|
+
? index.recordByPath.get(evidence.resolvedOutputPath)
|
|
348
|
+
: undefined;
|
|
349
|
+
const output = candidate?.kind === 'output' ? candidate : undefined;
|
|
350
|
+
const artifact = output && renderArtifact
|
|
351
|
+
? renderArtifact(output, { compact: true })
|
|
352
|
+
: null;
|
|
353
|
+
return (
|
|
354
|
+
<li key={`${evidence.id}-${indexInRecord}`}>
|
|
355
|
+
{artifact != null ? (
|
|
356
|
+
<div className="astra-record-preview__artifact">
|
|
357
|
+
{artifact}
|
|
358
|
+
</div>
|
|
359
|
+
) : null}
|
|
360
|
+
{output ? (
|
|
361
|
+
<RelatedRecord
|
|
362
|
+
record={output}
|
|
363
|
+
index={index}
|
|
364
|
+
detail={output.type}
|
|
365
|
+
onOpenRecord={onOpenRecord}
|
|
366
|
+
renderRecordReference={renderRecordReference}
|
|
367
|
+
/>
|
|
368
|
+
) : evidence.artifact ? (
|
|
369
|
+
<span
|
|
370
|
+
className="astra-record-preview__relation-trigger"
|
|
371
|
+
data-kind="output"
|
|
372
|
+
>
|
|
373
|
+
<span
|
|
374
|
+
className="astra-record-preview__relation-glyph"
|
|
375
|
+
aria-hidden="true"
|
|
376
|
+
>
|
|
377
|
+
{surfaceGlyph('output')}
|
|
378
|
+
</span>
|
|
379
|
+
<span className="astra-record-preview__relation-label">
|
|
380
|
+
{evidence.artifact}
|
|
381
|
+
</span>
|
|
382
|
+
</span>
|
|
383
|
+
) : null}
|
|
384
|
+
{evidence.quote ? (
|
|
385
|
+
<blockquote className="astra-record-preview__quote">
|
|
386
|
+
<Prose
|
|
387
|
+
text={evidence.quote.exact}
|
|
388
|
+
field="quote"
|
|
389
|
+
renderText={renderText}
|
|
390
|
+
/>
|
|
391
|
+
</blockquote>
|
|
392
|
+
) : null}
|
|
393
|
+
<Citation
|
|
394
|
+
evidence={evidence}
|
|
395
|
+
record={record}
|
|
396
|
+
renderCitation={renderCitation}
|
|
397
|
+
/>
|
|
398
|
+
</li>
|
|
399
|
+
);
|
|
400
|
+
})}
|
|
401
|
+
</ul>
|
|
402
|
+
</section>
|
|
403
|
+
) : null}
|
|
404
|
+
</div>
|
|
405
|
+
</>
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function InsightPreview({
|
|
410
|
+
record,
|
|
411
|
+
renderText,
|
|
412
|
+
renderCitation,
|
|
413
|
+
}: SharedPreviewProps & { record: ResolvedInsight }) {
|
|
414
|
+
const labels = useLabels();
|
|
415
|
+
const source = primaryLiteratureEvidence(record);
|
|
416
|
+
return (
|
|
417
|
+
<>
|
|
418
|
+
<PreviewHeader
|
|
419
|
+
kind="prior_insight"
|
|
420
|
+
kindLabel={labels.kinds.prior_insight}
|
|
421
|
+
/>
|
|
422
|
+
<div className="astra-record-preview__body">
|
|
423
|
+
<div className="astra-record-preview__description">
|
|
424
|
+
<Prose text={record.claim} field="claim" renderText={renderText} />
|
|
425
|
+
</div>
|
|
426
|
+
{source?.quote ? (
|
|
427
|
+
<blockquote className="astra-record-preview__quote">
|
|
428
|
+
<Prose
|
|
429
|
+
text={source.quote.exact}
|
|
430
|
+
field="quote"
|
|
431
|
+
renderText={renderText}
|
|
432
|
+
/>
|
|
433
|
+
</blockquote>
|
|
434
|
+
) : null}
|
|
435
|
+
{source ? (
|
|
436
|
+
<Citation
|
|
437
|
+
evidence={source}
|
|
438
|
+
record={record}
|
|
439
|
+
renderCitation={renderCitation}
|
|
440
|
+
/>
|
|
441
|
+
) : null}
|
|
442
|
+
</div>
|
|
443
|
+
</>
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function OutputRecordPreview({
|
|
448
|
+
record,
|
|
449
|
+
index,
|
|
450
|
+
renderArtifact,
|
|
451
|
+
renderText,
|
|
452
|
+
}: SharedPreviewProps & { record: ResolvedOutput }) {
|
|
453
|
+
const labels = useLabels();
|
|
454
|
+
const inputNames = record.provenance.inputPaths.map((path) => {
|
|
455
|
+
const input = index.recordByPath.get(path);
|
|
456
|
+
return input ? recordTitle(input) : path;
|
|
457
|
+
});
|
|
458
|
+
const recipe = record.recipe?.command ?? record.recipe?.container;
|
|
459
|
+
const flow = [
|
|
460
|
+
inputNames.length ? inputNames.join(', ') : undefined,
|
|
461
|
+
recipe,
|
|
462
|
+
record.canonicalPath,
|
|
463
|
+
].filter((value): value is string => Boolean(value));
|
|
464
|
+
const artifact = renderArtifact
|
|
465
|
+
? renderArtifact(record, { compact: true })
|
|
466
|
+
: null;
|
|
467
|
+
return (
|
|
468
|
+
<>
|
|
469
|
+
<PreviewHeader
|
|
470
|
+
kind="output"
|
|
471
|
+
kindLabel={labels.kinds.output}
|
|
472
|
+
title={recordTitle(record)}
|
|
473
|
+
/>
|
|
474
|
+
<div className="astra-record-preview__body">
|
|
475
|
+
{record.description ? (
|
|
476
|
+
<div className="astra-record-preview__description">
|
|
477
|
+
<Prose
|
|
478
|
+
text={record.description}
|
|
479
|
+
field="description"
|
|
480
|
+
renderText={renderText}
|
|
481
|
+
/>
|
|
482
|
+
</div>
|
|
483
|
+
) : null}
|
|
484
|
+
{artifact != null ? (
|
|
485
|
+
<div className="astra-record-preview__artifact">
|
|
486
|
+
{artifact}
|
|
487
|
+
</div>
|
|
488
|
+
) : null}
|
|
489
|
+
{flow.length > 1 ? (
|
|
490
|
+
<section className="astra-record-preview__section">
|
|
491
|
+
<h4>{labels.preview.provenance}</h4>
|
|
492
|
+
<ol className="astra-record-preview__flow">
|
|
493
|
+
{flow.map((node, indexInFlow) => (
|
|
494
|
+
<li key={`${node}-${indexInFlow}`}>
|
|
495
|
+
<code>{node}</code>
|
|
496
|
+
</li>
|
|
497
|
+
))}
|
|
498
|
+
</ol>
|
|
499
|
+
</section>
|
|
500
|
+
) : null}
|
|
501
|
+
</div>
|
|
502
|
+
</>
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function InputPreview({
|
|
507
|
+
record,
|
|
508
|
+
renderText,
|
|
509
|
+
}: SharedPreviewProps & { record: ResolvedInput }) {
|
|
510
|
+
const labels = useLabels();
|
|
511
|
+
const source =
|
|
512
|
+
record.source ?? record.ref ?? record.resolvedFrom ?? record.from;
|
|
513
|
+
return (
|
|
514
|
+
<>
|
|
515
|
+
<PreviewHeader
|
|
516
|
+
kind="input"
|
|
517
|
+
kindLabel={labels.kinds.input}
|
|
518
|
+
title={recordTitle(record)}
|
|
519
|
+
/>
|
|
520
|
+
<div className="astra-record-preview__body">
|
|
521
|
+
{record.description ? (
|
|
522
|
+
<div className="astra-record-preview__description">
|
|
523
|
+
<Prose
|
|
524
|
+
text={record.description}
|
|
525
|
+
field="description"
|
|
526
|
+
renderText={renderText}
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
) : null}
|
|
530
|
+
{source ? (
|
|
531
|
+
<section className="astra-record-preview__section">
|
|
532
|
+
<h4>{labels.preview.source}</h4>
|
|
533
|
+
<code className="astra-record-preview__source">{source}</code>
|
|
534
|
+
</section>
|
|
535
|
+
) : null}
|
|
536
|
+
</div>
|
|
537
|
+
</>
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function RecordEntryPreview({
|
|
542
|
+
record,
|
|
543
|
+
maxSupportingInsights,
|
|
544
|
+
...shared
|
|
545
|
+
}: SharedPreviewProps & {
|
|
546
|
+
record: ResolvedRecord;
|
|
547
|
+
maxSupportingInsights: number;
|
|
548
|
+
}) {
|
|
549
|
+
switch (record.kind) {
|
|
550
|
+
case 'decision':
|
|
551
|
+
return (
|
|
552
|
+
<DecisionPreview
|
|
553
|
+
{...shared}
|
|
554
|
+
record={record}
|
|
555
|
+
maxSupportingInsights={maxSupportingInsights}
|
|
556
|
+
/>
|
|
557
|
+
);
|
|
558
|
+
case 'finding':
|
|
559
|
+
return <FindingPreview {...shared} record={record} />;
|
|
560
|
+
case 'prior_insight':
|
|
561
|
+
return <InsightPreview {...shared} record={record} />;
|
|
562
|
+
case 'output':
|
|
563
|
+
return <OutputRecordPreview {...shared} record={record} />;
|
|
564
|
+
case 'input':
|
|
565
|
+
return <InputPreview {...shared} record={record} />;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function AnalysisPreview({
|
|
570
|
+
analysis,
|
|
571
|
+
href,
|
|
572
|
+
renderText,
|
|
573
|
+
onOpenAnalysis,
|
|
574
|
+
}: {
|
|
575
|
+
analysis: ResolvedAnalysisNode;
|
|
576
|
+
href?: string | undefined;
|
|
577
|
+
renderText?: TextRenderer | undefined;
|
|
578
|
+
onOpenAnalysis?: ((analysis: ResolvedAnalysisNode, href?: string) => void) | undefined;
|
|
579
|
+
}) {
|
|
580
|
+
const labels = useLabels();
|
|
581
|
+
const title = analysisTitle(analysis);
|
|
582
|
+
const safeHref = (() => {
|
|
583
|
+
if (!href) return undefined;
|
|
584
|
+
try {
|
|
585
|
+
const parsed = new URL(href, 'https://astra-ui.invalid/');
|
|
586
|
+
return parsed.protocol === 'http:' || parsed.protocol === 'https:'
|
|
587
|
+
? href
|
|
588
|
+
: undefined;
|
|
589
|
+
} catch {
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
})();
|
|
593
|
+
let titleNode: ReactNode = title;
|
|
594
|
+
if (onOpenAnalysis) {
|
|
595
|
+
titleNode = (
|
|
596
|
+
<button
|
|
597
|
+
type="button"
|
|
598
|
+
className="astra-record-preview__analysis-link"
|
|
599
|
+
onClick={() => {
|
|
600
|
+
onOpenAnalysis(analysis, safeHref);
|
|
601
|
+
}}
|
|
602
|
+
>
|
|
603
|
+
{title}
|
|
604
|
+
</button>
|
|
605
|
+
);
|
|
606
|
+
} else if (safeHref) {
|
|
607
|
+
titleNode = (
|
|
608
|
+
<a className="astra-record-preview__analysis-link" href={safeHref}>
|
|
609
|
+
{title}
|
|
610
|
+
</a>
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
return (
|
|
614
|
+
<>
|
|
615
|
+
<PreviewHeader
|
|
616
|
+
kind="analysis"
|
|
617
|
+
kindLabel={labels.kinds.analysis}
|
|
618
|
+
title={titleNode}
|
|
619
|
+
/>
|
|
620
|
+
<div className="astra-record-preview__body">
|
|
621
|
+
{analysis.description ? (
|
|
622
|
+
<div className="astra-record-preview__description">
|
|
623
|
+
<Prose
|
|
624
|
+
text={analysis.description}
|
|
625
|
+
field="description"
|
|
626
|
+
renderText={renderText}
|
|
627
|
+
/>
|
|
628
|
+
</div>
|
|
629
|
+
) : null}
|
|
630
|
+
<p className="astra-record-preview__counts">
|
|
631
|
+
{labels.sectionCount('decisions', analysis.decisions.length)}
|
|
632
|
+
{' · '}
|
|
633
|
+
{labels.sectionCount('outputs', analysis.outputs.length)}
|
|
634
|
+
</p>
|
|
635
|
+
</div>
|
|
636
|
+
</>
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function ValuePreview({
|
|
641
|
+
entry,
|
|
642
|
+
renderText,
|
|
643
|
+
}: {
|
|
644
|
+
entry: Extract<RecordPreviewEntry, { kind: 'value' }>;
|
|
645
|
+
renderText?: TextRenderer | undefined;
|
|
646
|
+
}) {
|
|
647
|
+
const labels = useLabels();
|
|
648
|
+
const { record } = entry;
|
|
649
|
+
const kindLabel =
|
|
650
|
+
record.kind === 'output' ? labels.kinds.output : labels.kinds.decision;
|
|
651
|
+
const description =
|
|
652
|
+
record.kind === 'output' ? record.description : record.rationale;
|
|
653
|
+
return (
|
|
654
|
+
<>
|
|
655
|
+
<PreviewHeader
|
|
656
|
+
kind={record.kind}
|
|
657
|
+
kindLabel={kindLabel}
|
|
658
|
+
title={
|
|
659
|
+
<span className="astra-record-preview__value">
|
|
660
|
+
{entry.value}
|
|
661
|
+
{entry.unit ? (
|
|
662
|
+
<small className="astra-record-preview__unit"> {entry.unit}</small>
|
|
663
|
+
) : null}
|
|
664
|
+
</span>
|
|
665
|
+
}
|
|
666
|
+
/>
|
|
667
|
+
<div className="astra-record-preview__body">
|
|
668
|
+
{entry.column ||
|
|
669
|
+
entry.filter ||
|
|
670
|
+
entry.product ||
|
|
671
|
+
entry.selection ? (
|
|
672
|
+
<div className="astra-record-preview__selection">
|
|
673
|
+
{entry.column ? <code>{entry.column}</code> : null}
|
|
674
|
+
{entry.filter ? <span>{entry.filter}</span> : null}
|
|
675
|
+
{entry.selection ? <code>{entry.selection}</code> : null}
|
|
676
|
+
{entry.product ? (
|
|
677
|
+
<span>{labels.preview.valueSource(entry.product)}</span>
|
|
678
|
+
) : null}
|
|
679
|
+
</div>
|
|
680
|
+
) : null}
|
|
681
|
+
{description ? (
|
|
682
|
+
<div className="astra-record-preview__description">
|
|
683
|
+
<Prose
|
|
684
|
+
text={description}
|
|
685
|
+
field={record.kind === 'output' ? 'description' : 'rationale'}
|
|
686
|
+
renderText={renderText}
|
|
687
|
+
/>
|
|
688
|
+
</div>
|
|
689
|
+
) : null}
|
|
690
|
+
</div>
|
|
691
|
+
</>
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function previewKind(entry: RecordPreviewEntry): SurfaceKind {
|
|
696
|
+
if (entry.kind === 'analysis') return 'analysis';
|
|
697
|
+
return entry.record.kind;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Compact, positioning-agnostic preview content for resolved records,
|
|
702
|
+
* analyses, and inline values. Pair it with PreviewPopover or render it inline.
|
|
703
|
+
*/
|
|
704
|
+
export const RecordPreview = forwardRef<HTMLElement, RecordPreviewProps>(
|
|
705
|
+
function RecordPreview(
|
|
706
|
+
{
|
|
707
|
+
entry,
|
|
708
|
+
document,
|
|
709
|
+
index,
|
|
710
|
+
renderArtifact,
|
|
711
|
+
renderText,
|
|
712
|
+
renderCitation,
|
|
713
|
+
onOpenRecord,
|
|
714
|
+
onOpenAnalysis,
|
|
715
|
+
renderRecordReference,
|
|
716
|
+
maxSupportingInsights = 3,
|
|
717
|
+
className,
|
|
718
|
+
...props
|
|
719
|
+
},
|
|
720
|
+
ref,
|
|
721
|
+
) {
|
|
722
|
+
const maximum = Number.isFinite(maxSupportingInsights)
|
|
723
|
+
? Math.max(0, Math.floor(maxSupportingInsights))
|
|
724
|
+
: Number.MAX_SAFE_INTEGER;
|
|
725
|
+
const shared: SharedPreviewProps = {
|
|
726
|
+
document,
|
|
727
|
+
index,
|
|
728
|
+
renderArtifact,
|
|
729
|
+
renderText,
|
|
730
|
+
renderCitation,
|
|
731
|
+
onOpenRecord,
|
|
732
|
+
renderRecordReference,
|
|
733
|
+
};
|
|
734
|
+
return (
|
|
735
|
+
<article
|
|
736
|
+
data-slot="record-preview"
|
|
737
|
+
data-entry-kind={entry.kind}
|
|
738
|
+
data-kind={previewKind(entry)}
|
|
739
|
+
{...props}
|
|
740
|
+
ref={ref}
|
|
741
|
+
className={cn('astra-record-preview', className)}
|
|
742
|
+
>
|
|
743
|
+
{entry.kind === 'record' ? (
|
|
744
|
+
<RecordEntryPreview
|
|
745
|
+
{...shared}
|
|
746
|
+
record={entry.record}
|
|
747
|
+
maxSupportingInsights={maximum}
|
|
748
|
+
/>
|
|
749
|
+
) : entry.kind === 'analysis' ? (
|
|
750
|
+
<AnalysisPreview
|
|
751
|
+
analysis={entry.analysis}
|
|
752
|
+
href={entry.href}
|
|
753
|
+
renderText={renderText}
|
|
754
|
+
onOpenAnalysis={onOpenAnalysis}
|
|
755
|
+
/>
|
|
756
|
+
) : (
|
|
757
|
+
<ValuePreview entry={entry} renderText={renderText} />
|
|
758
|
+
)}
|
|
759
|
+
</article>
|
|
760
|
+
);
|
|
761
|
+
},
|
|
762
|
+
);
|