@fe-free/ai 4.0.1 → 4.0.2
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/CHANGELOG.md +9 -0
- package/package.json +4 -4
- package/src/sender/actions.tsx +8 -3
- package/src/sender/index.tsx +14 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/ai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"ahooks": "^3.7.8",
|
|
14
14
|
"classnames": "^2.5.1",
|
|
15
|
-
"@fe-free/core": "4.0.
|
|
15
|
+
"@fe-free/core": "4.0.2"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"antd": "^5.27.1",
|
|
19
19
|
"dayjs": "~1.11.10",
|
|
20
20
|
"react": "^19.2.0",
|
|
21
|
-
"@fe-free/icons": "4.0.
|
|
22
|
-
"@fe-free/tool": "4.0.
|
|
21
|
+
"@fe-free/icons": "4.0.2",
|
|
22
|
+
"@fe-free/tool": "4.0.2"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"test": "echo \"Error: no test specified\" && exit 1"
|
package/src/sender/actions.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import type { SenderProps } from './types';
|
|
|
10
10
|
|
|
11
11
|
function Actions(
|
|
12
12
|
props: SenderProps & {
|
|
13
|
+
refText: RefObject<HTMLTextAreaElement>;
|
|
13
14
|
refUpload: RefObject<HTMLDivElement>;
|
|
14
15
|
isUploading: boolean;
|
|
15
16
|
fileList: UploadFile[];
|
|
@@ -19,13 +20,13 @@ function Actions(
|
|
|
19
20
|
},
|
|
20
21
|
) {
|
|
21
22
|
const {
|
|
23
|
+
refText,
|
|
22
24
|
loading,
|
|
23
25
|
onSubmit,
|
|
24
26
|
value,
|
|
25
27
|
onChange,
|
|
26
28
|
refUpload,
|
|
27
29
|
isUploading,
|
|
28
|
-
fileList,
|
|
29
30
|
setFileList,
|
|
30
31
|
fileUrls,
|
|
31
32
|
setFileUrls,
|
|
@@ -48,12 +49,16 @@ function Actions(
|
|
|
48
49
|
// 有内容才提交
|
|
49
50
|
if (newValue.text || (newValue.files && newValue.files.length > 0)) {
|
|
50
51
|
await Promise.resolve(onSubmit?.(newValue));
|
|
52
|
+
|
|
53
|
+
// reset
|
|
51
54
|
setFileList([]);
|
|
52
55
|
setFileUrls([]);
|
|
53
|
-
|
|
54
56
|
onChange?.({});
|
|
57
|
+
|
|
58
|
+
// focus
|
|
59
|
+
refText.current?.focus();
|
|
55
60
|
}
|
|
56
|
-
}, [isLoading, value, onSubmit, setFileList, setFileUrls, onChange]);
|
|
61
|
+
}, [isLoading, value, onSubmit, setFileList, setFileUrls, onChange, refText]);
|
|
57
62
|
|
|
58
63
|
return (
|
|
59
64
|
<div className="flex items-center gap-2">
|
package/src/sender/index.tsx
CHANGED
|
@@ -2,17 +2,19 @@ import { useDrop } from 'ahooks';
|
|
|
2
2
|
import { Input } from 'antd';
|
|
3
3
|
import type { UploadFile } from 'antd/lib';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
+
import type { RefObject } from 'react';
|
|
5
6
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
6
7
|
import { Actions } from './actions';
|
|
7
8
|
import { FileUpload, Files } from './files';
|
|
8
9
|
import './style.scss';
|
|
9
10
|
import type { SenderProps, SenderRef } from './types';
|
|
10
11
|
|
|
11
|
-
function Text(props: SenderProps) {
|
|
12
|
-
const { value, onChange, placeholder } = props;
|
|
12
|
+
function Text(props: SenderProps & { refText: RefObject<HTMLTextAreaElement> }) {
|
|
13
|
+
const { value, onChange, placeholder, refText } = props;
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
16
|
<Input.TextArea
|
|
17
|
+
ref={refText}
|
|
16
18
|
value={value?.text}
|
|
17
19
|
onChange={(e) => {
|
|
18
20
|
onChange?.({ ...value, text: e.target.value });
|
|
@@ -37,6 +39,8 @@ function Sender(originProps: SenderProps) {
|
|
|
37
39
|
};
|
|
38
40
|
}, [originProps]);
|
|
39
41
|
|
|
42
|
+
const refText = useRef<HTMLTextAreaElement>(null);
|
|
43
|
+
|
|
40
44
|
const { value, onChange, allowUpload } = props;
|
|
41
45
|
const { filesMaxCount } = allowUpload || {};
|
|
42
46
|
|
|
@@ -96,9 +100,12 @@ function Sender(originProps: SenderProps) {
|
|
|
96
100
|
<div className="fea-sender-wrap">
|
|
97
101
|
<div
|
|
98
102
|
ref={refContainer}
|
|
99
|
-
className={classNames(
|
|
100
|
-
'fea-sender-
|
|
101
|
-
|
|
103
|
+
className={classNames(
|
|
104
|
+
'fea-sender relative flex flex-col rounded-lg border border-01 bg-white p-2',
|
|
105
|
+
{
|
|
106
|
+
'fea-sender-drag-hover': dragHover,
|
|
107
|
+
},
|
|
108
|
+
)}
|
|
102
109
|
>
|
|
103
110
|
<Files
|
|
104
111
|
{...props}
|
|
@@ -108,10 +115,11 @@ function Sender(originProps: SenderProps) {
|
|
|
108
115
|
setFileUrls={setFileUrls}
|
|
109
116
|
/>
|
|
110
117
|
<div className="flex">
|
|
111
|
-
<Text {...props} />
|
|
118
|
+
<Text {...props} refText={refText} />
|
|
112
119
|
</div>
|
|
113
120
|
<Actions
|
|
114
121
|
{...props}
|
|
122
|
+
refText={refText}
|
|
115
123
|
refUpload={refUpload}
|
|
116
124
|
isUploading={isUploading}
|
|
117
125
|
fileList={fileList}
|