@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/ai/Player.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { injectEfCss } from "../forms/Button.js";
|
|
3
|
+
import { Icon } from "../icons/Icon.js";
|
|
4
|
+
const CSS = `
|
|
5
|
+
.ef-player{display:flex;flex-direction:column;gap:10px;padding:14px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-card);font-family:var(--font-sans)}
|
|
6
|
+
.ef-player__top{display:flex;align-items:center;gap:10px}
|
|
7
|
+
.ef-player__title{flex:1;min-width:0;font-size:13.5px;font-weight:var(--weight-semibold);color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
8
|
+
.ef-player__meta{font-size:12px;color:var(--text-muted)}
|
|
9
|
+
.ef-player__wave{position:relative;display:flex;align-items:center;justify-content:space-between;height:44px;cursor:pointer;touch-action:none}
|
|
10
|
+
.ef-player__bar{flex:none;width:2.5px;border-radius:var(--radius-full);background:var(--sand-300,#D9D2C3);transition:background .2s var(--ease-out)}
|
|
11
|
+
.ef-player__bar--played{background:var(--accent)}
|
|
12
|
+
.ef-player__bar--loading{animation:ef-player-load 1.2s ease-in-out infinite}
|
|
13
|
+
@keyframes ef-player-load{0%,100%{transform:scaleY(.3);opacity:.5}50%{transform:scaleY(1);opacity:1}}
|
|
14
|
+
.ef-player__row{display:flex;align-items:center;gap:6px}
|
|
15
|
+
.ef-player__btn{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;border:none;background:none;cursor:pointer;color:var(--text-secondary);border-radius:var(--radius-full);transition:color var(--dur-fast) var(--ease-out),background var(--dur-fast) var(--ease-out)}
|
|
16
|
+
.ef-player__btn:hover{color:var(--text-primary);background:var(--surface-subtle)}
|
|
17
|
+
.ef-player__btn:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
18
|
+
.ef-player__play{width:38px;height:38px;background:var(--accent);color:var(--accent-contrast)}
|
|
19
|
+
.ef-player__play:hover{background:var(--accent-hover);color:var(--accent-contrast)}
|
|
20
|
+
.ef-player__time{font-size:12px;color:var(--text-muted);font-variant-numeric:tabular-nums}
|
|
21
|
+
`;
|
|
22
|
+
export function formatTime(s, hint) {
|
|
23
|
+
const t = Math.max(0, Math.floor(s || 0));
|
|
24
|
+
const h = Math.floor(t / 3600),
|
|
25
|
+
m = Math.floor(t % 3600 / 60),
|
|
26
|
+
sec = t % 60;
|
|
27
|
+
if ((hint || t) >= 3600) return h + ':' + String(m).padStart(2, '0') + ':' + String(sec).padStart(2, '0');
|
|
28
|
+
return m + ':' + String(sec).padStart(2, '0');
|
|
29
|
+
}
|
|
30
|
+
function pseudoPeaks(seedStr, n) {
|
|
31
|
+
const s = seedStr || 'ef';
|
|
32
|
+
let seed = 0;
|
|
33
|
+
for (let i = 0; i < s.length; i++) seed = (seed * 31 + s.charCodeAt(i)) % 9973;
|
|
34
|
+
const out = [];
|
|
35
|
+
for (let i = 0; i < n; i++) {
|
|
36
|
+
const v = Math.abs(Math.sin(seed + i * 0.83) * 0.6 + Math.sin(seed * 2 + i * 0.31) * 0.4);
|
|
37
|
+
out.push(0.18 + 0.82 * Math.min(1, v));
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
export const Player = /*#__PURE__*/React.forwardRef(function Player({
|
|
42
|
+
src,
|
|
43
|
+
title,
|
|
44
|
+
meta,
|
|
45
|
+
peaks,
|
|
46
|
+
samples = 72,
|
|
47
|
+
onTimeChange,
|
|
48
|
+
style,
|
|
49
|
+
className
|
|
50
|
+
}, ref) {
|
|
51
|
+
injectEfCss('ef-css-player', CSS);
|
|
52
|
+
const audio = React.useRef(null);
|
|
53
|
+
const wave = React.useRef(null);
|
|
54
|
+
const [playing, setPlaying] = React.useState(false);
|
|
55
|
+
const [t, setT] = React.useState(0);
|
|
56
|
+
const [dur, setDur] = React.useState(0);
|
|
57
|
+
const [muted, setMuted] = React.useState(false);
|
|
58
|
+
const bars = React.useMemo(() => peaks || pseudoPeaks(src, samples), [peaks, src, samples]);
|
|
59
|
+
const write = next => {
|
|
60
|
+
setT(next);
|
|
61
|
+
if (onTimeChange) onTimeChange(next);
|
|
62
|
+
};
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
const a = audio.current;
|
|
65
|
+
if (!a) return;
|
|
66
|
+
const onT = () => write(a.currentTime);
|
|
67
|
+
const onD = () => setDur(isFinite(a.duration) ? a.duration : 0);
|
|
68
|
+
const onP = () => setPlaying(true),
|
|
69
|
+
onPa = () => setPlaying(false);
|
|
70
|
+
a.addEventListener('timeupdate', onT);
|
|
71
|
+
a.addEventListener('durationchange', onD);
|
|
72
|
+
a.addEventListener('loadedmetadata', onD);
|
|
73
|
+
a.addEventListener('play', onP);
|
|
74
|
+
a.addEventListener('pause', onPa);
|
|
75
|
+
a.addEventListener('ended', onPa);
|
|
76
|
+
return () => {
|
|
77
|
+
a.removeEventListener('timeupdate', onT);
|
|
78
|
+
a.removeEventListener('durationchange', onD);
|
|
79
|
+
a.removeEventListener('loadedmetadata', onD);
|
|
80
|
+
a.removeEventListener('play', onP);
|
|
81
|
+
a.removeEventListener('pause', onPa);
|
|
82
|
+
a.removeEventListener('ended', onPa);
|
|
83
|
+
};
|
|
84
|
+
}, [src]);
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (!playing) return;
|
|
87
|
+
let raf;
|
|
88
|
+
const tick = () => {
|
|
89
|
+
if (audio.current) write(audio.current.currentTime);
|
|
90
|
+
raf = requestAnimationFrame(tick);
|
|
91
|
+
};
|
|
92
|
+
raf = requestAnimationFrame(tick);
|
|
93
|
+
return () => cancelAnimationFrame(raf);
|
|
94
|
+
}, [playing]);
|
|
95
|
+
const jumpTo = s => {
|
|
96
|
+
const a = audio.current;
|
|
97
|
+
const v = Math.max(0, Math.min(s, dur || s));
|
|
98
|
+
write(v);
|
|
99
|
+
if (a) a.currentTime = v;
|
|
100
|
+
};
|
|
101
|
+
const toggle = () => {
|
|
102
|
+
const a = audio.current;
|
|
103
|
+
if (!a) return;
|
|
104
|
+
if (a.paused) a.play().catch(() => {});else a.pause();
|
|
105
|
+
};
|
|
106
|
+
React.useImperativeHandle(ref, () => ({
|
|
107
|
+
jumpTo,
|
|
108
|
+
play: () => audio.current && audio.current.play(),
|
|
109
|
+
pause: () => audio.current && audio.current.pause()
|
|
110
|
+
}), [dur]);
|
|
111
|
+
const seekFromPointer = e => {
|
|
112
|
+
const el = wave.current;
|
|
113
|
+
if (!el || !dur) return;
|
|
114
|
+
const r = el.getBoundingClientRect();
|
|
115
|
+
jumpTo(Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)) * dur);
|
|
116
|
+
};
|
|
117
|
+
const onPointerDown = e => {
|
|
118
|
+
seekFromPointer(e);
|
|
119
|
+
const el = e.currentTarget;
|
|
120
|
+
el.setPointerCapture(e.pointerId);
|
|
121
|
+
const move = ev => seekFromPointer(ev);
|
|
122
|
+
const up = () => {
|
|
123
|
+
el.removeEventListener('pointermove', move);
|
|
124
|
+
el.removeEventListener('pointerup', up);
|
|
125
|
+
};
|
|
126
|
+
el.addEventListener('pointermove', move);
|
|
127
|
+
el.addEventListener('pointerup', up);
|
|
128
|
+
};
|
|
129
|
+
const ratio = dur > 0 ? Math.min(t / dur, 1) : 0;
|
|
130
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: `ef-player${className ? ' ' + className : ''}`,
|
|
132
|
+
style: style
|
|
133
|
+
}, src ? /*#__PURE__*/React.createElement("audio", {
|
|
134
|
+
ref: audio,
|
|
135
|
+
src: src,
|
|
136
|
+
preload: "metadata",
|
|
137
|
+
muted: muted
|
|
138
|
+
}) : null, title || meta ? /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
className: "ef-player__top"
|
|
140
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
141
|
+
className: "ef-player__title"
|
|
142
|
+
}, title), meta ? /*#__PURE__*/React.createElement("span", {
|
|
143
|
+
className: "ef-player__meta"
|
|
144
|
+
}, meta) : null) : null, /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
ref: wave,
|
|
146
|
+
className: "ef-player__wave",
|
|
147
|
+
role: "slider",
|
|
148
|
+
"aria-label": "Seek",
|
|
149
|
+
"aria-valuemin": 0,
|
|
150
|
+
"aria-valuemax": Math.round(dur),
|
|
151
|
+
"aria-valuenow": Math.round(t),
|
|
152
|
+
onPointerDown: onPointerDown
|
|
153
|
+
}, bars.map((p, i) => /*#__PURE__*/React.createElement("span", {
|
|
154
|
+
key: i,
|
|
155
|
+
className: `ef-player__bar${!dur && playing ? ' ef-player__bar--loading' : (i + 0.5) / bars.length <= ratio ? ' ef-player__bar--played' : ''}`,
|
|
156
|
+
style: {
|
|
157
|
+
height: Math.max(8, p * 100) + '%',
|
|
158
|
+
animationDelay: !dur ? i * 30 + 'ms' : undefined
|
|
159
|
+
}
|
|
160
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
className: "ef-player__row"
|
|
162
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
163
|
+
type: "button",
|
|
164
|
+
className: "ef-player__btn",
|
|
165
|
+
"aria-label": "Back 10 seconds",
|
|
166
|
+
onClick: () => jumpTo(t - 10)
|
|
167
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
168
|
+
name: "skip-back",
|
|
169
|
+
size: 14
|
|
170
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
171
|
+
type: "button",
|
|
172
|
+
className: "ef-player__btn ef-player__play",
|
|
173
|
+
"aria-label": playing ? 'Pause' : 'Play',
|
|
174
|
+
onClick: toggle
|
|
175
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
176
|
+
name: playing ? 'pause' : 'play',
|
|
177
|
+
size: 15
|
|
178
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
179
|
+
type: "button",
|
|
180
|
+
className: "ef-player__btn",
|
|
181
|
+
"aria-label": "Forward 10 seconds",
|
|
182
|
+
onClick: () => jumpTo(t + 10)
|
|
183
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
184
|
+
name: "skip-forward",
|
|
185
|
+
size: 14
|
|
186
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
187
|
+
className: "ef-player__time"
|
|
188
|
+
}, formatTime(t, dur), " / ", formatTime(dur)), /*#__PURE__*/React.createElement("button", {
|
|
189
|
+
type: "button",
|
|
190
|
+
className: "ef-player__btn",
|
|
191
|
+
style: {
|
|
192
|
+
marginLeft: 'auto'
|
|
193
|
+
},
|
|
194
|
+
"aria-label": muted ? 'Unmute' : 'Mute',
|
|
195
|
+
"aria-pressed": muted,
|
|
196
|
+
onClick: () => setMuted(!muted)
|
|
197
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
198
|
+
name: muted ? 'volume-x' : 'volume-2',
|
|
199
|
+
size: 14
|
|
200
|
+
}))));
|
|
201
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface PromptComposerProps {
|
|
2
|
+
/** Controlled text */
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
onChange?: (text: string, e: React.ChangeEvent) => void;
|
|
6
|
+
/** Enter sends (Shift+Enter = newline) */
|
|
7
|
+
onSend?: (text: string) => void;
|
|
8
|
+
/** Attach button; omit and the button is not rendered */
|
|
9
|
+
onAttach?: (e: React.MouseEvent) => void;
|
|
10
|
+
/** Voice-input button; omit and the button is not rendered */
|
|
11
|
+
onVoice?: (e: React.MouseEvent) => void;
|
|
12
|
+
/** Swaps send for a stop button while a response streams */
|
|
13
|
+
busy?: boolean;
|
|
14
|
+
/** Called by the stop button when `busy` */
|
|
15
|
+
onStop?: (e: React.MouseEvent) => void;
|
|
16
|
+
/** @default 'Ask the agent anything…' */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/** @default 2 */
|
|
19
|
+
rows?: number;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** FileTile chips shown above the input */
|
|
22
|
+
attachments?: React.ReactNode;
|
|
23
|
+
/** Muted hint left of the send button */
|
|
24
|
+
hint?: React.ReactNode;
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const PromptComposer: React.ForwardRefExoticComponent<PromptComposerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 { IconButton } from "../forms/IconButton.js";
|
|
5
|
+
import { injectEfCss } from "../forms/Button.js";
|
|
6
|
+
const CSS = `
|
|
7
|
+
.ef-composer{display:flex;flex-direction:column;background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-lg);transition:border-color var(--dur-fast) var(--ease-out),box-shadow var(--dur-fast) var(--ease-out)}
|
|
8
|
+
.ef-composer:focus-within{border-color:var(--accent);box-shadow:var(--focus-ring)}
|
|
9
|
+
.ef-composer__input{border:none;background:none;resize:none;padding:14px 16px 6px;font-family:var(--font-sans);font-size:var(--text-md);line-height:1.5;color:var(--text-primary);outline:none;min-height:24px}
|
|
10
|
+
.ef-composer__input::placeholder{color:var(--text-muted)}
|
|
11
|
+
.ef-composer__bar{display:flex;align-items:center;gap:2px;padding:6px 8px 8px}
|
|
12
|
+
.ef-composer__send{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;margin-left:auto;border:none;border-radius:var(--radius-md);background:var(--accent);color:var(--accent-contrast);cursor:pointer;transition:background var(--dur-fast) var(--ease-out),transform var(--dur-fast) var(--ease-out)}
|
|
13
|
+
.ef-composer__send:hover:not(:disabled){background:var(--accent-hover)}
|
|
14
|
+
.ef-composer__send:active:not(:disabled){transform:scale(.95)}
|
|
15
|
+
.ef-composer__send:disabled{background:var(--sand-200);color:var(--sand-400);cursor:not-allowed}
|
|
16
|
+
.ef-composer__send:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
17
|
+
.ef-composer__hint{font-size:var(--text-xs);color:var(--text-muted);padding:0 4px}
|
|
18
|
+
`;
|
|
19
|
+
export const PromptComposer = /*#__PURE__*/React.forwardRef(function PromptComposer({
|
|
20
|
+
value,
|
|
21
|
+
defaultValue,
|
|
22
|
+
onChange,
|
|
23
|
+
onSend,
|
|
24
|
+
onAttach,
|
|
25
|
+
onVoice,
|
|
26
|
+
busy,
|
|
27
|
+
onStop,
|
|
28
|
+
placeholder = 'Ask the agent anything…',
|
|
29
|
+
rows = 2,
|
|
30
|
+
disabled,
|
|
31
|
+
attachments,
|
|
32
|
+
hint,
|
|
33
|
+
style,
|
|
34
|
+
className,
|
|
35
|
+
...rest
|
|
36
|
+
}, ref) {
|
|
37
|
+
injectEfCss('ef-css-composer', CSS);
|
|
38
|
+
const [inner, setInner] = React.useState(defaultValue || '');
|
|
39
|
+
const v = value != null ? value : inner;
|
|
40
|
+
const set = (t, e) => {
|
|
41
|
+
if (value == null) setInner(t);
|
|
42
|
+
if (onChange) onChange(t, e);
|
|
43
|
+
};
|
|
44
|
+
const send = () => {
|
|
45
|
+
if (v.trim() && onSend && !disabled) {
|
|
46
|
+
onSend(v);
|
|
47
|
+
if (value == null) setInner('');
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
51
|
+
ref: ref
|
|
52
|
+
}, rest, {
|
|
53
|
+
className: `ef-composer${className ? ' ' + className : ''}`,
|
|
54
|
+
style: style
|
|
55
|
+
}), attachments ? /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
style: {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
gap: 6,
|
|
59
|
+
flexWrap: 'wrap',
|
|
60
|
+
padding: '10px 12px 0'
|
|
61
|
+
}
|
|
62
|
+
}, attachments) : null, /*#__PURE__*/React.createElement("textarea", {
|
|
63
|
+
className: "ef-composer__input",
|
|
64
|
+
rows: rows,
|
|
65
|
+
placeholder: placeholder,
|
|
66
|
+
value: v,
|
|
67
|
+
disabled: disabled,
|
|
68
|
+
onChange: e => set(e.target.value, e),
|
|
69
|
+
onKeyDown: e => {
|
|
70
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
send();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: "ef-composer__bar"
|
|
77
|
+
}, onAttach ? /*#__PURE__*/React.createElement(IconButton, {
|
|
78
|
+
icon: "paperclip",
|
|
79
|
+
label: "Attach files",
|
|
80
|
+
size: "sm",
|
|
81
|
+
onClick: onAttach
|
|
82
|
+
}) : null, onVoice ? /*#__PURE__*/React.createElement(IconButton, {
|
|
83
|
+
icon: "mic",
|
|
84
|
+
label: "Voice input",
|
|
85
|
+
size: "sm",
|
|
86
|
+
onClick: onVoice
|
|
87
|
+
}) : null, hint ? /*#__PURE__*/React.createElement("span", {
|
|
88
|
+
className: "ef-composer__hint"
|
|
89
|
+
}, hint) : null, busy ? /*#__PURE__*/React.createElement("button", {
|
|
90
|
+
className: "ef-composer__send",
|
|
91
|
+
"aria-label": "Stop generating",
|
|
92
|
+
onClick: onStop,
|
|
93
|
+
disabled: !onStop
|
|
94
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
95
|
+
name: "square",
|
|
96
|
+
size: 13,
|
|
97
|
+
strokeWidth: 2.5
|
|
98
|
+
})) : /*#__PURE__*/React.createElement("button", {
|
|
99
|
+
className: "ef-composer__send",
|
|
100
|
+
"aria-label": "Send",
|
|
101
|
+
disabled: disabled || !v.trim(),
|
|
102
|
+
onClick: send
|
|
103
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
104
|
+
name: "arrow-up-right",
|
|
105
|
+
size: 16,
|
|
106
|
+
strokeWidth: 2,
|
|
107
|
+
style: {
|
|
108
|
+
transform: 'rotate(-45deg)'
|
|
109
|
+
}
|
|
110
|
+
}))));
|
|
111
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface PromptStep {
|
|
2
|
+
/** Answer key */
|
|
3
|
+
name: string;
|
|
4
|
+
question: React.ReactNode;
|
|
5
|
+
options: string[];
|
|
6
|
+
/** true, or a placeholder string, adds an "Other" free-text row */
|
|
7
|
+
other?: boolean | string;
|
|
8
|
+
}
|
|
9
|
+
export interface PromptStepsProps {
|
|
10
|
+
steps: PromptStep[];
|
|
11
|
+
defaultValues?: Record<string, string>;
|
|
12
|
+
onAnswer?: (value: string, ctx: { name: string; stepIndex: number; totalSteps: number }) => void;
|
|
13
|
+
onComplete?: (answers: Record<string, string>) => void;
|
|
14
|
+
onDismiss?: () => void;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function PromptSteps(props: PromptStepsProps): React.JSX.Element;
|
|
@@ -0,0 +1,167 @@
|
|
|
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-promptsteps{border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-card);padding:5px;font-family:var(--font-sans)}
|
|
7
|
+
.ef-promptsteps:focus{outline:none}
|
|
8
|
+
.ef-promptsteps:focus-visible{box-shadow:var(--focus-ring)}
|
|
9
|
+
.ef-promptsteps__q{padding:8px 11px 6px;font-size:13.5px;font-weight:var(--weight-semibold);color:var(--text-primary)}
|
|
10
|
+
.ef-promptsteps__opt{display:flex;align-items:center;gap:11px;width:100%;padding:8px 11px;border:none;background:none;cursor:pointer;text-align:left;border-radius:var(--radius-sm);font-family:var(--font-sans);font-size:13.5px;color:var(--text-secondary)}
|
|
11
|
+
.ef-promptsteps__opt--hi{background:var(--surface-sunken);color:var(--text-primary)}
|
|
12
|
+
.ef-promptsteps__num{flex:none;width:14px;font-variant-numeric:tabular-nums;color:var(--text-muted);font-size:12.5px}
|
|
13
|
+
.ef-promptsteps__other{flex:1;min-width:0;border:none;background:none;outline:none;font-family:var(--font-sans);font-size:13.5px;color:var(--text-primary);padding:0}
|
|
14
|
+
.ef-promptsteps__other::placeholder{color:var(--text-muted)}
|
|
15
|
+
.ef-promptsteps__foot{display:flex;align-items:center;gap:12px;padding:8px 11px 5px;font-size:12px;color:var(--text-muted)}
|
|
16
|
+
.ef-promptsteps__back{display:inline-flex;align-items:center;gap:4px;border:none;background:none;cursor:pointer;padding:2px 6px;margin-left:-6px;border-radius:var(--radius-sm);font-family:var(--font-sans);font-size:12px;color:var(--text-muted)}
|
|
17
|
+
.ef-promptsteps__back:hover{color:var(--text-primary)}
|
|
18
|
+
.ef-promptsteps__kbd{margin-left:auto;display:inline-flex;align-items:center;gap:5px}
|
|
19
|
+
.ef-promptsteps__kbd kbd{padding:1px 6px;border:1px solid var(--border-default);border-radius:var(--radius-sm);background:var(--surface-subtle);font-family:var(--font-sans);font-size:11px;color:var(--text-secondary)}
|
|
20
|
+
`;
|
|
21
|
+
export function PromptSteps({
|
|
22
|
+
steps = [],
|
|
23
|
+
defaultValues = {},
|
|
24
|
+
onAnswer,
|
|
25
|
+
onComplete,
|
|
26
|
+
onDismiss,
|
|
27
|
+
style,
|
|
28
|
+
className,
|
|
29
|
+
...rest
|
|
30
|
+
}) {
|
|
31
|
+
injectEfCss('ef-css-promptsteps', CSS);
|
|
32
|
+
const [idx, setIdx] = React.useState(0);
|
|
33
|
+
const [hi, setHi] = React.useState(0);
|
|
34
|
+
const [other, setOther] = React.useState('');
|
|
35
|
+
const [answers, setAnswers] = React.useState(defaultValues);
|
|
36
|
+
const rootRef = React.useRef(null);
|
|
37
|
+
const otherRef = React.useRef(null);
|
|
38
|
+
const step = steps[idx];
|
|
39
|
+
const opts = step ? step.options.concat(step.other ? ['__other__'] : []) : [];
|
|
40
|
+
const otherIdx = step && step.other ? opts.length - 1 : -1;
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (hi === otherIdx && otherRef.current) otherRef.current.focus();else if (rootRef.current && (!document.activeElement || !rootRef.current.contains(document.activeElement) || document.activeElement === otherRef.current)) rootRef.current.focus();
|
|
43
|
+
}, [hi, idx, otherIdx]);
|
|
44
|
+
const reset = () => {
|
|
45
|
+
setIdx(0);
|
|
46
|
+
setHi(0);
|
|
47
|
+
setOther('');
|
|
48
|
+
setAnswers(defaultValues);
|
|
49
|
+
};
|
|
50
|
+
const submit = () => {
|
|
51
|
+
if (!step) return;
|
|
52
|
+
const isOther = hi === otherIdx;
|
|
53
|
+
const value = isOther ? other.trim() : opts[hi];
|
|
54
|
+
if (!value) return;
|
|
55
|
+
const next = {
|
|
56
|
+
...answers,
|
|
57
|
+
[step.name]: value
|
|
58
|
+
};
|
|
59
|
+
setAnswers(next);
|
|
60
|
+
if (onAnswer) onAnswer(value, {
|
|
61
|
+
name: step.name,
|
|
62
|
+
stepIndex: idx,
|
|
63
|
+
totalSteps: steps.length
|
|
64
|
+
});
|
|
65
|
+
if (idx === steps.length - 1) {
|
|
66
|
+
if (onComplete) onComplete(next);
|
|
67
|
+
reset();
|
|
68
|
+
} else {
|
|
69
|
+
setIdx(idx + 1);
|
|
70
|
+
setHi(0);
|
|
71
|
+
setOther('');
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const back = () => {
|
|
75
|
+
if (idx > 0) {
|
|
76
|
+
setIdx(idx - 1);
|
|
77
|
+
setHi(0);
|
|
78
|
+
setOther('');
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const onKey = e => {
|
|
82
|
+
const inOther = e.target === otherRef.current;
|
|
83
|
+
if (e.key === 'ArrowDown') {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
setHi(Math.min(opts.length - 1, hi + 1));
|
|
86
|
+
} else if (e.key === 'ArrowUp') {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
setHi(Math.max(0, hi - 1));
|
|
89
|
+
} else if (e.key === 'Enter') {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
submit();
|
|
92
|
+
} else if (e.key === 'Escape') {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
reset();
|
|
95
|
+
if (onDismiss) onDismiss();
|
|
96
|
+
} else if (e.key === 'ArrowLeft' && !inOther || e.key === 'Tab' && e.shiftKey) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
back();
|
|
99
|
+
} else if (!inOther && /^[1-9]$/.test(e.key)) {
|
|
100
|
+
const n = +e.key - 1;
|
|
101
|
+
if (n < opts.length) {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
setHi(n);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
if (!step) return null;
|
|
108
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
109
|
+
ref: rootRef,
|
|
110
|
+
tabIndex: -1,
|
|
111
|
+
className: `ef-promptsteps${className ? ' ' + className : ''}`,
|
|
112
|
+
style: style,
|
|
113
|
+
onKeyDown: onKey
|
|
114
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
className: "ef-promptsteps__q"
|
|
116
|
+
}, step.question), opts.map((o, i) => i === otherIdx ? /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
key: "__other",
|
|
118
|
+
className: `ef-promptsteps__opt${hi === i ? ' ef-promptsteps__opt--hi' : ''}`,
|
|
119
|
+
style: {
|
|
120
|
+
cursor: 'text'
|
|
121
|
+
},
|
|
122
|
+
onMouseEnter: () => setHi(i),
|
|
123
|
+
onClick: () => {
|
|
124
|
+
setHi(i);
|
|
125
|
+
if (otherRef.current) otherRef.current.focus();
|
|
126
|
+
}
|
|
127
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
128
|
+
className: "ef-promptsteps__num"
|
|
129
|
+
}, i + 1, "."), /*#__PURE__*/React.createElement("input", {
|
|
130
|
+
ref: otherRef,
|
|
131
|
+
className: "ef-promptsteps__other",
|
|
132
|
+
type: "text",
|
|
133
|
+
value: other,
|
|
134
|
+
placeholder: typeof step.other === 'string' ? step.other : 'Type your answer',
|
|
135
|
+
onChange: e => {
|
|
136
|
+
setOther(e.target.value);
|
|
137
|
+
setHi(i);
|
|
138
|
+
},
|
|
139
|
+
onFocus: () => setHi(i)
|
|
140
|
+
})) : /*#__PURE__*/React.createElement("button", {
|
|
141
|
+
key: o,
|
|
142
|
+
type: "button",
|
|
143
|
+
className: `ef-promptsteps__opt${hi === i ? ' ef-promptsteps__opt--hi' : ''}`,
|
|
144
|
+
onMouseEnter: () => setHi(i),
|
|
145
|
+
onClick: () => {
|
|
146
|
+
setHi(i);
|
|
147
|
+
submit();
|
|
148
|
+
}
|
|
149
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
150
|
+
className: "ef-promptsteps__num"
|
|
151
|
+
}, i + 1, "."), /*#__PURE__*/React.createElement("span", {
|
|
152
|
+
style: {
|
|
153
|
+
flex: 1
|
|
154
|
+
}
|
|
155
|
+
}, o))), /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
className: "ef-promptsteps__foot"
|
|
157
|
+
}, idx > 0 ? /*#__PURE__*/React.createElement("button", {
|
|
158
|
+
type: "button",
|
|
159
|
+
className: "ef-promptsteps__back",
|
|
160
|
+
onClick: back
|
|
161
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
162
|
+
name: "chevron-left",
|
|
163
|
+
size: 12
|
|
164
|
+
}), "Back") : null, /*#__PURE__*/React.createElement("span", null, idx + 1, " of ", steps.length), /*#__PURE__*/React.createElement("span", {
|
|
165
|
+
className: "ef-promptsteps__kbd"
|
|
166
|
+
}, "select ", /*#__PURE__*/React.createElement("kbd", null, "\u2191\u2193"), " or ", /*#__PURE__*/React.createElement("kbd", null, "1\u20139"), " \xB7 confirm ", /*#__PURE__*/React.createElement("kbd", null, "\u21B5"))));
|
|
167
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ReasoningProps {
|
|
2
|
+
/** Pulsing glyph + "Thinking…" header */
|
|
3
|
+
streaming?: boolean;
|
|
4
|
+
/** Header reads "Thought for <duration>" */
|
|
5
|
+
duration?: string;
|
|
6
|
+
/** Custom header text */
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
/** Controlled open state */
|
|
10
|
+
open?: boolean;
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
/** The reasoning text */
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function Reasoning(props: ReasoningProps): React.JSX.Element;
|
package/ai/Reasoning.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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-reasoning{border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-subtle);overflow:hidden}
|
|
7
|
+
.ef-reasoning__head{display:flex;align-items:center;gap:8px;width:100%;padding:9px 12px;border:none;background:none;cursor:pointer;text-align:left;font-family:var(--font-sans);font-size:var(--text-sm);font-weight:500;color:var(--text-secondary)}
|
|
8
|
+
.ef-reasoning__head:focus-visible{outline:none;box-shadow:var(--focus-ring)}
|
|
9
|
+
.ef-reasoning__glyph{display:inline-flex;color:var(--text-muted)}
|
|
10
|
+
.ef-reasoning--streaming .ef-reasoning__glyph{animation:ef-reasoning-pulse 1.2s var(--ease-out) infinite}
|
|
11
|
+
@keyframes ef-reasoning-pulse{0%,100%{opacity:1}50%{opacity:.35}}
|
|
12
|
+
.ef-reasoning__chev{margin-left:auto;display:inline-flex;color:var(--text-muted);transition:transform var(--dur-med) var(--ease-out)}
|
|
13
|
+
.ef-reasoning--open .ef-reasoning__chev{transform:rotate(180deg)}
|
|
14
|
+
.ef-reasoning__body{padding:2px 14px 12px;font-size:13.5px;line-height:1.65;color:var(--text-secondary);white-space:pre-wrap;border-top:1px dashed var(--border-default);padding-top:10px;margin:0 0}
|
|
15
|
+
`;
|
|
16
|
+
export function Reasoning({
|
|
17
|
+
streaming,
|
|
18
|
+
duration,
|
|
19
|
+
defaultOpen,
|
|
20
|
+
open,
|
|
21
|
+
onOpenChange,
|
|
22
|
+
label,
|
|
23
|
+
children,
|
|
24
|
+
style,
|
|
25
|
+
className,
|
|
26
|
+
...rest
|
|
27
|
+
}) {
|
|
28
|
+
injectEfCss('ef-css-reasoning', CSS);
|
|
29
|
+
const [un, setUn] = React.useState(!!defaultOpen);
|
|
30
|
+
const isOpen = open !== undefined ? open : un;
|
|
31
|
+
const flip = () => {
|
|
32
|
+
if (open === undefined) setUn(!isOpen);
|
|
33
|
+
if (onOpenChange) onOpenChange(!isOpen);
|
|
34
|
+
};
|
|
35
|
+
const head = label || (streaming ? 'Thinking…' : duration ? 'Thought for ' + duration : 'Reasoning');
|
|
36
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
37
|
+
className: `ef-reasoning${isOpen ? ' ef-reasoning--open' : ''}${streaming ? ' ef-reasoning--streaming' : ''}${className ? ' ' + className : ''}`,
|
|
38
|
+
style: style
|
|
39
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
40
|
+
type: "button",
|
|
41
|
+
className: "ef-reasoning__head",
|
|
42
|
+
"aria-expanded": isOpen,
|
|
43
|
+
onClick: flip
|
|
44
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: "ef-reasoning__glyph"
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
47
|
+
name: "brain",
|
|
48
|
+
size: 14
|
|
49
|
+
})), head, /*#__PURE__*/React.createElement("span", {
|
|
50
|
+
className: "ef-reasoning__chev"
|
|
51
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
52
|
+
name: "chevron-down",
|
|
53
|
+
size: 14
|
|
54
|
+
}))), isOpen ? /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "ef-reasoning__body"
|
|
56
|
+
}, children) : null);
|
|
57
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ComposerItem {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
group?: string;
|
|
7
|
+
keywords?: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface RichComposerProps {
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** @-mention items, inserted as atomic chips */
|
|
12
|
+
mentions?: ComposerItem[];
|
|
13
|
+
/** /-command items, executed via onCommand */
|
|
14
|
+
commands?: ComposerItem[];
|
|
15
|
+
hint?: React.ReactNode;
|
|
16
|
+
/** Left toolbar slot */
|
|
17
|
+
actions?: React.ReactNode;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
onSubmit?: (value: { text: string; mentions: { id: string; label: string }[] }) => void;
|
|
21
|
+
onCommand?: (item: ComposerItem) => void;
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function RichComposer(props: RichComposerProps): React.JSX.Element;
|