@astra-spec/ui 0.0.1
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/LICENSE +29 -0
- package/README.md +261 -0
- package/TOKENS.md +93 -0
- package/blocks.css +7 -0
- package/components.css +13 -0
- package/dist/blocks/analysis-tree.d.ts +13 -0
- package/dist/blocks/analysis-tree.d.ts.map +1 -0
- package/dist/blocks/analysis-tree.js +19 -0
- package/dist/blocks/analysis-tree.js.map +1 -0
- package/dist/blocks/decisions-list.d.ts +17 -0
- package/dist/blocks/decisions-list.d.ts.map +1 -0
- package/dist/blocks/decisions-list.js +56 -0
- package/dist/blocks/decisions-list.js.map +1 -0
- package/dist/blocks/findings-list.d.ts +9 -0
- package/dist/blocks/findings-list.d.ts.map +1 -0
- package/dist/blocks/findings-list.js +35 -0
- package/dist/blocks/findings-list.js.map +1 -0
- package/dist/blocks/index.d.ts +18 -0
- package/dist/blocks/index.d.ts.map +1 -0
- package/dist/blocks/index.js +10 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/blocks/inputs-list.d.ts +9 -0
- package/dist/blocks/inputs-list.d.ts.map +1 -0
- package/dist/blocks/inputs-list.js +32 -0
- package/dist/blocks/inputs-list.js.map +1 -0
- package/dist/blocks/outputs-list.d.ts +18 -0
- package/dist/blocks/outputs-list.d.ts.map +1 -0
- package/dist/blocks/outputs-list.js +47 -0
- package/dist/blocks/outputs-list.js.map +1 -0
- package/dist/blocks/papers-list.d.ts +16 -0
- package/dist/blocks/papers-list.d.ts.map +1 -0
- package/dist/blocks/papers-list.js +20 -0
- package/dist/blocks/papers-list.js.map +1 -0
- package/dist/blocks/prior-insights-list.d.ts +9 -0
- package/dist/blocks/prior-insights-list.d.ts.map +1 -0
- package/dist/blocks/prior-insights-list.js +29 -0
- package/dist/blocks/prior-insights-list.js.map +1 -0
- package/dist/blocks/section.d.ts +36 -0
- package/dist/blocks/section.d.ts.map +1 -0
- package/dist/blocks/section.js +30 -0
- package/dist/blocks/section.js.map +1 -0
- package/dist/components/artifact-preview.d.ts +71 -0
- package/dist/components/artifact-preview.d.ts.map +1 -0
- package/dist/components/artifact-preview.js +170 -0
- package/dist/components/artifact-preview.js.map +1 -0
- package/dist/components/decision-detail.d.ts +17 -0
- package/dist/components/decision-detail.d.ts.map +1 -0
- package/dist/components/decision-detail.js +21 -0
- package/dist/components/decision-detail.js.map +1 -0
- package/dist/components/detail-entry.d.ts +15 -0
- package/dist/components/detail-entry.d.ts.map +1 -0
- package/dist/components/detail-entry.js +14 -0
- package/dist/components/detail-entry.js.map +1 -0
- package/dist/components/finding-detail.d.ts +19 -0
- package/dist/components/finding-detail.d.ts.map +1 -0
- package/dist/components/finding-detail.js +39 -0
- package/dist/components/finding-detail.js.map +1 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +15 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/input-detail.d.ts +15 -0
- package/dist/components/input-detail.d.ts.map +1 -0
- package/dist/components/input-detail.js +21 -0
- package/dist/components/input-detail.js.map +1 -0
- package/dist/components/insight-detail.d.ts +25 -0
- package/dist/components/insight-detail.d.ts.map +1 -0
- package/dist/components/insight-detail.js +30 -0
- package/dist/components/insight-detail.js.map +1 -0
- package/dist/components/insight-trigger.d.ts +20 -0
- package/dist/components/insight-trigger.d.ts.map +1 -0
- package/dist/components/insight-trigger.js +32 -0
- package/dist/components/insight-trigger.js.map +1 -0
- package/dist/components/output-detail.d.ts +39 -0
- package/dist/components/output-detail.d.ts.map +1 -0
- package/dist/components/output-detail.js +124 -0
- package/dist/components/output-detail.js.map +1 -0
- package/dist/components/output-dialog.d.ts +18 -0
- package/dist/components/output-dialog.d.ts.map +1 -0
- package/dist/components/output-dialog.js +11 -0
- package/dist/components/output-dialog.js.map +1 -0
- package/dist/components/paper-detail.d.ts +34 -0
- package/dist/components/paper-detail.d.ts.map +1 -0
- package/dist/components/paper-detail.js +60 -0
- package/dist/components/paper-detail.js.map +1 -0
- package/dist/components/record-dialog.d.ts +33 -0
- package/dist/components/record-dialog.d.ts.map +1 -0
- package/dist/components/record-dialog.js +114 -0
- package/dist/components/record-dialog.js.map +1 -0
- package/dist/components/relation-items.d.ts +9 -0
- package/dist/components/relation-items.d.ts.map +1 -0
- package/dist/components/relation-items.js +20 -0
- package/dist/components/relation-items.js.map +1 -0
- package/dist/components/use-detail-stack.d.ts +31 -0
- package/dist/components/use-detail-stack.d.ts.map +1 -0
- package/dist/components/use-detail-stack.js +49 -0
- package/dist/components/use-detail-stack.js.map +1 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +6 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/labels.d.ts +61 -0
- package/dist/lib/labels.d.ts.map +1 -0
- package/dist/lib/labels.js +79 -0
- package/dist/lib/labels.js.map +1 -0
- package/dist/lib/slot.d.ts +11 -0
- package/dist/lib/slot.d.ts.map +1 -0
- package/dist/lib/slot.js +83 -0
- package/dist/lib/slot.js.map +1 -0
- package/dist/model/doi.d.ts +2 -0
- package/dist/model/doi.d.ts.map +1 -0
- package/dist/model/doi.js +5 -0
- package/dist/model/doi.js.map +1 -0
- package/dist/model/index.d.ts +10 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +7 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/locate-record.d.ts +8 -0
- package/dist/model/locate-record.d.ts.map +1 -0
- package/dist/model/locate-record.js +7 -0
- package/dist/model/locate-record.js.map +1 -0
- package/dist/model/papers.d.ts +38 -0
- package/dist/model/papers.d.ts.map +1 -0
- package/dist/model/papers.js +91 -0
- package/dist/model/papers.js.map +1 -0
- package/dist/model/records.d.ts +10 -0
- package/dist/model/records.d.ts.map +1 -0
- package/dist/model/records.js +32 -0
- package/dist/model/records.js.map +1 -0
- package/dist/model/relations.d.ts +45 -0
- package/dist/model/relations.d.ts.map +1 -0
- package/dist/model/relations.js +98 -0
- package/dist/model/relations.js.map +1 -0
- package/dist/primitives/badge.d.ts +11 -0
- package/dist/primitives/badge.d.ts.map +1 -0
- package/dist/primitives/badge.js +7 -0
- package/dist/primitives/badge.js.map +1 -0
- package/dist/primitives/button.d.ts +18 -0
- package/dist/primitives/button.d.ts.map +1 -0
- package/dist/primitives/button.js +12 -0
- package/dist/primitives/button.js.map +1 -0
- package/dist/primitives/detail-layout.d.ts +26 -0
- package/dist/primitives/detail-layout.d.ts.map +1 -0
- package/dist/primitives/detail-layout.js +21 -0
- package/dist/primitives/detail-layout.js.map +1 -0
- package/dist/primitives/dialog.d.ts +133 -0
- package/dist/primitives/dialog.d.ts.map +1 -0
- package/dist/primitives/dialog.js +266 -0
- package/dist/primitives/dialog.js.map +1 -0
- package/dist/primitives/index.d.ts +25 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +14 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/kind.d.ts +6 -0
- package/dist/primitives/kind.d.ts.map +1 -0
- package/dist/primitives/kind.js +14 -0
- package/dist/primitives/kind.js.map +1 -0
- package/dist/primitives/prose.d.ts +36 -0
- package/dist/primitives/prose.d.ts.map +1 -0
- package/dist/primitives/prose.js +57 -0
- package/dist/primitives/prose.js.map +1 -0
- package/dist/primitives/record-list.d.ts +31 -0
- package/dist/primitives/record-list.d.ts.map +1 -0
- package/dist/primitives/record-list.js +17 -0
- package/dist/primitives/record-list.js.map +1 -0
- package/dist/primitives/relation-list.d.ts +22 -0
- package/dist/primitives/relation-list.d.ts.map +1 -0
- package/dist/primitives/relation-list.js +13 -0
- package/dist/primitives/relation-list.js.map +1 -0
- package/dist/primitives/surface-header.d.ts +31 -0
- package/dist/primitives/surface-header.d.ts.map +1 -0
- package/dist/primitives/surface-header.js +13 -0
- package/dist/primitives/surface-header.js.map +1 -0
- package/dist/views/index.d.ts +4 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +3 -0
- package/dist/views/index.js.map +1 -0
- package/dist/views/inventory.d.ts +46 -0
- package/dist/views/inventory.d.ts.map +1 -0
- package/dist/views/inventory.js +101 -0
- package/dist/views/inventory.js.map +1 -0
- package/package.json +127 -0
- package/primitives.css +15 -0
- package/src/blocks/analysis-tree.tsx +109 -0
- package/src/blocks/decisions-list.tsx +113 -0
- package/src/blocks/findings-list.tsx +61 -0
- package/src/blocks/index.ts +23 -0
- package/src/blocks/inputs-list.tsx +51 -0
- package/src/blocks/outputs-list.tsx +143 -0
- package/src/blocks/papers-list.tsx +65 -0
- package/src/blocks/prior-insights-list.tsx +52 -0
- package/src/blocks/section.tsx +113 -0
- package/src/components/artifact-preview.tsx +314 -0
- package/src/components/decision-detail.tsx +93 -0
- package/src/components/detail-entry.ts +19 -0
- package/src/components/finding-detail.tsx +99 -0
- package/src/components/index.ts +44 -0
- package/src/components/input-detail.tsx +67 -0
- package/src/components/insight-detail.tsx +120 -0
- package/src/components/insight-trigger.tsx +102 -0
- package/src/components/output-detail.tsx +258 -0
- package/src/components/output-dialog.tsx +63 -0
- package/src/components/paper-detail.tsx +216 -0
- package/src/components/record-dialog.tsx +232 -0
- package/src/components/relation-items.ts +31 -0
- package/src/components/use-detail-stack.ts +78 -0
- package/src/lib/cn.ts +5 -0
- package/src/lib/labels.tsx +145 -0
- package/src/lib/slot.tsx +87 -0
- package/src/model/doi.ts +5 -0
- package/src/model/index.ts +32 -0
- package/src/model/locate-record.ts +13 -0
- package/src/model/papers.ts +146 -0
- package/src/model/records.ts +43 -0
- package/src/model/relations.ts +134 -0
- package/src/primitives/badge.tsx +32 -0
- package/src/primitives/button.tsx +58 -0
- package/src/primitives/detail-layout.tsx +84 -0
- package/src/primitives/dialog.tsx +555 -0
- package/src/primitives/index.ts +48 -0
- package/src/primitives/kind.ts +19 -0
- package/src/primitives/prose.tsx +74 -0
- package/src/primitives/record-list.tsx +103 -0
- package/src/primitives/relation-list.tsx +95 -0
- package/src/primitives/surface-header.tsx +87 -0
- package/src/views/index.ts +3 -0
- package/src/views/inventory.tsx +224 -0
- package/styles/base.css +49 -0
- package/styles/blocks/analysis-tree.css +64 -0
- package/styles/blocks/decisions-list.css +73 -0
- package/styles/blocks/outputs-list.css +349 -0
- package/styles/blocks/papers-list.css +98 -0
- package/styles/blocks/records.css +72 -0
- package/styles/components/artifact-preview.css +242 -0
- package/styles/components/decision-detail.css +159 -0
- package/styles/components/evidence.css +79 -0
- package/styles/components/finding-detail.css +63 -0
- package/styles/components/input-detail.css +95 -0
- package/styles/components/insight-detail.css +138 -0
- package/styles/components/insight-list.css +46 -0
- package/styles/components/insight-trigger.css +54 -0
- package/styles/components/output-detail.css +732 -0
- package/styles/components/paper-detail.css +249 -0
- package/styles/components/paper-doi.css +36 -0
- package/styles/primitives/badge.css +107 -0
- package/styles/primitives/button.css +116 -0
- package/styles/primitives/count-heading.css +27 -0
- package/styles/primitives/detail-layout.css +225 -0
- package/styles/primitives/dialog.css +634 -0
- package/styles/primitives/empty-state.css +10 -0
- package/styles/primitives/kind.css +41 -0
- package/styles/primitives/prose.css +15 -0
- package/styles/primitives/record-list.css +425 -0
- package/styles/primitives/relation-list.css +184 -0
- package/styles/primitives/surface-header.css +183 -0
- package/styles/tokens.css +119 -0
- package/styles/views/inventory.css +186 -0
- package/styles.css +2 -0
- package/views.css +3 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ResolvedAnalysisNode, ResolvedInsight } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { recordTitle } from '../model/records.js';
|
|
4
|
+
import { useLabels } from '../lib/labels.js';
|
|
5
|
+
import { EmptyState, RecordList } from '../primitives/record-list.js';
|
|
6
|
+
import { InventoryRecords } from './section.js';
|
|
7
|
+
|
|
8
|
+
export interface FindingsListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
9
|
+
analysis: ResolvedAnalysisNode;
|
|
10
|
+
onOpenRecord: (finding: ResolvedInsight, analysis: ResolvedAnalysisNode) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function evidenceLabel(count: number): string {
|
|
14
|
+
return `${count} evidence ${count === 1 ? 'item' : 'items'}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Findings with their claim and evidence count. */
|
|
18
|
+
export const FindingsList = forwardRef<HTMLDivElement, FindingsListProps>(function FindingsList({
|
|
19
|
+
analysis,
|
|
20
|
+
onOpenRecord,
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}, ref) {
|
|
24
|
+
const labels = useLabels();
|
|
25
|
+
const records = analysis.findings;
|
|
26
|
+
if (!records.length) {
|
|
27
|
+
return <EmptyState data-slot="findings-list" {...props} ref={ref} className={className}>{labels.empty.findings}</EmptyState>;
|
|
28
|
+
}
|
|
29
|
+
return (
|
|
30
|
+
<InventoryRecords {...props} ref={ref} kind="finding" className={className}>
|
|
31
|
+
<RecordList
|
|
32
|
+
label={labels.sections.findings}
|
|
33
|
+
columnTemplate="minmax(18rem, 1fr) 7rem 1.5rem"
|
|
34
|
+
columns={[
|
|
35
|
+
{ label: 'Finding', className: 'astra-record-list__primary' },
|
|
36
|
+
{ label: 'Evidence', className: 'astra-record-list__count astra-record-list__secondary' },
|
|
37
|
+
{ className: 'astra-record-list__arrow' },
|
|
38
|
+
]}
|
|
39
|
+
rows={records.map((record) => {
|
|
40
|
+
const count = record.evidence.length;
|
|
41
|
+
return {
|
|
42
|
+
key: record.canonicalPath,
|
|
43
|
+
accessibleLabel: `${recordTitle(record)}: ${record.claim} ${evidenceLabel(count)}`,
|
|
44
|
+
onOpen: () => { onOpenRecord(record, analysis); },
|
|
45
|
+
cells: [
|
|
46
|
+
<span className="astra-record-list__name" data-variant="claim">
|
|
47
|
+
<span className="astra-record-list__glyph" aria-hidden="true">●</span>
|
|
48
|
+
<span>
|
|
49
|
+
{record.label ? <small>{record.label}</small> : null}
|
|
50
|
+
<strong>{record.claim}</strong>
|
|
51
|
+
</span>
|
|
52
|
+
</span>,
|
|
53
|
+
<span>{evidenceLabel(count)}</span>,
|
|
54
|
+
<span aria-hidden="true">→</span>,
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
})}
|
|
58
|
+
/>
|
|
59
|
+
</InventoryRecords>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Blocks: sections of the inventory page, composable into any layout. */
|
|
2
|
+
export { AnalysisTree } from './analysis-tree.js';
|
|
3
|
+
export type { AnalysisTreeProps } from './analysis-tree.js';
|
|
4
|
+
export { InventoryOutline, sectionKind, InventoryRecords, InventorySection } from './section.js';
|
|
5
|
+
export type {
|
|
6
|
+
InventoryOutlineEntry,
|
|
7
|
+
InventoryOutlineProps,
|
|
8
|
+
InventoryRecordsProps,
|
|
9
|
+
InventorySectionId,
|
|
10
|
+
InventorySectionProps,
|
|
11
|
+
} from './section.js';
|
|
12
|
+
export { OutputCard, OutputsList } from './outputs-list.js';
|
|
13
|
+
export type { OutputCardProps, OutputsListProps } from './outputs-list.js';
|
|
14
|
+
export { ALL_TAGS, DecisionsList, decisionTagLabel } from './decisions-list.js';
|
|
15
|
+
export type { DecisionsListProps } from './decisions-list.js';
|
|
16
|
+
export { InputsList } from './inputs-list.js';
|
|
17
|
+
export type { InputsListProps } from './inputs-list.js';
|
|
18
|
+
export { FindingsList } from './findings-list.js';
|
|
19
|
+
export type { FindingsListProps } from './findings-list.js';
|
|
20
|
+
export { PriorInsightsList } from './prior-insights-list.js';
|
|
21
|
+
export type { PriorInsightsListProps } from './prior-insights-list.js';
|
|
22
|
+
export { PaperRows, PapersList } from './papers-list.js';
|
|
23
|
+
export type { PaperRowsProps, PapersListProps } from './papers-list.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ResolvedAnalysisNode, ResolvedInput } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { recordTitle } from '../model/records.js';
|
|
4
|
+
import { useLabels } from '../lib/labels.js';
|
|
5
|
+
import { inputSourceLabel } from '../components/input-detail.js';
|
|
6
|
+
import { EmptyState, RecordIdentity, RecordList } from '../primitives/record-list.js';
|
|
7
|
+
import { InventoryRecords } from './section.js';
|
|
8
|
+
|
|
9
|
+
export interface InputsListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
10
|
+
analysis: ResolvedAnalysisNode;
|
|
11
|
+
onOpenRecord: (input: ResolvedInput, analysis: ResolvedAnalysisNode) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Inputs with their declared source and type. */
|
|
15
|
+
export const InputsList = forwardRef<HTMLDivElement, InputsListProps>(function InputsList({
|
|
16
|
+
analysis,
|
|
17
|
+
onOpenRecord,
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
}, ref) {
|
|
21
|
+
const labels = useLabels();
|
|
22
|
+
const records = analysis.inputs;
|
|
23
|
+
if (!records.length) {
|
|
24
|
+
return <EmptyState data-slot="inputs-list" {...props} ref={ref} className={className}>{labels.empty.inputs}</EmptyState>;
|
|
25
|
+
}
|
|
26
|
+
return (
|
|
27
|
+
<InventoryRecords {...props} ref={ref} kind="input" className={className}>
|
|
28
|
+
<RecordList
|
|
29
|
+
label={labels.sections.inputs}
|
|
30
|
+
columnTemplate="minmax(14rem, 1.1fr) minmax(12rem, 1fr) 6.875rem 1.5rem"
|
|
31
|
+
columns={[
|
|
32
|
+
{ label: 'Input', className: 'astra-record-list__primary' },
|
|
33
|
+
{ label: 'Source', className: 'astra-record-list__source' },
|
|
34
|
+
{ label: 'Type', className: 'astra-record-list__secondary' },
|
|
35
|
+
{ className: 'astra-record-list__arrow' },
|
|
36
|
+
]}
|
|
37
|
+
rows={records.map((record) => ({
|
|
38
|
+
key: record.canonicalPath,
|
|
39
|
+
accessibleLabel: recordTitle(record),
|
|
40
|
+
onOpen: () => { onOpenRecord(record, analysis); },
|
|
41
|
+
cells: [
|
|
42
|
+
<RecordIdentity kind="input" title={recordTitle(record)} />,
|
|
43
|
+
<code title={inputSourceLabel(record)}>{inputSourceLabel(record)}</code>,
|
|
44
|
+
<span className="astra-record-list__tag">{record.type}</span>,
|
|
45
|
+
<span aria-hidden="true">→</span>,
|
|
46
|
+
],
|
|
47
|
+
}))}
|
|
48
|
+
/>
|
|
49
|
+
</InventoryRecords>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { ResolvedAnalysisNode, ResolvedOutput } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, useId, type HTMLAttributes } from 'react';
|
|
3
|
+
import { recordTitle } from '../model/records.js';
|
|
4
|
+
import { cn } from '../lib/cn.js';
|
|
5
|
+
import { useLabels } from '../lib/labels.js';
|
|
6
|
+
import type { ArtifactRenderer } from '../components/artifact-preview.js';
|
|
7
|
+
import { EmptyState, RecordIdentity, RecordList } from '../primitives/record-list.js';
|
|
8
|
+
import { OutputPreview } from '../components/output-detail.js';
|
|
9
|
+
|
|
10
|
+
export interface OutputsListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
11
|
+
analysis: ResolvedAnalysisNode;
|
|
12
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
13
|
+
onOpenRecord: (output: ResolvedOutput, analysis: ResolvedAnalysisNode) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
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, type, and title. */
|
|
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
|
+
<span className="astra-output-card__kind">{output.type}</span>
|
|
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 OutputFiles({ outputs, onOpen }: { outputs: ResolvedOutput[]; onOpen: (output: ResolvedOutput) => void }) {
|
|
88
|
+
const id = useId();
|
|
89
|
+
if (!outputs.length) return null;
|
|
90
|
+
return (
|
|
91
|
+
<section className="astra-inventory-outputs__group astra-inventory-outputs__files" aria-labelledby={id}>
|
|
92
|
+
<h3 id={id} className="astra-inventory-outputs__group-heading">
|
|
93
|
+
<span>Other outputs</span>
|
|
94
|
+
</h3>
|
|
95
|
+
<RecordList
|
|
96
|
+
label="Other outputs"
|
|
97
|
+
columnTemplate="minmax(14rem, 1fr) 1.5rem"
|
|
98
|
+
columns={[
|
|
99
|
+
{ label: 'Output', className: 'astra-record-list__primary' },
|
|
100
|
+
{ className: 'astra-record-list__arrow' },
|
|
101
|
+
]}
|
|
102
|
+
rows={outputs.map((output) => ({
|
|
103
|
+
key: output.canonicalPath,
|
|
104
|
+
accessibleLabel: recordTitle(output),
|
|
105
|
+
onOpen: () => { onOpen(output); },
|
|
106
|
+
cells: [
|
|
107
|
+
<RecordIdentity
|
|
108
|
+
kind="output"
|
|
109
|
+
title={recordTitle(output)}
|
|
110
|
+
subtitle={output.label ? output.id : output.format?.toUpperCase()}
|
|
111
|
+
/>,
|
|
112
|
+
<span aria-hidden="true">→</span>,
|
|
113
|
+
],
|
|
114
|
+
}))}
|
|
115
|
+
/>
|
|
116
|
+
</section>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Figures and tables as galleries, everything else as a list. */
|
|
121
|
+
export const OutputsList = forwardRef<HTMLDivElement, OutputsListProps>(function OutputsList({
|
|
122
|
+
analysis,
|
|
123
|
+
renderArtifact,
|
|
124
|
+
onOpenRecord,
|
|
125
|
+
className,
|
|
126
|
+
...props
|
|
127
|
+
}, ref) {
|
|
128
|
+
const labels = useLabels();
|
|
129
|
+
const figures = analysis.outputs.filter(({ type }) => type === 'figure');
|
|
130
|
+
const tables = analysis.outputs.filter(({ type }) => type === 'table');
|
|
131
|
+
const files = analysis.outputs.filter(({ type }) => type !== 'figure' && type !== 'table');
|
|
132
|
+
if (!analysis.outputs.length) {
|
|
133
|
+
return <EmptyState data-slot="outputs-list" {...props} ref={ref} className={className}>{labels.empty.outputs}</EmptyState>;
|
|
134
|
+
}
|
|
135
|
+
const open = (output: ResolvedOutput) => { onOpenRecord(output, analysis); };
|
|
136
|
+
return (
|
|
137
|
+
<div data-slot="outputs-list" {...props} ref={ref} className={cn('astra-inventory-outputs', className)}>
|
|
138
|
+
<OutputGallery title="Figures" outputs={figures} renderArtifact={renderArtifact} onOpen={open} />
|
|
139
|
+
<OutputGallery title="Tables" outputs={tables} renderArtifact={renderArtifact} onOpen={open} />
|
|
140
|
+
<OutputFiles outputs={files} onOpen={open} />
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ResolvedAnalysisNode } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import type { InventoryPaper } from '../model/papers.js';
|
|
4
|
+
import { countLabel } from '../model/records.js';
|
|
5
|
+
import { cn } from '../lib/cn.js';
|
|
6
|
+
import { useLabels } from '../lib/labels.js';
|
|
7
|
+
import { EmptyState } from '../primitives/record-list.js';
|
|
8
|
+
import { InventoryRecords } from './section.js';
|
|
9
|
+
|
|
10
|
+
export interface PapersListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
11
|
+
papers: readonly InventoryPaper[];
|
|
12
|
+
analysis: ResolvedAnalysisNode;
|
|
13
|
+
onOpenPaper: (paper: InventoryPaper, analysis: ResolvedAnalysisNode) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PaperRowsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
17
|
+
papers: readonly InventoryPaper[];
|
|
18
|
+
onOpen: (paper: InventoryPaper) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Cited papers with their insight and decision counts. */
|
|
22
|
+
export const PaperRows = forwardRef<HTMLDivElement, PaperRowsProps>(function PaperRows({ papers, onOpen, className, ...props }, ref) {
|
|
23
|
+
const labels = useLabels();
|
|
24
|
+
return (
|
|
25
|
+
<div data-slot="paper-list" {...props} ref={ref} className={cn('astra-paper-list', className)} role="group" aria-label={labels.sections.papers}>
|
|
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>
|
|
44
|
+
))}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const PapersList = forwardRef<HTMLDivElement, PapersListProps>(function PapersList({
|
|
50
|
+
papers,
|
|
51
|
+
analysis,
|
|
52
|
+
onOpenPaper,
|
|
53
|
+
className,
|
|
54
|
+
...props
|
|
55
|
+
}, ref) {
|
|
56
|
+
const labels = useLabels();
|
|
57
|
+
if (!papers.length) {
|
|
58
|
+
return <EmptyState data-slot="papers-list" {...props} ref={ref} className={className}>{labels.empty.papers}</EmptyState>;
|
|
59
|
+
}
|
|
60
|
+
return (
|
|
61
|
+
<InventoryRecords {...props} ref={ref} kind="paper" className={className}>
|
|
62
|
+
<PaperRows papers={papers} onOpen={(paper) => { onOpenPaper(paper, analysis); }} />
|
|
63
|
+
</InventoryRecords>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ResolvedAnalysisNode, ResolvedInsight } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { countLabel, recordTitle } from '../model/records.js';
|
|
4
|
+
import { useLabels } from '../lib/labels.js';
|
|
5
|
+
import { EmptyState, RecordIdentity, RecordList } from '../primitives/record-list.js';
|
|
6
|
+
import { InventoryRecords } from './section.js';
|
|
7
|
+
|
|
8
|
+
export interface PriorInsightsListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
9
|
+
analysis: ResolvedAnalysisNode;
|
|
10
|
+
onOpenRecord: (insight: ResolvedInsight, analysis: ResolvedAnalysisNode) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Prior insights with their claim and source count. */
|
|
14
|
+
export const PriorInsightsList = forwardRef<HTMLDivElement, PriorInsightsListProps>(function PriorInsightsList({
|
|
15
|
+
analysis,
|
|
16
|
+
onOpenRecord,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}, ref) {
|
|
20
|
+
const labels = useLabels();
|
|
21
|
+
const records = analysis.prior_insights;
|
|
22
|
+
if (!records.length) {
|
|
23
|
+
return <EmptyState data-slot="prior-insights-list" {...props} ref={ref} className={className}>{labels.empty.prior_insights}</EmptyState>;
|
|
24
|
+
}
|
|
25
|
+
return (
|
|
26
|
+
<InventoryRecords {...props} ref={ref} kind="prior_insight" className={className}>
|
|
27
|
+
<RecordList
|
|
28
|
+
label={labels.sections.prior_insights}
|
|
29
|
+
columnTemplate="minmax(18rem, 1fr) 7rem 1.5rem"
|
|
30
|
+
columns={[
|
|
31
|
+
{ label: 'Prior insight', className: 'astra-record-list__primary' },
|
|
32
|
+
{ label: 'Evidence', className: 'astra-record-list__count astra-record-list__secondary' },
|
|
33
|
+
{ className: 'astra-record-list__arrow' },
|
|
34
|
+
]}
|
|
35
|
+
rows={records.map((record) => ({
|
|
36
|
+
key: record.canonicalPath,
|
|
37
|
+
accessibleLabel: `${recordTitle(record)}: ${record.claim} ${countLabel(record.evidence.length, 'source')}`,
|
|
38
|
+
onOpen: () => { onOpenRecord(record, analysis); },
|
|
39
|
+
cells: [
|
|
40
|
+
<RecordIdentity
|
|
41
|
+
kind="prior_insight"
|
|
42
|
+
title={record.claim}
|
|
43
|
+
subtitle={record.label ? record.id : undefined}
|
|
44
|
+
/>,
|
|
45
|
+
<span>{countLabel(record.evidence.length, 'source')}</span>,
|
|
46
|
+
<span aria-hidden="true">→</span>,
|
|
47
|
+
],
|
|
48
|
+
}))}
|
|
49
|
+
/>
|
|
50
|
+
</InventoryRecords>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import { surfaceGlyph, type SurfaceKind } from '../primitives/kind.js';
|
|
4
|
+
import { useLabels } from '../lib/labels.js';
|
|
5
|
+
|
|
6
|
+
export type InventorySectionId = 'outputs' | 'decisions' | 'inputs' | 'findings' | 'prior_insights' | 'papers';
|
|
7
|
+
|
|
8
|
+
export interface InventorySectionProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
9
|
+
/** Anchor id for the heading; also the outline link target. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Which built-in section this is, for the section-specific layout hooks. */
|
|
12
|
+
section?: InventorySectionId | undefined;
|
|
13
|
+
title: ReactNode;
|
|
14
|
+
count?: number | undefined;
|
|
15
|
+
/** Text shown for the count, e.g. "65 outputs"; defaults to the bare number. */
|
|
16
|
+
countLabel?: ReactNode | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A titled, counted block of the inventory page. */
|
|
20
|
+
export const InventorySection = forwardRef<HTMLElement, InventorySectionProps>(function InventorySection({
|
|
21
|
+
id,
|
|
22
|
+
section,
|
|
23
|
+
title,
|
|
24
|
+
count,
|
|
25
|
+
countLabel,
|
|
26
|
+
className,
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}, ref) {
|
|
30
|
+
return (
|
|
31
|
+
<section
|
|
32
|
+
data-slot="inventory-section"
|
|
33
|
+
{...props}
|
|
34
|
+
ref={ref}
|
|
35
|
+
className={cn('astra-inventory__section', className)}
|
|
36
|
+
{...(section ? { 'data-section': section } : {})}
|
|
37
|
+
>
|
|
38
|
+
<div className="astra-inventory__heading">
|
|
39
|
+
<h2 id={id} tabIndex={-1}>
|
|
40
|
+
<span>{title}</span>
|
|
41
|
+
</h2>
|
|
42
|
+
{count !== undefined ? <span>{countLabel ?? count}</span> : null}
|
|
43
|
+
</div>
|
|
44
|
+
{children}
|
|
45
|
+
</section>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** The record kind each inventory section lists; drives the outline glyph and colour. */
|
|
50
|
+
export function sectionKind(section: InventorySectionId): SurfaceKind {
|
|
51
|
+
switch (section) {
|
|
52
|
+
case 'outputs': return 'output';
|
|
53
|
+
case 'decisions': return 'decision';
|
|
54
|
+
case 'inputs': return 'input';
|
|
55
|
+
case 'findings': return 'finding';
|
|
56
|
+
case 'prior_insights': return 'prior_insight';
|
|
57
|
+
case 'papers': return 'paper';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface InventoryOutlineEntry {
|
|
62
|
+
id: string;
|
|
63
|
+
label: ReactNode;
|
|
64
|
+
count?: number | undefined;
|
|
65
|
+
/** Shows the kind's glyph in the kind's colour before the label. */
|
|
66
|
+
kind?: SurfaceKind | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface InventoryOutlineProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
70
|
+
entries: InventoryOutlineEntry[];
|
|
71
|
+
title?: ReactNode | undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The sticky "on this page" list of section anchors. */
|
|
75
|
+
export const InventoryOutline = forwardRef<HTMLElement, InventoryOutlineProps>(function InventoryOutline({
|
|
76
|
+
entries,
|
|
77
|
+
title,
|
|
78
|
+
className,
|
|
79
|
+
...props
|
|
80
|
+
}, ref) {
|
|
81
|
+
const labels = useLabels();
|
|
82
|
+
return (
|
|
83
|
+
<aside
|
|
84
|
+
data-slot="inventory-outline"
|
|
85
|
+
{...props}
|
|
86
|
+
ref={ref}
|
|
87
|
+
className={cn('astra-inventory-outline', className)}
|
|
88
|
+
aria-label={labels.outline}
|
|
89
|
+
>
|
|
90
|
+
<h3>{title ?? labels.outline}</h3>
|
|
91
|
+
<nav>
|
|
92
|
+
{entries.map((entry) => (
|
|
93
|
+
<a key={entry.id} href={`#${entry.id}`}>
|
|
94
|
+
<span className="astra-inventory-outline__glyph" {...(entry.kind ? { 'data-kind': entry.kind } : {})} aria-hidden="true">
|
|
95
|
+
{entry.kind ? surfaceGlyph(entry.kind) : null}
|
|
96
|
+
</span>
|
|
97
|
+
<span>{entry.label}</span>
|
|
98
|
+
{entry.count !== undefined ? <span>{entry.count}</span> : null}
|
|
99
|
+
</a>
|
|
100
|
+
))}
|
|
101
|
+
</nav>
|
|
102
|
+
</aside>
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export interface InventoryRecordsProps extends HTMLAttributes<HTMLDivElement> {
|
|
107
|
+
kind: 'output' | 'decision' | 'input' | 'finding' | 'prior_insight' | 'paper';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Wrapper that gives a per-kind list its layout hooks. */
|
|
111
|
+
export const InventoryRecords = forwardRef<HTMLDivElement, InventoryRecordsProps>(function InventoryRecords({ kind, className, ...props }, ref) {
|
|
112
|
+
return <div data-slot="inventory-records" {...props} ref={ref} className={cn('astra-inventory-records', className)} data-kind={kind} />;
|
|
113
|
+
});
|