@agentscope-ai/chat 1.1.45-beta.1766389993910 → 1.1.45-beta.1766392979633

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.
@@ -0,0 +1,42 @@
1
+ import { IconButton, Popover } from "@agentscope-ai/design";
2
+ import { PlusOutlined } from "@ant-design/icons";
3
+ import { useGetState } from "ahooks";
4
+ import { Flex } from "antd";
5
+ import React from "react";
6
+ import { useEffect, useState } from "react";
7
+
8
+
9
+
10
+ export default function UploadPopover({
11
+ nodes
12
+ }: {
13
+ nodes: React.ReactElement[];
14
+ }) {
15
+ const [visible, setVisible, getVisible] = useGetState(false);
16
+
17
+ useEffect(() => {
18
+ const close = () => {
19
+ if (getVisible()) {
20
+ setVisible(false);
21
+ }
22
+ };
23
+
24
+ document.addEventListener('click', close, true);
25
+ return () => {
26
+ document.removeEventListener('click', close, true);
27
+ }
28
+ }, []);
29
+
30
+ return <Popover
31
+ placement='bottomLeft'
32
+ open={visible}
33
+ onOpenChange={setVisible}
34
+ content={<Flex vertical>
35
+ {nodes}
36
+ </Flex>} trigger="click" styles={{ body: { padding: 4 } }}>
37
+ <IconButton
38
+ icon={<PlusOutlined />}
39
+ bordered={false}
40
+ />
41
+ </Popover>
42
+ }
@@ -8,7 +8,7 @@ import { GetProp, Space, Upload } from 'antd';
8
8
  import Style from './style';
9
9
  import { IconButton, Button } from '@agentscope-ai/design';
10
10
  import { AIGC } from '@agentscope-ai/chat';
11
- import { PlusOutlined } from '@ant-design/icons';
11
+ import UploadPopover from './UploadPopover';
12
12
 
13
13
  type AttachedFiles = GetProp<typeof Attachments, 'items'>;
14
14
 
@@ -130,14 +130,8 @@ export default forwardRef(function (_, ref) {
130
130
  });
131
131
 
132
132
  if (nodes.length === 1) return nodes;
133
- return <Popover content={<Flex vertical>
134
- {nodes}
135
- </Flex>} trigger="click" styles={{ body: { padding: 4 } }}>
136
- <IconButton
137
- icon={<PlusOutlined />}
138
- bordered={false}
139
- />
140
- </Popover>
133
+ return <UploadPopover nodes={nodes} />
134
+
141
135
 
142
136
 
143
137
  }, [onInput.variant, onUpload, attachedFiles]);
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export default function UploadPopover({ nodes }: {
3
+ nodes: React.ReactElement[];
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,51 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { IconButton, Popover } from "@agentscope-ai/design";
8
+ import { PlusOutlined } from "@agentscope-ai/icons-override-antd";
9
+ import { useGetState } from "ahooks";
10
+ import { Flex } from "antd";
11
+ import React from "react";
12
+ import { useEffect } from "react";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ export default function UploadPopover(_ref) {
15
+ var nodes = _ref.nodes;
16
+ var _useGetState = useGetState(false),
17
+ _useGetState2 = _slicedToArray(_useGetState, 3),
18
+ visible = _useGetState2[0],
19
+ setVisible = _useGetState2[1],
20
+ getVisible = _useGetState2[2];
21
+ useEffect(function () {
22
+ var close = function close() {
23
+ if (getVisible()) {
24
+ setVisible(false);
25
+ }
26
+ };
27
+ document.addEventListener('click', close, true);
28
+ return function () {
29
+ document.removeEventListener('click', close, true);
30
+ };
31
+ }, []);
32
+ return /*#__PURE__*/_jsx(Popover, {
33
+ placement: "bottomLeft",
34
+ open: visible,
35
+ onOpenChange: setVisible,
36
+ content: /*#__PURE__*/_jsx(Flex, {
37
+ vertical: true,
38
+ children: nodes
39
+ }),
40
+ trigger: "click",
41
+ styles: {
42
+ body: {
43
+ padding: 4
44
+ }
45
+ },
46
+ children: /*#__PURE__*/_jsx(IconButton, {
47
+ icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
48
+ bordered: false
49
+ })
50
+ });
51
+ }
@@ -18,7 +18,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
18
18
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
  import React, { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
21
- import { Flex, Popover } from 'antd';
22
21
  import { useProviderContext, ChatInput, Sender, Attachments } from "../..";
23
22
  import cls from 'classnames';
24
23
  import { useChatAnywhere } from "../hooks/ChatAnywhereProvider";
@@ -27,7 +26,7 @@ import { Upload } from 'antd';
27
26
  import Style from "./style";
28
27
  import { IconButton, Button } from '@agentscope-ai/design';
29
28
  import { AIGC } from "../..";
30
- import { PlusOutlined } from "@agentscope-ai/icons-override-antd";
29
+ import UploadPopover from "./UploadPopover";
31
30
  import { jsx as _jsx } from "react/jsx-runtime";
32
31
  import { jsxs as _jsxs } from "react/jsx-runtime";
33
32
  import { createElement as _createElement } from "react";
@@ -168,21 +167,8 @@ export default /*#__PURE__*/forwardRef(function (_, ref) {
168
167
  }), trigger);
169
168
  });
170
169
  if (nodes.length === 1) return nodes;
171
- return /*#__PURE__*/_jsx(Popover, {
172
- content: /*#__PURE__*/_jsx(Flex, {
173
- vertical: true,
174
- children: nodes
175
- }),
176
- trigger: "click",
177
- styles: {
178
- body: {
179
- padding: 4
180
- }
181
- },
182
- children: /*#__PURE__*/_jsx(IconButton, {
183
- icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
184
- bordered: false
185
- })
170
+ return /*#__PURE__*/_jsx(UploadPopover, {
171
+ nodes: nodes
186
172
  });
187
173
  }, [onInput.variant, onUpload, attachedFiles]);
188
174
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/chat",
3
- "version": "1.1.45-beta.1766389993910",
3
+ "version": "1.1.45-beta.1766392979633",
4
4
  "description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": [