@agentscope-ai/chat 1.1.45-beta.1766481031578 → 1.1.45-beta.1766559488425
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/components/ChatAnywhere/Input/UploadPopover.tsx +20 -18
- package/components/ChatAnywhere/Input/index.tsx +14 -15
- package/lib/ChatAnywhere/Input/UploadPopover.d.ts +2 -3
- package/lib/ChatAnywhere/Input/UploadPopover.js +21 -15
- package/lib/ChatAnywhere/Input/index.js +7 -7
- package/package.json +1 -1
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { IconButton, Popover } from "@agentscope-ai/design";
|
|
2
2
|
import { PlusOutlined } from "@ant-design/icons";
|
|
3
3
|
import { useGetState } from "ahooks";
|
|
4
|
-
import { Flex } from "antd";
|
|
5
|
-
import React from "react";
|
|
4
|
+
import { Flex, Upload } from "antd";
|
|
5
|
+
import React, { useMemo } from "react";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
8
|
export default function UploadPopover({
|
|
11
|
-
|
|
9
|
+
uploadPropsList
|
|
12
10
|
}: {
|
|
13
|
-
|
|
11
|
+
uploadPropsList: any[];
|
|
14
12
|
}) {
|
|
15
13
|
const [visible, setVisible, getVisible] = useGetState(false);
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
const nodes = useMemo(() => {
|
|
16
|
+
return uploadPropsList.map((item, index) => {
|
|
17
|
+
return (
|
|
18
|
+
<Upload
|
|
19
|
+
key={index}
|
|
20
|
+
{...item}
|
|
21
|
+
customRequest={(v) => {
|
|
22
|
+
if (item.customRequest) {
|
|
23
|
+
item.customRequest(v);
|
|
24
|
+
}
|
|
25
|
+
setVisible(false);
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
});
|
|
30
|
+
}, [uploadPropsList]);
|
|
29
31
|
|
|
30
32
|
return <Popover
|
|
31
33
|
placement='bottomLeft'
|
|
@@ -90,7 +90,7 @@ export default forwardRef(function (_, ref) {
|
|
|
90
90
|
if (onInput.variant === 'aigc' || !onUpload?.length) {
|
|
91
91
|
return [];
|
|
92
92
|
}
|
|
93
|
-
const
|
|
93
|
+
const uploadPropsList = onUpload.map((item, index) => {
|
|
94
94
|
|
|
95
95
|
let trigger;
|
|
96
96
|
|
|
@@ -108,11 +108,11 @@ export default forwardRef(function (_, ref) {
|
|
|
108
108
|
/>
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
fileList
|
|
114
|
-
key
|
|
115
|
-
onChange
|
|
111
|
+
return {
|
|
112
|
+
...item,
|
|
113
|
+
fileList: attachedFiles[index],
|
|
114
|
+
key: index,
|
|
115
|
+
onChange: (info) => {
|
|
116
116
|
if (item.beforeUpload && info.file.status) {
|
|
117
117
|
handleFileChange(index, info.fileList)
|
|
118
118
|
}
|
|
@@ -120,17 +120,16 @@ export default forwardRef(function (_, ref) {
|
|
|
120
120
|
if (!item.beforeUpload) {
|
|
121
121
|
handleFileChange(index, info.fileList)
|
|
122
122
|
}
|
|
123
|
-
}
|
|
124
|
-
showUploadList
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
trigger
|
|
128
|
-
}
|
|
129
|
-
</Upload>
|
|
123
|
+
},
|
|
124
|
+
showUploadList: false,
|
|
125
|
+
children: trigger,
|
|
126
|
+
}
|
|
130
127
|
});
|
|
131
128
|
|
|
132
|
-
if (
|
|
133
|
-
|
|
129
|
+
if (uploadPropsList.length === 1) return (
|
|
130
|
+
<Upload {...uploadPropsList[0]} />
|
|
131
|
+
);
|
|
132
|
+
return <UploadPopover uploadPropsList={uploadPropsList} />
|
|
134
133
|
|
|
135
134
|
|
|
136
135
|
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
8
|
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
9
|
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); }
|
|
@@ -7,28 +13,28 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
13
|
import { IconButton, Popover } from "@agentscope-ai/design";
|
|
8
14
|
import { PlusOutlined } from "@agentscope-ai/icons-override-antd";
|
|
9
15
|
import { useGetState } from "ahooks";
|
|
10
|
-
import { Flex } from "antd";
|
|
11
|
-
import React from "react";
|
|
12
|
-
import { useEffect } from "react";
|
|
16
|
+
import { Flex, Upload } from "antd";
|
|
17
|
+
import React, { useMemo } from "react";
|
|
13
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
19
|
export default function UploadPopover(_ref) {
|
|
15
|
-
var
|
|
20
|
+
var uploadPropsList = _ref.uploadPropsList;
|
|
16
21
|
var _useGetState = useGetState(false),
|
|
17
22
|
_useGetState2 = _slicedToArray(_useGetState, 3),
|
|
18
23
|
visible = _useGetState2[0],
|
|
19
24
|
setVisible = _useGetState2[1],
|
|
20
25
|
getVisible = _useGetState2[2];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
var nodes = useMemo(function () {
|
|
27
|
+
return uploadPropsList.map(function (item, index) {
|
|
28
|
+
return /*#__PURE__*/_jsx(Upload, _objectSpread(_objectSpread({}, item), {}, {
|
|
29
|
+
customRequest: function customRequest(v) {
|
|
30
|
+
if (item.customRequest) {
|
|
31
|
+
item.customRequest(v);
|
|
32
|
+
}
|
|
33
|
+
setVisible(false);
|
|
34
|
+
}
|
|
35
|
+
}), index);
|
|
36
|
+
});
|
|
37
|
+
}, [uploadPropsList]);
|
|
32
38
|
return /*#__PURE__*/_jsx(Popover, {
|
|
33
39
|
placement: "bottomLeft",
|
|
34
40
|
open: visible,
|
|
@@ -29,7 +29,6 @@ import { AIGC } from "../..";
|
|
|
29
29
|
import UploadPopover from "./UploadPopover";
|
|
30
30
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
31
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
|
-
import { createElement as _createElement } from "react";
|
|
33
32
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
34
33
|
export default /*#__PURE__*/forwardRef(function (_, ref) {
|
|
35
34
|
var _React$useState = React.useState(''),
|
|
@@ -128,7 +127,7 @@ export default /*#__PURE__*/forwardRef(function (_, ref) {
|
|
|
128
127
|
if (onInput.variant === 'aigc' || !(onUpload !== null && onUpload !== void 0 && onUpload.length)) {
|
|
129
128
|
return [];
|
|
130
129
|
}
|
|
131
|
-
var
|
|
130
|
+
var uploadPropsList = onUpload.map(function (item, index) {
|
|
132
131
|
var trigger;
|
|
133
132
|
if (item.trigger) {
|
|
134
133
|
trigger = item.trigger;
|
|
@@ -152,7 +151,7 @@ export default /*#__PURE__*/forwardRef(function (_, ref) {
|
|
|
152
151
|
bordered: false
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
|
-
return
|
|
154
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
156
155
|
fileList: attachedFiles[index],
|
|
157
156
|
key: index,
|
|
158
157
|
onChange: function onChange(info) {
|
|
@@ -163,12 +162,13 @@ export default /*#__PURE__*/forwardRef(function (_, ref) {
|
|
|
163
162
|
handleFileChange(index, info.fileList);
|
|
164
163
|
}
|
|
165
164
|
},
|
|
166
|
-
showUploadList: false
|
|
167
|
-
|
|
165
|
+
showUploadList: false,
|
|
166
|
+
children: trigger
|
|
167
|
+
});
|
|
168
168
|
});
|
|
169
|
-
if (
|
|
169
|
+
if (uploadPropsList.length === 1) return /*#__PURE__*/_jsx(Upload, _objectSpread({}, uploadPropsList[0]));
|
|
170
170
|
return /*#__PURE__*/_jsx(UploadPopover, {
|
|
171
|
-
|
|
171
|
+
uploadPropsList: uploadPropsList
|
|
172
172
|
});
|
|
173
173
|
}, [onInput.variant, onUpload, attachedFiles]);
|
|
174
174
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentscope-ai/chat",
|
|
3
|
-
"version": "1.1.45-beta.
|
|
3
|
+
"version": "1.1.45-beta.1766559488425",
|
|
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": [
|