@cozeloop/components 0.0.3 → 0.0.4
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/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,103 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { type ContentPart } from '@cozeloop/api-schema/prompt';
|
|
3
|
-
import {
|
|
4
|
-
type Content,
|
|
5
|
-
type Image,
|
|
6
|
-
type ContentType,
|
|
7
|
-
} from '@cozeloop/api-schema/evaluation';
|
|
8
|
-
import { ItemErrorType, type MultiModalSpec } from '@cozeloop/api-schema/data';
|
|
9
|
-
|
|
10
|
-
export enum ImageStatus {
|
|
11
|
-
Loading = 'loading',
|
|
12
|
-
Success = 'success',
|
|
13
|
-
Error = 'error',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type FileItemStatus =
|
|
17
|
-
| 'success'
|
|
18
|
-
| 'uploadFail'
|
|
19
|
-
| 'validateFail'
|
|
20
|
-
| 'validating'
|
|
21
|
-
| 'uploading'
|
|
22
|
-
| 'wait';
|
|
23
|
-
|
|
24
|
-
export interface ContentPartLoop extends ContentPart {
|
|
25
|
-
uid?: string;
|
|
26
|
-
status?: FileItemStatus;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const ErrorTypeMap = {
|
|
30
|
-
[ItemErrorType.MismatchSchema]: 'schema 不匹配',
|
|
31
|
-
[ItemErrorType.EmptyData]: '空数据',
|
|
32
|
-
[ItemErrorType.ExceedMaxItemSize]: '单条数据大小超限',
|
|
33
|
-
[ItemErrorType.ExceedDatasetCapacity]: '数据集容量超限',
|
|
34
|
-
[ItemErrorType.MalformedFile]: '文件格式错误',
|
|
35
|
-
[ItemErrorType.InternalError]: '系统错误',
|
|
36
|
-
[ItemErrorType.IllegalContent]: '包含非法内容',
|
|
37
|
-
[ItemErrorType.MissingRequiredField]: '缺少必填字段',
|
|
38
|
-
[ItemErrorType.ExceedMaxNestedDepth]: '数据嵌套层数超限',
|
|
39
|
-
[ItemErrorType.TransformItemFailed]: '数据转换失败',
|
|
40
|
-
[ItemErrorType.ExceedMaxImageCount]: '图片数量超限',
|
|
41
|
-
[ItemErrorType.ExceedMaxImageSize]: '图片大小超限',
|
|
42
|
-
[ItemErrorType.GetImageFailed]: '图片获取失败',
|
|
43
|
-
[ItemErrorType.IllegalExtension]: '文件扩展名不合法',
|
|
44
|
-
[ItemErrorType.UploadImageFailed]: '上传图片失败',
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type MultipartItemContentType = ContentType | 'Video';
|
|
48
|
-
export interface MultipartItem extends Omit<Content, 'content_type'> {
|
|
49
|
-
uid?: string;
|
|
50
|
-
sourceImage?: {
|
|
51
|
-
status: ImageStatus;
|
|
52
|
-
file?: File;
|
|
53
|
-
};
|
|
54
|
-
sourceVideo?: {
|
|
55
|
-
status: ImageStatus;
|
|
56
|
-
file?: File;
|
|
57
|
-
};
|
|
58
|
-
video?: Image;
|
|
59
|
-
content_type: MultipartItemContentType;
|
|
60
|
-
config?: {
|
|
61
|
-
image_resolution?: string;
|
|
62
|
-
video_fps?: number;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface ImageField {
|
|
67
|
-
name?: string;
|
|
68
|
-
url?: string;
|
|
69
|
-
uri?: string;
|
|
70
|
-
thumb_url?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface UploadAttachmentDetail {
|
|
74
|
-
contentType?: ContentType;
|
|
75
|
-
originImage?: ImageField;
|
|
76
|
-
image?: ImageField;
|
|
77
|
-
errorType?: ItemErrorType;
|
|
78
|
-
errMsg?: string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type MultipartEditorConfig = MultiModalSpec & {
|
|
82
|
-
imageEnabled?: boolean;
|
|
83
|
-
imageSupportedFormats?: string[];
|
|
84
|
-
videoEnabled?: boolean;
|
|
85
|
-
videoSupportedFormats?: string[];
|
|
86
|
-
maxVideoSize?: number;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export interface MultipartEditorProps {
|
|
90
|
-
spaceID?: Int64;
|
|
91
|
-
className?: string;
|
|
92
|
-
value?: MultipartItem[];
|
|
93
|
-
multipartConfig?: MultipartEditorConfig;
|
|
94
|
-
readonly?: boolean;
|
|
95
|
-
onChange?: (contents: MultipartItem[]) => void;
|
|
96
|
-
uploadFile?: (params: any) => Promise<string>;
|
|
97
|
-
uploadImageUrl?: (
|
|
98
|
-
urls: string[],
|
|
99
|
-
) => Promise<UploadAttachmentDetail[] | undefined>;
|
|
100
|
-
imageHidden?: boolean;
|
|
101
|
-
videoHidden?: boolean;
|
|
102
|
-
intranetUrlValidator?: (url: string) => boolean;
|
|
103
|
-
}
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @coze-arch/max-line-per-function */
|
|
2
|
-
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
|
3
|
-
|
|
4
|
-
import { ContentType } from '@cozeloop/api-schema/prompt';
|
|
5
|
-
import {
|
|
6
|
-
IconCozImage,
|
|
7
|
-
IconCozImageArrowUp,
|
|
8
|
-
IconCozVideo,
|
|
9
|
-
} from '@coze-arch/coze-design/icons';
|
|
10
|
-
import {
|
|
11
|
-
IconButton,
|
|
12
|
-
Menu,
|
|
13
|
-
Toast,
|
|
14
|
-
Upload,
|
|
15
|
-
type UploadProps,
|
|
16
|
-
} from '@coze-arch/coze-design';
|
|
17
|
-
|
|
18
|
-
import { type ContentPartLoop } from './type';
|
|
19
|
-
|
|
20
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
21
|
-
interface UploadBtnProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
22
|
-
spaceID: string;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
maxImageSize?: number;
|
|
25
|
-
maxVideoSize?: number;
|
|
26
|
-
maxFileCount?: number;
|
|
27
|
-
imageEnabled?: boolean;
|
|
28
|
-
videoEnabled?: boolean;
|
|
29
|
-
imageSupportedFormats?: string[];
|
|
30
|
-
videoSupportedFormats?: string[];
|
|
31
|
-
fileLimit?: number;
|
|
32
|
-
fileParts?: ContentPartLoop[];
|
|
33
|
-
uploadFile?: (params: any) => Promise<string>;
|
|
34
|
-
onFilePartsChange?: (part: ContentPartLoop) => void;
|
|
35
|
-
}
|
|
36
|
-
export interface UploadButtonRef {
|
|
37
|
-
getUploadImage: () => Upload | null;
|
|
38
|
-
getUploadVideo: () => Upload | null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const UploadButton = forwardRef<UploadButtonRef, UploadBtnProps>(
|
|
42
|
-
(
|
|
43
|
-
{
|
|
44
|
-
spaceID,
|
|
45
|
-
disabled,
|
|
46
|
-
maxImageSize,
|
|
47
|
-
maxVideoSize,
|
|
48
|
-
maxFileCount,
|
|
49
|
-
uploadFile,
|
|
50
|
-
imageEnabled,
|
|
51
|
-
videoEnabled,
|
|
52
|
-
imageSupportedFormats,
|
|
53
|
-
videoSupportedFormats,
|
|
54
|
-
fileLimit,
|
|
55
|
-
fileParts = [],
|
|
56
|
-
onFilePartsChange,
|
|
57
|
-
}: UploadBtnProps,
|
|
58
|
-
ref,
|
|
59
|
-
) => {
|
|
60
|
-
const uploadImgRef = useRef<Upload>(null);
|
|
61
|
-
const uploadVideoRef = useRef<Upload>(null);
|
|
62
|
-
|
|
63
|
-
const createUploadHandler =
|
|
64
|
-
(fileType: 'image' | 'video'): UploadProps['customRequest'] =>
|
|
65
|
-
({ fileInstance, file, onProgress, onSuccess, onError }) => {
|
|
66
|
-
const currentFileType = fileType;
|
|
67
|
-
const { uid } = file;
|
|
68
|
-
|
|
69
|
-
const reader = new FileReader();
|
|
70
|
-
reader.readAsDataURL(fileInstance as Blob);
|
|
71
|
-
reader.onload = async () => {
|
|
72
|
-
const base64Url = reader.result as string;
|
|
73
|
-
const partInfo =
|
|
74
|
-
currentFileType === 'image'
|
|
75
|
-
? { image_url: { url: file.url, thumb_url: base64Url } }
|
|
76
|
-
: { video_url: { url: file.url, thumb_url: base64Url } };
|
|
77
|
-
const part: ContentPartLoop = {
|
|
78
|
-
type:
|
|
79
|
-
currentFileType === 'image'
|
|
80
|
-
? ContentType.ImageURL
|
|
81
|
-
: ContentType.VideoURL,
|
|
82
|
-
...partInfo,
|
|
83
|
-
status: 'uploading',
|
|
84
|
-
uid,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
onFilePartsChange?.(part);
|
|
89
|
-
const res = await uploadFile?.({
|
|
90
|
-
spaceID,
|
|
91
|
-
file: fileInstance,
|
|
92
|
-
fileType: 'image', // 不管是视频还是图片,都走imageX上传,所以fileType必须都是image
|
|
93
|
-
onProgress,
|
|
94
|
-
onSuccess,
|
|
95
|
-
onError,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const fileInfo =
|
|
99
|
-
currentFileType === 'image'
|
|
100
|
-
? {
|
|
101
|
-
image_url: {
|
|
102
|
-
url: file.url,
|
|
103
|
-
uri: res,
|
|
104
|
-
thumb_url: base64Url,
|
|
105
|
-
},
|
|
106
|
-
}
|
|
107
|
-
: {
|
|
108
|
-
video_url: {
|
|
109
|
-
url: file.url,
|
|
110
|
-
uri: res,
|
|
111
|
-
thumb_url: base64Url,
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const newPart: ContentPartLoop = {
|
|
116
|
-
...part,
|
|
117
|
-
...fileInfo,
|
|
118
|
-
status: 'success',
|
|
119
|
-
};
|
|
120
|
-
onFilePartsChange?.(newPart);
|
|
121
|
-
} catch (error) {
|
|
122
|
-
console.info('error', error);
|
|
123
|
-
Toast.error('图片上传失败,请稍后重试');
|
|
124
|
-
onFilePartsChange?.({
|
|
125
|
-
...part,
|
|
126
|
-
status: 'uploadFail',
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const renderImageUpload = useCallback(
|
|
133
|
-
(children: React.ReactNode) => (
|
|
134
|
-
<Upload
|
|
135
|
-
ref={uploadImgRef}
|
|
136
|
-
action=""
|
|
137
|
-
customRequest={createUploadHandler('image')}
|
|
138
|
-
accept={imageSupportedFormats?.join(',') || 'image/*'}
|
|
139
|
-
showUploadList={false}
|
|
140
|
-
maxSize={maxImageSize ? maxImageSize * 1024 * 1024 : 0}
|
|
141
|
-
limit={fileLimit}
|
|
142
|
-
onSizeError={() => Toast.error(`图片大小不能超过${maxImageSize}MB`)}
|
|
143
|
-
onExceed={() => Toast.warning(`最多上传${maxFileCount}张图片`)}
|
|
144
|
-
multiple
|
|
145
|
-
fileList={fileParts.map(it => ({
|
|
146
|
-
uid: it.uid || '',
|
|
147
|
-
url: it.image_url?.url,
|
|
148
|
-
status: it.status || 'success',
|
|
149
|
-
name: it.uid || '',
|
|
150
|
-
size: '0',
|
|
151
|
-
}))}
|
|
152
|
-
>
|
|
153
|
-
{children}
|
|
154
|
-
</Upload>
|
|
155
|
-
),
|
|
156
|
-
[fileParts, maxImageSize, fileLimit, imageSupportedFormats],
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
const renderVideoUpload = useCallback(
|
|
160
|
-
(children: React.ReactNode) => (
|
|
161
|
-
<Upload
|
|
162
|
-
ref={uploadVideoRef}
|
|
163
|
-
action=""
|
|
164
|
-
customRequest={createUploadHandler('video')}
|
|
165
|
-
accept={videoSupportedFormats?.join(',') || 'video/*'}
|
|
166
|
-
showUploadList={false}
|
|
167
|
-
maxSize={maxVideoSize ? maxVideoSize * 1024 : 0}
|
|
168
|
-
limit={fileLimit}
|
|
169
|
-
onSizeError={() => Toast.error(`视频大小不能超过${maxVideoSize}MB`)}
|
|
170
|
-
onExceed={() => Toast.warning(`最多上传${maxFileCount}个视频`)}
|
|
171
|
-
multiple
|
|
172
|
-
fileList={fileParts.map(it => ({
|
|
173
|
-
uid: it.uid || '',
|
|
174
|
-
url: it.video_url?.url,
|
|
175
|
-
status: it.status || 'success',
|
|
176
|
-
name: it.uid || '',
|
|
177
|
-
size: '0',
|
|
178
|
-
}))}
|
|
179
|
-
>
|
|
180
|
-
{children}
|
|
181
|
-
</Upload>
|
|
182
|
-
),
|
|
183
|
-
[fileParts, maxVideoSize, fileLimit, videoSupportedFormats],
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
useImperativeHandle(ref, () => ({
|
|
187
|
-
getUploadImage: () => uploadImgRef.current,
|
|
188
|
-
getUploadVideo: () => uploadVideoRef.current,
|
|
189
|
-
}));
|
|
190
|
-
|
|
191
|
-
if (!imageEnabled && !videoEnabled) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (imageEnabled && !videoEnabled) {
|
|
196
|
-
return renderImageUpload(
|
|
197
|
-
<IconButton
|
|
198
|
-
icon={<IconCozImage />}
|
|
199
|
-
color="primary"
|
|
200
|
-
disabled={disabled}
|
|
201
|
-
data-btm="d41383"
|
|
202
|
-
data-btm-title="图片上传"
|
|
203
|
-
/>,
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (!imageEnabled && videoEnabled) {
|
|
208
|
-
return renderVideoUpload(
|
|
209
|
-
<IconButton
|
|
210
|
-
icon={<IconCozVideo />}
|
|
211
|
-
color="primary"
|
|
212
|
-
disabled={disabled}
|
|
213
|
-
data-btm="d27622"
|
|
214
|
-
data-btm-title="视频上传"
|
|
215
|
-
/>,
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<>
|
|
221
|
-
<Menu
|
|
222
|
-
render={
|
|
223
|
-
<Menu.SubMenu mode="menu">
|
|
224
|
-
<Menu.Item
|
|
225
|
-
onClick={() => {
|
|
226
|
-
uploadImgRef.current?.openFileDialog();
|
|
227
|
-
}}
|
|
228
|
-
data-btm="d41383"
|
|
229
|
-
data-btm-title="图片上传"
|
|
230
|
-
>
|
|
231
|
-
图片上传
|
|
232
|
-
</Menu.Item>
|
|
233
|
-
<Menu.Item
|
|
234
|
-
onClick={() => {
|
|
235
|
-
uploadVideoRef.current?.openFileDialog();
|
|
236
|
-
}}
|
|
237
|
-
data-btm="d27622"
|
|
238
|
-
data-btm-title="视频上传"
|
|
239
|
-
>
|
|
240
|
-
视频上传
|
|
241
|
-
</Menu.Item>
|
|
242
|
-
</Menu.SubMenu>
|
|
243
|
-
}
|
|
244
|
-
>
|
|
245
|
-
<IconButton
|
|
246
|
-
icon={<IconCozImageArrowUp />}
|
|
247
|
-
color="primary"
|
|
248
|
-
disabled={disabled}
|
|
249
|
-
/>
|
|
250
|
-
</Menu>
|
|
251
|
-
{renderImageUpload(null)}
|
|
252
|
-
{renderVideoUpload(null)}
|
|
253
|
-
</>
|
|
254
|
-
);
|
|
255
|
-
},
|
|
256
|
-
);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type MultipartEditorConfig } from './type';
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_FILE_SIZE = 20 * 1024 * 1024;
|
|
4
|
-
export const DEFAULT_FILE_COUNT = 20;
|
|
5
|
-
export const DEFAULT_PART_COUNT = 50;
|
|
6
|
-
export const DEFAULT_SUPPORTED_FORMATS = [
|
|
7
|
-
'.jpg',
|
|
8
|
-
'.jpeg',
|
|
9
|
-
'.png',
|
|
10
|
-
'.gif',
|
|
11
|
-
'.bmp',
|
|
12
|
-
'.webp',
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
export const DEFAULT_VIDEO_SUPPORTED_FORMATS = [
|
|
16
|
-
'.mp4',
|
|
17
|
-
'.avi',
|
|
18
|
-
'.mov',
|
|
19
|
-
'.wmv',
|
|
20
|
-
'.flv',
|
|
21
|
-
'.mkv',
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
export const getMultipartConfig = (multipartConfig?: MultipartEditorConfig) => {
|
|
25
|
-
const {
|
|
26
|
-
max_file_count,
|
|
27
|
-
max_part_count,
|
|
28
|
-
max_file_size,
|
|
29
|
-
imageEnabled,
|
|
30
|
-
videoEnabled,
|
|
31
|
-
imageSupportedFormats,
|
|
32
|
-
videoSupportedFormats,
|
|
33
|
-
maxVideoSize,
|
|
34
|
-
} = multipartConfig || {};
|
|
35
|
-
const maxFileCount = max_file_count
|
|
36
|
-
? Number(max_file_count)
|
|
37
|
-
: DEFAULT_FILE_COUNT;
|
|
38
|
-
const maxPartCount = max_part_count
|
|
39
|
-
? Number(max_part_count)
|
|
40
|
-
: DEFAULT_PART_COUNT;
|
|
41
|
-
const trueMaxFileCount =
|
|
42
|
-
maxFileCount > maxPartCount ? maxPartCount : maxFileCount;
|
|
43
|
-
const maxFileSize = max_file_size ? Number(max_file_size) : DEFAULT_FILE_SIZE;
|
|
44
|
-
const currentImageSupportedFormats = (
|
|
45
|
-
imageSupportedFormats?.map(format =>
|
|
46
|
-
format.startsWith('.') ? format : `.${format}`,
|
|
47
|
-
) || DEFAULT_SUPPORTED_FORMATS
|
|
48
|
-
).join(',');
|
|
49
|
-
const currentVideoSupportedFormats = (
|
|
50
|
-
videoSupportedFormats?.map(format =>
|
|
51
|
-
format.startsWith('.') ? format : `.${format}`,
|
|
52
|
-
) || DEFAULT_VIDEO_SUPPORTED_FORMATS
|
|
53
|
-
).join(',');
|
|
54
|
-
return {
|
|
55
|
-
maxFileCount: trueMaxFileCount,
|
|
56
|
-
maxPartCount,
|
|
57
|
-
maxFileSize,
|
|
58
|
-
imageEnabled,
|
|
59
|
-
videoEnabled,
|
|
60
|
-
imageSupportedFormats: currentImageSupportedFormats,
|
|
61
|
-
videoSupportedFormats: currentVideoSupportedFormats,
|
|
62
|
-
maxVideoSize,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { IconCozLongArrowTopRight } from '@coze-arch/coze-design/icons';
|
|
3
|
-
import { Tooltip, Button } from '@coze-arch/coze-design';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
url: string;
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function OpenDetailButton({ url, className }: Props) {
|
|
11
|
-
return (
|
|
12
|
-
<Tooltip theme="dark" content="查看详情">
|
|
13
|
-
<Button
|
|
14
|
-
onClick={e => {
|
|
15
|
-
e.stopPropagation();
|
|
16
|
-
window.open(url);
|
|
17
|
-
}}
|
|
18
|
-
className={classNames(
|
|
19
|
-
'flex-shrink-0 !h-6 !w-6 !min-w-[24px] !p-[5px]',
|
|
20
|
-
className,
|
|
21
|
-
)}
|
|
22
|
-
size="small"
|
|
23
|
-
color="secondary"
|
|
24
|
-
icon={
|
|
25
|
-
<IconCozLongArrowTopRight className="h-[14px] w-[14px] coz-fg-secondary" />
|
|
26
|
-
}
|
|
27
|
-
></Button>
|
|
28
|
-
</Tooltip>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
IconCozIllus404Dark,
|
|
6
|
-
IconCozIllus404,
|
|
7
|
-
IconCozIllusErrorDark,
|
|
8
|
-
IconCozIllusError,
|
|
9
|
-
IconCozIllusLock,
|
|
10
|
-
IconCozIllusLockDark,
|
|
11
|
-
IconCozIllusEmpty,
|
|
12
|
-
IconCozIllusEmptyDark,
|
|
13
|
-
} from '@coze-arch/coze-design/illustrations';
|
|
14
|
-
import { Empty, Spin, type EmptyStateProps } from '@coze-arch/coze-design';
|
|
15
|
-
|
|
16
|
-
interface PageLoadingProps {
|
|
17
|
-
tip?: ReactNode;
|
|
18
|
-
className?: string;
|
|
19
|
-
style?: CSSProperties;
|
|
20
|
-
}
|
|
21
|
-
interface FullPageProps {
|
|
22
|
-
className?: string;
|
|
23
|
-
style?: CSSProperties;
|
|
24
|
-
children?: ReactNode;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type PageContentProps = Omit<EmptyStateProps, 'image' | 'darkModeImage'>;
|
|
28
|
-
|
|
29
|
-
export function FullPage({ children, className, style }: FullPageProps) {
|
|
30
|
-
return (
|
|
31
|
-
<div
|
|
32
|
-
className={classNames(
|
|
33
|
-
'w-full h-full flex items-center justify-center bg-semi-bg-1 z-10',
|
|
34
|
-
className,
|
|
35
|
-
)}
|
|
36
|
-
style={style}
|
|
37
|
-
>
|
|
38
|
-
{children}
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
export function PageLoading(props: PageLoadingProps) {
|
|
43
|
-
return (
|
|
44
|
-
<FullPage className={props.className} style={props.style}>
|
|
45
|
-
<Spin wrapperClassName="w-full h-full" spinning tip={props.tip} />
|
|
46
|
-
</FullPage>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function PageNotFound({ className, ...props }: PageContentProps) {
|
|
51
|
-
return (
|
|
52
|
-
<FullPage className={className}>
|
|
53
|
-
<Empty
|
|
54
|
-
image={<IconCozIllus404 className="text-[160px]" />}
|
|
55
|
-
darkModeImage={<IconCozIllus404Dark className="text-[160px]" />}
|
|
56
|
-
description="页面丢失了"
|
|
57
|
-
{...props}
|
|
58
|
-
/>
|
|
59
|
-
</FullPage>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function PageError({ className, ...props }: PageContentProps) {
|
|
64
|
-
return (
|
|
65
|
-
<FullPage className={className}>
|
|
66
|
-
<Empty
|
|
67
|
-
image={<IconCozIllusError className="text-[160px]" />}
|
|
68
|
-
darkModeImage={<IconCozIllusErrorDark className="text-[160px]" />}
|
|
69
|
-
description="页面加载失败"
|
|
70
|
-
{...props}
|
|
71
|
-
/>
|
|
72
|
-
</FullPage>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function PageNoAuth({ className, ...props }: PageContentProps) {
|
|
77
|
-
return (
|
|
78
|
-
<FullPage className={className}>
|
|
79
|
-
<Empty
|
|
80
|
-
image={<IconCozIllusLock className="text-[160px]" />}
|
|
81
|
-
darkModeImage={<IconCozIllusLockDark className="text-[160px]" />}
|
|
82
|
-
description="暂无权限"
|
|
83
|
-
{...props}
|
|
84
|
-
></Empty>
|
|
85
|
-
</FullPage>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function PageNoContent({ className, ...props }: PageContentProps) {
|
|
90
|
-
return (
|
|
91
|
-
<FullPage className={className}>
|
|
92
|
-
<Empty
|
|
93
|
-
image={<IconCozIllusEmpty className="text-[160px]" />}
|
|
94
|
-
darkModeImage={<IconCozIllusEmptyDark className="text-[160px]" />}
|
|
95
|
-
{...props}
|
|
96
|
-
/>
|
|
97
|
-
</FullPage>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { PrimaryPage } from './primary-header';
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
|
|
5
|
-
interface PrimaryPageHeaderProps {
|
|
6
|
-
pageTitle?: ReactNode;
|
|
7
|
-
filterSlot?: ReactNode;
|
|
8
|
-
children?: ReactNode;
|
|
9
|
-
headerClassName?: string;
|
|
10
|
-
titleClassName?: string;
|
|
11
|
-
contentClassName?: string;
|
|
12
|
-
className?: string;
|
|
13
|
-
titleSlot?: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const PrimaryPage = ({
|
|
17
|
-
pageTitle,
|
|
18
|
-
filterSlot,
|
|
19
|
-
children,
|
|
20
|
-
contentClassName,
|
|
21
|
-
className,
|
|
22
|
-
headerClassName,
|
|
23
|
-
titleClassName,
|
|
24
|
-
titleSlot,
|
|
25
|
-
}: PrimaryPageHeaderProps) => (
|
|
26
|
-
<div
|
|
27
|
-
className={classNames(
|
|
28
|
-
'pt-2 pb-3 h-full max-h-full flex flex-col',
|
|
29
|
-
className,
|
|
30
|
-
)}
|
|
31
|
-
>
|
|
32
|
-
{pageTitle || titleSlot ? (
|
|
33
|
-
<div
|
|
34
|
-
className={classNames(
|
|
35
|
-
'flex items-center justify-between py-4 px-6',
|
|
36
|
-
headerClassName,
|
|
37
|
-
)}
|
|
38
|
-
>
|
|
39
|
-
<div
|
|
40
|
-
className={classNames(
|
|
41
|
-
'text-[20px] font-medium leading-6 coz-fg-plus',
|
|
42
|
-
titleClassName,
|
|
43
|
-
)}
|
|
44
|
-
>
|
|
45
|
-
{pageTitle}
|
|
46
|
-
</div>
|
|
47
|
-
<div>{titleSlot}</div>
|
|
48
|
-
</div>
|
|
49
|
-
) : null}
|
|
50
|
-
{filterSlot ? (
|
|
51
|
-
<div className="box-border coz-fg-secondary pt-1 pb-3 px-6">
|
|
52
|
-
{filterSlot}
|
|
53
|
-
</div>
|
|
54
|
-
) : null}
|
|
55
|
-
<div
|
|
56
|
-
className={classNames(
|
|
57
|
-
'flex-1 h-full max-h-full overflow-hidden px-6',
|
|
58
|
-
contentClassName,
|
|
59
|
-
)}
|
|
60
|
-
>
|
|
61
|
-
{children}
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { Typography } from '@coze-arch/coze-design';
|
|
4
|
-
|
|
5
|
-
import styles from './index.module.less';
|
|
6
|
-
|
|
7
|
-
interface PrimaryTitleProps {
|
|
8
|
-
title: string;
|
|
9
|
-
className?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function PrimaryTitle({ title, className }: PrimaryTitleProps) {
|
|
13
|
-
return (
|
|
14
|
-
<Typography.Text className={classNames(styles['primary-title'], className)}>
|
|
15
|
-
{title}
|
|
16
|
-
</Typography.Text>
|
|
17
|
-
);
|
|
18
|
-
}
|