@agentscope-ai/chat 1.1.46-beta.1768114534636 → 1.1.46-beta.1768191317759

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.
@@ -78,8 +78,8 @@ export default function Audio(props: IAudio) {
78
78
  <>
79
79
  <audio ref={audioRef} src={props.src} muted={isMuted} />
80
80
  <div className={prefixCls}>
81
- <IconButton shape="circle" size="small" type="text" onClick={togglePlay} icon={isPlaying ? <SparkPauseFill /> : <SparkPlayFill />} />
82
- <IconButton shape="circle" size="small" type="text" onClick={toggleMuted} icon={isMuted ? <SparkMuteLine /> : <SparkVolumeLine />} />
81
+ <IconButton size="small" type="text" onClick={togglePlay} icon={isPlaying ? <SparkPauseFill /> : <SparkPlayFill />} />
82
+ <IconButton size="small" type="text" onClick={toggleMuted} icon={isMuted ? <SparkMuteLine /> : <SparkVolumeLine />} />
83
83
  <div className={`${prefixCls}-time`}>{formatTime(currentTime)}</div>
84
84
  <div
85
85
  className={`${prefixCls}-progress`}
@@ -16,4 +16,9 @@ export default function (props: IImage) {
16
16
  } as Locale}
17
17
  ><Image src={props.src} width={"100%"} height={"100%"} /></ConfigProvider>
18
18
  </div>;
19
+ }
20
+
21
+
22
+ export function ImagesContainer(props: { children: React.ReactNode }) {
23
+ return <Image.PreviewGroup>{props.children}</Image.PreviewGroup>
19
24
  }
@@ -1,8 +1,9 @@
1
1
  import { IVideo } from "./types";
2
2
  import { useProviderContext } from "..";
3
3
  import { useRef, useState, useCallback } from "react";
4
- import { SparkPauseFill, SparkPlayFill } from "@agentscope-ai/icons";
4
+ import { SparkEnlargeLine, SparkPauseFill, SparkPlayFill } from "@agentscope-ai/icons";
5
5
  import cls from "classnames";
6
+ import { IconButton } from "@agentscope-ai/design";
6
7
 
7
8
  export default function Video(props: IVideo) {
8
9
  const prefixCls = useProviderContext().getPrefixCls('assets-preview-video');
@@ -48,6 +49,22 @@ export default function Video(props: IVideo) {
48
49
  }
49
50
  }, []);
50
51
 
52
+ const handleEnlarge = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
53
+ event.stopPropagation();
54
+ const video = videoRef.current;
55
+ if (!video) return;
56
+
57
+ if (video.requestFullscreen) {
58
+ video.requestFullscreen();
59
+ } else if ((video as any).webkitRequestFullscreen) {
60
+ // Safari 兼容
61
+ (video as any).webkitRequestFullscreen();
62
+ } else if ((video as any).msRequestFullscreen) {
63
+ // IE11 兼容
64
+ (video as any).msRequestFullscreen();
65
+ }
66
+ }, []);
67
+
51
68
  return (
52
69
  <div
53
70
  className={prefixCls}
@@ -66,19 +83,23 @@ export default function Video(props: IVideo) {
66
83
  onEnded={handleEnded}
67
84
  />
68
85
  <div className={cls(`${prefixCls}-overlay`, {
69
- [`${prefixCls}-overlay-playing`]: isPlaying,
70
- [`${prefixCls}-overlay-paused`]: !isPlaying,
86
+ [`${prefixCls}-overlay-playing`]: 1,
87
+ // [`${prefixCls}-overlay-paused`]: 1,
71
88
  })} onClick={isPlaying ? handlePlayPause : handlePlayPause}>
72
89
  <div className={`${prefixCls}-play-btn`}>
73
90
  {
74
91
  isPlaying ? <SparkPauseFill /> : <SparkPlayFill />
75
92
  }
76
93
  </div>
77
- <div className={`${prefixCls}-duration`}>
78
- {formatTime(currentTime)}/{formatTime(duration)}
94
+
95
+
96
+ <div className={`${prefixCls}-enlarge`} onClick={handleEnlarge}>
97
+ <IconButton bordered={false} size="small" icon={<SparkEnlargeLine />} />
79
98
  </div>
80
99
  </div>
81
-
100
+ <div className={`${prefixCls}-duration`}>
101
+ {formatTime(duration - currentTime)}
102
+ </div>
82
103
  </div>
83
104
  );
84
105
  }
@@ -0,0 +1,13 @@
1
+
2
+ import { AssetsPreview } from '@agentscope-ai/chat';
3
+ import { Flex, Space } from 'antd';
4
+ import React from 'react';
5
+
6
+ export default function () {
7
+ return <AssetsPreview type="audio" data={[
8
+ { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', },
9
+ { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', },
10
+ { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', },
11
+
12
+ ]} />
13
+ }
@@ -0,0 +1,9 @@
1
+ import { AssetsPreview } from '@agentscope-ai/chat';
2
+ import { Flex, Space } from 'antd';
3
+ import React from 'react';
4
+
5
+ export default function () {
6
+ return <AssetsPreview type="image" data={[
7
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 1, height: 1 },
8
+ ]} />
9
+ }
@@ -0,0 +1,21 @@
1
+ import { AssetsPreview } from '@agentscope-ai/chat';
2
+ import { Flex, Space } from 'antd';
3
+ import React from 'react';
4
+
5
+ export default function () {
6
+ return <AssetsPreview type="image" data={[
7
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
8
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
9
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
10
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
11
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
12
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
13
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
14
+ { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
15
+ ]} />
16
+
17
+
18
+
19
+
20
+
21
+ }
@@ -0,0 +1,10 @@
1
+
2
+ import { AssetsPreview } from '@agentscope-ai/chat';
3
+ import { Flex, Space } from 'antd';
4
+ import React from 'react';
5
+
6
+ export default function () {
7
+ return <AssetsPreview type="video" data={[
8
+ { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
9
+ ]} />
10
+ }
@@ -2,11 +2,35 @@
2
2
  group:
3
3
  title: Output
4
4
  order: 3
5
- title: ???
6
- description: ???
5
+ title: AssetsPreview
6
+ description: Preview assets in conversations
7
7
  ---
8
8
 
9
- <DemoTitle title="???" desc="???"></DemoTitle>
9
+ <DemoTitle title="AssetsPreview" desc="Preview assets in conversations"></DemoTitle>
10
10
 
11
+ <Install>import { AssetsPreview } from '@agentscope-ai/chat'</Install>
11
12
 
12
- <code src="./demo/index.tsx"></code>
13
+ #### AssetsPreview Examples
14
+
15
+ <code src="./demo/left.tsx" height="auto">Multiple images left-aligned</code>
16
+ <code src="./demo/center.tsx" height="auto">Single image centered</code>
17
+ <code src="./demo/video.tsx" height="auto">Video preview</code>
18
+ <code src="./demo/audio.tsx" height="auto">Audio preview</code>
19
+
20
+ #### API
21
+
22
+ ##### IAssetsPreviewProps
23
+
24
+ <ApiParser source="./index.tsx" id="IAssetsPreviewProps"></ApiParser>
25
+
26
+ ##### IImage
27
+
28
+ <ApiParser source="./types.tsx" id="IImage"></ApiParser>
29
+
30
+ ##### IVideo
31
+
32
+ <ApiParser source="./types.tsx" id="IVideo"></ApiParser>
33
+
34
+ ##### IAudio
35
+
36
+ <ApiParser source="./types.tsx" id="IAudio"></ApiParser>
@@ -2,20 +2,44 @@ import { useProviderContext } from '../Provider';
2
2
  import Style from './style';
3
3
  import cls from 'classnames';
4
4
  import { IImage, IVideo, IAudio } from './types';
5
- import Image from './Image';
5
+ import Image, { ImagesContainer } from './Image';
6
6
  import Video from './Video';
7
7
  import Audio from './Audio';
8
8
  import { useCallback, useDeferredValue, useEffect, useRef, useState } from 'react';
9
9
  import { SparkLeftLine, SparkRightLine } from '@agentscope-ai/icons';
10
10
  import { IconButton } from '@agentscope-ai/design';
11
-
12
11
  export interface IAssetsPreviewProps {
12
+ /**
13
+ * @description 类名
14
+ * @descriptionEn Class Name
15
+ * @default ''
16
+ */
13
17
  className?: string;
18
+ /**
19
+ * @description 语义化类名
20
+ * @descriptionEn Semantic Class Name
21
+ * @default {}
22
+ */
14
23
  classNames?: {
15
24
  container?: string;
16
25
  };
26
+ /**
27
+ * @description 高度
28
+ * @descriptionEn Height
29
+ * @default 144
30
+ */
17
31
  height?: number;
32
+ /**
33
+ * @description 类型
34
+ * @descriptionEn Type
35
+ * @default 'image'
36
+ */
18
37
  type: 'image' | 'video' | 'audio';
38
+ /**
39
+ * @description 数据
40
+ * @descriptionEn Data
41
+ * @default []
42
+ */
19
43
  data: (IImage | IVideo | IAudio)[];
20
44
  }
21
45
 
@@ -44,7 +68,7 @@ function AssetsPreview(props: IAssetsPreviewProps) {
44
68
 
45
69
 
46
70
  const toArrow = useCallback((direct: 'left' | 'right') => {
47
- const width = 100;
71
+ const width = 200;
48
72
  ref.current.scrollLeft = ref.current.scrollLeft + width * (direct === 'left' ? -1 : 1)
49
73
  }, [])
50
74
 
@@ -54,16 +78,19 @@ function AssetsPreview(props: IAssetsPreviewProps) {
54
78
  audio: Audio,
55
79
  }[props.type];
56
80
 
81
+
82
+ const list = props.data.map((item, index) => {
83
+ return <Component key={index} {...item as any} />;
84
+ })
85
+
57
86
  return <>
58
87
  <Style />
59
88
  <div className={cls(`${prefixCls}`, props.className)}>
60
- <div className={cls(`${prefixCls}-container`, props.className)} style={props.type !== 'audio' ? { height } : {
89
+ <div className={cls(`${prefixCls}-container`, props.classNames?.container)} style={props.type !== 'audio' ? { height } : {
61
90
  flexDirection: 'column'
62
91
  }} onScroll={onScroll} ref={ref}>
63
92
  {
64
- props.data.map((item, index) => {
65
- return <Component key={index} {...item as any} />;
66
- })
93
+ props.type === 'image' ? <ImagesContainer>{list}</ImagesContainer> : list
67
94
  }
68
95
  </div>
69
96
 
@@ -85,7 +112,6 @@ function AssetsPreview(props: IAssetsPreviewProps) {
85
112
 
86
113
  </> : null
87
114
  }
88
-
89
115
  </div>
90
116
  </>
91
117
  }
@@ -1,11 +1,36 @@
1
1
  ---
2
-
3
2
  group:
4
- title: 输出
3
+ title: Output
5
4
  order: 3
6
- title: ???
7
- description: ???
5
+ title: AssetsPreview
6
+ description: 可以在对话中预览资源
8
7
  ---
9
8
 
9
+ <DemoTitle title="AssetsPreview" desc="可以在对话中预览资源"></DemoTitle>
10
+
11
+ <Install>import { AssetsPreview } from '@agentscope-ai/chat'</Install>
12
+
13
+ #### AssetsPreview 示例
14
+
15
+ <code src="./demo/left.tsx" height="auto">多张左对齐平铺</code>
16
+ <code src="./demo/center.tsx" height="auto">单张居中显示</code>
17
+ <code src="./demo/video.tsx" height="auto">视频生成</code>
18
+ <code src="./demo/audio.tsx" height="auto">音频生成</code>
19
+
20
+ #### API
21
+
22
+ ##### IAssetsPreviewProps
23
+
24
+ <ApiParser source="./index.tsx" id="IAssetsPreviewProps"></ApiParser>
25
+
26
+ ##### IImage
27
+
28
+ <ApiParser source="./types.tsx" id="IImage"></ApiParser>
29
+
30
+ ##### IVideo
31
+
32
+ <ApiParser source="./types.tsx" id="IVideo"></ApiParser>
33
+
34
+ ##### IAudio
10
35
 
11
- <DemoTitle title="???" desc="???"></DemoTitle>
36
+ <ApiParser source="./types.tsx" id="IAudio"></ApiParser>
@@ -65,6 +65,7 @@ export default createGlobalStyle`
65
65
 
66
66
  .anticon-eye {
67
67
  font-size: 20px;
68
+ margin: 0 !important;
68
69
  }
69
70
  }
70
71
 
@@ -77,6 +78,20 @@ export default createGlobalStyle`
77
78
  position: relative;
78
79
  cursor: pointer;
79
80
 
81
+ &-enlarge {
82
+ display: none;
83
+ position: absolute;
84
+ top: 6px;
85
+ right: 6px;
86
+ z-index: 1;
87
+ border-radius: 4px;
88
+ background-color: ${(p) => p.theme.colorBgBase};
89
+
90
+ button {
91
+ display: flex;
92
+ }
93
+ }
94
+
80
95
  video {
81
96
  width: 100%;
82
97
  height: 100%;
@@ -93,7 +108,13 @@ export default createGlobalStyle`
93
108
  flex-direction: column;
94
109
  align-items: center;
95
110
  justify-content: center;
96
- border-radius: 4px;
111
+ border-radius: 8px;
112
+
113
+ &:hover {
114
+ .${(p) => p.theme.prefixCls}-assets-preview-video-enlarge {
115
+ display: block;
116
+ }
117
+ }
97
118
 
98
119
  &-playing {
99
120
  opacity: 0;
@@ -126,13 +147,27 @@ export default createGlobalStyle`
126
147
 
127
148
  &-duration {
128
149
  position: absolute;
150
+ display: flex;
151
+ align-items: center;
152
+ justify-content: center;
129
153
  bottom: 8px;
130
- left: 50%;
131
- transform: translateX(-50%);
154
+ left: 0px;
155
+ height: 28px;
156
+ bottom: 0;
157
+ right: 0;
132
158
  font-size: 14px;
133
159
  font-weight: 500;
134
160
  color: #fff;
135
161
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
162
+ background: linear-gradient(180deg, rgba(111, 111, 111, 0.27) 0%, rgba(38, 36, 76, 0.83) 100%);
163
+ }
164
+
165
+ &-overlay {
166
+ &:hover {
167
+ ~ .${(p) => p.theme.prefixCls}-assets-preview-video-duration {
168
+ background: transparent;
169
+ }
170
+ }
136
171
  }
137
172
 
138
173
  &-playing-overlay {
@@ -142,7 +177,6 @@ export default createGlobalStyle`
142
177
  right: 0;
143
178
  bottom: 0;
144
179
  }
145
-
146
180
  }
147
181
 
148
182
  &-audio {
@@ -1,14 +1,54 @@
1
1
  export interface IImage {
2
+ /**
3
+ * @description 图片地址
4
+ * @descriptionEn Image URL
5
+ * @default ''
6
+ */
2
7
  src: string;
8
+ /**
9
+ * @description 图片宽度(比例值)
10
+ * @descriptionEn Image Width (Ratio Value)
11
+ * @default 0
12
+ */
3
13
  width: number;
14
+ /**
15
+ * @description 图片高度(比例值)
16
+ * @descriptionEn Image Height (Ratio Value)
17
+ * @default 0
18
+ */
4
19
  height: number;
5
20
  }
6
21
  export interface IVideo {
22
+ /**
23
+ * @description 封面图片地址
24
+ * @descriptionEn Poster Image URL
25
+ * @default ''
26
+ */
7
27
  poster?: string;
28
+ /**
29
+ * @description 视频地址
30
+ * @descriptionEn Video URL
31
+ * @default ''
32
+ */
8
33
  src: string;
34
+ /**
35
+ * @description 视频宽度(比例值)
36
+ * @descriptionEn Video Width (Ratio Value)
37
+ * @default 0
38
+ */
9
39
  width: number;
40
+ /**
41
+ * @description 视频高度(比例值)
42
+ * @descriptionEn Video Height (Ratio Value)
43
+ * @default 0
44
+ */
10
45
  height: number;
11
46
  }
12
47
  export interface IAudio {
48
+ /**
49
+ * @description 音频地址
50
+ * @descriptionEn Audio URL
51
+ * @default ''
52
+ */
13
53
  src: string;
14
54
  }
@@ -92,13 +92,11 @@ export default function Audio(props) {
92
92
  }), /*#__PURE__*/_jsxs("div", {
93
93
  className: prefixCls,
94
94
  children: [/*#__PURE__*/_jsx(IconButton, {
95
- shape: "circle",
96
95
  size: "small",
97
96
  type: "text",
98
97
  onClick: togglePlay,
99
98
  icon: isPlaying ? /*#__PURE__*/_jsx(SparkPauseFill, {}) : /*#__PURE__*/_jsx(SparkPlayFill, {})
100
99
  }), /*#__PURE__*/_jsx(IconButton, {
101
- shape: "circle",
102
100
  size: "small",
103
101
  type: "text",
104
102
  onClick: toggleMuted,
@@ -1,2 +1,6 @@
1
+ /// <reference types="react" />
1
2
  import { IImage } from "./types";
2
3
  export default function (props: IImage): import("react/jsx-runtime").JSX.Element;
4
+ export declare function ImagesContainer(props: {
5
+ children: React.ReactNode;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -21,4 +21,9 @@ export default function (props) {
21
21
  })
22
22
  })
23
23
  });
24
+ }
25
+ export function ImagesContainer(props) {
26
+ return /*#__PURE__*/_jsx(Image.PreviewGroup, {
27
+ children: props.children
28
+ });
24
29
  }
@@ -15,8 +15,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
15
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
16
  import { useProviderContext } from "..";
17
17
  import { useRef, useState, useCallback } from "react";
18
- import { SparkPauseFill, SparkPlayFill } from "@agentscope-ai/icons";
18
+ import { SparkEnlargeLine, SparkPauseFill, SparkPlayFill } from "@agentscope-ai/icons";
19
19
  import cls from "classnames";
20
+ import { IconButton } from "@agentscope-ai/design";
20
21
  import { jsx as _jsx } from "react/jsx-runtime";
21
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
22
23
  export default function Video(props) {
@@ -69,6 +70,20 @@ export default function Video(props) {
69
70
  setCurrentTime(videoRef.current.currentTime);
70
71
  }
71
72
  }, []);
73
+ var handleEnlarge = useCallback(function (event) {
74
+ event.stopPropagation();
75
+ var video = videoRef.current;
76
+ if (!video) return;
77
+ if (video.requestFullscreen) {
78
+ video.requestFullscreen();
79
+ } else if (video.webkitRequestFullscreen) {
80
+ // Safari 兼容
81
+ video.webkitRequestFullscreen();
82
+ } else if (video.msRequestFullscreen) {
83
+ // IE11 兼容
84
+ video.msRequestFullscreen();
85
+ }
86
+ }, []);
72
87
  return /*#__PURE__*/_jsxs("div", {
73
88
  className: prefixCls,
74
89
  style: {
@@ -83,15 +98,23 @@ export default function Video(props) {
83
98
  onTimeUpdate: handleTimeUpdate,
84
99
  onEnded: handleEnded
85
100
  })), /*#__PURE__*/_jsxs("div", {
86
- className: cls("".concat(prefixCls, "-overlay"), _defineProperty(_defineProperty({}, "".concat(prefixCls, "-overlay-playing"), isPlaying), "".concat(prefixCls, "-overlay-paused"), !isPlaying)),
101
+ className: cls("".concat(prefixCls, "-overlay"), _defineProperty({}, "".concat(prefixCls, "-overlay-playing"), 1)),
87
102
  onClick: isPlaying ? handlePlayPause : handlePlayPause,
88
103
  children: [/*#__PURE__*/_jsx("div", {
89
104
  className: "".concat(prefixCls, "-play-btn"),
90
105
  children: isPlaying ? /*#__PURE__*/_jsx(SparkPauseFill, {}) : /*#__PURE__*/_jsx(SparkPlayFill, {})
91
- }), /*#__PURE__*/_jsxs("div", {
92
- className: "".concat(prefixCls, "-duration"),
93
- children: [formatTime(currentTime), "/", formatTime(duration)]
106
+ }), /*#__PURE__*/_jsx("div", {
107
+ className: "".concat(prefixCls, "-enlarge"),
108
+ onClick: handleEnlarge,
109
+ children: /*#__PURE__*/_jsx(IconButton, {
110
+ bordered: false,
111
+ size: "small",
112
+ icon: /*#__PURE__*/_jsx(SparkEnlargeLine, {})
113
+ })
94
114
  })]
115
+ }), /*#__PURE__*/_jsx("div", {
116
+ className: "".concat(prefixCls, "-duration"),
117
+ children: formatTime(duration - currentTime)
95
118
  })]
96
119
  });
97
120
  }
@@ -1,11 +1,36 @@
1
1
  import { IImage, IVideo, IAudio } from './types';
2
2
  export interface IAssetsPreviewProps {
3
+ /**
4
+ * @description 类名
5
+ * @descriptionEn Class Name
6
+ * @default ''
7
+ */
3
8
  className?: string;
9
+ /**
10
+ * @description 语义化类名
11
+ * @descriptionEn Semantic Class Name
12
+ * @default {}
13
+ */
4
14
  classNames?: {
5
15
  container?: string;
6
16
  };
17
+ /**
18
+ * @description 高度
19
+ * @descriptionEn Height
20
+ * @default 144
21
+ */
7
22
  height?: number;
23
+ /**
24
+ * @description 类型
25
+ * @descriptionEn Type
26
+ * @default 'image'
27
+ */
8
28
  type: 'image' | 'video' | 'audio';
29
+ /**
30
+ * @description 数据
31
+ * @descriptionEn Data
32
+ * @default []
33
+ */
9
34
  data: (IImage | IVideo | IAudio)[];
10
35
  }
11
36
  declare function AssetsPreview(props: IAssetsPreviewProps): import("react/jsx-runtime").JSX.Element;
@@ -13,7 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useProviderContext } from "../Provider";
14
14
  import Style from "./style";
15
15
  import cls from 'classnames';
16
- import Image from "./Image";
16
+ import Image, { ImagesContainer } from "./Image";
17
17
  import Video from "./Video";
18
18
  import Audio from "./Audio";
19
19
  import { useCallback, useDeferredValue, useEffect, useRef, useState } from 'react';
@@ -23,6 +23,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
23
23
  import { Fragment as _Fragment } from "react/jsx-runtime";
24
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
25
25
  function AssetsPreview(props) {
26
+ var _props$classNames;
26
27
  var prefixCls = useProviderContext().getPrefixCls('assets-preview');
27
28
  var ref = useRef(null);
28
29
  var _props$height = props.height,
@@ -49,7 +50,7 @@ function AssetsPreview(props) {
49
50
  }
50
51
  }, []);
51
52
  var toArrow = useCallback(function (direct) {
52
- var width = 100;
53
+ var width = 200;
53
54
  ref.current.scrollLeft = ref.current.scrollLeft + width * (direct === 'left' ? -1 : 1);
54
55
  }, []);
55
56
  var Component = {
@@ -57,11 +58,14 @@ function AssetsPreview(props) {
57
58
  video: Video,
58
59
  audio: Audio
59
60
  }[props.type];
61
+ var list = props.data.map(function (item, index) {
62
+ return /*#__PURE__*/_jsx(Component, _objectSpread({}, item), index);
63
+ });
60
64
  return /*#__PURE__*/_jsxs(_Fragment, {
61
65
  children: [/*#__PURE__*/_jsx(Style, {}), /*#__PURE__*/_jsxs("div", {
62
66
  className: cls("".concat(prefixCls), props.className),
63
67
  children: [/*#__PURE__*/_jsx("div", {
64
- className: cls("".concat(prefixCls, "-container"), props.className),
68
+ className: cls("".concat(prefixCls, "-container"), (_props$classNames = props.classNames) === null || _props$classNames === void 0 ? void 0 : _props$classNames.container),
65
69
  style: props.type !== 'audio' ? {
66
70
  height: height
67
71
  } : {
@@ -69,9 +73,9 @@ function AssetsPreview(props) {
69
73
  },
70
74
  onScroll: onScroll,
71
75
  ref: ref,
72
- children: props.data.map(function (item, index) {
73
- return /*#__PURE__*/_jsx(Component, _objectSpread({}, item), index);
74
- })
76
+ children: props.type === 'image' ? /*#__PURE__*/_jsx(ImagesContainer, {
77
+ children: list
78
+ }) : list
75
79
  }), arrowTop && props.type !== 'audio' ? /*#__PURE__*/_jsxs(_Fragment, {
76
80
  children: [deferScrollLeft > 50 && /*#__PURE__*/_jsxs(_Fragment, {
77
81
  children: [/*#__PURE__*/_jsx("div", {
@@ -1,7 +1,7 @@
1
1
  var _templateObject;
2
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
3
  import { createGlobalStyle } from 'antd-style';
4
- export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-assets-preview {\n position: relative;\n\n &-left-edge,\n &-right-edge {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 128px;\n pointer-events: none;\n }\n\n &-left-edge {\n left: 0;\n background: linear-gradient(to right, ", ", rgba(0, 0, 0, 0));\n }\n\n &-right-edge {\n right: 0;\n background: linear-gradient(to left, ", ", rgba(0, 0, 0, 0));\n }\n\n &-arrow {\n position: absolute;\n bottom: 0;\n }\n\n &-left-arrow {\n left: 10px;\n }\n\n &-right-arrow {\n right: 10px;\n }\n\n &-container {\n display: flex;\n padding: 8px;\n gap: 8px;\n overflow-x: auto;\n justify-content: safe center;\n background-color: ", ";\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE/Edge */\n &::-webkit-scrollbar {\n display: none; /* Chrome/Safari/Opera */\n }\n }\n\n\n &-image {\n height: 100%;\n flex-basis: auto;\n flex-shrink: 0;\n border-radius: 8px;\n overflow: hidden;\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n\n .anticon-eye {\n font-size: 20px;\n }\n }\n\n &-video {\n height: 100%;\n flex-basis: auto;\n flex-shrink: 0;\n border-radius: 8px;\n overflow: hidden;\n position: relative;\n cursor: pointer;\n\n video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n &-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n\n &-playing {\n opacity: 0;\n &:hover {\n opacity: 1;\n background: linear-gradient(180deg, rgba(111, 111, 111, 0.27) 0%, rgba(38, 36, 76, 0.83) 100%);\n }\n }\n\n &-paused {\n background: linear-gradient(180deg, rgba(111, 111, 111, 0.27) 0%, rgba(38, 36, 76, 0.83) 100%);\n }\n }\n\n &-play-btn {\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n transition: transform 0.2s ease;\n font-size: 40px;\n \n\n &:hover {\n transform: scale(1.1);\n }\n }\n\n &-duration {\n position: absolute;\n bottom: 8px;\n left: 50%;\n transform: translateX(-50%);\n font-size: 14px;\n font-weight: 500;\n color: #fff;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);\n }\n\n &-playing-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n \n }\n \n &-audio {\n display: flex;\n align-items: center;\n gap: 8px;\n background-color: ", ";\n border-radius: 8px;\n border: 1px solid ", ";\n height: 40px;\n padding: 0 8px;\n\n &-time {\n font-size: 12px;\n color: ", ";\n line-height: 1;\n }\n\n &-progress {\n flex: 1;\n height: 8px;\n background-color: ", ";\n border-radius: 4px;\n cursor: pointer;\n position: relative;\n overflow: hidden;\n\n &-bar {\n height: 100%;\n background-color: ", ";\n border-radius: 4px;\n transition: width 0.1s linear;\n }\n }\n }\n}\n"])), function (p) {
4
+ export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-assets-preview {\n position: relative;\n\n &-left-edge,\n &-right-edge {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 128px;\n pointer-events: none;\n }\n\n &-left-edge {\n left: 0;\n background: linear-gradient(to right, ", ", rgba(0, 0, 0, 0));\n }\n\n &-right-edge {\n right: 0;\n background: linear-gradient(to left, ", ", rgba(0, 0, 0, 0));\n }\n\n &-arrow {\n position: absolute;\n bottom: 0;\n }\n\n &-left-arrow {\n left: 10px;\n }\n\n &-right-arrow {\n right: 10px;\n }\n\n &-container {\n display: flex;\n padding: 8px;\n gap: 8px;\n overflow-x: auto;\n justify-content: safe center;\n background-color: ", ";\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE/Edge */\n &::-webkit-scrollbar {\n display: none; /* Chrome/Safari/Opera */\n }\n }\n\n\n &-image {\n height: 100%;\n flex-basis: auto;\n flex-shrink: 0;\n border-radius: 8px;\n overflow: hidden;\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n\n .anticon-eye {\n font-size: 20px;\n margin: 0 !important;\n }\n }\n\n &-video {\n height: 100%;\n flex-basis: auto;\n flex-shrink: 0;\n border-radius: 8px;\n overflow: hidden;\n position: relative;\n cursor: pointer;\n\n &-enlarge {\n display: none;\n position: absolute;\n top: 6px;\n right: 6px;\n z-index: 1;\n border-radius: 4px;\n background-color: ", ";\n\n button {\n display: flex;\n }\n }\n\n video {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n &-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n border-radius: 8px;\n\n &:hover {\n .", "-assets-preview-video-enlarge {\n display: block;\n }\n }\n\n &-playing {\n opacity: 0;\n &:hover {\n opacity: 1;\n background: linear-gradient(180deg, rgba(111, 111, 111, 0.27) 0%, rgba(38, 36, 76, 0.83) 100%);\n }\n }\n\n &-paused {\n background: linear-gradient(180deg, rgba(111, 111, 111, 0.27) 0%, rgba(38, 36, 76, 0.83) 100%);\n }\n }\n\n &-play-btn {\n width: 40px;\n height: 40px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n transition: transform 0.2s ease;\n font-size: 40px;\n \n\n &:hover {\n transform: scale(1.1);\n }\n }\n\n &-duration {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n bottom: 8px;\n left: 0px;\n height: 28px;\n bottom: 0;\n right: 0;\n font-size: 14px;\n font-weight: 500;\n color: #fff;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);\n background: linear-gradient(180deg, rgba(111, 111, 111, 0.27) 0%, rgba(38, 36, 76, 0.83) 100%);\n }\n\n &-overlay {\n &:hover {\n ~ .", "-assets-preview-video-duration {\n background: transparent;\n }\n }\n }\n\n &-playing-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n }\n \n &-audio {\n display: flex;\n align-items: center;\n gap: 8px;\n background-color: ", ";\n border-radius: 8px;\n border: 1px solid ", ";\n height: 40px;\n padding: 0 8px;\n\n &-time {\n font-size: 12px;\n color: ", ";\n line-height: 1;\n }\n\n &-progress {\n flex: 1;\n height: 8px;\n background-color: ", ";\n border-radius: 4px;\n cursor: pointer;\n position: relative;\n overflow: hidden;\n\n &-bar {\n height: 100%;\n background-color: ", ";\n border-radius: 4px;\n transition: width 0.1s linear;\n }\n }\n }\n}\n"])), function (p) {
5
5
  return p.theme.prefixCls;
6
6
  }, function (p) {
7
7
  return p.theme.colorBgLayout;
@@ -11,6 +11,12 @@ export default createGlobalStyle(_templateObject || (_templateObject = _taggedTe
11
11
  return p.theme.colorFillTertiary;
12
12
  }, function (p) {
13
13
  return p.theme.colorBgBase;
14
+ }, function (p) {
15
+ return p.theme.prefixCls;
16
+ }, function (p) {
17
+ return p.theme.prefixCls;
18
+ }, function (p) {
19
+ return p.theme.colorBgBase;
14
20
  }, function (p) {
15
21
  return p.theme.colorBorderSecondary;
16
22
  }, function (p) {
@@ -1,14 +1,54 @@
1
1
  export interface IImage {
2
+ /**
3
+ * @description 图片地址
4
+ * @descriptionEn Image URL
5
+ * @default ''
6
+ */
2
7
  src: string;
8
+ /**
9
+ * @description 图片宽度(比例值)
10
+ * @descriptionEn Image Width (Ratio Value)
11
+ * @default 0
12
+ */
3
13
  width: number;
14
+ /**
15
+ * @description 图片高度(比例值)
16
+ * @descriptionEn Image Height (Ratio Value)
17
+ * @default 0
18
+ */
4
19
  height: number;
5
20
  }
6
21
  export interface IVideo {
22
+ /**
23
+ * @description 封面图片地址
24
+ * @descriptionEn Poster Image URL
25
+ * @default ''
26
+ */
7
27
  poster?: string;
28
+ /**
29
+ * @description 视频地址
30
+ * @descriptionEn Video URL
31
+ * @default ''
32
+ */
8
33
  src: string;
34
+ /**
35
+ * @description 视频宽度(比例值)
36
+ * @descriptionEn Video Width (Ratio Value)
37
+ * @default 0
38
+ */
9
39
  width: number;
40
+ /**
41
+ * @description 视频高度(比例值)
42
+ * @descriptionEn Video Height (Ratio Value)
43
+ * @default 0
44
+ */
10
45
  height: number;
11
46
  }
12
47
  export interface IAudio {
48
+ /**
49
+ * @description 音频地址
50
+ * @descriptionEn Audio URL
51
+ * @default ''
52
+ */
13
53
  src: string;
14
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/chat",
3
- "version": "1.1.46-beta.1768114534636",
3
+ "version": "1.1.46-beta.1768191317759",
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": [
@@ -1,63 +0,0 @@
1
- import { AssetsPreview } from '@agentscope-ai/chat';
2
- import { Flex, Space } from 'antd';
3
- import React from 'react';
4
-
5
- export default function () {
6
- return <Flex vertical gap={32}>
7
- <AssetsPreview type="audio" data={[
8
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', },
9
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', },
10
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', },
11
-
12
- ]} />
13
-
14
-
15
- <AssetsPreview type="image" data={[
16
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
17
- ]} />
18
-
19
-
20
- <AssetsPreview type="image" data={[
21
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
22
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
23
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
24
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
25
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
26
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
27
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
28
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 16, height: 9 },
29
- ]} />
30
-
31
- <AssetsPreview type="image" data={[
32
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 1, height: 1 },
33
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 1, height: 1 },
34
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 1, height: 1 },
35
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 1, height: 1 },
36
- ]} />
37
-
38
- <AssetsPreview type="image" data={[
39
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 9, height: 16 },
40
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 9, height: 16 },
41
- { src: 'https://img.alicdn.com/imgextra/i3/O1CN01dKprif1ar0awCMDwK_!!6000000003382-0-tps-2640-1100.jpg', width: 9, height: 16 },
42
- ]} />
43
-
44
- <AssetsPreview type="video" data={[
45
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
46
- ]} />
47
-
48
- <AssetsPreview type="video" data={[
49
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
50
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
51
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
52
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
53
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
54
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', width: 16, height: 9 },
55
- ]} />
56
-
57
- <AssetsPreview type="audio" data={[
58
- { src: 'https://cloud.video.taobao.com/vod/m9amjbqLTGUvaGo3o61u-Ch2hycUCa3RA3pAw1-Zv_0.mp4', },
59
- ]} />
60
-
61
-
62
- </Flex>
63
- }