@astra-spec/ui 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -20
- package/TOKENS.md +17 -8
- package/components.css +1 -0
- package/dist/blocks/decisions-list.d.ts +0 -1
- package/dist/blocks/decisions-list.d.ts.map +1 -1
- package/dist/blocks/decisions-list.js +1 -5
- package/dist/blocks/decisions-list.js.map +1 -1
- package/dist/blocks/findings-list.d.ts.map +1 -1
- package/dist/blocks/findings-list.js +2 -1
- package/dist/blocks/findings-list.js.map +1 -1
- package/dist/blocks/index.d.ts +3 -3
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +2 -2
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/inputs-list.js +1 -1
- package/dist/blocks/inputs-list.js.map +1 -1
- package/dist/blocks/outputs-list.d.ts +2 -2
- package/dist/blocks/outputs-list.d.ts.map +1 -1
- package/dist/blocks/outputs-list.js +15 -19
- package/dist/blocks/outputs-list.js.map +1 -1
- package/dist/blocks/section.d.ts +1 -4
- package/dist/blocks/section.d.ts.map +1 -1
- package/dist/blocks/section.js +3 -13
- package/dist/blocks/section.js.map +1 -1
- package/dist/components/artifact-preview.d.ts +2 -54
- package/dist/components/artifact-preview.d.ts.map +1 -1
- package/dist/components/artifact-preview.js +2 -107
- package/dist/components/artifact-preview.js.map +1 -1
- package/dist/components/decision-detail.d.ts +1 -1
- package/dist/components/decision-detail.d.ts.map +1 -1
- package/dist/components/decision-detail.js.map +1 -1
- package/dist/components/finding-detail.d.ts +2 -2
- package/dist/components/finding-detail.d.ts.map +1 -1
- package/dist/components/finding-detail.js.map +1 -1
- package/dist/components/index.d.ts +9 -13
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -8
- package/dist/components/index.js.map +1 -1
- package/dist/components/input-detail.d.ts +1 -2
- package/dist/components/input-detail.d.ts.map +1 -1
- package/dist/components/input-detail.js +0 -3
- package/dist/components/input-detail.js.map +1 -1
- package/dist/components/insight-detail.d.ts +2 -8
- package/dist/components/insight-detail.d.ts.map +1 -1
- package/dist/components/insight-detail.js +5 -11
- package/dist/components/insight-detail.js.map +1 -1
- package/dist/components/insight-trigger.d.ts +1 -1
- package/dist/components/insight-trigger.d.ts.map +1 -1
- package/dist/components/insight-trigger.js +3 -2
- package/dist/components/insight-trigger.js.map +1 -1
- package/dist/components/output-detail.d.ts +2 -7
- package/dist/components/output-detail.d.ts.map +1 -1
- package/dist/components/output-detail.js +3 -30
- package/dist/components/output-detail.js.map +1 -1
- package/dist/components/output-dialog.d.ts +2 -2
- package/dist/components/output-dialog.d.ts.map +1 -1
- package/dist/components/output-dialog.js +2 -1
- package/dist/components/output-dialog.js.map +1 -1
- package/dist/components/paper-detail.d.ts +14 -14
- package/dist/components/paper-detail.d.ts.map +1 -1
- package/dist/components/paper-detail.js +49 -29
- package/dist/components/paper-detail.js.map +1 -1
- package/dist/components/paper-pdf-viewer.d.ts +19 -0
- package/dist/components/paper-pdf-viewer.d.ts.map +1 -0
- package/dist/components/paper-pdf-viewer.js +250 -0
- package/dist/components/paper-pdf-viewer.js.map +1 -0
- package/dist/components/record-dialog.d.ts +7 -5
- package/dist/components/record-dialog.d.ts.map +1 -1
- package/dist/components/record-dialog.js +7 -5
- package/dist/components/record-dialog.js.map +1 -1
- package/dist/components/record-preview.d.ts +2 -2
- package/dist/components/record-preview.d.ts.map +1 -1
- package/dist/components/record-preview.js +9 -8
- package/dist/components/record-preview.js.map +1 -1
- package/dist/components/relation-items.d.ts +1 -1
- package/dist/components/relation-items.d.ts.map +1 -1
- package/dist/components/relation-items.js +10 -3
- package/dist/components/relation-items.js.map +1 -1
- package/dist/{components/use-detail-stack.d.ts → lib/detail-stack.d.ts} +17 -2
- package/dist/lib/detail-stack.d.ts.map +1 -0
- package/dist/{components/use-detail-stack.js → lib/detail-stack.js} +15 -2
- package/dist/lib/detail-stack.js.map +1 -0
- package/dist/lib/index.d.ts +14 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/labels.d.ts +20 -0
- package/dist/lib/labels.d.ts.map +1 -1
- package/dist/lib/labels.js +20 -0
- package/dist/lib/labels.js.map +1 -1
- package/dist/lib/pdf-quote.d.ts +47 -0
- package/dist/lib/pdf-quote.d.ts.map +1 -0
- package/dist/lib/pdf-quote.js +154 -0
- package/dist/lib/pdf-quote.js.map +1 -0
- package/dist/lib/pdf-runtime.d.ts +102 -0
- package/dist/lib/pdf-runtime.d.ts.map +1 -0
- package/dist/lib/pdf-runtime.js +48 -0
- package/dist/lib/pdf-runtime.js.map +1 -0
- package/dist/lib/preview-data.d.ts +55 -0
- package/dist/lib/preview-data.d.ts.map +1 -0
- package/dist/lib/preview-data.js +108 -0
- package/dist/lib/preview-data.js.map +1 -0
- package/dist/lib/prose.d.ts +37 -0
- package/dist/lib/prose.d.ts.map +1 -0
- package/dist/lib/prose.js +60 -0
- package/dist/lib/prose.js.map +1 -0
- package/dist/lib/use-isomorphic-layout-effect.d.ts +4 -0
- package/dist/lib/use-isomorphic-layout-effect.d.ts.map +1 -0
- package/dist/lib/use-isomorphic-layout-effect.js +4 -0
- package/dist/lib/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/lib/use-output-expanded.d.ts +7 -0
- package/dist/lib/use-output-expanded.d.ts.map +1 -0
- package/dist/lib/use-output-expanded.js +29 -0
- package/dist/lib/use-output-expanded.js.map +1 -0
- package/dist/model/index.d.ts +5 -3
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -2
- package/dist/model/index.js.map +1 -1
- package/dist/model/kind.d.ts +9 -0
- package/dist/model/kind.d.ts.map +1 -0
- package/dist/model/kind.js +25 -0
- package/dist/model/kind.js.map +1 -0
- package/dist/model/papers.d.ts +6 -6
- package/dist/model/papers.d.ts.map +1 -1
- package/dist/model/papers.js +8 -0
- package/dist/model/papers.js.map +1 -1
- package/dist/model/records.d.ts +5 -1
- package/dist/model/records.d.ts.map +1 -1
- package/dist/model/records.js +9 -0
- package/dist/model/records.js.map +1 -1
- package/dist/primitives/badge.d.ts +1 -1
- package/dist/primitives/badge.d.ts.map +1 -1
- package/dist/primitives/button.js +1 -1
- package/dist/primitives/button.js.map +1 -1
- package/dist/primitives/dialog.d.ts +1 -1
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +3 -3
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/index.d.ts +8 -9
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +4 -5
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/inline-reference.d.ts +9 -0
- package/dist/primitives/inline-reference.d.ts.map +1 -0
- package/dist/primitives/inline-reference.js +14 -0
- package/dist/primitives/inline-reference.js.map +1 -0
- package/dist/primitives/kind-glyph.d.ts +8 -0
- package/dist/primitives/kind-glyph.d.ts.map +1 -0
- package/dist/primitives/kind-glyph.js +9 -0
- package/dist/primitives/kind-glyph.js.map +1 -0
- package/dist/primitives/preview-popover.d.ts +2 -2
- package/dist/primitives/preview-popover.d.ts.map +1 -1
- package/dist/primitives/preview-popover.js +1 -1
- package/dist/primitives/preview-popover.js.map +1 -1
- package/dist/primitives/prose.d.ts +1 -35
- package/dist/primitives/prose.d.ts.map +1 -1
- package/dist/primitives/prose.js +2 -58
- package/dist/primitives/prose.js.map +1 -1
- package/dist/primitives/record-list.d.ts +1 -1
- package/dist/primitives/record-list.d.ts.map +1 -1
- package/dist/primitives/record-list.js +3 -2
- package/dist/primitives/record-list.js.map +1 -1
- package/dist/primitives/relation-list.d.ts +1 -1
- package/dist/primitives/relation-list.d.ts.map +1 -1
- package/dist/primitives/relation-list.js +3 -2
- package/dist/primitives/relation-list.js.map +1 -1
- package/dist/primitives/slot.d.ts.map +1 -0
- package/dist/{lib → primitives}/slot.js +1 -1
- package/dist/primitives/slot.js.map +1 -0
- package/dist/primitives/surface-header.d.ts +1 -1
- package/dist/primitives/surface-header.d.ts.map +1 -1
- package/dist/views/inventory.d.ts +7 -5
- package/dist/views/inventory.d.ts.map +1 -1
- package/dist/views/inventory.js +5 -4
- package/dist/views/inventory.js.map +1 -1
- package/isolate.css +7 -0
- package/package.json +15 -3
- package/primitives.css +2 -0
- package/src/blocks/decisions-list.tsx +1 -6
- package/src/blocks/findings-list.tsx +2 -1
- package/src/blocks/index.ts +2 -3
- package/src/blocks/inputs-list.tsx +1 -1
- package/src/blocks/outputs-list.tsx +53 -30
- package/src/blocks/section.tsx +3 -15
- package/src/components/artifact-preview.tsx +6 -161
- package/src/components/decision-detail.tsx +2 -1
- package/src/components/finding-detail.tsx +3 -2
- package/src/components/index.ts +10 -30
- package/src/components/input-detail.tsx +2 -5
- package/src/components/insight-detail.tsx +20 -35
- package/src/components/insight-trigger.tsx +5 -3
- package/src/components/output-detail.tsx +17 -38
- package/src/components/output-dialog.tsx +4 -3
- package/src/components/paper-detail.tsx +121 -66
- package/src/components/paper-pdf-viewer.tsx +319 -0
- package/src/components/record-dialog.tsx +15 -10
- package/src/components/record-preview.tsx +12 -17
- package/src/components/relation-items.ts +15 -5
- package/src/{components/use-detail-stack.ts → lib/detail-stack.ts} +24 -1
- package/src/lib/index.ts +22 -0
- package/src/lib/labels.tsx +40 -0
- package/src/lib/pdf-quote.ts +189 -0
- package/src/lib/pdf-runtime.ts +131 -0
- package/src/lib/preview-data.ts +155 -0
- package/src/lib/prose.tsx +87 -0
- package/src/lib/use-isomorphic-layout-effect.ts +4 -0
- package/src/lib/use-output-expanded.ts +27 -0
- package/src/model/index.ts +4 -2
- package/src/model/kind.ts +33 -0
- package/src/model/papers.ts +9 -7
- package/src/model/records.ts +12 -0
- package/src/primitives/badge.tsx +1 -1
- package/src/primitives/button.tsx +1 -1
- package/src/primitives/dialog.tsx +3 -5
- package/src/primitives/index.ts +8 -17
- package/src/primitives/inline-reference.tsx +25 -0
- package/src/primitives/kind-glyph.tsx +24 -0
- package/src/primitives/preview-popover.tsx +3 -3
- package/src/primitives/prose.tsx +1 -86
- package/src/primitives/record-list.tsx +3 -4
- package/src/primitives/relation-list.tsx +4 -7
- package/src/{lib → primitives}/slot.tsx +1 -1
- package/src/primitives/surface-header.tsx +1 -1
- package/src/views/inventory.tsx +12 -8
- package/styles/blocks/analysis-tree.css +6 -6
- package/styles/blocks/decisions-list.css +10 -10
- package/styles/blocks/outputs-list.css +272 -45
- package/styles/blocks/papers-list.css +14 -14
- package/styles/blocks/records.css +13 -13
- package/styles/components/artifact-preview.css +21 -21
- package/styles/components/decision-detail.css +23 -23
- package/styles/components/evidence.css +4 -9
- package/styles/components/finding-detail.css +11 -11
- package/styles/components/input-detail.css +11 -11
- package/styles/components/insight-detail.css +57 -95
- package/styles/components/insight-list.css +9 -9
- package/styles/components/insight-trigger.css +5 -8
- package/styles/components/output-detail.css +74 -189
- package/styles/components/paper-detail.css +90 -109
- package/styles/components/paper-doi.css +5 -14
- package/styles/components/paper-pdf-viewer.css +120 -0
- package/styles/components/record-preview.css +444 -268
- package/styles/primitives/badge.css +2 -2
- package/styles/primitives/button.css +25 -25
- package/styles/primitives/count-heading.css +5 -5
- package/styles/primitives/detail-layout.css +25 -25
- package/styles/primitives/dialog.css +86 -86
- package/styles/primitives/empty-state.css +1 -1
- package/styles/primitives/inline-reference.css +37 -0
- package/styles/primitives/kind-glyph.css +31 -0
- package/styles/primitives/kind.css +6 -0
- package/styles/primitives/preview-popover.css +6 -11
- package/styles/primitives/prose.css +1 -1
- package/styles/primitives/record-list.css +46 -62
- package/styles/primitives/relation-list.css +20 -42
- package/styles/primitives/surface-header.css +20 -16
- package/styles/tokens.css +26 -8
- package/styles/views/inventory.css +27 -29
- package/dist/components/detail-entry.d.ts +0 -15
- package/dist/components/detail-entry.d.ts.map +0 -1
- package/dist/components/detail-entry.js +0 -14
- package/dist/components/detail-entry.js.map +0 -1
- package/dist/components/use-detail-stack.d.ts.map +0 -1
- package/dist/components/use-detail-stack.js.map +0 -1
- package/dist/lib/slot.d.ts.map +0 -1
- package/dist/lib/slot.js.map +0 -1
- package/dist/primitives/kind.d.ts +0 -6
- package/dist/primitives/kind.d.ts.map +0 -1
- package/dist/primitives/kind.js +0 -14
- package/dist/primitives/kind.js.map +0 -1
- package/src/components/detail-entry.ts +0 -19
- package/src/primitives/kind.ts +0 -19
- /package/dist/{lib → primitives}/slot.d.ts +0 -0
package/src/model/records.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ResolvedAnalysisNode,
|
|
3
3
|
ResolvedDecision,
|
|
4
|
+
ResolvedInput,
|
|
4
5
|
ResolvedInsight,
|
|
5
6
|
ResolvedOutput,
|
|
6
7
|
ResolvedRecord,
|
|
@@ -41,3 +42,14 @@ export function isVisualOutput(output: ResolvedOutput): boolean {
|
|
|
41
42
|
export function countLabel(count: number, singular: string, plural = `${singular}s`): string {
|
|
42
43
|
return `${count} ${count === 1 ? singular : plural}`;
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
/** Where an input comes from, as declared, or a placeholder. */
|
|
47
|
+
export function inputSourceLabel(record: ResolvedInput): string {
|
|
48
|
+
return record.source ?? record.ref ?? record.resolvedFrom ?? 'Source not declared';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A decision tag's display label: the host's, or the tag itself in sentence case. */
|
|
52
|
+
export function decisionTagLabel(tag: string, labels: Readonly<Record<string, string>>): string {
|
|
53
|
+
return labels[tag]
|
|
54
|
+
?? tag.replace(/_/g, ' ').replace(/^./, (character: string) => character.toUpperCase());
|
|
55
|
+
}
|
package/src/primitives/badge.tsx
CHANGED
|
@@ -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 '
|
|
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 '
|
|
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 '
|
|
20
|
+
import { Slot } from './slot.js';
|
|
21
21
|
import { IconButton } from './button.js';
|
|
22
|
-
import type { SurfaceKind } from '
|
|
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
|
/* ------------------------------------------------------------------ */
|
package/src/primitives/index.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
/** Presentation primitives: generic UI with no ASTRA model beyond record kinds. */
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
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,9 @@ 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
|
|
53
|
-
export type {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
ProseRenderOptions,
|
|
59
|
-
ProseToken,
|
|
60
|
-
TextRenderer,
|
|
61
|
-
} from './prose.js';
|
|
47
|
+
export { Prose } from './prose.js';
|
|
48
|
+
export type { ProseProps } from './prose.js';
|
|
49
|
+
export { KindGlyph } from './kind-glyph.js';
|
|
50
|
+
export type { KindGlyphProps } from './kind-glyph.js';
|
|
51
|
+
export { InlineReference } from './inline-reference.js';
|
|
52
|
+
export type { InlineReferenceProps } from './inline-reference.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Children, cloneElement, forwardRef, type HTMLAttributes, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { SurfaceKind } from '../model/kind.js';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
import { Slot } from './slot.js';
|
|
5
|
+
import { KindGlyph } from './kind-glyph.js';
|
|
6
|
+
|
|
7
|
+
export interface InlineReferenceProps extends HTMLAttributes<HTMLSpanElement> {
|
|
8
|
+
kind?: SurfaceKind | 'value' | 'option' | undefined;
|
|
9
|
+
asChild?: boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Editorial inline token. Hosts own its text, navigation and preview interaction. */
|
|
13
|
+
export const InlineReference = forwardRef<HTMLSpanElement, InlineReferenceProps>(function InlineReference({
|
|
14
|
+
kind, asChild = false, className, children, ...props
|
|
15
|
+
}, ref) {
|
|
16
|
+
const Component = asChild ? Slot : 'span';
|
|
17
|
+
const glyph = kind && kind !== 'value' ? <KindGlyph kind={kind === 'option' ? 'decision' : kind} /> : null;
|
|
18
|
+
const child = asChild ? Children.only(children) as ReactElement<{ children?: ReactNode }> : undefined;
|
|
19
|
+
const content = child ? cloneElement(child, {}, glyph, child.props.children) : <>{glyph}{children}</>;
|
|
20
|
+
return (
|
|
21
|
+
<Component data-slot="inline-reference" {...props} ref={ref} className={cn('astra-ui astra-inline-reference', className)} data-kind={kind}>
|
|
22
|
+
{content}
|
|
23
|
+
</Component>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
2
|
+
import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
|
|
5
|
+
export interface KindGlyphProps extends HTMLAttributes<HTMLSpanElement> {
|
|
6
|
+
kind: SurfaceKind;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Decorative kind mark. Its kind selects both symbol and colour; typography is shared across surfaces. */
|
|
10
|
+
export const KindGlyph = forwardRef<HTMLSpanElement, KindGlyphProps>(function KindGlyph({
|
|
11
|
+
kind, className, ...props
|
|
12
|
+
}, ref) {
|
|
13
|
+
return (
|
|
14
|
+
<span data-slot="kind-glyph" {...props} ref={ref} className={cn('astra-kind-glyph', className)} data-kind={kind} aria-hidden="true">
|
|
15
|
+
{kind === 'paper' ? (
|
|
16
|
+
<svg viewBox="0 0 24 24" width="1em" height="1em" fill="none" stroke="currentColor"
|
|
17
|
+
strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false">
|
|
18
|
+
<path d="M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8l-5-5Z" />
|
|
19
|
+
<path d="M14 3v5h5M8 12h8M8 16h6" />
|
|
20
|
+
</svg>
|
|
21
|
+
) : surfaceGlyph(kind)}
|
|
22
|
+
</span>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
@@ -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 '
|
|
39
|
+
import { Slot } from './slot.js';
|
|
40
40
|
import { useDialogDismissGuard, useOptionalDialog } from './dialog.js';
|
|
41
|
-
import type { SurfaceKind } from '
|
|
41
|
+
import type { SurfaceKind } from '../model/kind.js';
|
|
42
42
|
|
|
43
43
|
const ARROW_HEIGHT = 7;
|
|
44
44
|
const REFERENCE_GAP = 6;
|
|
@@ -57,7 +57,7 @@ export interface PreviewPopoverProps
|
|
|
57
57
|
children: ReactNode;
|
|
58
58
|
/** Accessible name for the non-modal preview dialog. */
|
|
59
59
|
label: string;
|
|
60
|
-
kind?: SurfaceKind | undefined;
|
|
60
|
+
kind?: SurfaceKind | 'value' | undefined;
|
|
61
61
|
disabled?: boolean | undefined;
|
|
62
62
|
open?: boolean | undefined;
|
|
63
63
|
defaultOpen?: boolean | undefined;
|
package/src/primitives/prose.tsx
CHANGED
|
@@ -1,89 +1,4 @@
|
|
|
1
|
-
import {
|
|
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,7 @@
|
|
|
1
|
+
import { KindGlyph } from './kind-glyph.js';
|
|
1
2
|
import { forwardRef, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
3
|
import { cn } from '../lib/cn.js';
|
|
3
|
-
import {
|
|
4
|
+
import { type SurfaceKind } from '../model/kind.js';
|
|
4
5
|
|
|
5
6
|
export interface RecordListColumn {
|
|
6
7
|
label?: string | undefined;
|
|
@@ -85,9 +86,7 @@ export const RecordIdentity = forwardRef<HTMLSpanElement, RecordIdentityProps>(f
|
|
|
85
86
|
}, ref) {
|
|
86
87
|
return (
|
|
87
88
|
<span data-slot="record-identity" {...props} ref={ref} className={cn('astra-record-list__name', className)}>
|
|
88
|
-
<
|
|
89
|
-
{surfaceGlyph(kind)}
|
|
90
|
-
</span>
|
|
89
|
+
<KindGlyph className="astra-record-list__glyph" kind={kind} />
|
|
91
90
|
<span>
|
|
92
91
|
<strong>{title}</strong>
|
|
93
92
|
{subtitle != null ? <small>{subtitle}</small> : null}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { KindGlyph } from './kind-glyph.js';
|
|
1
2
|
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
3
|
import { cn } from '../lib/cn.js';
|
|
3
4
|
import { CountHeading } from './detail-layout.js';
|
|
4
|
-
import {
|
|
5
|
+
import { type SurfaceKind } from '../model/kind.js';
|
|
5
6
|
|
|
6
7
|
export interface RelationItem {
|
|
7
8
|
key: string;
|
|
@@ -25,12 +26,8 @@ export interface RelationListProps extends Omit<HTMLAttributes<HTMLElement>, 'ti
|
|
|
25
26
|
function RelationItemContent({ item }: { item: RelationItem }) {
|
|
26
27
|
return (
|
|
27
28
|
<>
|
|
28
|
-
<span
|
|
29
|
-
|
|
30
|
-
{...(item.kind ? {} : { 'data-empty': '' })}
|
|
31
|
-
aria-hidden="true"
|
|
32
|
-
>
|
|
33
|
-
{item.kind ? surfaceGlyph(item.kind) : ''}
|
|
29
|
+
<span className="astra-relation-item__glyph" data-empty={!item.kind ? '' : undefined} aria-hidden="true">
|
|
30
|
+
{item.kind ? <KindGlyph kind={item.kind} /> : null}
|
|
34
31
|
</span>
|
|
35
32
|
<span className="astra-relation-item__copy">
|
|
36
33
|
<span className="astra-relation-item__label">{item.label}</span>
|
|
@@ -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 '
|
|
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';
|
package/src/views/inventory.tsx
CHANGED
|
@@ -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 {
|
|
15
|
-
import type {
|
|
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 '../
|
|
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 '../
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
215
|
+
loadPdfJs={loadPdfJs}
|
|
216
|
+
onOpenPaperFile={onOpenPaperFile}
|
|
213
217
|
onOpenArtifact={onOpenArtifact}
|
|
214
218
|
onFetchPaper={onFetchPaper}
|
|
215
219
|
onOpenRecord={stack.pushRecord}
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
:where(.astra-ui) .astra-analysis-tree h2 {
|
|
10
|
-
margin: 0 0
|
|
10
|
+
margin: 0 0 8px;
|
|
11
11
|
color: var(--astra-color-text-subtle);
|
|
12
|
-
font-size:
|
|
12
|
+
font-size: var(--astra-font-size-2xs);
|
|
13
13
|
font-weight: 700;
|
|
14
14
|
letter-spacing: 0.1em;
|
|
15
15
|
text-transform: uppercase;
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
display: flex;
|
|
26
26
|
width: 100%;
|
|
27
27
|
align-items: center;
|
|
28
|
-
gap:
|
|
28
|
+
gap: 8px;
|
|
29
29
|
cursor: pointer;
|
|
30
30
|
border: 0;
|
|
31
|
-
border-radius:
|
|
31
|
+
border-radius: 4px;
|
|
32
32
|
background: transparent;
|
|
33
33
|
color: var(--astra-color-text-muted);
|
|
34
|
-
padding:
|
|
34
|
+
padding: 6px 8px;
|
|
35
35
|
font: inherit;
|
|
36
|
-
font-size:
|
|
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:
|
|
7
|
+
font-size: var(--astra-font-size-2xs);
|
|
8
8
|
white-space: nowrap;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
:where(.astra-ui) .astra-inventory-filter > span {
|
|
17
|
-
font-size:
|
|
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
|
|
21
21
|
declared in records.css); :where() keeps the specificity unchanged. */
|
|
22
|
-
@container (max-width:
|
|
22
|
+
@container (max-width: 608px) {
|
|
23
23
|
:where(.astra-ui) :where(.astra-inventory-records) .astra-inventory-filter {
|
|
24
24
|
align-items: flex-start;
|
|
25
25
|
flex-direction: column;
|
|
@@ -30,25 +30,25 @@
|
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: center;
|
|
32
32
|
justify-content: space-between;
|
|
33
|
-
gap:
|
|
34
|
-
margin: 0 0
|
|
33
|
+
gap: 16px;
|
|
34
|
+
margin: 0 0 10px;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
:where(.astra-ui) .astra-inventory-filter__chips {
|
|
38
38
|
display: flex;
|
|
39
39
|
flex-wrap: wrap;
|
|
40
|
-
gap:
|
|
40
|
+
gap: 6px;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
:where(.astra-ui) .astra-inventory-filter__chips button {
|
|
44
44
|
min-height: 0;
|
|
45
|
-
padding:
|
|
45
|
+
padding: 4px 10px;
|
|
46
46
|
border: 1px solid var(--astra-color-border-strong);
|
|
47
47
|
border-radius: 999px;
|
|
48
48
|
background: transparent;
|
|
49
49
|
color: var(--astra-color-text-subtle);
|
|
50
50
|
cursor: pointer;
|
|
51
|
-
font: 500
|
|
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,10 +60,10 @@
|
|
|
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
|
|
63
|
+
font: 400 var(--astra-font-size-xs)/1.2 var(--astra-font-ui);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
@container (max-width:
|
|
66
|
+
@container (max-width: 544px) {
|
|
67
67
|
:where(.astra-ui) :where(.astra-inventory-records) .astra-inventory-filter {
|
|
68
68
|
align-items: flex-start;
|
|
69
69
|
flex-direction: column;
|