@seed-ship/mcp-ui-solid 2.3.0 → 2.4.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.
Files changed (39) hide show
  1. package/dist/components/ChatPrompt.cjs +271 -0
  2. package/dist/components/ChatPrompt.cjs.map +1 -0
  3. package/dist/components/ChatPrompt.d.ts +33 -0
  4. package/dist/components/ChatPrompt.d.ts.map +1 -0
  5. package/dist/components/ChatPrompt.js +271 -0
  6. package/dist/components/ChatPrompt.js.map +1 -0
  7. package/dist/hooks/useChatBus.cjs +28 -0
  8. package/dist/hooks/useChatBus.cjs.map +1 -0
  9. package/dist/hooks/useChatBus.d.ts +56 -0
  10. package/dist/hooks/useChatBus.d.ts.map +1 -0
  11. package/dist/hooks/useChatBus.js +28 -0
  12. package/dist/hooks/useChatBus.js.map +1 -0
  13. package/dist/index.cjs +9 -0
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +5 -1
  16. package/dist/index.d.ts +5 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +9 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/services/chat-bus.cjs +118 -0
  21. package/dist/services/chat-bus.cjs.map +1 -0
  22. package/dist/services/chat-bus.d.ts +43 -0
  23. package/dist/services/chat-bus.d.ts.map +1 -0
  24. package/dist/services/chat-bus.js +118 -0
  25. package/dist/services/chat-bus.js.map +1 -0
  26. package/dist/services/index.d.ts +1 -0
  27. package/dist/services/index.d.ts.map +1 -1
  28. package/dist/types/chat-bus.d.ts +286 -0
  29. package/dist/types/chat-bus.d.ts.map +1 -0
  30. package/package.json +1 -1
  31. package/src/components/ChatPrompt.test.tsx +280 -0
  32. package/src/components/ChatPrompt.tsx +263 -0
  33. package/src/hooks/useChatBus.tsx +81 -0
  34. package/src/index.ts +34 -0
  35. package/src/services/chat-bus.test.ts +306 -0
  36. package/src/services/chat-bus.ts +183 -0
  37. package/src/services/index.ts +2 -0
  38. package/src/types/chat-bus.ts +320 -0
  39. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const web = require("solid-js/web");
4
+ const solidJs = require("solid-js");
5
+ var _tmpl$ = /* @__PURE__ */ web.template(`<div class="w-full max-w-2xl mx-auto mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg overflow-hidden"role=dialog style="animation:chat-prompt-slide-up 0.2s ease-out"><div class="flex items-center justify-between px-4 py-2.5 border-b border-gray-100 dark:border-gray-700"><p class="text-sm font-medium text-gray-900 dark:text-white"></p><button class="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"aria-label=Dismiss><svg class="w-4 h-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M6 18L18 6M6 6l12 12"></path></svg></button></div><div class="px-4 py-3"></div><style>
6
+ @keyframes chat-prompt-slide-up {
7
+ from { opacity: 0; transform: translateY(8px); }
8
+ to { opacity: 1; transform: translateY(0); }
9
+ }
10
+ `), _tmpl$2 = /* @__PURE__ */ web.template(`<div>`), _tmpl$3 = /* @__PURE__ */ web.template(`<span class=mr-2>`), _tmpl$4 = /* @__PURE__ */ web.template(`<span class="block text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal">`), _tmpl$5 = /* @__PURE__ */ web.template(`<button class="px-4 py-2 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white hover:bg-blue-50 hover:border-blue-300 dark:hover:bg-blue-900/30 dark:hover:border-blue-600 transition-colors text-left"><!$><!/><!$><!/><!$><!/>`), _tmpl$6 = /* @__PURE__ */ web.template(`<p class="text-sm text-gray-600 dark:text-gray-400 mb-3">`), _tmpl$7 = /* @__PURE__ */ web.template(`<div><!$><!/><div class="flex gap-2 justify-end"><button class="px-4 py-2 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"></button><button>`), _tmpl$8 = /* @__PURE__ */ web.template(`<form class="flex flex-col gap-3"><!$><!/><div class="flex justify-end"><button type=submit class="px-4 py-2 text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed transition-colors">`), _tmpl$9 = /* @__PURE__ */ web.template(`<span class="text-red-500 ml-0.5">*`), _tmpl$0 = /* @__PURE__ */ web.template(`<textarea rows=3 class="w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors">`), _tmpl$1 = /* @__PURE__ */ web.template(`<select class="w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors"><option value></option><!$><!/>`), _tmpl$10 = /* @__PURE__ */ web.template(`<input class="w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors">`), _tmpl$11 = /* @__PURE__ */ web.template(`<div><label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1"><!$><!/><!$><!/></label><!$><!/>`), _tmpl$12 = /* @__PURE__ */ web.template(`<option>`);
11
+ const ChatPrompt = (props) => {
12
+ return (() => {
13
+ var _el$ = web.getNextElement(_tmpl$), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$2.nextSibling;
14
+ web.insert(_el$3, () => props.config.title);
15
+ _el$4.$$click = () => {
16
+ var _a;
17
+ (_a = props.onDismiss) == null ? void 0 : _a.call(props);
18
+ props.onSubmit({
19
+ type: props.config.type,
20
+ value: "",
21
+ label: "",
22
+ dismissed: true
23
+ });
24
+ };
25
+ web.insert(_el$5, web.createComponent(solidJs.Switch, {
26
+ get children() {
27
+ return [web.createComponent(solidJs.Match, {
28
+ get when() {
29
+ return props.config.type === "choice";
30
+ },
31
+ get children() {
32
+ return web.createComponent(ChoiceBody, {
33
+ get config() {
34
+ return props.config.config;
35
+ },
36
+ onSelect: (value, label) => props.onSubmit({
37
+ type: "choice",
38
+ value,
39
+ label
40
+ })
41
+ });
42
+ }
43
+ }), web.createComponent(solidJs.Match, {
44
+ get when() {
45
+ return props.config.type === "confirm";
46
+ },
47
+ get children() {
48
+ return web.createComponent(ConfirmBody, {
49
+ get config() {
50
+ return props.config.config;
51
+ },
52
+ onConfirm: () => props.onSubmit({
53
+ type: "confirm",
54
+ value: "confirmed",
55
+ label: props.config.config.confirmLabel || "Confirmed"
56
+ }),
57
+ onCancel: () => {
58
+ var _a;
59
+ (_a = props.onDismiss) == null ? void 0 : _a.call(props);
60
+ props.onSubmit({
61
+ type: "confirm",
62
+ value: "cancelled",
63
+ label: props.config.config.cancelLabel || "Cancelled",
64
+ dismissed: true
65
+ });
66
+ }
67
+ });
68
+ }
69
+ }), web.createComponent(solidJs.Match, {
70
+ get when() {
71
+ return props.config.type === "form";
72
+ },
73
+ get children() {
74
+ return web.createComponent(FormBody, {
75
+ get config() {
76
+ return props.config.config;
77
+ },
78
+ onSubmit: (data, label) => props.onSubmit({
79
+ type: "form",
80
+ value: data,
81
+ label
82
+ })
83
+ });
84
+ }
85
+ })];
86
+ }
87
+ }));
88
+ web.effect(() => web.setAttribute(_el$, "aria-label", props.config.title));
89
+ web.runHydrationEvents();
90
+ return _el$;
91
+ })();
92
+ };
93
+ const ChoiceBody = (props) => {
94
+ const layoutClass = () => {
95
+ switch (props.config.layout) {
96
+ case "vertical":
97
+ return "flex flex-col gap-2";
98
+ case "grid":
99
+ return "grid grid-cols-2 gap-2";
100
+ default:
101
+ return "flex flex-wrap gap-2";
102
+ }
103
+ };
104
+ return (() => {
105
+ var _el$6 = web.getNextElement(_tmpl$2);
106
+ web.insert(_el$6, web.createComponent(solidJs.For, {
107
+ get each() {
108
+ return props.config.options;
109
+ },
110
+ children: (option) => (() => {
111
+ var _el$7 = web.getNextElement(_tmpl$5), _el$0 = _el$7.firstChild, [_el$1, _co$] = web.getNextMarker(_el$0.nextSibling), _el$10 = _el$1.nextSibling, [_el$11, _co$2] = web.getNextMarker(_el$10.nextSibling), _el$12 = _el$11.nextSibling, [_el$13, _co$3] = web.getNextMarker(_el$12.nextSibling);
112
+ _el$7.$$click = () => props.onSelect(option.value, option.label);
113
+ web.insert(_el$7, web.createComponent(solidJs.Show, {
114
+ get when() {
115
+ return option.icon;
116
+ },
117
+ get children() {
118
+ var _el$8 = web.getNextElement(_tmpl$3);
119
+ web.insert(_el$8, () => option.icon);
120
+ return _el$8;
121
+ }
122
+ }), _el$1, _co$);
123
+ web.insert(_el$7, () => option.label, _el$11, _co$2);
124
+ web.insert(_el$7, web.createComponent(solidJs.Show, {
125
+ get when() {
126
+ return option.description;
127
+ },
128
+ get children() {
129
+ var _el$9 = web.getNextElement(_tmpl$4);
130
+ web.insert(_el$9, () => option.description);
131
+ return _el$9;
132
+ }
133
+ }), _el$13, _co$3);
134
+ web.runHydrationEvents();
135
+ return _el$7;
136
+ })()
137
+ }));
138
+ web.effect(() => web.className(_el$6, layoutClass()));
139
+ return _el$6;
140
+ })();
141
+ };
142
+ const ConfirmBody = (props) => {
143
+ const isDanger = () => props.config.variant === "danger";
144
+ return (() => {
145
+ var _el$14 = web.getNextElement(_tmpl$7), _el$19 = _el$14.firstChild, [_el$20, _co$4] = web.getNextMarker(_el$19.nextSibling), _el$16 = _el$20.nextSibling, _el$17 = _el$16.firstChild, _el$18 = _el$17.nextSibling;
146
+ web.insert(_el$14, web.createComponent(solidJs.Show, {
147
+ get when() {
148
+ return props.config.message;
149
+ },
150
+ get children() {
151
+ var _el$15 = web.getNextElement(_tmpl$6);
152
+ web.insert(_el$15, () => props.config.message);
153
+ return _el$15;
154
+ }
155
+ }), _el$20, _co$4);
156
+ web.addEventListener(_el$17, "click", props.onCancel, true);
157
+ web.insert(_el$17, () => props.config.cancelLabel || "Cancel");
158
+ web.addEventListener(_el$18, "click", props.onConfirm, true);
159
+ web.insert(_el$18, () => props.config.confirmLabel || "Confirm");
160
+ web.effect(() => web.className(_el$18, `px-4 py-2 text-sm font-medium rounded-lg text-white transition-colors ${isDanger() ? "bg-red-600 hover:bg-red-700" : "bg-blue-600 hover:bg-blue-700"}`));
161
+ web.runHydrationEvents();
162
+ return _el$14;
163
+ })();
164
+ };
165
+ const FormBody = (props) => {
166
+ const [formData, setFormData] = solidJs.createSignal({});
167
+ const updateField = (name, value) => {
168
+ setFormData((prev) => ({
169
+ ...prev,
170
+ [name]: value
171
+ }));
172
+ };
173
+ const handleSubmit = (e) => {
174
+ e.preventDefault();
175
+ const data = formData();
176
+ const label = Object.entries(data).filter(([, v]) => v).map(([k, v]) => `${k}: ${v}`).join(", ");
177
+ props.onSubmit(data, label || "Form submitted");
178
+ };
179
+ const isValid = () => {
180
+ const data = formData();
181
+ return (props.config.fields || []).filter((f) => f.required).every((f) => {
182
+ var _a;
183
+ return (_a = data[f.name]) == null ? void 0 : _a.trim();
184
+ });
185
+ };
186
+ return (() => {
187
+ var _el$21 = web.getNextElement(_tmpl$8), _el$24 = _el$21.firstChild, [_el$25, _co$5] = web.getNextMarker(_el$24.nextSibling), _el$22 = _el$25.nextSibling, _el$23 = _el$22.firstChild;
188
+ _el$21.addEventListener("submit", handleSubmit);
189
+ web.insert(_el$21, web.createComponent(solidJs.For, {
190
+ get each() {
191
+ return props.config.fields;
192
+ },
193
+ children: (field) => (() => {
194
+ var _el$26 = web.getNextElement(_tmpl$11), _el$27 = _el$26.firstChild, _el$29 = _el$27.firstChild, [_el$30, _co$6] = web.getNextMarker(_el$29.nextSibling), _el$31 = _el$30.nextSibling, [_el$32, _co$7] = web.getNextMarker(_el$31.nextSibling), _el$39 = _el$27.nextSibling, [_el$40, _co$9] = web.getNextMarker(_el$39.nextSibling);
195
+ web.insert(_el$27, () => field.label, _el$30, _co$6);
196
+ web.insert(_el$27, web.createComponent(solidJs.Show, {
197
+ get when() {
198
+ return field.required;
199
+ },
200
+ get children() {
201
+ return web.getNextElement(_tmpl$9);
202
+ }
203
+ }), _el$32, _co$7);
204
+ web.insert(_el$26, web.createComponent(solidJs.Switch, {
205
+ get children() {
206
+ return [web.createComponent(solidJs.Match, {
207
+ get when() {
208
+ return field.type === "textarea";
209
+ },
210
+ get children() {
211
+ var _el$33 = web.getNextElement(_tmpl$0);
212
+ _el$33.$$input = (e) => updateField(field.name, e.currentTarget.value);
213
+ web.effect(() => web.setAttribute(_el$33, "placeholder", field.placeholder));
214
+ web.effect(() => web.setProperty(_el$33, "value", formData()[field.name] || ""));
215
+ web.runHydrationEvents();
216
+ return _el$33;
217
+ }
218
+ }), web.createComponent(solidJs.Match, {
219
+ get when() {
220
+ return field.type === "select";
221
+ },
222
+ get children() {
223
+ var _el$34 = web.getNextElement(_tmpl$1), _el$35 = _el$34.firstChild, _el$36 = _el$35.nextSibling, [_el$37, _co$8] = web.getNextMarker(_el$36.nextSibling);
224
+ _el$34.addEventListener("change", (e) => updateField(field.name, e.currentTarget.value));
225
+ web.insert(_el$35, () => field.placeholder || "Select...");
226
+ web.insert(_el$34, web.createComponent(solidJs.For, {
227
+ get each() {
228
+ return field.options;
229
+ },
230
+ children: (opt) => (() => {
231
+ var _el$41 = web.getNextElement(_tmpl$12);
232
+ web.insert(_el$41, () => opt.label);
233
+ web.effect(() => web.setProperty(_el$41, "value", opt.value));
234
+ return _el$41;
235
+ })()
236
+ }), _el$37, _co$8);
237
+ web.effect(() => web.setProperty(_el$34, "value", formData()[field.name] || ""));
238
+ return _el$34;
239
+ }
240
+ }), web.createComponent(solidJs.Match, {
241
+ when: true,
242
+ get children() {
243
+ var _el$38 = web.getNextElement(_tmpl$10);
244
+ _el$38.$$input = (e) => updateField(field.name, e.currentTarget.value);
245
+ web.effect((_p$) => {
246
+ var _v$ = field.type === "number" ? "number" : "text", _v$2 = field.placeholder;
247
+ _v$ !== _p$.e && web.setAttribute(_el$38, "type", _p$.e = _v$);
248
+ _v$2 !== _p$.t && web.setAttribute(_el$38, "placeholder", _p$.t = _v$2);
249
+ return _p$;
250
+ }, {
251
+ e: void 0,
252
+ t: void 0
253
+ });
254
+ web.effect(() => web.setProperty(_el$38, "value", formData()[field.name] || ""));
255
+ web.runHydrationEvents();
256
+ return _el$38;
257
+ }
258
+ })];
259
+ }
260
+ }), _el$40, _co$9);
261
+ return _el$26;
262
+ })()
263
+ }), _el$25, _co$5);
264
+ web.insert(_el$23, () => props.config.submitLabel || "Submit");
265
+ web.effect(() => web.setProperty(_el$23, "disabled", !isValid()));
266
+ return _el$21;
267
+ })();
268
+ };
269
+ web.delegateEvents(["click", "input"]);
270
+ exports.ChatPrompt = ChatPrompt;
271
+ //# sourceMappingURL=ChatPrompt.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatPrompt.cjs","sources":["../../src/components/ChatPrompt.tsx"],"sourcesContent":["/**\n * ChatPrompt — Ephemeral structured interaction above chat input\n * v2.4.0: choice, confirm, form subtypes\n *\n * @experimental — This component may change without major bump until v2.5.0.\n *\n * Renders above the chat input. User responds → Promise resolves → prompt disappears.\n * Supports AbortSignal for cleanup on navigation (C4).\n */\n\nimport { Component, Show, For, createSignal, onCleanup, Switch, Match } from 'solid-js'\nimport type {\n ChatPromptConfig,\n ChatPromptResponse,\n ChoicePromptConfig,\n ConfirmPromptConfig,\n FormPromptConfig,\n} from '../types/chat-bus'\n\nexport interface ChatPromptProps {\n /** Prompt configuration */\n config: ChatPromptConfig\n /** Called when user responds */\n onSubmit: (response: ChatPromptResponse) => void\n /** Called when user dismisses */\n onDismiss?: () => void\n}\n\n/**\n * @experimental\n * Ephemeral interaction component — choice buttons, confirmation dialog, or quick form.\n * Designed to sit between the chat messages and the input area.\n *\n * @example\n * <ChatPrompt\n * config={{ type: 'choice', title: 'Format?', config: { options: [...] } }}\n * onSubmit={(r) => bus.events.emit('onChatPromptResponse', { streamKey, response: r })}\n * onDismiss={() => setActivePrompt(null)}\n * />\n */\nexport const ChatPrompt: Component<ChatPromptProps> = (props) => {\n return (\n <div\n class=\"w-full max-w-2xl mx-auto mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg overflow-hidden\"\n style={{ animation: 'chat-prompt-slide-up 0.2s ease-out' }}\n role=\"dialog\"\n aria-label={props.config.title}\n >\n {/* Header */}\n <div class=\"flex items-center justify-between px-4 py-2.5 border-b border-gray-100 dark:border-gray-700\">\n <p class=\"text-sm font-medium text-gray-900 dark:text-white\">{props.config.title}</p>\n <button\n onClick={() => {\n props.onDismiss?.()\n props.onSubmit({ type: props.config.type, value: '', label: '', dismissed: true })\n }}\n class=\"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors\"\n aria-label=\"Dismiss\"\n >\n <svg class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n </div>\n\n {/* Body — type-specific */}\n <div class=\"px-4 py-3\">\n <Switch>\n <Match when={props.config.type === 'choice'}>\n <ChoiceBody\n config={props.config.config as ChoicePromptConfig}\n onSelect={(value, label) => props.onSubmit({ type: 'choice', value, label })}\n />\n </Match>\n <Match when={props.config.type === 'confirm'}>\n <ConfirmBody\n config={props.config.config as ConfirmPromptConfig}\n onConfirm={() => props.onSubmit({ type: 'confirm', value: 'confirmed', label: (props.config.config as ConfirmPromptConfig).confirmLabel || 'Confirmed' })}\n onCancel={() => {\n props.onDismiss?.()\n props.onSubmit({ type: 'confirm', value: 'cancelled', label: (props.config.config as ConfirmPromptConfig).cancelLabel || 'Cancelled', dismissed: true })\n }}\n />\n </Match>\n <Match when={props.config.type === 'form'}>\n <FormBody\n config={props.config.config as FormPromptConfig}\n onSubmit={(data, label) => props.onSubmit({ type: 'form', value: data, label })}\n />\n </Match>\n </Switch>\n </div>\n\n <style>{`\n @keyframes chat-prompt-slide-up {\n from { opacity: 0; transform: translateY(8px); }\n to { opacity: 1; transform: translateY(0); }\n }\n `}</style>\n </div>\n )\n}\n\n// ─── Choice ──────────────────────────────────────────────────\n\nconst ChoiceBody: Component<{\n config: ChoicePromptConfig\n onSelect: (value: string, label: string) => void\n}> = (props) => {\n const layoutClass = () => {\n switch (props.config.layout) {\n case 'vertical': return 'flex flex-col gap-2'\n case 'grid': return 'grid grid-cols-2 gap-2'\n default: return 'flex flex-wrap gap-2'\n }\n }\n\n return (\n <div class={layoutClass()}>\n <For each={props.config.options}>\n {(option) => (\n <button\n onClick={() => props.onSelect(option.value, option.label)}\n class=\"px-4 py-2 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white hover:bg-blue-50 hover:border-blue-300 dark:hover:bg-blue-900/30 dark:hover:border-blue-600 transition-colors text-left\"\n >\n <Show when={option.icon}>\n <span class=\"mr-2\">{option.icon}</span>\n </Show>\n {option.label}\n <Show when={option.description}>\n <span class=\"block text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal\">{option.description}</span>\n </Show>\n </button>\n )}\n </For>\n </div>\n )\n}\n\n// ─── Confirm ─────────────────────────────────────────────────\n\nconst ConfirmBody: Component<{\n config: ConfirmPromptConfig\n onConfirm: () => void\n onCancel: () => void\n}> = (props) => {\n const isDanger = () => props.config.variant === 'danger'\n\n return (\n <div>\n <Show when={props.config.message}>\n <p class=\"text-sm text-gray-600 dark:text-gray-400 mb-3\">{props.config.message}</p>\n </Show>\n <div class=\"flex gap-2 justify-end\">\n <button\n onClick={props.onCancel}\n class=\"px-4 py-2 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors\"\n >\n {props.config.cancelLabel || 'Cancel'}\n </button>\n <button\n onClick={props.onConfirm}\n class={`px-4 py-2 text-sm font-medium rounded-lg text-white transition-colors ${\n isDanger()\n ? 'bg-red-600 hover:bg-red-700'\n : 'bg-blue-600 hover:bg-blue-700'\n }`}\n >\n {props.config.confirmLabel || 'Confirm'}\n </button>\n </div>\n </div>\n )\n}\n\n// ─── Form ────────────────────────────────────────────────────\n\nconst FormBody: Component<{\n config: FormPromptConfig\n onSubmit: (data: Record<string, unknown>, label: string) => void\n}> = (props) => {\n const [formData, setFormData] = createSignal<Record<string, string>>({})\n\n const updateField = (name: string, value: string) => {\n setFormData((prev) => ({ ...prev, [name]: value }))\n }\n\n const handleSubmit = (e: Event) => {\n e.preventDefault()\n const data = formData()\n // Build a human-readable label from the form values\n const label = Object.entries(data)\n .filter(([, v]) => v)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')\n props.onSubmit(data, label || 'Form submitted')\n }\n\n const isValid = () => {\n const data = formData()\n return (props.config.fields || [])\n .filter((f) => f.required)\n .every((f) => data[f.name]?.trim())\n }\n\n return (\n <form onSubmit={handleSubmit} class=\"flex flex-col gap-3\">\n <For each={props.config.fields}>\n {(field) => (\n <div>\n <label class=\"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1\">\n {field.label}\n <Show when={field.required}>\n <span class=\"text-red-500 ml-0.5\">*</span>\n </Show>\n </label>\n <Switch>\n <Match when={field.type === 'textarea'}>\n <textarea\n value={formData()[field.name] || ''}\n onInput={(e) => updateField(field.name, e.currentTarget.value)}\n placeholder={field.placeholder}\n rows={3}\n class=\"w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors\"\n />\n </Match>\n <Match when={field.type === 'select'}>\n <select\n value={formData()[field.name] || ''}\n onChange={(e) => updateField(field.name, e.currentTarget.value)}\n class=\"w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors\"\n >\n <option value=\"\">{field.placeholder || 'Select...'}</option>\n <For each={field.options}>\n {(opt) => <option value={opt.value}>{opt.label}</option>}\n </For>\n </select>\n </Match>\n <Match when={true}>\n <input\n type={field.type === 'number' ? 'number' : 'text'}\n value={formData()[field.name] || ''}\n onInput={(e) => updateField(field.name, e.currentTarget.value)}\n placeholder={field.placeholder}\n class=\"w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors\"\n />\n </Match>\n </Switch>\n </div>\n )}\n </For>\n <div class=\"flex justify-end\">\n <button\n type=\"submit\"\n disabled={!isValid()}\n class=\"px-4 py-2 text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed transition-colors\"\n >\n {props.config.submitLabel || 'Submit'}\n </button>\n </div>\n </form>\n )\n}\n"],"names":["ChatPrompt","props","_el$","_$getNextElement","_tmpl$","_el$2","firstChild","_el$3","_el$4","nextSibling","_el$5","_$insert","config","title","$$click","onDismiss","onSubmit","type","value","label","dismissed","_$createComponent","Switch","children","Match","when","ChoiceBody","onSelect","ConfirmBody","onConfirm","confirmLabel","onCancel","cancelLabel","FormBody","data","_$effect","_$setAttribute","_$runHydrationEvents","layoutClass","layout","_el$6","_tmpl$2","For","each","options","option","_el$7","_tmpl$5","_el$0","_el$1","_co$","_$getNextMarker","_el$10","_el$11","_co$2","_el$12","_el$13","_co$3","Show","icon","_el$8","_tmpl$3","description","_el$9","_tmpl$4","_$className","isDanger","variant","_el$14","_tmpl$7","_el$19","_el$20","_co$4","_el$16","_el$17","_el$18","message","_el$15","_tmpl$6","_$addEventListener","formData","setFormData","createSignal","updateField","name","prev","handleSubmit","e","preventDefault","Object","entries","filter","v","map","k","join","isValid","fields","f","required","every","trim","_el$21","_tmpl$8","_el$24","_el$25","_co$5","_el$22","_el$23","addEventListener","field","_el$26","_tmpl$11","_el$27","_el$29","_el$30","_co$6","_el$31","_el$32","_co$7","_el$39","_el$40","_co$9","_tmpl$9","_el$33","_tmpl$0","$$input","currentTarget","placeholder","_$setProperty","_el$34","_tmpl$1","_el$35","_el$36","_el$37","_co$8","opt","_el$41","_tmpl$12","_el$38","_tmpl$10","_p$","_v$","_v$2","t","undefined","submitLabel","_$delegateEvents"],"mappings":";;;;;;;;;;AAwCO,MAAMA,aAA0CC,CAAAA,UAAU;AAC/D,UAAA,MAAA;AAAA,QAAAC,OAAAC,IAAAA,eAAAC,MAAA,GAAAC,QAAAH,KAAAI,YAAAC,QAAAF,MAAAC,YAAAE,QAAAD,MAAAE,aAAAC,QAAAL,MAAAI;AAAAE,QAAAA,OAAAJ,OAAA,MASoEN,MAAMW,OAAOC,KAAK;AAAAL,UAAAM,UAErE,MAAM;;AACbb,kBAAMc,cAANd;AACAA,YAAMe,SAAS;AAAA,QAAEC,MAAMhB,MAAMW,OAAOK;AAAAA,QAAMC,OAAO;AAAA,QAAIC,OAAO;AAAA,QAAIC,WAAW;AAAA,MAAA,CAAM;AAAA,IACnF;AAACT,eAAAD,OAAAW,IAAAA,gBAYFC,gBAAM;AAAA,MAAA,IAAAC,WAAA;AAAA,eAAA,CAAAF,IAAAA,gBACJG,eAAK;AAAA,UAAA,IAACC,OAAI;AAAA,mBAAExB,MAAMW,OAAOK,SAAS;AAAA,UAAQ;AAAA,UAAA,IAAAM,WAAA;AAAA,mBAAAF,IAAAA,gBACxCK,YAAU;AAAA,cAAA,IACTd,SAAM;AAAA,uBAAEX,MAAMW,OAAOA;AAAAA,cAA4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2
+ * ChatPrompt — Ephemeral structured interaction above chat input
3
+ * v2.4.0: choice, confirm, form subtypes
4
+ *
5
+ * @experimental — This component may change without major bump until v2.5.0.
6
+ *
7
+ * Renders above the chat input. User responds → Promise resolves → prompt disappears.
8
+ * Supports AbortSignal for cleanup on navigation (C4).
9
+ */
10
+ import { Component } from 'solid-js';
11
+ import type { ChatPromptConfig, ChatPromptResponse } from '../types/chat-bus';
12
+ export interface ChatPromptProps {
13
+ /** Prompt configuration */
14
+ config: ChatPromptConfig;
15
+ /** Called when user responds */
16
+ onSubmit: (response: ChatPromptResponse) => void;
17
+ /** Called when user dismisses */
18
+ onDismiss?: () => void;
19
+ }
20
+ /**
21
+ * @experimental
22
+ * Ephemeral interaction component — choice buttons, confirmation dialog, or quick form.
23
+ * Designed to sit between the chat messages and the input area.
24
+ *
25
+ * @example
26
+ * <ChatPrompt
27
+ * config={{ type: 'choice', title: 'Format?', config: { options: [...] } }}
28
+ * onSubmit={(r) => bus.events.emit('onChatPromptResponse', { streamKey, response: r })}
29
+ * onDismiss={() => setActivePrompt(null)}
30
+ * />
31
+ */
32
+ export declare const ChatPrompt: Component<ChatPromptProps>;
33
+ //# sourceMappingURL=ChatPrompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatPrompt.d.ts","sourceRoot":"","sources":["../../src/components/ChatPrompt.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAqD,MAAM,UAAU,CAAA;AACvF,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAInB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,MAAM,EAAE,gBAAgB,CAAA;IACxB,gCAAgC;IAChC,QAAQ,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAChD,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,CAAC,eAAe,CA6DjD,CAAA"}
@@ -0,0 +1,271 @@
1
+ import { delegateEvents, getNextElement, template, insert, createComponent, effect, setAttribute, runHydrationEvents, getNextMarker, className, addEventListener, setProperty } from "solid-js/web";
2
+ import { Switch, Match, For, Show, createSignal } from "solid-js";
3
+ var _tmpl$ = /* @__PURE__ */ template(`<div class="w-full max-w-2xl mx-auto mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg overflow-hidden"role=dialog style="animation:chat-prompt-slide-up 0.2s ease-out"><div class="flex items-center justify-between px-4 py-2.5 border-b border-gray-100 dark:border-gray-700"><p class="text-sm font-medium text-gray-900 dark:text-white"></p><button class="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"aria-label=Dismiss><svg class="w-4 h-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M6 18L18 6M6 6l12 12"></path></svg></button></div><div class="px-4 py-3"></div><style>
4
+ @keyframes chat-prompt-slide-up {
5
+ from { opacity: 0; transform: translateY(8px); }
6
+ to { opacity: 1; transform: translateY(0); }
7
+ }
8
+ `), _tmpl$2 = /* @__PURE__ */ template(`<div>`), _tmpl$3 = /* @__PURE__ */ template(`<span class=mr-2>`), _tmpl$4 = /* @__PURE__ */ template(`<span class="block text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal">`), _tmpl$5 = /* @__PURE__ */ template(`<button class="px-4 py-2 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white hover:bg-blue-50 hover:border-blue-300 dark:hover:bg-blue-900/30 dark:hover:border-blue-600 transition-colors text-left"><!$><!/><!$><!/><!$><!/>`), _tmpl$6 = /* @__PURE__ */ template(`<p class="text-sm text-gray-600 dark:text-gray-400 mb-3">`), _tmpl$7 = /* @__PURE__ */ template(`<div><!$><!/><div class="flex gap-2 justify-end"><button class="px-4 py-2 text-sm font-medium rounded-lg border border-gray-200 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"></button><button>`), _tmpl$8 = /* @__PURE__ */ template(`<form class="flex flex-col gap-3"><!$><!/><div class="flex justify-end"><button type=submit class="px-4 py-2 text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed transition-colors">`), _tmpl$9 = /* @__PURE__ */ template(`<span class="text-red-500 ml-0.5">*`), _tmpl$0 = /* @__PURE__ */ template(`<textarea rows=3 class="w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors">`), _tmpl$1 = /* @__PURE__ */ template(`<select class="w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors"><option value></option><!$><!/>`), _tmpl$10 = /* @__PURE__ */ template(`<input class="w-full px-3 py-2 text-sm rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:border-blue-400 focus:ring-1 focus:ring-blue-400 outline-none transition-colors">`), _tmpl$11 = /* @__PURE__ */ template(`<div><label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1"><!$><!/><!$><!/></label><!$><!/>`), _tmpl$12 = /* @__PURE__ */ template(`<option>`);
9
+ const ChatPrompt = (props) => {
10
+ return (() => {
11
+ var _el$ = getNextElement(_tmpl$), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$2.nextSibling;
12
+ insert(_el$3, () => props.config.title);
13
+ _el$4.$$click = () => {
14
+ var _a;
15
+ (_a = props.onDismiss) == null ? void 0 : _a.call(props);
16
+ props.onSubmit({
17
+ type: props.config.type,
18
+ value: "",
19
+ label: "",
20
+ dismissed: true
21
+ });
22
+ };
23
+ insert(_el$5, createComponent(Switch, {
24
+ get children() {
25
+ return [createComponent(Match, {
26
+ get when() {
27
+ return props.config.type === "choice";
28
+ },
29
+ get children() {
30
+ return createComponent(ChoiceBody, {
31
+ get config() {
32
+ return props.config.config;
33
+ },
34
+ onSelect: (value, label) => props.onSubmit({
35
+ type: "choice",
36
+ value,
37
+ label
38
+ })
39
+ });
40
+ }
41
+ }), createComponent(Match, {
42
+ get when() {
43
+ return props.config.type === "confirm";
44
+ },
45
+ get children() {
46
+ return createComponent(ConfirmBody, {
47
+ get config() {
48
+ return props.config.config;
49
+ },
50
+ onConfirm: () => props.onSubmit({
51
+ type: "confirm",
52
+ value: "confirmed",
53
+ label: props.config.config.confirmLabel || "Confirmed"
54
+ }),
55
+ onCancel: () => {
56
+ var _a;
57
+ (_a = props.onDismiss) == null ? void 0 : _a.call(props);
58
+ props.onSubmit({
59
+ type: "confirm",
60
+ value: "cancelled",
61
+ label: props.config.config.cancelLabel || "Cancelled",
62
+ dismissed: true
63
+ });
64
+ }
65
+ });
66
+ }
67
+ }), createComponent(Match, {
68
+ get when() {
69
+ return props.config.type === "form";
70
+ },
71
+ get children() {
72
+ return createComponent(FormBody, {
73
+ get config() {
74
+ return props.config.config;
75
+ },
76
+ onSubmit: (data, label) => props.onSubmit({
77
+ type: "form",
78
+ value: data,
79
+ label
80
+ })
81
+ });
82
+ }
83
+ })];
84
+ }
85
+ }));
86
+ effect(() => setAttribute(_el$, "aria-label", props.config.title));
87
+ runHydrationEvents();
88
+ return _el$;
89
+ })();
90
+ };
91
+ const ChoiceBody = (props) => {
92
+ const layoutClass = () => {
93
+ switch (props.config.layout) {
94
+ case "vertical":
95
+ return "flex flex-col gap-2";
96
+ case "grid":
97
+ return "grid grid-cols-2 gap-2";
98
+ default:
99
+ return "flex flex-wrap gap-2";
100
+ }
101
+ };
102
+ return (() => {
103
+ var _el$6 = getNextElement(_tmpl$2);
104
+ insert(_el$6, createComponent(For, {
105
+ get each() {
106
+ return props.config.options;
107
+ },
108
+ children: (option) => (() => {
109
+ var _el$7 = getNextElement(_tmpl$5), _el$0 = _el$7.firstChild, [_el$1, _co$] = getNextMarker(_el$0.nextSibling), _el$10 = _el$1.nextSibling, [_el$11, _co$2] = getNextMarker(_el$10.nextSibling), _el$12 = _el$11.nextSibling, [_el$13, _co$3] = getNextMarker(_el$12.nextSibling);
110
+ _el$7.$$click = () => props.onSelect(option.value, option.label);
111
+ insert(_el$7, createComponent(Show, {
112
+ get when() {
113
+ return option.icon;
114
+ },
115
+ get children() {
116
+ var _el$8 = getNextElement(_tmpl$3);
117
+ insert(_el$8, () => option.icon);
118
+ return _el$8;
119
+ }
120
+ }), _el$1, _co$);
121
+ insert(_el$7, () => option.label, _el$11, _co$2);
122
+ insert(_el$7, createComponent(Show, {
123
+ get when() {
124
+ return option.description;
125
+ },
126
+ get children() {
127
+ var _el$9 = getNextElement(_tmpl$4);
128
+ insert(_el$9, () => option.description);
129
+ return _el$9;
130
+ }
131
+ }), _el$13, _co$3);
132
+ runHydrationEvents();
133
+ return _el$7;
134
+ })()
135
+ }));
136
+ effect(() => className(_el$6, layoutClass()));
137
+ return _el$6;
138
+ })();
139
+ };
140
+ const ConfirmBody = (props) => {
141
+ const isDanger = () => props.config.variant === "danger";
142
+ return (() => {
143
+ var _el$14 = getNextElement(_tmpl$7), _el$19 = _el$14.firstChild, [_el$20, _co$4] = getNextMarker(_el$19.nextSibling), _el$16 = _el$20.nextSibling, _el$17 = _el$16.firstChild, _el$18 = _el$17.nextSibling;
144
+ insert(_el$14, createComponent(Show, {
145
+ get when() {
146
+ return props.config.message;
147
+ },
148
+ get children() {
149
+ var _el$15 = getNextElement(_tmpl$6);
150
+ insert(_el$15, () => props.config.message);
151
+ return _el$15;
152
+ }
153
+ }), _el$20, _co$4);
154
+ addEventListener(_el$17, "click", props.onCancel, true);
155
+ insert(_el$17, () => props.config.cancelLabel || "Cancel");
156
+ addEventListener(_el$18, "click", props.onConfirm, true);
157
+ insert(_el$18, () => props.config.confirmLabel || "Confirm");
158
+ effect(() => className(_el$18, `px-4 py-2 text-sm font-medium rounded-lg text-white transition-colors ${isDanger() ? "bg-red-600 hover:bg-red-700" : "bg-blue-600 hover:bg-blue-700"}`));
159
+ runHydrationEvents();
160
+ return _el$14;
161
+ })();
162
+ };
163
+ const FormBody = (props) => {
164
+ const [formData, setFormData] = createSignal({});
165
+ const updateField = (name, value) => {
166
+ setFormData((prev) => ({
167
+ ...prev,
168
+ [name]: value
169
+ }));
170
+ };
171
+ const handleSubmit = (e) => {
172
+ e.preventDefault();
173
+ const data = formData();
174
+ const label = Object.entries(data).filter(([, v]) => v).map(([k, v]) => `${k}: ${v}`).join(", ");
175
+ props.onSubmit(data, label || "Form submitted");
176
+ };
177
+ const isValid = () => {
178
+ const data = formData();
179
+ return (props.config.fields || []).filter((f) => f.required).every((f) => {
180
+ var _a;
181
+ return (_a = data[f.name]) == null ? void 0 : _a.trim();
182
+ });
183
+ };
184
+ return (() => {
185
+ var _el$21 = getNextElement(_tmpl$8), _el$24 = _el$21.firstChild, [_el$25, _co$5] = getNextMarker(_el$24.nextSibling), _el$22 = _el$25.nextSibling, _el$23 = _el$22.firstChild;
186
+ _el$21.addEventListener("submit", handleSubmit);
187
+ insert(_el$21, createComponent(For, {
188
+ get each() {
189
+ return props.config.fields;
190
+ },
191
+ children: (field) => (() => {
192
+ var _el$26 = getNextElement(_tmpl$11), _el$27 = _el$26.firstChild, _el$29 = _el$27.firstChild, [_el$30, _co$6] = getNextMarker(_el$29.nextSibling), _el$31 = _el$30.nextSibling, [_el$32, _co$7] = getNextMarker(_el$31.nextSibling), _el$39 = _el$27.nextSibling, [_el$40, _co$9] = getNextMarker(_el$39.nextSibling);
193
+ insert(_el$27, () => field.label, _el$30, _co$6);
194
+ insert(_el$27, createComponent(Show, {
195
+ get when() {
196
+ return field.required;
197
+ },
198
+ get children() {
199
+ return getNextElement(_tmpl$9);
200
+ }
201
+ }), _el$32, _co$7);
202
+ insert(_el$26, createComponent(Switch, {
203
+ get children() {
204
+ return [createComponent(Match, {
205
+ get when() {
206
+ return field.type === "textarea";
207
+ },
208
+ get children() {
209
+ var _el$33 = getNextElement(_tmpl$0);
210
+ _el$33.$$input = (e) => updateField(field.name, e.currentTarget.value);
211
+ effect(() => setAttribute(_el$33, "placeholder", field.placeholder));
212
+ effect(() => setProperty(_el$33, "value", formData()[field.name] || ""));
213
+ runHydrationEvents();
214
+ return _el$33;
215
+ }
216
+ }), createComponent(Match, {
217
+ get when() {
218
+ return field.type === "select";
219
+ },
220
+ get children() {
221
+ var _el$34 = getNextElement(_tmpl$1), _el$35 = _el$34.firstChild, _el$36 = _el$35.nextSibling, [_el$37, _co$8] = getNextMarker(_el$36.nextSibling);
222
+ _el$34.addEventListener("change", (e) => updateField(field.name, e.currentTarget.value));
223
+ insert(_el$35, () => field.placeholder || "Select...");
224
+ insert(_el$34, createComponent(For, {
225
+ get each() {
226
+ return field.options;
227
+ },
228
+ children: (opt) => (() => {
229
+ var _el$41 = getNextElement(_tmpl$12);
230
+ insert(_el$41, () => opt.label);
231
+ effect(() => setProperty(_el$41, "value", opt.value));
232
+ return _el$41;
233
+ })()
234
+ }), _el$37, _co$8);
235
+ effect(() => setProperty(_el$34, "value", formData()[field.name] || ""));
236
+ return _el$34;
237
+ }
238
+ }), createComponent(Match, {
239
+ when: true,
240
+ get children() {
241
+ var _el$38 = getNextElement(_tmpl$10);
242
+ _el$38.$$input = (e) => updateField(field.name, e.currentTarget.value);
243
+ effect((_p$) => {
244
+ var _v$ = field.type === "number" ? "number" : "text", _v$2 = field.placeholder;
245
+ _v$ !== _p$.e && setAttribute(_el$38, "type", _p$.e = _v$);
246
+ _v$2 !== _p$.t && setAttribute(_el$38, "placeholder", _p$.t = _v$2);
247
+ return _p$;
248
+ }, {
249
+ e: void 0,
250
+ t: void 0
251
+ });
252
+ effect(() => setProperty(_el$38, "value", formData()[field.name] || ""));
253
+ runHydrationEvents();
254
+ return _el$38;
255
+ }
256
+ })];
257
+ }
258
+ }), _el$40, _co$9);
259
+ return _el$26;
260
+ })()
261
+ }), _el$25, _co$5);
262
+ insert(_el$23, () => props.config.submitLabel || "Submit");
263
+ effect(() => setProperty(_el$23, "disabled", !isValid()));
264
+ return _el$21;
265
+ })();
266
+ };
267
+ delegateEvents(["click", "input"]);
268
+ export {
269
+ ChatPrompt
270
+ };
271
+ //# sourceMappingURL=ChatPrompt.js.map