@astra-spec/ui 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +173 -20
  2. package/TOKENS.md +6 -3
  3. package/components.css +1 -0
  4. package/dist/blocks/decisions-list.d.ts +0 -1
  5. package/dist/blocks/decisions-list.d.ts.map +1 -1
  6. package/dist/blocks/decisions-list.js +1 -5
  7. package/dist/blocks/decisions-list.js.map +1 -1
  8. package/dist/blocks/index.d.ts +3 -3
  9. package/dist/blocks/index.d.ts.map +1 -1
  10. package/dist/blocks/index.js +2 -2
  11. package/dist/blocks/index.js.map +1 -1
  12. package/dist/blocks/inputs-list.js +1 -1
  13. package/dist/blocks/inputs-list.js.map +1 -1
  14. package/dist/blocks/outputs-list.d.ts +2 -2
  15. package/dist/blocks/outputs-list.d.ts.map +1 -1
  16. package/dist/blocks/outputs-list.js +15 -19
  17. package/dist/blocks/outputs-list.js.map +1 -1
  18. package/dist/blocks/section.d.ts +1 -4
  19. package/dist/blocks/section.d.ts.map +1 -1
  20. package/dist/blocks/section.js +1 -12
  21. package/dist/blocks/section.js.map +1 -1
  22. package/dist/components/artifact-preview.d.ts +2 -54
  23. package/dist/components/artifact-preview.d.ts.map +1 -1
  24. package/dist/components/artifact-preview.js +2 -107
  25. package/dist/components/artifact-preview.js.map +1 -1
  26. package/dist/components/decision-detail.d.ts +1 -1
  27. package/dist/components/decision-detail.d.ts.map +1 -1
  28. package/dist/components/decision-detail.js.map +1 -1
  29. package/dist/components/finding-detail.d.ts +2 -2
  30. package/dist/components/finding-detail.d.ts.map +1 -1
  31. package/dist/components/finding-detail.js.map +1 -1
  32. package/dist/components/index.d.ts +9 -13
  33. package/dist/components/index.d.ts.map +1 -1
  34. package/dist/components/index.js +6 -8
  35. package/dist/components/index.js.map +1 -1
  36. package/dist/components/input-detail.d.ts +1 -2
  37. package/dist/components/input-detail.d.ts.map +1 -1
  38. package/dist/components/input-detail.js +0 -3
  39. package/dist/components/input-detail.js.map +1 -1
  40. package/dist/components/insight-detail.d.ts +2 -8
  41. package/dist/components/insight-detail.d.ts.map +1 -1
  42. package/dist/components/insight-detail.js +5 -11
  43. package/dist/components/insight-detail.js.map +1 -1
  44. package/dist/components/insight-trigger.d.ts +1 -1
  45. package/dist/components/insight-trigger.d.ts.map +1 -1
  46. package/dist/components/insight-trigger.js.map +1 -1
  47. package/dist/components/output-detail.d.ts +2 -7
  48. package/dist/components/output-detail.d.ts.map +1 -1
  49. package/dist/components/output-detail.js +3 -30
  50. package/dist/components/output-detail.js.map +1 -1
  51. package/dist/components/output-dialog.d.ts +2 -2
  52. package/dist/components/output-dialog.d.ts.map +1 -1
  53. package/dist/components/output-dialog.js +2 -1
  54. package/dist/components/output-dialog.js.map +1 -1
  55. package/dist/components/paper-detail.d.ts +14 -14
  56. package/dist/components/paper-detail.d.ts.map +1 -1
  57. package/dist/components/paper-detail.js +49 -29
  58. package/dist/components/paper-detail.js.map +1 -1
  59. package/dist/components/paper-pdf-viewer.d.ts +19 -0
  60. package/dist/components/paper-pdf-viewer.d.ts.map +1 -0
  61. package/dist/components/paper-pdf-viewer.js +250 -0
  62. package/dist/components/paper-pdf-viewer.js.map +1 -0
  63. package/dist/components/record-dialog.d.ts +7 -5
  64. package/dist/components/record-dialog.d.ts.map +1 -1
  65. package/dist/components/record-dialog.js +7 -5
  66. package/dist/components/record-dialog.js.map +1 -1
  67. package/dist/components/record-preview.d.ts +2 -2
  68. package/dist/components/record-preview.d.ts.map +1 -1
  69. package/dist/components/record-preview.js +2 -2
  70. package/dist/components/record-preview.js.map +1 -1
  71. package/dist/components/relation-items.d.ts +1 -1
  72. package/dist/components/relation-items.d.ts.map +1 -1
  73. package/dist/components/relation-items.js +10 -3
  74. package/dist/components/relation-items.js.map +1 -1
  75. package/dist/{components/use-detail-stack.d.ts → lib/detail-stack.d.ts} +17 -2
  76. package/dist/lib/detail-stack.d.ts.map +1 -0
  77. package/dist/{components/use-detail-stack.js → lib/detail-stack.js} +15 -2
  78. package/dist/lib/detail-stack.js.map +1 -0
  79. package/dist/lib/index.d.ts +14 -0
  80. package/dist/lib/index.d.ts.map +1 -0
  81. package/dist/lib/index.js +9 -0
  82. package/dist/lib/index.js.map +1 -0
  83. package/dist/lib/labels.d.ts +20 -0
  84. package/dist/lib/labels.d.ts.map +1 -1
  85. package/dist/lib/labels.js +20 -0
  86. package/dist/lib/labels.js.map +1 -1
  87. package/dist/lib/pdf-quote.d.ts +47 -0
  88. package/dist/lib/pdf-quote.d.ts.map +1 -0
  89. package/dist/lib/pdf-quote.js +154 -0
  90. package/dist/lib/pdf-quote.js.map +1 -0
  91. package/dist/lib/pdf-runtime.d.ts +102 -0
  92. package/dist/lib/pdf-runtime.d.ts.map +1 -0
  93. package/dist/lib/pdf-runtime.js +48 -0
  94. package/dist/lib/pdf-runtime.js.map +1 -0
  95. package/dist/lib/preview-data.d.ts +55 -0
  96. package/dist/lib/preview-data.d.ts.map +1 -0
  97. package/dist/lib/preview-data.js +108 -0
  98. package/dist/lib/preview-data.js.map +1 -0
  99. package/dist/lib/prose.d.ts +37 -0
  100. package/dist/lib/prose.d.ts.map +1 -0
  101. package/dist/lib/prose.js +60 -0
  102. package/dist/lib/prose.js.map +1 -0
  103. package/dist/lib/use-isomorphic-layout-effect.d.ts +4 -0
  104. package/dist/lib/use-isomorphic-layout-effect.d.ts.map +1 -0
  105. package/dist/lib/use-isomorphic-layout-effect.js +4 -0
  106. package/dist/lib/use-isomorphic-layout-effect.js.map +1 -0
  107. package/dist/lib/use-output-expanded.d.ts +7 -0
  108. package/dist/lib/use-output-expanded.d.ts.map +1 -0
  109. package/dist/lib/use-output-expanded.js +29 -0
  110. package/dist/lib/use-output-expanded.js.map +1 -0
  111. package/dist/model/index.d.ts +5 -3
  112. package/dist/model/index.d.ts.map +1 -1
  113. package/dist/model/index.js +3 -2
  114. package/dist/model/index.js.map +1 -1
  115. package/dist/{primitives → model}/kind.d.ts +3 -0
  116. package/dist/model/kind.d.ts.map +1 -0
  117. package/dist/model/kind.js +25 -0
  118. package/dist/model/kind.js.map +1 -0
  119. package/dist/model/papers.d.ts +6 -6
  120. package/dist/model/papers.d.ts.map +1 -1
  121. package/dist/model/papers.js +8 -0
  122. package/dist/model/papers.js.map +1 -1
  123. package/dist/model/records.d.ts +5 -1
  124. package/dist/model/records.d.ts.map +1 -1
  125. package/dist/model/records.js +9 -0
  126. package/dist/model/records.js.map +1 -1
  127. package/dist/primitives/badge.d.ts +1 -1
  128. package/dist/primitives/badge.d.ts.map +1 -1
  129. package/dist/primitives/button.js +1 -1
  130. package/dist/primitives/button.js.map +1 -1
  131. package/dist/primitives/dialog.d.ts +1 -1
  132. package/dist/primitives/dialog.d.ts.map +1 -1
  133. package/dist/primitives/dialog.js +3 -3
  134. package/dist/primitives/dialog.js.map +1 -1
  135. package/dist/primitives/index.d.ts +4 -9
  136. package/dist/primitives/index.d.ts.map +1 -1
  137. package/dist/primitives/index.js +2 -5
  138. package/dist/primitives/index.js.map +1 -1
  139. package/dist/primitives/preview-popover.d.ts +1 -1
  140. package/dist/primitives/preview-popover.d.ts.map +1 -1
  141. package/dist/primitives/preview-popover.js +1 -1
  142. package/dist/primitives/preview-popover.js.map +1 -1
  143. package/dist/primitives/prose.d.ts +1 -35
  144. package/dist/primitives/prose.d.ts.map +1 -1
  145. package/dist/primitives/prose.js +2 -58
  146. package/dist/primitives/prose.js.map +1 -1
  147. package/dist/primitives/record-list.d.ts +1 -1
  148. package/dist/primitives/record-list.d.ts.map +1 -1
  149. package/dist/primitives/record-list.js +1 -1
  150. package/dist/primitives/record-list.js.map +1 -1
  151. package/dist/primitives/relation-list.d.ts +1 -1
  152. package/dist/primitives/relation-list.d.ts.map +1 -1
  153. package/dist/primitives/relation-list.js +1 -1
  154. package/dist/primitives/relation-list.js.map +1 -1
  155. package/dist/primitives/slot.d.ts.map +1 -0
  156. package/dist/{lib → primitives}/slot.js +1 -1
  157. package/dist/primitives/slot.js.map +1 -0
  158. package/dist/primitives/surface-header.d.ts +1 -1
  159. package/dist/primitives/surface-header.d.ts.map +1 -1
  160. package/dist/views/inventory.d.ts +7 -5
  161. package/dist/views/inventory.d.ts.map +1 -1
  162. package/dist/views/inventory.js +5 -4
  163. package/dist/views/inventory.js.map +1 -1
  164. package/package.json +11 -1
  165. package/src/blocks/decisions-list.tsx +1 -6
  166. package/src/blocks/index.ts +2 -3
  167. package/src/blocks/inputs-list.tsx +1 -1
  168. package/src/blocks/outputs-list.tsx +53 -30
  169. package/src/blocks/section.tsx +1 -14
  170. package/src/components/artifact-preview.tsx +6 -161
  171. package/src/components/decision-detail.tsx +2 -1
  172. package/src/components/finding-detail.tsx +3 -2
  173. package/src/components/index.ts +10 -30
  174. package/src/components/input-detail.tsx +2 -5
  175. package/src/components/insight-detail.tsx +20 -35
  176. package/src/components/insight-trigger.tsx +2 -1
  177. package/src/components/output-detail.tsx +17 -38
  178. package/src/components/output-dialog.tsx +4 -3
  179. package/src/components/paper-detail.tsx +121 -66
  180. package/src/components/paper-pdf-viewer.tsx +319 -0
  181. package/src/components/record-dialog.tsx +15 -10
  182. package/src/components/record-preview.tsx +5 -4
  183. package/src/components/relation-items.ts +15 -5
  184. package/src/{components/use-detail-stack.ts → lib/detail-stack.ts} +24 -1
  185. package/src/lib/index.ts +22 -0
  186. package/src/lib/labels.tsx +40 -0
  187. package/src/lib/pdf-quote.ts +189 -0
  188. package/src/lib/pdf-runtime.ts +131 -0
  189. package/src/lib/preview-data.ts +155 -0
  190. package/src/lib/prose.tsx +87 -0
  191. package/src/lib/use-isomorphic-layout-effect.ts +4 -0
  192. package/src/lib/use-output-expanded.ts +27 -0
  193. package/src/model/index.ts +4 -2
  194. package/src/{primitives → model}/kind.ts +14 -0
  195. package/src/model/papers.ts +9 -7
  196. package/src/model/records.ts +12 -0
  197. package/src/primitives/badge.tsx +1 -1
  198. package/src/primitives/button.tsx +1 -1
  199. package/src/primitives/dialog.tsx +3 -5
  200. package/src/primitives/index.ts +4 -17
  201. package/src/primitives/preview-popover.tsx +2 -2
  202. package/src/primitives/prose.tsx +1 -86
  203. package/src/primitives/record-list.tsx +1 -1
  204. package/src/primitives/relation-list.tsx +1 -1
  205. package/src/{lib → primitives}/slot.tsx +1 -1
  206. package/src/primitives/surface-header.tsx +1 -1
  207. package/src/views/inventory.tsx +12 -8
  208. package/styles/blocks/analysis-tree.css +2 -2
  209. package/styles/blocks/decisions-list.css +4 -4
  210. package/styles/blocks/outputs-list.css +246 -19
  211. package/styles/blocks/papers-list.css +2 -2
  212. package/styles/components/artifact-preview.css +6 -6
  213. package/styles/components/decision-detail.css +2 -2
  214. package/styles/components/evidence.css +2 -2
  215. package/styles/components/input-detail.css +4 -4
  216. package/styles/components/insight-detail.css +56 -94
  217. package/styles/components/insight-list.css +3 -3
  218. package/styles/components/insight-trigger.css +1 -4
  219. package/styles/components/output-detail.css +25 -140
  220. package/styles/components/paper-detail.css +76 -95
  221. package/styles/components/paper-doi.css +3 -12
  222. package/styles/components/paper-pdf-viewer.css +120 -0
  223. package/styles/components/record-preview.css +10 -10
  224. package/styles/primitives/badge.css +1 -1
  225. package/styles/primitives/count-heading.css +2 -2
  226. package/styles/primitives/detail-layout.css +5 -5
  227. package/styles/primitives/dialog.css +9 -9
  228. package/styles/primitives/record-list.css +17 -17
  229. package/styles/primitives/relation-list.css +6 -6
  230. package/styles/primitives/surface-header.css +5 -5
  231. package/styles/tokens.css +11 -3
  232. package/styles/views/inventory.css +3 -3
  233. package/dist/components/detail-entry.d.ts +0 -15
  234. package/dist/components/detail-entry.d.ts.map +0 -1
  235. package/dist/components/detail-entry.js +0 -14
  236. package/dist/components/detail-entry.js.map +0 -1
  237. package/dist/components/use-detail-stack.d.ts.map +0 -1
  238. package/dist/components/use-detail-stack.js.map +0 -1
  239. package/dist/lib/slot.d.ts.map +0 -1
  240. package/dist/lib/slot.js.map +0 -1
  241. package/dist/primitives/kind.d.ts.map +0 -1
  242. package/dist/primitives/kind.js +0 -14
  243. package/dist/primitives/kind.js.map +0 -1
  244. package/src/components/detail-entry.ts +0 -19
  245. /package/dist/{lib → primitives}/slot.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, type HTMLAttributes } from 'react';
2
2
  import { cn } from '../lib/cn.js';
3
- import type { SurfaceKind } from './kind.js';
3
+ import type { SurfaceKind } from '../model/kind.js';
4
4
 
5
5
  export type BadgeTone = 'neutral' | 'kind' | 'status' | 'universe';
6
6
  export type BadgeStatus = 'available' | 'current' | 'materialized' | 'ready' | 'error' | 'missing' | 'stale';
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, type ButtonHTMLAttributes } from 'react';
2
2
  import { cn } from '../lib/cn.js';
3
- import { Slot } from '../lib/slot.js';
3
+ import { Slot } from './slot.js';
4
4
 
5
5
  export type ButtonVariant = 'primary' | 'secondary' | 'quiet';
6
6
  export type ButtonSize = 'small' | 'medium';
@@ -5,7 +5,6 @@ import {
5
5
  useContext,
6
6
  useEffect,
7
7
  useId,
8
- useLayoutEffect,
9
8
  useMemo,
10
9
  useRef,
11
10
  type FocusEvent,
@@ -16,17 +15,16 @@ import {
16
15
  type SyntheticEvent,
17
16
  } from 'react';
18
17
  import { cn } from '../lib/cn.js';
18
+ import { useIsomorphicLayoutEffect } from '../lib/use-isomorphic-layout-effect.js';
19
19
  import { useLabels } from '../lib/labels.js';
20
- import { Slot } from '../lib/slot.js';
20
+ import { Slot } from './slot.js';
21
21
  import { IconButton } from './button.js';
22
- import type { SurfaceKind } from './kind.js';
22
+ import type { SurfaceKind } from '../model/kind.js';
23
23
  import { SurfaceHeader, type SurfaceHeadingLevel } from './surface-header.js';
24
24
 
25
25
  export type DialogMode = 'modal' | 'embedded';
26
26
  export type DialogLayout = 'single' | 'reader';
27
27
 
28
- const useIsomorphicLayoutEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;
29
-
30
28
  /* ------------------------------------------------------------------ */
31
29
  /* Presentation defaults shared by a subtree (mode, back trail) */
32
30
  /* ------------------------------------------------------------------ */
@@ -1,11 +1,6 @@
1
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';
2
+ export { Slot } from './slot.js';
3
+ export type { SlotProps } from './slot.js';
9
4
  export { Button, IconButton } from './button.js';
10
5
  export type { ButtonProps, ButtonSize, ButtonTone, ButtonVariant, IconButtonProps } from './button.js';
11
6
  export { PreviewPopover } from './preview-popover.js';
@@ -49,13 +44,5 @@ export { RelationList } from './relation-list.js';
49
44
  export type { RelationItem, RelationListProps } from './relation-list.js';
50
45
  export { CountHeading, DetailLayout, DetailMain, DetailRail, DetailSection } from './detail-layout.js';
51
46
  export type { CountHeadingProps, DetailLayoutMode, DetailLayoutProps, DetailRailProps, DetailSectionProps } from './detail-layout.js';
52
- export { Prose, parseProse, renderProse } from './prose.js';
53
- export type {
54
- ProseContext,
55
- ProseField,
56
- ProseMathMacros,
57
- ProseProps,
58
- ProseRenderOptions,
59
- ProseToken,
60
- TextRenderer,
61
- } from './prose.js';
47
+ export { Prose } from './prose.js';
48
+ export type { ProseProps } from './prose.js';
@@ -36,9 +36,9 @@ import {
36
36
  type ReactNode,
37
37
  } from 'react';
38
38
  import { cn } from '../lib/cn.js';
39
- import { Slot } from '../lib/slot.js';
39
+ import { Slot } from './slot.js';
40
40
  import { useDialogDismissGuard, useOptionalDialog } from './dialog.js';
41
- import type { SurfaceKind } from './kind.js';
41
+ import type { SurfaceKind } from '../model/kind.js';
42
42
 
43
43
  const ARROW_HEIGHT = 7;
44
44
  const REFERENCE_GAP = 6;
@@ -1,89 +1,4 @@
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
- /** String macro expansions accepted by the built-in KaTeX renderer. */
21
- export type ProseMathMacros = Readonly<Record<string, string>>;
22
-
23
- export interface ProseRenderOptions {
24
- /** Host-normalized math macros, such as `{ '\\vect': '\\mathbf{#1}' }`. */
25
- macros?: ProseMathMacros | undefined;
26
- }
27
-
28
- /** Balanced tokens: display math first, then `code`, then inline math. */
29
- const PROSE_TOKEN = /(\$\$[\s\S]+?\$\$|`[^`\n]+`|\$[^$\n]+\$)/g;
30
-
31
- /** Splits authored prose into text, inline `code`, `$inline$` and `$$display$$` math. */
32
- export function parseProse(text: string): ProseToken[] {
33
- const nodes: ProseToken[] = [];
34
- let last = 0;
35
- for (const match of text.matchAll(PROSE_TOKEN)) {
36
- const index = match.index;
37
- if (index > last) nodes.push({ type: 'text', value: text.slice(last, index) });
38
- const token = match[0];
39
- if (token.startsWith('$$')) nodes.push({ type: 'math', value: token.slice(2, -2).trim() });
40
- else if (token.startsWith('`')) nodes.push({ type: 'inlineCode', value: token.slice(1, -1) });
41
- else nodes.push({ type: 'inlineMath', value: token.slice(1, -1) });
42
- last = index + token.length;
43
- }
44
- if (last < text.length) nodes.push({ type: 'text', value: text.slice(last) });
45
- return nodes;
46
- }
47
-
48
- function renderMath(
49
- value: string,
50
- displayMode: boolean,
51
- macros?: ProseMathMacros,
52
- ): string {
53
- return renderToString(value, {
54
- displayMode,
55
- output: 'htmlAndMathml',
56
- strict: 'ignore',
57
- throwOnError: false,
58
- // KaTeX may mutate its macro object for global definitions. Keep a host's
59
- // shared configuration immutable across independent prose fields.
60
- ...(macros ? { macros: { ...macros } } : {}),
61
- });
62
- }
63
-
64
- /**
65
- * The built-in rendering: inline `code`, and `$inline$` / `$$display$$` math
66
- * typeset with KaTeX (load `katex/dist/katex.css`; the stylesheet bundles
67
- * import it). Text without those markers is returned as is.
68
- */
69
- export function renderProse(
70
- text: string,
71
- options: ProseRenderOptions = {},
72
- ): ReactNode {
73
- if (!/[`$]/.test(text)) return text;
74
- return parseProse(text).map((node, index) => {
75
- switch (node.type) {
76
- case 'inlineCode':
77
- return <code key={index}>{node.value}</code>;
78
- case 'inlineMath':
79
- return <span key={index} className="astra-prose__inline-math" dangerouslySetInnerHTML={{ __html: renderMath(node.value, false, options.macros) }} />;
80
- case 'math':
81
- return <div key={index} className="astra-prose__display-math" dangerouslySetInnerHTML={{ __html: renderMath(node.value, true, options.macros) }} />;
82
- default:
83
- return <Fragment key={index}>{node.value}</Fragment>;
84
- }
85
- });
86
- }
1
+ import { renderProse, type ProseContext, type TextRenderer } from '../lib/prose.js';
87
2
 
88
3
  export interface ProseProps extends ProseContext {
89
4
  text?: string | undefined;
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
2
2
  import { cn } from '../lib/cn.js';
3
- import { surfaceGlyph, type SurfaceKind } from './kind.js';
3
+ import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
4
4
 
5
5
  export interface RecordListColumn {
6
6
  label?: string | undefined;
@@ -1,7 +1,7 @@
1
1
  import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
2
2
  import { cn } from '../lib/cn.js';
3
3
  import { CountHeading } from './detail-layout.js';
4
- import { surfaceGlyph, type SurfaceKind } from './kind.js';
4
+ import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
5
5
 
6
6
  export interface RelationItem {
7
7
  key: string;
@@ -8,7 +8,7 @@ import {
8
8
  type ReactNode,
9
9
  type Ref,
10
10
  } from 'react';
11
- import { cn } from './cn.js';
11
+ import { cn } from '../lib/cn.js';
12
12
 
13
13
  export interface SlotProps extends HTMLAttributes<HTMLElement> {
14
14
  children?: ReactNode;
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
2
2
  import { cn } from '../lib/cn.js';
3
- import type { SurfaceKind } from './kind.js';
3
+ import type { SurfaceKind } from '../model/kind.js';
4
4
 
5
5
  export type SurfaceHeaderDensity = 'compact' | 'regular' | 'inline';
6
6
  export type SurfaceHeadingLevel = 'h1' | 'h2' | 'h3' | 'h4';
@@ -11,20 +11,21 @@ import { collectInventoryPapers, findPaper, paperForDoi, type InventoryPaper, ty
11
11
  import { locateRecord } from '../model/locate-record.js';
12
12
  import { cn } from '../lib/cn.js';
13
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';
14
+ import type { OpenPaperFileHandler } from '../components/paper-detail.js';
15
+ import type { PdfJsLoader } from '../lib/pdf-runtime.js';
16
16
  import { RecordDialog } from '../components/record-dialog.js';
17
- import { useDetailStack } from '../components/use-detail-stack.js';
17
+ import { useDetailStack, type DetailEntry } from '../lib/detail-stack.js';
18
18
  import type { ArtifactRenderer } from '../components/artifact-preview.js';
19
19
  import { DialogProvider, type DialogMode } from '../primitives/dialog.js';
20
- import type { TextRenderer } from '../primitives/prose.js';
20
+ import type { TextRenderer } from '../lib/prose.js';
21
21
  import { DecisionsList } from '../blocks/decisions-list.js';
22
22
  import { FindingsList } from '../blocks/findings-list.js';
23
23
  import { InputsList } from '../blocks/inputs-list.js';
24
24
  import { OutputsList } from '../blocks/outputs-list.js';
25
25
  import { PapersList } from '../blocks/papers-list.js';
26
26
  import { PriorInsightsList } from '../blocks/prior-insights-list.js';
27
- import { InventoryOutline, InventorySection, sectionKind, type InventorySectionId } from '../blocks/section.js';
27
+ import { InventoryOutline, InventorySection } from '../blocks/section.js';
28
+ import { sectionKind, type InventorySectionId } from '../model/kind.js';
28
29
 
29
30
  export const DEFAULT_SECTIONS: readonly InventorySectionId[] = ['outputs', 'decisions', 'inputs', 'findings', 'prior_insights', 'papers'];
30
31
 
@@ -42,7 +43,8 @@ export interface InventoryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'ch
42
43
  labels?: AstraLabelOverrides | undefined;
43
44
  renderArtifact?: ArtifactRenderer | undefined;
44
45
  renderText?: TextRenderer | undefined;
45
- renderPaper?: PaperRenderer | undefined;
46
+ loadPdfJs?: PdfJsLoader | undefined;
47
+ onOpenPaperFile?: OpenPaperFileHandler | undefined;
46
48
  onOpenArtifact?: ((output: ResolvedOutput) => void | Promise<void>) | undefined;
47
49
  paperMetadata?: InventoryPaperMetadataMap | undefined;
48
50
  /** Notify the host to fetch this DOI; update paperMetadata when complete. */
@@ -87,7 +89,8 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
87
89
  showOutline = true,
88
90
  renderArtifact,
89
91
  renderText,
90
- renderPaper,
92
+ loadPdfJs,
93
+ onOpenPaperFile,
91
94
  onOpenArtifact,
92
95
  paperMetadata = EMPTY_PAPER_METADATA,
93
96
  onFetchPaper,
@@ -209,7 +212,8 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
209
212
  paperMetadata={paperMetadata}
210
213
  renderArtifact={renderArtifact}
211
214
  renderText={renderText}
212
- renderPaper={renderPaper}
215
+ loadPdfJs={loadPdfJs}
216
+ onOpenPaperFile={onOpenPaperFile}
213
217
  onOpenArtifact={onOpenArtifact}
214
218
  onFetchPaper={onFetchPaper}
215
219
  onOpenRecord={stack.pushRecord}
@@ -9,7 +9,7 @@
9
9
  :where(.astra-ui) .astra-analysis-tree h2 {
10
10
  margin: 0 0 0.5rem;
11
11
  color: var(--astra-color-text-subtle);
12
- font-size: 0.625rem;
12
+ font-size: var(--astra-font-size-2xs);
13
13
  font-weight: 700;
14
14
  letter-spacing: 0.1em;
15
15
  text-transform: uppercase;
@@ -33,7 +33,7 @@
33
33
  color: var(--astra-color-text-muted);
34
34
  padding: 0.375rem 0.5rem;
35
35
  font: inherit;
36
- font-size: 0.8125rem;
36
+ font-size: var(--astra-font-size-sm);
37
37
  line-height: 1.3;
38
38
  text-align: start;
39
39
  }
@@ -4,7 +4,7 @@
4
4
  :where(.astra-ui) .astra-inventory-filter > span {
5
5
  color: var(--astra-color-text-subtle);
6
6
  font-family: var(--astra-font-ui);
7
- font-size: 0.66rem;
7
+ font-size: var(--astra-font-size-2xs);
8
8
  white-space: nowrap;
9
9
  }
10
10
 
@@ -14,7 +14,7 @@
14
14
  }
15
15
 
16
16
  :where(.astra-ui) .astra-inventory-filter > span {
17
- font-size: 0.75rem;
17
+ font-size: var(--astra-font-size-xs);
18
18
  }
19
19
 
20
20
  /* The filter stacks on the width of its records block (the query container
@@ -48,7 +48,7 @@
48
48
  background: transparent;
49
49
  color: var(--astra-color-text-subtle);
50
50
  cursor: pointer;
51
- font: 500 0.75rem/1.2 var(--astra-font-ui);
51
+ font: 500 var(--astra-font-size-xs)/1.2 var(--astra-font-ui);
52
52
  }
53
53
 
54
54
  :where(.astra-ui) .astra-inventory-filter__chips button[aria-pressed="true"] {
@@ -60,7 +60,7 @@
60
60
  :where(.astra-ui) .astra-inventory-filter > span {
61
61
  flex: 0 0 auto;
62
62
  color: var(--astra-color-text-subtle);
63
- font: 400 0.75rem/1.2 var(--astra-font-ui);
63
+ font: 400 var(--astra-font-size-xs)/1.2 var(--astra-font-ui);
64
64
  }
65
65
 
66
66
  @container (max-width: 34rem) {
@@ -12,10 +12,6 @@
12
12
  grid-template-columns: 1fr;
13
13
  }
14
14
 
15
- :where(.astra-ui) .astra-inventory-outputs__files .astra-record-list__body > button {
16
- grid-template-columns: minmax(0, 1fr) 1rem;
17
- }
18
-
19
15
  }
20
16
  @media (prefers-reduced-motion: reduce) {
21
17
  :where(.astra-ui) .astra-output-card,
@@ -67,7 +63,7 @@
67
63
  color: var(--astra-color-text-muted);
68
64
  padding: 0.25rem 0.5rem;
69
65
  font-family: var(--astra-font-ui);
70
- font-size: 0.65rem;
66
+ font-size: var(--astra-font-size-2xs);
71
67
  font-weight: 700;
72
68
  opacity: 0;
73
69
  transition: opacity 140ms ease;
@@ -81,7 +77,7 @@
81
77
  :where(.astra-ui) .astra-output-card__kind {
82
78
  color: var(--astra-color-accent);
83
79
  font-family: var(--astra-font-ui);
84
- font-size: 0.65rem;
80
+ font-size: var(--astra-font-size-2xs);
85
81
  font-weight: 700;
86
82
  letter-spacing: 0.09em;
87
83
  text-transform: uppercase;
@@ -99,15 +95,11 @@
99
95
  :where(.astra-ui) .astra-output-card__body code {
100
96
  overflow: hidden;
101
97
  color: var(--astra-color-text-subtle);
102
- font-size: 0.68rem;
98
+ font-size: var(--astra-font-size-2xs);
103
99
  text-overflow: ellipsis;
104
100
  white-space: nowrap;
105
101
  }
106
102
 
107
- :where(.astra-ui) .astra-inventory-outputs__files {
108
- overflow: visible;
109
- }
110
-
111
103
  :where(.astra-ui) .astra-output-card {
112
104
  --astra-kind: var(--astra-color-kind-output);
113
105
  --astra-kind-ink: var(--astra-color-kind-output);
@@ -150,7 +142,7 @@
150
142
  margin: 0 0 0.625rem;
151
143
  color: var(--astra-color-text-subtle);
152
144
  font-family: var(--astra-font-ui);
153
- font-size: 0.6875rem;
145
+ font-size: var(--astra-font-size-2xs);
154
146
  font-weight: 600;
155
147
  letter-spacing: 0.09em;
156
148
  text-transform: uppercase;
@@ -199,6 +191,41 @@
199
191
  border: 0;
200
192
  }
201
193
 
194
+ /* A metric card stacks label over value so the number reads at a glance;
195
+ the host's compact preview supplies the same data as the dialog. */
196
+ :where(.astra-ui) .astra-output-card__preview > .astra-artifact:where([data-type="metric"]) {
197
+ box-sizing: border-box;
198
+ display: flex;
199
+ width: 100%;
200
+ height: 100%;
201
+ flex-direction: column;
202
+ align-items: center;
203
+ justify-content: center;
204
+ gap: 0.35rem;
205
+ padding: 0.6rem;
206
+ text-align: center;
207
+ }
208
+
209
+ :where(.astra-ui) .astra-output-card__preview > .astra-artifact:where([data-type="metric"]) > .astra-artifact__metric-label {
210
+ overflow: hidden;
211
+ max-width: 100%;
212
+ color: var(--astra-color-text-subtle);
213
+ font-size: var(--astra-font-size-2xs);
214
+ line-height: 1.3;
215
+ text-overflow: ellipsis;
216
+ white-space: nowrap;
217
+ }
218
+
219
+ :where(.astra-ui) .astra-output-card__preview > .astra-artifact:where([data-type="metric"]) .astra-artifact__metric-value {
220
+ max-width: 100%;
221
+ font-size: clamp(1.25rem, 3cqw, 1.75rem);
222
+ }
223
+
224
+ :where(.astra-ui) .astra-output-card__preview > .astra-artifact:where([data-type="metric"]) .astra-artifact__metric-uncertainty,
225
+ :where(.astra-ui) .astra-output-card__preview > .astra-artifact:where([data-type="metric"]) .astra-artifact__metric-unit {
226
+ font-size: var(--astra-font-size-xs);
227
+ }
228
+
202
229
  :where(.astra-ui) .astra-output-card__open {
203
230
  top: 0.45rem;
204
231
  right: 0.45rem;
@@ -214,16 +241,16 @@
214
241
 
215
242
  :where(.astra-ui) .astra-output-card__kind {
216
243
  color: var(--astra-color-kind-output);
217
- font-size: 0.5625rem;
244
+ font-size: var(--astra-font-size-2xs);
218
245
  }
219
246
 
220
247
  :where(.astra-ui) .astra-output-card__body strong {
221
- font-size: 0.8125rem;
248
+ font-size: var(--astra-font-size-sm);
222
249
  font-weight: 600;
223
250
  }
224
251
 
225
252
  :where(.astra-ui) .astra-output-card__body code {
226
- font-size: 0.625rem;
253
+ font-size: var(--astra-font-size-2xs);
227
254
  }
228
255
 
229
256
  @container (max-width: 58rem) {
@@ -254,7 +281,7 @@
254
281
  margin: 0 0 0.625rem;
255
282
  color: var(--astra-color-text-subtle);
256
283
  font-family: var(--astra-font-ui);
257
- font-size: 0.6875rem;
284
+ font-size: var(--astra-font-size-2xs);
258
285
  font-weight: 600;
259
286
  letter-spacing: 0.09em;
260
287
  text-transform: uppercase;
@@ -305,7 +332,7 @@
305
332
  border: 0;
306
333
  background: color-mix(in srgb, var(--astra-color-surface-raised) 92%, transparent);
307
334
  color: var(--astra-color-text-muted);
308
- font: 600 0.625rem/1.2 var(--astra-font-ui);
335
+ font: 600 var(--astra-font-size-2xs)/1.2 var(--astra-font-ui);
309
336
  }
310
337
 
311
338
  :where(.astra-ui) .astra-output-card__body {
@@ -317,7 +344,7 @@
317
344
  display: block;
318
345
  margin-bottom: 0.125rem;
319
346
  color: var(--astra-color-kind-output);
320
- font: 700 0.5625rem/1.2 var(--astra-font-ui);
347
+ font: 700 var(--astra-font-size-2xs)/1.2 var(--astra-font-ui);
321
348
  letter-spacing: 0.08em;
322
349
  text-transform: uppercase;
323
350
  }
@@ -325,7 +352,7 @@
325
352
  :where(.astra-ui) .astra-output-card__body strong {
326
353
  display: block;
327
354
  overflow: hidden;
328
- font: 600 0.8125rem/1.25 var(--astra-font-ui);
355
+ font: 600 var(--astra-font-size-sm)/1.25 var(--astra-font-ui);
329
356
  text-overflow: ellipsis;
330
357
  white-space: nowrap;
331
358
  }
@@ -346,4 +373,204 @@
346
373
  }
347
374
 
348
375
  }
376
+
377
+ /* Compact outputs: wrapping metric tiles and a responsive file grid. */
378
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid {
379
+ display: grid;
380
+ grid-template-columns: minmax(0, 1fr);
381
+ column-gap: calc(4 * var(--astra-space-2));
382
+ margin: 0;
383
+ padding: 0;
384
+ list-style: none;
385
+ }
386
+
387
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid > li {
388
+ position: relative;
389
+ display: flex;
390
+ min-width: 0;
391
+ border-bottom: 1px solid var(--astra-color-border-subtle);
392
+ }
393
+
394
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid > li::before {
395
+ content: '';
396
+ position: absolute;
397
+ display: none;
398
+ inset-block: 0;
399
+ inset-inline-start: calc(-2 * var(--astra-space-2));
400
+ border-inline-start: 1px solid var(--astra-color-border);
401
+ pointer-events: none;
402
+ }
403
+
404
+ :where(.astra-ui) .astra-output-entry {
405
+ appearance: none;
406
+ display: grid;
407
+ grid-template-columns: minmax(0, 1fr) auto;
408
+ align-items: baseline;
409
+ gap: var(--astra-space-3);
410
+ width: 100%;
411
+ min-width: 0;
412
+ min-height: 2.75rem;
413
+ margin: 0;
414
+ padding: var(--astra-space-3) var(--astra-space-2);
415
+ border: 0;
416
+ border-radius: 0;
417
+ background: transparent;
418
+ color: var(--astra-color-text);
419
+ font: 400 var(--astra-font-size-sm)/1.5 var(--astra-font-ui);
420
+ text-align: start;
421
+ cursor: pointer;
422
+ }
423
+
424
+ :where(.astra-ui) .astra-output-entry:hover {
425
+ background: var(--astra-color-surface-muted);
426
+ }
427
+
428
+ :where(.astra-ui) .astra-output-entry:focus-visible {
429
+ outline: 2px solid var(--astra-color-focus);
430
+ outline-offset: -2px;
431
+ background: var(--astra-color-surface-muted);
432
+ }
433
+
434
+ :where(.astra-ui) .astra-output-entry__name {
435
+ min-width: 0;
436
+ overflow-wrap: anywhere;
437
+ font-weight: 500;
438
+ }
439
+
440
+ :where(.astra-ui) .astra-output-entry__format {
441
+ color: var(--astra-color-text-subtle);
442
+ font: 500 var(--astra-font-size-2xs)/1.5 var(--astra-font-mono);
443
+ overflow-wrap: anywhere;
444
+ text-align: end;
445
+ }
446
+
447
+ :where(.astra-ui) .astra-output-entry__value {
448
+ min-width: 0;
449
+ text-align: center;
450
+ font-variant-numeric: tabular-nums;
451
+ overflow-wrap: anywhere;
452
+ }
453
+
454
+ :where(.astra-ui) .astra-output-entry__status {
455
+ color: var(--astra-color-text-subtle);
456
+ font-size: var(--astra-font-size-xs);
457
+ overflow-wrap: anywhere;
458
+ }
459
+
460
+ :where(.astra-ui) .astra-output-entry__name .astra-output-entry__status {
461
+ display: block;
462
+ font-weight: 400;
463
+ }
464
+
465
+ :where(.astra-ui) .astra-output-entry__value .astra-artifact__metric {
466
+ flex-wrap: wrap;
467
+ justify-content: center;
468
+ gap: 0 0.3em;
469
+ font: inherit;
470
+ }
471
+
472
+ :where(.astra-ui) .astra-output-entry__value .astra-artifact__metric-label {
473
+ display: none;
474
+ }
475
+
476
+ :where(.astra-ui) .astra-output-entry__value :is(.astra-artifact__metric-value, .astra-artifact__metric-uncertainty, .astra-artifact__metric-unit) {
477
+ max-width: 100%;
478
+ color: inherit;
479
+ font: inherit;
480
+ text-align: center;
481
+ }
482
+
483
+ :where(.astra-ui) .astra-output-entry__value .astra-artifact__metric-value {
484
+ font-weight: 600;
485
+ }
486
+
487
+ :where(.astra-ui) .astra-output-entry__value .astra-artifact__placeholder {
488
+ display: block;
489
+ text-align: center;
490
+ }
491
+
492
+ :where(.astra-ui) .astra-output-entry__value .astra-artifact__placeholder > span:first-child {
493
+ display: none;
494
+ }
495
+
496
+ @container (min-width: 42rem) {
497
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid:where([data-layout="grid"]) {
498
+ grid-template-columns: repeat(2, minmax(0, 1fr));
499
+ }
500
+
501
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid:where([data-layout="grid"]) > li:where(:nth-child(2n))::before {
502
+ display: block;
503
+ }
504
+ }
505
+
506
+ @container (min-width: 72rem) {
507
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid:where([data-layout="grid"]) {
508
+ grid-template-columns: repeat(3, minmax(0, 1fr));
509
+ }
510
+
511
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid:where([data-layout="grid"]) > li::before {
512
+ display: none;
513
+ }
514
+
515
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid:where([data-layout="grid"]) > li:where(:not(:nth-child(3n + 1)))::before {
516
+ display: block;
517
+ }
518
+ }
519
+
520
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid:where([data-layout="tiles"]) {
521
+ display: flex;
522
+ flex-wrap: wrap;
523
+ align-items: flex-start;
524
+ gap: var(--astra-space-2);
525
+ }
526
+
527
+ :where(.astra-ui) .astra-inventory-outputs__compact-grid:where([data-layout="tiles"]) > li {
528
+ max-width: 100%;
529
+ border: 0;
530
+ }
531
+
532
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]) {
533
+ grid-template-columns: minmax(0, 1fr);
534
+ gap: calc(0.5 * var(--astra-space-2));
535
+ width: auto;
536
+ max-width: 100%;
537
+ min-height: 3.25rem;
538
+ padding: var(--astra-space-2) var(--astra-space-3);
539
+ border: 1px solid var(--astra-color-border);
540
+ border-radius: calc(2 * var(--astra-radius-preview));
541
+ background: var(--astra-color-artifact-paper);
542
+ color: var(--astra-color-artifact-ink);
543
+ font-size: var(--astra-font-size-xs);
544
+ text-align: center;
545
+ }
546
+
547
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]) .astra-output-entry__name {
548
+ grid-row: 2;
549
+ color: color-mix(in srgb, var(--astra-color-artifact-ink) 72%, var(--astra-color-artifact-paper));
550
+ font: 600 var(--astra-font-size-sm)/1.25 var(--astra-font-ui);
551
+ }
552
+
553
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]) .astra-output-entry__value {
554
+ grid-row: 1;
555
+ }
556
+
557
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]) .astra-artifact__metric {
558
+ color: var(--astra-color-artifact-ink);
559
+ }
560
+
561
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]) .astra-artifact__metric-value {
562
+ font-size: 1rem;
563
+ line-height: 1.25;
564
+ }
565
+
566
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]) :is(.astra-output-entry__status, .astra-artifact__placeholder) {
567
+ color: color-mix(in srgb, var(--astra-color-artifact-ink) 72%, var(--astra-color-artifact-paper));
568
+ text-align: center;
569
+ }
570
+
571
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]):hover,
572
+ :where(.astra-ui) .astra-output-entry:where([data-kind="metric"]):focus-visible {
573
+ background: var(--astra-color-artifact-paper);
574
+ border-color: var(--astra-color-focus);
575
+ }
349
576
  }