From 0a59030d48920cde4b7a8c59a8a48ef4de9dedfa Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 17:31:03 +0800 Subject: [PATCH 01/17] chore: standardize repository config --- .dumirc => .dumirc.ts | 7 + .github/FUNDING.yml | 17 +- .github/dependabot.yml | 27 +--- .github/workflows/codeql.yml | 43 +++++ .github/workflows/react-component-ci.yml | 10 +- .github/workflows/react-doctor.yml | 27 ++++ .github/workflows/surge-preview.yml | 39 +++++ .gitignore | 17 +- README.md | 195 ++++++++++++----------- docs/examples/asyncAction.tsx | 1 - docs/examples/customRequest.tsx | 5 +- docs/examples/directoryUpload.tsx | 1 - docs/examples/drag.tsx | 1 - docs/examples/dragDirectory.tsx | 1 - docs/examples/paste.tsx | 1 - docs/examples/pasteDirectory.tsx | 1 - docs/index.md | 4 +- package.json | 18 ++- tsconfig.json | 9 +- vercel.json | 16 +- 20 files changed, 265 insertions(+), 175 deletions(-) rename .dumirc => .dumirc.ts (64%) create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 .github/workflows/surge-preview.yml diff --git a/.dumirc b/.dumirc.ts similarity index 64% rename from .dumirc rename to .dumirc.ts index ba410f77..1c9ae2bd 100644 --- a/.dumirc +++ b/.dumirc.ts @@ -1,10 +1,14 @@ import { defineConfig } from 'dumi'; import path from 'path'; +const basePath = process.env.GH_PAGES ? '/upload/' : '/'; +const publicPath = process.env.GH_PAGES ? '/upload/' : '/'; + export default defineConfig({ alias: { '@rc-component/upload$': path.resolve('src'), '@rc-component/upload/es': path.resolve('src'), + '@rc-component/upload/es/*': path.resolve('src'), }, mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], @@ -12,4 +16,7 @@ export default defineConfig({ name: 'Upload', logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, + outputPath: 'docs-dist', + base: basePath, + publicPath, }); diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 33b1999c..758659af 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,15 +1,2 @@ -# These are supported funding model platforms - -github: ant-design # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: ant-design # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -polar: # Replace with a single Polar username -buy_me_a_coffee: # Replace with a single Buy Me a Coffee username -thanks_dev: # Replace with a single thanks.dev username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +github: ant-design +open_collective: ant-design diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c834920a..07575c02 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,23 +1,8 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: sinon - versions: - - 10.0.0 - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + time: '21:00' + open-pull-requests-limit: 10 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..23f424a8 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,43 @@ +name: 'CodeQL' + +on: + push: + branches: ['master'] + pull_request: + branches: ['master'] + schedule: + - cron: '17 10 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [javascript] + + steps: + - name: Checkout + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + + - name: Initialize CodeQL + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index f860ff10..1ed64209 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -1,6 +1,12 @@ name: ✅ test -on: [push, pull_request] +on: + push: + branches: [master] + pull_request: + branches: [master] +permissions: + contents: read jobs: test: - uses: react-component/rc-test/.github/workflows/test.yml@main + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main secrets: inherit diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 00000000..f68281c8 --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,27 @@ +name: React Doctor + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [master] + +permissions: + contents: read + pull-requests: write + issues: write + statuses: write + +concurrency: + group: react-doctor-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + react-doctor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + fetch-depth: 0 + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 00000000..1b29a17b --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,39 @@ +name: Surge Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + checks: write + statuses: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ env.SURGE_TOKEN != '' }} + with: + surge_token: ${{ env.SURGE_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dist: docs-dist + failOnError: true + setCommitStatus: true + build: | + npm install + npm run build + - name: Skip Surge preview + if: ${{ env.SURGE_TOKEN == '' }} + run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/.gitignore b/.gitignore index e1117e8f..4597fc50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.iml *.log +*.log.* .idea/ .ipr .iws @@ -24,22 +25,24 @@ dist assets/**/*.css build lib -coverage -yarn.lock es +/coverage +yarn.lock package-lock.json pnpm-lock.yaml +.doc +docs-dist +.vercel +.storybook tmp/ .history -.storybook -.doc # umi .umi .umi-production .umi-test .env.local +.dumi/ -# dumi -.dumi/tmp -.dumi/tmp-production +bun.lockb +bun.lock diff --git a/README.md b/README.md index 0ab56f7e..426840be 100644 --- a/README.md +++ b/README.md @@ -1,113 +1,114 @@ -# @rc-component/upload - -React Upload - -[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] - -[npm-image]: http://img.shields.io/npm/v/@rc-component/upload.svg?style=flat-square -[npm-url]: http://npmjs.org/package/@rc-component/upload -[travis-image]: https://img.shields.io/travis/react-component/upload/master?style=flat-square -[travis-url]: https://travis-ci.com/react-component/upload -[github-actions-image]: https://github.com/react-component/upload/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/upload/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/upload/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/upload -[download-image]: https://img.shields.io/npm/dm/@rc-component/upload.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/upload -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/upload -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/upload -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square - -## Development - +
+

@rc-component/upload

+

📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.

+

+ Ant Design +

+

Part of the Ant Design ecosystem.

+ +

+ npm version + npm downloads + CI + Codecov + bundle size + dumi +

+
+ +## Highlights + +- Supports Ajax uploads with progress, headers, credentials, and custom request overrides. +- Supports directory, drag, paste, async action, and before-upload flows. +- Exposes `abort(file)` through the component instance for active requests. +- Provides semantic `classNames` and `styles` slots for the hidden input. + +## Install + +```bash +npm install @rc-component/upload ``` -npm install -npm start -``` - -## Example -http://localhost:8000/ +## Usage -online example: https://upload.react-component.vercel.app/ +```tsx pure +import Upload from '@rc-component/upload'; + +export default () => ( + { + console.log('start', file.name); + }} + onSuccess={(response, file) => { + console.log('success', file.name, response); + }} + > + + +); +``` -## Feature +Online preview: https://upload.react-component.vercel.app/ -- support IE11+, Chrome, Firefox, Safari +## API -## install +### Upload -[![@rc-component/upload](https://nodei.co/npm/@rc-component/upload.png)](https://npmjs.org/package/@rc-component/upload) +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| `accept` | string \| AcceptConfig | - | Input accept config. | +| `action` | string \| `(file) => string \| PromiseLike` | - | Upload URL or async resolver. | +| `beforeUpload` | `(file, fileList) => BeforeUploadFileType \| Promise \| void` | - | Validate or transform before upload. Return false to stop upload. | +| `className` | string | - | Root class name. | +| `classNames` | `{ input?: string }` | - | Semantic class names. | +| `component` | React.ComponentType \| string | `'span'` | Root component. | +| `customRequest` | CustomUploadRequestOption | - | Override default request behavior. | +| `data` | object \| `(file) => object` | `{}` | Extra upload data. | +| `directory` | boolean | false | Enable directory upload. | +| `disabled` | boolean | false | Disable upload trigger. | +| `hasControlInside` | boolean | false | Whether child already contains a control element. | +| `headers` | Record | `{}` | Request headers. | +| `id` | string | - | Input id. | +| `method` | `'POST' \| 'PUT' \| 'PATCH' \| 'post' \| 'put' \| 'patch'` | `'post'` | Request method. | +| `multiple` | boolean | false | Allow multiple file selection. | +| `name` | string | `'file'` | File field name. | +| `onBatchStart` | `(fileList) => void` | - | Called when a batch starts. | +| `onError` | `(error, response, file) => void` | - | Upload error callback. | +| `onProgress` | `(event, file) => void` | - | Upload progress callback. | +| `onStart` | `(file) => void` | - | Upload start callback. | +| `onSuccess` | `(response, file, xhr) => void` | - | Upload success callback. | +| `openFileDialogOnClick` | boolean | true | Open file dialog when root is clicked. | +| `pastable` | boolean | false | Enable paste upload. | +| `prefixCls` | string | `'rc-upload'` | Prefix class name. | +| `style` | React.CSSProperties | - | Root style. | +| `styles` | `{ input?: React.CSSProperties }` | - | Semantic styles. | +| `withCredentials` | boolean | false | Send credentials with Ajax upload. | + +### Methods + +| Name | Type | Description | +| ------- | ------------------------- | ----------------------- | +| `abort` | `(file?: RcFile) => void` | Abort an active upload. | -## Usage +## Development -```js -var Upload = require('@rc-component/upload'); -var React = require('react'); -React.render(, container); +```bash +npm install +npm start +npm test +npm run tsc +npm run compile +npm run build ``` -## API +## Release -### props +```bash +npm run prepublishOnly +``` -| name | type | default | description | -| --- | --- | --- | --- | -| name | string | file | file param post to server | -| style | object | {} | root component inline style | -| className | string | - | root component className | -| disabled | boolean | false | whether disabled | -| component | "div" \| "span" | "span" | wrap component name | -| action | string | function(file): string | Promise<string> | | form action url | -| method | string | post | request method | -| directory | boolean | false | support upload whole directory | -| data | object/function(file) | | other data object to post or a function which returns a data object(a promise object which resolve a data object) | -| headers | object | {} | http headers to post, available in modern browsers | -| accept | string | | input accept attribute | -| capture | string | | input capture attribute | -| multiple | boolean | false | only support ie10+ | -| onStart | function | | start upload file | -| onError | function | | error callback | -| onSuccess | function | | success callback | -| onProgress | function | | progress callback, only for modern browsers | -| beforeUpload | function | null | before upload check, return false or a rejected Promise will stop upload, only for modern browsers | -| customRequest | function | null | provide an override for the default xhr behavior for additional customization | -| withCredentials | boolean | false | ajax upload with cookie send | -| openFileDialogOnClick | boolean | true | useful for drag only upload as it does not trigger on enter key or click event | -| pastable | boolean | false | support paste upload | - -#### onError arguments - -1. `err`: request error message -2. `response`: request response, not support on iframeUpload -3. `file`: upload file - -### onSuccess arguments - -1. `result`: response body -2. `file`: upload file -3. `xhr`: xhr header, only for modern browsers which support AJAX upload. since 2.4.0 - -### customRequest - -Allows for advanced customization by overriding default behavior in AjaxUploader. Provide your own XMLHttpRequest calls to interface with custom backend processes or interact with AWS S3 service through the aws-sdk-js package. - -customRequest callback is passed an object with: - -- `onProgress: (event: { percent: number }): void` -- `onError: (event: Error, body?: Object): void` -- `onSuccess: (body: Object): void` -- `data: Object` -- `filename: String` -- `file: File` -- `withCredentials: Boolean` -- `action: String` -- `headers: Object` - -### methods - -abort(file?: File) => void: abort the uploading file +`prepublishOnly` builds the package with Father and publishes through `rc-np`. Run `npm run gh-pages` to deploy the dumi site. ## License diff --git a/docs/examples/asyncAction.tsx b/docs/examples/asyncAction.tsx index 84a47797..daaac08a 100644 --- a/docs/examples/asyncAction.tsx +++ b/docs/examples/asyncAction.tsx @@ -1,5 +1,4 @@ /* eslint no-console:0 */ -import React from 'react'; import Upload from '@rc-component/upload'; const props = { diff --git a/docs/examples/customRequest.tsx b/docs/examples/customRequest.tsx index 2ea9953a..230af06f 100644 --- a/docs/examples/customRequest.tsx +++ b/docs/examples/customRequest.tsx @@ -1,8 +1,7 @@ /* eslint no-console:0 */ -import React from 'react'; -import axios from 'axios'; -import Upload from '@rc-component/upload'; import { UploadRequestOption } from '@/interface'; +import Upload from '@rc-component/upload'; +import axios from 'axios'; const uploadProps = { action: '/upload.do', diff --git a/docs/examples/directoryUpload.tsx b/docs/examples/directoryUpload.tsx index 19641b7f..0941f829 100644 --- a/docs/examples/directoryUpload.tsx +++ b/docs/examples/directoryUpload.tsx @@ -1,6 +1,5 @@ /* eslint no-console:0 */ -import React from 'react'; import Upload from '@rc-component/upload'; const Test = () => { diff --git a/docs/examples/drag.tsx b/docs/examples/drag.tsx index 626dfe73..4d1f8716 100644 --- a/docs/examples/drag.tsx +++ b/docs/examples/drag.tsx @@ -1,5 +1,4 @@ /* eslint no-console:0 */ -import React from 'react'; import Upload from '@rc-component/upload'; const props = { diff --git a/docs/examples/dragDirectory.tsx b/docs/examples/dragDirectory.tsx index b74c8faa..0a5e4c94 100644 --- a/docs/examples/dragDirectory.tsx +++ b/docs/examples/dragDirectory.tsx @@ -1,5 +1,4 @@ /* eslint no-console:0 */ -import React from 'react'; import Upload from '@rc-component/upload'; const props = { diff --git a/docs/examples/paste.tsx b/docs/examples/paste.tsx index 3bdc7b8b..410bdf47 100644 --- a/docs/examples/paste.tsx +++ b/docs/examples/paste.tsx @@ -1,5 +1,4 @@ /* eslint no-console:0 */ -import React from 'react'; import Upload from '@rc-component/upload'; const props = { diff --git a/docs/examples/pasteDirectory.tsx b/docs/examples/pasteDirectory.tsx index 875591d1..e5ab98f5 100644 --- a/docs/examples/pasteDirectory.tsx +++ b/docs/examples/pasteDirectory.tsx @@ -1,5 +1,4 @@ /* eslint no-console:0 */ -import React from 'react'; import Upload from '@rc-component/upload'; const props = { diff --git a/docs/index.md b/docs/index.md index eee2f149..3712ef7a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,5 @@ --- -title: @rc-component/upload +title: '@rc-component/upload' --- - \ No newline at end of file + diff --git a/package.json b/package.json index b6eb1f4f..4ad1e36d 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "@rc-component/upload", "version": "1.1.1", - "description": "upload ui component for react", + "description": "Upload UI component for React", "keywords": [ "react", "react-component", "react-upload", "upload" ], - "homepage": "http://github.com/react-component/upload", + "homepage": "https://react-component.github.io/upload", "bugs": { "url": "http://github.com/react-component/upload/issues" }, @@ -19,22 +19,25 @@ "license": "MIT", "main": "./lib/index", "module": "./es/index", + "types": "./lib/index.d.ts", "files": [ "lib", "es" ], "scripts": { + "build": "npm run compile && npm run docs:build", "compile": "father build", "coverage": "rc-test --coverage", + "deploy": "npm run gh-pages", "docs:build": "dumi build", - "docs:deploy": "npm run docs:build && gh-pages -d dist", + "docs:deploy": "gh-pages -d docs-dist", + "gh-pages": "cross-env GH_PAGES=1 npm run compile && npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", - "now-build": "npm run docs:build", "prepublishOnly": "npm run compile && rc-np", - "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", - "postpublish": "npm run docs:deploy", + "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", - "test": "rc-test" + "test": "rc-test", + "tsc": "tsc --noEmit" }, "dependencies": { "@rc-component/util": "^1.11.1", @@ -51,6 +54,7 @@ "@types/react-dom": "^19.2.2", "@umijs/fabric": "^4.0.1", "axios": "^1.9.0", + "cross-env": "^7.0.0", "dumi": "^2.1.0", "eslint": "^8.0.0", "father": "^4.0.0", diff --git a/tsconfig.json b/tsconfig.json index 604e96a2..1f8949df 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,9 +9,12 @@ "esModuleInterop": true, "paths": { "@/*": ["src/*"], - "@@/*": ["src/.umi/*"], - "@rc-component/upload": ["src/index.ts"] + "@@/*": [".dumi/tmp/*"], + "@rc-component/upload": ["src/index.ts"], + "@rc-component/upload/es": ["src"], + "@rc-component/upload/es/*": ["src/*"] } }, - "include": [".dumirc.ts", "./src/**/*.ts", "./src/**/*.tsx", "./docs/**/*.tsx"] + "include": [".dumirc.ts", "src", "tests", "docs/examples"], + "exclude": ["docs-dist", "lib", "es"] } diff --git a/vercel.json b/vercel.json index f9f49832..5f9139ef 100644 --- a/vercel.json +++ b/vercel.json @@ -1,14 +1,6 @@ { - "$schema": "https://openapi.vercel.sh/vercel.json", - "version": 2, - "name": "@rc-component/upload", - "builds": [ - { - "src": "package.json", - "use": "@vercel/static-build", - "config": { - "distDir": "dist" - } - } - ] + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" } From e0cbc6187dae00813693e62d9e402e3f7774b243 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:27:34 +0800 Subject: [PATCH 02/17] chore: address AI review feedback --- .dumirc.ts | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index 1c9ae2bd..f20f77e3 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -6,9 +6,8 @@ const publicPath = process.env.GH_PAGES ? '/upload/' : '/'; export default defineConfig({ alias: { - '@rc-component/upload$': path.resolve('src'), - '@rc-component/upload/es': path.resolve('src'), - '@rc-component/upload/es/*': path.resolve('src'), + '@rc-component/upload$': path.resolve(__dirname, 'src'), + '@rc-component/upload/es': path.resolve(__dirname, 'src'), }, mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], diff --git a/package.json b/package.json index 4ad1e36d..f670c3d7 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "deploy": "npm run gh-pages", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "gh-pages": "cross-env GH_PAGES=1 npm run compile && npm run docs:build && npm run docs:deploy", + "gh-pages": "npm run compile && cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", From 5c3b64ce69e122ee372893bd4b6dce18f55e45a5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:56:51 +0800 Subject: [PATCH 03/17] docs: standardize README release details --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 426840be..0f2aa91a 100644 --- a/README.md +++ b/README.md @@ -108,8 +108,8 @@ npm run build npm run prepublishOnly ``` -`prepublishOnly` builds the package with Father and publishes through `rc-np`. Run `npm run gh-pages` to deploy the dumi site. +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. ## License -@rc-component/upload is released under the MIT license. +@rc-component/upload is released under the [MIT](./LICENSE) license. From ac7e6d3665e9a7d66249dc8a93eaf9b1fd7296ee Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:13:59 +0800 Subject: [PATCH 04/17] ci: make surge preview non-blocking --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 1b29a17b..ad8683da 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -29,7 +29,7 @@ jobs: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist - failOnError: true + failOnError: false setCommitStatus: true build: | npm install From 94a5cd768349960b71879eb7a88c92b38409c276 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:25:44 +0800 Subject: [PATCH 05/17] ci: keep surge preview as fallback --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index ad8683da..70768bf2 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -30,7 +30,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false - setCommitStatus: true + setCommitStatus: false build: | npm install npm run build From 121a2dc306f2e88f89b412357e1da7308c06d366 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:04:06 +0800 Subject: [PATCH 06/17] docs: refine README usage and ecosystem note --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0f2aa91a..9ac1e811 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,7 @@

@rc-component/upload

+

Part of the Ant Design ecosystem.

📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.

-

- Ant Design -

-

Part of the Ant Design ecosystem.

npm version @@ -16,6 +13,7 @@

+ ## Highlights - Supports Ajax uploads with progress, headers, credentials, and custom request overrides. From 1b8ac59a167a694f1693072480dedc800a8738e1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:22:22 +0800 Subject: [PATCH 07/17] ci: isolate surge preview token --- .github/workflows/surge-preview.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 70768bf2..faf6b8bd 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -17,23 +17,26 @@ jobs: preview: runs-on: ubuntu-latest env: - SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} PREVIEW: true steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false + - name: Build preview + if: ${{ secrets.SURGE_TOKEN != '' }} + run: | + npm install + npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ env.SURGE_TOKEN != '' }} + if: ${{ secrets.SURGE_TOKEN != '' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false setCommitStatus: false - build: | - npm install - npm run build - name: Skip Surge preview - if: ${{ env.SURGE_TOKEN == '' }} + if: ${{ secrets.SURGE_TOKEN == '' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." From a183f0db0b95eba1e9a15d918e27a9b4d4f50032 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:20:39 +0800 Subject: [PATCH 08/17] docs: add Chinese README --- README.md | 2 + README.zh-CN.md | 115 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 README.zh-CN.md diff --git a/README.md b/README.md index 9ac1e811..318ebac5 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@

+

English | 简体中文

+ ## Highlights diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 00000000..1adcbb9d --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,115 @@ +
+

@rc-component/upload

+

Ant Design 生态的一部分。

+

📤 React 文件上传基础组件,支持拖拽、请求定制和上传列表。

+ +

+ npm version + npm downloads + CI + Codecov + bundle size + dumi +

+
+ +

English | 简体中文

+ + +## 特性 + +- 支持 Ajax uploads with progress, headers, credentials, and custom request overrides. +- 支持 directory, drag, paste, async action, and before-upload flows. +- 暴露 `abort(file)` through the component instance for active requests. +- 提供 semantic `classNames` and `styles` slots for the hidden input. + +## 安装 + +```bash +npm install @rc-component/upload +``` + +## 使用 + +```tsx pure +import Upload from '@rc-component/upload'; + +export default () => ( + { + console.log('start', file.name); + }} + onSuccess={(response, file) => { + console.log('success', file.name, response); + }} + > + + +); +``` + +Online preview: https://upload.react-component.vercel.app/ + +## API + +### Upload + +| 名称 | 类型 | 默认值 | 说明 | +| --- | --- | --- | --- | +| `accept` | string \| AcceptConfig | - | Input accept config. | +| `action` | string \| `(file) => string \| PromiseLike` | - | Upload URL or async resolver. | +| `beforeUpload` | `(file, fileList) => BeforeUploadFileType \| Promise \| void` | - | Validate or transform before upload. Return false to stop upload. | +| `className` | string | - | Root class name. | +| `classNames` | `{ input?: string }` | - | Semantic class names. | +| `component` | React.ComponentType \| string | `'span'` | Root component. | +| `customRequest` | CustomUploadRequestOption | - | Override default request behavior. | +| `data` | object \| `(file) => object` | `{}` | Extra upload data. | +| `directory` | boolean | false | Enable directory upload. | +| `disabled` | boolean | false | Disable upload trigger. | +| `hasControlInside` | boolean | false | Whether child already contains a control element. | +| `headers` | Record | `{}` | Request headers. | +| `id` | string | - | Input id. | +| `method` | `'POST' \| 'PUT' \| 'PATCH' \| 'post' \| 'put' \| 'patch'` | `'post'` | Request method. | +| `multiple` | boolean | false | Allow multiple file selection. | +| `name` | string | `'file'` | File field name. | +| `onBatchStart` | `(fileList) => void` | - | Called when a batch starts. | +| `onError` | `(error, response, file) => void` | - | Upload error callback. | +| `onProgress` | `(event, file) => void` | - | Upload progress callback. | +| `onStart` | `(file) => void` | - | Upload start callback. | +| `onSuccess` | `(response, file, xhr) => void` | - | Upload success callback. | +| `openFileDialogOnClick` | boolean | true | Open file dialog when root is clicked. | +| `pastable` | boolean | false | Enable paste upload. | +| `prefixCls` | string | `'rc-upload'` | Prefix class name. | +| `style` | React.CSSProperties | - | Root style. | +| `styles` | `{ input?: React.CSSProperties }` | - | Semantic styles. | +| `withCredentials` | boolean | false | Send credentials with Ajax upload. | + +### Methods + +| 名称 | 类型 | 说明 | +| ------- | ------------------------- | ----------------------- | +| `abort` | `(file?: RcFile) => void` | Abort an active upload. | + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run tsc +npm run compile +npm run build +``` + +## 发布 + +```bash +npm run prepublishOnly +``` + +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. + +## 许可证 + +@rc-component/upload is released under the [MIT](./LICENSE) license. From a9222b63d98c06dd608fb00bdab9122299841f43 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:35:12 +0800 Subject: [PATCH 09/17] docs: add Ant Design logo to README --- README.md | 1 + README.zh-CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 318ebac5..39c6ba1a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@

@rc-component/upload

Part of the Ant Design ecosystem.

+ Ant Design

📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 1adcbb9d..45828866 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,7 @@

@rc-component/upload

Ant Design 生态的一部分。

+ Ant Design

📤 React 文件上传基础组件,支持拖拽、请求定制和上传列表。

From 21d03ef829582d160222d2115be366b2df0e694c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 23:04:26 +0800 Subject: [PATCH 10/17] docs: refine bilingual README branding --- README.md | 3 +- README.zh-CN.md | 77 ++++++++++++++++++++++++------------------------- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 39c6ba1a..1cdc2f9d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

@rc-component/upload

-

Part of the Ant Design ecosystem.

- Ant Design +

Ant Design Part of the Ant Design ecosystem.

📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 45828866..bd165c87 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,7 +1,6 @@

@rc-component/upload

-

Ant Design 生态的一部分。

- Ant Design +

Ant Design Ant Design 生态的一部分。

📤 React 文件上传基础组件,支持拖拽、请求定制和上传列表。

@@ -19,10 +18,10 @@ ## 特性 -- 支持 Ajax uploads with progress, headers, credentials, and custom request overrides. -- 支持 directory, drag, paste, async action, and before-upload flows. -- 暴露 `abort(file)` through the component instance for active requests. -- 提供 semantic `classNames` and `styles` slots for the hidden input. +- 支持带进度、请求头、凭证和自定义请求覆盖的 Ajax 上传。 +- 支持目录上传、拖拽、粘贴、异步 action 和上传前处理流程。 +- 通过组件实例暴露 `abort(file)`,用于中止进行中的请求。 +- 为隐藏 input 提供语义化 `classNames` 和 `styles` 插槽。 ## 安装 @@ -50,7 +49,7 @@ export default () => ( ); ``` -Online preview: https://upload.react-component.vercel.app/ +在线预览:https://upload.react-component.vercel.app/ ## API @@ -58,39 +57,39 @@ Online preview: https://upload.react-component.vercel.app/ | 名称 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | -| `accept` | string \| AcceptConfig | - | Input accept config. | -| `action` | string \| `(file) => string \| PromiseLike` | - | Upload URL or async resolver. | -| `beforeUpload` | `(file, fileList) => BeforeUploadFileType \| Promise \| void` | - | Validate or transform before upload. Return false to stop upload. | -| `className` | string | - | Root class name. | -| `classNames` | `{ input?: string }` | - | Semantic class names. | -| `component` | React.ComponentType \| string | `'span'` | Root component. | -| `customRequest` | CustomUploadRequestOption | - | Override default request behavior. | -| `data` | object \| `(file) => object` | `{}` | Extra upload data. | -| `directory` | boolean | false | Enable directory upload. | -| `disabled` | boolean | false | Disable upload trigger. | -| `hasControlInside` | boolean | false | Whether child already contains a control element. | -| `headers` | Record | `{}` | Request headers. | -| `id` | string | - | Input id. | -| `method` | `'POST' \| 'PUT' \| 'PATCH' \| 'post' \| 'put' \| 'patch'` | `'post'` | Request method. | -| `multiple` | boolean | false | Allow multiple file selection. | -| `name` | string | `'file'` | File field name. | -| `onBatchStart` | `(fileList) => void` | - | Called when a batch starts. | -| `onError` | `(error, response, file) => void` | - | Upload error callback. | -| `onProgress` | `(event, file) => void` | - | Upload progress callback. | -| `onStart` | `(file) => void` | - | Upload start callback. | -| `onSuccess` | `(response, file, xhr) => void` | - | Upload success callback. | -| `openFileDialogOnClick` | boolean | true | Open file dialog when root is clicked. | -| `pastable` | boolean | false | Enable paste upload. | -| `prefixCls` | string | `'rc-upload'` | Prefix class name. | -| `style` | React.CSSProperties | - | Root style. | -| `styles` | `{ input?: React.CSSProperties }` | - | Semantic styles. | -| `withCredentials` | boolean | false | Send credentials with Ajax upload. | - -### Methods +| `accept` | string \| AcceptConfig | - | input accept 配置。 | +| `action` | string \| `(file) => string \| PromiseLike` | - | 上传地址或异步解析函数。 | +| `beforeUpload` | `(file, fileList) => BeforeUploadFileType \| Promise \| void` | - | 上传前校验或转换文件。返回 false 可阻止上传。 | +| `className` | string | - | 根className。 | +| `classNames` | `{ input?: string }` | - | 语义className。 | +| `component` | React.ComponentType \| string | `'span'` | 根组件。 | +| `customRequest` | CustomUploadRequestOption | - | 覆盖默认请求行为。 | +| `data` | object \| `(file) => object` | `{}` | 额外上传数据。 | +| `directory` | boolean | false | 启用目录上传。 | +| `disabled` | boolean | false | 禁用上传触发器。 | +| `hasControlInside` | boolean | false | 子节点是否已包含控制元素。 | +| `headers` | Record | `{}` | 请求头。 | +| `id` | string | - | Input id。 | +| `method` | `'POST' \| 'PUT' \| 'PATCH' \| 'post' \| 'put' \| 'patch'` | `'post'` | 请求方法。 | +| `multiple` | boolean | false | 允许多文件选择。 | +| `name` | string | `'file'` | 文件字段名。 | +| `onBatchStart` | `(fileList) => void` | - | 批量开始时调用。 | +| `onError` | `(error, response, file) => void` | - | 上传错误回调。 | +| `onProgress` | `(event, file) => void` | - | 上传进度回调。 | +| `onStart` | `(file) => void` | - | 上传开始回调。 | +| `onSuccess` | `(response, file, xhr) => void` | - | 上传成功回调。 | +| `openFileDialogOnClick` | boolean | true | 点击根节点时打开文件选择框。 | +| `pastable` | boolean | false | 启用粘贴上传。 | +| `prefixCls` | string | `'rc-upload'` | 前缀className。 | +| `style` | React.CSSProperties | - | 根样式。 | +| `styles` | `{ input?: React.CSSProperties }` | - | 语义化样式。 | +| `withCredentials` | boolean | false | 随 Ajax 上传发送凭证。 | + +### 方法 | 名称 | 类型 | 说明 | | ------- | ------------------------- | ----------------------- | -| `abort` | `(file?: RcFile) => void` | Abort an active upload. | +| `abort` | `(file?: RcFile) => void` | 中止进行中的上传。 | ## 本地开发 @@ -109,8 +108,8 @@ npm run build npm run prepublishOnly ``` -The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. +包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。 ## 许可证 -@rc-component/upload is released under the [MIT](./LICENSE) license. +@rc-component/upload 基于 [MIT](./LICENSE) 许可证发布。 From febbe3676c67662b23f6c9d702361877bb675124 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 01:28:45 +0800 Subject: [PATCH 11/17] chore: standardize rc tooling and docs --- .dumirc.ts | 2 +- README.md | 11 +++++++++++ README.zh-CN.md | 11 +++++++++++ package.json | 30 +++++++++++++++--------------- tsconfig.json | 36 ++++++++++++++++++++++++++++-------- 5 files changed, 66 insertions(+), 24 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index f20f77e3..40ccb7c7 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'dumi'; import path from 'path'; const basePath = process.env.GH_PAGES ? '/upload/' : '/'; -const publicPath = process.env.GH_PAGES ? '/upload/' : '/'; +const publicPath = basePath; export default defineConfig({ alias: { diff --git a/README.md b/README.md index 1cdc2f9d..7224044e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,17 @@ export default () => ( Online preview: https://upload.react-component.vercel.app/ +## Examples + +Run the local dumi site: + +```bash +npm install +npm start +``` + +Then open `http://localhost:8000`. + ## API ### Upload diff --git a/README.zh-CN.md b/README.zh-CN.md index bd165c87..bc865a7e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -51,6 +51,17 @@ export default () => ( 在线预览:https://upload.react-component.vercel.app/ +## 示例 + +运行本地 dumi 站点: + +```bash +npm install +npm start +``` + +然后打开 `http://localhost:8000`。 + ## API ### Upload diff --git a/package.json b/package.json index f670c3d7..14faa029 100644 --- a/package.json +++ b/package.json @@ -46,25 +46,25 @@ "devDependencies": { "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", - "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^16.2.0", - "@types/jest": "^30.0.0", - "@types/node": "^25.0.1", - "@types/react": "^19.2.2", - "@types/react-dom": "^19.2.2", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^15.0.7", + "@types/jest": "^29.5.14", + "@types/node": "^26.0.1", + "@types/react": "^18.3.31", + "@types/react-dom": "^18.3.7", "@umijs/fabric": "^4.0.1", "axios": "^1.9.0", - "cross-env": "^7.0.0", - "dumi": "^2.1.0", - "eslint": "^8.0.0", - "father": "^4.0.0", - "gh-pages": "^6.1.1", - "rc-test": "^7.0.13", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "cross-env": "^10.1.0", + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "father": "^4.6.23", + "gh-pages": "^6.3.0", + "rc-test": "^7.1.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", "regenerator-runtime": "^0.14.1", "sinon": "^9.0.2", - "typescript": "^5.3.3" + "typescript": "^5.9.3" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/tsconfig.json b/tsconfig.json index 1f8949df..27cc41ca 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,13 +8,33 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/upload": ["src/index.ts"], - "@rc-component/upload/es": ["src"], - "@rc-component/upload/es/*": ["src/*"] - } + "@/*": [ + "src/*" + ], + "@@/*": [ + ".dumi/tmp/*" + ], + "@rc-component/upload": [ + "src/index.ts" + ], + "@rc-component/upload/es": [ + "src" + ], + "@rc-component/upload/es/*": [ + "src/*" + ] + }, + "ignoreDeprecations": "5.0" }, - "include": [".dumirc.ts", "src", "tests", "docs/examples"], - "exclude": ["docs-dist", "lib", "es"] + "include": [ + ".dumirc.ts", + "src", + "tests", + "docs/examples" + ], + "exclude": [ + "docs-dist", + "lib", + "es" + ] } From 6f019d2a0c49fbe24c6a10728940969bad30d9d2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:01:09 +0800 Subject: [PATCH 12/17] chore: address standardization review comments --- .github/workflows/surge-preview.yml | 16 +++++++++++++--- README.md | 2 +- README.zh-CN.md | 8 ++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index faf6b8bd..cb6c8c4a 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -22,13 +22,23 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false + - name: Check Surge token + id: surge-token + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + run: | + if [ -n "$SURGE_TOKEN" ]; then + echo "enabled=true" >> "$GITHUB_OUTPUT" + else + echo "enabled=false" >> "$GITHUB_OUTPUT" + fi - name: Build preview - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} run: | npm install npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} env: SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: @@ -38,5 +48,5 @@ jobs: failOnError: false setCommitStatus: false - name: Skip Surge preview - if: ${{ secrets.SURGE_TOKEN == '' }} + if: ${{ steps.surge-token.outputs.enabled != 'true' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/README.md b/README.md index 7224044e..f3b92b67 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Then open `http://localhost:8000`. | Name | Type | Description | | ------- | ------------------------- | ----------------------- | -| `abort` | `(file?: RcFile) => void` | Abort an active upload. | +| `abort` | `(file: RcFile) => void` | Abort an active upload. | ## Development diff --git a/README.zh-CN.md b/README.zh-CN.md index bc865a7e..f465e081 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -71,8 +71,8 @@ npm start | `accept` | string \| AcceptConfig | - | input accept 配置。 | | `action` | string \| `(file) => string \| PromiseLike` | - | 上传地址或异步解析函数。 | | `beforeUpload` | `(file, fileList) => BeforeUploadFileType \| Promise \| void` | - | 上传前校验或转换文件。返回 false 可阻止上传。 | -| `className` | string | - | 根className。 | -| `classNames` | `{ input?: string }` | - | 语义className。 | +| `className` | string | - | 根 className。 | +| `classNames` | `{ input?: string }` | - | 语义化类名。 | | `component` | React.ComponentType \| string | `'span'` | 根组件。 | | `customRequest` | CustomUploadRequestOption | - | 覆盖默认请求行为。 | | `data` | object \| `(file) => object` | `{}` | 额外上传数据。 | @@ -91,7 +91,7 @@ npm start | `onSuccess` | `(response, file, xhr) => void` | - | 上传成功回调。 | | `openFileDialogOnClick` | boolean | true | 点击根节点时打开文件选择框。 | | `pastable` | boolean | false | 启用粘贴上传。 | -| `prefixCls` | string | `'rc-upload'` | 前缀className。 | +| `prefixCls` | string | `'rc-upload'` | 前缀 className。 | | `style` | React.CSSProperties | - | 根样式。 | | `styles` | `{ input?: React.CSSProperties }` | - | 语义化样式。 | | `withCredentials` | boolean | false | 随 Ajax 上传发送凭证。 | @@ -100,7 +100,7 @@ npm start | 名称 | 类型 | 说明 | | ------- | ------------------------- | ----------------------- | -| `abort` | `(file?: RcFile) => void` | 中止进行中的上传。 | +| `abort` | `(file: RcFile) => void` | 中止进行中的上传。 | ## 本地开发 From 8ae34edee7356eb3290a2cf15a5cb3963746a11d Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:24:56 +0800 Subject: [PATCH 13/17] ci: update GitHub Actions versions --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 23f424a8..6999184b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 with: category: '/language:${{ matrix.language }}' From c1861ae88f69489a995117fd48933e7fbc3e85d9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:30:31 +0800 Subject: [PATCH 14/17] ci: use resolvable CodeQL action ref --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6999184b..23f424a8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: category: '/language:${{ matrix.language }}' From 0bd3ea3b5ca054eedf75763bbd2b2bcfc3b47fe1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:03:34 +0800 Subject: [PATCH 15/17] ci: use actions checkout v7 --- .github/workflows/codeql.yml | 2 +- .github/workflows/react-doctor.yml | 2 +- .github/workflows/surge-preview.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 23f424a8..82242dfd 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + uses: actions/checkout@v7 with: persist-credentials: false diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml index f68281c8..097eb883 100644 --- a/.github/workflows/react-doctor.yml +++ b/.github/workflows/react-doctor.yml @@ -20,7 +20,7 @@ jobs: react-doctor: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: fetch-depth: 0 persist-credentials: false diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index cb6c8c4a..ebfecd53 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -19,7 +19,7 @@ jobs: env: PREVIEW: true steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: persist-credentials: false - name: Check Surge token From fe74f77d7fd8967ce8a9e0677c59a535dac1fcdf Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:32:41 +0800 Subject: [PATCH 16/17] chore: standardize package metadata --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 14faa029..3277a233 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ ], "homepage": "https://react-component.github.io/upload", "bugs": { - "url": "http://github.com/react-component/upload/issues" + "url": "https://github.com/react-component/upload/issues" }, "repository": { "type": "git", - "url": "git@github.com:react-component/upload.git" + "url": "https://github.com/react-component/upload.git" }, "license": "MIT", "main": "./lib/index", @@ -69,5 +69,8 @@ "peerDependencies": { "react": ">=16.9.0", "react-dom": ">=16.9.0" + }, + "publishConfig": { + "access": "public" } } From 27edb6289fc392867fc544a29b14c23200536ac0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:39:02 +0800 Subject: [PATCH 17/17] ci: standardize dependabot updates --- .github/dependabot.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 07575c02..3b730ef9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,6 +3,17 @@ updates: - package-ecosystem: npm directory: '/' schedule: - interval: daily + interval: weekly + day: monday time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai open-pull-requests-limit: 10