@djangocfg/ext-knowbase 1.0.21 → 1.0.23
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/config.cjs +12 -3
- package/dist/config.js +12 -3
- package/dist/hooks.cjs +209 -37
- package/dist/hooks.js +210 -38
- package/dist/i18n.cjs +164 -0
- package/dist/i18n.d.cts +72 -0
- package/dist/i18n.d.ts +72 -0
- package/dist/i18n.js +136 -0
- package/dist/index.cjs +12 -3
- package/dist/index.js +12 -3
- package/package.json +20 -11
- package/src/components/Chat/ChatWidget.tsx +30 -16
- package/src/components/Chat/components/MessageInput.tsx +15 -8
- package/src/components/Chat/components/MessageList.tsx +16 -7
- package/src/components/Chat/components/SessionList.tsx +29 -14
- package/src/i18n/index.ts +26 -0
- package/src/i18n/locales/en.ts +36 -0
- package/src/i18n/locales/ko.ts +36 -0
- package/src/i18n/locales/ru.ts +36 -0
- package/src/i18n/types.ts +59 -0
- package/src/i18n/useKnowbaseT.ts +60 -0
package/dist/hooks.js
CHANGED
|
@@ -5,11 +5,12 @@ import { initializeExtensionAPI, createExtensionAPI } from '@djangocfg/ext-base/
|
|
|
5
5
|
import useSWR, { useSWRConfig } from 'swr';
|
|
6
6
|
import { createExtensionConfig } from '@djangocfg/ext-base';
|
|
7
7
|
import '@djangocfg/ext-base/hooks';
|
|
8
|
-
import { createContext, useContext, useState, useCallback, useRef, useEffect } from 'react';
|
|
8
|
+
import { createContext, useContext, useState, useCallback, useRef, useMemo, useEffect } from 'react';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
import { Bot, ExternalLink, User, Loader2, Send, MessageSquare, Clock, Archive, Trash2, List, Plus, X, Minimize2, Maximize2 } from 'lucide-react';
|
|
11
11
|
import { usePathname } from 'next/navigation';
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
|
+
import { useLocale } from 'next-intl';
|
|
13
14
|
import { ScrollArea, Avatar, Card, CardContent, Badge, AvatarImage, AvatarFallback, Textarea, Button, Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, CardHeader } from '@djangocfg/ui-nextjs';
|
|
14
15
|
import { useIsMobile, useLocalStorage } from '@djangocfg/ui-core/hooks';
|
|
15
16
|
import moment from 'moment';
|
|
@@ -4788,7 +4789,7 @@ var apiKnowbase = createExtensionAPI(API);
|
|
|
4788
4789
|
// package.json
|
|
4789
4790
|
var package_default = {
|
|
4790
4791
|
name: "@djangocfg/ext-knowbase",
|
|
4791
|
-
version: "1.0.
|
|
4792
|
+
version: "1.0.23",
|
|
4792
4793
|
description: "Knowledge base and chat extension for DjangoCFG",
|
|
4793
4794
|
keywords: [
|
|
4794
4795
|
"django",
|
|
@@ -4834,6 +4835,11 @@ var package_default = {
|
|
|
4834
4835
|
types: "./dist/config.d.ts",
|
|
4835
4836
|
import: "./dist/config.js",
|
|
4836
4837
|
require: "./dist/config.cjs"
|
|
4838
|
+
},
|
|
4839
|
+
"./i18n": {
|
|
4840
|
+
types: "./dist/i18n.d.ts",
|
|
4841
|
+
import: "./dist/i18n.js",
|
|
4842
|
+
require: "./dist/i18n.cjs"
|
|
4837
4843
|
}
|
|
4838
4844
|
},
|
|
4839
4845
|
files: [
|
|
@@ -4849,27 +4855,31 @@ var package_default = {
|
|
|
4849
4855
|
peerDependencies: {
|
|
4850
4856
|
"@djangocfg/api": "workspace:*",
|
|
4851
4857
|
"@djangocfg/ext-base": "workspace:*",
|
|
4858
|
+
"@djangocfg/i18n": "workspace:*",
|
|
4852
4859
|
"@djangocfg/ui-core": "workspace:*",
|
|
4853
4860
|
"@djangocfg/ui-nextjs": "workspace:*",
|
|
4854
4861
|
consola: "^3.4.2",
|
|
4855
4862
|
"lucide-react": "^0.545.0",
|
|
4863
|
+
moment: "^2.30.1",
|
|
4856
4864
|
next: "^16",
|
|
4865
|
+
"next-intl": "^4",
|
|
4857
4866
|
"p-retry": "^7.0.0",
|
|
4858
4867
|
react: "^19",
|
|
4859
4868
|
"react-dom": "^19",
|
|
4860
4869
|
"react-markdown": "^9.0.0 || ^10.0.0",
|
|
4861
4870
|
swr: "^2.3.7",
|
|
4862
|
-
zod: "^4.3.4"
|
|
4863
|
-
moment: "^2.30.1"
|
|
4871
|
+
zod: "^4.3.4"
|
|
4864
4872
|
},
|
|
4865
4873
|
devDependencies: {
|
|
4866
4874
|
"@djangocfg/api": "workspace:*",
|
|
4867
4875
|
"@djangocfg/ext-base": "workspace:*",
|
|
4876
|
+
"@djangocfg/i18n": "workspace:*",
|
|
4868
4877
|
"@djangocfg/ui-core": "workspace:*",
|
|
4869
4878
|
"@djangocfg/typescript-config": "workspace:*",
|
|
4870
4879
|
"@types/node": "^24.7.2",
|
|
4871
4880
|
"@types/react": "^19.0.0",
|
|
4872
4881
|
consola: "^3.4.2",
|
|
4882
|
+
"next-intl": "^4.1.0",
|
|
4873
4883
|
"p-retry": "^7.0.0",
|
|
4874
4884
|
swr: "^2.3.7",
|
|
4875
4885
|
tsup: "^8.5.0",
|
|
@@ -5236,6 +5246,131 @@ function useChatUI() {
|
|
|
5236
5246
|
}
|
|
5237
5247
|
return context;
|
|
5238
5248
|
}
|
|
5249
|
+
|
|
5250
|
+
// src/i18n/locales/en.ts
|
|
5251
|
+
var en = {
|
|
5252
|
+
chat: {
|
|
5253
|
+
title: "Knowledge Assistant",
|
|
5254
|
+
titleShort: "Support",
|
|
5255
|
+
placeholder: "Ask me anything...",
|
|
5256
|
+
enterToSend: "Press Enter to send, Shift+Enter for new line",
|
|
5257
|
+
thinking: "Thinking...",
|
|
5258
|
+
source: "Source {index}",
|
|
5259
|
+
startConversation: "Start a Conversation",
|
|
5260
|
+
startConversationDescription: "Ask me anything about the documentation, features, or get help with your project.",
|
|
5261
|
+
openChat: "Open Support Chat"
|
|
5262
|
+
},
|
|
5263
|
+
sessions: {
|
|
5264
|
+
title: "Chat Sessions",
|
|
5265
|
+
description: "View and manage your chat history",
|
|
5266
|
+
noSessions: "No Sessions Yet",
|
|
5267
|
+
noSessionsDescription: "Start a new conversation to create your first session.",
|
|
5268
|
+
untitled: "Untitled Session",
|
|
5269
|
+
active: "Active",
|
|
5270
|
+
archive: "Archive",
|
|
5271
|
+
delete: "Delete",
|
|
5272
|
+
loadingMore: "Loading more...",
|
|
5273
|
+
noMore: "No more sessions",
|
|
5274
|
+
newChat: "New Chat"
|
|
5275
|
+
},
|
|
5276
|
+
actions: {
|
|
5277
|
+
sessions: "Sessions",
|
|
5278
|
+
collapse: "Collapse",
|
|
5279
|
+
expand: "Expand",
|
|
5280
|
+
close: "Close"
|
|
5281
|
+
}
|
|
5282
|
+
};
|
|
5283
|
+
|
|
5284
|
+
// src/i18n/locales/ru.ts
|
|
5285
|
+
var ru = {
|
|
5286
|
+
chat: {
|
|
5287
|
+
title: "\u0411\u0430\u0437\u0430 \u0437\u043D\u0430\u043D\u0438\u0439",
|
|
5288
|
+
titleShort: "\u041F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0430",
|
|
5289
|
+
placeholder: "\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u0432\u043E\u043F\u0440\u043E\u0441...",
|
|
5290
|
+
enterToSend: "Enter \u0434\u043B\u044F \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0438, Shift+Enter \u0434\u043B\u044F \u043D\u043E\u0432\u043E\u0439 \u0441\u0442\u0440\u043E\u043A\u0438",
|
|
5291
|
+
thinking: "\u0414\u0443\u043C\u0430\u044E...",
|
|
5292
|
+
source: "\u0418\u0441\u0442\u043E\u0447\u043D\u0438\u043A {index}",
|
|
5293
|
+
startConversation: "\u041D\u0430\u0447\u0430\u0442\u044C \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440",
|
|
5294
|
+
startConversationDescription: "\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u043B\u044E\u0431\u043E\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043E \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u0438, \u0444\u0443\u043D\u043A\u0446\u0438\u044F\u0445 \u0438\u043B\u0438 \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u0435 \u043F\u043E\u043C\u043E\u0449\u044C \u0441 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u043C.",
|
|
5295
|
+
openChat: "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0447\u0430\u0442 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0438"
|
|
5296
|
+
},
|
|
5297
|
+
sessions: {
|
|
5298
|
+
title: "\u0421\u0435\u0441\u0441\u0438\u0438 \u0447\u0430\u0442\u0430",
|
|
5299
|
+
description: "\u041F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u0438 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0438\u0441\u0442\u043E\u0440\u0438\u0435\u0439 \u0447\u0430\u0442\u0430",
|
|
5300
|
+
noSessions: "\u041D\u0435\u0442 \u0441\u0435\u0441\u0441\u0438\u0439",
|
|
5301
|
+
noSessionsDescription: "\u041D\u0430\u0447\u043D\u0438\u0442\u0435 \u043D\u043E\u0432\u044B\u0439 \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440, \u0447\u0442\u043E\u0431\u044B \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u0443\u044E \u0441\u0435\u0441\u0441\u0438\u044E.",
|
|
5302
|
+
untitled: "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F",
|
|
5303
|
+
active: "\u0410\u043A\u0442\u0438\u0432\u043D\u0430\u044F",
|
|
5304
|
+
archive: "\u0410\u0440\u0445\u0438\u0432\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
|
|
5305
|
+
delete: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
|
|
5306
|
+
loadingMore: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430...",
|
|
5307
|
+
noMore: "\u0411\u043E\u043B\u044C\u0448\u0435 \u043D\u0435\u0442 \u0441\u0435\u0441\u0441\u0438\u0439",
|
|
5308
|
+
newChat: "\u041D\u043E\u0432\u044B\u0439 \u0447\u0430\u0442"
|
|
5309
|
+
},
|
|
5310
|
+
actions: {
|
|
5311
|
+
sessions: "\u0421\u0435\u0441\u0441\u0438\u0438",
|
|
5312
|
+
collapse: "\u0421\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
|
|
5313
|
+
expand: "\u0420\u0430\u0437\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
|
|
5314
|
+
close: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C"
|
|
5315
|
+
}
|
|
5316
|
+
};
|
|
5317
|
+
|
|
5318
|
+
// src/i18n/locales/ko.ts
|
|
5319
|
+
var ko = {
|
|
5320
|
+
chat: {
|
|
5321
|
+
title: "\uC9C0\uC2DD \uB3C4\uC6B0\uBBF8",
|
|
5322
|
+
titleShort: "\uC9C0\uC6D0",
|
|
5323
|
+
placeholder: "\uBB34\uC5C7\uC774\uB4E0 \uBB3C\uC5B4\uBCF4\uC138\uC694...",
|
|
5324
|
+
enterToSend: "Enter\uB85C \uC804\uC1A1, Shift+Enter\uB85C \uC904\uBC14\uAFC8",
|
|
5325
|
+
thinking: "\uC0DD\uAC01 \uC911...",
|
|
5326
|
+
source: "\uCD9C\uCC98 {index}",
|
|
5327
|
+
startConversation: "\uB300\uD654 \uC2DC\uC791\uD558\uAE30",
|
|
5328
|
+
startConversationDescription: "\uBB38\uC11C, \uAE30\uB2A5\uC5D0 \uB300\uD574 \uC9C8\uBB38\uD558\uAC70\uB098 \uD504\uB85C\uC81D\uD2B8 \uB3C4\uC6C0\uC744 \uBC1B\uC73C\uC138\uC694.",
|
|
5329
|
+
openChat: "\uC9C0\uC6D0 \uCC44\uD305 \uC5F4\uAE30"
|
|
5330
|
+
},
|
|
5331
|
+
sessions: {
|
|
5332
|
+
title: "\uCC44\uD305 \uC138\uC158",
|
|
5333
|
+
description: "\uCC44\uD305 \uAE30\uB85D \uBCF4\uAE30 \uBC0F \uAD00\uB9AC",
|
|
5334
|
+
noSessions: "\uC138\uC158 \uC5C6\uC74C",
|
|
5335
|
+
noSessionsDescription: "\uC0C8 \uB300\uD654\uB97C \uC2DC\uC791\uD558\uC5EC \uCCAB \uBC88\uC9F8 \uC138\uC158\uC744 \uB9CC\uB4DC\uC138\uC694.",
|
|
5336
|
+
untitled: "\uC81C\uBAA9 \uC5C6\uC74C",
|
|
5337
|
+
active: "\uD65C\uC131",
|
|
5338
|
+
archive: "\uBCF4\uAD00",
|
|
5339
|
+
delete: "\uC0AD\uC81C",
|
|
5340
|
+
loadingMore: "\uBD88\uB7EC\uC624\uB294 \uC911...",
|
|
5341
|
+
noMore: "\uB354 \uC774\uC0C1 \uC138\uC158 \uC5C6\uC74C",
|
|
5342
|
+
newChat: "\uC0C8 \uCC44\uD305"
|
|
5343
|
+
},
|
|
5344
|
+
actions: {
|
|
5345
|
+
sessions: "\uC138\uC158",
|
|
5346
|
+
collapse: "\uCD95\uC18C",
|
|
5347
|
+
expand: "\uD655\uC7A5",
|
|
5348
|
+
close: "\uB2EB\uAE30"
|
|
5349
|
+
}
|
|
5350
|
+
};
|
|
5351
|
+
|
|
5352
|
+
// src/i18n/useKnowbaseT.ts
|
|
5353
|
+
var translations = { en, ru, ko };
|
|
5354
|
+
function getNestedValue(obj, path) {
|
|
5355
|
+
const keys = path.split(".");
|
|
5356
|
+
let result = obj;
|
|
5357
|
+
for (const key of keys) {
|
|
5358
|
+
if (result && typeof result === "object" && key in result) {
|
|
5359
|
+
result = result[key];
|
|
5360
|
+
} else {
|
|
5361
|
+
return path;
|
|
5362
|
+
}
|
|
5363
|
+
}
|
|
5364
|
+
return typeof result === "string" ? result : path;
|
|
5365
|
+
}
|
|
5366
|
+
function useKnowbaseT() {
|
|
5367
|
+
const locale = useLocale();
|
|
5368
|
+
const t = useMemo(() => translations[locale] || translations.en, [locale]);
|
|
5369
|
+
return useCallback(
|
|
5370
|
+
(key) => getNestedValue(t, key),
|
|
5371
|
+
[t]
|
|
5372
|
+
);
|
|
5373
|
+
}
|
|
5239
5374
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
5240
5375
|
var logger = createConsola({
|
|
5241
5376
|
level: isDevelopment ? 4 : 1
|
|
@@ -5252,8 +5387,15 @@ var MessageList = ({
|
|
|
5252
5387
|
autoScroll = true,
|
|
5253
5388
|
className = ""
|
|
5254
5389
|
}) => {
|
|
5390
|
+
const kt = useKnowbaseT();
|
|
5255
5391
|
const scrollRef = useRef(null);
|
|
5256
5392
|
const { user } = useAuth();
|
|
5393
|
+
const labels = useMemo(() => ({
|
|
5394
|
+
startConversation: kt("chat.startConversation"),
|
|
5395
|
+
startConversationDescription: kt("chat.startConversationDescription"),
|
|
5396
|
+
source: kt("chat.source"),
|
|
5397
|
+
thinking: kt("chat.thinking")
|
|
5398
|
+
}), [kt]);
|
|
5257
5399
|
useEffect(() => {
|
|
5258
5400
|
if (autoScroll && scrollRef.current) {
|
|
5259
5401
|
const scrollContainer = scrollRef.current.querySelector("[data-radix-scroll-area-viewport]");
|
|
@@ -5269,8 +5411,8 @@ var MessageList = ({
|
|
|
5269
5411
|
return /* @__PURE__ */ jsx(ScrollArea, { className: `h-full bg-muted/50 ${className}`, viewportRef: scrollRef, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 p-4", children: [
|
|
5270
5412
|
messages.length === 0 && !isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full text-center py-12", children: [
|
|
5271
5413
|
/* @__PURE__ */ jsx(Bot, { className: "h-12 w-12 text-muted-foreground mb-4" }),
|
|
5272
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children:
|
|
5273
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children:
|
|
5414
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: labels.startConversation }),
|
|
5415
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children: labels.startConversationDescription })
|
|
5274
5416
|
] }) : messages.map((message, index) => {
|
|
5275
5417
|
const isUser = message.role === Enums.ChatMessageRole.USER;
|
|
5276
5418
|
const isAssistant = message.role === Enums.ChatMessageRole.ASSISTANT;
|
|
@@ -5299,10 +5441,10 @@ var MessageList = ({
|
|
|
5299
5441
|
Badge,
|
|
5300
5442
|
{
|
|
5301
5443
|
variant: "secondary",
|
|
5302
|
-
className: "text-xs flex items-center gap-1 cursor-pointer
|
|
5444
|
+
className: "text-xs flex items-center gap-1 cursor-pointer\n hover:bg-secondary/80 hover:scale-105 active:scale-95\n transition-all duration-200 animate-in fade-in zoom-in-95",
|
|
5303
5445
|
style: { animationDelay: `${(idx + 1) * 100}ms` },
|
|
5304
5446
|
children: [
|
|
5305
|
-
source.document_title ||
|
|
5447
|
+
source.document_title || labels.source.replace("{index}", String(idx + 1)),
|
|
5306
5448
|
/* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" })
|
|
5307
5449
|
]
|
|
5308
5450
|
}
|
|
@@ -5323,7 +5465,7 @@ var MessageList = ({
|
|
|
5323
5465
|
/* @__PURE__ */ jsx(Avatar, { className: "h-8 w-8 shrink-0 animate-pulse", children: /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center justify-center bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Bot, { className: "h-5 w-5 animate-bounce" }) }) }),
|
|
5324
5466
|
/* @__PURE__ */ jsx(Card, { className: "bg-muted animate-pulse", children: /* @__PURE__ */ jsx(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
5325
5467
|
/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
|
|
5326
|
-
/* @__PURE__ */ jsx("span", { className: "animate-pulse", children:
|
|
5468
|
+
/* @__PURE__ */ jsx("span", { className: "animate-pulse", children: labels.thinking })
|
|
5327
5469
|
] }) }) })
|
|
5328
5470
|
] })
|
|
5329
5471
|
] }) });
|
|
@@ -5332,12 +5474,17 @@ var MessageInput = ({
|
|
|
5332
5474
|
onSend,
|
|
5333
5475
|
isLoading = false,
|
|
5334
5476
|
disabled = false,
|
|
5335
|
-
placeholder
|
|
5477
|
+
placeholder,
|
|
5336
5478
|
className = ""
|
|
5337
5479
|
}) => {
|
|
5480
|
+
const kt = useKnowbaseT();
|
|
5338
5481
|
const [message, setMessage] = useState("");
|
|
5339
5482
|
const [rows, setRows] = useState(1);
|
|
5340
5483
|
const textareaRef = useRef(null);
|
|
5484
|
+
const labels = useMemo(() => ({
|
|
5485
|
+
placeholder: placeholder || kt("chat.placeholder"),
|
|
5486
|
+
enterToSend: kt("chat.enterToSend")
|
|
5487
|
+
}), [kt, placeholder]);
|
|
5341
5488
|
useEffect(() => {
|
|
5342
5489
|
if (textareaRef.current) {
|
|
5343
5490
|
const lineHeight = 24;
|
|
@@ -5392,10 +5539,10 @@ var MessageInput = ({
|
|
|
5392
5539
|
value: message,
|
|
5393
5540
|
onChange: (e) => setMessage(e.target.value),
|
|
5394
5541
|
onKeyDown: handleKeyDown,
|
|
5395
|
-
placeholder,
|
|
5542
|
+
placeholder: labels.placeholder,
|
|
5396
5543
|
disabled: isDisabled,
|
|
5397
5544
|
rows,
|
|
5398
|
-
className: "resize-none min-h-[40px] max-h-[120px] transition-all duration-200
|
|
5545
|
+
className: "resize-none min-h-[40px] max-h-[120px] transition-all duration-200\n focus:ring-2 focus:ring-primary/20",
|
|
5399
5546
|
style: { resize: "none" }
|
|
5400
5547
|
}
|
|
5401
5548
|
),
|
|
@@ -5405,12 +5552,12 @@ var MessageInput = ({
|
|
|
5405
5552
|
type: "submit",
|
|
5406
5553
|
size: "icon",
|
|
5407
5554
|
disabled: !canSend,
|
|
5408
|
-
className: "shrink-0 h-10 w-10 transition-all duration-200
|
|
5555
|
+
className: "shrink-0 h-10 w-10 transition-all duration-200\n hover:scale-110 active:scale-95 disabled:scale-100",
|
|
5409
5556
|
children: isLoading ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "h-4 w-4" })
|
|
5410
5557
|
}
|
|
5411
5558
|
)
|
|
5412
5559
|
] }),
|
|
5413
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-2", children:
|
|
5560
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-2", children: labels.enterToSend })
|
|
5414
5561
|
] });
|
|
5415
5562
|
};
|
|
5416
5563
|
var PAGE_SIZE = 20;
|
|
@@ -5467,6 +5614,7 @@ var SessionList = ({
|
|
|
5467
5614
|
onSelectSession,
|
|
5468
5615
|
className = ""
|
|
5469
5616
|
}) => {
|
|
5617
|
+
const kt = useKnowbaseT();
|
|
5470
5618
|
const { deleteSession, archiveSession } = useKnowbaseSessionsContext();
|
|
5471
5619
|
const {
|
|
5472
5620
|
sessions,
|
|
@@ -5475,6 +5623,18 @@ var SessionList = ({
|
|
|
5475
5623
|
hasMore,
|
|
5476
5624
|
loadMore
|
|
5477
5625
|
} = useInfiniteSessions();
|
|
5626
|
+
const labels = useMemo(() => ({
|
|
5627
|
+
title: kt("sessions.title"),
|
|
5628
|
+
description: kt("sessions.description"),
|
|
5629
|
+
noSessions: kt("sessions.noSessions"),
|
|
5630
|
+
noSessionsDescription: kt("sessions.noSessionsDescription"),
|
|
5631
|
+
untitled: kt("sessions.untitled"),
|
|
5632
|
+
active: kt("sessions.active"),
|
|
5633
|
+
archive: kt("sessions.archive"),
|
|
5634
|
+
delete: kt("sessions.delete"),
|
|
5635
|
+
loadingMore: kt("sessions.loadingMore"),
|
|
5636
|
+
noMore: kt("sessions.noMore")
|
|
5637
|
+
}), [kt]);
|
|
5478
5638
|
const scrollRef = useRef(null);
|
|
5479
5639
|
const handleScroll = useCallback(() => {
|
|
5480
5640
|
if (!scrollRef.current || isLoadingMore || !hasMore) return;
|
|
@@ -5497,13 +5657,13 @@ var SessionList = ({
|
|
|
5497
5657
|
};
|
|
5498
5658
|
return /* @__PURE__ */ jsx(Sheet, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: `w-[400px] sm:w-[540px] ${className}`, children: [
|
|
5499
5659
|
/* @__PURE__ */ jsxs(SheetHeader, { children: [
|
|
5500
|
-
/* @__PURE__ */ jsx(SheetTitle, { children:
|
|
5501
|
-
/* @__PURE__ */ jsx(SheetDescription, { children:
|
|
5660
|
+
/* @__PURE__ */ jsx(SheetTitle, { children: labels.title }),
|
|
5661
|
+
/* @__PURE__ */ jsx(SheetDescription, { children: labels.description })
|
|
5502
5662
|
] }),
|
|
5503
5663
|
/* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-120px)] mt-6", viewportRef: scrollRef, children: isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : !sessions || sessions.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
|
|
5504
5664
|
/* @__PURE__ */ jsx(MessageSquare, { className: "h-12 w-12 text-muted-foreground mb-4" }),
|
|
5505
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children:
|
|
5506
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children:
|
|
5665
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: labels.noSessions }),
|
|
5666
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children: labels.noSessionsDescription })
|
|
5507
5667
|
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
5508
5668
|
sessions.map((session, index) => /* @__PURE__ */ jsxs(
|
|
5509
5669
|
"div",
|
|
@@ -5518,8 +5678,8 @@ var SessionList = ({
|
|
|
5518
5678
|
/* @__PURE__ */ jsx("div", { className: "shrink-0 mt-1", children: /* @__PURE__ */ jsx(MessageSquare, { className: "h-5 w-5 text-muted-foreground" }) }),
|
|
5519
5679
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
5520
5680
|
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2 mb-1", children: [
|
|
5521
|
-
/* @__PURE__ */ jsx("h4", { className: "font-medium text-sm truncate", children: session.title ||
|
|
5522
|
-
session.is_active && /* @__PURE__ */ jsx(Badge, { variant: "default", className: "shrink-0 text-xs", children:
|
|
5681
|
+
/* @__PURE__ */ jsx("h4", { className: "font-medium text-sm truncate", children: session.title || labels.untitled }),
|
|
5682
|
+
session.is_active && /* @__PURE__ */ jsx(Badge, { variant: "default", className: "shrink-0 text-xs", children: labels.active })
|
|
5523
5683
|
] }),
|
|
5524
5684
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
5525
5685
|
/* @__PURE__ */ jsx(Clock, { className: "h-3 w-3" }),
|
|
@@ -5537,7 +5697,7 @@ var SessionList = ({
|
|
|
5537
5697
|
e.stopPropagation();
|
|
5538
5698
|
archiveSession(session.id, {});
|
|
5539
5699
|
},
|
|
5540
|
-
title:
|
|
5700
|
+
title: labels.archive,
|
|
5541
5701
|
children: /* @__PURE__ */ jsx(Archive, { className: "h-4 w-4" })
|
|
5542
5702
|
}
|
|
5543
5703
|
),
|
|
@@ -5546,12 +5706,12 @@ var SessionList = ({
|
|
|
5546
5706
|
{
|
|
5547
5707
|
variant: "ghost",
|
|
5548
5708
|
size: "sm",
|
|
5549
|
-
className: "h-8 w-8 p-0 text-destructive hover:text-destructive
|
|
5709
|
+
className: "h-8 w-8 p-0 text-destructive hover:text-destructive\n hover:scale-110 active:scale-95 transition-transform duration-200",
|
|
5550
5710
|
onClick: (e) => {
|
|
5551
5711
|
e.stopPropagation();
|
|
5552
5712
|
deleteSession(session.id);
|
|
5553
5713
|
},
|
|
5554
|
-
title:
|
|
5714
|
+
title: labels.delete,
|
|
5555
5715
|
children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
|
|
5556
5716
|
}
|
|
5557
5717
|
)
|
|
@@ -5562,9 +5722,9 @@ var SessionList = ({
|
|
|
5562
5722
|
)),
|
|
5563
5723
|
isLoadingMore && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-6", children: [
|
|
5564
5724
|
/* @__PURE__ */ jsx(Loader2, { className: "h-5 w-5 animate-spin text-muted-foreground mr-2" }),
|
|
5565
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children:
|
|
5725
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: labels.loadingMore })
|
|
5566
5726
|
] }),
|
|
5567
|
-
!hasMore && sessions.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-center py-4", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children:
|
|
5727
|
+
!hasMore && sessions.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-center py-4", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: labels.noMore }) })
|
|
5568
5728
|
] }) })
|
|
5569
5729
|
] }) });
|
|
5570
5730
|
};
|
|
@@ -5577,6 +5737,7 @@ var ChatWidget = ({
|
|
|
5577
5737
|
onToggle,
|
|
5578
5738
|
onMessage
|
|
5579
5739
|
}) => {
|
|
5740
|
+
const kt = useKnowbaseT();
|
|
5580
5741
|
const { sendQuery, getChatHistory } = useKnowbaseChatContext();
|
|
5581
5742
|
const { createSession, getSession } = useKnowbaseSessionsContext();
|
|
5582
5743
|
const {
|
|
@@ -5587,6 +5748,17 @@ var ChatWidget = ({
|
|
|
5587
5748
|
toggleSources,
|
|
5588
5749
|
toggleTimestamps
|
|
5589
5750
|
} = useChatUI();
|
|
5751
|
+
const labels = useMemo(() => ({
|
|
5752
|
+
title: kt("chat.title"),
|
|
5753
|
+
titleShort: kt("chat.titleShort"),
|
|
5754
|
+
placeholder: kt("chat.placeholder"),
|
|
5755
|
+
openChat: kt("chat.openChat"),
|
|
5756
|
+
sessions: kt("actions.sessions"),
|
|
5757
|
+
newChat: kt("sessions.newChat"),
|
|
5758
|
+
collapse: kt("actions.collapse"),
|
|
5759
|
+
expand: kt("actions.expand"),
|
|
5760
|
+
close: kt("actions.close")
|
|
5761
|
+
}), [kt]);
|
|
5590
5762
|
const pathname = usePathname();
|
|
5591
5763
|
const isMobile = useIsMobile();
|
|
5592
5764
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -5727,7 +5899,7 @@ var ChatWidget = ({
|
|
|
5727
5899
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b bg-background shadow-sm", children: [
|
|
5728
5900
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5729
5901
|
/* @__PURE__ */ jsx(MessageSquare, { className: "h-5 w-5 text-primary" }),
|
|
5730
|
-
/* @__PURE__ */ jsx("h2", { className: "font-semibold text-foreground", children:
|
|
5902
|
+
/* @__PURE__ */ jsx("h2", { className: "font-semibold text-foreground", children: labels.title })
|
|
5731
5903
|
] }),
|
|
5732
5904
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5733
5905
|
/* @__PURE__ */ jsx(
|
|
@@ -5737,7 +5909,7 @@ var ChatWidget = ({
|
|
|
5737
5909
|
size: "sm",
|
|
5738
5910
|
onClick: () => setShowSessions(true),
|
|
5739
5911
|
className: "text-muted-foreground hover:text-foreground",
|
|
5740
|
-
title:
|
|
5912
|
+
title: labels.sessions,
|
|
5741
5913
|
children: /* @__PURE__ */ jsx(List, { className: "h-5 w-5" })
|
|
5742
5914
|
}
|
|
5743
5915
|
),
|
|
@@ -5748,7 +5920,7 @@ var ChatWidget = ({
|
|
|
5748
5920
|
size: "sm",
|
|
5749
5921
|
onClick: handleNewChat,
|
|
5750
5922
|
className: "text-muted-foreground hover:text-foreground",
|
|
5751
|
-
title:
|
|
5923
|
+
title: labels.newChat,
|
|
5752
5924
|
children: /* @__PURE__ */ jsx(Plus, { className: "h-5 w-5" })
|
|
5753
5925
|
}
|
|
5754
5926
|
),
|
|
@@ -5781,7 +5953,7 @@ var ChatWidget = ({
|
|
|
5781
5953
|
{
|
|
5782
5954
|
onSend: handleSendMessage,
|
|
5783
5955
|
isLoading,
|
|
5784
|
-
placeholder:
|
|
5956
|
+
placeholder: labels.placeholder
|
|
5785
5957
|
}
|
|
5786
5958
|
)
|
|
5787
5959
|
] })
|
|
@@ -5830,7 +6002,7 @@ var ChatWidget = ({
|
|
|
5830
6002
|
/* @__PURE__ */ jsxs(CardHeader, { className: "flex-row items-center justify-between space-y-0 pb-3 border-b", children: [
|
|
5831
6003
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5832
6004
|
/* @__PURE__ */ jsx(MessageSquare, { className: "h-5 w-5 text-primary" }),
|
|
5833
|
-
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-foreground", children:
|
|
6005
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-foreground", children: labels.titleShort })
|
|
5834
6006
|
] }),
|
|
5835
6007
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
5836
6008
|
/* @__PURE__ */ jsx(
|
|
@@ -5840,7 +6012,7 @@ var ChatWidget = ({
|
|
|
5840
6012
|
size: "sm",
|
|
5841
6013
|
onClick: () => setShowSessions(true),
|
|
5842
6014
|
className: "h-8 w-8 p-0",
|
|
5843
|
-
title:
|
|
6015
|
+
title: labels.sessions,
|
|
5844
6016
|
children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" })
|
|
5845
6017
|
}
|
|
5846
6018
|
),
|
|
@@ -5851,7 +6023,7 @@ var ChatWidget = ({
|
|
|
5851
6023
|
size: "sm",
|
|
5852
6024
|
onClick: handleNewChat,
|
|
5853
6025
|
className: "h-8 w-8 p-0",
|
|
5854
|
-
title:
|
|
6026
|
+
title: labels.newChat,
|
|
5855
6027
|
children: /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" })
|
|
5856
6028
|
}
|
|
5857
6029
|
),
|
|
@@ -5862,7 +6034,7 @@ var ChatWidget = ({
|
|
|
5862
6034
|
size: "sm",
|
|
5863
6035
|
onClick: uiState.isExpanded ? collapseChat : expandChat,
|
|
5864
6036
|
className: "h-8 w-8 p-0",
|
|
5865
|
-
title: uiState.isExpanded ?
|
|
6037
|
+
title: uiState.isExpanded ? labels.collapse : labels.expand,
|
|
5866
6038
|
children: uiState.isExpanded ? /* @__PURE__ */ jsx(Minimize2, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Maximize2, { className: "h-4 w-4" })
|
|
5867
6039
|
}
|
|
5868
6040
|
),
|
|
@@ -5873,7 +6045,7 @@ var ChatWidget = ({
|
|
|
5873
6045
|
size: "sm",
|
|
5874
6046
|
onClick: toggleChat,
|
|
5875
6047
|
className: "h-8 w-8 p-0",
|
|
5876
|
-
title:
|
|
6048
|
+
title: labels.close,
|
|
5877
6049
|
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
5878
6050
|
}
|
|
5879
6051
|
)
|
|
@@ -5896,7 +6068,7 @@ var ChatWidget = ({
|
|
|
5896
6068
|
{
|
|
5897
6069
|
onSend: handleSendMessage,
|
|
5898
6070
|
isLoading,
|
|
5899
|
-
placeholder:
|
|
6071
|
+
placeholder: labels.placeholder
|
|
5900
6072
|
}
|
|
5901
6073
|
)
|
|
5902
6074
|
] })
|
|
@@ -5931,14 +6103,14 @@ var ChatWidget = ({
|
|
|
5931
6103
|
Button,
|
|
5932
6104
|
{
|
|
5933
6105
|
onClick: toggleChat,
|
|
5934
|
-
className: "w-full h-full rounded-full shadow-2xl
|
|
6106
|
+
className: "w-full h-full rounded-full shadow-2xl\n hover:scale-110 hover:rotate-12 active:scale-95\n transition-all duration-300 ease-out\n flex items-center justify-center\n group",
|
|
5935
6107
|
style: {
|
|
5936
6108
|
backgroundColor: "hsl(var(--primary))",
|
|
5937
6109
|
borderRadius: "50%",
|
|
5938
6110
|
padding: 0
|
|
5939
6111
|
},
|
|
5940
|
-
title:
|
|
5941
|
-
"aria-label":
|
|
6112
|
+
title: labels.openChat,
|
|
6113
|
+
"aria-label": labels.openChat,
|
|
5942
6114
|
children: /* @__PURE__ */ jsx(
|
|
5943
6115
|
MessageSquare,
|
|
5944
6116
|
{
|