@mariozechner/pi-web-ui 0.5.44
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 +252 -0
- package/dist/ChatPanel.d.ts +23 -0
- package/dist/ChatPanel.d.ts.map +1 -0
- package/dist/ChatPanel.js +224 -0
- package/dist/ChatPanel.js.map +1 -0
- package/dist/app.css +2 -0
- package/dist/components/AgentInterface.d.ts +35 -0
- package/dist/components/AgentInterface.d.ts.map +1 -0
- package/dist/components/AgentInterface.js +308 -0
- package/dist/components/AgentInterface.js.map +1 -0
- package/dist/components/AttachmentTile.d.ts +12 -0
- package/dist/components/AttachmentTile.d.ts.map +1 -0
- package/dist/components/AttachmentTile.js +114 -0
- package/dist/components/AttachmentTile.js.map +1 -0
- package/dist/components/ConsoleBlock.d.ts +11 -0
- package/dist/components/ConsoleBlock.d.ts.map +1 -0
- package/dist/components/ConsoleBlock.js +77 -0
- package/dist/components/ConsoleBlock.js.map +1 -0
- package/dist/components/Input.d.ts +26 -0
- package/dist/components/Input.d.ts.map +1 -0
- package/dist/components/Input.js +56 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/MessageEditor.d.ts +38 -0
- package/dist/components/MessageEditor.d.ts.map +1 -0
- package/dist/components/MessageEditor.js +296 -0
- package/dist/components/MessageEditor.js.map +1 -0
- package/dist/components/MessageList.d.ts +13 -0
- package/dist/components/MessageList.d.ts.map +1 -0
- package/dist/components/MessageList.js +88 -0
- package/dist/components/MessageList.js.map +1 -0
- package/dist/components/Messages.d.ts +53 -0
- package/dist/components/Messages.d.ts.map +1 -0
- package/dist/components/Messages.js +323 -0
- package/dist/components/Messages.js.map +1 -0
- package/dist/components/ProviderKeyInput.d.ts +16 -0
- package/dist/components/ProviderKeyInput.d.ts.map +1 -0
- package/dist/components/ProviderKeyInput.js +183 -0
- package/dist/components/ProviderKeyInput.js.map +1 -0
- package/dist/components/SandboxedIframe.d.ts +63 -0
- package/dist/components/SandboxedIframe.d.ts.map +1 -0
- package/dist/components/SandboxedIframe.js +435 -0
- package/dist/components/SandboxedIframe.js.map +1 -0
- package/dist/components/StreamingMessageContainer.d.ts +17 -0
- package/dist/components/StreamingMessageContainer.d.ts.map +1 -0
- package/dist/components/StreamingMessageContainer.js +114 -0
- package/dist/components/StreamingMessageContainer.js.map +1 -0
- package/dist/dialogs/ApiKeyPromptDialog.d.ts +15 -0
- package/dist/dialogs/ApiKeyPromptDialog.d.ts.map +1 -0
- package/dist/dialogs/ApiKeyPromptDialog.js +80 -0
- package/dist/dialogs/ApiKeyPromptDialog.js.map +1 -0
- package/dist/dialogs/AttachmentOverlay.d.ts +32 -0
- package/dist/dialogs/AttachmentOverlay.d.ts.map +1 -0
- package/dist/dialogs/AttachmentOverlay.js +575 -0
- package/dist/dialogs/AttachmentOverlay.js.map +1 -0
- package/dist/dialogs/ModelSelector.d.ts +27 -0
- package/dist/dialogs/ModelSelector.d.ts.map +1 -0
- package/dist/dialogs/ModelSelector.js +334 -0
- package/dist/dialogs/ModelSelector.js.map +1 -0
- package/dist/dialogs/SettingsDialog.d.ts +31 -0
- package/dist/dialogs/SettingsDialog.d.ts.map +1 -0
- package/dist/dialogs/SettingsDialog.js +228 -0
- package/dist/dialogs/SettingsDialog.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/state/agent-session.d.ts +58 -0
- package/dist/state/agent-session.d.ts.map +1 -0
- package/dist/state/agent-session.js +252 -0
- package/dist/state/agent-session.js.map +1 -0
- package/dist/state/transports/AppTransport.d.ts +13 -0
- package/dist/state/transports/AppTransport.d.ts.map +1 -0
- package/dist/state/transports/AppTransport.js +316 -0
- package/dist/state/transports/AppTransport.js.map +1 -0
- package/dist/state/transports/ProviderTransport.d.ts +12 -0
- package/dist/state/transports/ProviderTransport.d.ts.map +1 -0
- package/dist/state/transports/ProviderTransport.js +44 -0
- package/dist/state/transports/ProviderTransport.js.map +1 -0
- package/dist/state/transports/index.d.ts +4 -0
- package/dist/state/transports/index.d.ts.map +1 -0
- package/dist/state/transports/index.js +4 -0
- package/dist/state/transports/index.js.map +1 -0
- package/dist/state/transports/proxy-types.d.ts +48 -0
- package/dist/state/transports/proxy-types.d.ts.map +1 -0
- package/dist/state/transports/proxy-types.js +2 -0
- package/dist/state/transports/proxy-types.js.map +1 -0
- package/dist/state/transports/types.d.ts +11 -0
- package/dist/state/transports/types.d.ts.map +1 -0
- package/dist/state/transports/types.js +2 -0
- package/dist/state/transports/types.js.map +1 -0
- package/dist/state/types.d.ts +15 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/types.js +2 -0
- package/dist/state/types.js.map +1 -0
- package/dist/storage/app-storage.d.ts +26 -0
- package/dist/storage/app-storage.d.ts.map +1 -0
- package/dist/storage/app-storage.js +44 -0
- package/dist/storage/app-storage.js.map +1 -0
- package/dist/storage/backends/chrome-storage-backend.d.ts +18 -0
- package/dist/storage/backends/chrome-storage-backend.d.ts.map +1 -0
- package/dist/storage/backends/chrome-storage-backend.js +67 -0
- package/dist/storage/backends/chrome-storage-backend.js.map +1 -0
- package/dist/storage/backends/indexeddb-backend.d.ts +20 -0
- package/dist/storage/backends/indexeddb-backend.d.ts.map +1 -0
- package/dist/storage/backends/indexeddb-backend.js +89 -0
- package/dist/storage/backends/indexeddb-backend.js.map +1 -0
- package/dist/storage/backends/local-storage-backend.d.ts +18 -0
- package/dist/storage/backends/local-storage-backend.d.ts.map +1 -0
- package/dist/storage/backends/local-storage-backend.js +69 -0
- package/dist/storage/backends/local-storage-backend.js.map +1 -0
- package/dist/storage/repositories/provider-keys-repository.d.ts +34 -0
- package/dist/storage/repositories/provider-keys-repository.d.ts.map +1 -0
- package/dist/storage/repositories/provider-keys-repository.js +50 -0
- package/dist/storage/repositories/provider-keys-repository.js.map +1 -0
- package/dist/storage/repositories/settings-repository.d.ts +34 -0
- package/dist/storage/repositories/settings-repository.d.ts.map +1 -0
- package/dist/storage/repositories/settings-repository.js +46 -0
- package/dist/storage/repositories/settings-repository.js.map +1 -0
- package/dist/storage/types.d.ts +43 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +2 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/tools/artifacts/ArtifactElement.d.ts +10 -0
- package/dist/tools/artifacts/ArtifactElement.d.ts.map +1 -0
- package/dist/tools/artifacts/ArtifactElement.js +12 -0
- package/dist/tools/artifacts/ArtifactElement.js.map +1 -0
- package/dist/tools/artifacts/HtmlArtifact.d.ts +30 -0
- package/dist/tools/artifacts/HtmlArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/HtmlArtifact.js +217 -0
- package/dist/tools/artifacts/HtmlArtifact.js.map +1 -0
- package/dist/tools/artifacts/MarkdownArtifact.d.ts +20 -0
- package/dist/tools/artifacts/MarkdownArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/MarkdownArtifact.js +84 -0
- package/dist/tools/artifacts/MarkdownArtifact.js.map +1 -0
- package/dist/tools/artifacts/SvgArtifact.d.ts +19 -0
- package/dist/tools/artifacts/SvgArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/SvgArtifact.js +80 -0
- package/dist/tools/artifacts/SvgArtifact.js.map +1 -0
- package/dist/tools/artifacts/TextArtifact.d.ts +20 -0
- package/dist/tools/artifacts/TextArtifact.d.ts.map +1 -0
- package/dist/tools/artifacts/TextArtifact.js +147 -0
- package/dist/tools/artifacts/TextArtifact.js.map +1 -0
- package/dist/tools/artifacts/artifacts.d.ts +67 -0
- package/dist/tools/artifacts/artifacts.d.ts.map +1 -0
- package/dist/tools/artifacts/artifacts.js +836 -0
- package/dist/tools/artifacts/artifacts.js.map +1 -0
- package/dist/tools/artifacts/index.d.ts +7 -0
- package/dist/tools/artifacts/index.d.ts.map +1 -0
- package/dist/tools/artifacts/index.js +7 -0
- package/dist/tools/artifacts/index.js.map +1 -0
- package/dist/tools/index.d.ts +14 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +29 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/javascript-repl.d.ts +43 -0
- package/dist/tools/javascript-repl.d.ts.map +1 -0
- package/dist/tools/javascript-repl.js +252 -0
- package/dist/tools/javascript-repl.js.map +1 -0
- package/dist/tools/renderer-registry.d.ts +11 -0
- package/dist/tools/renderer-registry.d.ts.map +1 -0
- package/dist/tools/renderer-registry.js +15 -0
- package/dist/tools/renderer-registry.js.map +1 -0
- package/dist/tools/renderers/BashRenderer.d.ts +12 -0
- package/dist/tools/renderers/BashRenderer.d.ts.map +1 -0
- package/dist/tools/renderers/BashRenderer.js +35 -0
- package/dist/tools/renderers/BashRenderer.js.map +1 -0
- package/dist/tools/renderers/CalculateRenderer.d.ts +12 -0
- package/dist/tools/renderers/CalculateRenderer.d.ts.map +1 -0
- package/dist/tools/renderers/CalculateRenderer.js +38 -0
- package/dist/tools/renderers/CalculateRenderer.js.map +1 -0
- package/dist/tools/renderers/DefaultRenderer.d.ts +8 -0
- package/dist/tools/renderers/DefaultRenderer.d.ts.map +1 -0
- package/dist/tools/renderers/DefaultRenderer.js +31 -0
- package/dist/tools/renderers/DefaultRenderer.js.map +1 -0
- package/dist/tools/renderers/GetCurrentTimeRenderer.d.ts +12 -0
- package/dist/tools/renderers/GetCurrentTimeRenderer.d.ts.map +1 -0
- package/dist/tools/renderers/GetCurrentTimeRenderer.js +30 -0
- package/dist/tools/renderers/GetCurrentTimeRenderer.js.map +1 -0
- package/dist/tools/types.d.ts +7 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/utils/attachment-utils.d.ts +19 -0
- package/dist/utils/attachment-utils.d.ts.map +1 -0
- package/dist/utils/attachment-utils.js +415 -0
- package/dist/utils/attachment-utils.js.map +1 -0
- package/dist/utils/auth-token.d.ts +3 -0
- package/dist/utils/auth-token.d.ts.map +1 -0
- package/dist/utils/auth-token.js +19 -0
- package/dist/utils/auth-token.js.map +1 -0
- package/dist/utils/format.d.ts +6 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +47 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/i18n.d.ts +111 -0
- package/dist/utils/i18n.d.ts.map +1 -0
- package/dist/utils/i18n.js +224 -0
- package/dist/utils/i18n.js.map +1 -0
- package/dist/utils/test-sessions.d.ts +347 -0
- package/dist/utils/test-sessions.d.ts.map +1 -0
- package/dist/utils/test-sessions.js +2215 -0
- package/dist/utils/test-sessions.js.map +1 -0
- package/example/README.md +61 -0
- package/example/index.html +13 -0
- package/example/package-lock.json +1965 -0
- package/example/package.json +22 -0
- package/example/src/app.css +1 -0
- package/example/src/main.ts +57 -0
- package/example/src/test-sessions.ts +104 -0
- package/example/tsconfig.json +15 -0
- package/example/vite.config.ts +6 -0
- package/package.json +45 -0
- package/src/ChatPanel.ts +214 -0
- package/src/app.css +44 -0
- package/src/components/AgentInterface.ts +316 -0
- package/src/components/AttachmentTile.ts +112 -0
- package/src/components/ConsoleBlock.ts +67 -0
- package/src/components/Input.ts +112 -0
- package/src/components/MessageEditor.ts +272 -0
- package/src/components/MessageList.ts +82 -0
- package/src/components/Messages.ts +310 -0
- package/src/components/ProviderKeyInput.ts +170 -0
- package/src/components/SandboxedIframe.ts +525 -0
- package/src/components/StreamingMessageContainer.ts +101 -0
- package/src/dialogs/ApiKeyPromptDialog.ts +76 -0
- package/src/dialogs/AttachmentOverlay.ts +635 -0
- package/src/dialogs/ModelSelector.ts +324 -0
- package/src/dialogs/SettingsDialog.ts +223 -0
- package/src/index.ts +63 -0
- package/src/state/agent-session.ts +311 -0
- package/src/state/transports/AppTransport.ts +363 -0
- package/src/state/transports/ProviderTransport.ts +49 -0
- package/src/state/transports/index.ts +3 -0
- package/src/state/transports/proxy-types.ts +15 -0
- package/src/state/transports/types.ts +16 -0
- package/src/state/types.ts +11 -0
- package/src/storage/app-storage.ts +53 -0
- package/src/storage/backends/chrome-storage-backend.ts +82 -0
- package/src/storage/backends/indexeddb-backend.ts +107 -0
- package/src/storage/backends/local-storage-backend.ts +74 -0
- package/src/storage/repositories/provider-keys-repository.ts +55 -0
- package/src/storage/repositories/settings-repository.ts +51 -0
- package/src/storage/types.ts +48 -0
- package/src/tools/artifacts/ArtifactElement.ts +15 -0
- package/src/tools/artifacts/HtmlArtifact.ts +221 -0
- package/src/tools/artifacts/MarkdownArtifact.ts +81 -0
- package/src/tools/artifacts/SvgArtifact.ts +77 -0
- package/src/tools/artifacts/TextArtifact.ts +148 -0
- package/src/tools/artifacts/artifacts.ts +888 -0
- package/src/tools/artifacts/index.ts +6 -0
- package/src/tools/index.ts +35 -0
- package/src/tools/javascript-repl.ts +309 -0
- package/src/tools/renderer-registry.ts +18 -0
- package/src/tools/renderers/BashRenderer.ts +45 -0
- package/src/tools/renderers/CalculateRenderer.ts +49 -0
- package/src/tools/renderers/DefaultRenderer.ts +36 -0
- package/src/tools/renderers/GetCurrentTimeRenderer.ts +39 -0
- package/src/tools/types.ts +7 -0
- package/src/utils/attachment-utils.ts +472 -0
- package/src/utils/auth-token.ts +22 -0
- package/src/utils/format.ts +42 -0
- package/src/utils/i18n.ts +343 -0
- package/src/utils/test-sessions.ts +2247 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, icon } from "@mariozechner/mini-lit";
|
|
8
|
+
import { LitElement } from "lit";
|
|
9
|
+
import { customElement, property } from "lit/decorators.js";
|
|
10
|
+
import { FileSpreadsheet, FileText, X } from "lucide";
|
|
11
|
+
import { AttachmentOverlay } from "../dialogs/AttachmentOverlay.js";
|
|
12
|
+
import { i18n } from "../utils/i18n.js";
|
|
13
|
+
let AttachmentTile = class AttachmentTile extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.showDelete = false;
|
|
17
|
+
this.handleClick = () => {
|
|
18
|
+
AttachmentOverlay.open(this.attachment);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
createRenderRoot() {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
this.style.display = "block";
|
|
27
|
+
this.classList.add("max-h-16");
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
const hasPreview = !!this.attachment.preview;
|
|
31
|
+
const isImage = this.attachment.type === "image";
|
|
32
|
+
const isPdf = this.attachment.mimeType === "application/pdf";
|
|
33
|
+
const isDocx = this.attachment.mimeType?.includes("wordprocessingml") ||
|
|
34
|
+
this.attachment.fileName.toLowerCase().endsWith(".docx");
|
|
35
|
+
const isPptx = this.attachment.mimeType?.includes("presentationml") ||
|
|
36
|
+
this.attachment.fileName.toLowerCase().endsWith(".pptx");
|
|
37
|
+
const isExcel = this.attachment.mimeType?.includes("spreadsheetml") ||
|
|
38
|
+
this.attachment.fileName.toLowerCase().endsWith(".xlsx") ||
|
|
39
|
+
this.attachment.fileName.toLowerCase().endsWith(".xls");
|
|
40
|
+
// Choose the appropriate icon
|
|
41
|
+
const getDocumentIcon = () => {
|
|
42
|
+
if (isExcel)
|
|
43
|
+
return icon(FileSpreadsheet, "md");
|
|
44
|
+
return icon(FileText, "md");
|
|
45
|
+
};
|
|
46
|
+
return html `
|
|
47
|
+
<div class="relative group inline-block">
|
|
48
|
+
${hasPreview
|
|
49
|
+
? html `
|
|
50
|
+
<div class="relative">
|
|
51
|
+
<img
|
|
52
|
+
src="data:${isImage ? this.attachment.mimeType : "image/png"};base64,${this.attachment.preview}"
|
|
53
|
+
class="w-16 h-16 object-cover rounded-lg border border-input cursor-pointer hover:opacity-80 transition-opacity"
|
|
54
|
+
alt="${this.attachment.fileName}"
|
|
55
|
+
title="${this.attachment.fileName}"
|
|
56
|
+
@click=${this.handleClick}
|
|
57
|
+
/>
|
|
58
|
+
${isPdf
|
|
59
|
+
? html `
|
|
60
|
+
<!-- PDF badge overlay -->
|
|
61
|
+
<div class="absolute bottom-0 left-0 right-0 bg-background/90 px-1 py-0.5 rounded-b-lg">
|
|
62
|
+
<div class="text-[10px] text-muted-foreground text-center font-medium">${i18n("PDF")}</div>
|
|
63
|
+
</div>
|
|
64
|
+
`
|
|
65
|
+
: ""}
|
|
66
|
+
</div>
|
|
67
|
+
`
|
|
68
|
+
: html `
|
|
69
|
+
<!-- Fallback: document icon + filename -->
|
|
70
|
+
<div
|
|
71
|
+
class="w-16 h-16 rounded-lg border border-input cursor-pointer hover:opacity-80 transition-opacity bg-muted text-muted-foreground flex flex-col items-center justify-center p-2"
|
|
72
|
+
@click=${this.handleClick}
|
|
73
|
+
title="${this.attachment.fileName}"
|
|
74
|
+
>
|
|
75
|
+
${getDocumentIcon()}
|
|
76
|
+
<div class="text-[10px] text-center truncate w-full">
|
|
77
|
+
${this.attachment.fileName.length > 10
|
|
78
|
+
? this.attachment.fileName.substring(0, 8) + "..."
|
|
79
|
+
: this.attachment.fileName}
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
`}
|
|
83
|
+
${this.showDelete
|
|
84
|
+
? html `
|
|
85
|
+
<button
|
|
86
|
+
@click=${(e) => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
this.onDelete?.();
|
|
89
|
+
}}
|
|
90
|
+
class="absolute -top-1 -right-1 w-5 h-5 bg-background hover:bg-muted text-muted-foreground hover:text-foreground rounded-full flex items-center justify-center opacity-100 hover:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover:opacity-100 transition-opacity border border-input shadow-sm"
|
|
91
|
+
title="${i18n("Remove")}"
|
|
92
|
+
>
|
|
93
|
+
${icon(X, "xs")}
|
|
94
|
+
</button>
|
|
95
|
+
`
|
|
96
|
+
: ""}
|
|
97
|
+
</div>
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
__decorate([
|
|
102
|
+
property({ type: Object })
|
|
103
|
+
], AttachmentTile.prototype, "attachment", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ type: Boolean })
|
|
106
|
+
], AttachmentTile.prototype, "showDelete", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
property()
|
|
109
|
+
], AttachmentTile.prototype, "onDelete", void 0);
|
|
110
|
+
AttachmentTile = __decorate([
|
|
111
|
+
customElement("attachment-tile")
|
|
112
|
+
], AttachmentTile);
|
|
113
|
+
export { AttachmentTile };
|
|
114
|
+
//# sourceMappingURL=AttachmentTile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentTile.js","sourceRoot":"","sources":["../../src/components/AttachmentTile.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGjC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAEuB,eAAU,G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EhB;YACD,CAAC,CAAC,EACJ;;GAED,CAAC;IACH,CAAC;CACD,CAAA;AArG4B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AACvB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAoB;AACpC;IAAX,QAAQ,EAAE;gDAAuB;AAHtB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAsG1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export declare class ConsoleBlock extends LitElement {
|
|
3
|
+
content: string;
|
|
4
|
+
private copied;
|
|
5
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
private copy;
|
|
8
|
+
updated(): void;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ConsoleBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleBlock.d.ts","sourceRoot":"","sources":["../../src/components/ConsoleBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAKjC,qBAAa,YAAa,SAAQ,UAAU;IAC/B,OAAO,EAAE,MAAM,CAAM;IACxB,OAAO,CAAC,MAAM,CAAS;cAEb,gBAAgB,IAAI,WAAW,GAAG,gBAAgB;IAI5D,iBAAiB,IAAI,IAAI;YAKpB,IAAI;IAYT,OAAO;IAQP,MAAM;CAsBf"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, icon } from "@mariozechner/mini-lit";
|
|
8
|
+
import { LitElement } from "lit";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
|
+
import { Check, Copy } from "lucide";
|
|
11
|
+
import { i18n } from "../utils/i18n.js";
|
|
12
|
+
export class ConsoleBlock extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.content = "";
|
|
16
|
+
this.copied = false;
|
|
17
|
+
}
|
|
18
|
+
createRenderRoot() {
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
super.connectedCallback();
|
|
23
|
+
this.style.display = "block";
|
|
24
|
+
}
|
|
25
|
+
async copy() {
|
|
26
|
+
try {
|
|
27
|
+
await navigator.clipboard.writeText(this.content || "");
|
|
28
|
+
this.copied = true;
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
this.copied = false;
|
|
31
|
+
}, 1500);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
console.error("Copy failed", e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
updated() {
|
|
38
|
+
// Auto-scroll to bottom on content changes
|
|
39
|
+
const container = this.querySelector(".console-scroll");
|
|
40
|
+
if (container) {
|
|
41
|
+
container.scrollTop = container.scrollHeight;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
45
|
+
return html `
|
|
46
|
+
<div class="border border-border rounded-lg overflow-hidden">
|
|
47
|
+
<div class="flex items-center justify-between px-3 py-1.5 bg-muted border-b border-border">
|
|
48
|
+
<span class="text-xs text-muted-foreground font-mono">${i18n("console")}</span>
|
|
49
|
+
<button
|
|
50
|
+
@click=${() => this.copy()}
|
|
51
|
+
class="flex items-center gap-1 px-2 py-0.5 text-xs rounded hover:bg-accent text-muted-foreground hover:text-accent-foreground transition-colors"
|
|
52
|
+
title="${i18n("Copy output")}"
|
|
53
|
+
>
|
|
54
|
+
${this.copied ? icon(Check, "sm") : icon(Copy, "sm")}
|
|
55
|
+
${this.copied ? html `<span>${i18n("Copied!")}</span>` : ""}
|
|
56
|
+
</button>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="console-scroll overflow-auto max-h-64">
|
|
59
|
+
<pre class="!bg-background !border-0 !rounded-none m-0 p-3 text-xs text-foreground font-mono whitespace-pre-wrap">
|
|
60
|
+
${this.content || ""}</pre
|
|
61
|
+
>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
__decorate([
|
|
68
|
+
property()
|
|
69
|
+
], ConsoleBlock.prototype, "content", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
state()
|
|
72
|
+
], ConsoleBlock.prototype, "copied", void 0);
|
|
73
|
+
// Register custom element
|
|
74
|
+
if (!customElements.get("console-block")) {
|
|
75
|
+
customElements.define("console-block", ConsoleBlock);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ConsoleBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleBlock.js","sourceRoot":"","sources":["../../src/components/ConsoleBlock.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MA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I,CAAA,SAAS,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;;;;;EAK9D,IAAI,CAAC,OAAO,IAAI,EAAE;;;;GAIjB,CAAC;IACH,CAAC;CACD;AAtDY;IAAX,QAAQ,EAAE;6CAAsB;AAChB;IAAhB,KAAK,EAAE;4CAAwB;AAuDjC,0BAA0B;AAC1B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;IAC1C,cAAc,CAAC,MAAM,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type BaseComponentProps } from "@mariozechner/mini-lit";
|
|
2
|
+
import { type Ref } from "lit/directives/ref.js";
|
|
3
|
+
export type InputType = "text" | "email" | "password" | "number" | "url" | "tel" | "search";
|
|
4
|
+
export type InputSize = "sm" | "md" | "lg";
|
|
5
|
+
export interface InputProps extends BaseComponentProps {
|
|
6
|
+
type?: InputType;
|
|
7
|
+
size?: InputSize;
|
|
8
|
+
value?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
name?: string;
|
|
15
|
+
autocomplete?: string;
|
|
16
|
+
min?: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
step?: number;
|
|
19
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
20
|
+
onInput?: (e: Event) => void;
|
|
21
|
+
onChange?: (e: Event) => void;
|
|
22
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
23
|
+
onKeyUp?: (e: KeyboardEvent) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const Input: import("@mariozechner/mini-lit").Component<InputProps>;
|
|
26
|
+
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources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@
|
|
|
1
|
+
import { fc, html } from "@mariozechner/mini-lit";
|
|
2
|
+
import { ref } from "lit/directives/ref.js";
|
|
3
|
+
import { i18n } from "../utils/i18n.js";
|
|
4
|
+
export const Input = fc(({ type = "text", size = "md", value = "", placeholder = "", label = "", error = "", disabled = false, required = false, name = "", autocomplete = "", min, max, step, inputRef, onInput, onChange, onKeyDown, onKeyUp, className = "", }) => {
|
|
5
|
+
const sizeClasses = {
|
|
6
|
+
sm: "h-8 px-3 py-1 text-sm",
|
|
7
|
+
md: "h-9 px-3 py-1 text-sm md:text-sm",
|
|
8
|
+
lg: "h-10 px-4 py-1 text-base",
|
|
9
|
+
};
|
|
10
|
+
const baseClasses = "flex w-full min-w-0 rounded-md border bg-transparent text-foreground shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium";
|
|
11
|
+
const interactionClasses = "placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground";
|
|
12
|
+
const focusClasses = "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]";
|
|
13
|
+
const darkClasses = "dark:bg-input/30";
|
|
14
|
+
const stateClasses = error
|
|
15
|
+
? "border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40"
|
|
16
|
+
: "border-input";
|
|
17
|
+
const disabledClasses = "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50";
|
|
18
|
+
const handleInput = (e) => {
|
|
19
|
+
onInput?.(e);
|
|
20
|
+
};
|
|
21
|
+
const handleChange = (e) => {
|
|
22
|
+
onChange?.(e);
|
|
23
|
+
};
|
|
24
|
+
return html `
|
|
25
|
+
<div class="flex flex-col gap-1.5 ${className}">
|
|
26
|
+
${label
|
|
27
|
+
? html `
|
|
28
|
+
<label class="text-sm font-medium text-foreground">
|
|
29
|
+
${label} ${required ? html `<span class="text-destructive">${i18n("*")}</span>` : ""}
|
|
30
|
+
</label>
|
|
31
|
+
`
|
|
32
|
+
: ""}
|
|
33
|
+
<input
|
|
34
|
+
type="${type}"
|
|
35
|
+
class="${baseClasses} ${sizeClasses[size]} ${interactionClasses} ${focusClasses} ${darkClasses} ${stateClasses} ${disabledClasses}"
|
|
36
|
+
.value=${value}
|
|
37
|
+
placeholder="${placeholder}"
|
|
38
|
+
?disabled=${disabled}
|
|
39
|
+
?required=${required}
|
|
40
|
+
?aria-invalid=${!!error}
|
|
41
|
+
name="${name}"
|
|
42
|
+
autocomplete="${autocomplete}"
|
|
43
|
+
min="${min ?? ""}"
|
|
44
|
+
max="${max ?? ""}"
|
|
45
|
+
step="${step ?? ""}"
|
|
46
|
+
@input=${handleInput}
|
|
47
|
+
@change=${handleChange}
|
|
48
|
+
@keydown=${onKeyDown}
|
|
49
|
+
@keyup=${onKeyUp}
|
|
50
|
+
${inputRef ? ref(inputRef) : ""}
|
|
51
|
+
/>
|
|
52
|
+
${error ? html `<span class="text-sm text-destructive">${error}</span>` : ""}
|
|
53
|
+
</div>
|
|
54
|
+
`;
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../src/components/Input.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,EAAE,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAY,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AA0BxC,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CACtB,CAAC,EACA,IAAI,GAAG,MAAM,EACb,IAAI,GAAG,IAAI,EACX,KAAK,GAAG,EAAE,EACV,WAAW,GAAG,EAAE,EAChB,KAAK,GAAG,EAAE,EACV,KAAK,GAAG,EAAE,EACV,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,EAAE,EACT,YAAY,GAAG,EAAE,EACj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AAI,EAAE;aACR,IAAI,IAAI,EAAE;cACT,WAAW;eACV,YAAY;gBACX,SAAS;cACX,OAAO;OACd,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;;MAE9B,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA,0CAA0C,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;;GAE5E,CAAC;AACH,CAAC,CACD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Model } from "@mariozechner/pi-ai";
|
|
2
|
+
import { LitElement } from "lit";
|
|
3
|
+
import "./AttachmentTile.js";
|
|
4
|
+
import { type Attachment } from "../utils/attachment-utils.js";
|
|
5
|
+
export declare class MessageEditor extends LitElement {
|
|
6
|
+
private _value;
|
|
7
|
+
private textareaRef;
|
|
8
|
+
get value(): string;
|
|
9
|
+
set value(val: string);
|
|
10
|
+
isStreaming: boolean;
|
|
11
|
+
currentModel?: Model<any>;
|
|
12
|
+
showAttachmentButton: boolean;
|
|
13
|
+
showModelSelector: boolean;
|
|
14
|
+
showThinking: boolean;
|
|
15
|
+
onInput?: (value: string) => void;
|
|
16
|
+
onSend?: (input: string, attachments: Attachment[]) => void;
|
|
17
|
+
onAbort?: () => void;
|
|
18
|
+
onModelSelect?: () => void;
|
|
19
|
+
onFilesChange?: (files: Attachment[]) => void;
|
|
20
|
+
attachments: Attachment[];
|
|
21
|
+
maxFiles: number;
|
|
22
|
+
maxFileSize: number;
|
|
23
|
+
acceptedTypes: string;
|
|
24
|
+
processingFiles: boolean;
|
|
25
|
+
private fileInputRef;
|
|
26
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
27
|
+
private handleTextareaInput;
|
|
28
|
+
private handleKeyDown;
|
|
29
|
+
private handleSend;
|
|
30
|
+
private handleAttachmentClick;
|
|
31
|
+
private handleFilesSelected;
|
|
32
|
+
private removeFile;
|
|
33
|
+
private adjustTextareaHeight;
|
|
34
|
+
firstUpdated(): void;
|
|
35
|
+
updated(): void;
|
|
36
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=MessageEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageEditor.d.ts","sourceRoot":"","sources":["../../src/components/MessageEditor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAIjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,8BAA8B,CAAC;AAG/E,qBACa,aAAc,SAAQ,UAAU;IAC5C,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,WAAW,CAAoC;IAEvD,IACI,KAAK,IAIM,MAAM,CAFpB;IAED,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,EAWpB;IAEW,WAAW,UAAS;IACpB,YAAY,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,oBAAoB,UAAQ;IAC5B,iBAAiB,UAAQ;IACzB,YAAY,UAAS;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAC5D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAC9C,WAAW,EAAE,UAAU,EAAE,CAAM;IAC/B,QAAQ,SAAM;IACd,WAAW,SAAoB;IAC/B,aAAa,SACqF;IAErG,eAAe,UAAS;IACjC,OAAO,CAAC,YAAY,CAAiC;cAElC,gBAAgB,IAAI,WAAW,GAAG,gBAAgB;IAIrE,OAAO,CAAC,mBAAmB,CAMzB;IAEF,OAAO,CAAC,aAAa,CAUnB;IAEF,OAAO,CAAC,UAAU,CAEhB;IAEF,OAAO,CAAC,qBAAqB,CAE3B;YAEY,mBAAmB;IAmCjC,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,oBAAoB;IAYnB,YAAY;IAQZ,OAAO;IAOP,MAAM;CAwHf"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Button, html, icon } from "@mariozechner/mini-lit";
|
|
8
|
+
import { LitElement } from "lit";
|
|
9
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
10
|
+
import { createRef, ref } from "lit/directives/ref.js";
|
|
11
|
+
import { Loader2, Paperclip, Send, Sparkles, Square } from "lucide";
|
|
12
|
+
import "./AttachmentTile.js";
|
|
13
|
+
import { loadAttachment } from "../utils/attachment-utils.js";
|
|
14
|
+
import { i18n } from "../utils/i18n.js";
|
|
15
|
+
let MessageEditor = class MessageEditor extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this._value = "";
|
|
19
|
+
this.textareaRef = createRef();
|
|
20
|
+
this.isStreaming = false;
|
|
21
|
+
this.showAttachmentButton = true;
|
|
22
|
+
this.showModelSelector = true;
|
|
23
|
+
this.showThinking = false; // Disabled for now
|
|
24
|
+
this.attachments = [];
|
|
25
|
+
this.maxFiles = 10;
|
|
26
|
+
this.maxFileSize = 20 * 1024 * 1024; // 20MB
|
|
27
|
+
this.acceptedTypes = "image/*,application/pdf,.docx,.pptx,.xlsx,.xls,.txt,.md,.json,.xml,.html,.css,.js,.ts,.jsx,.tsx,.yml,.yaml";
|
|
28
|
+
this.processingFiles = false;
|
|
29
|
+
this.fileInputRef = createRef();
|
|
30
|
+
this.handleTextareaInput = (e) => {
|
|
31
|
+
const textarea = e.target;
|
|
32
|
+
this.value = textarea.value;
|
|
33
|
+
textarea.style.height = "auto";
|
|
34
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`;
|
|
35
|
+
this.onInput?.(this.value);
|
|
36
|
+
};
|
|
37
|
+
this.handleKeyDown = (e) => {
|
|
38
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
if (!this.isStreaming && !this.processingFiles && (this.value.trim() || this.attachments.length > 0)) {
|
|
41
|
+
this.handleSend();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (e.key === "Escape" && this.isStreaming) {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
this.onAbort?.();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
this.handleSend = () => {
|
|
50
|
+
this.onSend?.(this.value, this.attachments);
|
|
51
|
+
};
|
|
52
|
+
this.handleAttachmentClick = () => {
|
|
53
|
+
this.fileInputRef.value?.click();
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
get value() {
|
|
57
|
+
return this._value;
|
|
58
|
+
}
|
|
59
|
+
set value(val) {
|
|
60
|
+
const oldValue = this._value;
|
|
61
|
+
this._value = val;
|
|
62
|
+
this.requestUpdate("value", oldValue);
|
|
63
|
+
this.updateComplete.then(() => {
|
|
64
|
+
const textarea = this.textareaRef.value;
|
|
65
|
+
if (textarea) {
|
|
66
|
+
textarea.style.height = "auto";
|
|
67
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
createRenderRoot() {
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
async handleFilesSelected(e) {
|
|
75
|
+
const input = e.target;
|
|
76
|
+
const files = Array.from(input.files || []);
|
|
77
|
+
if (files.length === 0)
|
|
78
|
+
return;
|
|
79
|
+
if (files.length + this.attachments.length > this.maxFiles) {
|
|
80
|
+
alert(`Maximum ${this.maxFiles} files allowed`);
|
|
81
|
+
input.value = "";
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.processingFiles = true;
|
|
85
|
+
const newAttachments = [];
|
|
86
|
+
for (const file of files) {
|
|
87
|
+
try {
|
|
88
|
+
if (file.size > this.maxFileSize) {
|
|
89
|
+
alert(`${file.name} exceeds maximum size of ${Math.round(this.maxFileSize / 1024 / 1024)}MB`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const attachment = await loadAttachment(file);
|
|
93
|
+
newAttachments.push(attachment);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error(`Error processing ${file.name}:`, error);
|
|
97
|
+
alert(`Failed to process ${file.name}: ${String(error)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
this.attachments = [...this.attachments, ...newAttachments];
|
|
101
|
+
this.onFilesChange?.(this.attachments);
|
|
102
|
+
this.processingFiles = false;
|
|
103
|
+
input.value = ""; // Reset input
|
|
104
|
+
}
|
|
105
|
+
removeFile(fileId) {
|
|
106
|
+
this.attachments = this.attachments.filter((f) => f.id !== fileId);
|
|
107
|
+
this.onFilesChange?.(this.attachments);
|
|
108
|
+
}
|
|
109
|
+
adjustTextareaHeight() {
|
|
110
|
+
const textarea = this.textareaRef.value;
|
|
111
|
+
if (textarea) {
|
|
112
|
+
// Reset height to auto to get accurate scrollHeight
|
|
113
|
+
textarea.style.height = "auto";
|
|
114
|
+
// Only adjust if there's content, otherwise keep minimal height
|
|
115
|
+
if (this.value.trim()) {
|
|
116
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
firstUpdated() {
|
|
121
|
+
const textarea = this.textareaRef.value;
|
|
122
|
+
if (textarea) {
|
|
123
|
+
// Don't adjust height on first render - let it be minimal
|
|
124
|
+
textarea.focus();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
updated() {
|
|
128
|
+
// Only adjust height when component updates if there's content
|
|
129
|
+
if (this.value) {
|
|
130
|
+
this.adjustTextareaHeight();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
render() {
|
|
134
|
+
return html `
|
|
135
|
+
<div class="bg-card rounded-xl border border-border shadow-sm">
|
|
136
|
+
<!-- Attachments -->
|
|
137
|
+
${this.attachments.length > 0
|
|
138
|
+
? html `
|
|
139
|
+
<div class="px-4 pt-3 pb-2 flex flex-wrap gap-2">
|
|
140
|
+
${this.attachments.map((attachment) => html `
|
|
141
|
+
<attachment-tile
|
|
142
|
+
.attachment=${attachment}
|
|
143
|
+
.showDelete=${true}
|
|
144
|
+
.onDelete=${() => this.removeFile(attachment.id)}
|
|
145
|
+
></attachment-tile>
|
|
146
|
+
`)}
|
|
147
|
+
</div>
|
|
148
|
+
`
|
|
149
|
+
: ""}
|
|
150
|
+
|
|
151
|
+
<textarea
|
|
152
|
+
class="w-full bg-transparent p-4 text-foreground placeholder-muted-foreground outline-none resize-none overflow-y-auto"
|
|
153
|
+
placeholder=${i18n("Type a message...")}
|
|
154
|
+
rows="1"
|
|
155
|
+
style="max-height: 200px;"
|
|
156
|
+
.value=${this.value}
|
|
157
|
+
@input=${this.handleTextareaInput}
|
|
158
|
+
@keydown=${this.handleKeyDown}
|
|
159
|
+
${ref(this.textareaRef)}
|
|
160
|
+
></textarea>
|
|
161
|
+
|
|
162
|
+
<!-- Hidden file input -->
|
|
163
|
+
<input
|
|
164
|
+
type="file"
|
|
165
|
+
${ref(this.fileInputRef)}
|
|
166
|
+
@change=${this.handleFilesSelected}
|
|
167
|
+
accept=${this.acceptedTypes}
|
|
168
|
+
multiple
|
|
169
|
+
style="display: none;"
|
|
170
|
+
/>
|
|
171
|
+
|
|
172
|
+
<!-- Button Row -->
|
|
173
|
+
<div class="px-2 pb-2 flex items-center justify-between">
|
|
174
|
+
<!-- Left side - attachment and quick action buttons -->
|
|
175
|
+
<div class="flex gap-2 items-center">
|
|
176
|
+
${this.showAttachmentButton
|
|
177
|
+
? this.processingFiles
|
|
178
|
+
? html `
|
|
179
|
+
<div class="h-8 w-8 flex items-center justify-center">
|
|
180
|
+
${icon(Loader2, "sm", "animate-spin text-muted-foreground")}
|
|
181
|
+
</div>
|
|
182
|
+
`
|
|
183
|
+
: html `
|
|
184
|
+
${Button({
|
|
185
|
+
variant: "ghost",
|
|
186
|
+
size: "icon",
|
|
187
|
+
className: "h-8 w-8",
|
|
188
|
+
onClick: this.handleAttachmentClick,
|
|
189
|
+
children: icon(Paperclip, "sm"),
|
|
190
|
+
})}
|
|
191
|
+
`
|
|
192
|
+
: ""}
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<!-- Model selector and send on the right -->
|
|
196
|
+
<div class="flex gap-2 items-center">
|
|
197
|
+
${this.showModelSelector && this.currentModel
|
|
198
|
+
? html `
|
|
199
|
+
${Button({
|
|
200
|
+
variant: "ghost",
|
|
201
|
+
size: "sm",
|
|
202
|
+
onClick: () => {
|
|
203
|
+
// Focus textarea before opening model selector so focus returns there
|
|
204
|
+
this.textareaRef.value?.focus();
|
|
205
|
+
// Wait for next frame to ensure focus takes effect before dialog captures it
|
|
206
|
+
requestAnimationFrame(() => {
|
|
207
|
+
this.onModelSelect?.();
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
children: html `
|
|
211
|
+
${icon(Sparkles, "sm")}
|
|
212
|
+
<span class="ml-1">${this.currentModel.id}</span>
|
|
213
|
+
`,
|
|
214
|
+
className: "h-8 text-xs truncate",
|
|
215
|
+
})}
|
|
216
|
+
`
|
|
217
|
+
: ""}
|
|
218
|
+
${this.isStreaming
|
|
219
|
+
? html `
|
|
220
|
+
${Button({
|
|
221
|
+
variant: "ghost",
|
|
222
|
+
size: "icon",
|
|
223
|
+
onClick: this.onAbort,
|
|
224
|
+
children: icon(Square, "sm"),
|
|
225
|
+
className: "h-8 w-8",
|
|
226
|
+
})}
|
|
227
|
+
`
|
|
228
|
+
: html `
|
|
229
|
+
${Button({
|
|
230
|
+
variant: "ghost",
|
|
231
|
+
size: "icon",
|
|
232
|
+
onClick: this.handleSend,
|
|
233
|
+
disabled: (!this.value.trim() && this.attachments.length === 0) || this.processingFiles,
|
|
234
|
+
children: html `<div style="transform: rotate(-45deg)">${icon(Send, "sm")}</div>`,
|
|
235
|
+
className: "h-8 w-8",
|
|
236
|
+
})}
|
|
237
|
+
`}
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
`;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
__decorate([
|
|
245
|
+
property()
|
|
246
|
+
], MessageEditor.prototype, "value", null);
|
|
247
|
+
__decorate([
|
|
248
|
+
property()
|
|
249
|
+
], MessageEditor.prototype, "isStreaming", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
property()
|
|
252
|
+
], MessageEditor.prototype, "currentModel", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
property()
|
|
255
|
+
], MessageEditor.prototype, "showAttachmentButton", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
property()
|
|
258
|
+
], MessageEditor.prototype, "showModelSelector", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
property()
|
|
261
|
+
], MessageEditor.prototype, "showThinking", void 0);
|
|
262
|
+
__decorate([
|
|
263
|
+
property()
|
|
264
|
+
], MessageEditor.prototype, "onInput", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
property()
|
|
267
|
+
], MessageEditor.prototype, "onSend", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
property()
|
|
270
|
+
], MessageEditor.prototype, "onAbort", void 0);
|
|
271
|
+
__decorate([
|
|
272
|
+
property()
|
|
273
|
+
], MessageEditor.prototype, "onModelSelect", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
property()
|
|
276
|
+
], MessageEditor.prototype, "onFilesChange", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
property()
|
|
279
|
+
], MessageEditor.prototype, "attachments", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
property()
|
|
282
|
+
], MessageEditor.prototype, "maxFiles", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
property()
|
|
285
|
+
], MessageEditor.prototype, "maxFileSize", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
property()
|
|
288
|
+
], MessageEditor.prototype, "acceptedTypes", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
state()
|
|
291
|
+
], MessageEditor.prototype, "processingFiles", void 0);
|
|
292
|
+
MessageEditor = __decorate([
|
|
293
|
+
customElement("message-editor")
|
|
294
|
+
], MessageEditor);
|
|
295
|
+
export { MessageEditor };
|
|
296
|
+
//# sourceMappingURL=MessageEditor.js.map
|