Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/uploader-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.3.17 (December 22, 2025)
## 0.3.18 (December 22, 2025)

- feat(uploader): add headless API for programmatic control

Expand Down
2 changes: 1 addition & 1 deletion packages/uploader-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blocklet/uploader-server",
"version": "0.3.17",
"version": "0.3.18",
"description": "blocklet upload server",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/uploader-server/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.17
0.3.18
3 changes: 2 additions & 1 deletion packages/uploader/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 0.3.17 (December 22, 2025)
## 0.3.18 (December 22, 2025)


- feat(uploader): add headless API for programmatic control

Expand Down
2 changes: 1 addition & 1 deletion packages/uploader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blocklet/uploader",
"version": "0.3.17",
"version": "0.3.18",
"description": "blocklet upload component",
"publishConfig": {
"access": "public"
Expand Down
11 changes: 3 additions & 8 deletions packages/uploader/src/react/uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ export function Uploader({
source,
});
});

if (autoUpload) {
state.uppy.upload();
}
Expand Down Expand Up @@ -996,17 +997,11 @@ export function Uploader({
getUploader: () => state.uppy,
open,
close,

// Headless API
triggerFileInput,
getDropzoneProps,
addFiles: (files: File[], options?: { autoUpload?: boolean }) => {
addFilesToUppy(files, 'local', options?.autoUpload !== false);
},
upload: () => state.uppy.upload(),
getProgress: () => state.uppy.getState().totalProgress,
getFiles: () => state.uppy.getFiles(),
removeFile: (fileId: string) => state.uppy.removeFile(fileId),
cancelAll: () => state.uppy.cancelAll(),
addFilesToUppy,
} as UploaderRef)
);

Expand Down
18 changes: 1 addition & 17 deletions packages/uploader/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,12 @@ export interface DropzoneProps {
}

export type UploaderRef = {
/** 获取底层 Uppy 实例 */
getUploader: () => Uppy;
/** 打开上传器 (Dashboard) */
open: (pluginName?: string) => void;
/** 关闭上传器 */
close: () => void;
/** 触发系统文件选择器 */
triggerFileInput: (options?: { accept?: string; multiple?: boolean; autoUpload?: boolean }) => void;
/** 获取拖拽区域 props,绑定到元素即可支持拖拽+点击上传 */
getDropzoneProps: (options?: { autoUpload?: boolean; noClick?: boolean }) => DropzoneProps;
/** 批量添加文件 */
addFiles: (files: File[], options?: { autoUpload?: boolean }) => void;
/** 开始上传 */
upload: () => Promise<any>;
/** 获取当前总进度 0-100 */
getProgress: () => number;
/** 获取当前文件列表 */
getFiles: () => UppyFile[];
/** 移除指定文件 */
removeFile: (fileId: string) => void;
/** 取消所有上传 */
cancelAll: () => void;
addFilesToUppy: (files: File[], source: string, autoUpload: boolean) => void;
};

export type UploaderProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/uploader/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.17
0.3.18
Loading