From 999dd677857c7245e53ee777ecb9b7993ab53d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Sun, 28 Sep 2025 15:16:15 +0800 Subject: [PATCH 1/5] chore: migrate to @rc-component namespace and update --- .dumirc | 4 +- README.md | 82 ++++++++++++++----------------- docs/examples/asyncAction.tsx | 2 +- docs/examples/beforeUpload.tsx | 2 +- docs/examples/customRequest.tsx | 2 +- docs/examples/directoryUpload.tsx | 2 +- docs/examples/drag.tsx | 2 +- docs/examples/dragDirectory.tsx | 2 +- docs/examples/paste.tsx | 2 +- docs/examples/pasteDirectory.tsx | 2 +- docs/examples/simple.tsx | 2 +- now.json | 11 ----- package.json | 14 +++--- tsconfig.json | 21 ++------ 14 files changed, 60 insertions(+), 90 deletions(-) delete mode 100644 now.json diff --git a/.dumirc b/.dumirc index 2d5ba2bc..ba410f77 100644 --- a/.dumirc +++ b/.dumirc @@ -3,8 +3,8 @@ import path from 'path'; export default defineConfig({ alias: { - 'rc-upload$': path.resolve('src'), - 'rc-upload/es': path.resolve('src'), + '@rc-component/upload$': path.resolve('src'), + '@rc-component/upload/es': path.resolve('src'), }, mfsu: false, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], diff --git a/README.md b/README.md index 29c60c37..57314f41 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,7 @@ 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 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-upload.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-upload @@ -43,7 +38,7 @@ online example: https://upload.react-component.vercel.app/ ## Feature -* support IE11+, Chrome, Firefox, Safari +- support IE11+, Chrome, Firefox, Safari ## install @@ -52,7 +47,7 @@ online example: https://upload.react-component.vercel.app/ ## Usage ```js -var Upload = require('rc-upload'); +var Upload = require('@rc-component/upload'); var React = require('react'); React.render(, container); ``` @@ -61,30 +56,30 @@ React.render(, container); ### props -|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 | +| 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 @@ -96,9 +91,7 @@ React.render(, container); 1. `result`: response body 2. `file`: upload file -3. `xhr`: xhr header, only for modern browsers which support AJAX upload. since - 2.4.0 - +3. `xhr`: xhr header, only for modern browsers which support AJAX upload. since 2.4.0 ### customRequest @@ -106,16 +99,15 @@ Allows for advanced customization by overriding default behavior in AjaxUploader 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` - +- `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 diff --git a/docs/examples/asyncAction.tsx b/docs/examples/asyncAction.tsx index c523cf3c..84a47797 100644 --- a/docs/examples/asyncAction.tsx +++ b/docs/examples/asyncAction.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ import React from 'react'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; const props = { action: () => { diff --git a/docs/examples/beforeUpload.tsx b/docs/examples/beforeUpload.tsx index bb27816c..38f645a1 100644 --- a/docs/examples/beforeUpload.tsx +++ b/docs/examples/beforeUpload.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import type { Action, RcFile } from '@/interface'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; const props = { action: '/upload.do' as Action, diff --git a/docs/examples/customRequest.tsx b/docs/examples/customRequest.tsx index afe58fd5..2ea9953a 100644 --- a/docs/examples/customRequest.tsx +++ b/docs/examples/customRequest.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; import axios from 'axios'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; import { UploadRequestOption } from '@/interface'; const uploadProps = { diff --git a/docs/examples/directoryUpload.tsx b/docs/examples/directoryUpload.tsx index c2c749ba..19641b7f 100644 --- a/docs/examples/directoryUpload.tsx +++ b/docs/examples/directoryUpload.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; const Test = () => { const uploaderProps = { diff --git a/docs/examples/drag.tsx b/docs/examples/drag.tsx index caf08e4b..626dfe73 100644 --- a/docs/examples/drag.tsx +++ b/docs/examples/drag.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ import React from 'react'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; const props = { action: '/upload.do', diff --git a/docs/examples/dragDirectory.tsx b/docs/examples/dragDirectory.tsx index 487e323f..b74c8faa 100644 --- a/docs/examples/dragDirectory.tsx +++ b/docs/examples/dragDirectory.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ import React from 'react'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; const props = { action: '/upload.do', diff --git a/docs/examples/paste.tsx b/docs/examples/paste.tsx index b7c95065..3bdc7b8b 100644 --- a/docs/examples/paste.tsx +++ b/docs/examples/paste.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ import React from 'react'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; const props = { action: '/upload.do', diff --git a/docs/examples/pasteDirectory.tsx b/docs/examples/pasteDirectory.tsx index 3bb7aefc..875591d1 100644 --- a/docs/examples/pasteDirectory.tsx +++ b/docs/examples/pasteDirectory.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ import React from 'react'; -import Upload from 'rc-upload'; +import Upload from '@rc-component/upload'; const props = { action: '/upload.do', diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx index c11d91a6..cffb2a6a 100644 --- a/docs/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -1,6 +1,6 @@ /* eslint no-console:0 */ -import Upload, { type UploadProps } from 'rc-upload'; +import Upload, { type UploadProps } from '@rc-component/upload'; import React from 'react'; const style = ` diff --git a/now.json b/now.json deleted file mode 100644 index c3e54f87..00000000 --- a/now.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": 2, - "name": "rc-upload", - "builds": [ - { - "src": "package.json", - "use": "@now/static-build", - "config": { "distDir": "dist" } - } - ] -} diff --git a/package.json b/package.json index 4956c387..f2db017f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "rc-upload", - "version": "4.11.0", + "name": "@rc-component/upload", + "version": "1.0.0", "description": "upload ui component for react", "keywords": [ "react", @@ -30,7 +30,7 @@ "docs:deploy": "npm run docs:build && gh-pages -d dist", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "now-build": "npm run docs:build", - "prepublishOnly": "npm run compile && np --yolo --no-publish", + "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", "postpublish": "npm run docs:deploy", "start": "dumi dev", @@ -38,11 +38,12 @@ }, "dependencies": { "@babel/runtime": "^7.18.3", - "classnames": "^2.2.5", - "rc-util": "^5.2.0" + "@rc-component/util": "^1.3.0", + "classnames": "^2.2.5" }, "devDependencies": { - "@rc-component/father-plugin": "^1.0.0", + "@rc-component/father-plugin": "^2.0.2", + "@rc-component/np": "^1.0.4", "@testing-library/jest-dom": "^6.1.5", "@testing-library/react": "^16.2.0", "@types/jest": "^30.0.0", @@ -58,7 +59,6 @@ "father": "^4.0.0", "fs-extra": "^11.2.0", "gh-pages": "^6.1.1", - "np": "^10.0.7", "raf": "^3.4.0", "rc-test": "^7.0.13", "react": "^18.0.0", diff --git a/tsconfig.json b/tsconfig.json index 3ea7e93a..604e96a2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,21 +8,10 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": [ - "src/*" - ], - "@@/*": [ - "src/.umi/*" - ], - "rc-upload": [ - "src/index.ts" - ] + "@/*": ["src/*"], + "@@/*": ["src/.umi/*"], + "@rc-component/upload": ["src/index.ts"] } }, - "include": [ - ".dumirc.ts", - "./src/**/*.ts", - "./src/**/*.tsx", - "./docs/**/*.tsx" - ] -} \ No newline at end of file + "include": [".dumirc.ts", "./src/**/*.ts", "./src/**/*.tsx", "./docs/**/*.tsx"] +} From 61ffe3c35e02599517a3bad6fe0a42ae0f60325b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Sun, 28 Sep 2025 15:47:14 +0800 Subject: [PATCH 2/5] docs: midify readme --- README.md | 18 +++++++++--------- docs/index.md | 2 +- package.json | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 57314f41..cdaae485 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# rc-upload +# @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-upload.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-upload +[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/workflows/CI/badge.svg @@ -16,10 +16,10 @@ React Upload [david-image]: https://david-dm.org/react-component/upload/status.svg?style=flat-square [david-dev-url]: https://david-dm.org/react-component/upload?type=dev [david-dev-image]: https://david-dm.org/react-component/upload/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/rc-upload.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-upload -[bundlephobia-url]: https://bundlephobia.com/package/rc-upload -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-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 @@ -42,7 +42,7 @@ online example: https://upload.react-component.vercel.app/ ## install -[![rc-upload](https://nodei.co/npm/rc-upload.png)](https://npmjs.org/package/rc-upload) +[![@rc-component/upload](https://nodei.co/npm/@rc-component/upload.png)](https://npmjs.org/package/@rc-component/upload) ## Usage @@ -115,4 +115,4 @@ abort(file?: File) => void: abort the uploading file ## License -rc-upload is released under the MIT license. +@rc-component/upload is released under the MIT license. diff --git a/docs/index.md b/docs/index.md index 5d590b81..eee2f149 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,5 @@ --- -title: rc-upload +title: @rc-component/upload --- \ No newline at end of file diff --git a/package.json b/package.json index f2db017f..5ff9af70 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "test": "rc-test" }, "dependencies": { - "@babel/runtime": "^7.18.3", "@rc-component/util": "^1.3.0", "classnames": "^2.2.5" }, From dc176be898d72ec4ac20bd2f5b8a73d089b8001a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Sun, 28 Sep 2025 16:08:04 +0800 Subject: [PATCH 3/5] feat: rc-util->@rc-component/util --- src/AjaxUploader.tsx | 2 +- src/attr-accept.ts | 2 +- tests/uploader.spec.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AjaxUploader.tsx b/src/AjaxUploader.tsx index 6ba8fc10..f5551e99 100644 --- a/src/AjaxUploader.tsx +++ b/src/AjaxUploader.tsx @@ -1,6 +1,6 @@ /* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */ import clsx from 'classnames'; -import pickAttrs from 'rc-util/lib/pickAttrs'; +import pickAttrs from '@rc-component/util/lib/pickAttrs'; import React, { Component } from 'react'; import attrAccept from './attr-accept'; import type { diff --git a/src/attr-accept.ts b/src/attr-accept.ts index 7d1caec4..c9da0266 100644 --- a/src/attr-accept.ts +++ b/src/attr-accept.ts @@ -1,4 +1,4 @@ -import warning from 'rc-util/lib/warning'; +import warning from '@rc-component/util/lib/warning'; import type { RcFile } from './interface'; export default (file: RcFile, acceptedFiles: string | string[]) => { diff --git a/tests/uploader.spec.tsx b/tests/uploader.spec.tsx index 71eb777e..c6883684 100644 --- a/tests/uploader.spec.tsx +++ b/tests/uploader.spec.tsx @@ -1,5 +1,5 @@ import { fireEvent, render } from '@testing-library/react'; -import { resetWarned } from 'rc-util/lib/warning'; +import { resetWarned } from '@rc-component/util/lib/warning'; import React from 'react'; import sinon from 'sinon'; import { format } from 'util'; From c0cf1a612f2905c09407a9221d7c09bda0701aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Sun, 28 Sep 2025 16:11:29 +0800 Subject: [PATCH 4/5] feat: modify rc-util path in component --- src/attr-accept.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attr-accept.ts b/src/attr-accept.ts index c9da0266..d16c2b69 100644 --- a/src/attr-accept.ts +++ b/src/attr-accept.ts @@ -1,4 +1,4 @@ -import warning from '@rc-component/util/lib/warning'; +import { warning } from '@rc-component/util'; import type { RcFile } from './interface'; export default (file: RcFile, acceptedFiles: string | string[]) => { From 60bd5c51330c0ed2c85ffcdd7b62e54885693d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Sun, 28 Sep 2025 16:13:39 +0800 Subject: [PATCH 5/5] docs: format --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cdaae485..59e0a9ce 100644 --- a/README.md +++ b/README.md @@ -57,12 +57,12 @@ React.render(, container); ### props | 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 | +| 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 |