@cozeloop/components 0.0.3 → 0.0.5
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/es/index.js +1 -1
- package/dist/lib/code-editor/index.js +3 -1
- package/dist/lib/code-editor/index.js.map +1 -1
- package/dist/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/.eslintcache +0 -1
- package/.rush/temp/shrinkwrap-deps.json +0 -770
- package/OWNERS +0 -5
- package/config/rush-project.json +0 -8
- package/eslint.config.js +0 -7
- package/rslib.config.js +0 -7
- package/script/publish.js +0 -146
- package/src/base-search-select/base-search-form-select.tsx +0 -10
- package/src/base-search-select/base-search-select.tsx +0 -200
- package/src/base-search-select/index.module.less +0 -16
- package/src/base-search-select/index.tsx +0 -3
- package/src/base-search-select/types.ts +0 -16
- package/src/base-search-select/utils.ts +0 -78
- package/src/basic-card/index.tsx +0 -23
- package/src/card-pane/index.module.less +0 -14
- package/src/card-pane/index.tsx +0 -25
- package/src/chip-select/index.module.less +0 -17
- package/src/chip-select/index.tsx +0 -7
- package/src/code-editor/index.tsx +0 -9
- package/src/code-usage/code-item.module.less +0 -32
- package/src/code-usage/index.tsx +0 -91
- package/src/codemirror-editor/code-editor.tsx +0 -139
- package/src/codemirror-editor/index.ts +0 -4
- package/src/codemirror-editor/json-editor.tsx +0 -183
- package/src/codemirror-editor/raw-text-editor.tsx +0 -68
- package/src/codemirror-editor/text-editor.tsx +0 -58
- package/src/codemirror-editor/themes/coze-dark.ts +0 -116
- package/src/codemirror-editor/themes/coze-light.ts +0 -122
- package/src/collapse-card/index.module.less +0 -27
- package/src/collapse-card/index.tsx +0 -93
- package/src/collapsible-card/index.module.less +0 -63
- package/src/collapsible-card/index.tsx +0 -57
- package/src/column-manage-storage/index.tsx +0 -64
- package/src/columns-select/index.tsx +0 -244
- package/src/edit-icon-button/index.tsx +0 -36
- package/src/footer-actions/index.tsx +0 -33
- package/src/hooks/use-infinite-scroll.ts +0 -183
- package/src/hooks/use-mouse-down-offset.ts +0 -50
- package/src/hooks/use-unsave-leave-warning.ts +0 -49
- package/src/id-render/icon-button-container.tsx +0 -37
- package/src/id-render/index.tsx +0 -64
- package/src/index-controller/record-navigation.tsx +0 -57
- package/src/index-controller/use-item-index-controller.ts +0 -197
- package/src/index.ts +0 -208
- package/src/infinite-scroll-table/index.tsx +0 -99
- package/src/info-tooltip/index.tsx +0 -41
- package/src/input-components/radio-button.tsx +0 -63
- package/src/input-slider/index.module.less +0 -30
- package/src/input-slider/index.tsx +0 -161
- package/src/input-with-count/index.tsx +0 -31
- package/src/jump-button/jump-icon-button.tsx +0 -12
- package/src/large-txt-render/index.tsx +0 -46
- package/src/layout/content.tsx +0 -28
- package/src/layout/header.tsx +0 -15
- package/src/layout/index.module.less +0 -28
- package/src/layout/index.tsx +0 -9
- package/src/layout/tabs.tsx +0 -11
- package/src/lazy-load-component/index.tsx +0 -55
- package/src/logic-editor/index.ts +0 -3
- package/src/logic-editor/logic-editor.module.less +0 -13
- package/src/logic-editor/logic-editor.tsx +0 -200
- package/src/logic-editor/logic-left-render.tsx +0 -100
- package/src/logic-editor/logic-operator-render.tsx +0 -54
- package/src/logic-editor/logic-right-render.tsx +0 -51
- package/src/logic-editor/logic-types.tsx +0 -238
- package/src/logic-editor/utils.ts +0 -22
- package/src/logic-expr/assets/select.svg +0 -1
- package/src/logic-expr/consts.ts +0 -6
- package/src/logic-expr/expr-group-render.tsx +0 -238
- package/src/logic-expr/expr-render.tsx +0 -226
- package/src/logic-expr/index.module.less +0 -252
- package/src/logic-expr/index.ts +0 -13
- package/src/logic-expr/logic-expr.tsx +0 -261
- package/src/logic-expr/logic-not.tsx +0 -46
- package/src/logic-expr/logic-toggle.tsx +0 -96
- package/src/logic-expr/types.ts +0 -95
- package/src/loop-radio-group/index.tsx +0 -16
- package/src/multi-part-editor/components/image-item-renderer.tsx +0 -134
- package/src/multi-part-editor/components/index.module.less +0 -21
- package/src/multi-part-editor/components/multipart-item-renderer.tsx +0 -74
- package/src/multi-part-editor/components/url-input-modal.tsx +0 -317
- package/src/multi-part-editor/components/video-item-renderer.tsx +0 -145
- package/src/multi-part-editor/index.module.less +0 -8
- package/src/multi-part-editor/index.tsx +0 -571
- package/src/multi-part-editor/multi-part-render.tsx +0 -87
- package/src/multi-part-editor/type.tsx +0 -103
- package/src/multi-part-editor/upload-button.tsx +0 -256
- package/src/multi-part-editor/utils.ts +0 -64
- package/src/open-detail-button/index.tsx +0 -30
- package/src/page-content/index.tsx +0 -99
- package/src/primary-page/index.tsx +0 -1
- package/src/primary-page/primary-header.tsx +0 -64
- package/src/primary-title/index.module.less +0 -14
- package/src/primary-title/index.tsx +0 -18
- package/src/provider/index.tsx +0 -89
- package/src/resizable-side-sheet/index.tsx +0 -69
- package/src/resize-sidesheet/index.module.less +0 -14
- package/src/resize-sidesheet/index.tsx +0 -68
- package/src/resize-sidesheet/use-drag.ts +0 -43
- package/src/schema-editor/index.tsx +0 -52
- package/src/search-form/index.tsx +0 -134
- package/src/semi-schema-form/components/tmpls/array-field-item.tsx +0 -97
- package/src/semi-schema-form/components/tmpls/array-field.tsx +0 -127
- package/src/semi-schema-form/components/tmpls/base-input.tsx +0 -126
- package/src/semi-schema-form/components/tmpls/description-field.tsx +0 -23
- package/src/semi-schema-form/components/tmpls/error-list.tsx +0 -44
- package/src/semi-schema-form/components/tmpls/field-error.tsx +0 -33
- package/src/semi-schema-form/components/tmpls/field.tsx +0 -54
- package/src/semi-schema-form/components/tmpls/icon-button.tsx +0 -112
- package/src/semi-schema-form/components/tmpls/index.ts +0 -39
- package/src/semi-schema-form/components/tmpls/object-field.tsx +0 -173
- package/src/semi-schema-form/components/tmpls/submit.tsx +0 -31
- package/src/semi-schema-form/components/tmpls/title-field.tsx +0 -30
- package/src/semi-schema-form/components/widgets/checkbox.tsx +0 -67
- package/src/semi-schema-form/components/widgets/checkboxs.tsx +0 -100
- package/src/semi-schema-form/components/widgets/index.ts +0 -17
- package/src/semi-schema-form/components/widgets/radio.tsx +0 -105
- package/src/semi-schema-form/components/widgets/range.tsx +0 -73
- package/src/semi-schema-form/components/widgets/select.tsx +0 -108
- package/src/semi-schema-form/components/widgets/textarea.tsx +0 -63
- package/src/semi-schema-form/index.tsx +0 -14
- package/src/sentinel-form/enum.ts +0 -16
- package/src/sentinel-form/index.tsx +0 -382
- package/src/step-nav/index.module.less +0 -45
- package/src/step-nav/index.tsx +0 -53
- package/src/table/index.module.less +0 -144
- package/src/table/index.tsx +0 -18
- package/src/table/sort-icon.tsx +0 -73
- package/src/table/table-with-pagination.tsx +0 -150
- package/src/table/table-without-pagniation.tsx +0 -66
- package/src/table-batch-operate/table-batch-operation.tsx +0 -47
- package/src/table-batch-operate/use-batch-operate.ts +0 -111
- package/src/table-col-actions/index.module.less +0 -8
- package/src/table-col-actions/index.tsx +0 -149
- package/src/table-cols-config/index.module.less +0 -34
- package/src/table-cols-config/index.tsx +0 -171
- package/src/table-cols-config/type.ts +0 -12
- package/src/table-cols-config/use-hidden-col-keys.ts +0 -53
- package/src/table-cols-config/util.ts +0 -56
- package/src/table-empty/index.tsx +0 -23
- package/src/table-header/index.module.less +0 -7
- package/src/table-header/index.tsx +0 -70
- package/src/tabs/index.module.less +0 -48
- package/src/tabs/index.tsx +0 -9
- package/src/text-area-pro/index.module.less +0 -5
- package/src/text-area-pro/index.tsx +0 -49
- package/src/text-with-copy/index.tsx +0 -95
- package/src/title-with-sub/index.tsx +0 -27
- package/src/tooltip-when-disabled/index.tsx +0 -23
- package/src/tooltip-with-disabled/index.tsx +0 -17
- package/src/types.d.ts +0 -24
- package/src/upload/index.ts +0 -39
- package/src/user-profile/index.tsx +0 -49
- package/src/utils/basic.ts +0 -29
- package/src/version-list/index.module.less +0 -16
- package/src/version-list/version-descriptions.tsx +0 -80
- package/src/version-list/version-item.tsx +0 -30
- package/src/version-list/version-list.tsx +0 -59
- package/src/version-list/version-switch-panel.tsx +0 -31
- package/tailwind.config.ts +0 -6
- package/tsconfig.build.json +0 -44
- package/tsconfig.json +0 -17
- package/tsconfig.misc.json +0 -28
- package/vitest.config.mts +0 -7
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { ContentType } from '@cozeloop/api-schema/evaluation';
|
|
4
|
-
import { IconCozTrashCan } from '@coze-arch/coze-design/icons';
|
|
5
|
-
import { Button, TextArea } from '@coze-arch/coze-design';
|
|
6
|
-
|
|
7
|
-
import { type MultipartItem } from '../type';
|
|
8
|
-
import { VideoItemRenderer } from './video-item-renderer';
|
|
9
|
-
import { ImageItemRenderer } from './image-item-renderer';
|
|
10
|
-
|
|
11
|
-
interface MultipartItemRendererProps {
|
|
12
|
-
item: MultipartItem;
|
|
13
|
-
readonly?: boolean;
|
|
14
|
-
onChange: (item: MultipartItem) => void;
|
|
15
|
-
onRemove: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const MultipartItemRenderer: React.FC<MultipartItemRendererProps> = ({
|
|
19
|
-
item,
|
|
20
|
-
readonly,
|
|
21
|
-
onChange,
|
|
22
|
-
onRemove,
|
|
23
|
-
}) => {
|
|
24
|
-
const handleTextChange = (text: string) => {
|
|
25
|
-
onChange({
|
|
26
|
-
...item,
|
|
27
|
-
text,
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
switch (item.content_type) {
|
|
32
|
-
case ContentType.Text:
|
|
33
|
-
return (
|
|
34
|
-
<div className="flex items-center gap-1">
|
|
35
|
-
<TextArea
|
|
36
|
-
value={item.text}
|
|
37
|
-
onChange={handleTextChange}
|
|
38
|
-
autosize={{ minRows: 1, maxRows: 3 }}
|
|
39
|
-
disabled={readonly}
|
|
40
|
-
placeholder="请输入文本信息"
|
|
41
|
-
/>
|
|
42
|
-
{readonly ? null : (
|
|
43
|
-
<Button
|
|
44
|
-
icon={<IconCozTrashCan />}
|
|
45
|
-
color="secondary"
|
|
46
|
-
size="small"
|
|
47
|
-
onClick={onRemove}
|
|
48
|
-
/>
|
|
49
|
-
)}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
case ContentType.Image:
|
|
54
|
-
return (
|
|
55
|
-
<ImageItemRenderer
|
|
56
|
-
item={item}
|
|
57
|
-
onRemove={onRemove}
|
|
58
|
-
onChange={onChange}
|
|
59
|
-
readonly={readonly}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
case 'Video':
|
|
63
|
-
return (
|
|
64
|
-
<VideoItemRenderer
|
|
65
|
-
item={item}
|
|
66
|
-
onRemove={onRemove}
|
|
67
|
-
onChange={onChange}
|
|
68
|
-
readonly={readonly}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
default:
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @coze-arch/max-line-per-function */
|
|
2
|
-
import React, { useState, useRef } from 'react';
|
|
3
|
-
|
|
4
|
-
import { type Image as ImageProps } from '@cozeloop/api-schema/evaluation';
|
|
5
|
-
import {
|
|
6
|
-
IconCozTrashCan,
|
|
7
|
-
IconCozPlus,
|
|
8
|
-
IconCozCheckMarkCircleFill,
|
|
9
|
-
IconCozCrossCircleFill,
|
|
10
|
-
} from '@coze-arch/coze-design/icons';
|
|
11
|
-
import {
|
|
12
|
-
Modal,
|
|
13
|
-
Button,
|
|
14
|
-
Image,
|
|
15
|
-
Spin,
|
|
16
|
-
Form,
|
|
17
|
-
type FormApi,
|
|
18
|
-
Typography,
|
|
19
|
-
Tag,
|
|
20
|
-
type ColumnProps,
|
|
21
|
-
} from '@coze-arch/coze-design';
|
|
22
|
-
|
|
23
|
-
import { LoopTable } from '../../table';
|
|
24
|
-
|
|
25
|
-
import { ErrorTypeMap, type UploadAttachmentDetail } from '../type';
|
|
26
|
-
|
|
27
|
-
interface UrlInputModalProps {
|
|
28
|
-
visible: boolean;
|
|
29
|
-
onConfirm: (results: ImageProps[]) => void;
|
|
30
|
-
onCancel: () => void;
|
|
31
|
-
maxCount?: number;
|
|
32
|
-
uploadImageUrl?: (
|
|
33
|
-
urls: string[],
|
|
34
|
-
) => Promise<UploadAttachmentDetail[] | undefined>;
|
|
35
|
-
uploadType?: 'image' | 'video';
|
|
36
|
-
intranetUrlValidator?: (url: string) => boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const UrlInputModal: React.FC<UrlInputModalProps> = ({
|
|
40
|
-
visible,
|
|
41
|
-
onConfirm,
|
|
42
|
-
onCancel,
|
|
43
|
-
maxCount = 6,
|
|
44
|
-
uploadImageUrl,
|
|
45
|
-
uploadType = 'image',
|
|
46
|
-
intranetUrlValidator,
|
|
47
|
-
}) => {
|
|
48
|
-
const [error, setError] = useState('');
|
|
49
|
-
const [isUploading, setIsUploading] = useState(false);
|
|
50
|
-
const [isUploaded, setIsUploaded] = useState(false);
|
|
51
|
-
const [uploadResults, setUploadResults] = useState<UploadAttachmentDetail[]>(
|
|
52
|
-
[],
|
|
53
|
-
);
|
|
54
|
-
const formRef = useRef<FormApi>();
|
|
55
|
-
// Validate helpers
|
|
56
|
-
const validateUrl = (url: string) => {
|
|
57
|
-
try {
|
|
58
|
-
new URL(url);
|
|
59
|
-
return true;
|
|
60
|
-
} catch {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Upload logic
|
|
66
|
-
const handleUpload = async formValues => {
|
|
67
|
-
if (formValues?.urls?.length === 0) {
|
|
68
|
-
setError('请至少添加一个图片链接');
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
setIsUploading(true);
|
|
72
|
-
setError('');
|
|
73
|
-
try {
|
|
74
|
-
const results = await uploadImageUrl?.(formValues?.urls);
|
|
75
|
-
setUploadResults(results || []);
|
|
76
|
-
setIsUploaded(true);
|
|
77
|
-
} catch (err) {
|
|
78
|
-
setError('上传失败,请重试');
|
|
79
|
-
} finally {
|
|
80
|
-
setIsUploading(false);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const handleConfirm = async () => {
|
|
85
|
-
if (!uploadImageUrl) {
|
|
86
|
-
const data = await formRef.current
|
|
87
|
-
?.validate()
|
|
88
|
-
?.catch(e => console.error(e));
|
|
89
|
-
if (Array.isArray(data?.urls)) {
|
|
90
|
-
onConfirm(
|
|
91
|
-
data?.urls?.map(item => ({
|
|
92
|
-
name: item,
|
|
93
|
-
url: item,
|
|
94
|
-
thumb_url: item,
|
|
95
|
-
})),
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (isUploaded) {
|
|
101
|
-
const successResults = uploadResults.filter(
|
|
102
|
-
item => item.errorType === undefined,
|
|
103
|
-
);
|
|
104
|
-
onConfirm(
|
|
105
|
-
successResults.map(item => ({
|
|
106
|
-
name: item.image?.name,
|
|
107
|
-
url: item.originImage?.url,
|
|
108
|
-
uri: item.image?.uri,
|
|
109
|
-
thumb_url: item.image?.thumb_url,
|
|
110
|
-
})),
|
|
111
|
-
);
|
|
112
|
-
} else {
|
|
113
|
-
await formRef.current?.submitForm();
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const handleCancel = () => {
|
|
118
|
-
setError('');
|
|
119
|
-
setIsUploading(false);
|
|
120
|
-
setIsUploaded(false);
|
|
121
|
-
setUploadResults([]);
|
|
122
|
-
onCancel();
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Dynamic form for URLs
|
|
126
|
-
const renderInputStage = () => (
|
|
127
|
-
<Form
|
|
128
|
-
initValues={{ urls: [''] }}
|
|
129
|
-
getFormApi={api => (formRef.current = api)}
|
|
130
|
-
onSubmit={uploadImageUrl ? handleUpload : undefined}
|
|
131
|
-
>
|
|
132
|
-
{({ formState, formApi }) => {
|
|
133
|
-
const urls: string[] = formState.values?.urls || [''];
|
|
134
|
-
const canAdd = urls.length < maxCount;
|
|
135
|
-
return (
|
|
136
|
-
<div>
|
|
137
|
-
{urls.map((_url, idx) => (
|
|
138
|
-
<div key={idx} className="flex gap-2">
|
|
139
|
-
<Form.Input
|
|
140
|
-
field={`urls[${idx}]`}
|
|
141
|
-
label={{
|
|
142
|
-
text: `${uploadType === 'image' ? '图片' : '视频'}${idx + 1}`,
|
|
143
|
-
required: true,
|
|
144
|
-
}}
|
|
145
|
-
fieldClassName="flex-1"
|
|
146
|
-
placeholder={`请输入${uploadType === 'image' ? '图片' : '视频'}链接,请使用公网域名`}
|
|
147
|
-
rules={[
|
|
148
|
-
{
|
|
149
|
-
validator: (_, value, cb) => {
|
|
150
|
-
if (!value) {
|
|
151
|
-
cb(
|
|
152
|
-
`请输入${uploadType === 'image' ? '图片' : '视频'}链接`,
|
|
153
|
-
);
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
if (
|
|
157
|
-
intranetUrlValidator &&
|
|
158
|
-
intranetUrlValidator(value)
|
|
159
|
-
) {
|
|
160
|
-
cb('请使用公网域名');
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
if (!validateUrl(value)) {
|
|
164
|
-
cb('请输入有效的URL');
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
]}
|
|
171
|
-
className="w-full"
|
|
172
|
-
/>
|
|
173
|
-
<Button
|
|
174
|
-
size="small"
|
|
175
|
-
color="secondary"
|
|
176
|
-
icon={<IconCozTrashCan className="w-[14px] h-[14px]" />}
|
|
177
|
-
onClick={() => {
|
|
178
|
-
formApi.setValue(
|
|
179
|
-
'urls',
|
|
180
|
-
urls.filter((_, i) => i !== idx),
|
|
181
|
-
);
|
|
182
|
-
}}
|
|
183
|
-
className="mt-[42px]"
|
|
184
|
-
disabled={urls.length === 1}
|
|
185
|
-
/>
|
|
186
|
-
</div>
|
|
187
|
-
))}
|
|
188
|
-
<Button
|
|
189
|
-
color="primary"
|
|
190
|
-
disabled={!canAdd}
|
|
191
|
-
icon={<IconCozPlus />}
|
|
192
|
-
onClick={() => formApi.setValue('urls', [...urls, ''])}
|
|
193
|
-
className="mt-2"
|
|
194
|
-
>
|
|
195
|
-
添加
|
|
196
|
-
<Typography.Text
|
|
197
|
-
className="ml-1"
|
|
198
|
-
type="secondary"
|
|
199
|
-
>{`${urls.length}/${maxCount}`}</Typography.Text>
|
|
200
|
-
</Button>
|
|
201
|
-
{error ? (
|
|
202
|
-
<div className="text-red-500 text-sm mt-1">{error}</div>
|
|
203
|
-
) : null}
|
|
204
|
-
</div>
|
|
205
|
-
);
|
|
206
|
-
}}
|
|
207
|
-
</Form>
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
const columns: ColumnProps<UploadAttachmentDetail>[] = [
|
|
211
|
-
{
|
|
212
|
-
title: '图片地址',
|
|
213
|
-
dataIndex: 'originImage.url',
|
|
214
|
-
width: 220,
|
|
215
|
-
ellipsis: { showTitle: true },
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
title: '图片预览',
|
|
219
|
-
dataIndex: 'originImage.url',
|
|
220
|
-
width: 120,
|
|
221
|
-
render: (url: string) => (
|
|
222
|
-
<Image
|
|
223
|
-
src={url}
|
|
224
|
-
width={60}
|
|
225
|
-
height={60}
|
|
226
|
-
imgStyle={{ objectFit: 'contain' }}
|
|
227
|
-
/>
|
|
228
|
-
),
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
title: '状态',
|
|
232
|
-
key: 'status',
|
|
233
|
-
align: 'left',
|
|
234
|
-
width: 200,
|
|
235
|
-
render: (record: UploadAttachmentDetail) => (
|
|
236
|
-
<div className="flex items-center">
|
|
237
|
-
<Tag
|
|
238
|
-
prefixIcon={
|
|
239
|
-
record?.errorType ? (
|
|
240
|
-
<IconCozCrossCircleFill />
|
|
241
|
-
) : (
|
|
242
|
-
<IconCozCheckMarkCircleFill />
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
color={record?.errorType ? 'red' : 'green'}
|
|
246
|
-
>
|
|
247
|
-
{record?.errorType ? '失败' : '成功'}
|
|
248
|
-
</Tag>
|
|
249
|
-
<Typography.Text type="secondary" className="ml-1">
|
|
250
|
-
{record.errorType ? ErrorTypeMap[record.errorType] : ''}
|
|
251
|
-
</Typography.Text>
|
|
252
|
-
</div>
|
|
253
|
-
),
|
|
254
|
-
},
|
|
255
|
-
];
|
|
256
|
-
|
|
257
|
-
const renderResultStage = () => (
|
|
258
|
-
<div className="space-y-4">
|
|
259
|
-
<LoopTable
|
|
260
|
-
tableProps={{
|
|
261
|
-
columns,
|
|
262
|
-
dataSource: uploadResults,
|
|
263
|
-
rowKey: 'id',
|
|
264
|
-
pagination: false,
|
|
265
|
-
size: 'small',
|
|
266
|
-
}}
|
|
267
|
-
/>
|
|
268
|
-
</div>
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
const getConfirmButtonText = () => {
|
|
272
|
-
if (!uploadImageUrl) {
|
|
273
|
-
return '确认';
|
|
274
|
-
}
|
|
275
|
-
if (isUploading) {
|
|
276
|
-
return '上传中...';
|
|
277
|
-
}
|
|
278
|
-
if (isUploaded) {
|
|
279
|
-
return `导入${uploadType === 'image' ? '图片' : '视频'}`;
|
|
280
|
-
}
|
|
281
|
-
return '上传';
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
return (
|
|
285
|
-
<Modal
|
|
286
|
-
title={`添加${uploadType === 'image' ? '图片' : '视频'}链接`}
|
|
287
|
-
visible={visible}
|
|
288
|
-
onCancel={handleCancel}
|
|
289
|
-
width={640}
|
|
290
|
-
footer={
|
|
291
|
-
<div className="flex justify-end">
|
|
292
|
-
<Button onClick={handleCancel} color="primary">
|
|
293
|
-
取消
|
|
294
|
-
</Button>
|
|
295
|
-
<Button
|
|
296
|
-
type="primary"
|
|
297
|
-
onClick={handleConfirm}
|
|
298
|
-
loading={isUploading}
|
|
299
|
-
// disabled={!isUploaded && urls.length === 0}
|
|
300
|
-
>
|
|
301
|
-
{getConfirmButtonText()}
|
|
302
|
-
</Button>
|
|
303
|
-
</div>
|
|
304
|
-
}
|
|
305
|
-
>
|
|
306
|
-
{isUploading ? (
|
|
307
|
-
<div className="flex items-center justify-center py-8">
|
|
308
|
-
<Spin size="large" />
|
|
309
|
-
<span className="ml-2">正在上传图片...</span>
|
|
310
|
-
</div>
|
|
311
|
-
) : null}
|
|
312
|
-
|
|
313
|
-
{!isUploading && !isUploaded && renderInputStage()}
|
|
314
|
-
{!isUploading && isUploaded ? renderResultStage() : null}
|
|
315
|
-
</Modal>
|
|
316
|
-
);
|
|
317
|
-
};
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @coze-arch/use-error-in-catch */
|
|
2
|
-
/* eslint-disable complexity */
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import classNames from 'classnames';
|
|
6
|
-
import { StorageProvider } from '@cozeloop/api-schema/data';
|
|
7
|
-
import {
|
|
8
|
-
IconCozCross,
|
|
9
|
-
IconCozPlayCircle,
|
|
10
|
-
IconCozRefresh,
|
|
11
|
-
} from '@coze-arch/coze-design/icons';
|
|
12
|
-
import { Loading, Modal } from '@coze-arch/coze-design';
|
|
13
|
-
|
|
14
|
-
import { ImageStatus, type MultipartItem } from '../type';
|
|
15
|
-
|
|
16
|
-
import styles from './index.module.less';
|
|
17
|
-
|
|
18
|
-
interface VideoItemRendererProps {
|
|
19
|
-
className?: string;
|
|
20
|
-
style?: React.CSSProperties;
|
|
21
|
-
spaceID?: Int64;
|
|
22
|
-
item: MultipartItem;
|
|
23
|
-
readonly?: boolean;
|
|
24
|
-
onRemove: () => void;
|
|
25
|
-
onChange: (item: MultipartItem) => void;
|
|
26
|
-
uploadFile?: (params: unknown) => Promise<string>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const VideoItemRenderer: React.FC<VideoItemRendererProps> = ({
|
|
30
|
-
className,
|
|
31
|
-
style,
|
|
32
|
-
spaceID,
|
|
33
|
-
item,
|
|
34
|
-
onRemove,
|
|
35
|
-
onChange,
|
|
36
|
-
uploadFile,
|
|
37
|
-
readonly,
|
|
38
|
-
}) => {
|
|
39
|
-
const [visible, setVisible] = useState(false);
|
|
40
|
-
const status = item?.sourceVideo?.status;
|
|
41
|
-
const uri = item?.video?.uri;
|
|
42
|
-
const url = item?.video?.url;
|
|
43
|
-
const isError = status === ImageStatus.Error;
|
|
44
|
-
const file = item?.sourceVideo?.file as File;
|
|
45
|
-
const retryUpload = async () => {
|
|
46
|
-
try {
|
|
47
|
-
onChange({
|
|
48
|
-
...item,
|
|
49
|
-
sourceVideo: {
|
|
50
|
-
...item.sourceVideo,
|
|
51
|
-
status: ImageStatus.Loading,
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
const newUri = await uploadFile?.({
|
|
55
|
-
file,
|
|
56
|
-
fileType: 'image',
|
|
57
|
-
spaceID,
|
|
58
|
-
});
|
|
59
|
-
onChange({
|
|
60
|
-
...item,
|
|
61
|
-
sourceVideo: {
|
|
62
|
-
...item.sourceVideo,
|
|
63
|
-
status: ImageStatus.Success,
|
|
64
|
-
},
|
|
65
|
-
video: {
|
|
66
|
-
...item.video,
|
|
67
|
-
uri: newUri,
|
|
68
|
-
storage_provider: StorageProvider.ImageX,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
} catch (error) {
|
|
72
|
-
onChange({
|
|
73
|
-
...item,
|
|
74
|
-
sourceVideo: {
|
|
75
|
-
...item.sourceVideo,
|
|
76
|
-
status: ImageStatus.Error,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<div className="flex flex-col">
|
|
84
|
-
<div
|
|
85
|
-
className={classNames('w-[64px] h-[64px] relative group', className)}
|
|
86
|
-
style={style}
|
|
87
|
-
>
|
|
88
|
-
<video
|
|
89
|
-
src={url}
|
|
90
|
-
className="w-full h-full rounded-[6px] border border-solid coz-stroke-plus"
|
|
91
|
-
/>
|
|
92
|
-
|
|
93
|
-
{status === ImageStatus.Loading ? null : (
|
|
94
|
-
<IconCozPlayCircle
|
|
95
|
-
className="text-white w-[16px] h-[16px] absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]"
|
|
96
|
-
onClick={() => setVisible(true)}
|
|
97
|
-
/>
|
|
98
|
-
)}
|
|
99
|
-
{status !== ImageStatus.Loading && (
|
|
100
|
-
<div
|
|
101
|
-
className={`absolute inset-0 flex gap-3 items-center rounded-[6px] justify-center bg-[rgba(0,0,0,0.4)] ${isError ? 'visible' : 'invisible'} group-hover:visible`}
|
|
102
|
-
>
|
|
103
|
-
{isError && !readonly && file ? (
|
|
104
|
-
<IconCozRefresh
|
|
105
|
-
className="text-white w-[16px] h-[16px] cursor-pointer"
|
|
106
|
-
onClick={retryUpload}
|
|
107
|
-
/>
|
|
108
|
-
) : null}
|
|
109
|
-
{uri || url ? (
|
|
110
|
-
<IconCozPlayCircle
|
|
111
|
-
className="text-white w-[16px] h-[16px] cursor-pointer"
|
|
112
|
-
onClick={() => setVisible(true)}
|
|
113
|
-
/>
|
|
114
|
-
) : null}
|
|
115
|
-
{readonly ? null : (
|
|
116
|
-
<div className="p-[2px] text-white cursor-pointer absolute right-[-4px] top-[-4px] z-10 bg-[var(--coz-fg-secondary)] rounded-[16px] flex items-end justify-center">
|
|
117
|
-
<IconCozCross onClick={onRemove} className="text-[12px]" />
|
|
118
|
-
</div>
|
|
119
|
-
)}
|
|
120
|
-
</div>
|
|
121
|
-
)}
|
|
122
|
-
{status === ImageStatus.Loading && (
|
|
123
|
-
<div className="absolute inset-0 flex items-center rounded-[6px] justify-center bg-[rgba(0,0,0,0.4)] z-10">
|
|
124
|
-
<Loading loading color="blue" />
|
|
125
|
-
</div>
|
|
126
|
-
)}
|
|
127
|
-
</div>
|
|
128
|
-
{status === ImageStatus.Error ? (
|
|
129
|
-
<div className="text-sm text-red-500">上传失败</div>
|
|
130
|
-
) : null}
|
|
131
|
-
<Modal
|
|
132
|
-
title="视频预览"
|
|
133
|
-
footer={null}
|
|
134
|
-
visible={visible}
|
|
135
|
-
onCancel={() => setVisible(false)}
|
|
136
|
-
footerFill={false}
|
|
137
|
-
hasScroll={false}
|
|
138
|
-
width={654}
|
|
139
|
-
className={styles['video-preview-modal']}
|
|
140
|
-
>
|
|
141
|
-
<video src={url} className="w-full h-[368px]" controls autoPlay />
|
|
142
|
-
</Modal>
|
|
143
|
-
</div>
|
|
144
|
-
);
|
|
145
|
-
};
|