@sveda-ai/vue 0.1.0 → 0.1.3
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 +2 -0
- package/dist/appearance.d.ts +13 -0
- package/dist/appearance.d.ts.map +1 -1
- package/dist/components/chat/ChatInput.vue.d.ts.map +1 -1
- package/dist/components/shell/SvedaFrameTicks.vue.d.ts +3 -0
- package/dist/components/shell/SvedaFrameTicks.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaResizeHandles.vue.d.ts +2 -2
- package/dist/components/shell/SvedaToolbar.vue.d.ts +2 -2
- package/dist/composables/useSvedaChatLayout.d.ts +5 -5
- package/dist/composables/useSvedaChatLayout.d.ts.map +1 -1
- package/dist/composables/useSvedaChatPage.d.ts +2 -2
- package/dist/composables/useSvedaChatPage.d.ts.map +1 -1
- package/dist/composables/useSvedaMessaging.d.ts.map +1 -1
- package/dist/composables/useSvedaModel.d.ts.map +1 -1
- package/dist/composables/useSvedaShell.d.ts +2 -2
- package/dist/composables/useSvedaShell.d.ts.map +1 -1
- package/dist/composables/useSvedaStreaming.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2755 -2547
- package/dist/lib/chatResize.d.ts +42 -0
- package/dist/lib/chatResize.d.ts.map +1 -0
- package/dist/lib/chatUiStorage.d.ts +2 -0
- package/dist/lib/chatUiStorage.d.ts.map +1 -1
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/styles.css +2 -4
- package/dist/vue.css +1 -1
- package/package.json +29 -18
- package/src/appearance.ts +147 -40
- package/src/components/chat/ChatHistoryDropdown.vue +6 -5
- package/src/components/chat/ChatInput.vue +8 -8
- package/src/components/chat/ChatMessageItem.vue +7 -7
- package/src/components/chat/ChatPendingIndicator.vue +1 -1
- package/src/components/shell/SvedaChat.vue +12 -9
- package/src/components/shell/SvedaFrameTicks.vue +18 -0
- package/src/components/shell/SvedaMinimizedTrigger.vue +2 -2
- package/src/components/shell/SvedaModelControls.vue +13 -3
- package/src/components/shell/SvedaModelSelect.vue +1 -1
- package/src/components/shell/SvedaResizeHandles.vue +8 -8
- package/src/components/shell/SvedaTabs.vue +3 -3
- package/src/components/shell/SvedaToolbar.vue +3 -3
- package/src/composables/useSvedaChatLayout.ts +203 -93
- package/src/composables/useSvedaChatPage.ts +4 -2
- package/src/composables/useSvedaMessaging.ts +12 -1
- package/src/composables/useSvedaModel.ts +3 -1
- package/src/composables/useSvedaShell.ts +12 -9
- package/src/composables/useSvedaStreaming.ts +9 -1
- package/src/index.ts +12 -0
- package/src/lib/chatResize.ts +123 -0
- package/src/lib/chatUiStorage.ts +46 -10
- package/src/plugin.ts +45 -1
- package/src/theme.css +56 -43
- package/src/theme.test.mjs +33 -1
- package/src/ui/button/index.ts +7 -7
- package/src/ui/card/Card.vue +1 -1
- package/src/ui/switch/Switch.vue +2 -2
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export const SVEDA_CHAT_LAYOUT_MIN_WIDTH = 320;
|
|
2
|
+
export const SVEDA_CHAT_LAYOUT_MIN_HEIGHT = 400;
|
|
3
|
+
export const SVEDA_CHAT_LAYOUT_MAX_WIDTH = 800;
|
|
4
|
+
export const SVEDA_CHAT_LAYOUT_MAX_HEIGHT = 900;
|
|
5
|
+
export const SVEDA_HISTORY_SIDEBAR_WIDTH = 320;
|
|
6
|
+
|
|
7
|
+
export interface EmbedHostSize {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
immersive: boolean;
|
|
11
|
+
fixed: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const resolveEmbedHostSize = ({
|
|
15
|
+
chatWidth,
|
|
16
|
+
chatHeight,
|
|
17
|
+
fixedWidth,
|
|
18
|
+
historyOpen,
|
|
19
|
+
viewMode,
|
|
20
|
+
viewportWidth,
|
|
21
|
+
viewportHeight,
|
|
22
|
+
}: {
|
|
23
|
+
chatWidth: number;
|
|
24
|
+
chatHeight: number;
|
|
25
|
+
fixedWidth: number;
|
|
26
|
+
historyOpen: boolean;
|
|
27
|
+
viewMode: 'floating' | 'fixed' | 'immersive';
|
|
28
|
+
viewportWidth: number;
|
|
29
|
+
viewportHeight: number;
|
|
30
|
+
}): EmbedHostSize => {
|
|
31
|
+
if (viewMode === 'immersive') {
|
|
32
|
+
return {
|
|
33
|
+
width: viewportWidth,
|
|
34
|
+
height: viewportHeight,
|
|
35
|
+
immersive: true,
|
|
36
|
+
fixed: false,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (viewMode === 'fixed') {
|
|
41
|
+
return {
|
|
42
|
+
width: fixedWidth + (historyOpen ? SVEDA_HISTORY_SIDEBAR_WIDTH : 0),
|
|
43
|
+
height: viewportHeight,
|
|
44
|
+
immersive: false,
|
|
45
|
+
fixed: true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
width: chatWidth + (historyOpen ? SVEDA_HISTORY_SIDEBAR_WIDTH : 0),
|
|
51
|
+
height: chatHeight,
|
|
52
|
+
immersive: false,
|
|
53
|
+
fixed: false,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const clamp = (value: number, min: number, max: number): number =>
|
|
58
|
+
Math.max(min, Math.min(max, value));
|
|
59
|
+
|
|
60
|
+
export interface ChatBoxSize {
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Pointer deltas for window resize must use screen coordinates.
|
|
67
|
+
*
|
|
68
|
+
* Inside an iframe, `clientX`/`clientY` are relative to the iframe viewport.
|
|
69
|
+
* Hosts pin the frame to the bottom-right, so growing the frame moves its origin
|
|
70
|
+
* and the next `clientX` snaps back — the window jitters. `screenX`/`screenY`
|
|
71
|
+
* stay stable across that origin shift (and still work for the in-page JS chat).
|
|
72
|
+
*/
|
|
73
|
+
export const pointerScreenDelta = (
|
|
74
|
+
event: Pick<MouseEvent, 'screenX' | 'screenY'>,
|
|
75
|
+
startX: number,
|
|
76
|
+
startY: number
|
|
77
|
+
): { deltaX: number; deltaY: number } => ({
|
|
78
|
+
deltaX: event.screenX - startX,
|
|
79
|
+
deltaY: event.screenY - startY,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const applyFloatingResize = (
|
|
83
|
+
direction: string,
|
|
84
|
+
startWidth: number,
|
|
85
|
+
startHeight: number,
|
|
86
|
+
deltaX: number,
|
|
87
|
+
deltaY: number
|
|
88
|
+
): ChatBoxSize => {
|
|
89
|
+
let width = startWidth;
|
|
90
|
+
let height = startHeight;
|
|
91
|
+
|
|
92
|
+
if (direction.includes('right')) {
|
|
93
|
+
width = clamp(startWidth + deltaX, SVEDA_CHAT_LAYOUT_MIN_WIDTH, SVEDA_CHAT_LAYOUT_MAX_WIDTH);
|
|
94
|
+
}
|
|
95
|
+
if (direction.includes('left')) {
|
|
96
|
+
width = clamp(startWidth - deltaX, SVEDA_CHAT_LAYOUT_MIN_WIDTH, SVEDA_CHAT_LAYOUT_MAX_WIDTH);
|
|
97
|
+
}
|
|
98
|
+
if (direction.includes('bottom')) {
|
|
99
|
+
height = clamp(startHeight + deltaY, SVEDA_CHAT_LAYOUT_MIN_HEIGHT, SVEDA_CHAT_LAYOUT_MAX_HEIGHT);
|
|
100
|
+
}
|
|
101
|
+
if (direction.includes('top')) {
|
|
102
|
+
height = clamp(startHeight - deltaY, SVEDA_CHAT_LAYOUT_MIN_HEIGHT, SVEDA_CHAT_LAYOUT_MAX_HEIGHT);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return { width, height };
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const applyFixedLeftResize = (
|
|
109
|
+
startWidth: number,
|
|
110
|
+
deltaX: number,
|
|
111
|
+
maxChat: number
|
|
112
|
+
): { width: number; enterImmersive: boolean } => {
|
|
113
|
+
const next = startWidth - deltaX;
|
|
114
|
+
if (next > maxChat && maxChat >= SVEDA_CHAT_LAYOUT_MIN_WIDTH) {
|
|
115
|
+
return { width: maxChat, enterImmersive: true };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const upper = Math.max(SVEDA_CHAT_LAYOUT_MIN_WIDTH, maxChat);
|
|
119
|
+
return {
|
|
120
|
+
width: clamp(next, SVEDA_CHAT_LAYOUT_MIN_WIDTH, upper),
|
|
121
|
+
enterImmersive: false,
|
|
122
|
+
};
|
|
123
|
+
};
|
package/src/lib/chatUiStorage.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export const SVEDA_CHAT_MINIMIZED_STORAGE_KEY = 'sveda.chat-minimized';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
3
|
+
const readFlag = (storage: Storage | undefined): boolean | null => {
|
|
4
|
+
if (!storage) {
|
|
5
|
+
return null;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
try {
|
|
9
|
-
const saved =
|
|
9
|
+
const saved = storage.getItem(SVEDA_CHAT_MINIMIZED_STORAGE_KEY);
|
|
10
10
|
if (saved === 'true') {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
@@ -14,20 +14,56 @@ export const readPersistedMinimized = (): boolean => {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
} catch {
|
|
17
|
-
return
|
|
17
|
+
return null;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
return
|
|
20
|
+
return null;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const storageOrNull = (read: () => Storage): Storage | undefined => {
|
|
24
24
|
if (typeof window === 'undefined') {
|
|
25
|
-
return;
|
|
25
|
+
return undefined;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
|
-
|
|
29
|
+
return read();
|
|
30
30
|
} catch {
|
|
31
|
-
return;
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const readPersistedMinimizedPreference = (): boolean | null => {
|
|
36
|
+
const session = readFlag(storageOrNull(() => sessionStorage));
|
|
37
|
+
if (session !== null) {
|
|
38
|
+
return session;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return readFlag(storageOrNull(() => localStorage));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const readPersistedMinimized = (): boolean => {
|
|
45
|
+
return readPersistedMinimizedPreference() ?? true;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const isPersistedSessionChatOpen = (): boolean => {
|
|
49
|
+
return readFlag(storageOrNull(() => sessionStorage)) === false;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const writePersistedMinimized = (isMinimized: boolean): void => {
|
|
53
|
+
const value = isMinimized ? 'true' : 'false';
|
|
54
|
+
|
|
55
|
+
for (const storage of [
|
|
56
|
+
storageOrNull(() => sessionStorage),
|
|
57
|
+
storageOrNull(() => localStorage),
|
|
58
|
+
]) {
|
|
59
|
+
if (!storage) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
storage.setItem(SVEDA_CHAT_MINIMIZED_STORAGE_KEY, value);
|
|
65
|
+
} catch {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
32
68
|
}
|
|
33
69
|
};
|
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { SvedaClient } from '@sveda-ai/core';
|
|
2
2
|
import { inject, type App, type InjectionKey } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
applySvedaAppearance,
|
|
5
|
+
mergeSvedaAppearance,
|
|
6
|
+
type SvedaAppearance,
|
|
7
|
+
} from './appearance';
|
|
4
8
|
import {
|
|
5
9
|
createSvedaI18n,
|
|
6
10
|
installSvedaI18n,
|
|
@@ -27,6 +31,8 @@ export interface SvedaBrand {
|
|
|
27
31
|
logoUrl?: string;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
export type SvedaBeforeSend = () => void | Promise<void>;
|
|
35
|
+
|
|
30
36
|
export interface SvedaPluginOptions {
|
|
31
37
|
endpoints: {
|
|
32
38
|
stream: string;
|
|
@@ -45,7 +51,9 @@ export interface SvedaPluginOptions {
|
|
|
45
51
|
appearance?: SvedaAppearance | null;
|
|
46
52
|
theme?: 'light' | 'dark';
|
|
47
53
|
hostEmbed?: boolean;
|
|
54
|
+
fillHost?: boolean;
|
|
48
55
|
hideLauncher?: boolean;
|
|
56
|
+
beforeSend?: SvedaBeforeSend;
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
export interface SvedaConfig {
|
|
@@ -74,12 +82,44 @@ export const SvedaFillHostKey: InjectionKey<boolean> = Symbol('sveda-fill-host')
|
|
|
74
82
|
|
|
75
83
|
export const SvedaHideLauncherKey: InjectionKey<boolean> = Symbol('sveda-hide-launcher');
|
|
76
84
|
|
|
85
|
+
export const SvedaBeforeSendKey: InjectionKey<SvedaBeforeSend | null> = Symbol('sveda-before-send');
|
|
86
|
+
|
|
77
87
|
const DEFAULT_CONFIG: SvedaConfig = {
|
|
78
88
|
brand: { name: 'Sveda', logoUrl: null },
|
|
79
89
|
models: [],
|
|
80
90
|
quickPrompts: [],
|
|
81
91
|
};
|
|
82
92
|
|
|
93
|
+
const scheduleEmbedAppearance = (stream: string): void => {
|
|
94
|
+
if (typeof fetch === 'undefined') {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let origin = '';
|
|
99
|
+
try {
|
|
100
|
+
const url = new URL(stream);
|
|
101
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
origin = url.origin;
|
|
105
|
+
} catch {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void fetch(`${origin}/sveda/embed/config`)
|
|
110
|
+
.then((response) => (response.ok ? response.json() : null))
|
|
111
|
+
.then((config) => {
|
|
112
|
+
if (!config || typeof config !== 'object') {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
applySvedaAppearance(
|
|
117
|
+
mergeSvedaAppearance((config as { appearance?: SvedaAppearance | null }).appearance, undefined),
|
|
118
|
+
);
|
|
119
|
+
})
|
|
120
|
+
.catch(() => {});
|
|
121
|
+
};
|
|
122
|
+
|
|
83
123
|
export function createSveda(options: SvedaPluginOptions): SvedaPlugin {
|
|
84
124
|
const client = new SvedaClient({
|
|
85
125
|
endpoints: options.endpoints,
|
|
@@ -126,6 +166,8 @@ export function createSveda(options: SvedaPluginOptions): SvedaPlugin {
|
|
|
126
166
|
...(options.theme ? { theme: options.theme } : {}),
|
|
127
167
|
});
|
|
128
168
|
}
|
|
169
|
+
} else {
|
|
170
|
+
scheduleEmbedAppearance(options.endpoints.stream);
|
|
129
171
|
}
|
|
130
172
|
|
|
131
173
|
return {
|
|
@@ -136,7 +178,9 @@ export function createSveda(options: SvedaPluginOptions): SvedaPlugin {
|
|
|
136
178
|
app.provide(SvedaClientKey, client);
|
|
137
179
|
app.provide(SvedaConfigKey, config);
|
|
138
180
|
app.provide(SvedaHostEmbedKey, Boolean(options.hostEmbed));
|
|
181
|
+
app.provide(SvedaFillHostKey, Boolean(options.fillHost ?? options.hostEmbed));
|
|
139
182
|
app.provide(SvedaHideLauncherKey, Boolean(options.hideLauncher));
|
|
183
|
+
app.provide(SvedaBeforeSendKey, options.beforeSend ?? null);
|
|
140
184
|
installSvedaI18n(app, i18n);
|
|
141
185
|
},
|
|
142
186
|
};
|
package/src/theme.css
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
:where(.sveda-chat, sveda-chat) {
|
|
2
|
-
--sveda-background:
|
|
3
|
-
--sveda-foreground: 0 0%
|
|
2
|
+
--sveda-background: 0 0% 100%;
|
|
3
|
+
--sveda-foreground: 0 0% 4%;
|
|
4
4
|
--sveda-card: 0 0% 100%;
|
|
5
|
-
--sveda-card-foreground: 0 0%
|
|
5
|
+
--sveda-card-foreground: 0 0% 4%;
|
|
6
6
|
--sveda-popover: 0 0% 100%;
|
|
7
|
-
--sveda-popover-foreground: 0 0%
|
|
8
|
-
--sveda-primary: 0 0%
|
|
9
|
-
--sveda-primary-foreground: 0 0%
|
|
10
|
-
--sveda-secondary:
|
|
11
|
-
--sveda-secondary-foreground: 0 0%
|
|
12
|
-
--sveda-muted:
|
|
13
|
-
--sveda-muted-foreground:
|
|
14
|
-
--sveda-accent:
|
|
15
|
-
--sveda-accent-foreground: 0 0%
|
|
7
|
+
--sveda-popover-foreground: 0 0% 4%;
|
|
8
|
+
--sveda-primary: 0 0% 4%;
|
|
9
|
+
--sveda-primary-foreground: 0 0% 100%;
|
|
10
|
+
--sveda-secondary: 40 20% 90%;
|
|
11
|
+
--sveda-secondary-foreground: 0 0% 4%;
|
|
12
|
+
--sveda-muted: 40 22% 90%;
|
|
13
|
+
--sveda-muted-foreground: 40 6% 41%;
|
|
14
|
+
--sveda-accent: 40 22% 90%;
|
|
15
|
+
--sveda-accent-foreground: 0 0% 4%;
|
|
16
16
|
--sveda-destructive: 0 84.2% 60.2%;
|
|
17
17
|
--sveda-destructive-foreground: 0 0% 98%;
|
|
18
|
-
--sveda-border:
|
|
19
|
-
--sveda-input:
|
|
20
|
-
--sveda-ring: 0 0%
|
|
18
|
+
--sveda-border: 42 18% 82%;
|
|
19
|
+
--sveda-input: 40 22% 92%;
|
|
20
|
+
--sveda-ring: 0 0% 4%;
|
|
21
21
|
--sveda-radius: 0;
|
|
22
|
-
--sveda-brand: 0 0%
|
|
23
|
-
--sveda-brand-foreground: 0 0%
|
|
24
|
-
--sveda-surface:
|
|
22
|
+
--sveda-brand: 0 0% 4%;
|
|
23
|
+
--sveda-brand-foreground: 0 0% 100%;
|
|
24
|
+
--sveda-surface: hsl(var(--sveda-background));
|
|
25
|
+
--font-sans: Geist, ui-sans-serif, system-ui, sans-serif;
|
|
26
|
+
--font-serif: Newsreader, ui-serif, Georgia, serif;
|
|
27
|
+
--font-mono: 'Geist Mono', ui-monospace, monospace;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
.sveda-chat,
|
|
@@ -56,37 +59,47 @@ sveda-chat {
|
|
|
56
59
|
--radius-2xl: var(--sveda-radius);
|
|
57
60
|
--radius-3xl: var(--sveda-radius);
|
|
58
61
|
--radius-4xl: var(--sveda-radius);
|
|
62
|
+
font-family: var(--font-sans, Geist, ui-sans-serif, system-ui, sans-serif);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
:where(.dark
|
|
62
|
-
--sveda-background:
|
|
63
|
-
--sveda-foreground:
|
|
64
|
-
--sveda-card:
|
|
65
|
-
--sveda-card-foreground:
|
|
66
|
-
--sveda-popover:
|
|
67
|
-
--sveda-popover-foreground:
|
|
68
|
-
--sveda-primary:
|
|
69
|
-
--sveda-primary-foreground:
|
|
70
|
-
--sveda-secondary:
|
|
71
|
-
--sveda-secondary-foreground:
|
|
72
|
-
--sveda-muted:
|
|
73
|
-
--sveda-muted-foreground:
|
|
74
|
-
--sveda-accent:
|
|
75
|
-
--sveda-accent-foreground:
|
|
65
|
+
:where(.sveda-chat.dark, sveda-chat.dark, .dark .sveda-chat, .dark sveda-chat) {
|
|
66
|
+
--sveda-background: 30 12% 9%;
|
|
67
|
+
--sveda-foreground: 40 24% 94%;
|
|
68
|
+
--sveda-card: 30 10% 12%;
|
|
69
|
+
--sveda-card-foreground: 40 24% 94%;
|
|
70
|
+
--sveda-popover: 30 10% 12%;
|
|
71
|
+
--sveda-popover-foreground: 40 24% 94%;
|
|
72
|
+
--sveda-primary: 40 24% 94%;
|
|
73
|
+
--sveda-primary-foreground: 30 12% 9%;
|
|
74
|
+
--sveda-secondary: 30 8% 16%;
|
|
75
|
+
--sveda-secondary-foreground: 40 24% 94%;
|
|
76
|
+
--sveda-muted: 30 8% 16%;
|
|
77
|
+
--sveda-muted-foreground: 36 10% 62%;
|
|
78
|
+
--sveda-accent: 30 8% 16%;
|
|
79
|
+
--sveda-accent-foreground: 40 24% 94%;
|
|
76
80
|
--sveda-destructive: 0 62.8% 30.6%;
|
|
77
|
-
--sveda-destructive-foreground:
|
|
78
|
-
--sveda-border:
|
|
79
|
-
--sveda-input:
|
|
80
|
-
--sveda-ring:
|
|
81
|
-
--sveda-brand:
|
|
82
|
-
--sveda-brand-foreground:
|
|
81
|
+
--sveda-destructive-foreground: 40 24% 94%;
|
|
82
|
+
--sveda-border: 30 8% 22%;
|
|
83
|
+
--sveda-input: 30 8% 16%;
|
|
84
|
+
--sveda-ring: 40 24% 94%;
|
|
85
|
+
--sveda-brand: 40 24% 94%;
|
|
86
|
+
--sveda-brand-foreground: 30 12% 9%;
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
.sveda-chat-surface {
|
|
86
|
-
background-color: var(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
background-color: var(--sveda-surface, hsl(var(--sveda-background)));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.sveda-chat-frame,
|
|
94
|
+
.sveda-chat .sveda-chat-frame,
|
|
95
|
+
sveda-chat .sveda-chat-frame {
|
|
96
|
+
border: 1px dashed hsl(var(--sveda-foreground));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sveda-chat ::selection,
|
|
100
|
+
sveda-chat ::selection {
|
|
101
|
+
background: hsl(var(--sveda-foreground));
|
|
102
|
+
color: hsl(var(--sveda-background));
|
|
90
103
|
}
|
|
91
104
|
|
|
92
105
|
body.sveda-chat-immersive-mode {
|
package/src/theme.test.mjs
CHANGED
|
@@ -15,10 +15,23 @@ const switchUi = readFileSync(join(dir, 'ui/switch/Switch.vue'), 'utf8');
|
|
|
15
15
|
|
|
16
16
|
test('theme.css exposes zero-specificity public sveda tokens without cycling host variables', () => {
|
|
17
17
|
assert.match(theme, /:where\(\.sveda-chat, sveda-chat\)/);
|
|
18
|
-
assert.match(
|
|
18
|
+
assert.match(chat, /SvedaFrameTicks/);
|
|
19
|
+
assert.match(theme, /--sveda-background:\s*0 0% 100%/);
|
|
20
|
+
assert.match(theme, /--sveda-border:\s*42 18% 82%/);
|
|
21
|
+
assert.match(theme, /\.sveda-chat-frame/);
|
|
22
|
+
assert.match(theme, /border:\s*1px dashed hsl\(var\(--sveda-foreground\)\)/);
|
|
23
|
+
assert.match(theme, /--font-serif:\s*Newsreader/);
|
|
24
|
+
assert.match(appearance, /background: '0 0% 100%'/);
|
|
25
|
+
assert.match(appearance, /export const mergeSvedaAppearance/);
|
|
26
|
+
assert.match(appearance, /export const isSvedaAppearanceProvided/);
|
|
27
|
+
assert.match(chat, /sveda-chat-frame/);
|
|
28
|
+
assert.match(trigger, /tracking-\[0\.14em\]/);
|
|
29
|
+
assert.match(trigger, /font-mono/);
|
|
19
30
|
assert.match(theme, /--sveda-foreground:/);
|
|
20
31
|
assert.match(theme, /--sveda-brand:/);
|
|
21
32
|
assert.match(theme, /--sveda-radius:\s*0/);
|
|
33
|
+
assert.match(theme, /:where\(\.sveda-chat\.dark, sveda-chat\.dark/);
|
|
34
|
+
assert.match(theme, /--sveda-background:\s*30 12% 9%/);
|
|
22
35
|
assert.match(theme, /\.sveda-chat-surface/);
|
|
23
36
|
assert.match(theme, /body\.sveda-chat-immersive-mode/);
|
|
24
37
|
assert.doesNotMatch(theme, /--background:\s*var\(--sveda-background\)/);
|
|
@@ -54,6 +67,9 @@ test('appearance helper injects radius and token declarations onto .sveda-chat',
|
|
|
54
67
|
assert.match(appearance, /useSvedaLauncher/);
|
|
55
68
|
assert.match(appearance, /sanitizeSvedaLauncher/);
|
|
56
69
|
assert.match(appearance, /sanitizeSvedaLauncherImage/);
|
|
70
|
+
assert.match(appearance, /sanitizeSvedaChrome/);
|
|
71
|
+
assert.match(appearance, /useSvedaChrome/);
|
|
72
|
+
assert.match(appearance, /svedaChrome/);
|
|
57
73
|
assert.match(appearance, /SVEDA_LAUNCHER_IMAGE_MAX_BYTES/);
|
|
58
74
|
});
|
|
59
75
|
|
|
@@ -61,7 +77,10 @@ test('thinking switch stays a pill with a raised thumb', () => {
|
|
|
61
77
|
assert.match(switchUi, /rounded-full/);
|
|
62
78
|
assert.match(switchUi, /shadow-inner/);
|
|
63
79
|
assert.match(switchUi, /size === 'sm'/);
|
|
80
|
+
assert.match(switchUi, /data-\[state=checked\]:bg-foreground/);
|
|
81
|
+
assert.match(switchUi, /bg-background/);
|
|
64
82
|
assert.doesNotMatch(switchUi, /rounded-\[var\(--sveda-radius\)\]/);
|
|
83
|
+
assert.doesNotMatch(switchUi, /bg-brand-primary-purple-foreground/);
|
|
65
84
|
});
|
|
66
85
|
|
|
67
86
|
test('minimized trigger uses launcher label, icon, and image', () => {
|
|
@@ -78,3 +97,16 @@ test('toast viewport stays inside the chat window', () => {
|
|
|
78
97
|
assert.match(viewport, /max-h-48/);
|
|
79
98
|
assert.doesNotMatch(viewport, /max-h-screen/);
|
|
80
99
|
});
|
|
100
|
+
|
|
101
|
+
test('composer uses the dashed paper frame and chrome can hide model and thinking', () => {
|
|
102
|
+
const input = readFileSync(join(dir, 'components/chat/ChatInput.vue'), 'utf8');
|
|
103
|
+
const controls = readFileSync(join(dir, 'components/shell/SvedaModelControls.vue'), 'utf8');
|
|
104
|
+
const model = readFileSync(join(dir, 'composables/useSvedaModel.ts'), 'utf8');
|
|
105
|
+
assert.match(input, /sveda-chat-frame/);
|
|
106
|
+
assert.match(input, /placeholder:font-mono/);
|
|
107
|
+
assert.match(input, /border-t border-dashed border-foreground/);
|
|
108
|
+
assert.match(controls, /useSvedaChrome/);
|
|
109
|
+
assert.match(controls, /showModelSelect/);
|
|
110
|
+
assert.match(controls, /showThinking/);
|
|
111
|
+
assert.match(model, /chrome\.thinking && selectedModelSupportsThinking/);
|
|
112
|
+
});
|
package/src/ui/button/index.ts
CHANGED
|
@@ -36,15 +36,15 @@ export const buttonHoverStyles: Record<
|
|
|
36
36
|
NonNullable<VariantProps<typeof buttonVariants>['variant']>,
|
|
37
37
|
string
|
|
38
38
|
> = {
|
|
39
|
-
default: '
|
|
40
|
-
destructive: 'bg-destructive/90
|
|
41
|
-
outline: 'bg-foreground/5 dark:bg-foreground/5 border-brand-primary-purple text-brand-primary-purple
|
|
42
|
-
secondary: 'bg-foreground/5 dark:bg-foreground/5 border-brand-primary-purple text-brand-primary-purple
|
|
43
|
-
ghost: 'bg-
|
|
39
|
+
default: 'opacity-90',
|
|
40
|
+
destructive: 'bg-destructive/90',
|
|
41
|
+
outline: 'bg-foreground/5 dark:bg-foreground/5 border-brand-primary-purple text-brand-primary-purple',
|
|
42
|
+
secondary: 'bg-foreground/5 dark:bg-foreground/5 border-brand-primary-purple text-brand-primary-purple',
|
|
43
|
+
ghost: 'bg-muted text-foreground',
|
|
44
44
|
ghostTransparent: 'bg-transparent text-foreground',
|
|
45
45
|
link: 'underline',
|
|
46
|
-
violet: '
|
|
47
|
-
main: '
|
|
46
|
+
violet: 'opacity-90',
|
|
47
|
+
main: 'opacity-90',
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export type ButtonVariants = VariantProps<typeof buttonVariants>
|
package/src/ui/card/Card.vue
CHANGED
|
@@ -8,7 +8,7 @@ const props = defineProps<{
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<template>
|
|
11
|
-
<div :class="cn('rounded-[var(--sveda-radius)] border
|
|
11
|
+
<div :class="cn('rounded-[var(--sveda-radius)] border bg-card text-card-foreground', props.class)">
|
|
12
12
|
<slot />
|
|
13
13
|
</div>
|
|
14
14
|
</template>
|
package/src/ui/switch/Switch.vue
CHANGED
|
@@ -38,14 +38,14 @@ const sizeClasses = computed(() =>
|
|
|
38
38
|
<SwitchRoot
|
|
39
39
|
v-bind="forwarded"
|
|
40
40
|
:class="cn(
|
|
41
|
-
'peer inline-flex shrink-0 cursor-pointer items-center rounded-full p-0.5 shadow-inner transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-
|
|
41
|
+
'peer inline-flex shrink-0 cursor-pointer items-center rounded-full p-0.5 shadow-inner transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-foreground data-[state=unchecked]:bg-muted-foreground',
|
|
42
42
|
sizeClasses.root,
|
|
43
43
|
props.class,
|
|
44
44
|
)"
|
|
45
45
|
>
|
|
46
46
|
<SwitchThumb
|
|
47
47
|
:class="cn(
|
|
48
|
-
'pointer-events-none block rounded-full
|
|
48
|
+
'pointer-events-none block rounded-full border border-foreground/25 bg-background shadow-[0_1px_2px_rgba(0,0,0,0.28)] ring-0 transition-transform data-[state=unchecked]:translate-x-0',
|
|
49
49
|
sizeClasses.thumb,
|
|
50
50
|
)"
|
|
51
51
|
>
|