@widgetic/chat 0.1.24 → 0.1.25
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/dist/components/ActionBar.svelte +60 -0
- package/dist/components/ActionBar.svelte.d.ts +3 -0
- package/dist/components/AttachmentDisplay.svelte +1 -0
- package/dist/components/Chat.svelte +115 -15
- package/dist/components/Chat.svelte.d.ts +14 -1
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.js +6 -0
- package/dist/types/attachment.d.ts +22 -0
- package/dist/types/attachment.js +1 -1
- package/dist/utils/fileUtils.js +16 -6
- package/package.json +1 -1
|
@@ -16,9 +16,12 @@
|
|
|
16
16
|
showScreenshot?: boolean;
|
|
17
17
|
showRecord?: boolean;
|
|
18
18
|
showUpload?: boolean;
|
|
19
|
+
showSelector?: boolean;
|
|
20
|
+
isSelectorActive?: boolean;
|
|
19
21
|
showComplete?: boolean;
|
|
20
22
|
onScreenshot?: () => void;
|
|
21
23
|
onUpload?: () => void;
|
|
24
|
+
onToggleSelector?: (active: boolean) => void;
|
|
22
25
|
onRecordStart?: () => void;
|
|
23
26
|
onRecordStop?: () => void;
|
|
24
27
|
onComplete?: (detail: { completed: boolean }) => void;
|
|
@@ -40,9 +43,12 @@
|
|
|
40
43
|
showScreenshot = true,
|
|
41
44
|
showRecord = true,
|
|
42
45
|
showUpload = true,
|
|
46
|
+
showSelector = false,
|
|
47
|
+
isSelectorActive = false,
|
|
43
48
|
showComplete = true,
|
|
44
49
|
onScreenshot,
|
|
45
50
|
onUpload,
|
|
51
|
+
onToggleSelector,
|
|
46
52
|
onRecordStart,
|
|
47
53
|
onRecordStop,
|
|
48
54
|
onComplete,
|
|
@@ -87,6 +93,12 @@
|
|
|
87
93
|
onUpload?.();
|
|
88
94
|
}
|
|
89
95
|
|
|
96
|
+
// Handle widget element selector toggle (disabled by default)
|
|
97
|
+
function handleSelectorToggle() {
|
|
98
|
+
if (disabled) return;
|
|
99
|
+
onToggleSelector?.(!isSelectorActive);
|
|
100
|
+
}
|
|
101
|
+
|
|
90
102
|
// Handle completion toggle
|
|
91
103
|
function handleCompletionToggle() {
|
|
92
104
|
if (disabled || !conversationId) return;
|
|
@@ -155,6 +167,36 @@
|
|
|
155
167
|
</button>
|
|
156
168
|
{/if}
|
|
157
169
|
|
|
170
|
+
{#if showSelector}
|
|
171
|
+
<!-- Widget Element Selector Toggle Button -->
|
|
172
|
+
<button
|
|
173
|
+
type="button"
|
|
174
|
+
class="action-button selector-button"
|
|
175
|
+
class:active={isSelectorActive}
|
|
176
|
+
onclick={handleSelectorToggle}
|
|
177
|
+
disabled={disabled}
|
|
178
|
+
aria-pressed={isSelectorActive}
|
|
179
|
+
title={isSelectorActive ? $t('chat.actions.selectorActiveTitle') : $t('chat.actions.selectorTitle')}
|
|
180
|
+
aria-label={$t('chat.actions.selectorLabel')}
|
|
181
|
+
data-testid="chat-selector-toggle-btn"
|
|
182
|
+
>
|
|
183
|
+
<svg viewBox="0 0 24 24" class="action-icon">
|
|
184
|
+
<path d="M5 3a2 2 0 0 0-2 2" />
|
|
185
|
+
<path d="M19 3a2 2 0 0 1 2 2" />
|
|
186
|
+
<path d="M21 19a2 2 0 0 1-2 2" />
|
|
187
|
+
<path d="M5 21a2 2 0 0 1-2-2" />
|
|
188
|
+
<path d="M9 3h1" />
|
|
189
|
+
<path d="M9 21h1" />
|
|
190
|
+
<path d="M14 3h1" />
|
|
191
|
+
<path d="M3 9v1" />
|
|
192
|
+
<path d="M21 9v1" />
|
|
193
|
+
<path d="M3 14v1" />
|
|
194
|
+
<path d="m12 12 7 2-3 1.5L14.5 19 12 12Z" />
|
|
195
|
+
</svg>
|
|
196
|
+
<span class="action-label">{$t('chat.actions.selector')}</span>
|
|
197
|
+
</button>
|
|
198
|
+
{/if}
|
|
199
|
+
|
|
158
200
|
{#if replaceComplete && completeReplacement}
|
|
159
201
|
{@render completeReplacement()}
|
|
160
202
|
{:else if showComplete}
|
|
@@ -312,6 +354,24 @@
|
|
|
312
354
|
color: #15803d;
|
|
313
355
|
}
|
|
314
356
|
|
|
357
|
+
/* Selector toggle button styling */
|
|
358
|
+
.selector-button:hover:not(:disabled) {
|
|
359
|
+
background-color: #f0fdf4;
|
|
360
|
+
border-color: #6d9a59;
|
|
361
|
+
color: #2f5421;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.selector-button.active {
|
|
365
|
+
background-color: #eef6ea;
|
|
366
|
+
border-color: #5e8c4a;
|
|
367
|
+
color: #2b4c1e;
|
|
368
|
+
box-shadow: inset 0 0 0 1px rgba(94, 140, 74, 0.35);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.selector-button.active:hover:not(:disabled) {
|
|
372
|
+
background-color: #e1f0da;
|
|
373
|
+
}
|
|
374
|
+
|
|
315
375
|
/* Completion button styling */
|
|
316
376
|
.completion-button.completed {
|
|
317
377
|
background-color: #dcfce7;
|
|
@@ -9,9 +9,12 @@ interface Props {
|
|
|
9
9
|
showScreenshot?: boolean;
|
|
10
10
|
showRecord?: boolean;
|
|
11
11
|
showUpload?: boolean;
|
|
12
|
+
showSelector?: boolean;
|
|
13
|
+
isSelectorActive?: boolean;
|
|
12
14
|
showComplete?: boolean;
|
|
13
15
|
onScreenshot?: () => void;
|
|
14
16
|
onUpload?: () => void;
|
|
17
|
+
onToggleSelector?: (active: boolean) => void;
|
|
15
18
|
onRecordStart?: () => void;
|
|
16
19
|
onRecordStop?: () => void;
|
|
17
20
|
onComplete?: (detail: {
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
if (fileType.startsWith('video/')) return '🎥';
|
|
58
58
|
if (fileType.startsWith('audio/')) return '🎵';
|
|
59
59
|
if (fileType.includes('pdf')) return '📄';
|
|
60
|
+
if (fileType.includes('csv')) return '📊';
|
|
60
61
|
if (fileType.includes('text') || fileType.includes('markdown')) return '📝';
|
|
61
62
|
if (fileType.includes('mermaid')) return '📊';
|
|
62
63
|
return '📎';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { setLogsEnabled, chatLog, chatWarn } from '../utils/logger.js';
|
|
9
9
|
import type { ChatConfig, ChatContext } from '../types/index.js';
|
|
10
10
|
import type { ClarificationSuggestion, DesignControlRequest } from '../types/message.js';
|
|
11
|
-
import type { AttachmentInput } from '../types/attachment.js';
|
|
11
|
+
import type { AttachmentInput, SelectedElementChatReference } from '../types/attachment.js';
|
|
12
12
|
import ChatMessages from './ChatMessages.svelte';
|
|
13
13
|
import ChatInput from './ChatInput.svelte';
|
|
14
14
|
import ActionBar from './ActionBar.svelte';
|
|
@@ -61,7 +61,11 @@
|
|
|
61
61
|
fileName: string;
|
|
62
62
|
fileSize?: number;
|
|
63
63
|
}>,
|
|
64
|
-
options?: {
|
|
64
|
+
options?: {
|
|
65
|
+
skipIntentGate?: boolean;
|
|
66
|
+
chipIntent?: ClarificationSuggestion['intent'];
|
|
67
|
+
selectedElements?: SelectedElementChatReference[];
|
|
68
|
+
},
|
|
65
69
|
) => Promise<void>;
|
|
66
70
|
/** Backend integration callbacks — when provided, replace mock chatService methods */
|
|
67
71
|
onLoadConversations?: (contextId: string) => Promise<any[] | null>;
|
|
@@ -161,6 +165,18 @@
|
|
|
161
165
|
* `conversationLineLabel`). When omitted, message text is shown as stored.
|
|
162
166
|
*/
|
|
163
167
|
storedLineLabel?: (content: string) => string;
|
|
168
|
+
/** Show the Widget Element Selector toggle button in the action bar (disabled by default). */
|
|
169
|
+
showSelector?: boolean;
|
|
170
|
+
/** Whether the Widget Element Selector is currently active for this chat's widget. */
|
|
171
|
+
isSelectorActive?: boolean;
|
|
172
|
+
/** Selected widget elements currently referenced in this chat. */
|
|
173
|
+
selectedElements?: SelectedElementChatReference[];
|
|
174
|
+
/** Fired when the user toggles the Selector button in the action bar. */
|
|
175
|
+
onToggleSelector?: (active: boolean) => void;
|
|
176
|
+
/** Fired when the user removes a single selected widget element chip. */
|
|
177
|
+
onRemoveSelectedElement?: (elementId: string) => void;
|
|
178
|
+
/** Fired when all selected widget elements should be cleared (e.g. after sending). */
|
|
179
|
+
onClearSelectedElements?: () => void;
|
|
164
180
|
}
|
|
165
181
|
|
|
166
182
|
// Expose methods to parent component
|
|
@@ -200,7 +216,7 @@
|
|
|
200
216
|
updateLastUserMessageAttachments: (attachments: Array<{ id?: string; url: string; file_type?: string; file_name?: string | null }>) => void;
|
|
201
217
|
}
|
|
202
218
|
|
|
203
|
-
let { context, config = {}, class: className = '', locale = null, messages: languageMessages = null, dir = undefined, style = '', isCompleted = false, onStatsUpdate, onChatReady, onCompletionToggle, onSendMessage, onLoadConversations, onLoadMessages, onCreateConversation, onSaveMessage, onRestoreCheckpointBackend, onTakeScreenshot, onConversationChange, onDraftChange, onRetryMessage, onUpgradePlans, onUploadChatFile, showHeader = true, headerTitle = '', showDescriptionHeader = true, showLogs = true, resizeExpandsContainer = false, onMessagesResize, onMessagesDrag, onMessagesDragEnd, onLoadOlderMessages, widgetHeadCommitSha = null, versionLabelByCommitSha = {}, versionLabelByPrompt = {}, versionTimeline = [], viewingVersion = null, isGenerating = false, onStopGeneration, renderDesignControls, actionBarExtras, completeReplacement, replaceComplete = false, composerExtras, storedLineLabel }: Props = $props();
|
|
219
|
+
let { context, config = {}, class: className = '', locale = null, messages: languageMessages = null, dir = undefined, style = '', isCompleted = false, onStatsUpdate, onChatReady, onCompletionToggle, onSendMessage, onLoadConversations, onLoadMessages, onCreateConversation, onSaveMessage, onRestoreCheckpointBackend, onTakeScreenshot, onConversationChange, onDraftChange, onRetryMessage, onUpgradePlans, onUploadChatFile, showHeader = true, headerTitle = '', showDescriptionHeader = true, showLogs = true, resizeExpandsContainer = false, onMessagesResize, onMessagesDrag, onMessagesDragEnd, onLoadOlderMessages, widgetHeadCommitSha = null, versionLabelByCommitSha = {}, versionLabelByPrompt = {}, versionTimeline = [], viewingVersion = null, isGenerating = false, onStopGeneration, renderDesignControls, actionBarExtras, completeReplacement, replaceComplete = false, showSelector = false, isSelectorActive = false, selectedElements = [], onToggleSelector, onRemoveSelectedElement, onClearSelectedElements, composerExtras, storedLineLabel }: Props = $props();
|
|
204
220
|
|
|
205
221
|
// The words of everything inside the chat, in the language the page chose. The page can change the language while the
|
|
206
222
|
// chat is open: the settings are read again whenever they change (and setting the same language again does nothing).
|
|
@@ -619,6 +635,11 @@
|
|
|
619
635
|
// chatLog('[Chat] Sending message:', content.substring(0, 60));
|
|
620
636
|
const submittedContent = content;
|
|
621
637
|
const submittedAttachments = normalizedAttachments;
|
|
638
|
+
const submittedSelectedElements =
|
|
639
|
+
selectedElements && selectedElements.length > 0 ? [...selectedElements] : undefined;
|
|
640
|
+
const displayMessageContent = submittedSelectedElements
|
|
641
|
+
? `[Selected: ${submittedSelectedElements.map((el) => el.label).join(', ')}]\n${submittedContent}`
|
|
642
|
+
: submittedContent;
|
|
622
643
|
|
|
623
644
|
try {
|
|
624
645
|
localIsSending = true;
|
|
@@ -627,6 +648,12 @@
|
|
|
627
648
|
// image thumbnails linger during long generations and can re-save them as drafts.
|
|
628
649
|
localInputText = '';
|
|
629
650
|
localAttachments = [];
|
|
651
|
+
if (submittedSelectedElements) {
|
|
652
|
+
onClearSelectedElements?.();
|
|
653
|
+
if (isSelectorActive) {
|
|
654
|
+
onToggleSelector?.(false);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
630
657
|
notifyDraftChange();
|
|
631
658
|
|
|
632
659
|
// Clear head/checkpoint marks — new prompt starts a new turn
|
|
@@ -642,7 +669,7 @@
|
|
|
642
669
|
|
|
643
670
|
// Add user message to the UI immediately (local mock for instant feedback)
|
|
644
671
|
const userMessage = await chatService.sendMessage(activeConversationId, {
|
|
645
|
-
messageContent:
|
|
672
|
+
messageContent: displayMessageContent,
|
|
646
673
|
attachments: submittedAttachments
|
|
647
674
|
});
|
|
648
675
|
chatStore.actions.addMessage(activeConversationId, userMessage);
|
|
@@ -660,7 +687,7 @@
|
|
|
660
687
|
})).filter((att: { url?: string; file?: File }) => !!att.url || att.file instanceof File);
|
|
661
688
|
const saved = await onSaveMessage(
|
|
662
689
|
activeConversationId,
|
|
663
|
-
|
|
690
|
+
displayMessageContent,
|
|
664
691
|
'user',
|
|
665
692
|
persistAttachments.length > 0 ? persistAttachments : undefined,
|
|
666
693
|
);
|
|
@@ -678,15 +705,33 @@
|
|
|
678
705
|
}
|
|
679
706
|
|
|
680
707
|
if (onSendMessage) {
|
|
681
|
-
const outgoing = (submittedAttachments || []).map((att) =>
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
708
|
+
const outgoing = (submittedAttachments || []).map((att) => {
|
|
709
|
+
const rawFileName = att.file?.name || 'attachment';
|
|
710
|
+
const rawFileType = att.file?.type || '';
|
|
711
|
+
const resolvedFileType =
|
|
712
|
+
rawFileName.toLowerCase().endsWith('.csv') &&
|
|
713
|
+
(!rawFileType ||
|
|
714
|
+
rawFileType === 'application/octet-stream' ||
|
|
715
|
+
rawFileType === 'application/vnd.ms-excel' ||
|
|
716
|
+
rawFileType === 'application/csv')
|
|
717
|
+
? 'text/csv'
|
|
718
|
+
: rawFileType || 'application/octet-stream';
|
|
719
|
+
return {
|
|
720
|
+
file: att.file,
|
|
721
|
+
url: att.uploadedUrl || att.preview,
|
|
722
|
+
uploadId: att.uploadId,
|
|
723
|
+
fileType: resolvedFileType,
|
|
724
|
+
fileName: rawFileName,
|
|
725
|
+
fileSize: att.file?.size,
|
|
726
|
+
};
|
|
727
|
+
});
|
|
728
|
+
await onSendMessage(
|
|
729
|
+
submittedContent,
|
|
730
|
+
outgoing.length > 0 ? outgoing : undefined,
|
|
731
|
+
submittedSelectedElements
|
|
732
|
+
? { ...options, selectedElements: submittedSelectedElements }
|
|
733
|
+
: options
|
|
734
|
+
);
|
|
690
735
|
} else {
|
|
691
736
|
const aiResponse = await chatService.processAIResponse(activeConversationId, userMessage);
|
|
692
737
|
chatStore.actions.addMessage(activeConversationId, aiResponse);
|
|
@@ -1278,7 +1323,7 @@
|
|
|
1278
1323
|
|
|
1279
1324
|
function getAttachmentUploadIds(): string[] {
|
|
1280
1325
|
return localAttachments
|
|
1281
|
-
.filter((att) => att.
|
|
1326
|
+
.filter((att) => Boolean(att.uploadId))
|
|
1282
1327
|
.map((att) => att.uploadId as string);
|
|
1283
1328
|
}
|
|
1284
1329
|
|
|
@@ -1851,9 +1896,12 @@
|
|
|
1851
1896
|
showScreenshot={config?.features?.screenshot !== false}
|
|
1852
1897
|
showRecord={config?.features?.screenRecording !== false}
|
|
1853
1898
|
showUpload={config?.features?.fileUpload !== false}
|
|
1899
|
+
{showSelector}
|
|
1900
|
+
{isSelectorActive}
|
|
1854
1901
|
showComplete={config?.features?.markComplete !== false}
|
|
1855
1902
|
onScreenshot={() => void handleScreenshot()}
|
|
1856
1903
|
onUpload={() => void handleUpload()}
|
|
1904
|
+
onToggleSelector={(active) => onToggleSelector?.(active)}
|
|
1857
1905
|
onRecordStart={() => void handleRecordStart()}
|
|
1858
1906
|
onRecordStop={() => void handleRecordStop()}
|
|
1859
1907
|
onComplete={(detail) => void handleComplete(detail)}
|
|
@@ -1871,6 +1919,58 @@
|
|
|
1871
1919
|
</div>
|
|
1872
1920
|
{/if}
|
|
1873
1921
|
|
|
1922
|
+
{#if selectedElements && selectedElements.length > 0}
|
|
1923
|
+
<div
|
|
1924
|
+
class="prompt-chat-selected-elements-tray flex flex-wrap items-center gap-1.5 border-t border-gray-100 bg-[#F7FAF5] px-3 py-2 shrink-0"
|
|
1925
|
+
data-testid="chat-selected-elements-tray"
|
|
1926
|
+
>
|
|
1927
|
+
{#each selectedElements as item, index (item.id)}
|
|
1928
|
+
<div
|
|
1929
|
+
class="prompt-chat-selected-element-chip inline-flex max-w-full items-center gap-1.5 rounded-md border border-[#7BA668]/45 bg-white px-2 py-1 text-xs text-gray-800 shadow-xs"
|
|
1930
|
+
title={item.selector}
|
|
1931
|
+
>
|
|
1932
|
+
<span class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-[#6D9A59] font-sans text-[10px] font-bold text-white">
|
|
1933
|
+
{index + 1}
|
|
1934
|
+
</span>
|
|
1935
|
+
<span class="rounded bg-[#7BA668]/15 px-1 py-0.5 font-mono text-[11px] font-medium text-[#3C632C]">
|
|
1936
|
+
<{item.tagName}{item.idAttr ? `#${item.idAttr}` : ''}>
|
|
1937
|
+
</span>
|
|
1938
|
+
{#if item.textSnippet}
|
|
1939
|
+
<span class="text-gray-400">·</span>
|
|
1940
|
+
<span class="max-w-[180px] truncate text-[11px] text-gray-600">
|
|
1941
|
+
{item.textSnippet}
|
|
1942
|
+
</span>
|
|
1943
|
+
{:else if item.selector}
|
|
1944
|
+
<span class="text-gray-400">·</span>
|
|
1945
|
+
<span class="max-w-[160px] truncate font-mono text-[10px] text-gray-500">
|
|
1946
|
+
{item.selector}
|
|
1947
|
+
</span>
|
|
1948
|
+
{/if}
|
|
1949
|
+
{#if onRemoveSelectedElement}
|
|
1950
|
+
<button
|
|
1951
|
+
type="button"
|
|
1952
|
+
class="ms-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-gray-400 hover:bg-gray-200 hover:text-gray-700 cursor-pointer"
|
|
1953
|
+
onclick={() => onRemoveSelectedElement?.(item.id)}
|
|
1954
|
+
title={$t('chat.selector.removeElement')}
|
|
1955
|
+
aria-label={$t('chat.selector.removeElement')}
|
|
1956
|
+
>
|
|
1957
|
+
✕
|
|
1958
|
+
</button>
|
|
1959
|
+
{/if}
|
|
1960
|
+
</div>
|
|
1961
|
+
{/each}
|
|
1962
|
+
{#if selectedElements.length > 1 && onClearSelectedElements}
|
|
1963
|
+
<button
|
|
1964
|
+
type="button"
|
|
1965
|
+
class="ms-auto text-[11px] font-medium text-gray-500 hover:text-gray-800 cursor-pointer"
|
|
1966
|
+
onclick={() => onClearSelectedElements?.()}
|
|
1967
|
+
>
|
|
1968
|
+
{$t('chat.selector.clearAll')}
|
|
1969
|
+
</button>
|
|
1970
|
+
{/if}
|
|
1971
|
+
</div>
|
|
1972
|
+
{/if}
|
|
1973
|
+
|
|
1874
1974
|
{#if localAttachments.length > 0}
|
|
1875
1975
|
<div class="prompt-chat-attachments-tray-ct flex flex-wrap gap-2 p-3 border-t border-gray-100 bg-white shrink-0">
|
|
1876
1976
|
{#each localAttachments as attachment, index (attachment.preview || attachment.uploadedUrl || attachment.file?.name || index)}
|
|
@@ -2,7 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import { type TextDirection } from '@widgetic/design-system/components/textDirection';
|
|
3
3
|
import type { ChatConfig, ChatContext } from '../types/index.js';
|
|
4
4
|
import type { ClarificationSuggestion, DesignControlRequest } from '../types/message.js';
|
|
5
|
-
import type { AttachmentInput } from '../types/attachment.js';
|
|
5
|
+
import type { AttachmentInput, SelectedElementChatReference } from '../types/attachment.js';
|
|
6
6
|
interface ChatMethods {
|
|
7
7
|
sendMessage: (content: string, attachments?: Array<File | AttachmentInput>, options?: {
|
|
8
8
|
skipIntentGate?: boolean;
|
|
@@ -98,6 +98,7 @@ interface Props {
|
|
|
98
98
|
}>, options?: {
|
|
99
99
|
skipIntentGate?: boolean;
|
|
100
100
|
chipIntent?: ClarificationSuggestion['intent'];
|
|
101
|
+
selectedElements?: SelectedElementChatReference[];
|
|
101
102
|
}) => Promise<void>;
|
|
102
103
|
/** Backend integration callbacks — when provided, replace mock chatService methods */
|
|
103
104
|
onLoadConversations?: (contextId: string) => Promise<any[] | null>;
|
|
@@ -207,6 +208,18 @@ interface Props {
|
|
|
207
208
|
* `conversationLineLabel`). When omitted, message text is shown as stored.
|
|
208
209
|
*/
|
|
209
210
|
storedLineLabel?: (content: string) => string;
|
|
211
|
+
/** Show the Widget Element Selector toggle button in the action bar (disabled by default). */
|
|
212
|
+
showSelector?: boolean;
|
|
213
|
+
/** Whether the Widget Element Selector is currently active for this chat's widget. */
|
|
214
|
+
isSelectorActive?: boolean;
|
|
215
|
+
/** Selected widget elements currently referenced in this chat. */
|
|
216
|
+
selectedElements?: SelectedElementChatReference[];
|
|
217
|
+
/** Fired when the user toggles the Selector button in the action bar. */
|
|
218
|
+
onToggleSelector?: (active: boolean) => void;
|
|
219
|
+
/** Fired when the user removes a single selected widget element chip. */
|
|
220
|
+
onRemoveSelectedElement?: (elementId: string) => void;
|
|
221
|
+
/** Fired when all selected widget elements should be cleared (e.g. after sending). */
|
|
222
|
+
onClearSelectedElements?: () => void;
|
|
210
223
|
}
|
|
211
224
|
declare const Chat: import("svelte").Component<Props, {}, "">;
|
|
212
225
|
type Chat = ReturnType<typeof Chat>;
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -115,6 +115,12 @@ export declare const CHAT_MESSAGES: {
|
|
|
115
115
|
readonly 'chat.actions.upload': "Upload";
|
|
116
116
|
readonly 'chat.actions.uploadTitle': "Upload File";
|
|
117
117
|
readonly 'chat.actions.uploadLabel': "Upload file";
|
|
118
|
+
readonly 'chat.actions.selector': "Selector";
|
|
119
|
+
readonly 'chat.actions.selectorTitle': "Select a specific part of the widget to reference in chat";
|
|
120
|
+
readonly 'chat.actions.selectorActiveTitle': "Disable widget element selector";
|
|
121
|
+
readonly 'chat.actions.selectorLabel': "Toggle widget element selector";
|
|
122
|
+
readonly 'chat.selector.removeElement': "Remove selected element";
|
|
123
|
+
readonly 'chat.selector.clearAll': "Clear all";
|
|
118
124
|
readonly 'chat.actions.complete': "Complete";
|
|
119
125
|
readonly 'chat.actions.completed': "Completed";
|
|
120
126
|
readonly 'chat.actions.markCompleteTitle': "Mark this chat as done. You can still send messages and iterate on the widget.";
|
package/dist/i18n/messages.js
CHANGED
|
@@ -122,6 +122,12 @@ export const CHAT_MESSAGES = {
|
|
|
122
122
|
'chat.actions.upload': 'Upload',
|
|
123
123
|
'chat.actions.uploadTitle': 'Upload File',
|
|
124
124
|
'chat.actions.uploadLabel': 'Upload file',
|
|
125
|
+
'chat.actions.selector': 'Selector',
|
|
126
|
+
'chat.actions.selectorTitle': 'Select a specific part of the widget to reference in chat',
|
|
127
|
+
'chat.actions.selectorActiveTitle': 'Disable widget element selector',
|
|
128
|
+
'chat.actions.selectorLabel': 'Toggle widget element selector',
|
|
129
|
+
'chat.selector.removeElement': 'Remove selected element',
|
|
130
|
+
'chat.selector.clearAll': 'Clear all',
|
|
125
131
|
'chat.actions.complete': 'Complete',
|
|
126
132
|
'chat.actions.completed': 'Completed',
|
|
127
133
|
'chat.actions.markCompleteTitle': 'Mark this chat as done. You can still send messages and iterate on the widget.',
|
|
@@ -7,6 +7,28 @@ export type AttachmentType = 'image' | 'video' | 'document' | 'other';
|
|
|
7
7
|
* Attachment upload status
|
|
8
8
|
*/
|
|
9
9
|
export type UploadStatus = 'pending' | 'uploading' | 'completed' | 'failed';
|
|
10
|
+
/**
|
|
11
|
+
* Selected DOM element reference from the interactive Widget Element Selector on the canvas
|
|
12
|
+
*/
|
|
13
|
+
export interface SelectedElementChatReference {
|
|
14
|
+
id: string;
|
|
15
|
+
tagName: string;
|
|
16
|
+
selector: string;
|
|
17
|
+
idAttr?: string;
|
|
18
|
+
classList?: string[];
|
|
19
|
+
textSnippet?: string;
|
|
20
|
+
dataContent?: string;
|
|
21
|
+
parentTag?: string;
|
|
22
|
+
outerHtmlSnippet?: string;
|
|
23
|
+
attributes?: Record<string, string>;
|
|
24
|
+
rect?: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
10
32
|
/**
|
|
11
33
|
* Input for creating attachments
|
|
12
34
|
*/
|
package/dist/types/attachment.js
CHANGED
|
@@ -20,7 +20,7 @@ export const FILE_TYPE_CONFIG = {
|
|
|
20
20
|
type: 'document',
|
|
21
21
|
icon: 'file-text',
|
|
22
22
|
preview: false,
|
|
23
|
-
accept: ['application/pdf', 'text/plain', 'text/markdown', '.mermaid', '.md'],
|
|
23
|
+
accept: ['application/pdf', 'text/plain', 'text/markdown', 'text/csv', '.mermaid', '.md', '.csv'],
|
|
24
24
|
maxSize: 25 * 1024 * 1024, // 25MB
|
|
25
25
|
},
|
|
26
26
|
other: {
|
package/dist/utils/fileUtils.js
CHANGED
|
@@ -20,7 +20,7 @@ export const fileTypeConfig = {
|
|
|
20
20
|
type: 'document',
|
|
21
21
|
icon: 'file-text',
|
|
22
22
|
preview: false,
|
|
23
|
-
accept: ['application/pdf', 'text/plain', 'text/markdown', '.mermaid', '.md'],
|
|
23
|
+
accept: ['application/pdf', 'text/plain', 'text/markdown', 'text/csv', '.mermaid', '.md', '.csv'],
|
|
24
24
|
maxSize: 25 * 1024 * 1024, // 25MB
|
|
25
25
|
},
|
|
26
26
|
other: {
|
|
@@ -38,7 +38,7 @@ export function detectFileType(mimeType, fileName) {
|
|
|
38
38
|
// Check by file extension first for special cases
|
|
39
39
|
if (fileName) {
|
|
40
40
|
const extension = getFileExtension(fileName);
|
|
41
|
-
if (extension === 'mermaid' || extension === 'md') {
|
|
41
|
+
if (extension === 'mermaid' || extension === 'md' || extension === 'csv') {
|
|
42
42
|
return 'document';
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -51,6 +51,9 @@ export function detectFileType(mimeType, fileName) {
|
|
|
51
51
|
if (mimeType === 'application/pdf' ||
|
|
52
52
|
mimeType === 'text/plain' ||
|
|
53
53
|
mimeType === 'text/markdown' ||
|
|
54
|
+
mimeType === 'text/csv' ||
|
|
55
|
+
mimeType === 'application/csv' ||
|
|
56
|
+
mimeType === 'application/vnd.ms-excel' ||
|
|
54
57
|
mimeType.startsWith('text/')) {
|
|
55
58
|
return 'document';
|
|
56
59
|
}
|
|
@@ -79,10 +82,17 @@ export function validateFile(file, config) {
|
|
|
79
82
|
const mimeTypeAllowed = allowedTypes.includes(file.type);
|
|
80
83
|
// Check if file extension is explicitly allowed (e.g., .mermaid)
|
|
81
84
|
const extensionAllowed = allowedTypes.includes(`.${extension}`) || allowedTypes.includes(extension);
|
|
82
|
-
// Special handling for .mermaid and .
|
|
83
|
-
const isSpecialTextFile = (extension === 'mermaid' || extension === 'md') &&
|
|
84
|
-
file.type === 'text/plain'
|
|
85
|
-
|
|
85
|
+
// Special handling for .mermaid, .md, and .csv files with browser-specific text/csv MIME types
|
|
86
|
+
const isSpecialTextFile = (extension === 'mermaid' || extension === 'md' || extension === 'csv') &&
|
|
87
|
+
(file.type === 'text/plain' ||
|
|
88
|
+
file.type === 'text/csv' ||
|
|
89
|
+
file.type === 'application/csv' ||
|
|
90
|
+
file.type === 'application/vnd.ms-excel' ||
|
|
91
|
+
file.type === '') &&
|
|
92
|
+
(allowedTypes.includes('text/plain') ||
|
|
93
|
+
allowedTypes.includes('text/markdown') ||
|
|
94
|
+
allowedTypes.includes('text/csv') ||
|
|
95
|
+
allowedTypes.includes('.csv'));
|
|
86
96
|
if (!mimeTypeAllowed && !extensionAllowed && !isSpecialTextFile) {
|
|
87
97
|
return {
|
|
88
98
|
valid: false,
|