@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,48 @@
|
|
|
1
|
+
/** Presentation primitives: generic UI with no ASTRA model beyond record kinds. */
|
|
2
|
+
export { cn } from '../lib/cn.js';
|
|
3
|
+
export { Slot } from '../lib/slot.js';
|
|
4
|
+
export type { SlotProps } from '../lib/slot.js';
|
|
5
|
+
export { LabelsProvider, defaultLabels, mergeLabels, useLabels } from '../lib/labels.js';
|
|
6
|
+
export type { AstraLabelOverrides, AstraLabels, LabelsProviderProps } from '../lib/labels.js';
|
|
7
|
+
export { surfaceGlyph } from './kind.js';
|
|
8
|
+
export type { SurfaceKind } from './kind.js';
|
|
9
|
+
export { Button, IconButton } from './button.js';
|
|
10
|
+
export type { ButtonProps, ButtonSize, ButtonTone, ButtonVariant, IconButtonProps } from './button.js';
|
|
11
|
+
export { Badge } from './badge.js';
|
|
12
|
+
export type { BadgeProps, BadgeStatus, BadgeTone } from './badge.js';
|
|
13
|
+
export { SurfaceHeader } from './surface-header.js';
|
|
14
|
+
export type { SurfaceHeaderDensity, SurfaceHeaderProps, SurfaceHeadingLevel } from './surface-header.js';
|
|
15
|
+
export {
|
|
16
|
+
DetailDialog,
|
|
17
|
+
Dialog,
|
|
18
|
+
DialogAction,
|
|
19
|
+
DialogBack,
|
|
20
|
+
DialogBody,
|
|
21
|
+
DialogClose,
|
|
22
|
+
DialogContent,
|
|
23
|
+
DialogHeader,
|
|
24
|
+
DialogProvider,
|
|
25
|
+
useDialog,
|
|
26
|
+
useDialogDismissGuard,
|
|
27
|
+
} from './dialog.js';
|
|
28
|
+
export type {
|
|
29
|
+
DetailDialogProps,
|
|
30
|
+
DialogActionProps,
|
|
31
|
+
DialogBackProps,
|
|
32
|
+
DialogCloseProps,
|
|
33
|
+
DialogContentProps,
|
|
34
|
+
DialogContextValue,
|
|
35
|
+
DialogHeaderProps,
|
|
36
|
+
DialogLayout,
|
|
37
|
+
DialogMode,
|
|
38
|
+
DialogProps,
|
|
39
|
+
DialogProviderProps,
|
|
40
|
+
} from './dialog.js';
|
|
41
|
+
export { EmptyState, RecordIdentity, RecordList } from './record-list.js';
|
|
42
|
+
export type { RecordIdentityProps, RecordListColumn, RecordListProps, RecordListRow } from './record-list.js';
|
|
43
|
+
export { RelationList } from './relation-list.js';
|
|
44
|
+
export type { RelationItem, RelationListProps } from './relation-list.js';
|
|
45
|
+
export { CountHeading, DetailLayout, DetailMain, DetailRail, DetailSection } from './detail-layout.js';
|
|
46
|
+
export type { CountHeadingProps, DetailLayoutMode, DetailLayoutProps, DetailRailProps, DetailSectionProps } from './detail-layout.js';
|
|
47
|
+
export { Prose, parseProse, renderProse } from './prose.js';
|
|
48
|
+
export type { ProseContext, ProseField, ProseProps, ProseToken, TextRenderer } from './prose.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResolvedRecord } from '@astra-spec/sdk';
|
|
2
|
+
|
|
3
|
+
/** Record kinds plus the two non-record surfaces the UI colours. */
|
|
4
|
+
export type SurfaceKind = ResolvedRecord['kind'] | 'analysis' | 'paper';
|
|
5
|
+
|
|
6
|
+
const SURFACE_GLYPHS: Record<SurfaceKind, string> = {
|
|
7
|
+
analysis: '◐',
|
|
8
|
+
input: '↳',
|
|
9
|
+
decision: '◇',
|
|
10
|
+
output: '◆',
|
|
11
|
+
finding: '●',
|
|
12
|
+
prior_insight: '◈',
|
|
13
|
+
paper: '▧',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** The glyph that identifies a kind in lists, relations, and headers. */
|
|
17
|
+
export function surfaceGlyph(kind: SurfaceKind): string {
|
|
18
|
+
return SURFACE_GLYPHS[kind];
|
|
19
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Fragment, type ReactNode } from 'react';
|
|
2
|
+
import { renderToString } from 'katex';
|
|
3
|
+
|
|
4
|
+
export type ProseField = 'claim' | 'rationale' | 'description' | 'notes' | 'quote';
|
|
5
|
+
|
|
6
|
+
export interface ProseContext {
|
|
7
|
+
/** Which authored field is being rendered, when known. */
|
|
8
|
+
field?: ProseField | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Host-owned rendering for authored prose (Markdown, citations, ...); replaces the built-in rendering. */
|
|
12
|
+
export type TextRenderer = (text: string, context: ProseContext) => ReactNode;
|
|
13
|
+
|
|
14
|
+
export type ProseToken =
|
|
15
|
+
| { type: 'text'; value: string }
|
|
16
|
+
| { type: 'inlineCode'; value: string }
|
|
17
|
+
| { type: 'inlineMath'; value: string }
|
|
18
|
+
| { type: 'math'; value: string };
|
|
19
|
+
|
|
20
|
+
/** Balanced tokens: display math first, then `code`, then inline math. */
|
|
21
|
+
const PROSE_TOKEN = /(\$\$[\s\S]+?\$\$|`[^`\n]+`|\$[^$\n]+\$)/g;
|
|
22
|
+
|
|
23
|
+
/** Splits authored prose into text, inline `code`, `$inline$` and `$$display$$` math. */
|
|
24
|
+
export function parseProse(text: string): ProseToken[] {
|
|
25
|
+
const nodes: ProseToken[] = [];
|
|
26
|
+
let last = 0;
|
|
27
|
+
for (const match of text.matchAll(PROSE_TOKEN)) {
|
|
28
|
+
const index = match.index;
|
|
29
|
+
if (index > last) nodes.push({ type: 'text', value: text.slice(last, index) });
|
|
30
|
+
const token = match[0];
|
|
31
|
+
if (token.startsWith('$$')) nodes.push({ type: 'math', value: token.slice(2, -2).trim() });
|
|
32
|
+
else if (token.startsWith('`')) nodes.push({ type: 'inlineCode', value: token.slice(1, -1) });
|
|
33
|
+
else nodes.push({ type: 'inlineMath', value: token.slice(1, -1) });
|
|
34
|
+
last = index + token.length;
|
|
35
|
+
}
|
|
36
|
+
if (last < text.length) nodes.push({ type: 'text', value: text.slice(last) });
|
|
37
|
+
return nodes;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function renderMath(value: string, displayMode: boolean): string {
|
|
41
|
+
return renderToString(value, { displayMode, output: 'htmlAndMathml', strict: 'ignore', throwOnError: false });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The built-in rendering: inline `code`, and `$inline$` / `$$display$$` math
|
|
46
|
+
* typeset with KaTeX (load `katex/dist/katex.css`; the stylesheet bundles
|
|
47
|
+
* import it). Text without those markers is returned as is.
|
|
48
|
+
*/
|
|
49
|
+
export function renderProse(text: string): ReactNode {
|
|
50
|
+
if (!/[`$]/.test(text)) return text;
|
|
51
|
+
return parseProse(text).map((node, index) => {
|
|
52
|
+
switch (node.type) {
|
|
53
|
+
case 'inlineCode':
|
|
54
|
+
return <code key={index}>{node.value}</code>;
|
|
55
|
+
case 'inlineMath':
|
|
56
|
+
return <span key={index} className="astra-prose__inline-math" dangerouslySetInnerHTML={{ __html: renderMath(node.value, false) }} />;
|
|
57
|
+
case 'math':
|
|
58
|
+
return <div key={index} className="astra-prose__display-math" dangerouslySetInnerHTML={{ __html: renderMath(node.value, true) }} />;
|
|
59
|
+
default:
|
|
60
|
+
return <Fragment key={index}>{node.value}</Fragment>;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ProseProps extends ProseContext {
|
|
66
|
+
text?: string | undefined;
|
|
67
|
+
renderText?: TextRenderer | undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Authored prose: the host's `renderText` when given, otherwise `renderProse`. */
|
|
71
|
+
export function Prose({ text, field, renderText }: ProseProps) {
|
|
72
|
+
if (!text) return null;
|
|
73
|
+
return <>{renderText ? renderText(text, { field }) : renderProse(text)}</>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { forwardRef, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import { surfaceGlyph, type SurfaceKind } from './kind.js';
|
|
4
|
+
|
|
5
|
+
export interface RecordListColumn {
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
className?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface RecordListRow {
|
|
11
|
+
key: string;
|
|
12
|
+
accessibleLabel: string;
|
|
13
|
+
cells: ReactNode[];
|
|
14
|
+
onOpen: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RecordListProps extends HTMLAttributes<HTMLDivElement> {
|
|
18
|
+
/** Accessible name of the list (announced as a group). */
|
|
19
|
+
label: string;
|
|
20
|
+
columns: RecordListColumn[];
|
|
21
|
+
/** CSS grid template for the row columns. */
|
|
22
|
+
columnTemplate: string;
|
|
23
|
+
rows: RecordListRow[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A column-aligned list of clickable record rows. */
|
|
27
|
+
export const RecordList = forwardRef<HTMLDivElement, RecordListProps>(function RecordList({
|
|
28
|
+
label,
|
|
29
|
+
columns,
|
|
30
|
+
columnTemplate,
|
|
31
|
+
rows,
|
|
32
|
+
className,
|
|
33
|
+
style,
|
|
34
|
+
...props
|
|
35
|
+
}, ref) {
|
|
36
|
+
const gridStyle = { ...style, '--astra-record-columns': columnTemplate } as CSSProperties;
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
data-slot="record-list"
|
|
40
|
+
{...props}
|
|
41
|
+
ref={ref}
|
|
42
|
+
className={cn('astra-record-list', className)}
|
|
43
|
+
role="group"
|
|
44
|
+
aria-label={label}
|
|
45
|
+
style={gridStyle}
|
|
46
|
+
>
|
|
47
|
+
<div className="astra-record-list__head" aria-hidden="true">
|
|
48
|
+
{columns.map((column, index) => (
|
|
49
|
+
<span key={`${column.label ?? 'blank'}-${index}`} className={column.className}>
|
|
50
|
+
{column.label}
|
|
51
|
+
</span>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
<div className="astra-record-list__body">
|
|
55
|
+
{rows.map((row) => (
|
|
56
|
+
<button
|
|
57
|
+
key={row.key}
|
|
58
|
+
type="button"
|
|
59
|
+
aria-label={row.accessibleLabel}
|
|
60
|
+
onClick={row.onOpen}
|
|
61
|
+
>
|
|
62
|
+
{row.cells.map((cell, index) => (
|
|
63
|
+
<span key={index} className={columns[index]?.className}>{cell}</span>
|
|
64
|
+
))}
|
|
65
|
+
</button>
|
|
66
|
+
))}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export interface RecordIdentityProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'title'> {
|
|
73
|
+
kind: SurfaceKind;
|
|
74
|
+
title: ReactNode;
|
|
75
|
+
subtitle?: ReactNode | undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Glyph, title, and optional subtitle for a record row. */
|
|
79
|
+
export const RecordIdentity = forwardRef<HTMLSpanElement, RecordIdentityProps>(function RecordIdentity({
|
|
80
|
+
kind,
|
|
81
|
+
title,
|
|
82
|
+
subtitle,
|
|
83
|
+
className,
|
|
84
|
+
...props
|
|
85
|
+
}, ref) {
|
|
86
|
+
return (
|
|
87
|
+
<span data-slot="record-identity" {...props} ref={ref} className={cn('astra-record-list__name', className)}>
|
|
88
|
+
<span className="astra-record-list__glyph" data-kind={kind} aria-hidden="true">
|
|
89
|
+
{surfaceGlyph(kind)}
|
|
90
|
+
</span>
|
|
91
|
+
<span>
|
|
92
|
+
<strong>{title}</strong>
|
|
93
|
+
{subtitle != null ? <small>{subtitle}</small> : null}
|
|
94
|
+
</span>
|
|
95
|
+
</span>
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const EmptyState = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(
|
|
100
|
+
function EmptyState({ className, ...props }, ref) {
|
|
101
|
+
return <p data-slot="empty-state" {...props} ref={ref} className={cn('astra-empty-state', className)} />;
|
|
102
|
+
},
|
|
103
|
+
);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import { CountHeading } from './detail-layout.js';
|
|
4
|
+
import { surfaceGlyph, type SurfaceKind } from './kind.js';
|
|
5
|
+
|
|
6
|
+
export interface RelationItem {
|
|
7
|
+
key: string;
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
identifier?: ReactNode | undefined;
|
|
10
|
+
detail?: ReactNode | undefined;
|
|
11
|
+
kind?: SurfaceKind | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
accessibleLabel?: string | undefined;
|
|
14
|
+
onOpen?: (() => void) | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RelationListProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
18
|
+
title: ReactNode;
|
|
19
|
+
items: RelationItem[];
|
|
20
|
+
empty: ReactNode;
|
|
21
|
+
headerAction?: ReactNode | undefined;
|
|
22
|
+
description?: ReactNode | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function RelationItemContent({ item }: { item: RelationItem }) {
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<span
|
|
29
|
+
className="astra-relation-item__glyph"
|
|
30
|
+
{...(item.kind ? {} : { 'data-empty': '' })}
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
>
|
|
33
|
+
{item.kind ? surfaceGlyph(item.kind) : ''}
|
|
34
|
+
</span>
|
|
35
|
+
<span className="astra-relation-item__copy">
|
|
36
|
+
<span className="astra-relation-item__label">{item.label}</span>
|
|
37
|
+
{item.identifier != null ? <code>{item.identifier}</code> : null}
|
|
38
|
+
</span>
|
|
39
|
+
{item.detail != null ? <small>{item.detail}</small> : null}
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A titled, counted list of related records; items with `onOpen` become navigation triggers. */
|
|
45
|
+
export const RelationList = forwardRef<HTMLElement, RelationListProps>(function RelationList({
|
|
46
|
+
title,
|
|
47
|
+
items,
|
|
48
|
+
empty,
|
|
49
|
+
headerAction,
|
|
50
|
+
description,
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
}, ref) {
|
|
54
|
+
return (
|
|
55
|
+
<section data-slot="relation-list" {...props} ref={ref} className={cn('astra-relation-list', className)}>
|
|
56
|
+
{headerAction ? (
|
|
57
|
+
<div className="astra-relation-list__header">
|
|
58
|
+
<CountHeading title={title} count={items.length} />
|
|
59
|
+
{headerAction}
|
|
60
|
+
</div>
|
|
61
|
+
) : (
|
|
62
|
+
<CountHeading title={title} count={items.length} />
|
|
63
|
+
)}
|
|
64
|
+
{description ? (
|
|
65
|
+
<p className="astra-relation-list__description">{description}</p>
|
|
66
|
+
) : null}
|
|
67
|
+
{items.length ? (
|
|
68
|
+
<ul>
|
|
69
|
+
{items.map((item) => (
|
|
70
|
+
<li
|
|
71
|
+
key={item.key}
|
|
72
|
+
data-kind={item.kind}
|
|
73
|
+
{...(item.onOpen ? { 'data-interactive': '' } : {})}
|
|
74
|
+
className={item.className}
|
|
75
|
+
>
|
|
76
|
+
{item.onOpen ? (
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
className="astra-relation-list__trigger"
|
|
80
|
+
aria-label={item.accessibleLabel}
|
|
81
|
+
onClick={item.onOpen}
|
|
82
|
+
>
|
|
83
|
+
<RelationItemContent item={item} />
|
|
84
|
+
<span aria-hidden="true">→</span>
|
|
85
|
+
</button>
|
|
86
|
+
) : (
|
|
87
|
+
<RelationItemContent item={item} />
|
|
88
|
+
)}
|
|
89
|
+
</li>
|
|
90
|
+
))}
|
|
91
|
+
</ul>
|
|
92
|
+
) : empty != null ? <p>{empty}</p> : null}
|
|
93
|
+
</section>
|
|
94
|
+
);
|
|
95
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import type { SurfaceKind } from './kind.js';
|
|
4
|
+
|
|
5
|
+
export type SurfaceHeaderDensity = 'compact' | 'regular' | 'inline';
|
|
6
|
+
export type SurfaceHeadingLevel = 'h1' | 'h2' | 'h3' | 'h4';
|
|
7
|
+
|
|
8
|
+
export interface SurfaceHeaderProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
9
|
+
leading?: ReactNode | undefined;
|
|
10
|
+
eyebrow?: ReactNode | undefined;
|
|
11
|
+
title?: ReactNode | undefined;
|
|
12
|
+
titleId?: string | undefined;
|
|
13
|
+
titleAs?: SurfaceHeadingLevel | undefined;
|
|
14
|
+
identifier?: ReactNode | undefined;
|
|
15
|
+
actions?: ReactNode | undefined;
|
|
16
|
+
density?: SurfaceHeaderDensity | undefined;
|
|
17
|
+
kind?: SurfaceKind | undefined;
|
|
18
|
+
/** Class names for the header's parts; every part also carries a `data-slot`. */
|
|
19
|
+
classNames?: {
|
|
20
|
+
leading?: string | undefined;
|
|
21
|
+
content?: string | undefined;
|
|
22
|
+
eyebrow?: string | undefined;
|
|
23
|
+
title?: string | undefined;
|
|
24
|
+
identifier?: string | undefined;
|
|
25
|
+
actions?: string | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Titled header for details, popovers, and inline artifact metadata:
|
|
31
|
+
* leading slot, eyebrow, title, identifier, and trailing actions. Layout only;
|
|
32
|
+
* interaction belongs to the surface that owns it.
|
|
33
|
+
*/
|
|
34
|
+
export const SurfaceHeader = forwardRef<HTMLElement, SurfaceHeaderProps>(function SurfaceHeader({
|
|
35
|
+
leading,
|
|
36
|
+
eyebrow,
|
|
37
|
+
title,
|
|
38
|
+
titleId,
|
|
39
|
+
titleAs = 'h2',
|
|
40
|
+
identifier,
|
|
41
|
+
actions,
|
|
42
|
+
className,
|
|
43
|
+
classNames,
|
|
44
|
+
density = 'regular',
|
|
45
|
+
kind,
|
|
46
|
+
...props
|
|
47
|
+
}, ref) {
|
|
48
|
+
const Heading = titleAs;
|
|
49
|
+
return (
|
|
50
|
+
<header
|
|
51
|
+
data-slot="surface-header"
|
|
52
|
+
{...props}
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn('astra-surface-header', className)}
|
|
55
|
+
data-density={density}
|
|
56
|
+
{...(kind ? { 'data-kind': kind } : {})}
|
|
57
|
+
>
|
|
58
|
+
{leading != null ? (
|
|
59
|
+
<div data-slot="surface-header-leading" className={cn('astra-surface-header__leading', classNames?.leading)}>
|
|
60
|
+
{leading}
|
|
61
|
+
</div>
|
|
62
|
+
) : null}
|
|
63
|
+
<div data-slot="surface-header-content" className={cn('astra-surface-header__content', classNames?.content)}>
|
|
64
|
+
{eyebrow != null ? (
|
|
65
|
+
<div data-slot="surface-header-eyebrow" className={cn('astra-surface-header__eyebrow', classNames?.eyebrow)}>
|
|
66
|
+
{eyebrow}
|
|
67
|
+
</div>
|
|
68
|
+
) : null}
|
|
69
|
+
{title != null ? (
|
|
70
|
+
<Heading id={titleId} data-slot="surface-header-title" className={cn('astra-surface-header__title', classNames?.title)}>
|
|
71
|
+
{title}
|
|
72
|
+
</Heading>
|
|
73
|
+
) : null}
|
|
74
|
+
{identifier != null ? (
|
|
75
|
+
<code data-slot="surface-header-identifier" className={cn('astra-surface-header__identifier', classNames?.identifier)}>
|
|
76
|
+
{identifier}
|
|
77
|
+
</code>
|
|
78
|
+
) : null}
|
|
79
|
+
</div>
|
|
80
|
+
{actions != null ? (
|
|
81
|
+
<div data-slot="surface-header-actions" className={cn('astra-surface-header__actions', classNames?.actions)}>
|
|
82
|
+
{actions}
|
|
83
|
+
</div>
|
|
84
|
+
) : null}
|
|
85
|
+
</header>
|
|
86
|
+
);
|
|
87
|
+
});
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {
|
|
2
|
+
indexAnalysis,
|
|
3
|
+
type AnalysisIndex,
|
|
4
|
+
type ResolvedAnalysisDocument,
|
|
5
|
+
type ResolvedAnalysisNode,
|
|
6
|
+
type ResolvedOutput,
|
|
7
|
+
type ResolvedRecord,
|
|
8
|
+
} from '@astra-spec/sdk';
|
|
9
|
+
import { forwardRef, useEffect, useMemo, useRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
10
|
+
import { collectInventoryPapers, findPaper, paperForDoi, type InventoryPaper, type InventoryPaperMetadataMap } from '../model/papers.js';
|
|
11
|
+
import { locateRecord } from '../model/locate-record.js';
|
|
12
|
+
import { cn } from '../lib/cn.js';
|
|
13
|
+
import { LabelsProvider, useLabels, type AstraLabelOverrides } from '../lib/labels.js';
|
|
14
|
+
import type { DetailEntry } from '../components/detail-entry.js';
|
|
15
|
+
import type { PaperRenderer } from '../components/paper-detail.js';
|
|
16
|
+
import { RecordDialog } from '../components/record-dialog.js';
|
|
17
|
+
import { useDetailStack } from '../components/use-detail-stack.js';
|
|
18
|
+
import type { ArtifactRenderer } from '../components/artifact-preview.js';
|
|
19
|
+
import { DialogProvider, type DialogMode } from '../primitives/dialog.js';
|
|
20
|
+
import type { TextRenderer } from '../primitives/prose.js';
|
|
21
|
+
import { DecisionsList } from '../blocks/decisions-list.js';
|
|
22
|
+
import { FindingsList } from '../blocks/findings-list.js';
|
|
23
|
+
import { InputsList } from '../blocks/inputs-list.js';
|
|
24
|
+
import { OutputsList } from '../blocks/outputs-list.js';
|
|
25
|
+
import { PapersList } from '../blocks/papers-list.js';
|
|
26
|
+
import { PriorInsightsList } from '../blocks/prior-insights-list.js';
|
|
27
|
+
import { InventoryOutline, InventorySection, sectionKind, type InventorySectionId } from '../blocks/section.js';
|
|
28
|
+
|
|
29
|
+
export const DEFAULT_SECTIONS: readonly InventorySectionId[] = ['outputs', 'decisions', 'inputs', 'findings', 'prior_insights', 'papers'];
|
|
30
|
+
|
|
31
|
+
export interface InventoryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
32
|
+
document: ResolvedAnalysisDocument;
|
|
33
|
+
/** Pass a prebuilt index to share it with the host; otherwise one is derived from `document`. */
|
|
34
|
+
index?: AnalysisIndex | undefined;
|
|
35
|
+
/** Canonical analysis path; `$` selects the project root. A path the document does not contain shows the root. */
|
|
36
|
+
analysisPath?: string | undefined;
|
|
37
|
+
/** Which sections to show, in order. */
|
|
38
|
+
sections?: readonly InventorySectionId[] | undefined;
|
|
39
|
+
/** Prefix for section anchor ids, so several explorers can share a page. */
|
|
40
|
+
idPrefix?: string | undefined;
|
|
41
|
+
showOutline?: boolean | undefined;
|
|
42
|
+
labels?: AstraLabelOverrides | undefined;
|
|
43
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
44
|
+
renderText?: TextRenderer | undefined;
|
|
45
|
+
renderPaper?: PaperRenderer | undefined;
|
|
46
|
+
onOpenArtifact?: ((output: ResolvedOutput) => void | Promise<void>) | undefined;
|
|
47
|
+
paperMetadata?: InventoryPaperMetadataMap | undefined;
|
|
48
|
+
/** Notify the host to fetch this DOI; update paperMetadata when complete. */
|
|
49
|
+
onFetchPaper?: ((doi: string) => void) | undefined;
|
|
50
|
+
decisionTagLabels?: Readonly<Record<string, string>> | undefined;
|
|
51
|
+
detailMode?: DialogMode | undefined;
|
|
52
|
+
/** The open detail stack (controlled); pair with `onDetailChange`. */
|
|
53
|
+
detail?: DetailEntry[] | undefined;
|
|
54
|
+
defaultDetail?: DetailEntry[] | undefined;
|
|
55
|
+
onDetailChange?: ((next: DetailEntry[]) => void) | undefined;
|
|
56
|
+
/** Extra content rendered after the built-in sections. */
|
|
57
|
+
children?: ReactNode | undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const EMPTY_PAPER_METADATA: InventoryPaperMetadataMap = {};
|
|
61
|
+
|
|
62
|
+
function entryLabel(entry: DetailEntry, papers: readonly InventoryPaper[]): string {
|
|
63
|
+
return entry.kind === 'paper'
|
|
64
|
+
? findPaper(papers, entry.doi)?.title ?? entry.doi
|
|
65
|
+
: entry.canonicalPath.split('.').at(-1) ?? entry.canonicalPath;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The ready-made inventory page: per-kind sections, an outline, and a
|
|
70
|
+
* detail dialog stack. Every piece is exported separately for hosts that
|
|
71
|
+
* compose their own layout.
|
|
72
|
+
*/
|
|
73
|
+
export const Inventory = forwardRef<HTMLDivElement, InventoryProps>(function Inventory({ labels, ...props }, ref) {
|
|
74
|
+
return (
|
|
75
|
+
<LabelsProvider labels={labels}>
|
|
76
|
+
<ExplorerBody {...props} ref={ref} />
|
|
77
|
+
</LabelsProvider>
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(function ExplorerBody({
|
|
82
|
+
document,
|
|
83
|
+
index: providedIndex,
|
|
84
|
+
analysisPath = '$',
|
|
85
|
+
sections = DEFAULT_SECTIONS,
|
|
86
|
+
idPrefix = '',
|
|
87
|
+
showOutline = true,
|
|
88
|
+
renderArtifact,
|
|
89
|
+
renderText,
|
|
90
|
+
renderPaper,
|
|
91
|
+
onOpenArtifact,
|
|
92
|
+
paperMetadata = EMPTY_PAPER_METADATA,
|
|
93
|
+
onFetchPaper,
|
|
94
|
+
decisionTagLabels = {},
|
|
95
|
+
detailMode = 'modal',
|
|
96
|
+
detail,
|
|
97
|
+
defaultDetail,
|
|
98
|
+
onDetailChange,
|
|
99
|
+
className,
|
|
100
|
+
children,
|
|
101
|
+
...rest
|
|
102
|
+
}, ref) {
|
|
103
|
+
const labels = useLabels();
|
|
104
|
+
const index = useMemo(() => providedIndex ?? indexAnalysis(document), [document, providedIndex]);
|
|
105
|
+
const analysis = index.analysisByPath.get(analysisPath) ?? document.analysis;
|
|
106
|
+
const papers = useMemo(
|
|
107
|
+
() => collectInventoryPapers(document, index, analysis, paperMetadata),
|
|
108
|
+
[analysis, document, index, paperMetadata],
|
|
109
|
+
);
|
|
110
|
+
const stack = useDetailStack({ value: detail, defaultValue: defaultDetail, onChange: onDetailChange });
|
|
111
|
+
|
|
112
|
+
// Switching analysis closes any open detail (uncontrolled stacks only), and
|
|
113
|
+
// entries that stopped resolving after a document refresh are pruned so the
|
|
114
|
+
// host's view of the stack stays truthful. One effect, so a single commit
|
|
115
|
+
// makes at most one change: closing must not be followed by a prune of the
|
|
116
|
+
// stack it just replaced. It runs after render, never inside it, because it
|
|
117
|
+
// notifies the host.
|
|
118
|
+
const lastAnalysis = useRef(analysis.canonicalPath);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const analysisChanged = lastAnalysis.current !== analysis.canonicalPath;
|
|
121
|
+
lastAnalysis.current = analysis.canonicalPath;
|
|
122
|
+
if (analysisChanged && detail === undefined) {
|
|
123
|
+
if (stack.stack.length) stack.close();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const resolves = (entry: DetailEntry) => {
|
|
127
|
+
const owner = index.analysisByPath.get(entry.analysisPath);
|
|
128
|
+
if (!owner) return false;
|
|
129
|
+
if (entry.kind === 'paper') return Boolean(findPaper(papers, entry.doi) ?? paperForDoi(document, index, owner, entry.doi, paperMetadata));
|
|
130
|
+
return Boolean(locateRecord(index, entry.canonicalPath));
|
|
131
|
+
};
|
|
132
|
+
const next = stack.stack.filter(resolves);
|
|
133
|
+
if (next.length !== stack.stack.length) stack.set(next);
|
|
134
|
+
}, [analysis.canonicalPath, detail, document, index, paperMetadata, papers, stack]);
|
|
135
|
+
|
|
136
|
+
const openRecord = (record: ResolvedRecord, owner: ResolvedAnalysisNode) => { stack.openRecord(record, owner); };
|
|
137
|
+
|
|
138
|
+
const sectionContent: Record<InventorySectionId, { count: number; content: ReactNode }> = {
|
|
139
|
+
outputs: {
|
|
140
|
+
count: analysis.outputs.length,
|
|
141
|
+
content: <OutputsList analysis={analysis} renderArtifact={renderArtifact} onOpenRecord={openRecord} />,
|
|
142
|
+
},
|
|
143
|
+
decisions: {
|
|
144
|
+
count: analysis.decisions.length,
|
|
145
|
+
content: <DecisionsList analysis={analysis} tagLabels={decisionTagLabels} onOpenRecord={openRecord} />,
|
|
146
|
+
},
|
|
147
|
+
inputs: {
|
|
148
|
+
count: analysis.inputs.length,
|
|
149
|
+
content: <InputsList analysis={analysis} onOpenRecord={openRecord} />,
|
|
150
|
+
},
|
|
151
|
+
findings: {
|
|
152
|
+
count: analysis.findings.length,
|
|
153
|
+
content: <FindingsList analysis={analysis} onOpenRecord={openRecord} />,
|
|
154
|
+
},
|
|
155
|
+
prior_insights: {
|
|
156
|
+
count: analysis.prior_insights.length,
|
|
157
|
+
content: <PriorInsightsList analysis={analysis} onOpenRecord={openRecord} />,
|
|
158
|
+
},
|
|
159
|
+
papers: {
|
|
160
|
+
count: papers.length,
|
|
161
|
+
content: (
|
|
162
|
+
<PapersList
|
|
163
|
+
papers={papers}
|
|
164
|
+
analysis={analysis}
|
|
165
|
+
onOpenPaper={(paper, owner) => { stack.openPaper(paper.doi, owner); }}
|
|
166
|
+
/>
|
|
167
|
+
),
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
const anchorId = (section: InventorySectionId) => `${idPrefix}${section.replace('_', '-')}`;
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div data-slot="inventory" {...rest} ref={ref} className={cn('astra-inventory', className)}>
|
|
174
|
+
<div className="astra-inventory__layout">
|
|
175
|
+
<div className="astra-inventory__sections">
|
|
176
|
+
{sections.map((section) => (
|
|
177
|
+
<InventorySection
|
|
178
|
+
key={section}
|
|
179
|
+
id={anchorId(section)}
|
|
180
|
+
section={section}
|
|
181
|
+
title={labels.sections[section]}
|
|
182
|
+
count={sectionContent[section].count}
|
|
183
|
+
countLabel={labels.sectionCount(section, sectionContent[section].count)}
|
|
184
|
+
>
|
|
185
|
+
{sectionContent[section].content}
|
|
186
|
+
</InventorySection>
|
|
187
|
+
))}
|
|
188
|
+
{children}
|
|
189
|
+
</div>
|
|
190
|
+
{showOutline ? (
|
|
191
|
+
<InventoryOutline
|
|
192
|
+
entries={sections.map((section) => ({
|
|
193
|
+
id: anchorId(section),
|
|
194
|
+
label: labels.sections[section],
|
|
195
|
+
count: sectionContent[section].count,
|
|
196
|
+
kind: sectionKind(section),
|
|
197
|
+
}))}
|
|
198
|
+
/>
|
|
199
|
+
) : null}
|
|
200
|
+
</div>
|
|
201
|
+
{stack.active ? (
|
|
202
|
+
<DialogProvider mode={detailMode} backText={stack.previous ? entryLabel(stack.previous, papers) : undefined}>
|
|
203
|
+
<RecordDialog
|
|
204
|
+
entry={stack.active}
|
|
205
|
+
fallback={<p>{labels.notFound}</p>}
|
|
206
|
+
document={document}
|
|
207
|
+
index={index}
|
|
208
|
+
papers={papers}
|
|
209
|
+
paperMetadata={paperMetadata}
|
|
210
|
+
renderArtifact={renderArtifact}
|
|
211
|
+
renderText={renderText}
|
|
212
|
+
renderPaper={renderPaper}
|
|
213
|
+
onOpenArtifact={onOpenArtifact}
|
|
214
|
+
onFetchPaper={onFetchPaper}
|
|
215
|
+
onOpenRecord={stack.pushRecord}
|
|
216
|
+
onOpenPaper={stack.pushPaper}
|
|
217
|
+
onBack={stack.previous ? stack.back : undefined}
|
|
218
|
+
onClose={stack.close}
|
|
219
|
+
/>
|
|
220
|
+
</DialogProvider>
|
|
221
|
+
) : null}
|
|
222
|
+
</div>
|
|
223
|
+
);
|
|
224
|
+
});
|