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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hi-ui/upload

v4.2.3

Published

A sub-package for @hi-ui/hiui.

Downloads

235

Readme

Upload 上传

用来上传多种格式的附件

何时使用

上传本地文档

上传图片附件或照片墙

使用示例

Upload Props

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------- | ----------------------------------------- | | type | 上传组件类型 | string | default | drag | pictureCard | avatar | photo | default | | accept | 接收上传的文件类型, 用逗号隔开的 MIME 类型列表,参考 MDN-MIME 类型 | string | - | - | | content | 上传按钮文案,仅在 type === 'default' 的时候有效 | ReactNode | - | 本地上传 | | tips | 上传文件信息提示 | string | ReactNode | - | 本地上传 | | maxSize | 接收上传的文件体积上限(单位:KB) | number | - | - | | maxCount | 接收上传的文件最大数量 | number | - | - | | uploadAction | 必选,上传的地址 | (file) => Promise | string | - | - | | data | 除了上传文件外的其它 form 参数 | object | - | - | | name | 发到后台文件参数名 | string | - | file | | disabled | 是否禁用 | boolean | true | false | false | | headers | 设置上传的请求头部 | object | - | { 'Content-type': 'multipart/form-data' } | | withCredentials | 上传请求时是否携带 cookie | boolean | true | false | false | | showUploadList | 是否展示 uploadList, 仅在 type === 'default' 和 type === 'pictureCard' 时有效 | boolean | true | false | true | | multiple | 是否支持多选文件 | boolean | true | false | false | | defaultFileList | 默认已上传文件列表 | File[] | - | [] | | fileList | 已上传文件列表(受控) | File[] | - | - | | beforeUpload | 上传文件前的钩子,返回 true 继续上传,其他终止上传 | (files: File[], fileList: File[]) => boolean | - | () => true | | customUpload | 自定义上传,此时不会再触发 onChange,所有上传逻辑转移到该函数 | (files: Files[]) => void | - | - | | loading | 文件上传按钮是否 loading,为 true 时按钮不可点击。仅在 type='default' 时有效 | boolean | true | false | false | | photoSize | 设置上传按钮大小,仅在 type === 'photo' 时有效 | string | 'sm' | 'md' | 'lg' | 'md' |

Events

| 名称 | 说明 | 类型 | 参数 | 返回值 | | ---------- | ------------------------ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | | onChange | 上传回调 | (file: File, fileList: File[], response: object) => boolean | file: 上传的文件对象 fileList: 当前已上传文件列表集合 response: 响应对象 | boolean | Promise<boolean>: 返回 false 则已上传文件列表不展示该文件 | | onRemove | 删除上传的文件 | (file: File, fileList: File[], index: number) => boolean | file: 移除的文件对象, fileList: 当前已上传文件列表集合, index 索引 | boolean | Promise<boolean>: 返回 false 则不可删除,返回 true 时在前端删除文件 | | onDownload | 点击已上传的文件时的回调 | (file: File) => void | file: 点击的文件对象 | - |

Type

File

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ----------- | ------------ | ------ | ----------------------------------- | ------ | | fileId | 上传文件 id | string | - | - | | fileType | 文件类型 | string | - | - | | name | 文件名 | string | - | - | | uploadState | 上传文件状态 | string | 'success' | 'uploading' | 'error' | - | | url | 上传文件地址 | string | - | - |

CHANGELOG

| 参数 | 变更类型 | 变更内容 | 解决的问题 | | ------------------- | ------------------------------- | ---------- | ---------------------------- | | propName | feature | deprecated | update | 变更了什么 | 之前是什么样子,解决什么问题 | | ---- | ---- | ---- | ---- | | File.abort | feature | - | 功能强化 | | File.progressNumber | feature | - | 功能强化 |