@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.
Files changed (259) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +261 -0
  3. package/TOKENS.md +93 -0
  4. package/blocks.css +7 -0
  5. package/components.css +13 -0
  6. package/dist/blocks/analysis-tree.d.ts +13 -0
  7. package/dist/blocks/analysis-tree.d.ts.map +1 -0
  8. package/dist/blocks/analysis-tree.js +19 -0
  9. package/dist/blocks/analysis-tree.js.map +1 -0
  10. package/dist/blocks/decisions-list.d.ts +17 -0
  11. package/dist/blocks/decisions-list.d.ts.map +1 -0
  12. package/dist/blocks/decisions-list.js +56 -0
  13. package/dist/blocks/decisions-list.js.map +1 -0
  14. package/dist/blocks/findings-list.d.ts +9 -0
  15. package/dist/blocks/findings-list.d.ts.map +1 -0
  16. package/dist/blocks/findings-list.js +35 -0
  17. package/dist/blocks/findings-list.js.map +1 -0
  18. package/dist/blocks/index.d.ts +18 -0
  19. package/dist/blocks/index.d.ts.map +1 -0
  20. package/dist/blocks/index.js +10 -0
  21. package/dist/blocks/index.js.map +1 -0
  22. package/dist/blocks/inputs-list.d.ts +9 -0
  23. package/dist/blocks/inputs-list.d.ts.map +1 -0
  24. package/dist/blocks/inputs-list.js +32 -0
  25. package/dist/blocks/inputs-list.js.map +1 -0
  26. package/dist/blocks/outputs-list.d.ts +18 -0
  27. package/dist/blocks/outputs-list.d.ts.map +1 -0
  28. package/dist/blocks/outputs-list.js +47 -0
  29. package/dist/blocks/outputs-list.js.map +1 -0
  30. package/dist/blocks/papers-list.d.ts +16 -0
  31. package/dist/blocks/papers-list.d.ts.map +1 -0
  32. package/dist/blocks/papers-list.js +20 -0
  33. package/dist/blocks/papers-list.js.map +1 -0
  34. package/dist/blocks/prior-insights-list.d.ts +9 -0
  35. package/dist/blocks/prior-insights-list.d.ts.map +1 -0
  36. package/dist/blocks/prior-insights-list.js +29 -0
  37. package/dist/blocks/prior-insights-list.js.map +1 -0
  38. package/dist/blocks/section.d.ts +36 -0
  39. package/dist/blocks/section.d.ts.map +1 -0
  40. package/dist/blocks/section.js +30 -0
  41. package/dist/blocks/section.js.map +1 -0
  42. package/dist/components/artifact-preview.d.ts +71 -0
  43. package/dist/components/artifact-preview.d.ts.map +1 -0
  44. package/dist/components/artifact-preview.js +170 -0
  45. package/dist/components/artifact-preview.js.map +1 -0
  46. package/dist/components/decision-detail.d.ts +17 -0
  47. package/dist/components/decision-detail.d.ts.map +1 -0
  48. package/dist/components/decision-detail.js +21 -0
  49. package/dist/components/decision-detail.js.map +1 -0
  50. package/dist/components/detail-entry.d.ts +15 -0
  51. package/dist/components/detail-entry.d.ts.map +1 -0
  52. package/dist/components/detail-entry.js +14 -0
  53. package/dist/components/detail-entry.js.map +1 -0
  54. package/dist/components/finding-detail.d.ts +19 -0
  55. package/dist/components/finding-detail.d.ts.map +1 -0
  56. package/dist/components/finding-detail.js +39 -0
  57. package/dist/components/finding-detail.js.map +1 -0
  58. package/dist/components/index.d.ts +28 -0
  59. package/dist/components/index.d.ts.map +1 -0
  60. package/dist/components/index.js +15 -0
  61. package/dist/components/index.js.map +1 -0
  62. package/dist/components/input-detail.d.ts +15 -0
  63. package/dist/components/input-detail.d.ts.map +1 -0
  64. package/dist/components/input-detail.js +21 -0
  65. package/dist/components/input-detail.js.map +1 -0
  66. package/dist/components/insight-detail.d.ts +25 -0
  67. package/dist/components/insight-detail.d.ts.map +1 -0
  68. package/dist/components/insight-detail.js +30 -0
  69. package/dist/components/insight-detail.js.map +1 -0
  70. package/dist/components/insight-trigger.d.ts +20 -0
  71. package/dist/components/insight-trigger.d.ts.map +1 -0
  72. package/dist/components/insight-trigger.js +32 -0
  73. package/dist/components/insight-trigger.js.map +1 -0
  74. package/dist/components/output-detail.d.ts +39 -0
  75. package/dist/components/output-detail.d.ts.map +1 -0
  76. package/dist/components/output-detail.js +124 -0
  77. package/dist/components/output-detail.js.map +1 -0
  78. package/dist/components/output-dialog.d.ts +18 -0
  79. package/dist/components/output-dialog.d.ts.map +1 -0
  80. package/dist/components/output-dialog.js +11 -0
  81. package/dist/components/output-dialog.js.map +1 -0
  82. package/dist/components/paper-detail.d.ts +34 -0
  83. package/dist/components/paper-detail.d.ts.map +1 -0
  84. package/dist/components/paper-detail.js +60 -0
  85. package/dist/components/paper-detail.js.map +1 -0
  86. package/dist/components/record-dialog.d.ts +33 -0
  87. package/dist/components/record-dialog.d.ts.map +1 -0
  88. package/dist/components/record-dialog.js +114 -0
  89. package/dist/components/record-dialog.js.map +1 -0
  90. package/dist/components/relation-items.d.ts +9 -0
  91. package/dist/components/relation-items.d.ts.map +1 -0
  92. package/dist/components/relation-items.js +20 -0
  93. package/dist/components/relation-items.js.map +1 -0
  94. package/dist/components/use-detail-stack.d.ts +31 -0
  95. package/dist/components/use-detail-stack.d.ts.map +1 -0
  96. package/dist/components/use-detail-stack.js +49 -0
  97. package/dist/components/use-detail-stack.js.map +1 -0
  98. package/dist/lib/cn.d.ts +3 -0
  99. package/dist/lib/cn.d.ts.map +1 -0
  100. package/dist/lib/cn.js +6 -0
  101. package/dist/lib/cn.js.map +1 -0
  102. package/dist/lib/labels.d.ts +61 -0
  103. package/dist/lib/labels.d.ts.map +1 -0
  104. package/dist/lib/labels.js +79 -0
  105. package/dist/lib/labels.js.map +1 -0
  106. package/dist/lib/slot.d.ts +11 -0
  107. package/dist/lib/slot.d.ts.map +1 -0
  108. package/dist/lib/slot.js +83 -0
  109. package/dist/lib/slot.js.map +1 -0
  110. package/dist/model/doi.d.ts +2 -0
  111. package/dist/model/doi.d.ts.map +1 -0
  112. package/dist/model/doi.js +5 -0
  113. package/dist/model/doi.js.map +1 -0
  114. package/dist/model/index.d.ts +10 -0
  115. package/dist/model/index.d.ts.map +1 -0
  116. package/dist/model/index.js +7 -0
  117. package/dist/model/index.js.map +1 -0
  118. package/dist/model/locate-record.d.ts +8 -0
  119. package/dist/model/locate-record.d.ts.map +1 -0
  120. package/dist/model/locate-record.js +7 -0
  121. package/dist/model/locate-record.js.map +1 -0
  122. package/dist/model/papers.d.ts +38 -0
  123. package/dist/model/papers.d.ts.map +1 -0
  124. package/dist/model/papers.js +91 -0
  125. package/dist/model/papers.js.map +1 -0
  126. package/dist/model/records.d.ts +10 -0
  127. package/dist/model/records.d.ts.map +1 -0
  128. package/dist/model/records.js +32 -0
  129. package/dist/model/records.js.map +1 -0
  130. package/dist/model/relations.d.ts +45 -0
  131. package/dist/model/relations.d.ts.map +1 -0
  132. package/dist/model/relations.js +98 -0
  133. package/dist/model/relations.js.map +1 -0
  134. package/dist/primitives/badge.d.ts +11 -0
  135. package/dist/primitives/badge.d.ts.map +1 -0
  136. package/dist/primitives/badge.js +7 -0
  137. package/dist/primitives/badge.js.map +1 -0
  138. package/dist/primitives/button.d.ts +18 -0
  139. package/dist/primitives/button.d.ts.map +1 -0
  140. package/dist/primitives/button.js +12 -0
  141. package/dist/primitives/button.js.map +1 -0
  142. package/dist/primitives/detail-layout.d.ts +26 -0
  143. package/dist/primitives/detail-layout.d.ts.map +1 -0
  144. package/dist/primitives/detail-layout.js +21 -0
  145. package/dist/primitives/detail-layout.js.map +1 -0
  146. package/dist/primitives/dialog.d.ts +133 -0
  147. package/dist/primitives/dialog.d.ts.map +1 -0
  148. package/dist/primitives/dialog.js +266 -0
  149. package/dist/primitives/dialog.js.map +1 -0
  150. package/dist/primitives/index.d.ts +25 -0
  151. package/dist/primitives/index.d.ts.map +1 -0
  152. package/dist/primitives/index.js +14 -0
  153. package/dist/primitives/index.js.map +1 -0
  154. package/dist/primitives/kind.d.ts +6 -0
  155. package/dist/primitives/kind.d.ts.map +1 -0
  156. package/dist/primitives/kind.js +14 -0
  157. package/dist/primitives/kind.js.map +1 -0
  158. package/dist/primitives/prose.d.ts +36 -0
  159. package/dist/primitives/prose.d.ts.map +1 -0
  160. package/dist/primitives/prose.js +57 -0
  161. package/dist/primitives/prose.js.map +1 -0
  162. package/dist/primitives/record-list.d.ts +31 -0
  163. package/dist/primitives/record-list.d.ts.map +1 -0
  164. package/dist/primitives/record-list.js +17 -0
  165. package/dist/primitives/record-list.js.map +1 -0
  166. package/dist/primitives/relation-list.d.ts +22 -0
  167. package/dist/primitives/relation-list.d.ts.map +1 -0
  168. package/dist/primitives/relation-list.js +13 -0
  169. package/dist/primitives/relation-list.js.map +1 -0
  170. package/dist/primitives/surface-header.d.ts +31 -0
  171. package/dist/primitives/surface-header.d.ts.map +1 -0
  172. package/dist/primitives/surface-header.js +13 -0
  173. package/dist/primitives/surface-header.js.map +1 -0
  174. package/dist/views/index.d.ts +4 -0
  175. package/dist/views/index.d.ts.map +1 -0
  176. package/dist/views/index.js +3 -0
  177. package/dist/views/index.js.map +1 -0
  178. package/dist/views/inventory.d.ts +46 -0
  179. package/dist/views/inventory.d.ts.map +1 -0
  180. package/dist/views/inventory.js +101 -0
  181. package/dist/views/inventory.js.map +1 -0
  182. package/package.json +127 -0
  183. package/primitives.css +15 -0
  184. package/src/blocks/analysis-tree.tsx +109 -0
  185. package/src/blocks/decisions-list.tsx +113 -0
  186. package/src/blocks/findings-list.tsx +61 -0
  187. package/src/blocks/index.ts +23 -0
  188. package/src/blocks/inputs-list.tsx +51 -0
  189. package/src/blocks/outputs-list.tsx +143 -0
  190. package/src/blocks/papers-list.tsx +65 -0
  191. package/src/blocks/prior-insights-list.tsx +52 -0
  192. package/src/blocks/section.tsx +113 -0
  193. package/src/components/artifact-preview.tsx +314 -0
  194. package/src/components/decision-detail.tsx +93 -0
  195. package/src/components/detail-entry.ts +19 -0
  196. package/src/components/finding-detail.tsx +99 -0
  197. package/src/components/index.ts +44 -0
  198. package/src/components/input-detail.tsx +67 -0
  199. package/src/components/insight-detail.tsx +120 -0
  200. package/src/components/insight-trigger.tsx +102 -0
  201. package/src/components/output-detail.tsx +258 -0
  202. package/src/components/output-dialog.tsx +63 -0
  203. package/src/components/paper-detail.tsx +216 -0
  204. package/src/components/record-dialog.tsx +232 -0
  205. package/src/components/relation-items.ts +31 -0
  206. package/src/components/use-detail-stack.ts +78 -0
  207. package/src/lib/cn.ts +5 -0
  208. package/src/lib/labels.tsx +145 -0
  209. package/src/lib/slot.tsx +87 -0
  210. package/src/model/doi.ts +5 -0
  211. package/src/model/index.ts +32 -0
  212. package/src/model/locate-record.ts +13 -0
  213. package/src/model/papers.ts +146 -0
  214. package/src/model/records.ts +43 -0
  215. package/src/model/relations.ts +134 -0
  216. package/src/primitives/badge.tsx +32 -0
  217. package/src/primitives/button.tsx +58 -0
  218. package/src/primitives/detail-layout.tsx +84 -0
  219. package/src/primitives/dialog.tsx +555 -0
  220. package/src/primitives/index.ts +48 -0
  221. package/src/primitives/kind.ts +19 -0
  222. package/src/primitives/prose.tsx +74 -0
  223. package/src/primitives/record-list.tsx +103 -0
  224. package/src/primitives/relation-list.tsx +95 -0
  225. package/src/primitives/surface-header.tsx +87 -0
  226. package/src/views/index.ts +3 -0
  227. package/src/views/inventory.tsx +224 -0
  228. package/styles/base.css +49 -0
  229. package/styles/blocks/analysis-tree.css +64 -0
  230. package/styles/blocks/decisions-list.css +73 -0
  231. package/styles/blocks/outputs-list.css +349 -0
  232. package/styles/blocks/papers-list.css +98 -0
  233. package/styles/blocks/records.css +72 -0
  234. package/styles/components/artifact-preview.css +242 -0
  235. package/styles/components/decision-detail.css +159 -0
  236. package/styles/components/evidence.css +79 -0
  237. package/styles/components/finding-detail.css +63 -0
  238. package/styles/components/input-detail.css +95 -0
  239. package/styles/components/insight-detail.css +138 -0
  240. package/styles/components/insight-list.css +46 -0
  241. package/styles/components/insight-trigger.css +54 -0
  242. package/styles/components/output-detail.css +732 -0
  243. package/styles/components/paper-detail.css +249 -0
  244. package/styles/components/paper-doi.css +36 -0
  245. package/styles/primitives/badge.css +107 -0
  246. package/styles/primitives/button.css +116 -0
  247. package/styles/primitives/count-heading.css +27 -0
  248. package/styles/primitives/detail-layout.css +225 -0
  249. package/styles/primitives/dialog.css +634 -0
  250. package/styles/primitives/empty-state.css +10 -0
  251. package/styles/primitives/kind.css +41 -0
  252. package/styles/primitives/prose.css +15 -0
  253. package/styles/primitives/record-list.css +425 -0
  254. package/styles/primitives/relation-list.css +184 -0
  255. package/styles/primitives/surface-header.css +183 -0
  256. package/styles/tokens.css +119 -0
  257. package/styles/views/inventory.css +186 -0
  258. package/styles.css +2 -0
  259. package/views.css +3 -0
@@ -0,0 +1,124 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
3
+ import { isVisualOutput, recordTitle } from '../model/records.js';
4
+ import { cn } from '../lib/cn.js';
5
+ import { useLabels } from '../lib/labels.js';
6
+ import { ArtifactPreview } from './artifact-preview.js';
7
+ import { DialogAction, useDialogDismissGuard, useOptionalDialog } from '../primitives/dialog.js';
8
+ import { Prose } from '../primitives/prose.js';
9
+ import { RelationList } from '../primitives/relation-list.js';
10
+ import { relationItemsForLinks } from './relation-items.js';
11
+ /** The host's artifact renderer, or the built-in placeholder preview. */
12
+ export function OutputPreview({ output, compact = false, renderArtifact }) {
13
+ return renderArtifact
14
+ ? _jsx(_Fragment, { children: renderArtifact(output, { compact }) })
15
+ : _jsx(ArtifactPreview, { output: output, compact: compact });
16
+ }
17
+ /**
18
+ * What the detail shows in its artifact box: the host's rendering when it
19
+ * returns one, the built-in preview for figures and tables, nothing for other
20
+ * output types (a data file or a metric has no picture to frame).
21
+ */
22
+ function artifactNode(output, renderArtifact) {
23
+ if (renderArtifact)
24
+ return renderArtifact(output, { compact: false });
25
+ return isVisualOutput(output) ? _jsx(ArtifactPreview, { output: output, compact: false }) : null;
26
+ }
27
+ /** Artifact preview with provenance: description, recipe, alias, decisions, and inputs. */
28
+ export const OutputDetail = forwardRef(function OutputDetail({ record: output, relations, renderArtifact, renderText, onOpenRecord, expanded = false, onExpandedChange, className, ...props }, ref) {
29
+ const labels = useLabels();
30
+ const artifact = artifactNode(output, renderArtifact);
31
+ // Reader layout (artifact column + details rail) only when there is an
32
+ // artifact to frame: a host renderer may opt out of a figure or table by
33
+ // returning null, and the details then take the single column instead.
34
+ const visual = artifact != null;
35
+ const exitFullScreen = useCallback(() => { onExpandedChange?.(false); }, [onExpandedChange]);
36
+ // Inside a modal dialog, Escape reaches the full-screen layer through the
37
+ // dialog's cancel event (the guard), which fires after any keydown handling
38
+ // and cannot close the dialog underneath. Elsewhere the layer listens itself.
39
+ const dialog = useOptionalDialog();
40
+ const inModalDialog = dialog?.mode === 'modal';
41
+ useDialogDismissGuard(expanded, exitFullScreen);
42
+ useEffect(() => {
43
+ if (!expanded || inModalDialog)
44
+ return undefined;
45
+ const onKeyDown = (event) => {
46
+ if (event.key === 'Escape')
47
+ exitFullScreen();
48
+ };
49
+ document.addEventListener('keydown', onKeyDown);
50
+ return () => { document.removeEventListener('keydown', onKeyDown); };
51
+ }, [expanded, inModalDialog, exitFullScreen]);
52
+ // The full-screen layer is a modal: focus enters it, everything outside it
53
+ // (up to the enclosing native dialog, or the document) is inert while it
54
+ // is open, and focus returns to the control that opened it.
55
+ const layerRef = useRef(null);
56
+ useEffect(() => {
57
+ const layer = layerRef.current;
58
+ if (!expanded || !layer)
59
+ return undefined;
60
+ const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
61
+ const boundary = layer.closest('dialog') ?? document.body;
62
+ const inerted = [];
63
+ let node = layer;
64
+ while (node !== boundary) {
65
+ const parent = node.parentElement;
66
+ if (!parent)
67
+ break;
68
+ for (const sibling of Array.from(parent.children)) {
69
+ if (sibling !== node && !sibling.hasAttribute('inert')) {
70
+ sibling.setAttribute('inert', '');
71
+ inerted.push(sibling);
72
+ }
73
+ }
74
+ node = parent;
75
+ }
76
+ (layer.querySelector('button') ?? layer).focus();
77
+ return () => {
78
+ for (const element of inerted)
79
+ element.removeAttribute('inert');
80
+ if (opener?.isConnected)
81
+ opener.focus();
82
+ };
83
+ }, [expanded]);
84
+ const supportingDetails = (_jsxs("aside", { className: "astra-output-detail__provenance", "aria-label": "Output provenance and dependencies", children: [output.description ? (_jsxs("section", { className: "astra-output-detail__description", children: [_jsx("h4", { children: "Description" }), _jsx("div", { className: "astra-output-detail__description-text", children: _jsx(Prose, { text: output.description, field: "description", renderText: renderText }) })] })) : null, output.recipe?.command ? (_jsxs("section", { className: "astra-output-detail__recipe", children: [_jsx("h4", { children: "Recipe" }), _jsx("pre", { children: _jsx("code", { children: output.recipe.command }) }), output.recipe.container
85
+ ? _jsxs("p", { children: ["Container: ", _jsx("code", { children: output.recipe.container })] })
86
+ : null] })) : null, output.resolvedFrom ? (_jsx(RelationList, { className: "astra-detail__relations", title: "Resolved alias", items: relationItemsForLinks([relations.alias ?? { canonicalPath: output.resolvedFrom }], onOpenRecord), empty: null })) : null, _jsx(RelationList, { className: "astra-detail__relations", title: "Decision dependencies", items: relationItemsForLinks(relations.decisions, onOpenRecord), empty: "No decision dependencies are declared for this output." }), relations.indirectDecisions?.length ? (_jsx(RelationList, { className: "astra-detail__relations", title: "Indirect decision dependencies", description: "Through upstream outputs.", items: relationItemsForLinks(relations.indirectDecisions, onOpenRecord), empty: null })) : null, _jsx(RelationList, { className: "astra-detail__relations", title: "Inputs and upstream outputs", items: relationItemsForLinks(relations.inputs, onOpenRecord), empty: "No upstream dependencies are declared for this output." })] }));
87
+ return (_jsxs("div", { "data-slot": "output-detail", ...props, ref: ref, className: cn('astra-output-detail__layout', className), "data-layout": visual ? 'reader' : 'single', children: [_jsxs("div", { className: "astra-output-detail__result", children: [artifact != null ? (_jsxs("div", { ref: layerRef, className: "astra-output-detail__artifact", "data-type": output.type, ...(expanded
88
+ ? { 'data-expanded': '', role: 'dialog', 'aria-modal': 'true', 'aria-label': `Full-screen ${output.type}: ${recordTitle(output)}` }
89
+ : {}), children: [expanded ? (_jsxs("div", { className: "astra-output-detail__fullscreen-header", children: [_jsxs("span", { children: [_jsx("small", { children: labels.actions.fullScreen }), _jsx("strong", { children: recordTitle(output) })] }), _jsxs("button", { type: "button", onClick: () => onExpandedChange?.(false), children: [_jsx("span", { "aria-hidden": "true", children: "\u00D7" }), _jsx("span", { children: labels.actions.exitFullScreen })] })] })) : null, _jsx("div", { className: "astra-output-detail__preview", "data-type": output.type, children: artifact })] })) : null, !visual ? supportingDetails : null] }), visual ? _jsx("div", { className: "astra-output-detail__provenance-slot", children: supportingDetails }) : null] }));
90
+ });
91
+ /** Header actions for an output: open the artifact in the host, enter full screen. */
92
+ export function OutputDialogActions({ record: output, onOpenArtifact, expanded, onExpandedChange }) {
93
+ const labels = useLabels();
94
+ const visual = isVisualOutput(output);
95
+ return (_jsxs(_Fragment, { children: [onOpenArtifact && output.artifact ? (_jsxs(DialogAction, { onClick: () => { void onOpenArtifact(output); }, children: [_jsx("span", { "aria-hidden": "true", children: "\u2197" }), _jsx("span", { children: labels.actions.openArtifact })] })) : null, visual ? (_jsxs(DialogAction, { "aria-label": `View ${output.type} full screen`, "aria-expanded": expanded, onClick: () => { onExpandedChange(true); }, children: [_jsx("span", { "aria-hidden": "true", children: "\u26F6" }), _jsx("span", { children: labels.actions.fullScreen })] })) : null] }));
96
+ }
97
+ /** Full-screen state for an output, reset whenever the output changes (a controlled host is asked to reset). */
98
+ export function useOutputExpanded(output, controlled) {
99
+ const [internal, setInternal] = useState(false);
100
+ const [lastPath, setLastPath] = useState(output.canonicalPath);
101
+ if (lastPath !== output.canonicalPath) {
102
+ setLastPath(output.canonicalPath);
103
+ setInternal(false);
104
+ }
105
+ const isControlled = controlled?.expanded !== undefined;
106
+ const expanded = isControlled ? Boolean(controlled.expanded) : internal;
107
+ const onChange = controlled?.onExpandedChange;
108
+ const seenPath = useRef(output.canonicalPath);
109
+ const controlledExpanded = isControlled && Boolean(controlled.expanded);
110
+ useEffect(() => {
111
+ if (seenPath.current === output.canonicalPath)
112
+ return;
113
+ seenPath.current = output.canonicalPath;
114
+ if (controlledExpanded)
115
+ onChange?.(false);
116
+ }, [output.canonicalPath, controlledExpanded, onChange]);
117
+ const setExpanded = useCallback((next) => {
118
+ if (!isControlled)
119
+ setInternal(next);
120
+ onChange?.(next);
121
+ }, [isControlled, onChange]);
122
+ return [expanded, setExpanded];
123
+ }
124
+ //# sourceMappingURL=output-detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-detail.js","sourceRoot":"","sources":["../../src/components/output-detail.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAuC,MAAM,OAAO,CAAC;AAElH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAyB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,KAAK,EAAqB,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAA0B,MAAM,qBAAqB,CAAC;AAQpF,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,cAAc,EAAsB;IAC3F,OAAO,cAAc;QACnB,CAAC,CAAC,4BAAG,cAAc,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,GAAI;QAC5C,CAAC,CAAC,KAAC,eAAe,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAI,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,MAAsB,EAAE,cAA4C;IACxF,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,OAAO,cAAc,CAAC,MAAM,CAA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GAAG,MAAM,CAAC,aAAa,CAAC;QACxC,IAAI,kBAAkB;YAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,IAAa,EAAE,EAAE;QAChD,IAAI,CAAC,YAAY;YAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QACrC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7B,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAU,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ResolvedOutput } from '@astra-spec/sdk';
2
+ import type { OutputRelations } from '../model/relations.js';
3
+ import type { ArtifactRenderer } from './artifact-preview.js';
4
+ import { type DetailDialogProps } from '../primitives/dialog.js';
5
+ import type { TextRenderer } from '../primitives/prose.js';
6
+ import type { OpenRecordHandler } from './relation-items.js';
7
+ export interface OutputDialogProps extends Pick<DetailDialogProps, 'mode' | 'backText' | 'className' | 'onBack' | 'onClose'> {
8
+ record: ResolvedOutput;
9
+ relations: OutputRelations;
10
+ renderArtifact?: ArtifactRenderer | undefined;
11
+ renderText?: TextRenderer | undefined;
12
+ onOpenArtifact?: ((output: ResolvedOutput) => void | Promise<void>) | undefined;
13
+ onOpenRecord?: OpenRecordHandler | undefined;
14
+ expanded?: boolean | undefined;
15
+ onExpandedChange?: ((expanded: boolean) => void) | undefined;
16
+ }
17
+ export declare function OutputDialog({ record: output, relations, renderArtifact, renderText, onOpenArtifact, onOpenRecord, expanded: controlledExpanded, onExpandedChange, ...dialog }: OutputDialogProps): import("react").JSX.Element;
18
+ //# sourceMappingURL=output-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-dialog.d.ts","sourceRoot":"","sources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from "react/jsx-runtime";
2
+ import { isVisualOutput, recordTitle } from '../model/records.js';
3
+ import { useLabels } from '../lib/labels.js';
4
+ import { DetailDialog } from '../primitives/dialog.js';
5
+ import { OutputDetail, OutputDialogActions, useOutputExpanded } from './output-detail.js';
6
+ export function OutputDialog({ record: output, relations, renderArtifact, renderText, onOpenArtifact, onOpenRecord, expanded: controlledExpanded, onExpandedChange, ...dialog }) {
7
+ const labels = useLabels();
8
+ const [expanded, setExpanded] = useOutputExpanded(output, { expanded: controlledExpanded, onExpandedChange });
9
+ return (_jsx(DetailDialog, { ...dialog, kind: "output", layout: isVisualOutput(output) ? 'reader' : undefined, kindLabel: output.type, title: recordTitle(output), closeLabel: labels.closeRecord(labels.kinds.output), actions: (_jsx(OutputDialogActions, { record: output, onOpenArtifact: onOpenArtifact, expanded: expanded, onExpandedChange: setExpanded })), children: _jsx(OutputDetail, { record: output, relations: relations, renderArtifact: renderArtifact, renderText: renderText, onOpenRecord: onOpenRecord, expanded: expanded, onExpandedChange: setExpanded }) }));
10
+ }
11
+ //# sourceMappingURL=output-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-dialog.js","sourceRoot":"","sources":["../../src/components/output-dialog.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAA0B,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAc1F,MAAM,UAAU,YAAY,CAAC,EAC3B,MAAM,EAAE,MAAM,EACd,SAAS,EACT,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,EACZ,QAAQ,EAAE,kBAAkB,EAC5B,gBAAgB,EAChB,GAAG,MAAM,EACS;IAClB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC9G,OAAO,CACL,KAAC,YAAY,OACP,MAAM,EACV,IAAI,EAAC,QAAQ,EACb,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EACrD,SAAS,EAAE,MAAM,CAAC,IAAI,EACtB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAC1B,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EACnD,OAAO,EAAE,CACP,KAAC,mBAAmB,IAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,WAAW,GAC7B,CACH,YAED,KAAC,YAAY,IACX,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,WAAW,GAC7B,GACW,CAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { ResolvedDecision, ResolvedInsight } from '@astra-spec/sdk';
2
+ import { type HTMLAttributes, type ReactNode } from 'react';
3
+ import { type InventoryPaper, type InventoryPaperMetadata, type PaperFocusEvidence } from '../model/papers.js';
4
+ import { type DetailDialogProps } from '../primitives/dialog.js';
5
+ import { type TextRenderer } from '../primitives/prose.js';
6
+ export interface PaperRenderOptions {
7
+ focusEvidence?: PaperFocusEvidence | undefined;
8
+ }
9
+ /** Host slot for PDF, HTML, or any other paper presentation. */
10
+ export type PaperRenderer = (paper: InventoryPaper, options: PaperRenderOptions) => ReactNode;
11
+ export interface PaperDetailProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
12
+ record: InventoryPaper;
13
+ /** Fetch state for this DOI, if the host tracks it. */
14
+ metadata?: Pick<InventoryPaperMetadata, 'status' | 'error'> | undefined;
15
+ /** Insight whose first quoted passage is focused initially. */
16
+ focusInsight?: ResolvedInsight | undefined;
17
+ renderText?: TextRenderer | undefined;
18
+ renderPaper?: PaperRenderer | undefined;
19
+ /** Notify the host to fetch this DOI; refreshed metadata returns through props. */
20
+ onFetchPaper?: ((doi: string) => void) | undefined;
21
+ onOpenInsight?: ((insight: ResolvedInsight) => void) | undefined;
22
+ onOpenDecision?: ((decision: ResolvedDecision) => void) | undefined;
23
+ }
24
+ /** Host-rendered paper content beside the insights and decisions it supports. */
25
+ export declare const PaperDetail: import("react").ForwardRefExoticComponent<PaperDetailProps & import("react").RefAttributes<HTMLDivElement>>;
26
+ export interface PaperDialogProps extends Pick<DetailDialogProps, 'mode' | 'backText' | 'className' | 'onBack' | 'onClose'>, Omit<PaperDetailProps, 'className'> {
27
+ }
28
+ /** Header action linking to the paper's hosted content, when there is one. */
29
+ export interface PaperDialogActionsProps {
30
+ record: InventoryPaper;
31
+ }
32
+ export declare function PaperDialogActions({ record: paper }: PaperDialogActionsProps): import("react").JSX.Element | null;
33
+ export declare function PaperDialog({ record: paper, metadata, focusInsight, renderText, renderPaper, onFetchPaper, onOpenInsight, onOpenDecision, ...dialog }: PaperDialogProps): import("react").JSX.Element;
34
+ //# sourceMappingURL=paper-detail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paper-detail.d.ts","sourceRoot":"","sources":["../../src/components/paper-detail.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAsD,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGhH,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAAE,KA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gBAAgB,EAAE,WAAW,CAAC;CAAG;AAEnK,8EAA8E;AAC9E,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,uBAAuB,sCAW5E;AAED,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EAAE,KAAK,EACb,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,GAAG,MAAM,EACV,EAAE,gBAAgB,+BAwBlB"}
@@ -0,0 +1,60 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
3
+ import { doiHref } from '../model/doi.js';
4
+ import { countLabel } from '../model/records.js';
5
+ import { paperEvidence } from '../model/papers.js';
6
+ import { cn } from '../lib/cn.js';
7
+ import { useLabels } from '../lib/labels.js';
8
+ import { CountHeading } from '../primitives/detail-layout.js';
9
+ import { DetailDialog, DialogAction } from '../primitives/dialog.js';
10
+ import { Prose } from '../primitives/prose.js';
11
+ import { RelationList } from '../primitives/relation-list.js';
12
+ import { InsightTrigger } from './insight-trigger.js';
13
+ import { relationItemForRecord } from './relation-items.js';
14
+ function initialFocus(paper, focusInsight) {
15
+ if (!focusInsight)
16
+ return undefined;
17
+ const evidence = paperEvidence(focusInsight, paper.doi)[0];
18
+ return evidence?.quote ? { key: `${focusInsight.canonicalPath}-source`, insight: focusInsight, evidence } : undefined;
19
+ }
20
+ /** Host-rendered paper content beside the insights and decisions it supports. */
21
+ export const PaperDetail = forwardRef(function PaperDetail({ record: paper, metadata, focusInsight, renderText, renderPaper, onFetchPaper, onOpenInsight, onOpenDecision, className, ...props }, ref) {
22
+ const labels = useLabels();
23
+ const [focusKey, setFocusKey] = useState(undefined);
24
+ const [override, setOverride] = useState(undefined);
25
+ const key = `${paper.doi}|${focusInsight?.canonicalPath ?? ''}`;
26
+ if (focusKey !== key) {
27
+ setFocusKey(key);
28
+ setOverride(undefined);
29
+ }
30
+ // One object per request, kept across unrelated re-renders, with a key
31
+ // that changes on every locate click so a repeat of the same passage is
32
+ // still a new request to the host.
33
+ const focusEvidence = useMemo(() => override ?? initialFocus(paper, focusInsight), [override, paper, focusInsight]);
34
+ const sequence = useRef(0);
35
+ const locate = useCallback((insight, evidence) => {
36
+ sequence.current += 1;
37
+ setOverride({ key: `${insight.canonicalPath}-${sequence.current}`, insight, evidence });
38
+ }, []);
39
+ const canRender = Boolean(paper.pdfUrl && renderPaper);
40
+ const fetching = metadata?.status === 'fetching';
41
+ return (_jsxs("div", { "data-slot": "paper-detail", ...props, ref: ref, className: cn('astra-paper-detail__layout', className), children: [_jsx("div", { className: "astra-paper-detail__artifact", children: canRender && renderPaper ? (_jsx(_Fragment, { children: renderPaper(paper, { focusEvidence }) })) : (_jsx("div", { className: "astra-paper-detail__unavailable", ...(fetching ? { 'aria-busy': true } : {}), children: !paper.pdfUrl && onFetchPaper ? (_jsxs(_Fragment, { children: [_jsx("p", { ...(metadata?.status === 'error' ? { role: 'alert' } : {}), children: metadata?.status === 'error'
42
+ ? (metadata.error ?? 'The paper could not be fetched.')
43
+ : 'No paper content is available from this host.' }), _jsx("button", { type: "button", disabled: fetching, onClick: () => { onFetchPaper(paper.doi); }, children: labels.actions.fetchPaper })] })) : (_jsx("p", { children: paper.pdfUrl
44
+ ? 'This host has not supplied an embedded paper renderer.'
45
+ : 'Follow the DOI for the published version.' })) })) }), _jsxs("aside", { className: "astra-paper-detail__rail", "aria-label": "Paper insights and decisions", children: [_jsxs("section", { className: "astra-paper-doi", children: [_jsx("h4", { children: "DOI" }), _jsxs("a", { href: doiHref(paper.doi), target: "_blank", rel: "noreferrer", children: [paper.doi, " \u2197"] })] }), _jsxs("section", { className: "astra-insight-list", children: [_jsx(CountHeading, { title: "Insights from this paper", count: paper.insights.length }), _jsx("ul", { className: "astra-evidence astra-paper-detail__insights", children: paper.insights.map((insight) => {
46
+ const evidence = paperEvidence(insight, paper.doi);
47
+ return (_jsxs("li", { className: "astra-evidence__item astra-paper-insight", children: [_jsx(InsightTrigger, { insight: insight, tag: null, onOpen: () => onOpenInsight?.(insight) }), _jsx("div", { className: "astra-paper-insight__claim", children: _jsx(Prose, { text: insight.claim, field: "claim", renderText: renderText }) }), evidence.length ? (_jsxs("div", { className: "astra-paper-insight__sources", children: [_jsx("span", { children: countLabel(evidence.length, 'passage') }), canRender ? (_jsx("div", { children: evidence.map((source, index) => (_jsxs("button", { type: "button", className: "astra-paper-insight__locate", onClick: () => { locate(insight, source); }, "aria-label": `Locate source passage ${index + 1} in paper`, children: [labels.actions.locate, evidence.length > 1 ? ` ${index + 1}` : ''] }, `${insight.canonicalPath}-${index}`))) })) : null] })) : null] }, insight.canonicalPath));
48
+ }) })] }), _jsx(RelationList, { className: "astra-detail__relations", title: "Informs decisions", items: paper.decisions.map((decision) => relationItemForRecord(decision, undefined, undefined, { onOpen: onOpenDecision ? () => { onOpenDecision(decision); } : undefined })), empty: "No decisions cite insights from this paper." })] })] }));
49
+ });
50
+ export function PaperDialogActions({ record: paper }) {
51
+ const labels = useLabels();
52
+ if (!paper.pdfUrl)
53
+ return null;
54
+ return (_jsx(DialogAction, { asChild: true, children: _jsxs("a", { href: paper.pdfUrl, target: "_blank", rel: "noreferrer", children: [_jsx("span", { "aria-hidden": "true", children: "\u2197" }), _jsx("span", { children: labels.actions.openPaper })] }) }));
55
+ }
56
+ export function PaperDialog({ record: paper, metadata, focusInsight, renderText, renderPaper, onFetchPaper, onOpenInsight, onOpenDecision, ...dialog }) {
57
+ const labels = useLabels();
58
+ return (_jsx(DetailDialog, { ...dialog, kind: "paper", layout: "reader", kindLabel: labels.kinds.paper, title: paper.title, closeLabel: labels.closeRecord(labels.kinds.paper), actions: _jsx(PaperDialogActions, { record: paper }), children: _jsx(PaperDetail, { record: paper, metadata: metadata, focusInsight: focusInsight, renderText: renderText, renderPaper: renderPaper, onFetchPaper: onFetchPaper, onOpenInsight: onOpenInsight, onOpenDecision: onOpenDecision }) }));
59
+ }
60
+ //# sourceMappingURL=paper-detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paper-detail.js","sourceRoot":"","sources":["../../src/components/paper-detail.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAuC,MAAM,OAAO,CAAC;AAChH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAA6E,MAAM,oBAAoB,CAAC;AAC9H,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,YAAY,EAA0B,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,KAAK,EAAqB,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAuB5D,SAAS,YAAY,CAAC,KAAqB,EAAE,YAAyC;IACpF,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IACpC,MAAM,QAAQ,GAAG,aAAa,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,aAAa,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,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AC,OAAO,CAAC,SAAS,GAAQ,IACrC,GACS,CAChB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAC1B,MAAM,EAAE,KAAK,EACb,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,GAAG,MAAM,EACQ;IACjB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,CACL,KAAC,YAAY,OACP,MAAM,EACV,IAAI,EAAC,OAAO,EACZ,MAAM,EAAC,QAAQ,EACf,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,EAC7B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAClD,OAAO,EAAE,KAAC,kBAAkB,IAAC,MAAM,EAAE,KAAK,GAAI,YAE9C,KAAC,WAAW,IACV,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAC9B,GACW,CAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { AnalysisIndex, ResolvedAnalysisDocument, ResolvedAnalysisNode, ResolvedOutput, ResolvedRecord } from '@astra-spec/sdk';
2
+ import type { ReactNode } from 'react';
3
+ import { type InventoryPaper, type InventoryPaperMetadataMap } from '../model/papers.js';
4
+ import type { ArtifactRenderer } from './artifact-preview.js';
5
+ import { type DetailDialogProps } from '../primitives/dialog.js';
6
+ import type { TextRenderer } from '../primitives/prose.js';
7
+ import type { DetailEntry } from './detail-entry.js';
8
+ import { type PaperRenderer } from './paper-detail.js';
9
+ export interface RecordDialogProps extends Pick<DetailDialogProps, 'mode' | 'backText' | 'className' | 'onBack' | 'onClose'> {
10
+ entry: DetailEntry;
11
+ document: ResolvedAnalysisDocument;
12
+ index: AnalysisIndex;
13
+ /** Papers in scope, from `collectInventoryPapers()`; needed for paper entries and insight sources. */
14
+ papers?: readonly InventoryPaper[] | undefined;
15
+ paperMetadata?: InventoryPaperMetadataMap | undefined;
16
+ renderArtifact?: ArtifactRenderer | undefined;
17
+ renderText?: TextRenderer | undefined;
18
+ renderPaper?: PaperRenderer | undefined;
19
+ onOpenArtifact?: ((output: ResolvedOutput) => void | Promise<void>) | undefined;
20
+ onFetchPaper?: ((doi: string) => void) | undefined;
21
+ /** Navigation to another record from within the detail (drill-down). */
22
+ onOpenRecord?: ((record: ResolvedRecord, analysis: ResolvedAnalysisNode) => void) | undefined;
23
+ onOpenPaper?: ((doi: string, analysis: ResolvedAnalysisNode, focusInsightPath?: string) => void) | undefined;
24
+ /** Body rendered (inside the dialog shell) when the entry no longer resolves, e.g. after a document refresh; nothing renders without it. */
25
+ fallback?: ReactNode | undefined;
26
+ }
27
+ /**
28
+ * Renders the right detail dialog for a stack entry, deriving relations,
29
+ * evidence, insights, and papers from the index. One persistent dialog
30
+ * element hosts every kind, so drilling down keeps focus and the top layer.
31
+ */
32
+ export declare function RecordDialog({ entry, document, index, papers, paperMetadata, renderArtifact, renderText, renderPaper, onOpenArtifact, onFetchPaper, onOpenRecord, onOpenPaper, fallback, ...dialog }: RecordDialogProps): import("react").JSX.Element | null;
33
+ //# sourceMappingURL=record-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-dialog.d.ts","sourceRoot":"","sources":["../../src/components/record-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EAGpB,cAAc,EACd,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAA4C,KAAK,cAAc,EAAE,KAAK,yBAA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,oBAAoB,EAAE,gBAAgB,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC7G,4IAA4I;IAC5I,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC;AAWD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAW,EACX,aAAkB,EAClB,cAAc,EACd,UAAU,EACV,WAAW,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,QAAe,EACf,GAAG,MAAM,EACV,EAAE,iBAAiB,sCA0JnB"}
@@ -0,0 +1,114 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { locateRecord } from '../model/locate-record.js';
3
+ import { findPaper, paperForDoi, paperMetadataFor } from '../model/papers.js';
4
+ import { isInsight, isVisualOutput, recordTitle } from '../model/records.js';
5
+ import { decisionInsights, findingEvidence, informedDecisions, outputRelations } from '../model/relations.js';
6
+ import { useLabels } from '../lib/labels.js';
7
+ import { DetailDialog } from '../primitives/dialog.js';
8
+ import { DecisionDetail } from './decision-detail.js';
9
+ import { FindingDetail } from './finding-detail.js';
10
+ import { InputDetail } from './input-detail.js';
11
+ import { InsightDetail, primaryLiteratureEvidence } from './insight-detail.js';
12
+ import { OutputDetail, OutputDialogActions, useOutputExpanded } from './output-detail.js';
13
+ import { PaperDetail, PaperDialogActions } from './paper-detail.js';
14
+ /**
15
+ * Renders the right detail dialog for a stack entry, deriving relations,
16
+ * evidence, insights, and papers from the index. One persistent dialog
17
+ * element hosts every kind, so drilling down keeps focus and the top layer.
18
+ */
19
+ export function RecordDialog({ entry, document, index, papers = [], paperMetadata = {}, renderArtifact, renderText, renderPaper, onOpenArtifact, onFetchPaper, onOpenRecord, onOpenPaper, fallback = null, ...dialog }) {
20
+ const labels = useLabels();
21
+ const analysis = index.analysisByPath.get(entry.analysisPath);
22
+ const located = entry.kind === 'record' ? locateRecord(index, entry.canonicalPath) : undefined;
23
+ // Papers are looked up in the host's list first, then derived for the
24
+ // entry's own analysis: a record reached by drill-down may cite a paper the
25
+ // viewed analysis does not list.
26
+ const paper = entry.kind === 'paper' && analysis
27
+ ? findPaper(papers, entry.doi) ?? paperForDoi(document, index, analysis, entry.doi, paperMetadata)
28
+ : undefined;
29
+ const output = located?.record.kind === 'output' ? located.record : undefined;
30
+ const [expanded, setExpanded] = useOutputExpanded(output ?? PLACEHOLDER_OUTPUT);
31
+ const openByPath = (canonicalPath) => {
32
+ const target = locateRecord(index, canonicalPath);
33
+ if (target)
34
+ onOpenRecord?.(target.record, target.analysis);
35
+ };
36
+ const openInsight = (insight) => { openByPath(insight.canonicalPath); };
37
+ const openDecision = (decision) => { openByPath(decision.canonicalPath); };
38
+ let chrome;
39
+ if (entry.kind === 'paper' && paper && analysis) {
40
+ const focusRecord = entry.focusInsightPath ? index.recordByPath.get(entry.focusInsightPath) : undefined;
41
+ chrome = {
42
+ kind: 'paper',
43
+ kindLabel: labels.kinds.paper,
44
+ title: paper.title,
45
+ layout: 'reader',
46
+ actions: _jsx(PaperDialogActions, { record: paper }),
47
+ body: (_jsx(PaperDetail, { record: paper, metadata: paperMetadataFor(paper.doi, paperMetadata), focusInsight: isInsight(focusRecord) ? focusRecord : undefined, renderText: renderText, renderPaper: renderPaper, onFetchPaper: onFetchPaper, onOpenInsight: openInsight, onOpenDecision: openDecision })),
48
+ };
49
+ }
50
+ else if (located && analysis) {
51
+ const { record } = located;
52
+ switch (record.kind) {
53
+ case 'output':
54
+ chrome = {
55
+ kind: 'output',
56
+ kindLabel: record.type,
57
+ title: recordTitle(record),
58
+ layout: isVisualOutput(record) ? 'reader' : undefined,
59
+ actions: (_jsx(OutputDialogActions, { record: record, onOpenArtifact: onOpenArtifact, expanded: expanded, onExpandedChange: setExpanded })),
60
+ body: (_jsx(OutputDetail, { record: record, relations: outputRelations(index, record), renderArtifact: renderArtifact, renderText: renderText, onOpenRecord: onOpenRecord, expanded: expanded, onExpandedChange: setExpanded })),
61
+ };
62
+ break;
63
+ case 'input':
64
+ chrome = {
65
+ kind: 'input',
66
+ kindLabel: labels.kinds.input,
67
+ title: recordTitle(record),
68
+ body: _jsx(InputDetail, { record: record, renderText: renderText }),
69
+ };
70
+ break;
71
+ case 'decision':
72
+ chrome = {
73
+ kind: 'decision',
74
+ kindLabel: labels.kinds.decision,
75
+ title: recordTitle(record),
76
+ body: (_jsx(DecisionDetail, { record: record, insights: decisionInsights(index, record), renderText: renderText, onOpenInsight: openInsight })),
77
+ };
78
+ break;
79
+ case 'finding':
80
+ chrome = {
81
+ kind: 'finding',
82
+ kindLabel: labels.kinds.finding,
83
+ title: record.claim,
84
+ body: (_jsx(FindingDetail, { record: record, evidence: findingEvidence(index, record), renderText: renderText, onOpenRecord: onOpenRecord })),
85
+ };
86
+ break;
87
+ case 'prior_insight': {
88
+ // The same rule InsightDetail displays by, so the passage it shows
89
+ // and the paper this opens come from one evidence entry.
90
+ const sourceDoi = primaryLiteratureEvidence(record)?.doi;
91
+ const sourcePaper = sourceDoi
92
+ ? findPaper(papers, sourceDoi) ?? paperForDoi(document, index, located.analysis, sourceDoi, paperMetadata)
93
+ : undefined;
94
+ chrome = {
95
+ kind: 'prior_insight',
96
+ kindLabel: labels.kinds.prior_insight,
97
+ title: recordTitle(record),
98
+ body: (_jsx(InsightDetail, { record: record, decisions: informedDecisions(document, record), renderText: renderText, onOpenSource: sourcePaper && onOpenPaper
99
+ ? () => { onOpenPaper(sourcePaper.doi, analysis, record.canonicalPath); }
100
+ : undefined, onOpenDecision: openDecision })),
101
+ };
102
+ break;
103
+ }
104
+ }
105
+ }
106
+ if (!chrome) {
107
+ if (fallback == null)
108
+ return null;
109
+ return (_jsx(DetailDialog, { ...dialog, kind: "analysis", title: labels.notFound, closeLabel: labels.close, children: fallback }));
110
+ }
111
+ return (_jsx(DetailDialog, { ...dialog, kind: chrome.kind, layout: chrome.layout, kindLabel: chrome.kindLabel, title: chrome.title, closeLabel: labels.closeRecord(labels.kinds[chrome.kind]), actions: chrome.actions, children: chrome.body }));
112
+ }
113
+ const PLACEHOLDER_OUTPUT = { canonicalPath: '' };
114
+ //# sourceMappingURL=record-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-dialog.js","sourceRoot":"","sources":["../../src/components/record-dialog.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAuD,MAAM,oBAAoB,CAAC;AACnI,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAA6C,MAAM,yBAAyB,CAAC;AAGlG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAsB,MAAM,mBAAmB,CAAC;AA8BxF;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAM,GAAG,EAAE,EACX,aAAa,GAAG,EAAE,EAClB,cAAc,EACd,UAAU,EACV,WAAW,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,QAAQ,GAAG,IAAI,EACf,GAAG,MAAM,EACS;IA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AAY,OAAK,MAAM,EAAE,IAAI,EAAC,UAAU,EAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,YACvF,QAAQ,GACI,CAChB,CAAC;IACJ,CAAC;IACD,OAAO,CACL,KAAC,YAAY,OACP,MAAM,EACV,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EACzD,OAAO,EAAE,MAAM,CAAC,OAAO,YAEtB,MAAM,CAAC,IAAI,GACC,CAChB,CAAC;AACJ,CAAC;AAED,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,EAAE,EAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ResolvedAnalysisNode, ResolvedRecord } from '@astra-spec/sdk';
2
+ import type { LinkedRecord } from '../model/relations.js';
3
+ import type { RelationItem } from '../primitives/relation-list.js';
4
+ export type OpenRecordHandler = (record: ResolvedRecord, analysis: ResolvedAnalysisNode) => void;
5
+ /** Builds a relation-list item for a record, with navigation when the caller handles it. */
6
+ export declare function relationItemForRecord(record: ResolvedRecord, analysis: ResolvedAnalysisNode | undefined, onOpen: OpenRecordHandler | undefined, overrides?: Partial<RelationItem>): RelationItem;
7
+ /** Builds relation-list items for linked records; unresolved links show their path. */
8
+ export declare function relationItemsForLinks(links: LinkedRecord[], onOpen: OpenRecordHandler | undefined): RelationItem[];
9
+ //# sourceMappingURL=relation-items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation-items.d.ts","sourceRoot":"","sources":["../../src/components/relation-items.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;AAEjG,4FAA4F;AAC5F,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,SAAS,GAAE,OAAO,CAAC,YAAY,CAAM,GACpC,YAAY,CAUd;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,iBAAiB,GAAG,SAAS,GAAG,YAAY,EAAE,CAIlH"}
@@ -0,0 +1,20 @@
1
+ import { recordTitle } from '../model/records.js';
2
+ /** Builds a relation-list item for a record, with navigation when the caller handles it. */
3
+ export function relationItemForRecord(record, analysis, onOpen, overrides = {}) {
4
+ const title = recordTitle(record);
5
+ return {
6
+ key: record.canonicalPath,
7
+ label: title,
8
+ kind: record.kind,
9
+ accessibleLabel: `View ${record.kind}: ${title}`,
10
+ onOpen: analysis && onOpen ? () => { onOpen(record, analysis); } : undefined,
11
+ ...overrides,
12
+ };
13
+ }
14
+ /** Builds relation-list items for linked records; unresolved links show their path. */
15
+ export function relationItemsForLinks(links, onOpen) {
16
+ return links.map((link) => (link.record
17
+ ? relationItemForRecord(link.record, link.analysis, onOpen, { identifier: link.canonicalPath })
18
+ : { key: link.canonicalPath, label: link.canonicalPath, identifier: link.canonicalPath }));
19
+ }
20
+ //# sourceMappingURL=relation-items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation-items.js","sourceRoot":"","sources":["../../src/components/relation-items.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKlD,4FAA4F;AAC5F,MAAM,UAAU,qBAAqB,CACnC,MAAsB,EACtB,QAA0C,EAC1C,MAAqC,EACrC,YAAmC,EAAE;IAErC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,aAAa;QACzB,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,eAAe,EAAE,QAAQ,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE;QAChD,MAAM,EAAE,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;QAC5E,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,qBAAqB,CAAC,KAAqB,EAAE,MAAqC;IAChG,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;QACrC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;QAC/F,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { ResolvedAnalysisNode, ResolvedRecord } from '@astra-spec/sdk';
2
+ import { type DetailEntry } from './detail-entry.js';
3
+ export interface DetailStackOptions {
4
+ /** Controlled stack; pair with `onChange`. */
5
+ value?: readonly DetailEntry[] | undefined;
6
+ defaultValue?: readonly DetailEntry[] | undefined;
7
+ onChange?: ((next: DetailEntry[]) => void) | undefined;
8
+ }
9
+ export interface DetailStack {
10
+ stack: readonly DetailEntry[];
11
+ active: DetailEntry | undefined;
12
+ previous: DetailEntry | undefined;
13
+ /** Replaces the stack with a single entry. */
14
+ open: (entry: DetailEntry) => void;
15
+ openRecord: (record: ResolvedRecord, analysis: ResolvedAnalysisNode) => void;
16
+ openPaper: (doi: string, analysis: ResolvedAnalysisNode, focusInsightPath?: string) => void;
17
+ /** Pushes an entry on top of the current one (drill-down). */
18
+ push: (entry: DetailEntry) => void;
19
+ pushRecord: (record: ResolvedRecord, analysis: ResolvedAnalysisNode) => void;
20
+ pushPaper: (doi: string, analysis: ResolvedAnalysisNode, focusInsightPath?: string) => void;
21
+ back: () => void;
22
+ close: () => void;
23
+ set: (next: readonly DetailEntry[]) => void;
24
+ }
25
+ /**
26
+ * Headless navigation state for record details: a stack of entries with
27
+ * open/push/back/close. Works controlled (`value` + `onChange`) or
28
+ * uncontrolled (`defaultValue`), like a React input.
29
+ */
30
+ export declare function useDetailStack({ value, defaultValue, onChange }?: DetailStackOptions): DetailStack;
31
+ //# sourceMappingURL=use-detail-stack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-detail-stack.d.ts","sourceRoot":"","sources":["../../src/components/use-detail-stack.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,CAAC;IAC3C,YAAY,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,WAAW,GAAG,SAAS,CAAC;IAClC,8CAA8C;IAC9C,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC7E,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,gBAAgB,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5F,8DAA8D;IAC9D,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACnC,UAAU,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC7E,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,gBAAgB,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5F,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,KAAK,IAAI,CAAC;CAC7C;AAID;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAE,kBAAuB,GAAG,WAAW,CA0CtG"}
@@ -0,0 +1,49 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { paperEntry, recordEntry } from './detail-entry.js';
3
+ const EMPTY = [];
4
+ /**
5
+ * Headless navigation state for record details: a stack of entries with
6
+ * open/push/back/close. Works controlled (`value` + `onChange`) or
7
+ * uncontrolled (`defaultValue`), like a React input.
8
+ */
9
+ export function useDetailStack({ value, defaultValue, onChange } = {}) {
10
+ const [internal, setInternal] = useState(defaultValue ?? EMPTY);
11
+ const controlled = value !== undefined;
12
+ const stack = controlled ? value : internal;
13
+ const latest = useRef(stack);
14
+ useEffect(() => { latest.current = stack; });
15
+ const onChangeRef = useRef(onChange);
16
+ useEffect(() => { onChangeRef.current = onChange; });
17
+ // Uncontrolled updates read the latest stack (not the render-time one) so
18
+ // two calls in the same tick compose, and notify the host once per change.
19
+ // Controlled updates are proposals computed from the value the host last
20
+ // rendered; the host decides, like a controlled input.
21
+ const update = useCallback((compute) => {
22
+ const next = [...compute(latest.current)];
23
+ if (!controlled) {
24
+ latest.current = next;
25
+ setInternal(next);
26
+ }
27
+ onChangeRef.current?.(next);
28
+ }, [controlled]);
29
+ const set = useCallback((next) => { update(() => next); }, [update]);
30
+ return useMemo(() => {
31
+ const open = (entry) => { update(() => [entry]); };
32
+ const push = (entry) => { update((current) => [...current, entry]); };
33
+ return {
34
+ stack,
35
+ active: stack.at(-1),
36
+ previous: stack.length > 1 ? stack.at(-2) : undefined,
37
+ open,
38
+ openRecord: (record, analysis) => { open(recordEntry(record.canonicalPath, analysis.canonicalPath)); },
39
+ openPaper: (doi, analysis, focusInsightPath) => { open(paperEntry(doi, analysis.canonicalPath, focusInsightPath)); },
40
+ push,
41
+ pushRecord: (record, analysis) => { push(recordEntry(record.canonicalPath, analysis.canonicalPath)); },
42
+ pushPaper: (doi, analysis, focusInsightPath) => { push(paperEntry(doi, analysis.canonicalPath, focusInsightPath)); },
43
+ back: () => { update((current) => current.slice(0, -1)); },
44
+ close: () => { update(() => EMPTY); },
45
+ set,
46
+ };
47
+ }, [stack, set, update]);
48
+ }
49
+ //# sourceMappingURL=use-detail-stack.js.map