@svadmin/ai-elements 0.1.0 → 0.3.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 +45 -9
- package/dist/ai.css +35 -1
- package/dist/components/ChatDialog.svelte +93 -35
- 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/action/Action.svelte +48 -0
- package/dist/components/action/Action.svelte.d.ts +13 -0
- package/dist/components/action/Actions.svelte +12 -0
- package/dist/components/action/Actions.svelte.d.ts +9 -0
- package/dist/components/action/index.d.ts +4 -0
- package/dist/components/action/index.js +2 -0
- package/dist/components/artifact/ArtifactAction.svelte +43 -7
- 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/code/Code.svelte +16 -0
- package/dist/components/code/Code.svelte.d.ts +10 -0
- package/dist/components/code/index.d.ts +23 -0
- package/dist/components/code/index.js +14 -0
- package/dist/components/code-block/CodeBlock.svelte +23 -4
- package/dist/components/code-block/CodeBlock.svelte.d.ts +8 -4
- package/dist/components/code-block/CodeBlockContent.svelte +7 -1
- package/dist/components/code-block/CodeBlockContent.svelte.d.ts +1 -0
- package/dist/components/code-block/CodeBlockLine.svelte +3 -1
- package/dist/components/code-block/CodeBlockLine.svelte.d.ts +1 -0
- package/dist/components/code-block/CodeBlockOverflow.svelte +32 -0
- package/dist/components/code-block/CodeBlockOverflow.svelte.d.ts +13 -0
- package/dist/components/code-block/index.d.ts +3 -0
- package/dist/components/code-block/index.js +1 -0
- 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 +45 -9
- package/dist/components/message/MessageAction.svelte.d.ts +2 -2
- package/dist/components/message/MessageAttachment.svelte +64 -0
- package/dist/components/message/MessageAttachment.svelte.d.ts +18 -0
- package/dist/components/message/MessageAttachmentPreview.svelte +51 -0
- package/dist/components/message/MessageAttachmentPreview.svelte.d.ts +9 -0
- package/dist/components/message/MessageAttachments.svelte +25 -0
- package/dist/components/message/MessageAttachments.svelte.d.ts +9 -0
- package/dist/components/message/MessageResponse.svelte +26 -8
- package/dist/components/message/MessageResponse.svelte.d.ts +5 -5
- package/dist/components/message/index.d.ts +8 -0
- package/dist/components/message/index.js +3 -0
- package/dist/components/prompt-input/PromptInput.svelte +17 -4
- 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/PromptInputAttachment.svelte +31 -0
- package/dist/components/prompt-input/PromptInputAttachment.svelte.d.ts +9 -0
- package/dist/components/prompt-input/PromptInputAttachmentImagePreview.svelte +34 -0
- package/dist/components/prompt-input/PromptInputAttachmentImagePreview.svelte.d.ts +9 -0
- package/dist/components/prompt-input/PromptInputAttachments.svelte +22 -0
- package/dist/components/prompt-input/PromptInputAttachments.svelte.d.ts +10 -0
- 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/PromptInputToolbar.svelte +14 -0
- package/dist/components/prompt-input/PromptInputToolbar.svelte.d.ts +9 -0
- package/dist/components/prompt-input/PromptInputTools.svelte +0 -1
- package/dist/components/prompt-input/context.svelte.d.ts +1 -0
- package/dist/components/prompt-input/index.d.ts +8 -0
- package/dist/components/prompt-input/index.js +4 -0
- package/dist/components/reasoning/index.d.ts +1 -0
- package/dist/components/response/index.d.ts +2 -0
- package/dist/components/response/index.js +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 -16
- 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/VoiceSelectorRoot.svelte.d.ts +1 -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/components/workflow/index.d.ts +6 -0
- package/dist/components/workflow/index.js +3 -0
- package/dist/components/workflow/node/index.d.ts +1 -0
- package/dist/components/workflow/node/index.js +1 -0
- package/dist/components/workflow/panel/index.d.ts +1 -0
- package/dist/components/workflow/panel/index.js +1 -0
- package/dist/components/workflow/toolbar/index.d.ts +1 -0
- package/dist/components/workflow/toolbar/index.js +1 -0
- package/dist/context.svelte.d.ts +1 -0
- package/dist/contracts.d.ts +1 -1
- package/dist/generated-components.d.ts +2 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.js +8 -4
- package/dist/internal/Tooltip.svelte +124 -0
- package/dist/internal/Tooltip.svelte.d.ts +12 -0
- package/dist/parity-manifest.js +1 -0
- package/package.json +4 -3
|
@@ -1,6 +1,51 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
export type ConversationScrollButtonProps = Omit<HTMLButtonAttributes, 'children' | 'class' | 'onclick'> & {
|
|
6
|
+
class?: string;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
onclick?: (event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) => void;
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
1
12
|
<script lang="ts">
|
|
13
|
+
import { ArrowDown } from '@lucide/svelte';
|
|
2
14
|
import { useConversationContext } from '../context.svelte.js';
|
|
3
|
-
|
|
15
|
+
import { cn } from '../utils.js';
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
class: className = '',
|
|
19
|
+
children,
|
|
20
|
+
onclick,
|
|
21
|
+
type = 'button',
|
|
22
|
+
'aria-label': ariaLabel = 'Scroll to latest message',
|
|
23
|
+
...rest
|
|
24
|
+
}: ConversationScrollButtonProps = $props();
|
|
4
25
|
const conversation = useConversationContext();
|
|
26
|
+
|
|
27
|
+
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void {
|
|
28
|
+
onclick?.(event);
|
|
29
|
+
if (!event.defaultPrevented) conversation.scrollToBottom();
|
|
30
|
+
}
|
|
5
31
|
</script>
|
|
6
|
-
|
|
32
|
+
|
|
33
|
+
{#if !conversation.isAtBottom}
|
|
34
|
+
<button
|
|
35
|
+
{...rest}
|
|
36
|
+
{type}
|
|
37
|
+
class={cn(
|
|
38
|
+
'svadmin-ai__button absolute bottom-4 left-1/2 size-9 min-h-9 -translate-x-1/2 rounded-full border border-border bg-background p-0 shadow-sm',
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
aria-label={ariaLabel}
|
|
42
|
+
data-slot="conversation-scroll-button"
|
|
43
|
+
onclick={click}
|
|
44
|
+
>
|
|
45
|
+
{#if children}
|
|
46
|
+
{@render children()}
|
|
47
|
+
{:else}
|
|
48
|
+
<ArrowDown size={16} aria-hidden="true" />
|
|
49
|
+
{/if}
|
|
50
|
+
</button>
|
|
51
|
+
{/if}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
type
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
export type ConversationScrollButtonProps = Omit<HTMLButtonAttributes, 'children' | 'class' | 'onclick'> & {
|
|
2
4
|
class?: string;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
onclick?: (event: MouseEvent & {
|
|
7
|
+
currentTarget: EventTarget & HTMLButtonElement;
|
|
8
|
+
}) => void;
|
|
3
9
|
};
|
|
4
|
-
declare const ConversationScrollButton: import("svelte").Component
|
|
10
|
+
declare const ConversationScrollButton: import("svelte").Component<ConversationScrollButtonProps, {}, "">;
|
|
5
11
|
type ConversationScrollButton = ReturnType<typeof ConversationScrollButton>;
|
|
6
12
|
export default ConversationScrollButton;
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
4
|
import type { ChatMessage } from '../contracts.js';
|
|
4
|
-
import { cn } from '../utils.js';
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
children?: Snippet;
|
|
6
|
+
export type MessageProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
7
|
+
from: ChatMessage['role'];
|
|
9
8
|
class?: string;
|
|
10
|
-
|
|
9
|
+
children?: Snippet;
|
|
11
10
|
};
|
|
12
|
-
let { message, children, class: className = '' }: Props = $props();
|
|
13
|
-
const isUser = $derived(message.role === 'user');
|
|
14
11
|
</script>
|
|
15
12
|
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { cn } from '../utils.js';
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
from,
|
|
18
|
+
id,
|
|
19
|
+
class: className = '',
|
|
20
|
+
children,
|
|
21
|
+
...rest
|
|
22
|
+
}: MessageProps = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div
|
|
26
|
+
{...rest}
|
|
27
|
+
{id}
|
|
28
|
+
class={cn(
|
|
29
|
+
'group flex w-full max-w-[95%] flex-col gap-2',
|
|
30
|
+
from === 'user' ? 'is-user ml-auto justify-end' : 'is-assistant',
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
data-message-id={id}
|
|
34
|
+
data-role={from}
|
|
35
|
+
>
|
|
36
|
+
{@render children?.()}
|
|
37
|
+
</div>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import type { ChatMessage } from '../contracts.js';
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
children?: Snippet;
|
|
4
|
+
export type MessageProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
5
|
+
from: ChatMessage['role'];
|
|
6
6
|
class?: string;
|
|
7
|
-
|
|
7
|
+
children?: Snippet;
|
|
8
8
|
};
|
|
9
|
-
declare const Message: import("svelte").Component<
|
|
9
|
+
declare const Message: import("svelte").Component<MessageProps, {}, "">;
|
|
10
10
|
type Message = ReturnType<typeof Message>;
|
|
11
11
|
export default Message;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
export type MessageContentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
6
|
+
class?: string;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
3
12
|
import { cn } from '../utils.js';
|
|
4
|
-
|
|
5
|
-
let { class: className = '', children }:
|
|
13
|
+
|
|
14
|
+
let { class: className = '', children, ...rest }: MessageContentProps = $props();
|
|
6
15
|
</script>
|
|
7
|
-
|
|
16
|
+
|
|
17
|
+
<div
|
|
18
|
+
{...rest}
|
|
19
|
+
class={cn(
|
|
20
|
+
'flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-sm',
|
|
21
|
+
'group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground',
|
|
22
|
+
'group-[.is-assistant]:text-foreground',
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
data-slot="message-content"
|
|
26
|
+
>
|
|
8
27
|
{@render children?.()}
|
|
9
28
|
</div>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
type
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
export type MessageContentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
3
4
|
class?: string;
|
|
4
5
|
children?: Snippet;
|
|
5
6
|
};
|
|
6
|
-
declare const MessageContent: import("svelte").Component<
|
|
7
|
+
declare const MessageContent: import("svelte").Component<MessageContentProps, {}, "">;
|
|
7
8
|
type MessageContent = ReturnType<typeof MessageContent>;
|
|
8
9
|
export default MessageContent;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
-
|
|
5
|
-
import { provideReasoningContext } from './reasoning/context.svelte.js';
|
|
6
|
-
|
|
7
|
-
type Props = Omit<HTMLAttributes<HTMLDetailsElement>, 'children' | 'class' | 'open' | 'ontoggle' | 'title'> & {
|
|
4
|
+
export type ReasoningProps = Omit<HTMLAttributes<HTMLDetailsElement>, 'children' | 'class' | 'open' | 'ontoggle' | 'title'> & {
|
|
8
5
|
text?: string;
|
|
9
6
|
streaming?: boolean;
|
|
10
7
|
isStreaming?: boolean;
|
|
@@ -15,7 +12,14 @@
|
|
|
15
12
|
class?: string;
|
|
16
13
|
children?: Snippet;
|
|
17
14
|
onOpenChange?: (open: boolean) => void;
|
|
15
|
+
onopenchange?: (open: boolean) => void;
|
|
18
16
|
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import { untrack } from 'svelte';
|
|
21
|
+
import { cn } from '../utils.js';
|
|
22
|
+
import { provideReasoningContext } from './reasoning/context.svelte.js';
|
|
19
23
|
|
|
20
24
|
let {
|
|
21
25
|
text = '',
|
|
@@ -28,28 +32,66 @@
|
|
|
28
32
|
class: className = '',
|
|
29
33
|
children,
|
|
30
34
|
onOpenChange,
|
|
35
|
+
onopenchange,
|
|
31
36
|
...rest
|
|
32
|
-
}:
|
|
37
|
+
}: ReasoningProps = $props();
|
|
33
38
|
|
|
34
39
|
const resolvedStreaming = $derived(isStreaming ?? streaming);
|
|
35
40
|
let internalOpen = $state(untrack(() => defaultOpen ?? resolvedStreaming));
|
|
41
|
+
let computedDuration = $state<number | undefined>(undefined);
|
|
42
|
+
let startedAt = $state<number | null>(untrack(() => resolvedStreaming ? Date.now() : null));
|
|
43
|
+
let hasEverStreamed = $state(untrack(() => resolvedStreaming));
|
|
44
|
+
let hasAutoClosed = $state(false);
|
|
36
45
|
const isOpen = $derived(open ?? internalOpen);
|
|
46
|
+
const resolvedDuration = $derived(duration ?? computedDuration);
|
|
47
|
+
const explicitlyClosed = $derived(defaultOpen === false);
|
|
37
48
|
|
|
38
49
|
function setIsOpen(nextOpen: boolean): void {
|
|
50
|
+
if (nextOpen === isOpen) return;
|
|
39
51
|
if (open === undefined) internalOpen = nextOpen;
|
|
40
52
|
else open = nextOpen;
|
|
41
53
|
onOpenChange?.(nextOpen);
|
|
54
|
+
onopenchange?.(nextOpen);
|
|
42
55
|
}
|
|
43
56
|
|
|
44
57
|
provideReasoningContext({
|
|
45
58
|
get isStreaming() { return resolvedStreaming; },
|
|
46
59
|
get isOpen() { return isOpen; },
|
|
47
|
-
get duration() { return
|
|
60
|
+
get duration() { return resolvedDuration; },
|
|
48
61
|
setIsOpen,
|
|
49
62
|
});
|
|
63
|
+
|
|
64
|
+
// Keep one timing window per streaming run and close once after completion.
|
|
65
|
+
$effect(() => {
|
|
66
|
+
if (resolvedStreaming) {
|
|
67
|
+
hasEverStreamed = true;
|
|
68
|
+
if (startedAt === null) startedAt = Date.now();
|
|
69
|
+
if (!isOpen && !explicitlyClosed) setIsOpen(true);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (startedAt !== null) {
|
|
74
|
+
computedDuration = Math.ceil((Date.now() - startedAt) / 1000);
|
|
75
|
+
startedAt = null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!hasEverStreamed || !isOpen || hasAutoClosed) return;
|
|
79
|
+
|
|
80
|
+
const timer = setTimeout(() => {
|
|
81
|
+
setIsOpen(false);
|
|
82
|
+
hasAutoClosed = true;
|
|
83
|
+
}, 1000);
|
|
84
|
+
return () => clearTimeout(timer);
|
|
85
|
+
});
|
|
50
86
|
</script>
|
|
51
87
|
|
|
52
|
-
<details
|
|
88
|
+
<details
|
|
89
|
+
{...rest}
|
|
90
|
+
class={cn('svadmin-ai__surface not-prose mb-4 text-sm', className)}
|
|
91
|
+
open={isOpen}
|
|
92
|
+
data-slot="reasoning"
|
|
93
|
+
ontoggle={(event) => setIsOpen(event.currentTarget.open)}
|
|
94
|
+
>
|
|
53
95
|
{#if children}
|
|
54
96
|
{@render children()}
|
|
55
97
|
{:else}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
type
|
|
3
|
+
export type ReasoningProps = Omit<HTMLAttributes<HTMLDetailsElement>, 'children' | 'class' | 'open' | 'ontoggle' | 'title'> & {
|
|
4
4
|
text?: string;
|
|
5
5
|
streaming?: boolean;
|
|
6
6
|
isStreaming?: boolean;
|
|
@@ -11,7 +11,8 @@ type Props = Omit<HTMLAttributes<HTMLDetailsElement>, 'children' | 'class' | 'op
|
|
|
11
11
|
class?: string;
|
|
12
12
|
children?: Snippet;
|
|
13
13
|
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
onopenchange?: (open: boolean) => void;
|
|
14
15
|
};
|
|
15
|
-
declare const Reasoning: import("svelte").Component<
|
|
16
|
+
declare const Reasoning: import("svelte").Component<ReasoningProps, {}, "open">;
|
|
16
17
|
type Reasoning = ReturnType<typeof Reasoning>;
|
|
17
18
|
export default Reasoning;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
export interface ActionProps extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'size'> {
|
|
5
|
+
tooltip?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
size?: 'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg';
|
|
8
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
9
|
+
class?: string;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import Tooltip from '../../internal/Tooltip.svelte';
|
|
16
|
+
import { cn } from '../../utils.js';
|
|
17
|
+
let { tooltip, label, size = 'icon-sm', variant = 'ghost', class: className = '', type = 'button', children, 'aria-describedby': ariaDescribedBy, ...rest }: ActionProps = $props();
|
|
18
|
+
const actionChildren = $derived(children);
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Tooltip content={tooltip}>
|
|
22
|
+
{#snippet children({ describedBy })}
|
|
23
|
+
<button {...rest} {type} class={cn('svadmin-ai-action', className)} data-slot="action" data-size={size} data-variant={variant} aria-describedby={[ariaDescribedBy, describedBy].filter(Boolean).join(' ') || undefined}>
|
|
24
|
+
{@render actionChildren?.()}
|
|
25
|
+
{#if label || tooltip}<span class="svadmin-ai__sr-only">{label ?? tooltip}</span>{/if}
|
|
26
|
+
</button>
|
|
27
|
+
{/snippet}
|
|
28
|
+
</Tooltip>
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
.svadmin-ai-action { display: inline-flex; min-height: 2rem; align-items: center; justify-content: center; gap: .375rem; border: 1px solid transparent; border-radius: min(var(--radius, .5rem), .375rem); padding: .375rem .625rem; background: transparent; color: var(--muted-foreground, currentColor); font: inherit; font-size: .8125rem; cursor: pointer; }
|
|
32
|
+
.svadmin-ai-action[data-size='xs'] { min-height: 1.5rem; padding: .2rem .4rem; font-size: .75rem; }
|
|
33
|
+
.svadmin-ai-action[data-size='lg'] { min-height: 2.5rem; padding-inline: 1rem; }
|
|
34
|
+
.svadmin-ai-action[data-size^='icon'] { width: 2rem; padding: 0; }
|
|
35
|
+
.svadmin-ai-action[data-size='icon-xs'] { width: 1.5rem; min-height: 1.5rem; }
|
|
36
|
+
.svadmin-ai-action[data-size='icon-lg'] { width: 2.5rem; min-height: 2.5rem; }
|
|
37
|
+
.svadmin-ai-action[data-variant='outline'] { border-color: var(--border, currentColor); }
|
|
38
|
+
.svadmin-ai-action[data-variant='default'] { background: var(--primary, currentColor); color: var(--primary-foreground, Canvas); }
|
|
39
|
+
.svadmin-ai-action[data-variant='secondary'] { background: var(--secondary, var(--muted, transparent)); color: var(--secondary-foreground, var(--foreground, currentColor)); }
|
|
40
|
+
.svadmin-ai-action[data-variant='destructive'] { background: var(--destructive, currentColor); color: var(--destructive-foreground, Canvas); }
|
|
41
|
+
.svadmin-ai-action[data-variant='link'] { padding-inline: 0; color: var(--primary, currentColor); text-decoration: underline; text-underline-offset: .2rem; }
|
|
42
|
+
.svadmin-ai-action[data-variant='ghost']:hover:not(:disabled), .svadmin-ai-action[data-variant='outline']:hover:not(:disabled) { background: var(--muted, transparent); color: var(--foreground, currentColor); }
|
|
43
|
+
.svadmin-ai-action[data-variant='default']:hover:not(:disabled) { background: color-mix(in oklch, var(--primary, currentColor) 88%, var(--background, Canvas)); color: var(--primary-foreground, Canvas); }
|
|
44
|
+
.svadmin-ai-action[data-variant='secondary']:hover:not(:disabled) { background: color-mix(in oklch, var(--secondary, var(--muted, transparent)) 80%, var(--foreground, currentColor)); color: var(--secondary-foreground, var(--foreground, currentColor)); }
|
|
45
|
+
.svadmin-ai-action[data-variant='destructive']:hover:not(:disabled) { background: color-mix(in oklch, var(--destructive, currentColor) 88%, var(--background, Canvas)); color: var(--destructive-foreground, Canvas); }
|
|
46
|
+
.svadmin-ai-action:disabled { cursor: not-allowed; opacity: .5; }
|
|
47
|
+
.svadmin-ai-action:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
export interface ActionProps extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'size'> {
|
|
4
|
+
tooltip?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
size?: 'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg';
|
|
7
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
8
|
+
class?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const Action: import("svelte").Component<ActionProps, {}, "">;
|
|
12
|
+
type Action = ReturnType<typeof Action>;
|
|
13
|
+
export default Action;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
export type ActionsProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & { class?: string; children?: Snippet };
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { cn } from '../../utils.js';
|
|
9
|
+
let { class: className = '', children, ...rest }: ActionsProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<div {...rest} class={cn('flex items-center gap-1', className)} data-slot="actions">{@render children?.()}</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
export type ActionsProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
4
|
+
class?: string;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
};
|
|
7
|
+
declare const Actions: import("svelte").Component<ActionsProps, {}, "">;
|
|
8
|
+
type Actions = ReturnType<typeof Actions>;
|
|
9
|
+
export default Actions;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import type { LucideIcon } from '@lucide/svelte';
|
|
2
3
|
import type { Snippet } from 'svelte';
|
|
3
4
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
5
|
|
|
5
6
|
export interface ArtifactActionProps extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'title'> {
|
|
6
7
|
label?: string;
|
|
7
8
|
tooltip?: string;
|
|
9
|
+
icon?: LucideIcon;
|
|
10
|
+
size?: 'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg';
|
|
11
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
12
|
+
title?: string;
|
|
8
13
|
class?: string;
|
|
9
14
|
children?: Snippet;
|
|
10
15
|
}
|
|
@@ -12,19 +17,50 @@
|
|
|
12
17
|
|
|
13
18
|
<script lang="ts">
|
|
14
19
|
import { cn } from '../../utils.js';
|
|
15
|
-
|
|
20
|
+
import Tooltip from '../../internal/Tooltip.svelte';
|
|
21
|
+
let {
|
|
22
|
+
label,
|
|
23
|
+
tooltip,
|
|
24
|
+
icon,
|
|
25
|
+
size = 'sm',
|
|
26
|
+
variant = 'ghost',
|
|
27
|
+
title,
|
|
28
|
+
class: className = '',
|
|
29
|
+
children,
|
|
30
|
+
type = 'button',
|
|
31
|
+
'aria-describedby': ariaDescribedBy,
|
|
32
|
+
...rest
|
|
33
|
+
}: ArtifactActionProps = $props();
|
|
16
34
|
const accessibleLabel = $derived(label ?? tooltip);
|
|
35
|
+
const Icon = $derived(icon);
|
|
36
|
+
const actionChildren = $derived(children);
|
|
17
37
|
</script>
|
|
18
38
|
|
|
19
|
-
<
|
|
20
|
-
{
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
</
|
|
39
|
+
<Tooltip content={tooltip}>
|
|
40
|
+
{#snippet children({ describedBy: tooltipDescribedBy })}
|
|
41
|
+
<button {...rest} {type} class={cn('svadmin-ai-artifact-part__action', className)} aria-label={accessibleLabel} aria-describedby={[ariaDescribedBy, tooltipDescribedBy].filter(Boolean).join(' ') || undefined} {title} data-slot="artifact-action" data-size={size} data-variant={variant}>
|
|
42
|
+
{#if Icon}<Icon size={16} aria-hidden="true" />{:else}{@render actionChildren?.()}{/if}
|
|
43
|
+
{#if accessibleLabel}<span class="svadmin-ai__sr-only">{accessibleLabel}</span>{/if}
|
|
44
|
+
</button>
|
|
45
|
+
{/snippet}
|
|
46
|
+
</Tooltip>
|
|
24
47
|
|
|
25
48
|
<style>
|
|
26
49
|
.svadmin-ai-artifact-part__action { display: inline-flex; min-height: 2rem; align-items: center; justify-content: center; gap: .35rem; border: 1px solid transparent; border-radius: min(var(--radius, .5rem), .5rem); padding: .35rem .5rem; background: transparent; color: var(--muted-foreground, currentColor); font: inherit; font-size: .78rem; cursor: pointer; }
|
|
27
|
-
.svadmin-ai-artifact-part__action
|
|
50
|
+
.svadmin-ai-artifact-part__action[data-size='xs'] { min-height: 1.5rem; padding: .2rem .4rem; font-size: .72rem; }
|
|
51
|
+
.svadmin-ai-artifact-part__action[data-size^='icon'] { width: 2rem; padding: 0; }
|
|
52
|
+
.svadmin-ai-artifact-part__action[data-size='icon-xs'] { width: 1.5rem; min-height: 1.5rem; }
|
|
53
|
+
.svadmin-ai-artifact-part__action[data-size='icon-lg'] { width: 2.5rem; min-height: 2.5rem; }
|
|
54
|
+
.svadmin-ai-artifact-part__action[data-size='lg'] { min-height: 2.5rem; padding-inline: .75rem; }
|
|
55
|
+
.svadmin-ai-artifact-part__action[data-variant='outline'] { border-color: var(--border, currentColor); }
|
|
56
|
+
.svadmin-ai-artifact-part__action[data-variant='default'] { border-color: var(--primary, currentColor); background: var(--primary, currentColor); color: var(--primary-foreground, Canvas); }
|
|
57
|
+
.svadmin-ai-artifact-part__action[data-variant='secondary'] { background: var(--secondary, var(--muted, transparent)); color: var(--secondary-foreground, var(--foreground, currentColor)); }
|
|
58
|
+
.svadmin-ai-artifact-part__action[data-variant='destructive'] { background: var(--destructive, currentColor); color: var(--destructive-foreground, Canvas); }
|
|
59
|
+
.svadmin-ai-artifact-part__action[data-variant='link'] { padding-inline: 0; color: var(--primary, currentColor); text-decoration: underline; text-underline-offset: .2rem; }
|
|
60
|
+
.svadmin-ai-artifact-part__action[data-variant='ghost']:hover:not(:disabled), .svadmin-ai-artifact-part__action[data-variant='outline']:hover:not(:disabled) { border-color: var(--border, currentColor); background: var(--muted, transparent); color: var(--foreground, currentColor); }
|
|
61
|
+
.svadmin-ai-artifact-part__action[data-variant='default']:hover:not(:disabled) { border-color: var(--primary, currentColor); background: color-mix(in oklch, var(--primary, currentColor) 88%, var(--background, Canvas)); color: var(--primary-foreground, Canvas); }
|
|
62
|
+
.svadmin-ai-artifact-part__action[data-variant='secondary']:hover:not(:disabled) { background: color-mix(in oklch, var(--secondary, var(--muted, transparent)) 80%, var(--foreground, currentColor)); color: var(--secondary-foreground, var(--foreground, currentColor)); }
|
|
63
|
+
.svadmin-ai-artifact-part__action[data-variant='destructive']:hover:not(:disabled) { border-color: var(--destructive, currentColor); background: color-mix(in oklch, var(--destructive, currentColor) 88%, var(--background, Canvas)); color: var(--destructive-foreground, Canvas); }
|
|
28
64
|
.svadmin-ai-artifact-part__action:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
29
65
|
.svadmin-ai-artifact-part__action:disabled { cursor: not-allowed; opacity: .5; }
|
|
30
66
|
</style>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { LucideIcon } from '@lucide/svelte';
|
|
1
2
|
import type { Snippet } from 'svelte';
|
|
2
3
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
4
|
export interface ArtifactActionProps extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'title'> {
|
|
4
5
|
label?: string;
|
|
5
6
|
tooltip?: string;
|
|
7
|
+
icon?: LucideIcon;
|
|
8
|
+
size?: 'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg';
|
|
9
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
10
|
+
title?: string;
|
|
6
11
|
class?: string;
|
|
7
12
|
children?: Snippet;
|
|
8
13
|
}
|
|
@@ -1,24 +1,44 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
-
import { X } from '@lucide/svelte';
|
|
5
|
-
import { cn } from '../../utils.js';
|
|
6
4
|
|
|
7
|
-
interface
|
|
5
|
+
export interface ArtifactCloseProps extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'title'> {
|
|
8
6
|
label?: string;
|
|
7
|
+
size?: 'sm' | 'default' | 'icon' | 'icon-sm' | 'lg';
|
|
8
|
+
variant?: 'default' | 'outline' | 'ghost';
|
|
9
|
+
title?: string;
|
|
9
10
|
class?: string;
|
|
10
11
|
children?: Snippet;
|
|
11
12
|
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { X } from '@lucide/svelte';
|
|
17
|
+
import { cn } from '../../utils.js';
|
|
12
18
|
|
|
13
|
-
let {
|
|
19
|
+
let {
|
|
20
|
+
label = 'Close',
|
|
21
|
+
size = 'sm',
|
|
22
|
+
variant = 'ghost',
|
|
23
|
+
title,
|
|
24
|
+
class: className = '',
|
|
25
|
+
children,
|
|
26
|
+
type = 'button',
|
|
27
|
+
...rest
|
|
28
|
+
}: ArtifactCloseProps = $props();
|
|
14
29
|
</script>
|
|
15
30
|
|
|
16
|
-
<button {...rest} {type} class={cn('svadmin-ai-artifact-part__icon-button', className)} aria-label={label} title={label} data-slot="artifact-close">
|
|
31
|
+
<button {...rest} {type} class={cn('svadmin-ai-artifact-part__icon-button', className)} aria-label={label} title={title ?? label} data-slot="artifact-close" data-size={size} data-variant={variant}>
|
|
17
32
|
{#if children}{@render children()}{:else}<X size={16} aria-hidden="true" />{/if}
|
|
33
|
+
<span class="svadmin-ai__sr-only">{label}</span>
|
|
18
34
|
</button>
|
|
19
35
|
|
|
20
36
|
<style>
|
|
21
37
|
.svadmin-ai-artifact-part__icon-button { display: inline-flex; width: 2rem; height: 2rem; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: min(var(--radius, .5rem), .5rem); background: transparent; color: var(--muted-foreground, currentColor); cursor: pointer; }
|
|
38
|
+
.svadmin-ai-artifact-part__icon-button[data-size='lg'] { width: 2.5rem; height: 2.5rem; }
|
|
39
|
+
.svadmin-ai-artifact-part__icon-button[data-size='default'] { width: auto; padding-inline: .625rem; }
|
|
40
|
+
.svadmin-ai-artifact-part__icon-button[data-variant='outline'] { border-color: var(--border, currentColor); }
|
|
41
|
+
.svadmin-ai-artifact-part__icon-button[data-variant='default'] { border-color: var(--primary, currentColor); background: var(--primary, currentColor); color: var(--primary-foreground, Canvas); }
|
|
22
42
|
.svadmin-ai-artifact-part__icon-button:hover:not(:disabled) { border-color: var(--border, currentColor); color: var(--foreground, currentColor); }
|
|
23
43
|
.svadmin-ai-artifact-part__icon-button:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
24
44
|
.svadmin-ai-artifact-part__icon-button:disabled { cursor: not-allowed; opacity: .5; }
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
-
interface
|
|
3
|
+
export interface ArtifactCloseProps extends Omit<HTMLButtonAttributes, 'children' | 'class' | 'title'> {
|
|
4
4
|
label?: string;
|
|
5
|
+
size?: 'sm' | 'default' | 'icon' | 'icon-sm' | 'lg';
|
|
6
|
+
variant?: 'default' | 'outline' | 'ghost';
|
|
7
|
+
title?: string;
|
|
5
8
|
class?: string;
|
|
6
9
|
children?: Snippet;
|
|
7
10
|
}
|
|
8
|
-
declare const ArtifactClose: import("svelte").Component<
|
|
11
|
+
declare const ArtifactClose: import("svelte").Component<ArtifactCloseProps, {}, "">;
|
|
9
12
|
type ArtifactClose = ReturnType<typeof ArtifactClose>;
|
|
10
13
|
export default ArtifactClose;
|
|
@@ -8,3 +8,4 @@ export { default as Action, default as ArtifactAction } from './ArtifactAction.s
|
|
|
8
8
|
export { default as Content, default as ArtifactContent } from './ArtifactContent.svelte';
|
|
9
9
|
export type { ArtifactKind } from './Artifact.svelte';
|
|
10
10
|
export type { ArtifactActionProps } from './ArtifactAction.svelte';
|
|
11
|
+
export type { ArtifactCloseProps } from './ArtifactClose.svelte';
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, ...rest }: Props = $props();
|
|
5
5
|
</script>
|
|
6
6
|
<div {...rest} class={cn('flex items-center gap-1', className)} role="group" aria-label={rest['aria-label'] ?? 'Audio controls'} data-slot="audio-player-control-bar">{@render children?.()}</div>
|
|
7
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, ...rest }: Props = $props(); const context = useAudioPlayerContext('AudioPlayerDurationDisplay');
|
|
5
5
|
</script>
|
|
6
6
|
<span {...rest} class={cn('min-w-10 text-center text-xs tabular-nums text-muted-foreground', className)} data-slot="audio-player-duration-display">{#if children}{@render children(context.duration)}{:else}{formatAudioTime(context.duration)}{/if}</span>
|
|
7
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) context.toggleMuted(); }
|
|
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-label={context.muted ? 'Unmute audio' : 'Mute audio'} aria-pressed={context.muted} data-slot="audio-player-mute-button" onclick={click}>{#if children}{@render children(context.muted)}{:else if context.muted}<VolumeX size={15} aria-hidden="true" />{:else}<Volume2 size={15} aria-hidden="true" />{/if}</button>
|
|
8
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) context.togglePlayback(); }
|
|
6
6
|
</script>
|
|
7
7
|
<button {...rest} type="button" class={cn('svadmin-ai__button size-8 min-h-8 p-0', className)} aria-label={context.playing ? 'Pause audio' : 'Play audio'} aria-pressed={context.playing} data-slot="audio-player-play-button" onclick={click}>{#if children}{@render children(context.playing)}{:else if context.loading}<LoaderCircle class="animate-spin" size={15} aria-hidden="true" />{:else if context.playing}<Pause size={15} aria-hidden="true" />{:else}<Play size={15} aria-hidden="true" />{/if}</button>
|
|
8
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) context.seekBy(-Math.abs(seekOffset)); }
|
|
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-label={`Seek backward ${seekOffset} seconds`} data-slot="audio-player-seek-backward-button" onclick={click}>{#if children}{@render children(seekOffset)}{:else}<RotateCcw size={15} aria-hidden="true" />{/if}</button>
|
|
8
|
-
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
function click(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }): void { onclick?.(event); if (!event.defaultPrevented) context.seekBy(Math.abs(seekOffset)); }
|
|
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-label={`Seek forward ${seekOffset} seconds`} data-slot="audio-player-seek-forward-button" onclick={click}>{#if children}{@render children(seekOffset)}{:else}<RotateCw size={15} aria-hidden="true" />{/if}</button>
|
|
8
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
let { class: className = '', children, ...rest }: Props = $props(); const context = useAudioPlayerContext('AudioPlayerTimeDisplay');
|
|
5
5
|
</script>
|
|
6
6
|
<span {...rest} class={cn('min-w-10 text-center text-xs tabular-nums text-muted-foreground', className)} data-slot="audio-player-time-display">{#if children}{@render children(context.currentTime)}{:else}{formatAudioTime(context.currentTime)}{/if}</span>
|
|
7
|
-
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
function input(event: Event & { currentTarget: EventTarget & HTMLInputElement }): void { context.seekTo(Number(event.currentTarget.value)); oninput?.(event); }
|
|
5
5
|
</script>
|
|
6
6
|
<input {...rest} class={cn('min-w-20 flex-1 accent-primary', className)} type="range" min="0" max={context.duration || 0} step="0.01" value={context.currentTime} disabled={rest.disabled || context.duration <= 0} aria-label={rest['aria-label'] ?? 'Audio position'} aria-valuetext={`${formatAudioTime(context.currentTime)} of ${formatAudioTime(context.duration)}`} data-slot="audio-player-time-range" oninput={input} />
|
|
7
|
-
|