@svadmin/ai-elements 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -4
- package/UPSTREAM_PARITY.md +69 -0
- package/dist/ai.css +49 -1
- package/dist/components/ChatDialog.svelte +44 -38
- package/dist/components/ChatDialog.svelte.d.ts +5 -5
- package/dist/components/CopilotPanel.svelte +2 -2
- 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 +21 -16
- package/dist/components/artifact/ArtifactAction.svelte.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/commit/CommitActions.svelte +10 -1
- package/dist/components/message/MessageAction.svelte +22 -16
- 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 +9 -7
- package/dist/components/message/MessageResponse.svelte.d.ts +1 -1
- package/dist/components/message/index.d.ts +6 -0
- package/dist/components/message/index.js +3 -0
- package/dist/components/prompt-input/PromptInput.svelte +1 -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/PromptInputToolbar.svelte +14 -0
- package/dist/components/prompt-input/PromptInputToolbar.svelte.d.ts +9 -0
- package/dist/components/prompt-input/index.d.ts +8 -0
- package/dist/components/prompt-input/index.js +4 -0
- package/dist/components/response/index.d.ts +2 -0
- package/dist/components/response/index.js +1 -0
- package/dist/components/tool/ToolHeader.svelte +4 -17
- package/dist/components/voice-selector/VoiceSelectorRoot.svelte.d.ts +1 -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/contracts.d.ts +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -3
- package/dist/internal/Tooltip.svelte +124 -0
- package/dist/internal/Tooltip.svelte.d.ts +12 -0
- package/dist/parity-manifest.d.ts +1 -0
- package/dist/parity-manifest.js +97 -0
- package/dist/utils.d.ts +1 -2
- package/dist/utils.js +1 -5
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -58,7 +58,8 @@ The packed-package verification loads the root entry through `vite.ssrLoadModule
|
|
|
58
58
|
import {
|
|
59
59
|
Conversation,
|
|
60
60
|
Message,
|
|
61
|
-
|
|
61
|
+
MessageContent,
|
|
62
|
+
MessageResponse,
|
|
62
63
|
messageText,
|
|
63
64
|
PromptInput,
|
|
64
65
|
} from '@svadmin/ai-elements';
|
|
@@ -75,9 +76,9 @@ The packed-package verification loads the root entry through `vite.ssrLoadModule
|
|
|
75
76
|
|
|
76
77
|
<Conversation>
|
|
77
78
|
<Message from={message.role} data-message-id={message.id}>
|
|
78
|
-
<
|
|
79
|
-
<
|
|
80
|
-
</
|
|
79
|
+
<MessageContent>
|
|
80
|
+
<MessageResponse content={messageText(message)} />
|
|
81
|
+
</MessageContent>
|
|
81
82
|
</Message>
|
|
82
83
|
</Conversation>
|
|
83
84
|
|
|
@@ -107,6 +108,28 @@ export const componentRegistry = {
|
|
|
107
108
|
};
|
|
108
109
|
```
|
|
109
110
|
|
|
111
|
+
Admin tools use the same TypeBox boundary. Call tools through
|
|
112
|
+
`executeAdminTool` so untrusted model arguments are decoded before the tool
|
|
113
|
+
implementation runs:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { Type } from '@sinclair/typebox';
|
|
117
|
+
import { defineAdminTool, executeAdminTool } from '@svadmin/core';
|
|
118
|
+
|
|
119
|
+
const searchInventory = defineAdminTool({
|
|
120
|
+
name: 'searchInventory',
|
|
121
|
+
description: 'Search inventory by warehouse',
|
|
122
|
+
parameters: Type.Object({
|
|
123
|
+
warehouse: Type.String(),
|
|
124
|
+
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 100 })),
|
|
125
|
+
}),
|
|
126
|
+
readOnly: true,
|
|
127
|
+
execute: async ({ warehouse, limit }) => inventory.search({ warehouse, limit }),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
await executeAdminTool(searchInventory, modelArguments);
|
|
131
|
+
```
|
|
132
|
+
|
|
110
133
|
## Upstream parity
|
|
111
134
|
|
|
112
135
|
`AI_ELEMENT_PARITY` pins the audited `vercel/ai-elements` commit and verifies
|
|
@@ -116,6 +139,11 @@ interaction or pixel parity. `JSXPreview` intentionally uses a restricted,
|
|
|
116
139
|
TypeBox-validated parser instead of executing arbitrary JSX. `Tool.getStatusBadge`
|
|
117
140
|
returns Svelte-renderable status metadata instead of a React element.
|
|
118
141
|
|
|
142
|
+
The architecture comparison, adopted Sikandar patterns, component counts, and
|
|
143
|
+
intentional framework differences are documented in
|
|
144
|
+
[`UPSTREAM_PARITY.md`](./UPSTREAM_PARITY.md). Behavior classifications must be
|
|
145
|
+
backed by an existing test file in the parity manifest.
|
|
146
|
+
|
|
119
147
|
## AdminApp Integration
|
|
120
148
|
|
|
121
149
|
Pass providers through the owning Svelte tree and render the assistant through
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Upstream architecture and parity assessment
|
|
2
|
+
|
|
3
|
+
This package is evaluated against fixed source snapshots so that component
|
|
4
|
+
counts and behavior claims remain reproducible:
|
|
5
|
+
|
|
6
|
+
- `vercel/ai-elements` at `6a9d5b1822ffb10bba4bd97175f01edd7d8651cd`
|
|
7
|
+
- `vuepont/ai-elements-vue` at `ad4818f6081a2fe6e5b7bb53cebc5a66d9a24148`
|
|
8
|
+
- `SikandarJODD/ai-elements` at `fa4bc217f84bc571378bc371332a154106772614`
|
|
9
|
+
|
|
10
|
+
## Architecture decision
|
|
11
|
+
|
|
12
|
+
SVAdmin keeps its package-first architecture instead of copying the reference
|
|
13
|
+
applications wholesale. The current structure is stronger for an admin
|
|
14
|
+
framework because it provides:
|
|
15
|
+
|
|
16
|
+
- Svelte 5 runes, snippets, bindable state, and scoped context instead of React
|
|
17
|
+
compatibility wrappers;
|
|
18
|
+
- structured `ChatMessagePart` data for text, reasoning, tools, sources,
|
|
19
|
+
attachments, approvals, and generated components;
|
|
20
|
+
- TypeBox runtime boundaries for generated component props and agent tool
|
|
21
|
+
arguments;
|
|
22
|
+
- SSR, package-export, packed-consumer, and workspace integration gates;
|
|
23
|
+
- semantic design tokens and tenant/provider ownership inherited from SVAdmin.
|
|
24
|
+
|
|
25
|
+
The Sikandar project is stronger as a component-learning reference. Its
|
|
26
|
+
co-located examples, registry organization, concise component files, and
|
|
27
|
+
Svelte-native compound APIs make individual components easy to inspect. We
|
|
28
|
+
adopted the useful parts without importing its application routing or registry
|
|
29
|
+
runtime into the package:
|
|
30
|
+
|
|
31
|
+
- generic `Action` and `Code` families;
|
|
32
|
+
- message and prompt attachment composition;
|
|
33
|
+
- workflow subpath aggregation;
|
|
34
|
+
- small compound component files and Svelte context APIs;
|
|
35
|
+
- explicit `content` props for Markdown responses rather than attempting to
|
|
36
|
+
recover text from compiled Svelte snippets.
|
|
37
|
+
|
|
38
|
+
## Component inventory
|
|
39
|
+
|
|
40
|
+
The pinned official package exposes 49 component families and 398 runtime
|
|
41
|
+
exports. `vuepont/ai-elements-vue` exposes 48 comparable families. The Sikandar
|
|
42
|
+
documentation registry lists a smaller application-focused set, while SVAdmin
|
|
43
|
+
also includes admin-specific chat surfaces such as `ChatDialog`,
|
|
44
|
+
`CopilotPanel`, `AICommandBar`, `InsightCard`, `SmartSuggest`, and `VoiceInput`.
|
|
45
|
+
|
|
46
|
+
`AI_ELEMENT_PARITY` is the authoritative machine-readable inventory. Every
|
|
47
|
+
official runtime export is mapped to a local Svelte export. Behavior status is
|
|
48
|
+
tracked separately and must name an existing test file before a family can be
|
|
49
|
+
classified as verified. This prevents an export-only audit from being reported
|
|
50
|
+
as functional parity.
|
|
51
|
+
|
|
52
|
+
## Intentional framework differences
|
|
53
|
+
|
|
54
|
+
Two official helpers intentionally differ while preserving the user-facing
|
|
55
|
+
capability:
|
|
56
|
+
|
|
57
|
+
- `JSXPreview` parses a restricted, TypeBox-validated component grammar rather
|
|
58
|
+
than executing arbitrary JSX.
|
|
59
|
+
- `Tool.getStatusBadge` returns Svelte-renderable status metadata rather than a
|
|
60
|
+
React element.
|
|
61
|
+
|
|
62
|
+
`MessageResponse` accepts Markdown through `content` or `text`. Plain Svelte
|
|
63
|
+
children remain snippets and are rendered as authored UI; they are not mounted
|
|
64
|
+
into a hidden DOM node and scraped back into a string. This matches the
|
|
65
|
+
Sikandar Svelte implementation and preserves SSR and streaming reactivity.
|
|
66
|
+
|
|
67
|
+
Visual evidence remains independent from behavior evidence. A component can
|
|
68
|
+
be behavior-verified without claiming pixel identity across React, Vue, and
|
|
69
|
+
Svelte rendering stacks.
|
package/dist/ai.css
CHANGED
|
@@ -56,6 +56,53 @@
|
|
|
56
56
|
border-color: var(--border, currentColor);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
.svadmin-ai__icon-button {
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
width: 1.75rem;
|
|
62
|
+
height: 1.75rem;
|
|
63
|
+
min-height: 1.75rem;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
border: 1px solid transparent;
|
|
67
|
+
border-radius: min(var(--radius, 0.5rem), 0.375rem);
|
|
68
|
+
padding: 0;
|
|
69
|
+
background: transparent;
|
|
70
|
+
color: var(--muted-foreground, currentColor);
|
|
71
|
+
font: inherit;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.svadmin-ai__icon-button:hover:not(:disabled) {
|
|
77
|
+
background: color-mix(in oklch, var(--muted, transparent) 72%, transparent);
|
|
78
|
+
color: var(--foreground, currentColor);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.svadmin-ai__icon-button:focus-visible {
|
|
82
|
+
outline: 0;
|
|
83
|
+
box-shadow:
|
|
84
|
+
0 0 0 1px var(--card, Canvas),
|
|
85
|
+
0 0 0 3px var(--ring, currentColor);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.svadmin-ai__icon-button:active:not(:disabled) {
|
|
89
|
+
background: var(--muted, transparent);
|
|
90
|
+
transform: translateY(1px);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.svadmin-ai__icon-button--close {
|
|
94
|
+
color: color-mix(in oklch, var(--muted-foreground, currentColor) 88%, transparent);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.svadmin-ai__icon-button--close:hover:not(:disabled) {
|
|
98
|
+
background: var(--muted, transparent);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.svadmin-ai__icon-button:disabled {
|
|
102
|
+
cursor: not-allowed;
|
|
103
|
+
opacity: 0.5;
|
|
104
|
+
}
|
|
105
|
+
|
|
59
106
|
.svadmin-ai__button--danger {
|
|
60
107
|
background: var(--destructive, currentColor);
|
|
61
108
|
color: var(--destructive-foreground, Canvas);
|
|
@@ -102,5 +149,6 @@
|
|
|
102
149
|
}
|
|
103
150
|
|
|
104
151
|
@media (prefers-reduced-motion: reduce) {
|
|
105
|
-
.svadmin-ai__button
|
|
152
|
+
.svadmin-ai__button,
|
|
153
|
+
.svadmin-ai__icon-button { transition: none; }
|
|
106
154
|
}
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
type Props = {
|
|
55
|
-
/**
|
|
55
|
+
/** Renders a compact launcher button in the layout toolbar. */
|
|
56
56
|
docked?: boolean;
|
|
57
|
-
/**
|
|
57
|
+
/** Enables an isolated localStorage key; persistence requires a stable user identity. */
|
|
58
58
|
persistKey?: string;
|
|
59
59
|
onPersist?: (messages: ChatMessage[]) => void;
|
|
60
60
|
onRestore?: () => ChatMessage[];
|
|
61
61
|
onPersistenceError?: (detail: ChatPersistenceErrorDetail) => void;
|
|
62
|
-
/**
|
|
62
|
+
/** Stable scope for targeted `svadmin:ask-ai` events. */
|
|
63
63
|
scope?: string;
|
|
64
|
-
/**
|
|
64
|
+
/** Owning Layout scope used to arbitrate global shortcuts. */
|
|
65
65
|
ownerScope?: string;
|
|
66
|
-
/** Agent
|
|
66
|
+
/** Controlled component registry available to Agent rendering; unregistered names are never loaded dynamically. */
|
|
67
67
|
componentRegistry?: ComponentRegistry;
|
|
68
68
|
class?: string;
|
|
69
69
|
};
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
try {
|
|
172
172
|
apiUrl = adminContext.getDataProvider().getApiUrl();
|
|
173
173
|
} catch {
|
|
174
|
-
//
|
|
174
|
+
// Allow standalone usage with only an AI provider configured.
|
|
175
175
|
}
|
|
176
176
|
const tenantIdentity = adminContext.tenantCacheKey?.__svadminTenant;
|
|
177
177
|
const typedTenant = tenantIdentity === undefined
|
|
@@ -477,10 +477,10 @@
|
|
|
477
477
|
return file ? { id, type: 'file', file } : null;
|
|
478
478
|
}
|
|
479
479
|
case 'approval':
|
|
480
|
-
//
|
|
480
|
+
// Approvals depend on runtime capabilities; neither resolved nor pending states can be restored from storage.
|
|
481
481
|
return null;
|
|
482
482
|
case 'component':
|
|
483
|
-
//
|
|
483
|
+
// Generated components may carry host actions; discard them during restore based on capability state.
|
|
484
484
|
return null;
|
|
485
485
|
default:
|
|
486
486
|
return null;
|
|
@@ -639,7 +639,7 @@
|
|
|
639
639
|
return () => window.removeEventListener('svadmin:ask-ai', handler);
|
|
640
640
|
});
|
|
641
641
|
|
|
642
|
-
//
|
|
642
|
+
// A delayed snapshot must use the callback captured at creation, not a newer callback after rerender.
|
|
643
643
|
$effect.pre(() => {
|
|
644
644
|
const callback = onPersist;
|
|
645
645
|
untrack(() => {
|
|
@@ -654,7 +654,7 @@
|
|
|
654
654
|
});
|
|
655
655
|
});
|
|
656
656
|
|
|
657
|
-
//
|
|
657
|
+
// Each API, typed tenant, and explicit user key has an isolated history and run scope.
|
|
658
658
|
$effect.pre(() => {
|
|
659
659
|
const scopeToken = historyScopeToken;
|
|
660
660
|
const key = resolvedPersistKey;
|
|
@@ -694,7 +694,7 @@
|
|
|
694
694
|
});
|
|
695
695
|
});
|
|
696
696
|
|
|
697
|
-
// provider
|
|
697
|
+
// The provider identity may change while the persistence key stays stable; late results must still be invalidated.
|
|
698
698
|
$effect.pre(() => {
|
|
699
699
|
const nextRunScope = {
|
|
700
700
|
tenantIdentity: adminContext.tenantCacheKey?.__svadminTenant,
|
|
@@ -871,7 +871,7 @@
|
|
|
871
871
|
const activeProvider = provider;
|
|
872
872
|
if ((value.length === 0 && attachments.length === 0) || isStreaming || (!activeAgent && !activeProvider)) return;
|
|
873
873
|
|
|
874
|
-
//
|
|
874
|
+
// A new run revokes unresolved approval capabilities from the previous run.
|
|
875
875
|
if (approvalEntries.size > 0 || abortController) invalidateActiveRun();
|
|
876
876
|
approvalIds.clear();
|
|
877
877
|
|
|
@@ -1173,49 +1173,55 @@
|
|
|
1173
1173
|
aria-label="AI assistant"
|
|
1174
1174
|
aria-busy={isStreaming}
|
|
1175
1175
|
>
|
|
1176
|
-
<header class="flex shrink-0 items-center justify-between gap-3 border-b border-border/70 bg-
|
|
1176
|
+
<header class="flex shrink-0 items-center justify-between gap-3 border-b border-border/70 bg-card px-4 py-3 text-card-foreground">
|
|
1177
1177
|
<div class="flex min-w-0 items-center gap-2">
|
|
1178
|
-
<span class="flex size-8 shrink-0 items-center justify-center rounded-
|
|
1179
|
-
<Bot size={
|
|
1178
|
+
<span class="flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground" aria-hidden="true">
|
|
1179
|
+
<Bot size={16} />
|
|
1180
1180
|
</span>
|
|
1181
1181
|
<div class="min-w-0">
|
|
1182
1182
|
<h2 class="truncate text-sm font-semibold">AI assistant</h2>
|
|
1183
|
-
<p class="truncate text-xs
|
|
1183
|
+
<p class="svadmin-ai__muted truncate text-xs" aria-live="polite">
|
|
1184
1184
|
{isStreaming ? 'Generating response' : (chatContext.currentResource ?? 'Workspace')}
|
|
1185
1185
|
</p>
|
|
1186
1186
|
</div>
|
|
1187
1187
|
</div>
|
|
1188
|
-
<div class="flex shrink-0 items-center
|
|
1189
|
-
|
|
1188
|
+
<div class="flex shrink-0 items-center" role="toolbar" aria-label="AI assistant controls">
|
|
1189
|
+
<div class="flex items-center gap-0.5">
|
|
1190
|
+
{#if messages.length > 0}
|
|
1191
|
+
<button
|
|
1192
|
+
type="button"
|
|
1193
|
+
class="svadmin-ai__icon-button"
|
|
1194
|
+
aria-label="Clear conversation"
|
|
1195
|
+
title="Clear conversation"
|
|
1196
|
+
onclick={clearChat}
|
|
1197
|
+
>
|
|
1198
|
+
<Trash2 size={14} strokeWidth={1.75} aria-hidden="true" />
|
|
1199
|
+
</button>
|
|
1200
|
+
{/if}
|
|
1190
1201
|
<button
|
|
1191
1202
|
type="button"
|
|
1192
|
-
class="svadmin-
|
|
1193
|
-
aria-label=
|
|
1194
|
-
|
|
1203
|
+
class="svadmin-ai__icon-button"
|
|
1204
|
+
aria-label={minimized ? 'Expand AI assistant' : 'Minimize AI assistant'}
|
|
1205
|
+
title={minimized ? 'Expand AI assistant' : 'Minimize AI assistant'}
|
|
1206
|
+
aria-expanded={!minimized}
|
|
1207
|
+
onclick={() => { minimized = !minimized; }}
|
|
1195
1208
|
>
|
|
1196
|
-
|
|
1209
|
+
{#if minimized}
|
|
1210
|
+
<Maximize2 size={14} strokeWidth={1.75} aria-hidden="true" />
|
|
1211
|
+
{:else}
|
|
1212
|
+
<Minus size={14} strokeWidth={1.75} aria-hidden="true" />
|
|
1213
|
+
{/if}
|
|
1197
1214
|
</button>
|
|
1198
|
-
|
|
1199
|
-
<
|
|
1200
|
-
type="button"
|
|
1201
|
-
class="svadmin-ai__button svadmin-ai__button--ghost size-8 min-h-8 border-primary-foreground/25 p-0 text-primary-foreground"
|
|
1202
|
-
aria-label={minimized ? 'Expand AI assistant' : 'Minimize AI assistant'}
|
|
1203
|
-
aria-expanded={!minimized}
|
|
1204
|
-
onclick={() => { minimized = !minimized; }}
|
|
1205
|
-
>
|
|
1206
|
-
{#if minimized}
|
|
1207
|
-
<Maximize2 size={15} aria-hidden="true" />
|
|
1208
|
-
{:else}
|
|
1209
|
-
<Minus size={15} aria-hidden="true" />
|
|
1210
|
-
{/if}
|
|
1211
|
-
</button>
|
|
1215
|
+
</div>
|
|
1216
|
+
<span class="mx-1.5 h-4 w-px bg-border/70" aria-hidden="true"></span>
|
|
1212
1217
|
<button
|
|
1213
1218
|
type="button"
|
|
1214
|
-
class="svadmin-
|
|
1219
|
+
class="svadmin-ai__icon-button svadmin-ai__icon-button--close"
|
|
1215
1220
|
aria-label="Close AI assistant"
|
|
1221
|
+
title="Close AI assistant"
|
|
1216
1222
|
onclick={closeDialog}
|
|
1217
1223
|
>
|
|
1218
|
-
<X size={
|
|
1224
|
+
<X size={14} strokeWidth={1.75} aria-hidden="true" />
|
|
1219
1225
|
</button>
|
|
1220
1226
|
</div>
|
|
1221
1227
|
</header>
|
|
@@ -7,18 +7,18 @@ export interface ChatPersistenceErrorDetail {
|
|
|
7
7
|
error: unknown;
|
|
8
8
|
}
|
|
9
9
|
type Props = {
|
|
10
|
-
/**
|
|
10
|
+
/** Renders a compact launcher button in the layout toolbar. */
|
|
11
11
|
docked?: boolean;
|
|
12
|
-
/**
|
|
12
|
+
/** Enables an isolated localStorage key; persistence requires a stable user identity. */
|
|
13
13
|
persistKey?: string;
|
|
14
14
|
onPersist?: (messages: ChatMessage[]) => void;
|
|
15
15
|
onRestore?: () => ChatMessage[];
|
|
16
16
|
onPersistenceError?: (detail: ChatPersistenceErrorDetail) => void;
|
|
17
|
-
/**
|
|
17
|
+
/** Stable scope for targeted `svadmin:ask-ai` events. */
|
|
18
18
|
scope?: string;
|
|
19
|
-
/**
|
|
19
|
+
/** Owning Layout scope used to arbitrate global shortcuts. */
|
|
20
20
|
ownerScope?: string;
|
|
21
|
-
/** Agent
|
|
21
|
+
/** Controlled component registry available to Agent rendering; unregistered names are never loaded dynamically. */
|
|
22
22
|
componentRegistry?: ComponentRegistry;
|
|
23
23
|
class?: string;
|
|
24
24
|
};
|
|
@@ -127,8 +127,8 @@ Use bullet points and do not include introductory text.`;
|
|
|
127
127
|
<Sparkles class="size-4 text-primary" aria-hidden="true" />
|
|
128
128
|
Copilot
|
|
129
129
|
</h2>
|
|
130
|
-
<button type="button" class="svadmin-
|
|
131
|
-
<X
|
|
130
|
+
<button type="button" class="svadmin-ai__icon-button svadmin-ai__icon-button--close" aria-label="Close copilot" title="Close copilot" onclick={close}>
|
|
131
|
+
<X size={14} strokeWidth={1.75} aria-hidden="true" />
|
|
132
132
|
</button>
|
|
133
133
|
</header>
|
|
134
134
|
|
|
@@ -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;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
label?: string;
|
|
8
8
|
tooltip?: string;
|
|
9
9
|
icon?: LucideIcon;
|
|
10
|
-
size?: 'sm' | 'default' | 'icon' | 'icon-sm' | 'lg';
|
|
11
|
-
variant?: 'default' | 'outline' | 'ghost';
|
|
10
|
+
size?: 'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg';
|
|
11
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
12
12
|
title?: string;
|
|
13
13
|
class?: string;
|
|
14
14
|
children?: Snippet;
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
<script lang="ts">
|
|
19
19
|
import { cn } from '../../utils.js';
|
|
20
|
+
import Tooltip from '../../internal/Tooltip.svelte';
|
|
20
21
|
let {
|
|
21
22
|
label,
|
|
22
23
|
tooltip,
|
|
@@ -32,30 +33,34 @@
|
|
|
32
33
|
}: ArtifactActionProps = $props();
|
|
33
34
|
const accessibleLabel = $derived(label ?? tooltip);
|
|
34
35
|
const Icon = $derived(icon);
|
|
35
|
-
const
|
|
36
|
-
const describedBy = $derived([ariaDescribedBy, tooltip ? tooltipId : undefined].filter(Boolean).join(' ') || undefined);
|
|
36
|
+
const actionChildren = $derived(children);
|
|
37
37
|
</script>
|
|
38
38
|
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
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}
|
|
42
43
|
{#if accessibleLabel}<span class="svadmin-ai__sr-only">{accessibleLabel}</span>{/if}
|
|
43
44
|
</button>
|
|
44
|
-
{
|
|
45
|
-
</
|
|
45
|
+
{/snippet}
|
|
46
|
+
</Tooltip>
|
|
46
47
|
|
|
47
48
|
<style>
|
|
48
|
-
.svadmin-ai-artifact-part__action-anchor { position: relative; display: inline-flex; }
|
|
49
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; }
|
|
50
|
-
.svadmin-ai-artifact-part__action[data-size='
|
|
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; }
|
|
51
54
|
.svadmin-ai-artifact-part__action[data-size='lg'] { min-height: 2.5rem; padding-inline: .75rem; }
|
|
52
55
|
.svadmin-ai-artifact-part__action[data-variant='outline'] { border-color: var(--border, currentColor); }
|
|
53
56
|
.svadmin-ai-artifact-part__action[data-variant='default'] { border-color: var(--primary, currentColor); background: var(--primary, currentColor); color: var(--primary-foreground, Canvas); }
|
|
54
|
-
.svadmin-ai-artifact-part__action
|
|
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); }
|
|
55
64
|
.svadmin-ai-artifact-part__action:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }
|
|
56
65
|
.svadmin-ai-artifact-part__action:disabled { cursor: not-allowed; opacity: .5; }
|
|
57
|
-
.svadmin-ai-artifact-part__tooltip { position: absolute; z-index: 50; bottom: calc(100% + .5rem); left: 50%; width: max-content; max-width: 16rem; transform: translateX(-50%); visibility: hidden; border-radius: min(var(--radius, .5rem), .375rem); padding: .375rem .5rem; background: var(--popover, var(--foreground, currentColor)); color: var(--popover-foreground, var(--background, Canvas)); font-size: .75rem; line-height: 1.25; opacity: 0; pointer-events: none; transition: opacity 120ms ease, visibility 120ms ease; }
|
|
58
|
-
.svadmin-ai-artifact-part__action-anchor:hover .svadmin-ai-artifact-part__tooltip,
|
|
59
|
-
.svadmin-ai-artifact-part__action-anchor:focus-within .svadmin-ai-artifact-part__tooltip { visibility: visible; opacity: 1; }
|
|
60
|
-
@media (prefers-reduced-motion: reduce) { .svadmin-ai-artifact-part__tooltip { transition: none; } }
|
|
61
66
|
</style>
|
|
@@ -5,8 +5,8 @@ export interface ArtifactActionProps extends Omit<HTMLButtonAttributes, 'childre
|
|
|
5
5
|
label?: string;
|
|
6
6
|
tooltip?: string;
|
|
7
7
|
icon?: LucideIcon;
|
|
8
|
-
size?: 'sm' | 'default' | 'icon' | 'icon-sm' | 'lg';
|
|
9
|
-
variant?: 'default' | 'outline' | 'ghost';
|
|
8
|
+
size?: 'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg';
|
|
9
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
10
10
|
title?: string;
|
|
11
11
|
class?: string;
|
|
12
12
|
children?: Snippet;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { CodeBlockProps } from '../code-block/CodeBlock.svelte';
|
|
3
|
+
export type CodeRootProps = Omit<CodeBlockProps, 'language' | 'lang' | 'showLineNumbers'> & {
|
|
4
|
+
code: string;
|
|
5
|
+
lang?: string;
|
|
6
|
+
language?: string;
|
|
7
|
+
hideLines?: boolean;
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import CodeBlock from '../code-block/CodeBlock.svelte';
|
|
13
|
+
let { code, lang = 'typescript', language, hideLines = false, ...rest }: CodeRootProps = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<CodeBlock {...rest} {code} language={language ?? lang} showLineNumbers={!hideLines} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CodeBlockProps } from '../code-block/CodeBlock.svelte';
|
|
2
|
+
export type CodeRootProps = Omit<CodeBlockProps, 'language' | 'lang' | 'showLineNumbers'> & {
|
|
3
|
+
code: string;
|
|
4
|
+
lang?: string;
|
|
5
|
+
language?: string;
|
|
6
|
+
hideLines?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const Code: import("svelte").Component<CodeRootProps, {}, "">;
|
|
9
|
+
type Code = ReturnType<typeof Code>;
|
|
10
|
+
export default Code;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const codeVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
variant: {
|
|
4
|
+
default: "";
|
|
5
|
+
secondary: "border-transparent bg-secondary";
|
|
6
|
+
};
|
|
7
|
+
}, undefined, "relative h-full overflow-auto rounded-md border border-border bg-background text-foreground", {
|
|
8
|
+
variant: {
|
|
9
|
+
default: "";
|
|
10
|
+
secondary: "border-transparent bg-secondary";
|
|
11
|
+
};
|
|
12
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
13
|
+
variant: {
|
|
14
|
+
default: "";
|
|
15
|
+
secondary: "border-transparent bg-secondary";
|
|
16
|
+
};
|
|
17
|
+
}, undefined>>;
|
|
18
|
+
export type CodeVariant = VariantProps<typeof codeVariants>['variant'];
|
|
19
|
+
export { default, default as Root, default as Code } from './Code.svelte';
|
|
20
|
+
export { default as Overflow, default as CodeOverflow } from '../code-block/CodeBlockOverflow.svelte';
|
|
21
|
+
export { default as CopyButton, default as CodeCopyButton } from '../code-block/CodeBlockCopyButton.svelte';
|
|
22
|
+
export type { CodeBlockOverflowProps as CodeOverflowProps } from '../code-block/CodeBlockOverflow.svelte';
|
|
23
|
+
export type { CodeRootProps } from './Code.svelte';
|