@svadmin/ai-elements 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -6
- package/dist/components/ChatDialog.svelte +83 -28
- package/dist/components/ChatDialog.svelte.d.ts +6 -0
- package/dist/components/Conversation.svelte +37 -17
- package/dist/components/Conversation.svelte.d.ts +3 -2
- package/dist/components/ConversationContent.svelte +29 -4
- package/dist/components/ConversationContent.svelte.d.ts +3 -2
- package/dist/components/ConversationEmptyState.svelte +33 -7
- package/dist/components/ConversationEmptyState.svelte.d.ts +4 -2
- package/dist/components/ConversationScrollButton.svelte +47 -2
- package/dist/components/ConversationScrollButton.svelte.d.ts +8 -2
- package/dist/components/Message.svelte +30 -16
- package/dist/components/Message.svelte.d.ts +5 -5
- package/dist/components/MessageContent.svelte +23 -4
- package/dist/components/MessageContent.svelte.d.ts +3 -2
- package/dist/components/Reasoning.svelte +51 -9
- package/dist/components/Reasoning.svelte.d.ts +4 -3
- package/dist/components/artifact/ArtifactAction.svelte +37 -6
- package/dist/components/artifact/ArtifactAction.svelte.d.ts +5 -0
- package/dist/components/artifact/ArtifactClose.svelte +26 -6
- package/dist/components/artifact/ArtifactClose.svelte.d.ts +5 -2
- package/dist/components/artifact/index.d.ts +1 -0
- package/dist/components/audio-player/AudioPlayerControlBar.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerDurationDisplay.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerElement.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerMuteButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerPlayButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerSeekBackwardButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerSeekForwardButton.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerTimeDisplay.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerTimeRange.svelte +0 -1
- package/dist/components/audio-player/AudioPlayerVolumeRange.svelte +0 -1
- package/dist/components/checkpoint/index.d.ts +2 -2
- package/dist/components/context/Context.svelte +46 -5
- package/dist/components/context/Context.svelte.d.ts +5 -1
- package/dist/components/conversation/index.d.ts +4 -0
- package/dist/components/file-tree/FileTree.svelte +35 -16
- package/dist/components/file-tree/FileTree.svelte.d.ts +7 -1
- package/dist/components/file-tree/FileTreeFile.svelte +3 -3
- package/dist/components/file-tree/FileTreeFile.svelte.d.ts +1 -0
- package/dist/components/file-tree/context.svelte.d.ts +2 -0
- package/dist/components/inline-citation/InlineCitation.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCardBody.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselHeader.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselIndex.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselNext.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationCarouselPrev.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationQuote.svelte +0 -1
- package/dist/components/inline-citation/InlineCitationText.svelte +0 -1
- package/dist/components/jsx-preview/JSXPreviewContent.svelte +43 -31
- package/dist/components/jsx-preview/index.d.ts +1 -1
- package/dist/components/jsx-preview/parser.d.ts +18 -8
- package/dist/components/jsx-preview/parser.js +1 -1
- package/dist/components/message/MessageAction.svelte +37 -7
- package/dist/components/message/MessageAction.svelte.d.ts +1 -1
- package/dist/components/message/MessageResponse.svelte +23 -7
- package/dist/components/message/MessageResponse.svelte.d.ts +5 -5
- package/dist/components/message/index.d.ts +2 -0
- package/dist/components/prompt-input/PromptInput.svelte +16 -3
- package/dist/components/prompt-input/PromptInput.svelte.d.ts +3 -1
- package/dist/components/prompt-input/PromptInputActionAddAttachments.svelte +0 -1
- package/dist/components/prompt-input/PromptInputActionMenuContent.svelte +0 -1
- package/dist/components/prompt-input/PromptInputActionMenuTrigger.svelte +0 -1
- package/dist/components/prompt-input/PromptInputBody.svelte +0 -1
- package/dist/components/prompt-input/PromptInputButton.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommand.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandEmpty.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandGroup.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandInput.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandList.svelte +0 -1
- package/dist/components/prompt-input/PromptInputCommandSeparator.svelte +0 -1
- package/dist/components/prompt-input/PromptInputFooter.svelte +0 -1
- package/dist/components/prompt-input/PromptInputHeader.svelte +0 -1
- package/dist/components/prompt-input/PromptInputHoverCardContent.svelte +0 -1
- package/dist/components/prompt-input/PromptInputHoverCardTrigger.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSelectContent.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSelectItem.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSelectTrigger.svelte +0 -1
- package/dist/components/prompt-input/PromptInputSubmit.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTab.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabBody.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabItem.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabLabel.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTabsList.svelte +0 -1
- package/dist/components/prompt-input/PromptInputTextarea.svelte +3 -3
- package/dist/components/prompt-input/PromptInputTools.svelte +0 -1
- package/dist/components/prompt-input/context.svelte.d.ts +1 -0
- package/dist/components/reasoning/index.d.ts +1 -0
- package/dist/components/sandbox/SandboxHeader.svelte +13 -4
- package/dist/components/sandbox/SandboxHeader.svelte.d.ts +6 -5
- package/dist/components/sandbox/SandboxTabContent.svelte +1 -1
- package/dist/components/sandbox/SandboxTabs.svelte +2 -2
- package/dist/components/sandbox/SandboxTabs.svelte.d.ts +1 -0
- package/dist/components/sandbox/SandboxTabsTrigger.svelte +12 -2
- package/dist/components/sandbox/SandboxTabsTrigger.svelte.d.ts +4 -5
- package/dist/components/sandbox/context.svelte.d.ts +2 -0
- package/dist/components/snippet/index.d.ts +2 -2
- package/dist/components/stack-trace/StackTrace.svelte +6 -4
- package/dist/components/stack-trace/StackTrace.svelte.d.ts +2 -1
- package/dist/components/stack-trace/StackTraceCopyButton.svelte +48 -2
- package/dist/components/stack-trace/StackTraceHeader.svelte +37 -2
- package/dist/components/stack-trace/StackTraceHeader.svelte.d.ts +2 -2
- package/dist/components/suggestion/index.d.ts +1 -1
- package/dist/components/terminal/AnsiText.svelte +42 -0
- package/dist/components/terminal/AnsiText.svelte.d.ts +6 -0
- package/dist/components/terminal/Terminal.svelte +20 -10
- package/dist/components/terminal/Terminal.svelte.d.ts +2 -1
- package/dist/components/terminal/TerminalContent.svelte +2 -2
- package/dist/components/terminal/ansi.d.ts +12 -0
- package/dist/components/terminal/ansi.js +76 -0
- package/dist/components/tool/ToolHeader.svelte +4 -3
- package/dist/components/tool/ToolStatusBadge.svelte +4 -3
- package/dist/components/tool/index.d.ts +1 -1
- package/dist/components/tool/status.d.ts +4 -1
- package/dist/components/tool/status.js +7 -7
- package/dist/components/transcription/Transcription.svelte +22 -14
- package/dist/components/transcription/Transcription.svelte.d.ts +2 -1
- package/dist/components/transcription/TranscriptionSegment.svelte +1 -1
- package/dist/components/transcription/context.svelte.d.ts +1 -0
- package/dist/components/voice-selector/VoiceSelectorAccent.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorAge.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorAttributes.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorBullet.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorContent.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorDescription.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorDialog.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorEmpty.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorGender.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorGroup.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorInput.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorList.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorName.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorPreview.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorSeparator.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorShortcut.svelte +0 -1
- package/dist/components/voice-selector/VoiceSelectorTrigger.svelte +0 -1
- package/dist/context.svelte.d.ts +1 -0
- package/dist/generated-components.d.ts +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/parity-manifest.js +1 -0
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLFormAttributes } from 'svelte/elements';
|
|
2
3
|
import type { ChatAttachment, ChatSource } from '../../contracts.js';
|
|
3
4
|
export interface PromptInputMessage {
|
|
4
5
|
text: string;
|
|
@@ -10,7 +11,7 @@ export interface PromptInputSubmitDetail extends PromptInputMessage {
|
|
|
10
11
|
attachments: ChatAttachment[];
|
|
11
12
|
event: SubmitEvent;
|
|
12
13
|
}
|
|
13
|
-
export interface PromptInputProps {
|
|
14
|
+
export interface PromptInputProps extends Omit<HTMLFormAttributes, 'children' | 'class' | 'onerror' | 'onsubmit'> {
|
|
14
15
|
value?: string;
|
|
15
16
|
attachments?: ChatAttachment[];
|
|
16
17
|
accept?: string;
|
|
@@ -22,6 +23,7 @@ export interface PromptInputProps {
|
|
|
22
23
|
maxFiles?: number;
|
|
23
24
|
maxFileSize?: number;
|
|
24
25
|
globalDrop?: boolean;
|
|
26
|
+
syncHiddenInput?: boolean;
|
|
25
27
|
placeholder?: string;
|
|
26
28
|
ariaLabel?: string;
|
|
27
29
|
class?: string;
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
</script>
|
|
7
7
|
<input bind:this={input} class="svadmin-ai__sr-only" type="file" {accept} {multiple} aria-label={label} onchange={(event) => { const files = event.currentTarget.files; if (files) attachments.add(files); event.currentTarget.value = ''; }} />
|
|
8
8
|
<button {...rest} type="button" role="menuitem" class={cn('flex min-h-9 w-full items-center gap-2 rounded px-2 text-left text-sm hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring', className)} data-slot="prompt-input-action-add-attachments" onclick={open}><Image size={16} aria-hidden="true" />{label}</button>
|
|
9
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, align = 'start', ...rest }: Props = $props(); const menu = usePromptInputMenu();
|
|
5
5
|
</script>
|
|
6
6
|
{#if menu.open}<div {...rest} class={cn('absolute bottom-full z-30 mb-1 grid min-w-48 gap-0.5 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md', align === 'end' && 'right-0', align === 'center' && 'left-1/2 -translate-x-1/2', align === 'start' && 'left-0', className)} role="menu" data-slot="prompt-input-action-menu-content">{@render children?.()}</div>{/if}
|
|
7
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) menu.setOpen(!menu.open); }
|
|
6
6
|
</script>
|
|
7
7
|
<button {...rest} type="button" class={cn('svadmin-ai__button svadmin-ai__button--ghost size-8 min-h-8 p-0', className)} aria-haspopup="menu" aria-expanded={menu.open} aria-label={rest['aria-label'] ?? 'Prompt actions'} data-slot="prompt-input-action-menu-trigger" onclick={click}>{#if children}{@render children()}{:else}<Plus size={16} aria-hidden="true" />{/if}</button>
|
|
8
|
-
|
|
@@ -9,4 +9,3 @@
|
|
|
9
9
|
const tooltipText = $derived(typeof tooltip === 'string' ? tooltip : tooltip?.content);
|
|
10
10
|
</script>
|
|
11
11
|
<button {...rest} {type} title={title ?? tooltipText} class={cn('svadmin-ai__button', variant === 'ghost' && 'svadmin-ai__button--ghost', variant === 'outline' && 'border border-border bg-transparent', size === 'icon-sm' ? 'size-8 min-h-8 p-0' : 'min-h-8 px-3', className)} data-slot="prompt-input-button">{@render children?.()}{#if tooltip && typeof tooltip !== 'string' && tooltip.shortcut}<span class="svadmin-ai__sr-only">{tooltip.shortcut}</span>{/if}</button>
|
|
12
|
-
|
|
@@ -13,4 +13,3 @@
|
|
|
13
13
|
function keydown(event: KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement }): void { onkeydown?.(event); if (event.defaultPrevented) return; if (event.key === 'ArrowDown') { event.preventDefault(); move(1); } else if (event.key === 'ArrowUp') { event.preventDefault(); move(-1); } else if (event.key === 'Enter') { event.preventDefault(); selectActive(); } }
|
|
14
14
|
</script>
|
|
15
15
|
<div {...rest} class={cn('grid max-h-72 min-w-48 overflow-auto rounded-md border border-border bg-popover p-1 text-popover-foreground', className)} role="listbox" aria-label="Command menu" data-slot="prompt-input-command" onkeydown={keydown}>{@render children?.()}</div>
|
|
16
|
-
|
|
@@ -3,4 +3,3 @@
|
|
|
3
3
|
let { class: className = '', children }: { class?: string; children?: Snippet } = $props(); const command = usePromptInputCommand();
|
|
4
4
|
</script>
|
|
5
5
|
{#if command.visibleCount === 0}<p class={cn('px-3 py-6 text-center text-sm text-muted-foreground', className)} data-slot="prompt-input-command-empty">{#if children}{@render children()}{:else}No results found.{/if}</p>{/if}
|
|
6
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, heading, ...rest }: Props = $props();
|
|
5
5
|
</script>
|
|
6
6
|
<div {...rest} class={cn('grid gap-0.5 p-1', className)} role="group" data-slot="prompt-input-command-group">{#if heading}<h3 class="px-2 py-1 text-xs font-medium text-muted-foreground">{heading}</h3>{/if}{@render children?.()}</div>
|
|
7
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function input(event: Event & { currentTarget: EventTarget & HTMLInputElement }): void { command.setQuery(event.currentTarget.value); oninput?.(event); }
|
|
6
6
|
</script>
|
|
7
7
|
<label class={cn('flex min-h-9 items-center gap-2 border-b border-border px-2 text-sm', className)} data-slot="prompt-input-command-input"><Search size={14} aria-hidden="true" /><input {...rest} class="min-w-0 flex-1 border-0 bg-transparent outline-none" value={resolved} {placeholder} aria-label={rest['aria-label'] ?? 'Search'} oninput={input} /></label>
|
|
8
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, ...rest }: Props = $props(); const card = usePromptInputHoverCard();
|
|
5
5
|
</script>
|
|
6
6
|
{#if card.open}<div {...rest} class={cn('absolute bottom-full left-0 z-30 mb-2 w-64 rounded-md border border-border bg-popover p-3 text-popover-foreground shadow-md', className)} role="dialog" data-slot="prompt-input-hover-card-content">{@render children?.()}</div>{/if}
|
|
7
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, ...rest }: Props = $props(); const select = usePromptInputSelect();
|
|
5
5
|
</script>
|
|
6
6
|
{#if select.open}<div {...rest} class={cn('absolute bottom-full left-0 z-30 mb-1 grid min-w-40 gap-0.5 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md', className)} role="listbox" data-slot="prompt-input-select-content">{@render children?.()}</div>{/if}
|
|
7
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) select.setValue(value); }
|
|
6
6
|
</script>
|
|
7
7
|
<button {...rest} type="button" role="option" aria-selected={select.value === value} class={cn('flex min-h-8 w-full items-center gap-2 rounded px-2 text-left text-sm hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring', className)} data-slot="prompt-input-select-item" onclick={click}>{#if select.value === value}<Check size={14} aria-hidden="true" />{:else}<span class="size-3" aria-hidden="true"></span>{/if}{#if children}{@render children()}{:else}{value}{/if}</button>
|
|
8
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) select.setOpen(!select.open); }
|
|
6
6
|
</script>
|
|
7
7
|
<button {...rest} type="button" class={cn('inline-flex min-h-8 items-center gap-1 rounded px-2 text-xs font-medium text-muted-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring', className)} aria-haspopup="listbox" aria-expanded={select.open} data-slot="prompt-input-select-trigger" onclick={click}>{#if children}{@render children()}{:else}{select.value || 'Select'}{/if}<ChevronDown size={13} aria-hidden="true" /></button>
|
|
8
|
-
|
|
@@ -9,4 +9,3 @@
|
|
|
9
9
|
<button {...rest} type={generating && (onstop || onStop) ? 'button' : 'submit'} class={cn('svadmin-ai__button size-8 min-h-8 p-0', className)} aria-label={generating ? 'Stop' : 'Submit'} data-slot="prompt-input-submit" onclick={click}>
|
|
10
10
|
{#if children}{@render children()}{:else if status === 'submitted'}<LoaderCircle class="animate-spin" size={15} aria-hidden="true" />{:else if status === 'streaming'}<Square size={14} fill="currentColor" aria-hidden="true" />{:else if status === 'error'}<X size={15} aria-hidden="true" />{:else}<CornerDownLeft size={15} aria-hidden="true" />{/if}
|
|
11
11
|
</button>
|
|
12
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, value, active = false, ...rest }: Props = $props();
|
|
5
5
|
</script>
|
|
6
6
|
<div {...rest} class={cn('grid gap-2', className)} data-slot="prompt-input-tab" data-value={value} data-state={active ? 'active' : 'inactive'}>{@render children?.()}</div>
|
|
7
|
-
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
import { cn } from '../../utils.js';
|
|
4
4
|
import { usePromptInputAttachments, usePromptInputController } from './context.svelte.js';
|
|
5
5
|
interface Props extends Omit<HTMLTextareaAttributes, 'class' | 'value'> { class?: string; value?: string; }
|
|
6
|
-
let { class: className = '', value, name
|
|
6
|
+
let { class: className = '', value, name, placeholder = 'What would you like to know?', oninput, onkeydown, onpaste, oncompositionstart, oncompositionend, ...rest }: Props = $props();
|
|
7
7
|
const controller = usePromptInputController();
|
|
8
8
|
const attachments = usePromptInputAttachments();
|
|
9
9
|
let composing = $state(false);
|
|
10
10
|
const resolvedValue = $derived(value ?? controller.textInput.value);
|
|
11
|
+
const resolvedName = $derived(name ?? (controller.syncHiddenInput ? undefined : 'message'));
|
|
11
12
|
function input(event: Event & { currentTarget: EventTarget & HTMLTextAreaElement }): void { controller.textInput.setInput(event.currentTarget.value); oninput?.(event); }
|
|
12
13
|
function keydown(event: KeyboardEvent & { currentTarget: EventTarget & HTMLTextAreaElement }): void {
|
|
13
14
|
onkeydown?.(event); if (event.defaultPrevented) return;
|
|
@@ -18,5 +19,4 @@
|
|
|
18
19
|
function start(event: CompositionEvent & { currentTarget: EventTarget & HTMLTextAreaElement }): void { composing = true; oncompositionstart?.(event); }
|
|
19
20
|
function end(event: CompositionEvent & { currentTarget: EventTarget & HTMLTextAreaElement }): void { composing = false; oncompositionend?.(event); }
|
|
20
21
|
</script>
|
|
21
|
-
<textarea {...rest} {
|
|
22
|
-
|
|
22
|
+
<textarea {...rest} name={resolvedName} {placeholder} value={resolvedValue} class={cn('svadmin-ai__textarea field-sizing-content max-h-48 min-h-16 border-0 bg-transparent outline-none', className)} data-slot="prompt-input-textarea" oninput={input} onkeydown={keydown} onpaste={paste} oncompositionstart={start} oncompositionend={end}></textarea>
|
|
@@ -21,6 +21,7 @@ export interface PromptInputTextContext {
|
|
|
21
21
|
export interface PromptInputController {
|
|
22
22
|
readonly textInput: PromptInputTextContext;
|
|
23
23
|
readonly attachments: PromptInputAttachmentsContext;
|
|
24
|
+
readonly syncHiddenInput?: boolean;
|
|
24
25
|
registerFileInput(input: HTMLInputElement | null, open?: () => void): void;
|
|
25
26
|
}
|
|
26
27
|
export interface PromptInputReferencedSourcesContext {
|
|
@@ -2,6 +2,7 @@ export { default, default as Root, default as Reasoning } from '../Reasoning.sve
|
|
|
2
2
|
export { default as Trigger, default as ReasoningTrigger } from './ReasoningTrigger.svelte';
|
|
3
3
|
export { default as Content, default as ReasoningContent } from './ReasoningContent.svelte';
|
|
4
4
|
export { useReasoning } from './context.svelte.js';
|
|
5
|
+
export type { ReasoningProps } from '../Reasoning.svelte';
|
|
5
6
|
export type { ReasoningContextValue } from './context.svelte.js';
|
|
6
7
|
export type { ReasoningTriggerProps } from './ReasoningTrigger.svelte';
|
|
7
8
|
export type { ReasoningContentProps } from './ReasoningContent.svelte';
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
import { ChevronDown, Code2 } from '@lucide/svelte';
|
|
5
|
+
import { cn } from '../../utils.js';
|
|
6
|
+
import { getStatusBadge, type ToolDisplayState } from '../tool/status.js';
|
|
7
|
+
import { useSandboxContext } from './context.svelte.js';
|
|
8
|
+
|
|
9
|
+
interface Props extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'title'> { title?: string; state: ToolDisplayState; class?: string; children?: Snippet; }
|
|
10
|
+
let { title = 'Sandbox', state, class: className = '', children, onclick, ...rest }: Props = $props();
|
|
11
|
+
const context = useSandboxContext();
|
|
12
|
+
const badge = $derived(getStatusBadge(state));
|
|
13
|
+
function toggle(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) context.setOpen(!context.open); }
|
|
5
14
|
</script>
|
|
6
|
-
<button type="button" class={cn('flex w-full items-center justify-between gap-4 border-0 bg-transparent p-3 text-left hover:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring', className)} aria-expanded={context.open} onclick={
|
|
15
|
+
<button {...rest} type="button" class={cn('flex w-full items-center justify-between gap-4 border-0 bg-transparent p-3 text-left hover:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring', className)} aria-expanded={context.open} onclick={toggle}><span class="flex min-w-0 items-center gap-2"><Code2 class="size-4 shrink-0 text-muted-foreground" aria-hidden="true" /><span class="truncate text-sm font-medium">{title}</span><span class="rounded-md bg-muted px-2 py-0.5 text-xs text-muted-foreground" data-state={state} data-tone={badge.tone}>{badge.label}</span>{#if children}{@render children()}{/if}</span><ChevronDown class={cn('size-4 shrink-0 text-muted-foreground transition-transform', context.open && 'rotate-180')} aria-hidden="true" /></button>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
type
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
import { type ToolDisplayState } from '../tool/status.js';
|
|
4
|
+
interface Props extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'title'> {
|
|
3
5
|
title?: string;
|
|
4
|
-
state
|
|
6
|
+
state: ToolDisplayState;
|
|
5
7
|
class?: string;
|
|
6
8
|
children?: Snippet;
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
declare const SandboxHeader: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
}
|
|
10
|
+
declare const SandboxHeader: import("svelte").Component<Props, {}, "">;
|
|
10
11
|
type SandboxHeader = ReturnType<typeof SandboxHeader>;
|
|
11
12
|
export default SandboxHeader;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<script lang="ts">import type { Snippet } from 'svelte'; import { cn } from '../../utils.js'; import { useSandboxTabsContext } from './context.svelte.js'; let { value, class: className = '', children, ...rest }: { value: string; class?: string; children?: Snippet; [key: string]: unknown } = $props(); const context = useSandboxTabsContext(); const active = $derived(context.value === value);</script>
|
|
2
|
-
{#if active}<div role="tabpanel" data-value={value} class={cn('mt-0 text-sm', className)}
|
|
2
|
+
{#if active}<div {...rest} id={context.panelId(value)} role="tabpanel" aria-labelledby={context.tabId(value)} tabindex="0" data-state="active" data-value={value} class={cn('mt-0 text-sm', className)}>{@render children?.()}</div>{/if}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<script lang="ts">import type { Snippet } from 'svelte'; import { cn } from '../../utils.js'; import { provideSandboxTabsContext } from './context.svelte.js'; let { defaultValue = '', value = $bindable(defaultValue), class: className = '', children, onvaluechange, ...rest }: { value?: string; defaultValue?: string; class?: string; children?: Snippet; onvaluechange?: (value: string) => void; [key: string]: unknown } = $props(); function setValue(next: string): void { value = next; onvaluechange?.(next); } provideSandboxTabsContext({ get value() { return value; }, setValue });</script>
|
|
2
|
-
<div class={cn('w-full', className)} data-value={value}
|
|
1
|
+
<script lang="ts">import type { Snippet } from 'svelte'; import { cn } from '../../utils.js'; import { provideSandboxTabsContext } from './context.svelte.js'; let { defaultValue = '', value = $bindable(defaultValue), class: className = '', children, onvaluechange, onValueChange, ...rest }: { value?: string; defaultValue?: string; class?: string; children?: Snippet; onvaluechange?: (value: string) => void; onValueChange?: (value: string) => void; [key: string]: unknown } = $props(); const id = $props.id(); function setValue(next: string): void { value = next; onvaluechange?.(next); if (onValueChange !== onvaluechange) onValueChange?.(next); } function partId(kind: 'tab' | 'panel', next: string): string { return `${id}-${kind}-${encodeURIComponent(next)}`; } provideSandboxTabsContext({ get value() { return value; }, setValue, tabId(next) { return partId('tab', next); }, panelId(next) { return partId('panel', next); } });</script>
|
|
2
|
+
<div {...rest} class={cn('w-full', className)} data-value={value}>{@render children?.()}</div>
|
|
@@ -5,6 +5,7 @@ type $$ComponentProps = {
|
|
|
5
5
|
class?: string;
|
|
6
6
|
children?: Snippet;
|
|
7
7
|
onvaluechange?: (value: string) => void;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
8
9
|
[key: string]: unknown;
|
|
9
10
|
};
|
|
10
11
|
declare const SandboxTabs: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'; import type { HTMLButtonAttributes } from 'svelte/elements'; import { cn } from '../../utils.js'; import { useSandboxTabsContext } from './context.svelte.js';
|
|
3
|
+
interface Props extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'value'> { value: string; class?: string; children?: Snippet; }
|
|
4
|
+
let { value, class: className = '', children, disabled = false, onclick, onkeydown, ...rest }: Props = $props(); const context = useSandboxTabsContext(); const active = $derived(context.value === value);
|
|
5
|
+
function select(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) context.setValue(value); }
|
|
6
|
+
function moveFocus(event: KeyboardEvent & { currentTarget: EventTarget & HTMLButtonElement }): void {
|
|
7
|
+
onkeydown?.(event); if (event.defaultPrevented || !['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) return;
|
|
8
|
+
const tabs = Array.from(event.currentTarget.closest('[role="tablist"]')?.querySelectorAll<HTMLButtonElement>('[role="tab"]:not(:disabled)') ?? []); const current = tabs.indexOf(event.currentTarget); if (current < 0 || tabs.length === 0) return;
|
|
9
|
+
event.preventDefault(); const delta = event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1; const target = event.key === 'Home' ? tabs[0] : event.key === 'End' ? tabs.at(-1) : tabs[(current + delta + tabs.length) % tabs.length]; target?.focus(); target?.click();
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
<button {...rest} id={context.tabId(value)} type="button" role="tab" aria-controls={context.panelId(value)} aria-selected={active} data-state={active ? 'active' : 'inactive'} tabindex={active ? 0 : -1} class={cn('rounded-none border-0 border-b-2 border-transparent bg-transparent px-4 py-2 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring', active && 'border-primary text-foreground', className)} {disabled} onclick={select} onkeydown={moveFocus}>{@render children?.()}</button>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
type
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'value'> {
|
|
3
4
|
value: string;
|
|
4
5
|
class?: string;
|
|
5
6
|
children?: Snippet;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
declare const SandboxTabsTrigger: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
}
|
|
8
|
+
declare const SandboxTabsTrigger: import("svelte").Component<Props, {}, "">;
|
|
10
9
|
type SandboxTabsTrigger = ReturnType<typeof SandboxTabsTrigger>;
|
|
11
10
|
export default SandboxTabsTrigger;
|
|
@@ -5,6 +5,8 @@ export interface SandboxContextValue {
|
|
|
5
5
|
export interface SandboxTabsContextValue {
|
|
6
6
|
readonly value: string;
|
|
7
7
|
setValue(value: string): void;
|
|
8
|
+
tabId(value: string): string;
|
|
9
|
+
panelId(value: string): string;
|
|
8
10
|
}
|
|
9
11
|
export declare function provideSandboxContext(value: SandboxContextValue): void;
|
|
10
12
|
export declare function useSandboxContext(): SandboxContextValue;
|
|
@@ -5,7 +5,7 @@ import SnippetInput from './SnippetInput.svelte';
|
|
|
5
5
|
import SnippetText from './SnippetText.svelte';
|
|
6
6
|
export { Snippet, SnippetAddon, SnippetCopyButton, SnippetInput, SnippetText };
|
|
7
7
|
export declare const Root: import("svelte").Component<import("./Snippet.svelte").SnippetProps, {}, "">;
|
|
8
|
-
export declare const Addon: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "
|
|
8
|
+
export declare const Addon: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "children" | "class"> & {
|
|
9
9
|
align?: "inline-start" | "inline-end" | "block-start" | "block-end";
|
|
10
10
|
class?: string;
|
|
11
11
|
children?: import("svelte").Snippet;
|
|
@@ -16,7 +16,7 @@ export declare const Input: import("svelte").Component<Omit<import("svelte/eleme
|
|
|
16
16
|
} & {
|
|
17
17
|
ariaLabel?: string;
|
|
18
18
|
}, {}, "">;
|
|
19
|
-
export declare const Text: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLSpanElement>, "
|
|
19
|
+
export declare const Text: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLSpanElement>, "children" | "class"> & {
|
|
20
20
|
class?: string;
|
|
21
21
|
children?: import("svelte").Snippet;
|
|
22
22
|
}, {}, "">;
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
|
|
19
19
|
<script lang="ts">
|
|
20
20
|
import type { Snippet } from 'svelte';
|
|
21
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
21
22
|
import { ChevronDown, Copy, ExternalLink } from '@lucide/svelte';
|
|
22
23
|
import { cn } from '../../utils.js';
|
|
23
|
-
interface Props {
|
|
24
|
+
interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'class' | 'title'> {
|
|
24
25
|
trace?: string;
|
|
25
26
|
error?: StackTraceErrorData | Error | string;
|
|
26
27
|
message?: string;
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
stack,
|
|
46
47
|
frames,
|
|
47
48
|
title = 'Stack trace',
|
|
48
|
-
defaultOpen =
|
|
49
|
+
defaultOpen = false,
|
|
49
50
|
open = $bindable(defaultOpen),
|
|
50
51
|
class: className = '',
|
|
51
52
|
children,
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
onfilepathclick,
|
|
55
56
|
onOpenChange,
|
|
56
57
|
onFilePathClick,
|
|
58
|
+
...rest
|
|
57
59
|
}: Props = $props();
|
|
58
60
|
|
|
59
61
|
import { parseStackTrace as parseCompoundStackTrace, provideStackTraceContext } from './context.svelte.js';
|
|
@@ -102,11 +104,11 @@
|
|
|
102
104
|
</script>
|
|
103
105
|
|
|
104
106
|
{#if children}
|
|
105
|
-
<section class={cn('svadmin-ai-stack-trace', 'svadmin-ai-stack-trace--compound', className)} data-slot="stack-trace">
|
|
107
|
+
<section {...rest} class={cn('svadmin-ai-stack-trace', 'svadmin-ai-stack-trace--compound', className)} data-slot="stack-trace">
|
|
106
108
|
{@render children()}
|
|
107
109
|
</section>
|
|
108
110
|
{:else}
|
|
109
|
-
<details class={cn('svadmin-ai-stack-trace', className)} {open} ontoggle={(event) => { const next = (event.currentTarget as HTMLDetailsElement).open; open = next; onopenchange?.(next); if (onOpenChange !== onopenchange) onOpenChange?.(next); }}>
|
|
111
|
+
<details {...rest} class={cn('svadmin-ai-stack-trace', className)} {open} ontoggle={(event) => { const next = (event.currentTarget as HTMLDetailsElement).open; open = next; onopenchange?.(next); if (onOpenChange !== onopenchange) onOpenChange?.(next); }}>
|
|
110
112
|
<summary class="svadmin-ai-stack-trace__summary">
|
|
111
113
|
<span class="svadmin-ai-stack-trace__summary-main">
|
|
112
114
|
<span class="svadmin-ai-stack-trace__chevron" aria-hidden="true"><ChevronDown size={15} /></span>
|
|
@@ -13,7 +13,8 @@ export interface StackTraceErrorData {
|
|
|
13
13
|
stack?: string;
|
|
14
14
|
}
|
|
15
15
|
import type { Snippet } from 'svelte';
|
|
16
|
-
|
|
16
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
17
|
+
interface Props extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'class' | 'title'> {
|
|
17
18
|
trace?: string;
|
|
18
19
|
error?: StackTraceErrorData | Error | string;
|
|
19
20
|
message?: string;
|
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
import { Check, Copy } from '@lucide/svelte';
|
|
5
|
+
import { cn } from '../../utils.js';
|
|
6
|
+
import { useStackTraceContext } from './context.svelte.js';
|
|
7
|
+
|
|
8
|
+
interface Props extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'onerror'> {
|
|
9
|
+
class?: string;
|
|
10
|
+
children?: Snippet<[boolean]>;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
oncopy?: () => void;
|
|
13
|
+
onerror?: (error: Error) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { class: className = '', children, timeout = 2000, oncopy, onerror, onclick, onkeydown, disabled = false, ...rest }: Props = $props();
|
|
17
|
+
const stack = useStackTraceContext('StackTraceCopyButton');
|
|
18
|
+
let copied = $state(false);
|
|
19
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
20
|
+
|
|
21
|
+
async function copyTrace(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): Promise<void> {
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
onclick?.(event);
|
|
24
|
+
if (disabled || event.defaultPrevented) return;
|
|
25
|
+
if (typeof navigator === 'undefined' || !navigator.clipboard?.writeText) {
|
|
26
|
+
onerror?.(new Error('Clipboard API not available'));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
await navigator.clipboard.writeText(stack.raw);
|
|
31
|
+
copied = true;
|
|
32
|
+
oncopy?.();
|
|
33
|
+
if (timer) clearTimeout(timer);
|
|
34
|
+
timer = setTimeout(() => { copied = false; }, timeout);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
onerror?.(error instanceof Error ? error : new Error('Copy failed'));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function stopKeyboardPropagation(event: KeyboardEvent & { currentTarget: EventTarget & HTMLButtonElement }): void {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
onkeydown?.(event);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
$effect(() => () => { if (timer) clearTimeout(timer); });
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<button {...rest} type="button" class={cn('svadmin-ai-stack-part__button', className)} aria-label={copied ? 'Copied stack trace' : 'Copy stack trace'} title={copied ? 'Copied' : 'Copy stack trace'} {disabled} data-slot="stack-trace-copy-button" onclick={copyTrace} onkeydown={stopKeyboardPropagation}>{#if children}{@render children(copied)}{:else}{#if copied}<Check size={14} aria-hidden="true" />{:else}<Copy size={14} aria-hidden="true" />{/if}{/if}</button>
|
|
3
49
|
<style>.svadmin-ai-stack-part__button { display: inline-flex; width: 1.9rem; height: 1.9rem; align-items: center; justify-content: center; border: 0; border-radius: min(var(--radius, .5rem), .5rem); background: transparent; color: var(--muted-foreground, currentColor); cursor: pointer; }.svadmin-ai-stack-part__button:hover:not(:disabled) { background: var(--muted, transparent); color: var(--foreground, currentColor); }.svadmin-ai-stack-part__button:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }</style>
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { cn } from '../../utils.js';
|
|
5
|
+
import { useStackTraceContext } from './context.svelte.js';
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> {
|
|
8
|
+
class?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { class: className = '', children, onclick, onkeydown, tabindex = 0, ...rest }: Props = $props();
|
|
13
|
+
const stack = useStackTraceContext('StackTraceHeader');
|
|
14
|
+
|
|
15
|
+
function toggleFromClick(event: MouseEvent & { currentTarget: EventTarget & HTMLDivElement }): void {
|
|
16
|
+
onclick?.(event);
|
|
17
|
+
if (!event.defaultPrevented) stack.setOpen(!stack.open);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function toggleFromKeyboard(event: KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement }): void {
|
|
21
|
+
onkeydown?.(event);
|
|
22
|
+
if (event.defaultPrevented || event.target !== event.currentTarget || (event.key !== 'Enter' && event.key !== ' ')) return;
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
stack.setOpen(!stack.open);
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div
|
|
29
|
+
{...rest}
|
|
30
|
+
role="button"
|
|
31
|
+
{tabindex}
|
|
32
|
+
class={cn('svadmin-ai-stack-part__header', className)}
|
|
33
|
+
aria-expanded={stack.open}
|
|
34
|
+
data-slot="stack-trace-header"
|
|
35
|
+
onclick={toggleFromClick}
|
|
36
|
+
onkeydown={toggleFromKeyboard}
|
|
37
|
+
>{@render children?.()}</div>
|
|
3
38
|
<style>.svadmin-ai-stack-part__header { display: flex; width: 100%; align-items: center; gap: .75rem; padding: .7rem .8rem; border: 0; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; }.svadmin-ai-stack-part__header:hover { background: var(--muted, transparent); }.svadmin-ai-stack-part__header:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: -2px; }</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type {
|
|
3
|
-
interface Props extends Omit<
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> {
|
|
4
4
|
class?: string;
|
|
5
5
|
children?: Snippet;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Suggestion from './Suggestion.svelte';
|
|
2
2
|
import Suggestions from './Suggestions.svelte';
|
|
3
3
|
export { Suggestion, Suggestions };
|
|
4
|
-
export declare const Root: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "
|
|
4
|
+
export declare const Root: import("svelte").Component<Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "children" | "class"> & {
|
|
5
5
|
class?: string;
|
|
6
6
|
children?: import("svelte").Snippet;
|
|
7
7
|
ariaLabel?: string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { parseAnsi } from './ansi.js';
|
|
3
|
+
|
|
4
|
+
let { text }: { text: string } = $props();
|
|
5
|
+
const segments = $derived(parseAnsi(text));
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
{#each segments as segment, index (`${index}-${segment.text}`)}
|
|
9
|
+
<span
|
|
10
|
+
data-ansi-foreground={segment.foreground}
|
|
11
|
+
data-ansi-background={segment.background}
|
|
12
|
+
data-ansi-bold={segment.bold || undefined}
|
|
13
|
+
data-ansi-dim={segment.dim || undefined}
|
|
14
|
+
data-ansi-italic={segment.italic || undefined}
|
|
15
|
+
data-ansi-underline={segment.underline || undefined}
|
|
16
|
+
data-ansi-strikethrough={segment.strikethrough || undefined}
|
|
17
|
+
>{segment.text}</span>
|
|
18
|
+
{/each}
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
[data-ansi-bold='true'] { font-weight: 700; }
|
|
22
|
+
[data-ansi-dim='true'] { opacity: .65; }
|
|
23
|
+
[data-ansi-italic='true'] { font-style: italic; }
|
|
24
|
+
[data-ansi-underline='true'] { text-decoration: underline; }
|
|
25
|
+
[data-ansi-strikethrough='true'] { text-decoration: line-through; }
|
|
26
|
+
[data-ansi-foreground='black'] { color: var(--muted-foreground, currentColor); }
|
|
27
|
+
[data-ansi-foreground='red'] { color: var(--destructive, currentColor); }
|
|
28
|
+
[data-ansi-foreground='green'] { color: var(--success, currentColor); }
|
|
29
|
+
[data-ansi-foreground='yellow'] { color: var(--warning, currentColor); }
|
|
30
|
+
[data-ansi-foreground='blue'] { color: var(--info, var(--primary, currentColor)); }
|
|
31
|
+
[data-ansi-foreground='magenta'] { color: var(--chart-4, var(--primary, currentColor)); }
|
|
32
|
+
[data-ansi-foreground='cyan'] { color: var(--chart-5, var(--info, currentColor)); }
|
|
33
|
+
[data-ansi-foreground='white'] { color: var(--foreground, currentColor); }
|
|
34
|
+
[data-ansi-background='black'] { background: var(--muted, transparent); }
|
|
35
|
+
[data-ansi-background='red'] { background: color-mix(in srgb, var(--destructive, currentColor) 22%, transparent); }
|
|
36
|
+
[data-ansi-background='green'] { background: color-mix(in srgb, var(--success, currentColor) 22%, transparent); }
|
|
37
|
+
[data-ansi-background='yellow'] { background: color-mix(in srgb, var(--warning, currentColor) 22%, transparent); }
|
|
38
|
+
[data-ansi-background='blue'] { background: color-mix(in srgb, var(--info, var(--primary, currentColor)) 22%, transparent); }
|
|
39
|
+
[data-ansi-background='magenta'] { background: color-mix(in srgb, var(--chart-4, var(--primary, currentColor)) 22%, transparent); }
|
|
40
|
+
[data-ansi-background='cyan'] { background: color-mix(in srgb, var(--chart-5, var(--info, currentColor)) 22%, transparent); }
|
|
41
|
+
[data-ansi-background='white'] { background: color-mix(in srgb, var(--foreground, currentColor) 18%, transparent); }
|
|
42
|
+
</style>
|