@astra-spec/ui 0.0.3 → 0.0.5
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 +173 -20
- package/TOKENS.md +17 -8
- package/components.css +1 -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/findings-list.d.ts.map +1 -1
- package/dist/blocks/findings-list.js +2 -1
- package/dist/blocks/findings-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 +3 -13
- 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 +9 -13
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -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 +3 -2
- 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 +2 -2
- package/dist/components/record-preview.d.ts.map +1 -1
- package/dist/components/record-preview.js +9 -8
- package/dist/components/record-preview.js.map +1 -1
- 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 +20 -0
- package/dist/lib/labels.d.ts.map +1 -1
- package/dist/lib/labels.js +20 -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/model/kind.d.ts +9 -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 +8 -9
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +4 -5
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/inline-reference.d.ts +9 -0
- package/dist/primitives/inline-reference.d.ts.map +1 -0
- package/dist/primitives/inline-reference.js +14 -0
- package/dist/primitives/inline-reference.js.map +1 -0
- package/dist/primitives/kind-glyph.d.ts +8 -0
- package/dist/primitives/kind-glyph.d.ts.map +1 -0
- package/dist/primitives/kind-glyph.js +9 -0
- package/dist/primitives/kind-glyph.js.map +1 -0
- package/dist/primitives/preview-popover.d.ts +2 -2
- package/dist/primitives/preview-popover.d.ts.map +1 -1
- package/dist/primitives/preview-popover.js +1 -1
- package/dist/primitives/preview-popover.js.map +1 -1
- package/dist/primitives/prose.d.ts +1 -35
- package/dist/primitives/prose.d.ts.map +1 -1
- package/dist/primitives/prose.js +2 -58
- 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 +3 -2
- 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 +3 -2
- 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/isolate.css +7 -0
- package/package.json +15 -3
- package/primitives.css +2 -0
- package/src/blocks/decisions-list.tsx +1 -6
- package/src/blocks/findings-list.tsx +2 -1
- 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 +3 -15
- 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 +10 -30
- package/src/components/input-detail.tsx +2 -5
- package/src/components/insight-detail.tsx +20 -35
- package/src/components/insight-trigger.tsx +5 -3
- 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 +12 -17
- 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 +40 -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/model/kind.ts +33 -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 +8 -17
- package/src/primitives/inline-reference.tsx +25 -0
- package/src/primitives/kind-glyph.tsx +24 -0
- package/src/primitives/preview-popover.tsx +3 -3
- package/src/primitives/prose.tsx +1 -86
- package/src/primitives/record-list.tsx +3 -4
- package/src/primitives/relation-list.tsx +4 -7
- 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 +6 -6
- package/styles/blocks/decisions-list.css +10 -10
- package/styles/blocks/outputs-list.css +272 -45
- package/styles/blocks/papers-list.css +14 -14
- package/styles/blocks/records.css +13 -13
- package/styles/components/artifact-preview.css +21 -21
- package/styles/components/decision-detail.css +23 -23
- package/styles/components/evidence.css +4 -9
- package/styles/components/finding-detail.css +11 -11
- package/styles/components/input-detail.css +11 -11
- package/styles/components/insight-detail.css +57 -95
- package/styles/components/insight-list.css +9 -9
- package/styles/components/insight-trigger.css +5 -8
- package/styles/components/output-detail.css +74 -189
- package/styles/components/paper-detail.css +90 -109
- package/styles/components/paper-doi.css +5 -14
- package/styles/components/paper-pdf-viewer.css +120 -0
- package/styles/components/record-preview.css +444 -268
- package/styles/primitives/badge.css +2 -2
- package/styles/primitives/button.css +25 -25
- package/styles/primitives/count-heading.css +5 -5
- package/styles/primitives/detail-layout.css +25 -25
- package/styles/primitives/dialog.css +86 -86
- package/styles/primitives/empty-state.css +1 -1
- package/styles/primitives/inline-reference.css +37 -0
- package/styles/primitives/kind-glyph.css +31 -0
- package/styles/primitives/kind.css +6 -0
- package/styles/primitives/preview-popover.css +6 -11
- package/styles/primitives/prose.css +1 -1
- package/styles/primitives/record-list.css +46 -62
- package/styles/primitives/relation-list.css +20 -42
- package/styles/primitives/surface-header.css +20 -16
- package/styles/tokens.css +26 -8
- package/styles/views/inventory.css +27 -29
- 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 +0 -6
- 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/src/primitives/kind.ts +0 -19
- /package/dist/{lib → primitives}/slot.d.ts +0 -0
package/src/components/index.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/** ASTRA-aware components:
|
|
2
|
-
export {
|
|
3
|
-
export type { DetailEntry } from './detail-entry.js';
|
|
4
|
-
export { useDetailStack } from './use-detail-stack.js';
|
|
5
|
-
export type { DetailStack, DetailStackOptions } from './use-detail-stack.js';
|
|
6
|
-
export { relationItemForRecord, relationItemsForLinks } from './relation-items.js';
|
|
7
|
-
export type { OpenRecordHandler } from './relation-items.js';
|
|
8
|
-
export { OutputDetail, OutputDialogActions, OutputPreview, useOutputExpanded } from './output-detail.js';
|
|
1
|
+
/** ASTRA-aware components: one detail body and dialog per record kind, papers and their PDF reader, compact previews, and the RecordDialog router. */
|
|
2
|
+
export { OutputDetail, OutputDialogActions, OutputPreview } from './output-detail.js';
|
|
9
3
|
export type { OutputDetailProps, OutputDialogActionsProps, OutputPreviewProps } from './output-detail.js';
|
|
10
4
|
export { OutputDialog } from './output-dialog.js';
|
|
11
5
|
export type { OutputDialogProps } from './output-dialog.js';
|
|
@@ -13,14 +7,14 @@ export { DecisionDetail, DecisionDialog } from './decision-detail.js';
|
|
|
13
7
|
export type { DecisionDetailProps, DecisionDialogProps } from './decision-detail.js';
|
|
14
8
|
export { FindingDetail, FindingDialog } from './finding-detail.js';
|
|
15
9
|
export type { FindingDetailProps, FindingDialogProps } from './finding-detail.js';
|
|
16
|
-
export { InputDetail, InputDialog
|
|
10
|
+
export { InputDetail, InputDialog } from './input-detail.js';
|
|
17
11
|
export type { InputDetailProps, InputDialogProps } from './input-detail.js';
|
|
18
|
-
export { InsightDetail, InsightDialog
|
|
12
|
+
export { InsightDetail, InsightDialog } from './insight-detail.js';
|
|
19
13
|
export type { InsightDetailProps, InsightDialogProps } from './insight-detail.js';
|
|
20
14
|
export { InsightEvidenceTitle, InsightTrigger } from './insight-trigger.js';
|
|
21
15
|
export type { InsightEvidenceTitleProps, InsightTriggerProps } from './insight-trigger.js';
|
|
22
16
|
export { PaperDetail, PaperDialog, PaperDialogActions } from './paper-detail.js';
|
|
23
|
-
export type { PaperDetailProps, PaperDialogActionsProps, PaperDialogProps,
|
|
17
|
+
export type { PaperDetailProps, PaperDialogActionsProps, PaperDialogProps, OpenPaperFileHandler } from './paper-detail.js';
|
|
24
18
|
export { RecordDialog } from './record-dialog.js';
|
|
25
19
|
export type { RecordDialogProps } from './record-dialog.js';
|
|
26
20
|
export { RecordPreview } from './record-preview.js';
|
|
@@ -33,22 +27,8 @@ export type {
|
|
|
33
27
|
RecordPreviewReferenceRenderer,
|
|
34
28
|
RecordPreviewTarget,
|
|
35
29
|
} from './record-preview.js';
|
|
36
|
-
export {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} from './artifact-preview.js';
|
|
42
|
-
export type {
|
|
43
|
-
ArtifactPreviewData,
|
|
44
|
-
ArtifactPreviewProps,
|
|
45
|
-
ArtifactRenderOptions,
|
|
46
|
-
ArtifactRenderer,
|
|
47
|
-
DelimitedPreviewOptions,
|
|
48
|
-
ImagePreviewData,
|
|
49
|
-
LoadingPreviewData,
|
|
50
|
-
MetricPreviewData,
|
|
51
|
-
TablePreviewData,
|
|
52
|
-
TextPreviewData,
|
|
53
|
-
UnavailablePreviewData,
|
|
54
|
-
} from './artifact-preview.js';
|
|
30
|
+
export { ArtifactPreview } from './artifact-preview.js';
|
|
31
|
+
export type { ArtifactPreviewProps, ArtifactRenderOptions, ArtifactRenderer } from './artifact-preview.js';
|
|
32
|
+
|
|
33
|
+
export { PaperPdfViewer } from './paper-pdf-viewer.js';
|
|
34
|
+
export type { PaperPdfViewerProps, PdfLoadState, PdfPassage } from './paper-pdf-viewer.js';
|
|
@@ -4,11 +4,8 @@ import { recordTitle } from '../model/records.js';
|
|
|
4
4
|
import { useLabels } from '../lib/labels.js';
|
|
5
5
|
import { DetailLayout, DetailMain, DetailSection } from '../primitives/detail-layout.js';
|
|
6
6
|
import { DetailDialog, type DetailDialogProps } from '../primitives/dialog.js';
|
|
7
|
-
import { Prose
|
|
8
|
-
|
|
9
|
-
export function inputSourceLabel(record: ResolvedInput): string {
|
|
10
|
-
return record.source ?? record.ref ?? record.resolvedFrom ?? 'Source not declared';
|
|
11
|
-
}
|
|
7
|
+
import { Prose } from '../primitives/prose.js';
|
|
8
|
+
import type { TextRenderer } from '../lib/prose.js';
|
|
12
9
|
|
|
13
10
|
export interface InputDetailProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
14
11
|
record: ResolvedInput;
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import type { ResolvedDecision, ResolvedInsight } from '@astra-spec/sdk';
|
|
2
2
|
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
3
|
import { doiHref } from '../model/doi.js';
|
|
4
|
+
import { primaryLiteratureEvidence } from '../model/papers.js';
|
|
4
5
|
import { recordTitle } from '../model/records.js';
|
|
5
6
|
import { cn } from '../lib/cn.js';
|
|
6
7
|
import { useLabels } from '../lib/labels.js';
|
|
7
8
|
import { DetailLayout, DetailMain, DetailSection } from '../primitives/detail-layout.js';
|
|
8
9
|
import { DetailDialog, type DetailDialogProps } from '../primitives/dialog.js';
|
|
9
|
-
import { Prose
|
|
10
|
+
import { Prose } from '../primitives/prose.js';
|
|
11
|
+
import type { TextRenderer } from '../lib/prose.js';
|
|
10
12
|
import { RelationList } from '../primitives/relation-list.js';
|
|
11
13
|
import { relationItemForRecord } from './relation-items.js';
|
|
12
14
|
|
|
13
|
-
/**
|
|
14
|
-
* The literature evidence an insight is presented against: the first entry
|
|
15
|
-
* with a DOI. A quote without a DOI names no paper to open, so it is skipped;
|
|
16
|
-
* the passage shown and the paper opened always belong to this one entry.
|
|
17
|
-
*/
|
|
18
|
-
export function primaryLiteratureEvidence(insight: ResolvedInsight) {
|
|
19
|
-
return insight.evidence.find((evidence) => Boolean(evidence.doi));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
15
|
export interface InsightDetailProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
23
16
|
record: ResolvedInsight;
|
|
24
17
|
/** Decisions that cite this insight; see `informedDecisions()`. */
|
|
@@ -29,7 +22,7 @@ export interface InsightDetailProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
29
22
|
onOpenDecision?: ((decision: ResolvedDecision) => void) | undefined;
|
|
30
23
|
}
|
|
31
24
|
|
|
32
|
-
/** Claim, source
|
|
25
|
+
/** Claim, source passage, notes, and the decisions an insight informs. */
|
|
33
26
|
export const InsightDetail = forwardRef<HTMLDivElement, InsightDetailProps>(function InsightDetail({
|
|
34
27
|
record: insight,
|
|
35
28
|
decisions,
|
|
@@ -40,7 +33,18 @@ export const InsightDetail = forwardRef<HTMLDivElement, InsightDetailProps>(func
|
|
|
40
33
|
...props
|
|
41
34
|
}, ref) {
|
|
42
35
|
const source = primaryLiteratureEvidence(insight);
|
|
43
|
-
|
|
36
|
+
// The way to the paper: through the host when it can show it, else doi.org.
|
|
37
|
+
const sourceAction = source?.doi ? (
|
|
38
|
+
onOpenSource ? (
|
|
39
|
+
<button type="button" className="astra-insight-detail__open-source" onClick={onOpenSource}>
|
|
40
|
+
{source.quote ? 'Locate passage in paper' : 'Open source paper'} <span aria-hidden="true">→</span>
|
|
41
|
+
</button>
|
|
42
|
+
) : (
|
|
43
|
+
<a className="astra-insight-detail__open-source" href={doiHref(source.doi)} target="_blank" rel="noreferrer">
|
|
44
|
+
Open source paper <span aria-hidden="true">↗</span>
|
|
45
|
+
</a>
|
|
46
|
+
)
|
|
47
|
+
) : null;
|
|
44
48
|
return (
|
|
45
49
|
<DetailLayout data-slot="insight-detail" {...props} ref={ref} layout="single" className={cn('astra-insight-detail', className)}>
|
|
46
50
|
<DetailMain>
|
|
@@ -49,31 +53,12 @@ export const InsightDetail = forwardRef<HTMLDivElement, InsightDetailProps>(func
|
|
|
49
53
|
<Prose text={insight.claim} field="claim" renderText={renderText} />
|
|
50
54
|
</DetailSection>
|
|
51
55
|
) : null}
|
|
52
|
-
{source?.doi ? (
|
|
53
|
-
<section className="astra-insight-detail__paper astra-paper-doi">
|
|
54
|
-
<h4>Source paper</h4>
|
|
55
|
-
{onOpenSource ? (
|
|
56
|
-
<button type="button" onClick={onOpenSource}>
|
|
57
|
-
{source.doi}{sourceLocation} ↗
|
|
58
|
-
</button>
|
|
59
|
-
) : (
|
|
60
|
-
<a href={doiHref(source.doi)} target="_blank" rel="noreferrer">
|
|
61
|
-
{source.doi}{sourceLocation} ↗
|
|
62
|
-
</a>
|
|
63
|
-
)}
|
|
64
|
-
</section>
|
|
65
|
-
) : null}
|
|
66
56
|
{source?.quote ? (
|
|
67
|
-
<
|
|
68
|
-
<h4>Source passage</h4>
|
|
57
|
+
<figure className="astra-insight-detail__source-quote">
|
|
69
58
|
<blockquote><Prose text={source.quote.exact} field="quote" renderText={renderText} /></blockquote>
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</button>
|
|
74
|
-
) : null}
|
|
75
|
-
</section>
|
|
76
|
-
) : null}
|
|
59
|
+
{sourceAction ? <figcaption>{sourceAction}</figcaption> : null}
|
|
60
|
+
</figure>
|
|
61
|
+
) : sourceAction}
|
|
77
62
|
{insight.notes ? (
|
|
78
63
|
<section className="astra-insight-detail__notes">
|
|
79
64
|
<h4>Notes</h4>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KindGlyph } from '../primitives/kind-glyph.js';
|
|
1
2
|
import type { ResolvedInsight } from '@astra-spec/sdk';
|
|
2
3
|
import {
|
|
3
4
|
forwardRef,
|
|
@@ -9,7 +10,8 @@ import {
|
|
|
9
10
|
} from 'react';
|
|
10
11
|
import { recordTitle } from '../model/records.js';
|
|
11
12
|
import { cn } from '../lib/cn.js';
|
|
12
|
-
import { Prose
|
|
13
|
+
import { Prose } from '../primitives/prose.js';
|
|
14
|
+
import type { TextRenderer } from '../lib/prose.js';
|
|
13
15
|
|
|
14
16
|
export interface InsightEvidenceTitleProps {
|
|
15
17
|
name: string;
|
|
@@ -19,7 +21,7 @@ export interface InsightEvidenceTitleProps {
|
|
|
19
21
|
export function InsightEvidenceTitle({ name, tag }: InsightEvidenceTitleProps) {
|
|
20
22
|
return (
|
|
21
23
|
<span className="astra-evidence__title">
|
|
22
|
-
<
|
|
24
|
+
<KindGlyph className="astra-evidence__glyph--insight" kind="prior_insight" />
|
|
23
25
|
<span className="astra-evidence__name">{name}</span>
|
|
24
26
|
{tag ? <span className="astra-evidence__tag">{tag}</span> : null}
|
|
25
27
|
</span>
|
|
@@ -77,7 +79,7 @@ export const InsightTrigger = forwardRef<HTMLElement, InsightTriggerProps>(funct
|
|
|
77
79
|
onClick={open}
|
|
78
80
|
onKeyDown={keyOpen}
|
|
79
81
|
>
|
|
80
|
-
<
|
|
82
|
+
<KindGlyph className="astra-evidence__glyph--insight" kind="prior_insight" />
|
|
81
83
|
<div className="astra-insight-trigger__claim">
|
|
82
84
|
<Prose text={insight.claim} field="claim" renderText={renderText} />
|
|
83
85
|
</div>
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { ResolvedOutput } from '@astra-spec/sdk';
|
|
2
|
-
import { forwardRef, useCallback, useEffect, useRef,
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
3
3
|
import type { OutputRelations } from '../model/relations.js';
|
|
4
4
|
import { isVisualOutput, recordTitle } from '../model/records.js';
|
|
5
5
|
import { cn } from '../lib/cn.js';
|
|
6
6
|
import { useLabels } from '../lib/labels.js';
|
|
7
7
|
import { ArtifactPreview, type ArtifactRenderer } from './artifact-preview.js';
|
|
8
8
|
import { DialogAction, useDialogDismissGuard, useOptionalDialog } from '../primitives/dialog.js';
|
|
9
|
-
import { Prose
|
|
9
|
+
import { Prose } from '../primitives/prose.js';
|
|
10
|
+
import type { TextRenderer } from '../lib/prose.js';
|
|
10
11
|
import { RelationList } from '../primitives/relation-list.js';
|
|
11
|
-
import { relationItemsForLinks
|
|
12
|
+
import { relationItemsForLinks } from './relation-items.js';
|
|
13
|
+
import type { OpenRecordHandler } from '../lib/detail-stack.js';
|
|
12
14
|
|
|
13
15
|
export interface OutputPreviewProps {
|
|
14
16
|
output: ResolvedOutput;
|
|
@@ -116,15 +118,6 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
116
118
|
</div>
|
|
117
119
|
</section>
|
|
118
120
|
) : null}
|
|
119
|
-
{output.recipe?.command ? (
|
|
120
|
-
<section className="astra-output-detail__recipe">
|
|
121
|
-
<h4>Recipe</h4>
|
|
122
|
-
<pre><code>{output.recipe.command}</code></pre>
|
|
123
|
-
{output.recipe.container
|
|
124
|
-
? <p>Container: <code>{output.recipe.container}</code></p>
|
|
125
|
-
: null}
|
|
126
|
-
</section>
|
|
127
|
-
) : null}
|
|
128
121
|
{output.resolvedFrom ? (
|
|
129
122
|
<RelationList
|
|
130
123
|
className="astra-detail__relations"
|
|
@@ -143,7 +136,6 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
143
136
|
<RelationList
|
|
144
137
|
className="astra-detail__relations"
|
|
145
138
|
title="Indirect decision dependencies"
|
|
146
|
-
description="Through upstream outputs."
|
|
147
139
|
items={relationItemsForLinks(relations.indirectDecisions, onOpenRecord)}
|
|
148
140
|
empty={null}
|
|
149
141
|
/>
|
|
@@ -151,9 +143,20 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
151
143
|
<RelationList
|
|
152
144
|
className="astra-detail__relations"
|
|
153
145
|
title="Inputs and upstream outputs"
|
|
154
|
-
items={relationItemsForLinks(relations.inputs, onOpenRecord)
|
|
146
|
+
items={relationItemsForLinks(relations.inputs, onOpenRecord).map((item) => (
|
|
147
|
+
item.kind === 'output' ? { ...item, detail: 'intermediate output' } : item
|
|
148
|
+
))}
|
|
155
149
|
empty="No upstream dependencies are declared for this output."
|
|
156
150
|
/>
|
|
151
|
+
{output.recipe?.command ? (
|
|
152
|
+
<section className="astra-output-detail__recipe">
|
|
153
|
+
<h4>Recipe</h4>
|
|
154
|
+
<pre><code>{output.recipe.command}</code></pre>
|
|
155
|
+
{output.recipe.container
|
|
156
|
+
? <p>Container: <code>{output.recipe.container}</code></p>
|
|
157
|
+
: null}
|
|
158
|
+
</section>
|
|
159
|
+
) : null}
|
|
157
160
|
</aside>
|
|
158
161
|
);
|
|
159
162
|
|
|
@@ -232,27 +235,3 @@ export function OutputDialogActions({ record: output, onOpenArtifact, expanded,
|
|
|
232
235
|
);
|
|
233
236
|
}
|
|
234
237
|
|
|
235
|
-
/** Full-screen state for an output, reset whenever the output changes (a controlled host is asked to reset). */
|
|
236
|
-
export function useOutputExpanded(output: ResolvedOutput, controlled?: { expanded?: boolean | undefined; onExpandedChange?: ((next: boolean) => void) | undefined }) {
|
|
237
|
-
const [internal, setInternal] = useState(false);
|
|
238
|
-
const [lastPath, setLastPath] = useState(output.canonicalPath);
|
|
239
|
-
if (lastPath !== output.canonicalPath) {
|
|
240
|
-
setLastPath(output.canonicalPath);
|
|
241
|
-
setInternal(false);
|
|
242
|
-
}
|
|
243
|
-
const isControlled = controlled?.expanded !== undefined;
|
|
244
|
-
const expanded = isControlled ? Boolean(controlled.expanded) : internal;
|
|
245
|
-
const onChange = controlled?.onExpandedChange;
|
|
246
|
-
const seenPath = useRef(output.canonicalPath);
|
|
247
|
-
const controlledExpanded = isControlled && Boolean(controlled.expanded);
|
|
248
|
-
useEffect(() => {
|
|
249
|
-
if (seenPath.current === output.canonicalPath) return;
|
|
250
|
-
seenPath.current = output.canonicalPath;
|
|
251
|
-
if (controlledExpanded) onChange?.(false);
|
|
252
|
-
}, [output.canonicalPath, controlledExpanded, onChange]);
|
|
253
|
-
const setExpanded = useCallback((next: boolean) => {
|
|
254
|
-
if (!isControlled) setInternal(next);
|
|
255
|
-
onChange?.(next);
|
|
256
|
-
}, [isControlled, onChange]);
|
|
257
|
-
return [expanded, setExpanded] as const;
|
|
258
|
-
}
|
|
@@ -4,9 +4,10 @@ import { isVisualOutput, recordTitle } from '../model/records.js';
|
|
|
4
4
|
import { useLabels } from '../lib/labels.js';
|
|
5
5
|
import type { ArtifactRenderer } from './artifact-preview.js';
|
|
6
6
|
import { DetailDialog, type DetailDialogProps } from '../primitives/dialog.js';
|
|
7
|
-
import type { TextRenderer } from '../
|
|
8
|
-
import { OutputDetail, OutputDialogActions
|
|
9
|
-
import
|
|
7
|
+
import type { TextRenderer } from '../lib/prose.js';
|
|
8
|
+
import { OutputDetail, OutputDialogActions } from './output-detail.js';
|
|
9
|
+
import { useOutputExpanded } from '../lib/use-output-expanded.js';
|
|
10
|
+
import type { OpenRecordHandler } from '../lib/detail-stack.js';
|
|
10
11
|
|
|
11
12
|
export interface OutputDialogProps extends Pick<DetailDialogProps, 'mode' | 'backText' | 'className' | 'onBack' | 'onClose'> {
|
|
12
13
|
record: ResolvedOutput;
|
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { KindGlyph } from '../primitives/kind-glyph.js';
|
|
2
|
+
import type { ResolvedDecision, ResolvedEvidence, ResolvedInsight } from '@astra-spec/sdk';
|
|
3
|
+
import { forwardRef, useCallback, useMemo, useRef, useState, type HTMLAttributes } from 'react';
|
|
3
4
|
import { doiHref } from '../model/doi.js';
|
|
4
|
-
import { countLabel } from '../model/records.js';
|
|
5
|
-
import {
|
|
5
|
+
import { countLabel, recordTitle } from '../model/records.js';
|
|
6
|
+
import { decisionInsightPaths } from '../model/relations.js';
|
|
7
|
+
import { paperEvidence, type InventoryPaper, type InventoryPaperMetadata } from '../model/papers.js';
|
|
6
8
|
import { cn } from '../lib/cn.js';
|
|
7
9
|
import { useLabels } from '../lib/labels.js';
|
|
8
10
|
import { CountHeading } from '../primitives/detail-layout.js';
|
|
9
11
|
import { DetailDialog, DialogAction, type DetailDialogProps } from '../primitives/dialog.js';
|
|
10
|
-
import {
|
|
11
|
-
import { RelationList } from '../primitives/relation-list.js';
|
|
12
|
+
import type { TextRenderer } from '../lib/prose.js';
|
|
12
13
|
import { InsightTrigger } from './insight-trigger.js';
|
|
13
|
-
import {
|
|
14
|
+
import { PaperPdfViewer, type PdfPassage } from './paper-pdf-viewer.js';
|
|
15
|
+
import type { PdfJsLoader } from '../lib/pdf-runtime.js';
|
|
14
16
|
|
|
15
|
-
export
|
|
16
|
-
focusEvidence?: PaperFocusEvidence | undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** Host slot for PDF, HTML, or any other paper presentation. */
|
|
20
|
-
export type PaperRenderer = (paper: InventoryPaper, options: PaperRenderOptions) => ReactNode;
|
|
17
|
+
export type OpenPaperFileHandler = (paper: InventoryPaper) => void | Promise<void>;
|
|
21
18
|
|
|
22
19
|
export interface PaperDetailProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
23
20
|
record: InventoryPaper;
|
|
24
21
|
/** Fetch state for this DOI, if the host tracks it. */
|
|
25
22
|
metadata?: Pick<InventoryPaperMetadata, 'status' | 'error'> | undefined;
|
|
26
|
-
/** Insight whose first quoted passage is
|
|
23
|
+
/** Insight whose first quoted passage is located initially. */
|
|
27
24
|
focusInsight?: ResolvedInsight | undefined;
|
|
28
25
|
renderText?: TextRenderer | undefined;
|
|
29
|
-
|
|
26
|
+
/** Supplies pdf.js; with it and a `pdfUrl`, the paper is read in place and its passages located. */
|
|
27
|
+
loadPdfJs?: PdfJsLoader | undefined;
|
|
30
28
|
/** Notify the host to fetch this DOI; refreshed metadata returns through props. */
|
|
31
29
|
onFetchPaper?: ((doi: string) => void) | undefined;
|
|
32
30
|
onOpenInsight?: ((insight: ResolvedInsight) => void) | undefined;
|
|
33
31
|
onOpenDecision?: ((decision: ResolvedDecision) => void) | undefined;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
function passageFor(key: string, evidence: ResolvedEvidence): PdfPassage {
|
|
35
|
+
return { key, quote: evidence.quote?.exact, page: evidence.location?.page };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function initialPassage(paper: InventoryPaper, focusInsight: ResolvedInsight | undefined): PdfPassage | undefined {
|
|
39
|
+
const evidence = focusInsight ? paperEvidence(focusInsight, paper.doi)[0] : undefined;
|
|
40
|
+
return focusInsight && evidence ? passageFor(`${focusInsight.canonicalPath}-source`, evidence) : undefined;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
/**
|
|
43
|
+
/** PDF paper content beside the insights and decisions it supports. */
|
|
43
44
|
export const PaperDetail = forwardRef<HTMLDivElement, PaperDetailProps>(function PaperDetail({
|
|
44
45
|
record: paper,
|
|
45
46
|
metadata,
|
|
46
47
|
focusInsight,
|
|
47
48
|
renderText,
|
|
48
|
-
|
|
49
|
+
loadPdfJs,
|
|
49
50
|
onFetchPaper,
|
|
50
51
|
onOpenInsight,
|
|
51
52
|
onOpenDecision,
|
|
@@ -54,29 +55,45 @@ export const PaperDetail = forwardRef<HTMLDivElement, PaperDetailProps>(function
|
|
|
54
55
|
}, ref) {
|
|
55
56
|
const labels = useLabels();
|
|
56
57
|
const [focusKey, setFocusKey] = useState<string | undefined>(undefined);
|
|
57
|
-
const [override, setOverride] = useState<
|
|
58
|
+
const [override, setOverride] = useState<PdfPassage | undefined>(undefined);
|
|
59
|
+
const [decisionFilter, setDecisionFilter] = useState<string | undefined>(undefined);
|
|
60
|
+
// Keyed by URL so a failure for one paper never outlives it inside a persistent dialog.
|
|
61
|
+
const [failedPdfUrl, setFailedPdfUrl] = useState<string | undefined>(undefined);
|
|
58
62
|
const key = `${paper.doi}|${focusInsight?.canonicalPath ?? ''}`;
|
|
59
63
|
if (focusKey !== key) {
|
|
60
64
|
setFocusKey(key);
|
|
61
65
|
setOverride(undefined);
|
|
66
|
+
setDecisionFilter(undefined);
|
|
62
67
|
}
|
|
63
|
-
// One object per request, kept across unrelated re-renders, with a
|
|
64
|
-
// that changes on every locate click so a
|
|
65
|
-
//
|
|
66
|
-
const
|
|
68
|
+
// One passage object per request, kept across unrelated re-renders, with a
|
|
69
|
+
// key that changes on every locate click so repeating a passage is still a
|
|
70
|
+
// new request to the viewer.
|
|
71
|
+
const passage = useMemo(() => override ?? initialPassage(paper, focusInsight), [override, paper, focusInsight]);
|
|
67
72
|
const sequence = useRef(0);
|
|
68
|
-
const
|
|
73
|
+
const canLocate = Boolean(paper.pdfUrl && loadPdfJs) && failedPdfUrl !== paper.pdfUrl;
|
|
74
|
+
const locate = useCallback((insight: ResolvedInsight, evidence: ResolvedEvidence) => {
|
|
69
75
|
sequence.current += 1;
|
|
70
|
-
setOverride(
|
|
76
|
+
setOverride(passageFor(`${insight.canonicalPath}-${sequence.current}`, evidence));
|
|
71
77
|
}, []);
|
|
72
|
-
const canRender = Boolean(paper.pdfUrl && renderPaper);
|
|
73
78
|
const fetching = metadata?.status === 'fetching';
|
|
79
|
+
const filterDecision = paper.decisions.find((decision) => decision.canonicalPath === decisionFilter);
|
|
80
|
+
const visibleInsights = useMemo(() => {
|
|
81
|
+
if (!filterDecision) return paper.insights;
|
|
82
|
+
const cited = new Set(decisionInsightPaths(filterDecision));
|
|
83
|
+
return paper.insights.filter((insight) => cited.has(insight.canonicalPath));
|
|
84
|
+
}, [paper, filterDecision]);
|
|
74
85
|
|
|
75
86
|
return (
|
|
76
87
|
<div data-slot="paper-detail" {...props} ref={ref} className={cn('astra-paper-detail__layout', className)}>
|
|
77
88
|
<div className="astra-paper-detail__artifact">
|
|
78
|
-
{
|
|
79
|
-
|
|
89
|
+
{paper.pdfUrl && loadPdfJs ? (
|
|
90
|
+
<PaperPdfViewer
|
|
91
|
+
pdfUrl={paper.pdfUrl}
|
|
92
|
+
title={paper.title}
|
|
93
|
+
passage={passage}
|
|
94
|
+
loadPdfJs={loadPdfJs}
|
|
95
|
+
onLoadStateChange={(state) => { setFailedPdfUrl(state === 'error' ? paper.pdfUrl : undefined); }}
|
|
96
|
+
/>
|
|
80
97
|
) : (
|
|
81
98
|
<div className="astra-paper-detail__unavailable" {...(fetching ? { 'aria-busy': true } : {})}>
|
|
82
99
|
{!paper.pdfUrl && onFetchPaper ? (
|
|
@@ -93,43 +110,83 @@ export const PaperDetail = forwardRef<HTMLDivElement, PaperDetailProps>(function
|
|
|
93
110
|
) : (
|
|
94
111
|
<p>
|
|
95
112
|
{paper.pdfUrl
|
|
96
|
-
?
|
|
97
|
-
:
|
|
113
|
+
? labels.pdf.unavailable
|
|
114
|
+
: <>Follow the <a href={doiHref(paper.doi)} target="_blank" rel="noreferrer">DOI</a> for the published version.</>}
|
|
98
115
|
</p>
|
|
99
116
|
)}
|
|
100
117
|
</div>
|
|
101
118
|
)}
|
|
102
119
|
</div>
|
|
103
120
|
<aside className="astra-paper-detail__rail" aria-label="Paper insights and decisions">
|
|
104
|
-
<section className="astra-paper-
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
121
|
+
<section className="astra-paper-decisions">
|
|
122
|
+
<CountHeading title="Informs decisions" count={paper.decisions.length} />
|
|
123
|
+
{paper.decisions.length ? (
|
|
124
|
+
<div
|
|
125
|
+
className="astra-paper-decisions__filters"
|
|
126
|
+
role="group"
|
|
127
|
+
aria-label="Filter insights by decision"
|
|
128
|
+
>
|
|
129
|
+
{paper.decisions.map((decision) => {
|
|
130
|
+
const active = decision.canonicalPath === decisionFilter;
|
|
131
|
+
return (
|
|
132
|
+
<button
|
|
133
|
+
key={decision.canonicalPath}
|
|
134
|
+
type="button"
|
|
135
|
+
className="astra-paper-decisions__filter"
|
|
136
|
+
aria-pressed={active}
|
|
137
|
+
onClick={() => {
|
|
138
|
+
setDecisionFilter(active ? undefined : decision.canonicalPath);
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<KindGlyph kind="decision" />
|
|
142
|
+
<span>{recordTitle(decision)}</span>
|
|
143
|
+
</button>
|
|
144
|
+
);
|
|
145
|
+
})}
|
|
146
|
+
</div>
|
|
147
|
+
) : (
|
|
148
|
+
<p className="astra-paper-decisions__empty">No decisions cite insights from this paper.</p>
|
|
149
|
+
)}
|
|
150
|
+
{filterDecision && onOpenDecision ? (
|
|
151
|
+
<button
|
|
152
|
+
type="button"
|
|
153
|
+
className="astra-paper-decisions__open"
|
|
154
|
+
onClick={() => { onOpenDecision(filterDecision); }}
|
|
155
|
+
>
|
|
156
|
+
Open {recordTitle(filterDecision)} →
|
|
157
|
+
</button>
|
|
158
|
+
) : null}
|
|
109
159
|
</section>
|
|
110
160
|
<section className="astra-insight-list">
|
|
111
|
-
<CountHeading
|
|
161
|
+
<CountHeading
|
|
162
|
+
title={filterDecision ? `Insights for ${recordTitle(filterDecision)}` : 'Insights from this paper'}
|
|
163
|
+
count={visibleInsights.length}
|
|
164
|
+
/>
|
|
112
165
|
<ul className="astra-evidence astra-paper-detail__insights">
|
|
113
|
-
{
|
|
166
|
+
{visibleInsights.map((insight) => {
|
|
114
167
|
const evidence = paperEvidence(insight, paper.doi);
|
|
115
168
|
return (
|
|
116
169
|
<li key={insight.canonicalPath} className="astra-evidence__item astra-paper-insight">
|
|
117
|
-
<InsightTrigger
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
170
|
+
<InsightTrigger
|
|
171
|
+
insight={insight}
|
|
172
|
+
variant="claim"
|
|
173
|
+
renderText={renderText}
|
|
174
|
+
onOpen={() => onOpenInsight?.(insight)}
|
|
175
|
+
/>
|
|
121
176
|
{evidence.length ? (
|
|
122
177
|
<div className="astra-paper-insight__sources">
|
|
123
178
|
<span>{countLabel(evidence.length, 'passage')}</span>
|
|
124
|
-
{
|
|
179
|
+
{paper.pdfUrl && loadPdfJs ? (
|
|
125
180
|
<div>
|
|
126
181
|
{evidence.map((source, index) => (
|
|
182
|
+
// Kept focusable after a load failure so keyboard focus never drops out of the dialog.
|
|
127
183
|
<button
|
|
128
184
|
key={`${insight.canonicalPath}-${index}`}
|
|
129
185
|
type="button"
|
|
130
186
|
className="astra-paper-insight__locate"
|
|
131
|
-
|
|
132
|
-
|
|
187
|
+
aria-disabled={canLocate ? undefined : true}
|
|
188
|
+
onClick={() => { if (canLocate) locate(insight, source); }}
|
|
189
|
+
aria-label={labels.pdf.locatePassage(index + 1)}
|
|
133
190
|
>
|
|
134
191
|
{labels.actions.locate}{evidence.length > 1 ? ` ${index + 1}` : ''}
|
|
135
192
|
</button>
|
|
@@ -143,35 +200,32 @@ export const PaperDetail = forwardRef<HTMLDivElement, PaperDetailProps>(function
|
|
|
143
200
|
})}
|
|
144
201
|
</ul>
|
|
145
202
|
</section>
|
|
146
|
-
<RelationList
|
|
147
|
-
className="astra-detail__relations"
|
|
148
|
-
title="Informs decisions"
|
|
149
|
-
items={paper.decisions.map((decision) => relationItemForRecord(
|
|
150
|
-
decision,
|
|
151
|
-
undefined,
|
|
152
|
-
undefined,
|
|
153
|
-
{ onOpen: onOpenDecision ? () => { onOpenDecision(decision); } : undefined },
|
|
154
|
-
))}
|
|
155
|
-
empty="No decisions cite insights from this paper."
|
|
156
|
-
/>
|
|
157
203
|
</aside>
|
|
158
204
|
</div>
|
|
159
205
|
);
|
|
160
206
|
});
|
|
161
207
|
|
|
162
|
-
export interface PaperDialogProps extends Pick<DetailDialogProps, 'mode' | 'backText' | 'className' | 'onBack' | 'onClose'>, Omit<PaperDetailProps, 'className'> {
|
|
208
|
+
export interface PaperDialogProps extends Pick<DetailDialogProps, 'mode' | 'backText' | 'className' | 'onBack' | 'onClose'>, Omit<PaperDetailProps, 'className'> {
|
|
209
|
+
onOpenPaperFile?: OpenPaperFileHandler | undefined;
|
|
210
|
+
}
|
|
163
211
|
|
|
164
|
-
/** Header action linking to the paper's hosted content, when there is
|
|
212
|
+
/** Header action linking to the paper's hosted content, or to its DOI when there is none. */
|
|
165
213
|
export interface PaperDialogActionsProps {
|
|
166
214
|
record: InventoryPaper;
|
|
215
|
+
onOpenPaperFile?: OpenPaperFileHandler | undefined;
|
|
167
216
|
}
|
|
168
217
|
|
|
169
|
-
export function PaperDialogActions({ record: paper }: PaperDialogActionsProps) {
|
|
218
|
+
export function PaperDialogActions({ record: paper, onOpenPaperFile }: PaperDialogActionsProps) {
|
|
170
219
|
const labels = useLabels();
|
|
171
|
-
if (
|
|
220
|
+
if (paper.pdfUrl && onOpenPaperFile) return (
|
|
221
|
+
<DialogAction onClick={() => { void onOpenPaperFile(paper); }}>
|
|
222
|
+
<span aria-hidden="true">↗</span>
|
|
223
|
+
<span>{labels.actions.openPaper}</span>
|
|
224
|
+
</DialogAction>
|
|
225
|
+
);
|
|
172
226
|
return (
|
|
173
227
|
<DialogAction asChild>
|
|
174
|
-
<a href={paper.pdfUrl} target="_blank" rel="noreferrer">
|
|
228
|
+
<a href={paper.pdfUrl ?? doiHref(paper.doi)} target="_blank" rel="noreferrer">
|
|
175
229
|
<span aria-hidden="true">↗</span>
|
|
176
230
|
<span>{labels.actions.openPaper}</span>
|
|
177
231
|
</a>
|
|
@@ -184,10 +238,11 @@ export function PaperDialog({
|
|
|
184
238
|
metadata,
|
|
185
239
|
focusInsight,
|
|
186
240
|
renderText,
|
|
187
|
-
|
|
241
|
+
loadPdfJs,
|
|
188
242
|
onFetchPaper,
|
|
189
243
|
onOpenInsight,
|
|
190
244
|
onOpenDecision,
|
|
245
|
+
onOpenPaperFile,
|
|
191
246
|
...dialog
|
|
192
247
|
}: PaperDialogProps) {
|
|
193
248
|
const labels = useLabels();
|
|
@@ -199,14 +254,14 @@ export function PaperDialog({
|
|
|
199
254
|
kindLabel={labels.kinds.paper}
|
|
200
255
|
title={paper.title}
|
|
201
256
|
closeLabel={labels.closeRecord(labels.kinds.paper)}
|
|
202
|
-
actions={<PaperDialogActions record={paper} />}
|
|
257
|
+
actions={<PaperDialogActions record={paper} onOpenPaperFile={onOpenPaperFile} />}
|
|
203
258
|
>
|
|
204
259
|
<PaperDetail
|
|
205
260
|
record={paper}
|
|
206
261
|
metadata={metadata}
|
|
207
262
|
focusInsight={focusInsight}
|
|
208
263
|
renderText={renderText}
|
|
209
|
-
|
|
264
|
+
loadPdfJs={loadPdfJs}
|
|
210
265
|
onFetchPaper={onFetchPaper}
|
|
211
266
|
onOpenInsight={onOpenInsight}
|
|
212
267
|
onOpenDecision={onOpenDecision}
|