@svadmin/ai-elements 0.14.5 → 0.15.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/dist/components/ChatDialog.svelte +3 -3
- package/dist/components/confirmation/Confirmation.svelte +1 -1
- package/dist/components/context/ContextContentFooter.svelte +1 -1
- package/dist/components/mic-selector/MicSelectorInput.svelte +1 -1
- package/dist/components/mic-selector/MicSelectorList.svelte +1 -1
- package/dist/components/mic-selector/MicSelectorValue.svelte +1 -1
- package/dist/components/question/QuestionSubmit.svelte +1 -1
- package/dist/components/reasoning/ReasoningTrigger.svelte +1 -1
- package/dist/components/task/Task.svelte +1 -1
- package/dist/components/web-preview/WebPreview.svelte +1 -1
- package/dist/components/web-preview/WebPreviewBody.svelte +1 -1
- package/dist/components/web-preview/WebPreviewUrl.svelte +1 -1
- package/package.json +2 -2
|
@@ -1265,7 +1265,7 @@
|
|
|
1265
1265
|
<Message from={message.role} id={message.id}>
|
|
1266
1266
|
<MessageContent class={message.role === 'user' ? 'bg-primary text-primary-foreground' : ''}>
|
|
1267
1267
|
{#if message.parts.length === 0 && message.status === 'streaming'}
|
|
1268
|
-
<p class="svadmin-ai__muted text-sm">Thinking
|
|
1268
|
+
<p class="svadmin-ai__muted text-sm">Thinking…</p>
|
|
1269
1269
|
{/if}
|
|
1270
1270
|
{#each message.parts as part, partIndex (part.id ?? `${message.id}-part-${partIndex}`)}
|
|
1271
1271
|
{#if part.type === 'text'}
|
|
@@ -1340,7 +1340,7 @@
|
|
|
1340
1340
|
disabled={approvalPending}
|
|
1341
1341
|
onclick={() => void respondToApproval(part.approvalId, part.id, 'approved')}
|
|
1342
1342
|
>
|
|
1343
|
-
{approvalPending ? 'Submitting
|
|
1343
|
+
{approvalPending ? 'Submitting…' : 'Approve'}
|
|
1344
1344
|
</button>
|
|
1345
1345
|
<button
|
|
1346
1346
|
type="button"
|
|
@@ -1402,7 +1402,7 @@
|
|
|
1402
1402
|
bind:attachments={inputAttachments}
|
|
1403
1403
|
disabled={isStreaming}
|
|
1404
1404
|
loading={isStreaming}
|
|
1405
|
-
placeholder="Type a message
|
|
1405
|
+
placeholder="Type a message…"
|
|
1406
1406
|
ariaLabel="Message AI assistant"
|
|
1407
1407
|
onsubmit={(detail) => { void sendMessage(detail.value, detail.attachments); }}
|
|
1408
1408
|
onstop={stopStreaming}
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
{#if status === 'pending'}
|
|
107
107
|
<div class="svadmin-ai-confirmation__actions">
|
|
108
108
|
{#if oncancel}<button class="svadmin-ai-confirmation__button svadmin-ai-confirmation__button--ghost" type="button" disabled={!actionable} onclick={() => run(oncancel)}><X size={15} aria-hidden="true" />{cancelLabel}</button>{/if}
|
|
109
|
-
{#if onconfirm}<button class="svadmin-ai-confirmation__button" type="button" disabled={!actionable} aria-busy={busy} onclick={() => run(onconfirm)}><Check size={15} aria-hidden="true" />{busy ? 'Working
|
|
109
|
+
{#if onconfirm}<button class="svadmin-ai-confirmation__button" type="button" disabled={!actionable} aria-busy={busy} onclick={() => run(onconfirm)}><Check size={15} aria-hidden="true" />{busy ? 'Working…' : confirmLabel}</button>{/if}
|
|
110
110
|
</div>
|
|
111
111
|
{/if}
|
|
112
112
|
{/if}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<script lang="ts">import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements'; import { cn } from '../../utils.js'; import { useContextContext } from './context-state.svelte.js'; interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { class?: string; children?: Snippet; } let { class: className = '', children, ...rest }: Props = $props(); const context = useContextContext('ContextContentFooter'); const formattedCost = $derived(/^[A-Z]{3}$/.test(context.currency) ?
|
|
1
|
+
<script lang="ts">import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements'; import { formatAdminCurrency } from '@svadmin/core'; import { cn } from '../../utils.js'; import { useContextContext } from './context-state.svelte.js'; interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> { class?: string; children?: Snippet; } let { class: className = '', children, ...rest }: Props = $props(); const context = useContextContext('ContextContentFooter'); const formattedCost = $derived(/^[A-Z]{3}$/.test(context.currency) ? formatAdminCurrency(context.cost ?? 0, { locale: null, currency: context.currency }) : `${context.currency}${(context.cost ?? 0).toFixed(4)}`);</script>
|
|
2
2
|
<div {...rest} class={cn('svadmin-ai-context-part__footer', className)} data-slot="context-content-footer">{#if children}{@render children()}{:else}<span>Total cost</span><strong>{formattedCost}</strong>{/if}</div>
|
|
3
3
|
<style>.svadmin-ai-context-part__footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; border-top: 1px solid var(--border, currentColor); padding: .75rem; background: var(--muted, transparent); font-size: .75rem; }.svadmin-ai-context-part__footer span { color: var(--muted-foreground, currentColor); }</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Search } from '@lucide/svelte';
|
|
3
3
|
import { cn } from '../../utils.js';
|
|
4
4
|
type Props = { value?: string; class?: string; placeholder?: string };
|
|
5
|
-
let { value = $bindable(''), class: className = '', placeholder = 'Search microphones
|
|
5
|
+
let { value = $bindable(''), class: className = '', placeholder = 'Search microphones…' }: Props = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<label class={cn('flex items-center gap-2', className)}><Search size={14} aria-hidden="true" /><span class="svadmin-ai__sr-only">Search microphones</span><input class="svadmin-ai__input" type="search" bind:value {placeholder} /></label>
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
const selector = useMicSelectorContext();
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
|
-
{#if selector.loading}<p class={cn('svadmin-ai__muted text-xs', className)}>Loading microphones
|
|
10
|
+
{#if selector.loading}<p class={cn('svadmin-ai__muted text-xs', className)}>Loading microphones…</p>{:else if selector.error}<p class={cn('text-destructive text-xs', className)} role="alert">{selector.error}</p>{:else}{@render children?.(selector.devices)}{/if}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { cn } from '../../utils.js';
|
|
4
4
|
import { useMicSelectorContext } from './context.svelte.js';
|
|
5
5
|
type Props = { class?: string; children?: Snippet; placeholder?: string };
|
|
6
|
-
let { class: className = '', children, placeholder = 'Select microphone
|
|
6
|
+
let { class: className = '', children, placeholder = 'Select microphone…' }: Props = $props();
|
|
7
7
|
const selector = useMicSelectorContext();
|
|
8
8
|
const selected = $derived(selector.devices.find((device) => device.deviceId === selector.value));
|
|
9
9
|
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte'; import { cn } from '../../utils.js'; import { useQuestionContext } from './context.svelte.js'; let { class: className = '', children, disabled = false, ...rest }: { class?: string; children?: Snippet<[boolean]>; disabled?: boolean; [key: string]: unknown } = $props(); const context = useQuestionContext(); const hasResponse = $derived(context.value.selectedValues.length > 0 || context.value.text.trim().length > 0); const unavailable = $derived(context.disabled || disabled || context.busy || !hasResponse);
|
|
3
3
|
</script>
|
|
4
|
-
<button type="submit" class={cn('inline-flex min-h-9 items-center justify-center rounded-md border border-transparent bg-primary px-3 py-2 text-sm text-primary-foreground hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50', className)} disabled={unavailable} {...rest}>{#if children}{@render children(context.busy)}{:else}{context.busy ? 'Submitting
|
|
4
|
+
<button type="submit" class={cn('inline-flex min-h-9 items-center justify-center rounded-md border border-transparent bg-primary px-3 py-2 text-sm text-primary-foreground hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50', className)} disabled={unavailable} {...rest}>{#if children}{@render children(context.busy)}{:else}{context.busy ? 'Submitting…' : 'Submit'}{/if}</button>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
const message = $derived(getThinkingMessage?.(reasoning.isStreaming, reasoning.duration)
|
|
22
22
|
?? (reasoning.isStreaming || reasoning.duration === 0
|
|
23
|
-
? 'Thinking
|
|
23
|
+
? 'Thinking…'
|
|
24
24
|
: reasoning.duration === undefined
|
|
25
25
|
? 'Thought for a few seconds'
|
|
26
26
|
: `Thought for ${reasoning.duration} seconds`));
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
{#if status === 'running' && oncancel || status === 'failed' && onretry || status === 'cancelled' && onresume}
|
|
126
126
|
<footer class="svadmin-ai-task__actions">
|
|
127
127
|
{#if status === 'running' && oncancel}<button type="button" class="svadmin-ai-task__button svadmin-ai-task__button--ghost" disabled={disabled || busy} onclick={() => invoke(oncancel)}><Square size={14} aria-hidden="true" /> Cancel</button>{/if}
|
|
128
|
-
{#if status === 'failed' && onretry}<button type="button" class="svadmin-ai-task__button" disabled={disabled || busy} onclick={() => invoke(onretry)}><RotateCcw size={14} aria-hidden="true" /> {busy ? 'Retrying
|
|
128
|
+
{#if status === 'failed' && onretry}<button type="button" class="svadmin-ai-task__button" disabled={disabled || busy} onclick={() => invoke(onretry)}><RotateCcw size={14} aria-hidden="true" /> {busy ? 'Retrying…' : 'Retry'}</button>{/if}
|
|
129
129
|
{#if status === 'cancelled' && onresume}<button type="button" class="svadmin-ai-task__button" disabled={disabled || busy} onclick={() => invoke(onresume)}><Play size={14} aria-hidden="true" /> Resume</button>{/if}
|
|
130
130
|
</footer>
|
|
131
131
|
{/if}
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
|
|
139
139
|
{#if open}
|
|
140
140
|
<div id={`${previewId}-frame`} class="svadmin-ai-web-preview__stage" data-device={device}>
|
|
141
|
-
{#if loading}<div class="svadmin-ai-web-preview__loading" role="status">Loading preview
|
|
141
|
+
{#if loading}<div class="svadmin-ai-web-preview__loading" role="status">Loading preview…</div>{/if}
|
|
142
142
|
{#if safeUrl || srcdoc}
|
|
143
143
|
{#key revision}
|
|
144
144
|
<iframe title={title} src={safeUrl || undefined} {srcdoc} {sandbox} onload={handleLoad}></iframe>
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
let { src, srcdoc, sandbox, title, loading, class: className = '', onload, ...rest }: Props = $props(); const preview = useWebPreviewContext('WebPreviewBody'); const resolvedSrc = $derived(src === undefined ? preview.safeUrl : sanitizePreviewUrl(src)); const resolvedSrcdoc = $derived(srcdoc ?? preview.srcdoc); const resolvedSandbox = $derived(sandbox ?? preview.sandbox);
|
|
5
5
|
function loaded(event: Event): void { preview.frameLoaded(); onload?.(event); }
|
|
6
6
|
</script>
|
|
7
|
-
<div class="svadmin-ai-web-part__body" data-slot="web-preview-body">{#if preview.loading}{#if loading}{@render loading()}{:else}<span class="svadmin-ai-web-part__loading" role="status">Loading preview
|
|
7
|
+
<div class="svadmin-ai-web-part__body" data-slot="web-preview-body">{#if preview.loading}{#if loading}{@render loading()}{:else}<span class="svadmin-ai-web-part__loading" role="status">Loading preview…</span>{/if}{/if}{#if resolvedSrc || resolvedSrcdoc}{#key preview.revision}<iframe {...rest} class={cn('svadmin-ai-web-part__frame', className)} src={resolvedSrc || undefined} srcdoc={resolvedSrcdoc} sandbox={resolvedSandbox} title={title ?? preview.title} onload={loaded}></iframe>{/key}{:else}<p>No preview URL.</p>{/if}</div>
|
|
8
8
|
<style>.svadmin-ai-web-part__body { position: relative; display: flex; min-height: 20rem; flex: 1; overflow: auto; background: var(--muted, transparent); }.svadmin-ai-web-part__frame { display: block; width: 100%; min-height: 28rem; border: 0; background: var(--background, transparent); }.svadmin-ai-web-part__loading { position: absolute; z-index: 1; top: .75rem; left: 50%; transform: translateX(-50%); padding: .25rem .5rem; border: 1px solid var(--border, currentColor); border-radius: 999px; background: var(--popover, var(--background, transparent)); color: var(--muted-foreground, currentColor); font-size: .68rem; }.svadmin-ai-web-part__body p { margin: auto; color: var(--muted-foreground, currentColor); font-size: .78rem; }</style>
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
function handleInput(event: Event & { currentTarget: EventTarget & HTMLInputElement }): void { draft = event.currentTarget.value; value = draft; oninput?.(event); }
|
|
7
7
|
function handleKeydown(event: KeyboardEvent & { currentTarget: EventTarget & HTMLInputElement }): void { if (event.key === 'Enter' && preview.navigate(draft)) { value = draft.trim(); onnavigate?.(value); } onkeydown?.(event); }
|
|
8
8
|
</script>
|
|
9
|
-
<input {...rest} class={cn('svadmin-ai-web-part__url', className)} value={draft} inputmode="url" placeholder="Enter URL
|
|
9
|
+
<input {...rest} class={cn('svadmin-ai-web-part__url', className)} value={draft} inputmode="url" placeholder="Enter URL…" aria-invalid={invalid} data-slot="web-preview-url" oninput={handleInput} onkeydown={handleKeydown} />
|
|
10
10
|
<style>.svadmin-ai-web-part__url { min-width: 0; min-height: 2rem; flex: 1; padding: .35rem .55rem; border: 1px solid var(--input, var(--border, currentColor)); border-radius: min(var(--radius, .5rem), .5rem); background: var(--background, transparent); color: var(--foreground, currentColor); font: inherit; font-size: .75rem; }.svadmin-ai-web-part__url:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }.svadmin-ai-web-part__url[aria-invalid='true'] { border-color: var(--destructive, currentColor); }</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/ai-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Composable Svelte 5 AI interaction components for SVAdmin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@svadmin/core": "^0.
|
|
59
|
+
"@svadmin/core": "^0.82.0",
|
|
60
60
|
"@tanstack/svelte-query": "^6.1.48",
|
|
61
61
|
"svelte": "^5.56.10"
|
|
62
62
|
},
|