@astra-spec/ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +29 -0
- package/README.md +261 -0
- package/TOKENS.md +93 -0
- package/blocks.css +7 -0
- package/components.css +13 -0
- package/dist/blocks/analysis-tree.d.ts +13 -0
- package/dist/blocks/analysis-tree.d.ts.map +1 -0
- package/dist/blocks/analysis-tree.js +19 -0
- package/dist/blocks/analysis-tree.js.map +1 -0
- package/dist/blocks/decisions-list.d.ts +17 -0
- package/dist/blocks/decisions-list.d.ts.map +1 -0
- package/dist/blocks/decisions-list.js +56 -0
- package/dist/blocks/decisions-list.js.map +1 -0
- package/dist/blocks/findings-list.d.ts +9 -0
- package/dist/blocks/findings-list.d.ts.map +1 -0
- package/dist/blocks/findings-list.js +35 -0
- package/dist/blocks/findings-list.js.map +1 -0
- package/dist/blocks/index.d.ts +18 -0
- package/dist/blocks/index.d.ts.map +1 -0
- package/dist/blocks/index.js +10 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/blocks/inputs-list.d.ts +9 -0
- package/dist/blocks/inputs-list.d.ts.map +1 -0
- package/dist/blocks/inputs-list.js +32 -0
- package/dist/blocks/inputs-list.js.map +1 -0
- package/dist/blocks/outputs-list.d.ts +18 -0
- package/dist/blocks/outputs-list.d.ts.map +1 -0
- package/dist/blocks/outputs-list.js +47 -0
- package/dist/blocks/outputs-list.js.map +1 -0
- package/dist/blocks/papers-list.d.ts +16 -0
- package/dist/blocks/papers-list.d.ts.map +1 -0
- package/dist/blocks/papers-list.js +20 -0
- package/dist/blocks/papers-list.js.map +1 -0
- package/dist/blocks/prior-insights-list.d.ts +9 -0
- package/dist/blocks/prior-insights-list.d.ts.map +1 -0
- package/dist/blocks/prior-insights-list.js +29 -0
- package/dist/blocks/prior-insights-list.js.map +1 -0
- package/dist/blocks/section.d.ts +36 -0
- package/dist/blocks/section.d.ts.map +1 -0
- package/dist/blocks/section.js +30 -0
- package/dist/blocks/section.js.map +1 -0
- package/dist/components/artifact-preview.d.ts +71 -0
- package/dist/components/artifact-preview.d.ts.map +1 -0
- package/dist/components/artifact-preview.js +170 -0
- package/dist/components/artifact-preview.js.map +1 -0
- package/dist/components/decision-detail.d.ts +17 -0
- package/dist/components/decision-detail.d.ts.map +1 -0
- package/dist/components/decision-detail.js +21 -0
- package/dist/components/decision-detail.js.map +1 -0
- package/dist/components/detail-entry.d.ts +15 -0
- package/dist/components/detail-entry.d.ts.map +1 -0
- package/dist/components/detail-entry.js +14 -0
- package/dist/components/detail-entry.js.map +1 -0
- package/dist/components/finding-detail.d.ts +19 -0
- package/dist/components/finding-detail.d.ts.map +1 -0
- package/dist/components/finding-detail.js +39 -0
- package/dist/components/finding-detail.js.map +1 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +15 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/input-detail.d.ts +15 -0
- package/dist/components/input-detail.d.ts.map +1 -0
- package/dist/components/input-detail.js +21 -0
- package/dist/components/input-detail.js.map +1 -0
- package/dist/components/insight-detail.d.ts +25 -0
- package/dist/components/insight-detail.d.ts.map +1 -0
- package/dist/components/insight-detail.js +30 -0
- package/dist/components/insight-detail.js.map +1 -0
- package/dist/components/insight-trigger.d.ts +20 -0
- package/dist/components/insight-trigger.d.ts.map +1 -0
- package/dist/components/insight-trigger.js +32 -0
- package/dist/components/insight-trigger.js.map +1 -0
- package/dist/components/output-detail.d.ts +39 -0
- package/dist/components/output-detail.d.ts.map +1 -0
- package/dist/components/output-detail.js +124 -0
- package/dist/components/output-detail.js.map +1 -0
- package/dist/components/output-dialog.d.ts +18 -0
- package/dist/components/output-dialog.d.ts.map +1 -0
- package/dist/components/output-dialog.js +11 -0
- package/dist/components/output-dialog.js.map +1 -0
- package/dist/components/paper-detail.d.ts +34 -0
- package/dist/components/paper-detail.d.ts.map +1 -0
- package/dist/components/paper-detail.js +60 -0
- package/dist/components/paper-detail.js.map +1 -0
- package/dist/components/record-dialog.d.ts +33 -0
- package/dist/components/record-dialog.d.ts.map +1 -0
- package/dist/components/record-dialog.js +114 -0
- package/dist/components/record-dialog.js.map +1 -0
- package/dist/components/relation-items.d.ts +9 -0
- package/dist/components/relation-items.d.ts.map +1 -0
- package/dist/components/relation-items.js +20 -0
- package/dist/components/relation-items.js.map +1 -0
- package/dist/components/use-detail-stack.d.ts +31 -0
- package/dist/components/use-detail-stack.d.ts.map +1 -0
- package/dist/components/use-detail-stack.js +49 -0
- package/dist/components/use-detail-stack.js.map +1 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +6 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/labels.d.ts +61 -0
- package/dist/lib/labels.d.ts.map +1 -0
- package/dist/lib/labels.js +79 -0
- package/dist/lib/labels.js.map +1 -0
- package/dist/lib/slot.d.ts +11 -0
- package/dist/lib/slot.d.ts.map +1 -0
- package/dist/lib/slot.js +83 -0
- package/dist/lib/slot.js.map +1 -0
- package/dist/model/doi.d.ts +2 -0
- package/dist/model/doi.d.ts.map +1 -0
- package/dist/model/doi.js +5 -0
- package/dist/model/doi.js.map +1 -0
- package/dist/model/index.d.ts +10 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +7 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/locate-record.d.ts +8 -0
- package/dist/model/locate-record.d.ts.map +1 -0
- package/dist/model/locate-record.js +7 -0
- package/dist/model/locate-record.js.map +1 -0
- package/dist/model/papers.d.ts +38 -0
- package/dist/model/papers.d.ts.map +1 -0
- package/dist/model/papers.js +91 -0
- package/dist/model/papers.js.map +1 -0
- package/dist/model/records.d.ts +10 -0
- package/dist/model/records.d.ts.map +1 -0
- package/dist/model/records.js +32 -0
- package/dist/model/records.js.map +1 -0
- package/dist/model/relations.d.ts +45 -0
- package/dist/model/relations.d.ts.map +1 -0
- package/dist/model/relations.js +98 -0
- package/dist/model/relations.js.map +1 -0
- package/dist/primitives/badge.d.ts +11 -0
- package/dist/primitives/badge.d.ts.map +1 -0
- package/dist/primitives/badge.js +7 -0
- package/dist/primitives/badge.js.map +1 -0
- package/dist/primitives/button.d.ts +18 -0
- package/dist/primitives/button.d.ts.map +1 -0
- package/dist/primitives/button.js +12 -0
- package/dist/primitives/button.js.map +1 -0
- package/dist/primitives/detail-layout.d.ts +26 -0
- package/dist/primitives/detail-layout.d.ts.map +1 -0
- package/dist/primitives/detail-layout.js +21 -0
- package/dist/primitives/detail-layout.js.map +1 -0
- package/dist/primitives/dialog.d.ts +133 -0
- package/dist/primitives/dialog.d.ts.map +1 -0
- package/dist/primitives/dialog.js +266 -0
- package/dist/primitives/dialog.js.map +1 -0
- package/dist/primitives/index.d.ts +25 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +14 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/kind.d.ts +6 -0
- package/dist/primitives/kind.d.ts.map +1 -0
- package/dist/primitives/kind.js +14 -0
- package/dist/primitives/kind.js.map +1 -0
- package/dist/primitives/prose.d.ts +36 -0
- package/dist/primitives/prose.d.ts.map +1 -0
- package/dist/primitives/prose.js +57 -0
- package/dist/primitives/prose.js.map +1 -0
- package/dist/primitives/record-list.d.ts +31 -0
- package/dist/primitives/record-list.d.ts.map +1 -0
- package/dist/primitives/record-list.js +17 -0
- package/dist/primitives/record-list.js.map +1 -0
- package/dist/primitives/relation-list.d.ts +22 -0
- package/dist/primitives/relation-list.d.ts.map +1 -0
- package/dist/primitives/relation-list.js +13 -0
- package/dist/primitives/relation-list.js.map +1 -0
- package/dist/primitives/surface-header.d.ts +31 -0
- package/dist/primitives/surface-header.d.ts.map +1 -0
- package/dist/primitives/surface-header.js +13 -0
- package/dist/primitives/surface-header.js.map +1 -0
- package/dist/views/index.d.ts +4 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +3 -0
- package/dist/views/index.js.map +1 -0
- package/dist/views/inventory.d.ts +46 -0
- package/dist/views/inventory.d.ts.map +1 -0
- package/dist/views/inventory.js +101 -0
- package/dist/views/inventory.js.map +1 -0
- package/package.json +127 -0
- package/primitives.css +15 -0
- package/src/blocks/analysis-tree.tsx +109 -0
- package/src/blocks/decisions-list.tsx +113 -0
- package/src/blocks/findings-list.tsx +61 -0
- package/src/blocks/index.ts +23 -0
- package/src/blocks/inputs-list.tsx +51 -0
- package/src/blocks/outputs-list.tsx +143 -0
- package/src/blocks/papers-list.tsx +65 -0
- package/src/blocks/prior-insights-list.tsx +52 -0
- package/src/blocks/section.tsx +113 -0
- package/src/components/artifact-preview.tsx +314 -0
- package/src/components/decision-detail.tsx +93 -0
- package/src/components/detail-entry.ts +19 -0
- package/src/components/finding-detail.tsx +99 -0
- package/src/components/index.ts +44 -0
- package/src/components/input-detail.tsx +67 -0
- package/src/components/insight-detail.tsx +120 -0
- package/src/components/insight-trigger.tsx +102 -0
- package/src/components/output-detail.tsx +258 -0
- package/src/components/output-dialog.tsx +63 -0
- package/src/components/paper-detail.tsx +216 -0
- package/src/components/record-dialog.tsx +232 -0
- package/src/components/relation-items.ts +31 -0
- package/src/components/use-detail-stack.ts +78 -0
- package/src/lib/cn.ts +5 -0
- package/src/lib/labels.tsx +145 -0
- package/src/lib/slot.tsx +87 -0
- package/src/model/doi.ts +5 -0
- package/src/model/index.ts +32 -0
- package/src/model/locate-record.ts +13 -0
- package/src/model/papers.ts +146 -0
- package/src/model/records.ts +43 -0
- package/src/model/relations.ts +134 -0
- package/src/primitives/badge.tsx +32 -0
- package/src/primitives/button.tsx +58 -0
- package/src/primitives/detail-layout.tsx +84 -0
- package/src/primitives/dialog.tsx +555 -0
- package/src/primitives/index.ts +48 -0
- package/src/primitives/kind.ts +19 -0
- package/src/primitives/prose.tsx +74 -0
- package/src/primitives/record-list.tsx +103 -0
- package/src/primitives/relation-list.tsx +95 -0
- package/src/primitives/surface-header.tsx +87 -0
- package/src/views/index.ts +3 -0
- package/src/views/inventory.tsx +224 -0
- package/styles/base.css +49 -0
- package/styles/blocks/analysis-tree.css +64 -0
- package/styles/blocks/decisions-list.css +73 -0
- package/styles/blocks/outputs-list.css +349 -0
- package/styles/blocks/papers-list.css +98 -0
- package/styles/blocks/records.css +72 -0
- package/styles/components/artifact-preview.css +242 -0
- package/styles/components/decision-detail.css +159 -0
- package/styles/components/evidence.css +79 -0
- package/styles/components/finding-detail.css +63 -0
- package/styles/components/input-detail.css +95 -0
- package/styles/components/insight-detail.css +138 -0
- package/styles/components/insight-list.css +46 -0
- package/styles/components/insight-trigger.css +54 -0
- package/styles/components/output-detail.css +732 -0
- package/styles/components/paper-detail.css +249 -0
- package/styles/components/paper-doi.css +36 -0
- package/styles/primitives/badge.css +107 -0
- package/styles/primitives/button.css +116 -0
- package/styles/primitives/count-heading.css +27 -0
- package/styles/primitives/detail-layout.css +225 -0
- package/styles/primitives/dialog.css +634 -0
- package/styles/primitives/empty-state.css +10 -0
- package/styles/primitives/kind.css +41 -0
- package/styles/primitives/prose.css +15 -0
- package/styles/primitives/record-list.css +425 -0
- package/styles/primitives/relation-list.css +184 -0
- package/styles/primitives/surface-header.css +183 -0
- package/styles/tokens.css +119 -0
- package/styles/views/inventory.css +186 -0
- package/styles.css +2 -0
- package/views.css +3 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, } from 'react';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
import { useLabels } from '../lib/labels.js';
|
|
5
|
+
import { Slot } from '../lib/slot.js';
|
|
6
|
+
import { IconButton } from './button.js';
|
|
7
|
+
import { SurfaceHeader } from './surface-header.js';
|
|
8
|
+
const useIsomorphicLayoutEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;
|
|
9
|
+
const PresentationContext = createContext({});
|
|
10
|
+
/**
|
|
11
|
+
* Sets the default mode (modal or embedded) and back-trail text for every
|
|
12
|
+
* Dialog below it. Nested providers inherit what they do not set; explicit
|
|
13
|
+
* props on a Dialog still win.
|
|
14
|
+
*/
|
|
15
|
+
export function DialogProvider({ mode, backLabel, backText, children }) {
|
|
16
|
+
const parent = useContext(PresentationContext);
|
|
17
|
+
const value = useMemo(() => ({
|
|
18
|
+
mode: mode ?? parent.mode,
|
|
19
|
+
backLabel: backLabel ?? parent.backLabel,
|
|
20
|
+
backText: backText ?? parent.backText,
|
|
21
|
+
}), [mode, backLabel, backText, parent]);
|
|
22
|
+
return _jsx(PresentationContext.Provider, { value: value, children: children });
|
|
23
|
+
}
|
|
24
|
+
const DialogContext = createContext(null);
|
|
25
|
+
export function useDialog() {
|
|
26
|
+
const value = useContext(DialogContext);
|
|
27
|
+
if (!value)
|
|
28
|
+
throw new Error('Dialog parts must be rendered inside <Dialog>.');
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/** The enclosing Dialog, or null outside one. */
|
|
32
|
+
export function useOptionalDialog() {
|
|
33
|
+
return useContext(DialogContext);
|
|
34
|
+
}
|
|
35
|
+
export function Dialog({ open = true, onOpenChange, mode, kind, layout, backLabel, backText, children, }) {
|
|
36
|
+
const presentation = useContext(PresentationContext);
|
|
37
|
+
const labels = useLabels();
|
|
38
|
+
const titleId = useId();
|
|
39
|
+
const guards = useRef([]);
|
|
40
|
+
const nativeClose = useRef(null);
|
|
41
|
+
const closeRef = useRef(null);
|
|
42
|
+
const onOpenChangeRef = useRef(onOpenChange);
|
|
43
|
+
useEffect(() => { onOpenChangeRef.current = onOpenChange; });
|
|
44
|
+
const notifyOpenChange = useCallback((next) => { onOpenChangeRef.current?.(next); }, []);
|
|
45
|
+
// The native close steps restore focus to the opener and fire `close`,
|
|
46
|
+
// which relays the change; fall back to the callback when there is no
|
|
47
|
+
// open <dialog> (embedded mode, or already closed).
|
|
48
|
+
const requestClose = useCallback(() => {
|
|
49
|
+
if (!nativeClose.current?.())
|
|
50
|
+
notifyOpenChange(false);
|
|
51
|
+
}, [notifyOpenChange]);
|
|
52
|
+
const addGuard = useCallback((onDismiss) => {
|
|
53
|
+
const guard = { onDismiss };
|
|
54
|
+
const entry = () => guard.onDismiss?.();
|
|
55
|
+
guards.current = [...guards.current, entry];
|
|
56
|
+
return () => { guards.current = guards.current.filter((candidate) => candidate !== entry); };
|
|
57
|
+
}, []);
|
|
58
|
+
const isGuarded = useCallback(() => guards.current.length > 0, []);
|
|
59
|
+
// Decided when Escape arrives, not when a keydown listener saw it earlier:
|
|
60
|
+
// a guard released by that keydown would otherwise let the same Escape
|
|
61
|
+
// close the dialog too.
|
|
62
|
+
const requestDismiss = useCallback(() => {
|
|
63
|
+
const guard = guards.current.at(-1);
|
|
64
|
+
if (guard)
|
|
65
|
+
guard();
|
|
66
|
+
else
|
|
67
|
+
requestClose();
|
|
68
|
+
}, [requestClose]);
|
|
69
|
+
const registerNativeClose = useCallback((close) => { nativeClose.current = close; }, []);
|
|
70
|
+
const value = useMemo(() => ({
|
|
71
|
+
open,
|
|
72
|
+
mode: mode ?? presentation.mode ?? 'modal',
|
|
73
|
+
kind,
|
|
74
|
+
layout,
|
|
75
|
+
titleId,
|
|
76
|
+
backLabel: backLabel ?? presentation.backLabel ?? labels.backTo,
|
|
77
|
+
backText: backText ?? presentation.backText,
|
|
78
|
+
requestClose,
|
|
79
|
+
requestDismiss,
|
|
80
|
+
notifyOpenChange,
|
|
81
|
+
addGuard,
|
|
82
|
+
isGuarded,
|
|
83
|
+
registerNativeClose,
|
|
84
|
+
closeRef,
|
|
85
|
+
}), [open, mode, presentation, kind, layout, titleId, backLabel, backText, labels.backTo, requestClose, requestDismiss, notifyOpenChange, addGuard, isGuarded, registerNativeClose]);
|
|
86
|
+
return _jsx(DialogContext.Provider, { value: value, children: children });
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Registers a dismissal guard while `active`: backdrop clicks are ignored and
|
|
90
|
+
* Escape calls `onDismiss` (the inner layer exits) instead of closing the
|
|
91
|
+
* dialog. Inside a modal Dialog the inner layer must not listen for Escape
|
|
92
|
+
* itself; the `<dialog>`'s cancel event is the one signal that arrives after
|
|
93
|
+
* any host keydown handling. Safe to call outside a Dialog.
|
|
94
|
+
*/
|
|
95
|
+
export function useDialogDismissGuard(active, onDismiss) {
|
|
96
|
+
const context = useContext(DialogContext);
|
|
97
|
+
const addGuard = context?.addGuard;
|
|
98
|
+
const onDismissRef = useRef(onDismiss);
|
|
99
|
+
useEffect(() => { onDismissRef.current = onDismiss; });
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!active || !addGuard)
|
|
102
|
+
return undefined;
|
|
103
|
+
return addGuard(() => onDismissRef.current?.());
|
|
104
|
+
}, [active, addGuard]);
|
|
105
|
+
}
|
|
106
|
+
export const DialogContent = forwardRef(function DialogContent({ className, panelClassName, initialFocusRef, children, onMouseDown, onFocus, ...props }, ref) {
|
|
107
|
+
const { open, mode, kind, layout, titleId, requestClose, requestDismiss, notifyOpenChange, isGuarded, registerNativeClose, closeRef } = useDialog();
|
|
108
|
+
const dialogRef = useRef(null);
|
|
109
|
+
// The element that had focus when the dialog opened; focus returns to it on
|
|
110
|
+
// close (browsers do this for showModal() too, but not every environment).
|
|
111
|
+
const openerRef = useRef(null);
|
|
112
|
+
// Set while this component closes the <dialog> itself (host set `open`
|
|
113
|
+
// to false, or unmount), so the resulting `close` event is not reported
|
|
114
|
+
// back as a user dismissal. React StrictMode's simulated unmount would
|
|
115
|
+
// otherwise close every dialog right after it opened in development.
|
|
116
|
+
const closingSilently = useRef(false);
|
|
117
|
+
// The last element focused inside the dialog; when a render removes it
|
|
118
|
+
// (drill-down/back swaps the body), focus is kept inside the dialog.
|
|
119
|
+
const lastFocused = useRef(null);
|
|
120
|
+
const restoreFocus = useCallback(() => {
|
|
121
|
+
const opener = openerRef.current;
|
|
122
|
+
openerRef.current = null;
|
|
123
|
+
const active = document.activeElement;
|
|
124
|
+
if (opener?.isConnected && (!active || active === document.body || dialogRef.current?.contains(active)))
|
|
125
|
+
opener.focus();
|
|
126
|
+
}, []);
|
|
127
|
+
const setRefs = useCallback((node) => {
|
|
128
|
+
dialogRef.current = node;
|
|
129
|
+
if (typeof ref === 'function')
|
|
130
|
+
ref(node);
|
|
131
|
+
else if (ref)
|
|
132
|
+
ref.current = node;
|
|
133
|
+
}, [ref]);
|
|
134
|
+
// Let the root's requestClose run the native close steps.
|
|
135
|
+
useIsomorphicLayoutEffect(() => {
|
|
136
|
+
registerNativeClose(() => {
|
|
137
|
+
const dialog = dialogRef.current;
|
|
138
|
+
if (mode !== 'modal' || !dialog?.open)
|
|
139
|
+
return false;
|
|
140
|
+
dialog.close();
|
|
141
|
+
return true;
|
|
142
|
+
});
|
|
143
|
+
return () => { registerNativeClose(null); };
|
|
144
|
+
}, [mode, registerNativeClose]);
|
|
145
|
+
// Open/close the native dialog to match `open`.
|
|
146
|
+
useIsomorphicLayoutEffect(() => {
|
|
147
|
+
if (mode !== 'modal')
|
|
148
|
+
return;
|
|
149
|
+
const dialog = dialogRef.current;
|
|
150
|
+
if (!dialog)
|
|
151
|
+
return;
|
|
152
|
+
if (open && !dialog.open) {
|
|
153
|
+
openerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
154
|
+
dialog.showModal();
|
|
155
|
+
(initialFocusRef?.current ?? closeRef.current)?.focus();
|
|
156
|
+
}
|
|
157
|
+
else if (!open && dialog.open) {
|
|
158
|
+
closingSilently.current = true;
|
|
159
|
+
dialog.close();
|
|
160
|
+
restoreFocus();
|
|
161
|
+
}
|
|
162
|
+
}, [open, mode, initialFocusRef, closeRef, restoreFocus]);
|
|
163
|
+
// Closing on unmount keeps the browser's focus restoration: close()
|
|
164
|
+
// returns focus to the element that opened the dialog, removal does not.
|
|
165
|
+
useIsomorphicLayoutEffect(() => () => {
|
|
166
|
+
const dialog = dialogRef.current;
|
|
167
|
+
if (dialog?.open) {
|
|
168
|
+
closingSilently.current = true;
|
|
169
|
+
dialog.close();
|
|
170
|
+
}
|
|
171
|
+
restoreFocus();
|
|
172
|
+
}, [restoreFocus]);
|
|
173
|
+
// When the body swaps (drill-down/back) and the element that had focus was
|
|
174
|
+
// removed, keep focus inside the dialog rather than letting it fall to
|
|
175
|
+
// <body>. Focus that the user moved elsewhere (a host portal, a click on
|
|
176
|
+
// plain text) is left alone.
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
const dialog = dialogRef.current;
|
|
179
|
+
const last = lastFocused.current;
|
|
180
|
+
if (mode !== 'modal' || !dialog?.open || !last || last.isConnected)
|
|
181
|
+
return;
|
|
182
|
+
lastFocused.current = null;
|
|
183
|
+
closeRef.current?.focus();
|
|
184
|
+
});
|
|
185
|
+
const handleCancel = (event) => {
|
|
186
|
+
// Escape. Close (or let the guard handle it) explicitly rather than via
|
|
187
|
+
// the browser's default, which is deterministic across browsers
|
|
188
|
+
// (Chromium makes a repeated Escape non-cancelable) and test environments.
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
requestDismiss();
|
|
191
|
+
};
|
|
192
|
+
const handleClose = () => {
|
|
193
|
+
if (closingSilently.current) {
|
|
194
|
+
closingSilently.current = false;
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
restoreFocus();
|
|
198
|
+
if (open)
|
|
199
|
+
notifyOpenChange(false);
|
|
200
|
+
};
|
|
201
|
+
const handleFocus = (event) => {
|
|
202
|
+
onFocus?.(event);
|
|
203
|
+
lastFocused.current = event.target;
|
|
204
|
+
};
|
|
205
|
+
const handleMouseDown = (event) => {
|
|
206
|
+
onMouseDown?.(event);
|
|
207
|
+
if (event.defaultPrevented)
|
|
208
|
+
return;
|
|
209
|
+
if (event.target === event.currentTarget && event.button === 0 && !isGuarded())
|
|
210
|
+
requestClose();
|
|
211
|
+
};
|
|
212
|
+
const data = {
|
|
213
|
+
'data-slot': 'dialog',
|
|
214
|
+
'data-mode': mode,
|
|
215
|
+
...(kind ? { 'data-kind': kind } : {}),
|
|
216
|
+
...(layout ? { 'data-layout': layout } : {}),
|
|
217
|
+
};
|
|
218
|
+
const panel = (_jsx("section", { "data-slot": "dialog-panel", className: cn('astra-dialog__panel', panelClassName), ...(kind ? { 'data-kind': kind } : {}), "aria-labelledby": titleId, children: children }));
|
|
219
|
+
if (mode === 'embedded') {
|
|
220
|
+
if (!open)
|
|
221
|
+
return null;
|
|
222
|
+
return (
|
|
223
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions -- host handler passthrough only
|
|
224
|
+
_jsx("div", { ...data, ...props, ref: ref, className: cn('astra-dialog', className), onMouseDown: onMouseDown, onFocus: onFocus, children: panel }));
|
|
225
|
+
}
|
|
226
|
+
return (
|
|
227
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- backdrop click dismisses the modal
|
|
228
|
+
_jsx("dialog", { ...data, ...props, ref: setRefs, className: cn('astra-dialog', className), "aria-modal": "true", "aria-labelledby": titleId, onCancel: handleCancel, onClose: handleClose, onFocus: handleFocus, onMouseDown: handleMouseDown, children: panel }));
|
|
229
|
+
});
|
|
230
|
+
export function DialogHeader({ kindLabel, title, titleAs = 'h3', identifier, onBack, actions, closeLabel, showCloseButton = true, className, }) {
|
|
231
|
+
const { kind, titleId, backText } = useDialog();
|
|
232
|
+
return (_jsx(SurfaceHeader, { "data-slot": "dialog-header", className: cn('astra-dialog__header', className), classNames: { actions: 'astra-dialog__actions' }, kind: kind, density: "compact", leading: onBack ? _jsx(DialogBack, { onClick: onBack }) : undefined, eyebrow: (_jsxs("span", { "data-slot": "dialog-trail", className: "astra-dialog__trail", children: [onBack && backText ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "astra-dialog__crumb", children: backText }), _jsx("span", { className: "astra-dialog__trail-separator", "aria-hidden": "true", children: "\u25B8" })] })) : null, kindLabel != null ? _jsx("span", { "data-slot": "dialog-kind", className: "astra-dialog__kind", children: kindLabel }) : null] })), title: title, titleId: titleId, titleAs: titleAs, identifier: identifier, actions: (_jsxs(_Fragment, { children: [actions, showCloseButton ? _jsx(DialogClose, { label: closeLabel }) : null] })) }));
|
|
233
|
+
}
|
|
234
|
+
/** The dialog's close control; dismisses through the Dialog root. */
|
|
235
|
+
export function DialogClose({ label, className }) {
|
|
236
|
+
const { requestClose, closeRef } = useDialog();
|
|
237
|
+
const labels = useLabels();
|
|
238
|
+
return (_jsx(IconButton, { ref: closeRef, "data-slot": "dialog-close", className: className, label: label ?? labels.close, onClick: requestClose, title: labels.close, children: "\u00D7" }));
|
|
239
|
+
}
|
|
240
|
+
export function DialogBack({ onClick, className }) {
|
|
241
|
+
const { backLabel } = useDialog();
|
|
242
|
+
const labels = useLabels();
|
|
243
|
+
return (_jsx(IconButton, { "data-slot": "dialog-back", className: cn('astra-dialog__back', className), label: backLabel, onClick: onClick, title: labels.back, children: _jsx("span", { "aria-hidden": "true", children: "\u2190" }) }));
|
|
244
|
+
}
|
|
245
|
+
/** A text action for the dialog header (e.g. "Open ↗"); pass `asChild` to render a link. */
|
|
246
|
+
export const DialogAction = forwardRef(function DialogAction({ asChild = false, className, ...props }, ref) {
|
|
247
|
+
const Component = asChild ? Slot : 'button';
|
|
248
|
+
return (_jsx(Component, { "data-slot": "dialog-action", ...props, ...(asChild ? {} : { type: 'button' }), ref: ref, className: cn('astra-dialog__action', className) }));
|
|
249
|
+
});
|
|
250
|
+
export const DialogBody = forwardRef(function DialogBody({ className, ...props }, ref) {
|
|
251
|
+
return _jsx("div", { "data-slot": "dialog-body", ...props, ref: ref, className: cn('astra-dialog__body', className) });
|
|
252
|
+
});
|
|
253
|
+
/**
|
|
254
|
+
* Dialog + DialogContent + DialogHeader + DialogBody with the record-detail
|
|
255
|
+
* chrome. Every kind dialog and the inventory explorer build on this; hosts
|
|
256
|
+
* that need a different header compose the parts directly. HTML attributes
|
|
257
|
+
* land on the dialog root.
|
|
258
|
+
*/
|
|
259
|
+
export function DetailDialog({ open, mode, kind, layout, backLabel, backText, kindLabel, title, titleAs, identifier, onBack, actions, closeLabel, onClose, panelClassName, children, ...content }) {
|
|
260
|
+
const onCloseRef = useRef(onClose);
|
|
261
|
+
useEffect(() => { onCloseRef.current = onClose; });
|
|
262
|
+
const onOpenChange = useCallback((next) => { if (!next)
|
|
263
|
+
onCloseRef.current(); }, []);
|
|
264
|
+
return (_jsx(Dialog, { open: open, mode: mode, kind: kind, layout: layout, backLabel: backLabel, backText: backText, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { ...content, panelClassName: panelClassName, children: [_jsx(DialogHeader, { kindLabel: kindLabel, title: title, titleAs: titleAs, identifier: identifier, onBack: onBack, actions: actions, closeLabel: closeLabel }), _jsx(DialogBody, { children: children })] }) }));
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/primitives/dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,KAAK,EACL,eAAe,EACf,OAAO,EACP,MAAM,GAOP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAA4B,MAAM,qBAAqB,CAAC;AAK9E,MAAM,yBAAyB,GAAG,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC;AAYhG,MAAM,mBAAmB,GAAG,aAAa,CAAqB,EAAE,CAAC,CAAC;AAMlE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAuB;IACzF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,CAAC,EAC3B,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,SAAS,EACT,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,UAAU,EACV,MAAM,EACN,OAAO,EACP,UAAU,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,GAAG,OAAO,EACQ;IAClB,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,SAAS,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,IAAa,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;QAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9F,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,YAC9H,MAAC,aAAa,OAAK,OAAO,EAAE,cAAc,EAAE,cAAc,aACxD,KAAC,YAAY,IACX,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,GACtB,EACF,KAAC,UAAU,cAAE,QAAQ,GAAc,IACrB,GACT,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Presentation primitives: generic UI with no ASTRA model beyond record kinds. */
|
|
2
|
+
export { cn } from '../lib/cn.js';
|
|
3
|
+
export { Slot } from '../lib/slot.js';
|
|
4
|
+
export type { SlotProps } from '../lib/slot.js';
|
|
5
|
+
export { LabelsProvider, defaultLabels, mergeLabels, useLabels } from '../lib/labels.js';
|
|
6
|
+
export type { AstraLabelOverrides, AstraLabels, LabelsProviderProps } from '../lib/labels.js';
|
|
7
|
+
export { surfaceGlyph } from './kind.js';
|
|
8
|
+
export type { SurfaceKind } from './kind.js';
|
|
9
|
+
export { Button, IconButton } from './button.js';
|
|
10
|
+
export type { ButtonProps, ButtonSize, ButtonTone, ButtonVariant, IconButtonProps } from './button.js';
|
|
11
|
+
export { Badge } from './badge.js';
|
|
12
|
+
export type { BadgeProps, BadgeStatus, BadgeTone } from './badge.js';
|
|
13
|
+
export { SurfaceHeader } from './surface-header.js';
|
|
14
|
+
export type { SurfaceHeaderDensity, SurfaceHeaderProps, SurfaceHeadingLevel } from './surface-header.js';
|
|
15
|
+
export { DetailDialog, Dialog, DialogAction, DialogBack, DialogBody, DialogClose, DialogContent, DialogHeader, DialogProvider, useDialog, useDialogDismissGuard, } from './dialog.js';
|
|
16
|
+
export type { DetailDialogProps, DialogActionProps, DialogBackProps, DialogCloseProps, DialogContentProps, DialogContextValue, DialogHeaderProps, DialogLayout, DialogMode, DialogProps, DialogProviderProps, } from './dialog.js';
|
|
17
|
+
export { EmptyState, RecordIdentity, RecordList } from './record-list.js';
|
|
18
|
+
export type { RecordIdentityProps, RecordListColumn, RecordListProps, RecordListRow } from './record-list.js';
|
|
19
|
+
export { RelationList } from './relation-list.js';
|
|
20
|
+
export type { RelationItem, RelationListProps } from './relation-list.js';
|
|
21
|
+
export { CountHeading, DetailLayout, DetailMain, DetailRail, DetailSection } from './detail-layout.js';
|
|
22
|
+
export type { CountHeadingProps, DetailLayoutMode, DetailLayoutProps, DetailRailProps, DetailSectionProps } from './detail-layout.js';
|
|
23
|
+
export { Prose, parseProse, renderProse } from './prose.js';
|
|
24
|
+
export type { ProseContext, ProseField, ProseProps, ProseToken, TextRenderer } from './prose.js';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1E,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvG,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtI,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { LabelsProvider, defaultLabels, mergeLabels, useLabels } from '../lib/labels.js';
|
|
5
|
+
export { surfaceGlyph } from './kind.js';
|
|
6
|
+
export { Button, IconButton } from './button.js';
|
|
7
|
+
export { Badge } from './badge.js';
|
|
8
|
+
export { SurfaceHeader } from './surface-header.js';
|
|
9
|
+
export { DetailDialog, Dialog, DialogAction, DialogBack, DialogBody, DialogClose, DialogContent, DialogHeader, DialogProvider, useDialog, useDialogDismissGuard, } from './dialog.js';
|
|
10
|
+
export { EmptyState, RecordIdentity, RecordList } from './record-list.js';
|
|
11
|
+
export { RelationList } from './relation-list.js';
|
|
12
|
+
export { CountHeading, DetailLayout, DetailMain, DetailRail, DetailSection } from './detail-layout.js';
|
|
13
|
+
export { Prose, parseProse, renderProse } from './prose.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EACL,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,SAAS,EACT,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEvG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ResolvedRecord } from '@astra-spec/sdk';
|
|
2
|
+
/** Record kinds plus the two non-record surfaces the UI colours. */
|
|
3
|
+
export type SurfaceKind = ResolvedRecord['kind'] | 'analysis' | 'paper';
|
|
4
|
+
/** The glyph that identifies a kind in lists, relations, and headers. */
|
|
5
|
+
export declare function surfaceGlyph(kind: SurfaceKind): string;
|
|
6
|
+
//# sourceMappingURL=kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../../src/primitives/kind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,oEAAoE;AACpE,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,UAAU,GAAG,OAAO,CAAC;AAYxE,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const SURFACE_GLYPHS = {
|
|
2
|
+
analysis: '◐',
|
|
3
|
+
input: '↳',
|
|
4
|
+
decision: '◇',
|
|
5
|
+
output: '◆',
|
|
6
|
+
finding: '●',
|
|
7
|
+
prior_insight: '◈',
|
|
8
|
+
paper: '▧',
|
|
9
|
+
};
|
|
10
|
+
/** The glyph that identifies a kind in lists, relations, and headers. */
|
|
11
|
+
export function surfaceGlyph(kind) {
|
|
12
|
+
return SURFACE_GLYPHS[kind];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=kind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind.js","sourceRoot":"","sources":["../../src/primitives/kind.ts"],"names":[],"mappings":"AAKA,MAAM,cAAc,GAAgC;IAClD,QAAQ,EAAE,GAAG;IACb,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,GAAG;IAClB,KAAK,EAAE,GAAG;CACX,CAAC;AAEF,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAAC,IAAiB;IAC5C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type ProseField = 'claim' | 'rationale' | 'description' | 'notes' | 'quote';
|
|
3
|
+
export interface ProseContext {
|
|
4
|
+
/** Which authored field is being rendered, when known. */
|
|
5
|
+
field?: ProseField | undefined;
|
|
6
|
+
}
|
|
7
|
+
/** Host-owned rendering for authored prose (Markdown, citations, ...); replaces the built-in rendering. */
|
|
8
|
+
export type TextRenderer = (text: string, context: ProseContext) => ReactNode;
|
|
9
|
+
export type ProseToken = {
|
|
10
|
+
type: 'text';
|
|
11
|
+
value: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'inlineCode';
|
|
14
|
+
value: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'inlineMath';
|
|
17
|
+
value: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'math';
|
|
20
|
+
value: string;
|
|
21
|
+
};
|
|
22
|
+
/** Splits authored prose into text, inline `code`, `$inline$` and `$$display$$` math. */
|
|
23
|
+
export declare function parseProse(text: string): ProseToken[];
|
|
24
|
+
/**
|
|
25
|
+
* The built-in rendering: inline `code`, and `$inline$` / `$$display$$` math
|
|
26
|
+
* typeset with KaTeX (load `katex/dist/katex.css`; the stylesheet bundles
|
|
27
|
+
* import it). Text without those markers is returned as is.
|
|
28
|
+
*/
|
|
29
|
+
export declare function renderProse(text: string): ReactNode;
|
|
30
|
+
export interface ProseProps extends ProseContext {
|
|
31
|
+
text?: string | undefined;
|
|
32
|
+
renderText?: TextRenderer | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** Authored prose: the host's `renderText` when given, otherwise `renderProse`. */
|
|
35
|
+
export declare function Prose({ text, field, renderText }: ProseProps): import("react").JSX.Element | null;
|
|
36
|
+
//# sourceMappingURL=prose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prose.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Fragment } from 'react';
|
|
3
|
+
import { renderToString } from 'katex';
|
|
4
|
+
/** Balanced tokens: display math first, then `code`, then inline math. */
|
|
5
|
+
const PROSE_TOKEN = /(\$\$[\s\S]+?\$\$|`[^`\n]+`|\$[^$\n]+\$)/g;
|
|
6
|
+
/** Splits authored prose into text, inline `code`, `$inline$` and `$$display$$` math. */
|
|
7
|
+
export function parseProse(text) {
|
|
8
|
+
const nodes = [];
|
|
9
|
+
let last = 0;
|
|
10
|
+
for (const match of text.matchAll(PROSE_TOKEN)) {
|
|
11
|
+
const index = match.index;
|
|
12
|
+
if (index > last)
|
|
13
|
+
nodes.push({ type: 'text', value: text.slice(last, index) });
|
|
14
|
+
const token = match[0];
|
|
15
|
+
if (token.startsWith('$$'))
|
|
16
|
+
nodes.push({ type: 'math', value: token.slice(2, -2).trim() });
|
|
17
|
+
else if (token.startsWith('`'))
|
|
18
|
+
nodes.push({ type: 'inlineCode', value: token.slice(1, -1) });
|
|
19
|
+
else
|
|
20
|
+
nodes.push({ type: 'inlineMath', value: token.slice(1, -1) });
|
|
21
|
+
last = index + token.length;
|
|
22
|
+
}
|
|
23
|
+
if (last < text.length)
|
|
24
|
+
nodes.push({ type: 'text', value: text.slice(last) });
|
|
25
|
+
return nodes;
|
|
26
|
+
}
|
|
27
|
+
function renderMath(value, displayMode) {
|
|
28
|
+
return renderToString(value, { displayMode, output: 'htmlAndMathml', strict: 'ignore', throwOnError: false });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The built-in rendering: inline `code`, and `$inline$` / `$$display$$` math
|
|
32
|
+
* typeset with KaTeX (load `katex/dist/katex.css`; the stylesheet bundles
|
|
33
|
+
* import it). Text without those markers is returned as is.
|
|
34
|
+
*/
|
|
35
|
+
export function renderProse(text) {
|
|
36
|
+
if (!/[`$]/.test(text))
|
|
37
|
+
return text;
|
|
38
|
+
return parseProse(text).map((node, index) => {
|
|
39
|
+
switch (node.type) {
|
|
40
|
+
case 'inlineCode':
|
|
41
|
+
return _jsx("code", { children: node.value }, index);
|
|
42
|
+
case 'inlineMath':
|
|
43
|
+
return _jsx("span", { className: "astra-prose__inline-math", dangerouslySetInnerHTML: { __html: renderMath(node.value, false) } }, index);
|
|
44
|
+
case 'math':
|
|
45
|
+
return _jsx("div", { className: "astra-prose__display-math", dangerouslySetInnerHTML: { __html: renderMath(node.value, true) } }, index);
|
|
46
|
+
default:
|
|
47
|
+
return _jsx(Fragment, { children: node.value }, index);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Authored prose: the host's `renderText` when given, otherwise `renderProse`. */
|
|
52
|
+
export function Prose({ text, field, renderText }) {
|
|
53
|
+
if (!text)
|
|
54
|
+
return null;
|
|
55
|
+
return _jsx(_Fragment, { children: renderText ? renderText(text, { field }) : renderProse(text) });
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=prose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prose.js","sourceRoot":"","sources":["../../src/primitives/prose.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAkBvC,0EAA0E;AAC1E,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAEhE,yFAAyF;AACzF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,IAAI,KAAK,GAAG,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC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,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC1C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,YAAY;gBACf,OAAO,yBAAmB,IAAI,CAAC,KAAK,IAAlB,KAAK,CAAqB,CAAC;YAC/C,KAAK,YAAY;gBACf,OAAO,eAAkB,SAAS,EAAC,0BAA0B,EAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,IAA9G,KAAK,CAA6G,CAAC;YACvI,KAAK,MAAM;gBACT,OAAO,cAAiB,SAAS,EAAC,2BAA2B,EAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,IAA9G,KAAK,CAA6G,CAAC;YACtI;gBACE,OAAO,KAAC,QAAQ,cAAc,IAAI,CAAC,KAAK,IAAlB,KAAK,CAAyB,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAOD,mFAAmF;AACnF,MAAM,UAAU,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAc;IAC3D,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,4BAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAI,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type SurfaceKind } from './kind.js';
|
|
3
|
+
export interface RecordListColumn {
|
|
4
|
+
label?: string | undefined;
|
|
5
|
+
className?: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface RecordListRow {
|
|
8
|
+
key: string;
|
|
9
|
+
accessibleLabel: string;
|
|
10
|
+
cells: ReactNode[];
|
|
11
|
+
onOpen: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface RecordListProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
/** Accessible name of the list (announced as a group). */
|
|
15
|
+
label: string;
|
|
16
|
+
columns: RecordListColumn[];
|
|
17
|
+
/** CSS grid template for the row columns. */
|
|
18
|
+
columnTemplate: string;
|
|
19
|
+
rows: RecordListRow[];
|
|
20
|
+
}
|
|
21
|
+
/** A column-aligned list of clickable record rows. */
|
|
22
|
+
export declare const RecordList: import("react").ForwardRefExoticComponent<RecordListProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
|
+
export interface RecordIdentityProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'title'> {
|
|
24
|
+
kind: SurfaceKind;
|
|
25
|
+
title: ReactNode;
|
|
26
|
+
subtitle?: ReactNode | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Glyph, title, and optional subtitle for a record row. */
|
|
29
|
+
export declare const RecordIdentity: import("react").ForwardRefExoticComponent<RecordIdentityProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
30
|
+
export declare const EmptyState: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
31
|
+
//# sourceMappingURL=record-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-list.d.ts","sourceRoot":"","sources":["../../src/primitives/record-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5F,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACrE,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB;AAED,sDAAsD;AACtD,eAAO,MAAM,UAAU,4GA2CrB,CAAC;AAEH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACzF,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC;AAED,4DAA4D;AAC5D,eAAO,MAAM,cAAc,iHAkBzB,CAAC;AAEH,eAAO,MAAM,UAAU,uIAItB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
import { surfaceGlyph } from './kind.js';
|
|
5
|
+
/** A column-aligned list of clickable record rows. */
|
|
6
|
+
export const RecordList = forwardRef(function RecordList({ label, columns, columnTemplate, rows, className, style, ...props }, ref) {
|
|
7
|
+
const gridStyle = { ...style, '--astra-record-columns': columnTemplate };
|
|
8
|
+
return (_jsxs("div", { "data-slot": "record-list", ...props, ref: ref, className: cn('astra-record-list', className), role: "group", "aria-label": label, style: gridStyle, children: [_jsx("div", { className: "astra-record-list__head", "aria-hidden": "true", children: columns.map((column, index) => (_jsx("span", { className: column.className, children: column.label }, `${column.label ?? 'blank'}-${index}`))) }), _jsx("div", { className: "astra-record-list__body", children: rows.map((row) => (_jsx("button", { type: "button", "aria-label": row.accessibleLabel, onClick: row.onOpen, children: row.cells.map((cell, index) => (_jsx("span", { className: columns[index]?.className, children: cell }, index))) }, row.key))) })] }));
|
|
9
|
+
});
|
|
10
|
+
/** Glyph, title, and optional subtitle for a record row. */
|
|
11
|
+
export const RecordIdentity = forwardRef(function RecordIdentity({ kind, title, subtitle, className, ...props }, ref) {
|
|
12
|
+
return (_jsxs("span", { "data-slot": "record-identity", ...props, ref: ref, className: cn('astra-record-list__name', className), children: [_jsx("span", { className: "astra-record-list__glyph", "data-kind": kind, "aria-hidden": "true", children: surfaceGlyph(kind) }), _jsxs("span", { children: [_jsx("strong", { children: title }), subtitle != null ? _jsx("small", { children: subtitle }) : null] })] }));
|
|
13
|
+
});
|
|
14
|
+
export const EmptyState = forwardRef(function EmptyState({ className, ...props }, ref) {
|
|
15
|
+
return _jsx("p", { "data-slot": "empty-state", ...props, ref: ref, className: cn('astra-empty-state', className) });
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=record-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-list.js","sourceRoot":"","sources":["../../src/primitives/record-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2D,MAAM,OAAO,CAAC;AAC5F,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,YAAY,EAAoB,MAAM,WAAW,CAAC;AAuB3D,sDAAsD;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAkC,SAAS,UAAU,CAAC,EACxF,KAAK,EACL,OAAO,EACP,cAAc,EACd,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,GAAG;IACJ,MAAM,SAAS,GAAG,EAAE,GAAG,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAmB,CAAC;IAC1F,OAAO,CACL,4BACY,a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MAAM,YAC3E,YAAY,CAAC,IAAI,CAAC,GACd,EACP,2BACE,2BAAS,KAAK,GAAU,EACvB,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,0BAAQ,QAAQ,GAAS,CAAC,CAAC,CAAC,IAAI,IAC/C,IACF,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG;IAC9C,OAAO,yBAAa,aAAa,KAAK,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,mBAAmB,EAAE,SAAS,CAAC,GAAI,CAAC;AAC3G,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type SurfaceKind } from './kind.js';
|
|
3
|
+
export interface RelationItem {
|
|
4
|
+
key: string;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
identifier?: ReactNode | undefined;
|
|
7
|
+
detail?: ReactNode | undefined;
|
|
8
|
+
kind?: SurfaceKind | undefined;
|
|
9
|
+
className?: string | undefined;
|
|
10
|
+
accessibleLabel?: string | undefined;
|
|
11
|
+
onOpen?: (() => void) | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface RelationListProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
14
|
+
title: ReactNode;
|
|
15
|
+
items: RelationItem[];
|
|
16
|
+
empty: ReactNode;
|
|
17
|
+
headerAction?: ReactNode | undefined;
|
|
18
|
+
description?: ReactNode | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** A titled, counted list of related records; items with `onOpen` become navigation triggers. */
|
|
21
|
+
export declare const RelationList: import("react").ForwardRefExoticComponent<RelationListProps & import("react").RefAttributes<HTMLElement>>;
|
|
22
|
+
//# sourceMappingURL=relation-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-list.d.ts","sourceRoot":"","sources":["../../src/primitives/relation-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxE,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IACnF,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACrC;AAqBD,iGAAiG;AACjG,eAAO,MAAM,YAAY,2GAkDvB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { cn } from '../lib/cn.js';
|
|
4
|
+
import { CountHeading } from './detail-layout.js';
|
|
5
|
+
import { surfaceGlyph } from './kind.js';
|
|
6
|
+
function RelationItemContent({ item }) {
|
|
7
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "astra-relation-item__glyph", ...(item.kind ? {} : { 'data-empty': '' }), "aria-hidden": "true", children: item.kind ? surfaceGlyph(item.kind) : '' }), _jsxs("span", { className: "astra-relation-item__copy", children: [_jsx("span", { className: "astra-relation-item__label", children: item.label }), item.identifier != null ? _jsx("code", { children: item.identifier }) : null] }), item.detail != null ? _jsx("small", { children: item.detail }) : null] }));
|
|
8
|
+
}
|
|
9
|
+
/** A titled, counted list of related records; items with `onOpen` become navigation triggers. */
|
|
10
|
+
export const RelationList = forwardRef(function RelationList({ title, items, empty, headerAction, description, className, ...props }, ref) {
|
|
11
|
+
return (_jsxs("section", { "data-slot": "relation-list", ...props, ref: ref, className: cn('astra-relation-list', className), children: [headerAction ? (_jsxs("div", { className: "astra-relation-list__header", children: [_jsx(CountHeading, { title: title, count: items.length }), headerAction] })) : (_jsx(CountHeading, { title: title, count: items.length })), description ? (_jsx("p", { className: "astra-relation-list__description", children: description })) : null, items.length ? (_jsx("ul", { children: items.map((item) => (_jsx("li", { "data-kind": item.kind, ...(item.onOpen ? { 'data-interactive': '' } : {}), className: item.className, children: item.onOpen ? (_jsxs("button", { type: "button", className: "astra-relation-list__trigger", "aria-label": item.accessibleLabel, onClick: item.onOpen, children: [_jsx(RelationItemContent, { item: item }), _jsx("span", { "aria-hidden": "true", children: "\u2192" })] })) : (_jsx(RelationItemContent, { item: item })) }, item.key))) })) : empty != null ? _jsx("p", { children: empty }) : null] }));
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=relation-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-list.js","sourceRoot":"","sources":["../../src/primitives/relation-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD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