npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rc-component/upload

v1.2.0

Published

Upload UI component for React

Readme

特性

  • 支持带进度、请求头、凭证和自定义请求覆盖的 Ajax 上传。
  • 支持目录上传、拖拽、粘贴、异步 action 和上传前处理流程。
  • 通过组件实例暴露 abort(file),用于中止进行中的请求。
  • 为隐藏 input 提供语义化 classNamesstyles 插槽。

安装

npm install @rc-component/upload

使用

import Upload from '@rc-component/upload';

export default () => (
  <Upload
    action="/upload"
    onStart={file => {
      console.log('start', file.name);
    }}
    onSuccess={(response, file) => {
      console.log('success', file.name, response);
    }}
  >
    <button type="button">Upload</button>
  </Upload>
);

在线预览:https://upload.react-component.vercel.app/

示例

运行本地 dumi 站点:

npm install
npm start

然后打开 http://localhost:8000

API

Upload

| 名称 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | accept | string | AcceptConfig | - | input accept 配置。 | | action | string | (file) => string \| PromiseLike<string> | - | 上传地址或异步解析函数。 | | beforeUpload | (file, fileList) => BeforeUploadFileType \| Promise<void \| BeforeUploadFileType> \| 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<string, string> | {} | 请求头。 | | 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 | 中止进行中的上传。 | | retry | (file: RcFile) => void | 重试特定文件的上传。 |

本地开发

npm install
npm start
npm test
npm run tsc
npm run compile
npm run build

dumi 站点默认运行在 http://localhost:8000

发布

npm run prepublishOnly

包构建完成后,发布流程由 @rc-component/np 通过 rc-np 命令处理。

许可证

@rc-component/upload 基于 MIT 许可证发布。