diff --git a/.dumirc b/.dumirc.ts
similarity index 53%
rename from .dumirc
rename to .dumirc.ts
index ba410f77..40ccb7c7 100644
--- a/.dumirc
+++ b/.dumirc.ts
@@ -1,10 +1,13 @@
import { defineConfig } from 'dumi';
import path from 'path';
+const basePath = process.env.GH_PAGES ? '/upload/' : '/';
+const publicPath = basePath;
+
export default defineConfig({
alias: {
- '@rc-component/upload$': 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'],
@@ -12,4 +15,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/.fatherrc.ts b/.fatherrc.ts
new file mode 100644
index 00000000..96268ae1
--- /dev/null
+++ b/.fatherrc.ts
@@ -0,0 +1,5 @@
+import { defineConfig } from 'father';
+
+export default defineConfig({
+ plugins: ['@rc-component/father-plugin'],
+});
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..3b730ef9 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,23 +1,19 @@
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: 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
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 00000000..82242dfd
--- /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@v7
+ 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..097eb883
--- /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@v7
+ 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..4c2f17ed
--- /dev/null
+++ b/.github/workflows/surge-preview.yml
@@ -0,0 +1,54 @@
+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
+
+jobs:
+ preview:
+ runs-on: ubuntu-latest
+ concurrency:
+ group: surge-preview-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+ env:
+ PREVIEW: true
+ steps:
+ - uses: actions/checkout@v7
+ 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: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ run: |
+ npm install
+ npm run build
+ - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec
+ if: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ env:
+ SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
+ with:
+ surge_token: ${{ env.SURGE_TOKEN }}
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ dist: docs-dist
+ failOnError: false
+ setCommitStatus: false
+ - name: Skip Surge preview
+ if: ${{ steps.surge-token.outputs.enabled != 'true' }}
+ run: echo "SURGE_TOKEN is not configured; skip Surge preview."
diff --git a/.gitignore b/.gitignore
index e1117e8f..f0882bba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
*.iml
*.log
+*.log.*
.idea/
.ipr
.iws
@@ -24,22 +25,27 @@ 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
+bun.lockb
+bun.lock
+coverage
.dumi/tmp
.dumi/tmp-production
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100755
index 00000000..2312dc58
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1 @@
+npx lint-staged
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000..c466d872
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,14 @@
+node_modules
+coverage
+docs-dist
+dist
+es
+lib
+.dumi/tmp
+.dumi/tmp-production
+.vercel
+package-lock.json
+pnpm-lock.yaml
+yarn.lock
+bun.lockb
+*.log
diff --git a/README.md b/README.md
index 0ab56f7e..ae8ad8dc 100644
--- a/README.md
+++ b/README.md
@@ -1,114 +1,128 @@
-# @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
+
+
@rc-component/upload
+
Part of the Ant Design ecosystem.
+
📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.
-## Development
+
+
+
+
+
+
+
+
+
-```
-npm install
-npm start
-```
+English | 简体中文
-## Example
-http://localhost:8000/
+## Highlights
-online example: https://upload.react-component.vercel.app/
+- 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.
-## Feature
+## Install
-- support IE11+, Chrome, Firefox, Safari
+```bash
+npm install @rc-component/upload
+```
-## install
+## Usage
-[](https://npmjs.org/package/@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);
+ }}
+ >
+
+
+);
+```
-## Usage
+Online preview: https://upload.react-component.vercel.app/
+
+## Examples
-```js
-var Upload = require('@rc-component/upload');
-var React = require('react');
-React.render(, container);
+Run the local dumi site:
+
+```bash
+npm install
+npm start
```
+Then open `http://localhost:8000`.
+
## API
-### props
+### Upload
-| name | type | default | description |
+| 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
+| `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. |
+
+## Development
+
+```bash
+npm install
+npm start
+npm test
+npm run tsc
+npm run compile
+npm run build
+```
+
+The dumi site runs at `http://localhost:8000` by default.
+
+## Release
+
+```bash
+npm run prepublishOnly
+```
+
+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.
diff --git a/README.zh-CN.md b/README.zh-CN.md
new file mode 100644
index 00000000..fa00a14b
--- /dev/null
+++ b/README.zh-CN.md
@@ -0,0 +1,128 @@
+
+
@rc-component/upload
+
Ant Design 生态的一部分。
+
📤 React 文件上传基础组件,支持拖拽、请求定制和上传列表。
+
+
+
+
+
+
+
+
+
+
+
+English | 简体中文
+
+
+## 特性
+
+- 支持带进度、请求头、凭证和自定义请求覆盖的 Ajax 上传。
+- 支持目录上传、拖拽、粘贴、异步 action 和上传前处理流程。
+- 通过组件实例暴露 `abort(file)`,用于中止进行中的请求。
+- 为隐藏 input 提供语义化 `classNames` 和 `styles` 插槽。
+
+## 安装
+
+```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);
+ }}
+ >
+
+
+);
+```
+
+在线预览:https://upload.react-component.vercel.app/
+
+## 示例
+
+运行本地 dumi 站点:
+
+```bash
+npm install
+npm start
+```
+
+然后打开 `http://localhost:8000`。
+
+## API
+
+### Upload
+
+| 名称 | 类型 | 默认值 | 说明 |
+| --- | --- | --- | --- |
+| `accept` | string \| AcceptConfig | - | input accept 配置。 |
+| `action` | string \| `(file) => string \| PromiseLike` | - | 上传地址或异步解析函数。 |
+| `beforeUpload` | `(file, fileList) => BeforeUploadFileType \| Promise \| void` | - | 上传前校验或转换文件。返回 false 可阻止上传。 |
+| `className` | string | - | 根 className。 |
+| `classNames` | `{ input?: string }` | - | 语义化类名。 |
+| `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` | 中止进行中的上传。 |
+
+## 本地开发
+
+```bash
+npm install
+npm start
+npm test
+npm run tsc
+npm run compile
+npm run build
+```
+
+dumi 站点默认运行在 `http://localhost:8000`。
+
+## 发布
+
+```bash
+npm run prepublishOnly
+```
+
+包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。
+
+## 许可证
+
+@rc-component/upload 基于 [MIT](./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..ceb6737a 100644
--- a/package.json
+++ b/package.json
@@ -1,40 +1,44 @@
{
"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"
+ "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",
"module": "./es/index",
+ "types": "./es/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": "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",
- "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",
+ "prepare": "husky"
},
"dependencies": {
"@rc-component/util": "^1.11.1",
@@ -42,28 +46,38 @@
},
"devDependencies": {
"@rc-component/father-plugin": "^2.2.0",
+ "prettier": "^3.9.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",
- "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",
+ "husky": "^9.1.7",
+ "lint-staged": "^16.4.0"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
+ },
+ "publishConfig": {
+ "access": "public"
+ },
+ "lint-staged": {
+ "*": "prettier --write --ignore-unknown"
}
}
diff --git a/tsconfig.json b/tsconfig.json
index 604e96a2..d4e3e1a0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,10 +8,34 @@
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
- "@/*": ["src/*"],
- "@@/*": ["src/.umi/*"],
- "@rc-component/upload": ["src/index.ts"]
- }
+ "@/*": [
+ "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/**/*.ts", "./src/**/*.tsx", "./docs/**/*.tsx"]
+ "include": [
+ ".dumirc.ts",
+ ".fatherrc.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"
}