@elia-assistant/chatui 1.0.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/LICENSE +21 -0
- package/README.md +348 -0
- package/dist/App.d.ts +3 -0
- package/dist/assets/avatars/index.d.ts +4 -0
- package/dist/chat-store.js +96 -0
- package/dist/chatui.css +3 -0
- package/dist/chatui.css.d.ts +1 -0
- package/dist/chatui.iife.css +3 -0
- package/dist/chatui.iife.js +66 -0
- package/dist/chunks/i18n-BySVyBiz.js +2 -0
- package/dist/chunks/i18n-oL80Kbbg.js +1304 -0
- package/dist/chunks/middleware-DgE1WAsA.js +137 -0
- package/dist/chunks/settingsStore-BqlYxczg.js +254 -0
- package/dist/chunks/translation-B1sKHGC8.js +81 -0
- package/dist/chunks/translation-DYf8xjwU.js +81 -0
- package/dist/components/ChatView.d.ts +5 -0
- package/dist/components/CtaPopup.d.ts +6 -0
- package/dist/components/FaqTab.d.ts +7 -0
- package/dist/components/InputArea.d.ts +8 -0
- package/dist/components/MessageBubble.d.ts +7 -0
- package/dist/components/NotificationsTab.d.ts +7 -0
- package/dist/components/SettingsModal.d.ts +5 -0
- package/dist/components/Sidebar.d.ts +5 -0
- package/dist/components/Tabs.d.ts +12 -0
- package/dist/components/ThemePicker.d.ts +1 -0
- package/dist/createChat.d.ts +23 -0
- package/dist/hooks/useChat.d.ts +4 -0
- package/dist/hooks/useCta.d.ts +6 -0
- package/dist/hooks/useFeedJson.d.ts +11 -0
- package/dist/hooks/useTheme.d.ts +4 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10012 -0
- package/dist/lib/n8nClient.d.ts +18 -0
- package/dist/lib/storage.d.ts +3 -0
- package/dist/shims/use-sync-external-store-shim.d.ts +1 -0
- package/dist/store/chatStore.d.ts +37 -0
- package/dist/store/settingsStore.d.ts +23 -0
- package/dist/store.js +2 -0
- package/dist/themes.d.ts +4 -0
- package/dist/types/index.d.ts +138 -0
- package/dist/types.js +0 -0
- package/package.json +79 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChatConfig } from '../types/index.ts';
|
|
2
|
+
export declare class N8nApiError extends Error {
|
|
3
|
+
readonly status?: number;
|
|
4
|
+
constructor(message: string, status?: number);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Send a message to the n8n webhook.
|
|
8
|
+
*
|
|
9
|
+
* Non-streaming: expects { output: string } response.
|
|
10
|
+
* Streaming: SSE; each event contains data: { text: "chunk" } or data: { output: "full" }.
|
|
11
|
+
*
|
|
12
|
+
* @param config Chat configuration
|
|
13
|
+
* @param sessionId Current session ID (maps to chatSessionKey)
|
|
14
|
+
* @param text User message text
|
|
15
|
+
* @param onChunk Called with each streaming chunk (enables streaming mode)
|
|
16
|
+
* @returns Full bot response text
|
|
17
|
+
*/
|
|
18
|
+
export declare function sendMessage(config: ChatConfig, sessionId: string, text: string, language?: string, onChunk?: (chunk: string) => void): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSyncExternalStore } from 'react';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Message, Session } from '../types/index.ts';
|
|
2
|
+
interface ChatState {
|
|
3
|
+
sessions: Session[];
|
|
4
|
+
activeSessionId: string | null;
|
|
5
|
+
messages: Record<string, Message[]>;
|
|
6
|
+
isStreaming: boolean;
|
|
7
|
+
createSession(): string;
|
|
8
|
+
setActiveSession(id: string): void;
|
|
9
|
+
addMessage(sessionId: string, msg: Message): void;
|
|
10
|
+
appendToLastBot(sessionId: string, chunk: string): void;
|
|
11
|
+
setStreaming(val: boolean): void;
|
|
12
|
+
deleteSession(id: string): void;
|
|
13
|
+
renameSession(id: string, title: string): void;
|
|
14
|
+
clearMessages(sessionId: string): void;
|
|
15
|
+
}
|
|
16
|
+
export declare const useChatStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<ChatState>, "setState" | "persist"> & {
|
|
17
|
+
setState(partial: ChatState | Partial<ChatState> | ((state: ChatState) => ChatState | Partial<ChatState>), replace?: false | undefined): unknown;
|
|
18
|
+
setState(state: ChatState | ((state: ChatState) => ChatState), replace: true): unknown;
|
|
19
|
+
persist: {
|
|
20
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ChatState, {
|
|
21
|
+
sessions: Session[];
|
|
22
|
+
activeSessionId: string | null;
|
|
23
|
+
messages: Record<string, Message[]>;
|
|
24
|
+
}, unknown>>) => void;
|
|
25
|
+
clearStorage: () => void;
|
|
26
|
+
rehydrate: () => Promise<void> | void;
|
|
27
|
+
hasHydrated: () => boolean;
|
|
28
|
+
onHydrate: (fn: (state: ChatState) => void) => () => void;
|
|
29
|
+
onFinishHydration: (fn: (state: ChatState) => void) => () => void;
|
|
30
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<ChatState, {
|
|
31
|
+
sessions: Session[];
|
|
32
|
+
activeSessionId: string | null;
|
|
33
|
+
messages: Record<string, Message[]>;
|
|
34
|
+
}, unknown>>;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChatConfig } from '../types/index.ts';
|
|
2
|
+
interface SettingsState {
|
|
3
|
+
config: ChatConfig;
|
|
4
|
+
activeTheme: string;
|
|
5
|
+
language: string;
|
|
6
|
+
setConfig(patch: Partial<ChatConfig>): void;
|
|
7
|
+
setTheme(id: string): void;
|
|
8
|
+
setLanguage(lang: string): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SettingsState>, "setState" | "persist"> & {
|
|
11
|
+
setState(partial: SettingsState | Partial<SettingsState> | ((state: SettingsState) => SettingsState | Partial<SettingsState>), replace?: false | undefined): unknown;
|
|
12
|
+
setState(state: SettingsState | ((state: SettingsState) => SettingsState), replace: true): unknown;
|
|
13
|
+
persist: {
|
|
14
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SettingsState, SettingsState, unknown>>) => void;
|
|
15
|
+
clearStorage: () => void;
|
|
16
|
+
rehydrate: () => Promise<void> | void;
|
|
17
|
+
hasHydrated: () => boolean;
|
|
18
|
+
onHydrate: (fn: (state: SettingsState) => void) => () => void;
|
|
19
|
+
onFinishHydration: (fn: (state: SettingsState) => void) => () => void;
|
|
20
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<SettingsState, SettingsState, unknown>>;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export {};
|
package/dist/store.js
ADDED
package/dist/themes.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/** Per-language content overrides — keyed by language code e.g. "en", "sk" */
|
|
2
|
+
export interface LangOverride {
|
|
3
|
+
/** Initial bot messages shown before the user sends anything */
|
|
4
|
+
initialMessages?: string[];
|
|
5
|
+
/** CTA popup text (window mode) */
|
|
6
|
+
ctaText?: string;
|
|
7
|
+
/** Bot display name */
|
|
8
|
+
botName?: string;
|
|
9
|
+
/** Welcome screen subtitle */
|
|
10
|
+
welcomeSubtitle?: string;
|
|
11
|
+
/** Per-language tab title overrides (titles only — feed URLs/items are global). */
|
|
12
|
+
tabs?: {
|
|
13
|
+
notifications?: {
|
|
14
|
+
title?: string;
|
|
15
|
+
};
|
|
16
|
+
help?: {
|
|
17
|
+
title?: string;
|
|
18
|
+
};
|
|
19
|
+
chat?: {
|
|
20
|
+
title?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export type NotificationTagVariant = 'neutral' | 'success' | 'warning' | 'danger';
|
|
25
|
+
export interface NotificationTag {
|
|
26
|
+
label: string;
|
|
27
|
+
variant?: NotificationTagVariant;
|
|
28
|
+
}
|
|
29
|
+
export interface NotificationItem {
|
|
30
|
+
id?: string;
|
|
31
|
+
title: string;
|
|
32
|
+
message: string;
|
|
33
|
+
/** Tag entries can be plain strings (rendered as 'neutral') or { label, variant } objects. */
|
|
34
|
+
tags?: Array<string | NotificationTag>;
|
|
35
|
+
/** Verbatim string — host pre-formats. */
|
|
36
|
+
date?: string;
|
|
37
|
+
cta?: {
|
|
38
|
+
url: string;
|
|
39
|
+
title: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface FaqItem {
|
|
43
|
+
id?: string;
|
|
44
|
+
question: string;
|
|
45
|
+
answer: string;
|
|
46
|
+
category?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ChatConfig {
|
|
49
|
+
webhookUrl: string;
|
|
50
|
+
webhookConfig?: {
|
|
51
|
+
method?: 'POST' | 'GET';
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
};
|
|
54
|
+
chatInputKey?: string;
|
|
55
|
+
chatSessionKey?: string;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
showWelcomeScreen?: boolean;
|
|
58
|
+
defaultLanguage?: string;
|
|
59
|
+
/** Global fallback initial messages — per-language overrides live in i18n[lang].initialMessages */
|
|
60
|
+
initialMessages?: string[];
|
|
61
|
+
allowFileUploads?: boolean;
|
|
62
|
+
allowedFilesMimeTypes?: string;
|
|
63
|
+
/** Per-language content: initial messages, CTA text, bot name, welcome subtitle */
|
|
64
|
+
i18n?: Record<string, LangOverride>;
|
|
65
|
+
streaming?: boolean;
|
|
66
|
+
botName?: string;
|
|
67
|
+
theme?: string;
|
|
68
|
+
showSidebar?: boolean;
|
|
69
|
+
mode?: 'window' | 'fullscreen' | 'mixed';
|
|
70
|
+
showCta?: boolean;
|
|
71
|
+
ctaText?: string;
|
|
72
|
+
ctaDelay?: number;
|
|
73
|
+
ctaSound?: boolean;
|
|
74
|
+
/** Hide the built-in settings UI (gear button, theme picker, settings modal). */
|
|
75
|
+
hideSettings?: boolean;
|
|
76
|
+
/** Bot avatar. Built-in id (e.g. 'amara'), URL, or data URL. */
|
|
77
|
+
botAvatar?: string;
|
|
78
|
+
/** Popup toggle button icon (window mode). Built-in id, URL, or data URL. */
|
|
79
|
+
toggleButtonIcon?: string;
|
|
80
|
+
/** Link text shown after the localized "Powered by" prefix. Default: 'ELIA AI Assistant'. */
|
|
81
|
+
poweredByLabel?: string;
|
|
82
|
+
/** Link target URL. Default: 'https://www.elia-asistent.com'. */
|
|
83
|
+
poweredByUrl?: string;
|
|
84
|
+
/** Hide the entire "Powered by" footer line. */
|
|
85
|
+
poweredByHide?: boolean;
|
|
86
|
+
/** In fullscreen layout, present the chat as a bottom sheet (rounded top, drag handle, dimmed
|
|
87
|
+
* backdrop above) instead of fully covering the viewport. Applies to mode 'fullscreen' and to
|
|
88
|
+
* 'mixed' on mobile. Default: false. */
|
|
89
|
+
fullscreenSheet?: boolean;
|
|
90
|
+
/** Sheet height as a CSS length (vh, %, px). Default: '75vh'. */
|
|
91
|
+
fullscreenSheetHeight?: string;
|
|
92
|
+
/** Optional tabs above the chat panel. Tab is active iff its block has feedUrl OR items. */
|
|
93
|
+
tabs?: {
|
|
94
|
+
notifications?: {
|
|
95
|
+
title?: string;
|
|
96
|
+
feedUrl?: string;
|
|
97
|
+
items?: NotificationItem[];
|
|
98
|
+
};
|
|
99
|
+
help?: {
|
|
100
|
+
title?: string;
|
|
101
|
+
feedUrl?: string;
|
|
102
|
+
items?: FaqItem[];
|
|
103
|
+
};
|
|
104
|
+
chat?: {
|
|
105
|
+
title?: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export interface Message {
|
|
110
|
+
id: string;
|
|
111
|
+
role: 'user' | 'bot';
|
|
112
|
+
content: string;
|
|
113
|
+
ts: number;
|
|
114
|
+
}
|
|
115
|
+
export interface Session {
|
|
116
|
+
id: string;
|
|
117
|
+
title: string;
|
|
118
|
+
createdAt: number;
|
|
119
|
+
}
|
|
120
|
+
export interface ThemeDef {
|
|
121
|
+
id: string;
|
|
122
|
+
label: string;
|
|
123
|
+
scheme: 'dark' | 'light';
|
|
124
|
+
vars: ThemeVars;
|
|
125
|
+
}
|
|
126
|
+
export interface ThemeVars {
|
|
127
|
+
bgBase: string;
|
|
128
|
+
bgSurface: string;
|
|
129
|
+
bgSurface2: string;
|
|
130
|
+
bgBorder: string;
|
|
131
|
+
accent: string;
|
|
132
|
+
accentFg: string;
|
|
133
|
+
fgPrimary: string;
|
|
134
|
+
fgSecondary: string;
|
|
135
|
+
fgMuted: string;
|
|
136
|
+
userBubble: string;
|
|
137
|
+
userBubbleFg: string;
|
|
138
|
+
}
|
package/dist/types.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elia-assistant/chatui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"unpkg": "./dist/chatui.iife.js",
|
|
10
|
+
"jsdelivr": "./dist/chatui.iife.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/**/*.map",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./vanilla": {
|
|
23
|
+
"default": "./dist/chatui.iife.js"
|
|
24
|
+
},
|
|
25
|
+
"./store": {
|
|
26
|
+
"types": "./dist/store/settingsStore.d.ts",
|
|
27
|
+
"default": "./dist/store.js"
|
|
28
|
+
},
|
|
29
|
+
"./chat-store": {
|
|
30
|
+
"types": "./dist/store/chatStore.d.ts",
|
|
31
|
+
"default": "./dist/chat-store.js"
|
|
32
|
+
},
|
|
33
|
+
"./types": {
|
|
34
|
+
"types": "./dist/types/index.d.ts",
|
|
35
|
+
"default": "./dist/types.js"
|
|
36
|
+
},
|
|
37
|
+
"./css": {
|
|
38
|
+
"types": "./dist/chatui.css.d.ts",
|
|
39
|
+
"default": "./dist/chatui.css"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"dev": "vite",
|
|
44
|
+
"build": "tsc -b --noEmit && vite build && vite build --config vite.iife.config.ts && tsc -p tsconfig.build.json",
|
|
45
|
+
"preview": "vite preview",
|
|
46
|
+
"pack:dry": "npm pack --dry-run",
|
|
47
|
+
"prepublishOnly": "npm run build"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"react": "^19.0.0",
|
|
51
|
+
"react-dom": "^19.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"react": { "optional": true },
|
|
55
|
+
"react-dom": { "optional": true }
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"i18next": "^25.0.0",
|
|
59
|
+
"i18next-resources-to-backend": "^1.2.0",
|
|
60
|
+
"react-i18next": "^16.0.0",
|
|
61
|
+
"react-markdown": "^9.0.0",
|
|
62
|
+
"remark-gfm": "^4.0.0",
|
|
63
|
+
"zustand": "^5.0.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
67
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
68
|
+
"@types/node": "^25.6.0",
|
|
69
|
+
"@types/react": "^19.0.0",
|
|
70
|
+
"@types/react-dom": "^19.0.0",
|
|
71
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
72
|
+
"react": "^19.0.0",
|
|
73
|
+
"react-dom": "^19.0.0",
|
|
74
|
+
"tailwindcss": "^4.0.0",
|
|
75
|
+
"typescript": "~5.9.0",
|
|
76
|
+
"vite": "^8.0.0",
|
|
77
|
+
"vite-plugin-dts": "^4.5.4"
|
|
78
|
+
}
|
|
79
|
+
}
|