@zero-library/chat-agent 2.3.6 → 2.3.8

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/index.cjs.js CHANGED
@@ -1308,9 +1308,7 @@ var MessageRender_default = ({ message: message2, placement, onFilePreview, cust
1308
1308
  onFilePreview?.(file);
1309
1309
  }
1310
1310
  };
1311
- const mergedCustomComponents = react.useMemo(() => {
1312
- return { ...customComponents, ...propsCustomComponents };
1313
- }, [propsCustomComponents]);
1311
+ const mergedCustomComponents = { ...customComponents, ...propsCustomComponents };
1314
1312
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, children: !(msgContent || message2.msgFiles.length) ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { size: "small" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1315
1313
  msgContent && /* @__PURE__ */ jsxRuntime.jsx(
1316
1314
  x.Bubble,
@@ -1758,7 +1756,7 @@ var ConversationFavoritesList_default = () => {
1758
1756
  chatStore.getConversationFavorite();
1759
1757
  }, 300);
1760
1758
  const renderFavoriteList = react.useMemo(() => {
1761
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames11__default.default("height-full", "scroll-fade-in"), children: favoriteState.list.items.length ? favoriteState.list.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
1759
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 4, className: classNames11__default.default("height-full", "scroll-fade-in"), children: favoriteState.list.items.length ? favoriteState.list.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
1762
1760
  "div",
1763
1761
  {
1764
1762
  className: classNames11__default.default(styles_module_default3.favoriteCard, { [styles_module_default3.favoriteCardActive]: conversationState.active.id === item.id }),
@@ -1777,6 +1775,7 @@ var ConversationFavoritesList_default = () => {
1777
1775
  e.stopPropagation();
1778
1776
  chatStore.collectConversation(item.id, false);
1779
1777
  },
1778
+ onCancel: (e) => e.stopPropagation(),
1780
1779
  children: /* @__PURE__ */ jsxRuntime.jsx(
1781
1780
  antd.Button,
1782
1781
  {
@@ -2174,7 +2173,7 @@ init_Context();
2174
2173
  // src/ui/common/FeaturesRenderer.tsx
2175
2174
  init_Context();
2176
2175
 
2177
- // src/ui/common/QuickAsk/QuickAskPanel.tsx
2176
+ // src/ui/common/QuickAsk/QuickAskPanelDrawer.tsx
2178
2177
  init_Context();
2179
2178
 
2180
2179
  // src/ui/common/QuickAsk/QuickAskEditModal.tsx
@@ -2277,7 +2276,8 @@ var styles_module_default4 = {
2277
2276
  quickAskItemHeaderActions: "styles_module_quickAskItemHeaderActions",
2278
2277
  quickAskItemBody: "styles_module_quickAskItemBody"
2279
2278
  };
2280
- var QuickAskPanel_default = () => {
2279
+ var ALL = "all";
2280
+ var QuickAskPanelDrawer_default = ({ open, onClose }) => {
2281
2281
  const { message: message2 } = antd.App.useApp();
2282
2282
  const chatStore = useChatStore();
2283
2283
  const configState = valtio.useSnapshot(chatStore.config);
@@ -2298,6 +2298,19 @@ var QuickAskPanel_default = () => {
2298
2298
  } catch (err) {
2299
2299
  }
2300
2300
  };
2301
+ const tabsItems = react.useMemo(
2302
+ () => [
2303
+ {
2304
+ key: ALL,
2305
+ label: "\u5168\u90E8"
2306
+ },
2307
+ ...categories.map((item) => ({
2308
+ key: item.id,
2309
+ label: item.labelName
2310
+ }))
2311
+ ],
2312
+ [categories]
2313
+ );
2301
2314
  const [loading, setLoading] = react.useState(false);
2302
2315
  const fetchItems = common.useDebounce(async () => {
2303
2316
  try {
@@ -2353,153 +2366,158 @@ var QuickAskPanel_default = () => {
2353
2366
  } catch (err) {
2354
2367
  }
2355
2368
  };
2356
- return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: styles_module_default4.quickAskPanel, children: [
2357
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "space-between", align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Title, { level: 5, children: "\u5FEB\u901F\u63D0\u95EE" }) }),
2358
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, className: "m-b-16 m-t-16", children: [
2359
- !searchExpanded && /* @__PURE__ */ jsxRuntime.jsx(
2360
- antd.Button,
2361
- {
2362
- type: "dashed",
2363
- block: true,
2364
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
2365
- className: "flex-1",
2366
- onClick: () => {
2367
- setEditingItem(null);
2368
- setEditModalOpen(true);
2369
- },
2370
- children: "\u65B0\u589E\u5FEB\u901F\u63D0\u95EE"
2371
- }
2372
- ),
2373
- searchExpanded ? /* @__PURE__ */ jsxRuntime.jsx(
2374
- antd.Input,
2375
- {
2376
- autoFocus: true,
2377
- placeholder: "\u8F93\u5165\u95EE\u9898\u540D\u79F0\u6216\u5185\u5BB9\u68C0\u7D22",
2378
- prefix: /* @__PURE__ */ jsxRuntime.jsx(icons.SearchOutlined, {}),
2379
- value: searchText,
2380
- onChange: (e) => {
2381
- setSearchText(e.target.value);
2382
- fetchItems();
2383
- },
2384
- className: "flex-1",
2385
- allowClear: true,
2386
- onBlur: () => setSearchExpanded(false)
2387
- }
2388
- ) : /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.SearchOutlined, {}), onClick: () => setSearchExpanded(true) })
2389
- ] }),
2390
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", className: classNames11__default.default("scroll-fade-in", "m-b-16", styles_module_default4.tagContainer), children: [
2391
- /* @__PURE__ */ jsxRuntime.jsx(
2392
- antd.Tag,
2393
- {
2394
- color: !activeTab.id ? "processing" : "default",
2395
- className: "cursor-pointer",
2396
- bordered: false,
2397
- onClick: () => {
2398
- setActiveTab({});
2399
- fetchItems();
2400
- },
2401
- children: "\u5168\u90E8"
2402
- }
2403
- ),
2404
- categories.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
2405
- antd.Tag,
2406
- {
2407
- color: activeTab.id === c.id ? "processing" : "default",
2408
- className: "cursor-pointer",
2409
- bordered: false,
2410
- onClick: () => {
2411
- setActiveTab(c);
2412
- fetchItems();
2413
- },
2414
- children: c.labelName
2415
- },
2416
- c.id
2417
- ))
2418
- ] }),
2419
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, wrapperClassName: "full-spin", tip: "\u52A0\u8F7D\u4E2D...", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, className: "height-full scroll-fade-in", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
2420
- "div",
2369
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2370
+ /* @__PURE__ */ jsxRuntime.jsx(
2371
+ antd.Drawer,
2421
2372
  {
2422
- className: styles_module_default4.quickAskItem,
2423
- onClick: () => {
2424
- chatStore.setContent(item.content);
2425
- chatStore.setContentParams({
2426
- use_template: 1
2427
- });
2428
- },
2429
- children: [
2430
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, justify: "space-between", align: "center", className: styles_module_default4.quickAskItemHeader, children: [
2431
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames11__default.default("flex-1 text-ellipsis", styles_module_default4.quickAskItemTitle), children: item.title }),
2432
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { size: 4, className: styles_module_default4.quickAskItemHeaderActions, children: [
2433
- /* @__PURE__ */ jsxRuntime.jsx(
2434
- antd.Button,
2435
- {
2436
- type: "primary",
2437
- size: "small",
2438
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PushpinOutlined, { rotate: item.isTop ? -45 : 0 }),
2439
- title: item.isTop ? "\u53D6\u6D88\u7F6E\u9876" : "\u7F6E\u9876",
2440
- onClick: (e) => {
2441
- e.stopPropagation();
2442
- handleTop(item);
2443
- }
2444
- },
2445
- "top"
2446
- ),
2447
- /* @__PURE__ */ jsxRuntime.jsx(
2448
- antd.Button,
2449
- {
2450
- type: "primary",
2451
- size: "small",
2452
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}),
2453
- title: "\u590D\u5236",
2454
- onClick: (e) => {
2455
- e.stopPropagation();
2456
- setEditingItem({
2457
- title: item.title,
2458
- labelName: item.labelName,
2459
- content: item.content
2460
- });
2461
- setEditModalOpen(true);
2462
- }
2463
- },
2464
- "copy"
2465
- ),
2466
- /* @__PURE__ */ jsxRuntime.jsx(
2373
+ className: classNames11__default.default("no-padding-drawer"),
2374
+ width: 360,
2375
+ open,
2376
+ title: "\u5FEB\u901F\u63D0\u95EE",
2377
+ closable: { placement: "end" },
2378
+ onClose,
2379
+ placement: "right",
2380
+ mask: false,
2381
+ children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: styles_module_default4.quickAskPanel, children: [
2382
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 12, className: "p-16", vertical: true, children: [
2383
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, children: [
2384
+ !searchExpanded && /* @__PURE__ */ jsxRuntime.jsx(
2467
2385
  antd.Button,
2468
2386
  {
2469
- type: "primary",
2470
- size: "small",
2471
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.EditOutlined, {}),
2472
- title: "\u7F16\u8F91",
2473
- onClick: (e) => {
2474
- e.stopPropagation();
2475
- setEditingItem(item);
2387
+ type: "dashed",
2388
+ block: true,
2389
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
2390
+ className: "flex-1",
2391
+ onClick: () => {
2392
+ setEditingItem(null);
2476
2393
  setEditModalOpen(true);
2477
- }
2478
- },
2479
- "edit"
2394
+ },
2395
+ children: "\u65B0\u589E\u5FEB\u901F\u63D0\u95EE"
2396
+ }
2480
2397
  ),
2481
- item.canDelete && /* @__PURE__ */ jsxRuntime.jsx(
2482
- antd.Popconfirm,
2398
+ searchExpanded ? /* @__PURE__ */ jsxRuntime.jsx(
2399
+ antd.Input,
2483
2400
  {
2484
- title: "\u63D0\u793A",
2485
- okText: "\u786E\u5B9A",
2486
- cancelText: "\u53D6\u6D88",
2487
- description: "\u786E\u8BA4\u5220\u9664\u95EE\u9898\u5417?",
2488
- onConfirm: (e) => {
2489
- e.stopPropagation();
2490
- handleDelete(item.id);
2401
+ autoFocus: true,
2402
+ placeholder: "\u8F93\u5165\u95EE\u9898\u540D\u79F0\u6216\u5185\u5BB9\u68C0\u7D22",
2403
+ prefix: /* @__PURE__ */ jsxRuntime.jsx(icons.SearchOutlined, {}),
2404
+ value: searchText,
2405
+ onChange: (e) => {
2406
+ setSearchText(e.target.value);
2407
+ fetchItems();
2491
2408
  },
2492
- children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}), title: "\u5220\u9664", onClick: (e) => e.stopPropagation() })
2409
+ className: "flex-1",
2410
+ allowClear: true,
2411
+ onBlur: () => setSearchExpanded(false)
2412
+ }
2413
+ ) : /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.SearchOutlined, {}), onClick: () => setSearchExpanded(true) })
2414
+ ] }),
2415
+ /* @__PURE__ */ jsxRuntime.jsx(
2416
+ antd.Tabs,
2417
+ {
2418
+ className: styles_module_default4.tagContainer,
2419
+ activeKey: activeTab.id ? activeTab.id : ALL,
2420
+ onChange: (key) => {
2421
+ setActiveTab(key === ALL ? {} : categories.find((c) => c.id === key));
2422
+ fetchItems();
2493
2423
  },
2494
- "delete"
2495
- )
2496
- ] })
2424
+ tabPosition: "top",
2425
+ items: tabsItems,
2426
+ size: "small"
2427
+ }
2428
+ )
2497
2429
  ] }),
2498
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames11__default.default(styles_module_default4.quickAskItemBody), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ellipsis-3", children: item.content }) })
2499
- ]
2500
- },
2501
- item.id
2502
- )) }) }) }),
2430
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, wrapperClassName: "full-spin", tip: "\u52A0\u8F7D\u4E2D...", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, className: "height-full scroll-fade-in p-16 p-t-8", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
2431
+ "div",
2432
+ {
2433
+ className: styles_module_default4.quickAskItem,
2434
+ onClick: () => {
2435
+ chatStore.setContent(item.content);
2436
+ chatStore.setContentParams({
2437
+ use_template: 1
2438
+ });
2439
+ onClose();
2440
+ },
2441
+ children: [
2442
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, justify: "space-between", align: "center", className: styles_module_default4.quickAskItemHeader, children: [
2443
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames11__default.default("flex-1 text-ellipsis", styles_module_default4.quickAskItemTitle), children: item.title }),
2444
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { size: 4, className: styles_module_default4.quickAskItemHeaderActions, children: [
2445
+ /* @__PURE__ */ jsxRuntime.jsx(
2446
+ antd.Button,
2447
+ {
2448
+ type: "primary",
2449
+ size: "small",
2450
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PushpinOutlined, { rotate: item.isTop ? -45 : 0 }),
2451
+ title: item.isTop ? "\u53D6\u6D88\u7F6E\u9876" : "\u7F6E\u9876",
2452
+ onClick: (e) => {
2453
+ e.stopPropagation();
2454
+ handleTop(item);
2455
+ }
2456
+ },
2457
+ "top"
2458
+ ),
2459
+ /* @__PURE__ */ jsxRuntime.jsx(
2460
+ antd.Button,
2461
+ {
2462
+ type: "primary",
2463
+ size: "small",
2464
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}),
2465
+ title: "\u590D\u5236",
2466
+ onClick: (e) => {
2467
+ e.stopPropagation();
2468
+ setEditingItem({
2469
+ title: item.title,
2470
+ labelName: item.labelName,
2471
+ content: item.content
2472
+ });
2473
+ setEditModalOpen(true);
2474
+ }
2475
+ },
2476
+ "copy"
2477
+ ),
2478
+ /* @__PURE__ */ jsxRuntime.jsx(
2479
+ antd.Button,
2480
+ {
2481
+ type: "primary",
2482
+ size: "small",
2483
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.EditOutlined, {}),
2484
+ title: "\u7F16\u8F91",
2485
+ onClick: (e) => {
2486
+ e.stopPropagation();
2487
+ setEditingItem(item);
2488
+ setEditModalOpen(true);
2489
+ }
2490
+ },
2491
+ "edit"
2492
+ ),
2493
+ item.canDelete && /* @__PURE__ */ jsxRuntime.jsx(
2494
+ antd.Popconfirm,
2495
+ {
2496
+ title: "\u63D0\u793A",
2497
+ okText: "\u786E\u5B9A",
2498
+ cancelText: "\u53D6\u6D88",
2499
+ description: "\u786E\u8BA4\u5220\u9664\u95EE\u9898\u5417?",
2500
+ onConfirm: (e) => {
2501
+ e.stopPropagation();
2502
+ handleDelete(item.id);
2503
+ },
2504
+ onCancel: (e) => {
2505
+ e.stopPropagation();
2506
+ },
2507
+ children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}), title: "\u5220\u9664", onClick: (e) => e.stopPropagation() })
2508
+ },
2509
+ "delete"
2510
+ )
2511
+ ] })
2512
+ ] }),
2513
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames11__default.default(styles_module_default4.quickAskItemBody), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ellipsis-3", children: item.content }) })
2514
+ ]
2515
+ },
2516
+ item.id
2517
+ )) }) }) })
2518
+ ] })
2519
+ }
2520
+ ),
2503
2521
  editModalOpen && /* @__PURE__ */ jsxRuntime.jsx(
2504
2522
  QuickAskEditModal_default,
2505
2523
  {
@@ -2517,6 +2535,7 @@ var FeaturesRenderer_default = () => {
2517
2535
  const chatStore = useChatStore();
2518
2536
  const receiverState = valtio.useSnapshot(chatStore.receiver);
2519
2537
  const conversationState = valtio.useSnapshot(chatStore.conversation);
2538
+ const [quickAskOpen, setQuickAskOpen] = react.useState(false);
2520
2539
  const chatMessage = react.useMemo(
2521
2540
  () => conversationState.messages[conversationState.active.id] || {},
2522
2541
  [conversationState.messages[conversationState.active.id]]
@@ -2547,23 +2566,10 @@ var FeaturesRenderer_default = () => {
2547
2566
  children: "\u5411\u4E13\u5BB6\u54A8\u8BE2"
2548
2567
  }
2549
2568
  ),
2550
- receiverState.active.feature?.quickAsk && /* @__PURE__ */ jsxRuntime.jsx(
2551
- antd.Popover,
2552
- {
2553
- trigger: "click",
2554
- placement: "topLeft",
2555
- content: /* @__PURE__ */ jsxRuntime.jsx(QuickAskPanel_default, {}),
2556
- children: /* @__PURE__ */ jsxRuntime.jsx(
2557
- antd.Button,
2558
- {
2559
- size: "small",
2560
- color: "primary",
2561
- variant: "filled",
2562
- children: "\u5FEB\u901F\u63D0\u95EE"
2563
- }
2564
- )
2565
- }
2566
- )
2569
+ receiverState.active.feature?.quickAsk && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2570
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { size: "small", color: "primary", variant: "filled", onClick: () => setQuickAskOpen(true), children: "\u5FEB\u901F\u63D0\u95EE" }),
2571
+ quickAskOpen && /* @__PURE__ */ jsxRuntime.jsx(QuickAskPanelDrawer_default, { open: quickAskOpen, onClose: () => setQuickAskOpen(false) })
2572
+ ] })
2567
2573
  ] });
2568
2574
  };
2569
2575
  var ChatSender_default2 = react.forwardRef(