@efolusi/meridian 1.5.0
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 +12 -0
- package/ai/AgentRun.d.ts +20 -0
- package/ai/AgentRun.js +100 -0
- package/ai/ChatMessage.d.ts +19 -0
- package/ai/ChatMessage.js +81 -0
- package/ai/Citation.d.ts +23 -0
- package/ai/Citation.js +146 -0
- package/ai/Confirmation.d.ts +26 -0
- package/ai/Confirmation.js +84 -0
- package/ai/Conversation.d.ts +15 -0
- package/ai/Conversation.js +81 -0
- package/ai/DocumentCard.d.ts +17 -0
- package/ai/DocumentCard.js +101 -0
- package/ai/FeedbackBar.d.ts +14 -0
- package/ai/FeedbackBar.js +84 -0
- package/ai/GeneratedImage.d.ts +22 -0
- package/ai/GeneratedImage.js +100 -0
- package/ai/ModelSelector.d.ts +21 -0
- package/ai/ModelSelector.js +112 -0
- package/ai/Player.d.ts +18 -0
- package/ai/Player.js +201 -0
- package/ai/PromptComposer.d.ts +28 -0
- package/ai/PromptComposer.js +111 -0
- package/ai/PromptSteps.d.ts +18 -0
- package/ai/PromptSteps.js +167 -0
- package/ai/Reasoning.d.ts +17 -0
- package/ai/Reasoning.js +57 -0
- package/ai/RichComposer.d.ts +25 -0
- package/ai/RichComposer.js +247 -0
- package/ai/Sandbox.d.ts +20 -0
- package/ai/Sandbox.js +96 -0
- package/ai/SelectionQuote.d.ts +15 -0
- package/ai/SelectionQuote.js +123 -0
- package/ai/SourceCard.d.ts +17 -0
- package/ai/SourceCard.js +57 -0
- package/ai/Suggestions.d.ts +10 -0
- package/ai/Suggestions.js +38 -0
- package/ai/Task.d.ts +15 -0
- package/ai/Task.js +49 -0
- package/ai/Todo.d.ts +13 -0
- package/ai/Todo.js +87 -0
- package/ai/ToolCall.d.ts +30 -0
- package/ai/ToolCall.js +147 -0
- package/ai/Transcript.d.ts +27 -0
- package/ai/Transcript.js +96 -0
- package/ai/UsageMeter.d.ts +21 -0
- package/ai/UsageMeter.js +81 -0
- package/ai/WebPreview.d.ts +19 -0
- package/ai/WebPreview.js +179 -0
- package/assets/fonts/BricolageGrotesque-Variable.ttf +0 -0
- package/assets/fonts/Figtree-Italic-Variable.ttf +0 -0
- package/assets/fonts/Figtree-Variable.ttf +0 -0
- package/assets/fonts/JetBrainsMono-Italic-Variable.ttf +0 -0
- package/assets/fonts/JetBrainsMono-Variable.ttf +0 -0
- package/assets/fonts/OFL-BricolageGrotesque.txt +93 -0
- package/assets/fonts/OFL-Figtree.txt +93 -0
- package/assets/fonts/OFL-JetBrainsMono.txt +93 -0
- package/code/CodeBlock.d.ts +17 -0
- package/code/CodeBlock.js +99 -0
- package/code/Console.d.ts +19 -0
- package/code/Console.js +124 -0
- package/code/CopyField.d.ts +10 -0
- package/code/CopyField.js +54 -0
- package/code/Diff.d.ts +26 -0
- package/code/Diff.js +358 -0
- package/code/EnvList.d.ts +14 -0
- package/code/EnvList.js +89 -0
- package/code/Exception.d.ts +25 -0
- package/code/Exception.js +90 -0
- package/code/Terminal.d.ts +20 -0
- package/code/Terminal.js +58 -0
- package/data/BarChart.d.ts +14 -0
- package/data/BarChart.js +44 -0
- package/data/DonutChart.d.ts +17 -0
- package/data/DonutChart.js +114 -0
- package/data/EmptyState.d.ts +13 -0
- package/data/EmptyState.js +39 -0
- package/data/KeyValueList.d.ts +14 -0
- package/data/KeyValueList.js +34 -0
- package/data/LineChart.d.ts +15 -0
- package/data/LineChart.js +85 -0
- package/data/Skeleton.d.ts +11 -0
- package/data/Skeleton.js +49 -0
- package/data/Sparkline.d.ts +14 -0
- package/data/Sparkline.js +42 -0
- package/data/Stat.d.ts +14 -0
- package/data/Stat.js +40 -0
- package/data/StatusDot.d.ts +10 -0
- package/data/StatusDot.js +34 -0
- package/data/Table.d.ts +53 -0
- package/data/Table.js +174 -0
- package/dates/Calendar.d.ts +8 -0
- package/dates/Calendar.js +143 -0
- package/dates/DatePicker.d.ts +12 -0
- package/dates/DatePicker.js +118 -0
- package/display/Accordion.d.ts +15 -0
- package/display/Accordion.js +52 -0
- package/display/AspectRatio.d.ts +8 -0
- package/display/AspectRatio.js +24 -0
- package/display/Avatar.d.ts +17 -0
- package/display/Avatar.js +52 -0
- package/display/Badge.d.ts +10 -0
- package/display/Badge.js +34 -0
- package/display/Card.d.ts +17 -0
- package/display/Card.js +51 -0
- package/display/Carousel.d.ts +16 -0
- package/display/Carousel.js +97 -0
- package/display/Collapsible.d.ts +12 -0
- package/display/Collapsible.js +46 -0
- package/display/Divider.d.ts +9 -0
- package/display/Divider.js +33 -0
- package/display/Kbd.d.ts +7 -0
- package/display/Kbd.js +18 -0
- package/display/Link.d.ts +12 -0
- package/display/Link.js +41 -0
- package/display/ListItem.d.ts +19 -0
- package/display/ListItem.js +61 -0
- package/display/Resizable.d.ts +16 -0
- package/display/Resizable.js +90 -0
- package/display/ScrollArea.d.ts +8 -0
- package/display/ScrollArea.js +28 -0
- package/display/Tag.d.ts +9 -0
- package/display/Tag.js +41 -0
- package/display/Toolbar.d.ts +22 -0
- package/display/Toolbar.js +55 -0
- package/display/TreeList.d.ts +20 -0
- package/display/TreeList.js +101 -0
- package/feedback/Alert.d.ts +14 -0
- package/feedback/Alert.js +56 -0
- package/feedback/Banner.d.ts +15 -0
- package/feedback/Banner.js +49 -0
- package/feedback/ConfirmDialog.d.ts +18 -0
- package/feedback/ConfirmDialog.js +49 -0
- package/feedback/Dialog.d.ts +13 -0
- package/feedback/Dialog.js +107 -0
- package/feedback/Loader.d.ts +12 -0
- package/feedback/Loader.js +41 -0
- package/feedback/Progress.d.ts +15 -0
- package/feedback/Progress.js +48 -0
- package/feedback/Spinner.d.ts +9 -0
- package/feedback/Spinner.js +38 -0
- package/feedback/Toast.d.ts +70 -0
- package/feedback/Toast.js +216 -0
- package/feedback/Tooltip.d.ts +12 -0
- package/feedback/Tooltip.js +86 -0
- package/files/FileDrop.d.ts +15 -0
- package/files/FileDrop.js +75 -0
- package/files/FileTile.d.ts +19 -0
- package/files/FileTile.js +96 -0
- package/files/FileTypeIcon.d.ts +11 -0
- package/files/FileTypeIcon.js +121 -0
- package/finance/PaymentCard.d.ts +17 -0
- package/finance/PaymentCard.js +109 -0
- package/forms/Button.d.ts +15 -0
- package/forms/Button.js +82 -0
- package/forms/ButtonGroup.d.ts +5 -0
- package/forms/ButtonGroup.js +22 -0
- package/forms/ButtonTile.d.ts +21 -0
- package/forms/ButtonTile.js +69 -0
- package/forms/Checkbox.d.ts +6 -0
- package/forms/Checkbox.js +52 -0
- package/forms/Combobox.d.ts +17 -0
- package/forms/Combobox.js +162 -0
- package/forms/DigitEntry.d.ts +15 -0
- package/forms/DigitEntry.js +88 -0
- package/forms/FormField.d.ts +39 -0
- package/forms/FormField.js +127 -0
- package/forms/IconButton.d.ts +11 -0
- package/forms/IconButton.js +41 -0
- package/forms/Input.d.ts +14 -0
- package/forms/Input.js +75 -0
- package/forms/InputGroup.d.ts +15 -0
- package/forms/InputGroup.js +59 -0
- package/forms/Label.d.ts +11 -0
- package/forms/Label.js +29 -0
- package/forms/Radio.d.ts +6 -0
- package/forms/Radio.js +46 -0
- package/forms/Select.d.ts +10 -0
- package/forms/Select.js +68 -0
- package/forms/Slider.d.ts +18 -0
- package/forms/Slider.js +75 -0
- package/forms/Switch.d.ts +6 -0
- package/forms/Switch.js +46 -0
- package/forms/Textarea.d.ts +8 -0
- package/forms/Textarea.js +58 -0
- package/forms/Toggle.d.ts +26 -0
- package/forms/Toggle.js +85 -0
- package/icons/Icon.d.ts +13 -0
- package/icons/Icon.js +54 -0
- package/index.d.ts +106 -0
- package/index.js +106 -0
- package/navigation/Breadcrumbs.d.ts +12 -0
- package/navigation/Breadcrumbs.js +41 -0
- package/navigation/Menubar.d.ts +10 -0
- package/navigation/Menubar.js +173 -0
- package/navigation/PageControl.d.ts +11 -0
- package/navigation/PageControl.js +36 -0
- package/navigation/Pagination.d.ts +9 -0
- package/navigation/Pagination.js +68 -0
- package/navigation/SegmentedControl.d.ts +17 -0
- package/navigation/SegmentedControl.js +42 -0
- package/navigation/SideNav.d.ts +18 -0
- package/navigation/SideNav.js +87 -0
- package/navigation/Steps.d.ts +15 -0
- package/navigation/Steps.js +61 -0
- package/navigation/Tabs.d.ts +17 -0
- package/navigation/Tabs.js +76 -0
- package/navigation/TopNav.d.ts +10 -0
- package/navigation/TopNav.js +26 -0
- package/overlay/CommandPalette.d.ts +21 -0
- package/overlay/CommandPalette.js +164 -0
- package/overlay/ContextMenu.d.ts +11 -0
- package/overlay/ContextMenu.js +140 -0
- package/overlay/Drawer.d.ts +14 -0
- package/overlay/Drawer.js +99 -0
- package/overlay/HoverCard.d.ts +17 -0
- package/overlay/HoverCard.js +74 -0
- package/overlay/Menu.d.ts +24 -0
- package/overlay/Menu.js +153 -0
- package/overlay/Popover.d.ts +16 -0
- package/overlay/Popover.js +96 -0
- package/overlay/Portal.d.ts +10 -0
- package/overlay/Portal.js +127 -0
- package/package.json +41 -0
- package/styles.css +6 -0
- package/tokens/base.css +10 -0
- package/tokens/colors.css +38 -0
- package/tokens/effects.css +22 -0
- package/tokens/fonts.css +5 -0
- package/tokens/spacing.css +12 -0
- package/tokens/typography.css +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @efolusi/meridian
|
|
2
|
+
|
|
3
|
+
The npm build of [Meridian](https://meridian.efolusi.com). Import the stylesheet once, then components as you need them.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import '@efolusi/meridian/styles.css';
|
|
7
|
+
import { Button, FormField, Input } from '@efolusi/meridian';
|
|
8
|
+
// or per component, for the smallest graph:
|
|
9
|
+
import { Button } from '@efolusi/meridian/forms/Button.js';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`react` and `react-dom` are peer dependencies. Full docs, live demos and the zero-build CDN path: https://meridian.efolusi.com
|
package/ai/AgentRun.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface AgentRunStep {
|
|
2
|
+
id?: string;
|
|
3
|
+
title: React.ReactNode;
|
|
4
|
+
/** Supporting line — text or nodes */
|
|
5
|
+
detail?: React.ReactNode;
|
|
6
|
+
/** Collapsible panel (ToolCall, Diff…) behind a "Show detail" toggle */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Open the panel initially */
|
|
9
|
+
defaultOpen?: boolean;
|
|
10
|
+
/** @default 'pending' */
|
|
11
|
+
status?: 'done' | 'active' | 'pending' | 'error';
|
|
12
|
+
/** Mono timestamp on the right */
|
|
13
|
+
time?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AgentRunProps {
|
|
16
|
+
steps: AgentRunStep[];
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function AgentRun(props: AgentRunProps): React.JSX.Element;
|
package/ai/AgentRun.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { injectEfCss } from "../forms/Button.js";
|
|
4
|
+
import { Icon } from "../icons/Icon.js";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.ef-agentrun{display:flex;flex-direction:column}
|
|
7
|
+
.ef-agentrun__step{display:flex;gap:12px;position:relative}
|
|
8
|
+
.ef-agentrun__rail{display:flex;flex-direction:column;align-items:center;flex:none;width:22px}
|
|
9
|
+
.ef-agentrun__dot{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:var(--radius-full);border:1px solid var(--border-strong);background:var(--surface-card);color:var(--text-muted);flex:none}
|
|
10
|
+
.ef-agentrun__step--done .ef-agentrun__dot{background:var(--accent);border-color:var(--accent);color:var(--accent-contrast)}
|
|
11
|
+
.ef-agentrun__step--active .ef-agentrun__dot{border-color:var(--accent);color:var(--accent)}
|
|
12
|
+
.ef-agentrun__step--error .ef-agentrun__dot{background:var(--danger-100);border-color:var(--danger-600);color:var(--danger-600)}
|
|
13
|
+
.ef-agentrun__spin{display:inline-flex;animation:ef-agentrun-spin .9s linear infinite}
|
|
14
|
+
@keyframes ef-agentrun-spin{to{transform:rotate(360deg)}}
|
|
15
|
+
.ef-agentrun__line{width:1px;flex:1;background:var(--border-default);margin:3px 0}
|
|
16
|
+
.ef-agentrun__step--done .ef-agentrun__line{background:var(--accent-subtle-border)}
|
|
17
|
+
.ef-agentrun__content{flex:1;min-width:0;padding:1px 0 18px}
|
|
18
|
+
.ef-agentrun__step:last-child .ef-agentrun__content{padding-bottom:2px}
|
|
19
|
+
.ef-agentrun__title{display:flex;align-items:baseline;gap:8px;font-size:var(--text-sm);font-weight:600;color:var(--text-primary)}
|
|
20
|
+
.ef-agentrun__step--pending .ef-agentrun__title{color:var(--text-muted);font-weight:500}
|
|
21
|
+
.ef-agentrun__time{margin-left:auto;font-family:var(--font-mono);font-size:11px;color:var(--text-muted);flex:none}
|
|
22
|
+
.ef-agentrun__detail{font-size:13px;line-height:1.55;color:var(--text-secondary);margin-top:3px}
|
|
23
|
+
.ef-agentrun__toggle{display:inline-flex;align-items:center;gap:5px;border:none;background:none;padding:0;cursor:pointer;font-family:var(--font-sans);font-size:12px;font-weight:500;color:var(--text-muted);margin-top:4px}
|
|
24
|
+
.ef-agentrun__toggle:hover{color:var(--text-primary)}
|
|
25
|
+
.ef-agentrun__toggle:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
26
|
+
.ef-agentrun__toggle .ef-agentrun__tchev{display:inline-flex;transition:transform var(--dur-med) var(--ease-out)}
|
|
27
|
+
.ef-agentrun__toggle--open .ef-agentrun__tchev{transform:rotate(180deg)}
|
|
28
|
+
.ef-agentrun__panel{margin-top:8px;display:flex;flex-direction:column;gap:8px}
|
|
29
|
+
`;
|
|
30
|
+
export function AgentRun({
|
|
31
|
+
steps = [],
|
|
32
|
+
style,
|
|
33
|
+
className,
|
|
34
|
+
...rest
|
|
35
|
+
}) {
|
|
36
|
+
injectEfCss('ef-css-agentrun', CSS);
|
|
37
|
+
const [openIds, setOpenIds] = React.useState(() => new Set(steps.filter(s => s.defaultOpen).map((s, idx) => s.id || idx)));
|
|
38
|
+
const flip = key => setOpenIds(prev => {
|
|
39
|
+
const n = new Set(prev);
|
|
40
|
+
if (n.has(key)) n.delete(key);else n.add(key);
|
|
41
|
+
return n;
|
|
42
|
+
});
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
44
|
+
className: `ef-agentrun${className ? ' ' + className : ''}`,
|
|
45
|
+
style: style,
|
|
46
|
+
role: "list"
|
|
47
|
+
}), steps.map((s, i) => {
|
|
48
|
+
const st = s.status || 'pending';
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
key: s.id || i,
|
|
51
|
+
role: "listitem",
|
|
52
|
+
className: `ef-agentrun__step ef-agentrun__step--${st}`
|
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "ef-agentrun__rail"
|
|
55
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
56
|
+
className: "ef-agentrun__dot"
|
|
57
|
+
}, st === 'done' ? /*#__PURE__*/React.createElement(Icon, {
|
|
58
|
+
name: "check",
|
|
59
|
+
size: 12
|
|
60
|
+
}) : st === 'active' ? /*#__PURE__*/React.createElement("span", {
|
|
61
|
+
className: "ef-agentrun__spin"
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
63
|
+
name: "loader-circle",
|
|
64
|
+
size: 12
|
|
65
|
+
})) : st === 'error' ? /*#__PURE__*/React.createElement(Icon, {
|
|
66
|
+
name: "x",
|
|
67
|
+
size: 12
|
|
68
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
69
|
+
style: {
|
|
70
|
+
width: 5,
|
|
71
|
+
height: 5,
|
|
72
|
+
borderRadius: 99,
|
|
73
|
+
background: 'currentColor',
|
|
74
|
+
display: 'inline-block'
|
|
75
|
+
}
|
|
76
|
+
})), i < steps.length - 1 ? /*#__PURE__*/React.createElement("span", {
|
|
77
|
+
className: "ef-agentrun__line"
|
|
78
|
+
}) : null), /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: "ef-agentrun__content"
|
|
80
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
81
|
+
className: "ef-agentrun__title"
|
|
82
|
+
}, s.title, s.time ? /*#__PURE__*/React.createElement("span", {
|
|
83
|
+
className: "ef-agentrun__time"
|
|
84
|
+
}, s.time) : null), s.detail ? /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: "ef-agentrun__detail"
|
|
86
|
+
}, s.detail) : null, s.children ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
87
|
+
type: "button",
|
|
88
|
+
className: `ef-agentrun__toggle${openIds.has(s.id || i) ? ' ef-agentrun__toggle--open' : ''}`,
|
|
89
|
+
"aria-expanded": openIds.has(s.id || i),
|
|
90
|
+
onClick: () => flip(s.id || i)
|
|
91
|
+
}, openIds.has(s.id || i) ? 'Hide detail' : 'Show detail', /*#__PURE__*/React.createElement("span", {
|
|
92
|
+
className: "ef-agentrun__tchev"
|
|
93
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
94
|
+
name: "chevron-down",
|
|
95
|
+
size: 12
|
|
96
|
+
}))), openIds.has(s.id || i) ? /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
className: "ef-agentrun__panel"
|
|
98
|
+
}, s.children) : null) : null));
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ChatMessageProps {
|
|
2
|
+
/** @default 'assistant' */
|
|
3
|
+
role?: 'user' | 'assistant' | 'system';
|
|
4
|
+
/** Display name @default You / Agent / System */
|
|
5
|
+
name?: string;
|
|
6
|
+
time?: string;
|
|
7
|
+
/** Blinking caret while generating */
|
|
8
|
+
streaming?: boolean;
|
|
9
|
+
/** false hides the hover action row; a node replaces it wholesale */
|
|
10
|
+
actions?: boolean | React.ReactNode;
|
|
11
|
+
/** Copy button; omit and the button is not rendered */
|
|
12
|
+
onCopy?: (e: React.MouseEvent) => void;
|
|
13
|
+
/** Retry button; omit and the button is not rendered */
|
|
14
|
+
onRetry?: (e: React.MouseEvent) => void;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function ChatMessage(props: ChatMessageProps): React.JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Icon } from "../icons/Icon.js";
|
|
4
|
+
import { Avatar } from "../display/Avatar.js";
|
|
5
|
+
import { IconButton } from "../forms/IconButton.js";
|
|
6
|
+
import { injectEfCss } from "../forms/Button.js";
|
|
7
|
+
const CSS = `
|
|
8
|
+
.ef-msg{display:flex;gap:12px;max-width:720px}
|
|
9
|
+
.ef-msg__avatar{flex:none;margin-top:2px}
|
|
10
|
+
.ef-msg__bot{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:var(--radius-full);background:var(--accent);color:var(--accent-contrast);flex:none;margin-top:2px}
|
|
11
|
+
.ef-msg__meta{display:flex;align-items:baseline;gap:8px}
|
|
12
|
+
.ef-msg__name{font-size:var(--text-sm);font-weight:var(--weight-semibold);color:var(--text-primary)}
|
|
13
|
+
.ef-msg__time{font-size:var(--text-xs);color:var(--text-muted)}
|
|
14
|
+
.ef-msg__body{font-size:var(--text-md);line-height:var(--leading-relaxed);color:var(--text-primary);margin-top:4px}
|
|
15
|
+
.ef-msg--user .ef-msg__body{background:var(--surface-card);border:1px solid var(--border-default);border-radius:var(--radius-md);padding:10px 14px}
|
|
16
|
+
.ef-msg__actions{display:flex;gap:2px;margin-top:6px;opacity:0;transition:opacity var(--dur-fast) var(--ease-out)}
|
|
17
|
+
.ef-msg:hover .ef-msg__actions{opacity:1}
|
|
18
|
+
@keyframes ef-caret{0%,100%{opacity:1}50%{opacity:0}}
|
|
19
|
+
.ef-msg__caret{display:inline-block;width:7px;height:15px;background:var(--accent);margin-left:3px;vertical-align:-2px;animation:ef-caret 1s steps(1) infinite}
|
|
20
|
+
`;
|
|
21
|
+
export function ChatMessage({
|
|
22
|
+
role = 'assistant',
|
|
23
|
+
name,
|
|
24
|
+
time,
|
|
25
|
+
streaming,
|
|
26
|
+
actions,
|
|
27
|
+
onCopy,
|
|
28
|
+
onRetry,
|
|
29
|
+
children,
|
|
30
|
+
style,
|
|
31
|
+
className,
|
|
32
|
+
...rest
|
|
33
|
+
}) {
|
|
34
|
+
injectEfCss('ef-css-msg', CSS);
|
|
35
|
+
const who = name || (role === 'user' ? 'You' : role === 'system' ? 'System' : 'Agent');
|
|
36
|
+
// Only render an action a caller can actually handle: a button with nowhere to
|
|
37
|
+
// go is worse than no button. `actions` may be a node to replace the row wholesale.
|
|
38
|
+
const builtIn = onCopy || onRetry ? /*#__PURE__*/React.createElement(React.Fragment, null, onCopy ? /*#__PURE__*/React.createElement(IconButton, {
|
|
39
|
+
icon: "copy",
|
|
40
|
+
label: "Copy",
|
|
41
|
+
size: "sm",
|
|
42
|
+
onClick: onCopy
|
|
43
|
+
}) : null, onRetry ? /*#__PURE__*/React.createElement(IconButton, {
|
|
44
|
+
icon: "refresh-cw",
|
|
45
|
+
label: "Retry",
|
|
46
|
+
size: "sm",
|
|
47
|
+
onClick: onRetry
|
|
48
|
+
}) : null) : null;
|
|
49
|
+
const actionRow = actions === false ? null : actions != null && actions !== true ? actions : builtIn;
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
51
|
+
className: `ef-msg ef-msg--${role}${className ? ' ' + className : ''}`,
|
|
52
|
+
style: style
|
|
53
|
+
}), role === 'assistant' || role === 'system' ? /*#__PURE__*/React.createElement("span", {
|
|
54
|
+
className: "ef-msg__bot"
|
|
55
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
56
|
+
name: "bot",
|
|
57
|
+
size: 15
|
|
58
|
+
})) : /*#__PURE__*/React.createElement("span", {
|
|
59
|
+
className: "ef-msg__avatar"
|
|
60
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
61
|
+
name: who,
|
|
62
|
+
size: 28
|
|
63
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
style: {
|
|
65
|
+
flex: 1,
|
|
66
|
+
minWidth: 0
|
|
67
|
+
}
|
|
68
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
className: "ef-msg__meta"
|
|
70
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
71
|
+
className: "ef-msg__name"
|
|
72
|
+
}, who), time ? /*#__PURE__*/React.createElement("span", {
|
|
73
|
+
className: "ef-msg__time"
|
|
74
|
+
}, time) : null), /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: "ef-msg__body"
|
|
76
|
+
}, children, streaming ? /*#__PURE__*/React.createElement("span", {
|
|
77
|
+
className: "ef-msg__caret"
|
|
78
|
+
}) : null), actionRow && role === 'assistant' && !streaming ? /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: "ef-msg__actions"
|
|
80
|
+
}, actionRow) : null));
|
|
81
|
+
}
|
package/ai/Citation.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface CitationSource { title: string; url?: string; domain?: string; description?: string; }
|
|
2
|
+
export interface CitationProps {
|
|
3
|
+
/** Superscript number */
|
|
4
|
+
index: number;
|
|
5
|
+
href?: string;
|
|
6
|
+
/** Tooltip + aria label */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** Hover preview card(s) with pager when 2+ */
|
|
9
|
+
sources?: CitationSource[];
|
|
10
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface Source { index?: number; title: string; url?: string; domain?: string; }
|
|
15
|
+
export interface SourceListProps {
|
|
16
|
+
sources: Source[];
|
|
17
|
+
/** @default 'Sources' */
|
|
18
|
+
title?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function Citation(props: CitationProps): React.JSX.Element;
|
|
23
|
+
export declare function SourceList(props: SourceListProps): React.JSX.Element;
|
package/ai/Citation.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { injectEfCss } from "../forms/Button.js";
|
|
4
|
+
import { Icon } from "../icons/Icon.js";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.ef-citation{display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;margin:0 1px;vertical-align:super;border-radius:var(--radius-sm);border:1px solid var(--accent-subtle-border);background:var(--accent-subtle);color:var(--brand-700);font-family:var(--font-mono);font-size:10px;font-weight:600;text-decoration:none;cursor:pointer;line-height:1}
|
|
7
|
+
.ef-citation:hover{border-color:var(--brand-700)}
|
|
8
|
+
.ef-citation:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
9
|
+
.ef-citation__wrap{position:relative;display:inline}
|
|
10
|
+
.ef-citation__pop{position:absolute;bottom:calc(100% + 8px);left:0;width:280px;background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-md);padding:12px;z-index:var(--z-popover);animation:ef-citation-in var(--dur-fast) var(--ease-out);cursor:default;text-align:left}
|
|
11
|
+
@keyframes ef-citation-in{from{opacity:0;transform:translateY(3px)}}
|
|
12
|
+
.ef-citation__pop-name{display:flex;align-items:center;gap:6px;font-family:var(--font-mono);font-size:11px;color:var(--text-muted)}
|
|
13
|
+
.ef-citation__pop-title{font-size:13.5px;font-weight:600;color:var(--text-primary);line-height:1.4;margin-top:5px}
|
|
14
|
+
.ef-citation__pop-desc{font-size:12.5px;line-height:1.55;color:var(--text-secondary);margin-top:5px;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
|
|
15
|
+
.ef-citation__pop-nav{display:flex;align-items:center;gap:4px;margin-top:9px;padding-top:8px;border-top:1px solid var(--border-default)}
|
|
16
|
+
.ef-citation__pop-btn{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border:1px solid var(--border-default);border-radius:var(--radius-sm);background:none;cursor:pointer;color:var(--text-secondary)}
|
|
17
|
+
.ef-citation__pop-btn:hover{color:var(--text-primary);background:var(--surface-subtle)}
|
|
18
|
+
.ef-citation__pop-count{margin-left:auto;font-family:var(--font-mono);font-size:11px;color:var(--text-muted)}
|
|
19
|
+
.ef-sources{display:flex;flex-direction:column;border:1px solid var(--border-default);border-radius:var(--radius-md);overflow:hidden}
|
|
20
|
+
.ef-sources__head{padding:9px 13px;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--text-muted);background:var(--surface-subtle);border-bottom:1px solid var(--border-default)}
|
|
21
|
+
.ef-sources__item{display:flex;align-items:center;gap:10px;padding:9px 13px;text-decoration:none;border-bottom:1px solid var(--border-default);transition:background var(--dur-fast) var(--ease-out)}
|
|
22
|
+
.ef-sources__item:last-child{border-bottom:none}
|
|
23
|
+
.ef-sources__item:hover{background:var(--surface-subtle)}
|
|
24
|
+
.ef-sources__item:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
25
|
+
.ef-sources__num{flex:none;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:var(--radius-sm);background:var(--accent-subtle);color:var(--brand-700);font-family:var(--font-mono);font-size:10.5px;font-weight:600}
|
|
26
|
+
.ef-sources__title{flex:1;min-width:0;font-size:13.5px;font-weight:500;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
27
|
+
.ef-sources__domain{flex:none;font-family:var(--font-mono);font-size:11.5px;color:var(--text-muted)}
|
|
28
|
+
.ef-sources__ext{flex:none;display:inline-flex;color:var(--text-muted)}
|
|
29
|
+
`;
|
|
30
|
+
export function Citation({
|
|
31
|
+
index,
|
|
32
|
+
href,
|
|
33
|
+
title,
|
|
34
|
+
sources,
|
|
35
|
+
onClick,
|
|
36
|
+
style,
|
|
37
|
+
className,
|
|
38
|
+
...rest
|
|
39
|
+
}) {
|
|
40
|
+
injectEfCss('ef-css-citation', CSS);
|
|
41
|
+
const [open, setOpen] = React.useState(false);
|
|
42
|
+
const [i, setI] = React.useState(0);
|
|
43
|
+
const t = React.useRef(null);
|
|
44
|
+
const list = sources && sources.length ? sources : null;
|
|
45
|
+
const enter = () => {
|
|
46
|
+
if (!list) return;
|
|
47
|
+
clearTimeout(t.current);
|
|
48
|
+
t.current = setTimeout(() => setOpen(true), 200);
|
|
49
|
+
};
|
|
50
|
+
const leave = () => {
|
|
51
|
+
clearTimeout(t.current);
|
|
52
|
+
t.current = setTimeout(() => setOpen(false), 180);
|
|
53
|
+
};
|
|
54
|
+
React.useEffect(() => () => clearTimeout(t.current), []);
|
|
55
|
+
const chip = /*#__PURE__*/React.createElement("a", {
|
|
56
|
+
href: href || list && list[0] && list[0].url || '#',
|
|
57
|
+
title: title,
|
|
58
|
+
onClick: onClick,
|
|
59
|
+
target: href ? '_blank' : undefined,
|
|
60
|
+
rel: href ? 'noopener' : undefined,
|
|
61
|
+
className: `ef-citation${className ? ' ' + className : ''}`,
|
|
62
|
+
style: list ? null : style,
|
|
63
|
+
"aria-label": title ? 'Source ' + index + ': ' + title : 'Source ' + index
|
|
64
|
+
}, index);
|
|
65
|
+
if (!list) return chip;
|
|
66
|
+
const cur = list[Math.abs(i) % list.length];
|
|
67
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
|
|
68
|
+
className: "ef-citation__wrap",
|
|
69
|
+
style: style,
|
|
70
|
+
onMouseEnter: enter,
|
|
71
|
+
onMouseLeave: leave
|
|
72
|
+
}), chip, open ? /*#__PURE__*/React.createElement("span", {
|
|
73
|
+
className: "ef-citation__pop",
|
|
74
|
+
role: "dialog"
|
|
75
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
76
|
+
className: "ef-citation__pop-name"
|
|
77
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
78
|
+
name: "globe",
|
|
79
|
+
size: 11
|
|
80
|
+
}), cur.domain || 'source'), /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: "ef-citation__pop-title",
|
|
82
|
+
style: {
|
|
83
|
+
display: 'block'
|
|
84
|
+
}
|
|
85
|
+
}, cur.title), cur.description ? /*#__PURE__*/React.createElement("span", {
|
|
86
|
+
className: "ef-citation__pop-desc",
|
|
87
|
+
style: {
|
|
88
|
+
display: 'block'
|
|
89
|
+
}
|
|
90
|
+
}, cur.description) : null, list.length > 1 ? /*#__PURE__*/React.createElement("span", {
|
|
91
|
+
className: "ef-citation__pop-nav",
|
|
92
|
+
style: {
|
|
93
|
+
display: 'flex'
|
|
94
|
+
}
|
|
95
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
"aria-label": "Previous source",
|
|
98
|
+
className: "ef-citation__pop-btn",
|
|
99
|
+
onClick: () => setI((i - 1 + list.length) % list.length)
|
|
100
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
101
|
+
name: "chevron-left",
|
|
102
|
+
size: 12
|
|
103
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
104
|
+
type: "button",
|
|
105
|
+
"aria-label": "Next source",
|
|
106
|
+
className: "ef-citation__pop-btn",
|
|
107
|
+
onClick: () => setI((i + 1) % list.length)
|
|
108
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
109
|
+
name: "chevron-right",
|
|
110
|
+
size: 12
|
|
111
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
112
|
+
className: "ef-citation__pop-count"
|
|
113
|
+
}, Math.abs(i) % list.length + 1, "/", list.length)) : null) : null);
|
|
114
|
+
}
|
|
115
|
+
export function SourceList({
|
|
116
|
+
sources = [],
|
|
117
|
+
title = 'Sources',
|
|
118
|
+
style,
|
|
119
|
+
className,
|
|
120
|
+
...rest
|
|
121
|
+
}) {
|
|
122
|
+
injectEfCss('ef-css-citation', CSS);
|
|
123
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
124
|
+
className: `ef-sources${className ? ' ' + className : ''}`,
|
|
125
|
+
style: style
|
|
126
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
className: "ef-sources__head"
|
|
128
|
+
}, title), sources.map((s, i) => /*#__PURE__*/React.createElement("a", {
|
|
129
|
+
key: s.index || i,
|
|
130
|
+
className: "ef-sources__item",
|
|
131
|
+
href: s.url || '#',
|
|
132
|
+
target: s.url ? '_blank' : undefined,
|
|
133
|
+
rel: s.url ? 'noopener' : undefined
|
|
134
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
135
|
+
className: "ef-sources__num"
|
|
136
|
+
}, s.index || i + 1), /*#__PURE__*/React.createElement("span", {
|
|
137
|
+
className: "ef-sources__title"
|
|
138
|
+
}, s.title), s.domain ? /*#__PURE__*/React.createElement("span", {
|
|
139
|
+
className: "ef-sources__domain"
|
|
140
|
+
}, s.domain) : null, /*#__PURE__*/React.createElement("span", {
|
|
141
|
+
className: "ef-sources__ext"
|
|
142
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
143
|
+
name: "external-link",
|
|
144
|
+
size: 12
|
|
145
|
+
})))));
|
|
146
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface ConfirmationProps {
|
|
2
|
+
title: React.ReactNode;
|
|
3
|
+
description?: React.ReactNode;
|
|
4
|
+
/** 'danger' for destructive approvals @default 'default' */
|
|
5
|
+
tone?: 'default' | 'danger';
|
|
6
|
+
/** Controlled state */
|
|
7
|
+
state?: 'pending' | 'approved' | 'rejected';
|
|
8
|
+
/** @default 'pending' */
|
|
9
|
+
defaultState?: 'pending' | 'approved' | 'rejected';
|
|
10
|
+
onStateChange?: (state: 'pending' | 'approved' | 'rejected') => void;
|
|
11
|
+
/** Lucide icon; defaults by tone */
|
|
12
|
+
icon?: string;
|
|
13
|
+
/** @default 'Approve' */
|
|
14
|
+
approveLabel?: string;
|
|
15
|
+
/** @default 'Reject' */
|
|
16
|
+
rejectLabel?: string;
|
|
17
|
+
/** Status line after approving */
|
|
18
|
+
approvedNote?: React.ReactNode;
|
|
19
|
+
/** Status line after rejecting */
|
|
20
|
+
rejectedNote?: React.ReactNode;
|
|
21
|
+
/** Extra content (ToolCall, Diff…) */
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function Confirmation(props: ConfirmationProps): React.JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { injectEfCss } from "../forms/Button.js";
|
|
4
|
+
import { Icon } from "../icons/Icon.js";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.ef-confirm{border-radius:var(--radius-md);background:var(--surface-card);border:1px solid var(--accent-subtle-border);box-shadow:0 0 0 2px var(--accent-subtle)}
|
|
7
|
+
.ef-confirm--danger{border-color:var(--danger-300,var(--danger-600));box-shadow:0 0 0 2px var(--danger-100,#F8ECEA)}
|
|
8
|
+
.ef-confirm--settled{border-color:var(--border-default);box-shadow:none}
|
|
9
|
+
.ef-confirm__head{display:flex;align-items:center;gap:9px;padding:11px 14px 0}
|
|
10
|
+
.ef-confirm__icon{display:inline-flex;color:var(--brand-700);flex:none}
|
|
11
|
+
.ef-confirm--danger .ef-confirm__icon{color:var(--danger-600)}
|
|
12
|
+
.ef-confirm__title{font-size:var(--text-sm);font-weight:600;color:var(--text-primary)}
|
|
13
|
+
.ef-confirm__desc{padding:6px 14px 0;font-size:13.5px;line-height:1.6;color:var(--text-secondary)}
|
|
14
|
+
.ef-confirm__content{padding:10px 14px 0}
|
|
15
|
+
.ef-confirm__actions{display:flex;justify-content:flex-end;gap:8px;padding:12px 14px}
|
|
16
|
+
.ef-confirm__btn{height:30px;padding:0 13px;border-radius:var(--radius-sm);border:1px solid var(--border-strong);background:var(--surface-card);cursor:pointer;font-family:var(--font-sans);font-size:12.5px;font-weight:600;color:var(--text-primary);transition:background var(--dur-fast) var(--ease-out)}
|
|
17
|
+
.ef-confirm__btn:hover{background:var(--surface-subtle)}
|
|
18
|
+
.ef-confirm__btn:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
19
|
+
.ef-confirm__btn--accept{background:var(--accent);border-color:var(--accent);color:var(--accent-contrast)}
|
|
20
|
+
.ef-confirm__btn--accept:hover{background:var(--accent-hover)}
|
|
21
|
+
.ef-confirm--danger .ef-confirm__btn--accept{background:var(--danger-600);border-color:var(--danger-600);color:var(--danger-contrast)}
|
|
22
|
+
.ef-confirm__status{display:flex;align-items:center;gap:8px;padding:10px 14px 12px;font-size:13px;color:var(--text-secondary)}
|
|
23
|
+
.ef-confirm__status--approved{color:var(--success-600,var(--text-secondary))}
|
|
24
|
+
.ef-confirm__status--rejected{color:var(--text-muted)}
|
|
25
|
+
`;
|
|
26
|
+
export function Confirmation({
|
|
27
|
+
title,
|
|
28
|
+
description,
|
|
29
|
+
tone = 'default',
|
|
30
|
+
state,
|
|
31
|
+
defaultState = 'pending',
|
|
32
|
+
onStateChange,
|
|
33
|
+
icon,
|
|
34
|
+
approveLabel = 'Approve',
|
|
35
|
+
rejectLabel = 'Reject',
|
|
36
|
+
approvedNote = 'Approved — continuing.',
|
|
37
|
+
rejectedNote = 'Rejected — the agent will skip this.',
|
|
38
|
+
children,
|
|
39
|
+
style,
|
|
40
|
+
className,
|
|
41
|
+
...rest
|
|
42
|
+
}) {
|
|
43
|
+
injectEfCss('ef-css-confirm', CSS);
|
|
44
|
+
const [un, setUn] = React.useState(defaultState);
|
|
45
|
+
const cur = state !== undefined ? state : un;
|
|
46
|
+
const set = next => {
|
|
47
|
+
if (state === undefined) setUn(next);
|
|
48
|
+
if (onStateChange) onStateChange(next);
|
|
49
|
+
};
|
|
50
|
+
const settled = cur !== 'pending';
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
52
|
+
role: "group",
|
|
53
|
+
className: `ef-confirm${tone === 'danger' ? ' ef-confirm--danger' : ''}${settled ? ' ef-confirm--settled' : ''}${className ? ' ' + className : ''}`,
|
|
54
|
+
style: style
|
|
55
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: "ef-confirm__head"
|
|
57
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
58
|
+
className: "ef-confirm__icon"
|
|
59
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
60
|
+
name: icon || (tone === 'danger' ? 'triangle-alert' : 'shield-check'),
|
|
61
|
+
size: 15
|
|
62
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
63
|
+
className: "ef-confirm__title"
|
|
64
|
+
}, title)), description ? /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
className: "ef-confirm__desc"
|
|
66
|
+
}, description) : null, children ? /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
className: "ef-confirm__content"
|
|
68
|
+
}, children) : null, cur === 'pending' ? /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
className: "ef-confirm__actions"
|
|
70
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
71
|
+
type: "button",
|
|
72
|
+
className: "ef-confirm__btn",
|
|
73
|
+
onClick: () => set('rejected')
|
|
74
|
+
}, rejectLabel), /*#__PURE__*/React.createElement("button", {
|
|
75
|
+
type: "button",
|
|
76
|
+
className: "ef-confirm__btn ef-confirm__btn--accept",
|
|
77
|
+
onClick: () => set('approved')
|
|
78
|
+
}, approveLabel)) : /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: `ef-confirm__status ef-confirm__status--${cur}`
|
|
80
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
81
|
+
name: cur === 'approved' ? 'circle-check' : 'circle-alert',
|
|
82
|
+
size: 14
|
|
83
|
+
}), cur === 'approved' ? approvedNote : rejectedNote));
|
|
84
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ConversationProps {
|
|
2
|
+
/** Viewport height @default 420 */
|
|
3
|
+
height?: number | string;
|
|
4
|
+
/** Keep pinned to bottom as content grows @default true */
|
|
5
|
+
autoStick?: boolean;
|
|
6
|
+
/** @default 'Jump to latest' */
|
|
7
|
+
jumpLabel?: string;
|
|
8
|
+
/** Viewport padding @default 4 */
|
|
9
|
+
padding?: number | string;
|
|
10
|
+
/** Messages, tool calls, etc. */
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const Conversation: React.ForwardRefExoticComponent<ConversationProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { injectEfCss } from "../forms/Button.js";
|
|
4
|
+
import { Icon } from "../icons/Icon.js";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.ef-conversation{position:relative;overflow:hidden;display:flex;flex-direction:column}
|
|
7
|
+
.ef-conversation__viewport{overflow-y:auto;overscroll-behavior:contain;flex:1;min-height:0}
|
|
8
|
+
.ef-conversation__inner{display:flex;flex-direction:column;gap:18px}
|
|
9
|
+
.ef-conversation__jump{position:absolute;left:50%;transform:translateX(-50%);bottom:12px;display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 13px;border-radius:var(--radius-full);border:1px solid var(--border-strong);background:var(--surface-card);box-shadow:var(--shadow-md);cursor:pointer;font-family:var(--font-sans);font-size:12.5px;font-weight:500;color:var(--text-secondary);z-index:5;animation:ef-conversation-in var(--dur-fast) var(--ease-out)}
|
|
10
|
+
.ef-conversation__jump:hover{color:var(--text-primary)}
|
|
11
|
+
.ef-conversation__jump:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
12
|
+
@keyframes ef-conversation-in{from{opacity:0;transform:translateX(-50%) translateY(4px)}}
|
|
13
|
+
`;
|
|
14
|
+
export const Conversation = /*#__PURE__*/React.forwardRef(function Conversation({
|
|
15
|
+
height = 420,
|
|
16
|
+
autoStick = true,
|
|
17
|
+
jumpLabel = 'Jump to latest',
|
|
18
|
+
padding = 4,
|
|
19
|
+
children,
|
|
20
|
+
style,
|
|
21
|
+
className,
|
|
22
|
+
...rest
|
|
23
|
+
}, ref) {
|
|
24
|
+
injectEfCss('ef-css-conversation', CSS);
|
|
25
|
+
const viewport = React.useRef(null);
|
|
26
|
+
const inner = React.useRef(null);
|
|
27
|
+
const wasBottom = React.useRef(true);
|
|
28
|
+
const [atBottom, setAtBottom] = React.useState(true);
|
|
29
|
+
const recompute = () => {
|
|
30
|
+
const v = viewport.current;
|
|
31
|
+
if (!v) return;
|
|
32
|
+
const at = v.scrollHeight - v.scrollTop - v.clientHeight < 24;
|
|
33
|
+
wasBottom.current = at;
|
|
34
|
+
setAtBottom(at);
|
|
35
|
+
};
|
|
36
|
+
const toBottom = behavior => {
|
|
37
|
+
const v = viewport.current;
|
|
38
|
+
if (v) v.scrollTo({
|
|
39
|
+
top: v.scrollHeight,
|
|
40
|
+
behavior: behavior || 'smooth'
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
const v = viewport.current;
|
|
45
|
+
if (v) v.scrollTop = v.scrollHeight;
|
|
46
|
+
recompute();
|
|
47
|
+
if (!inner.current || typeof ResizeObserver === 'undefined') return;
|
|
48
|
+
const ro = new ResizeObserver(() => {
|
|
49
|
+
if (autoStick && wasBottom.current && viewport.current) viewport.current.scrollTop = viewport.current.scrollHeight;
|
|
50
|
+
recompute();
|
|
51
|
+
});
|
|
52
|
+
ro.observe(inner.current);
|
|
53
|
+
return () => ro.disconnect();
|
|
54
|
+
}, [autoStick]);
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
56
|
+
ref: ref
|
|
57
|
+
}, rest, {
|
|
58
|
+
className: `ef-conversation${className ? ' ' + className : ''}`,
|
|
59
|
+
style: {
|
|
60
|
+
height,
|
|
61
|
+
...style
|
|
62
|
+
}
|
|
63
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
ref: viewport,
|
|
65
|
+
className: "ef-conversation__viewport",
|
|
66
|
+
onScroll: recompute,
|
|
67
|
+
style: {
|
|
68
|
+
padding
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
ref: inner,
|
|
72
|
+
className: "ef-conversation__inner"
|
|
73
|
+
}, children)), !atBottom ? /*#__PURE__*/React.createElement("button", {
|
|
74
|
+
type: "button",
|
|
75
|
+
className: "ef-conversation__jump",
|
|
76
|
+
onClick: () => toBottom()
|
|
77
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
78
|
+
name: "chevron-down",
|
|
79
|
+
size: 13
|
|
80
|
+
}), jumpLabel) : null);
|
|
81
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface DocumentCardProps {
|
|
2
|
+
title: React.ReactNode;
|
|
3
|
+
/** Muted meta, e.g. "1,240 words" */
|
|
4
|
+
meta?: React.ReactNode;
|
|
5
|
+
/** Icon name. Default 'file-text' */
|
|
6
|
+
icon?: string;
|
|
7
|
+
/** Clipped height in px before expand. Default 200 */
|
|
8
|
+
collapsedHeight?: number;
|
|
9
|
+
defaultOpen?: boolean;
|
|
10
|
+
onCopy?: (text: string) => void;
|
|
11
|
+
/** Extra header action buttons */
|
|
12
|
+
actions?: React.ReactNode;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function DocumentCard(props: DocumentCardProps): React.JSX.Element;
|