{"id":20237415,"url":"https://github.com/react-widget/upload","last_synced_at":"2025-03-03T14:30:09.930Z","repository":{"id":57347724,"uuid":"277103950","full_name":"react-widget/upload","owner":"react-widget","description":"https://react-widget.github.io/upload/","archived":false,"fork":false,"pushed_at":"2020-07-05T02:41:35.000Z","size":244,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T01:48:26.997Z","etag":null,"topics":["react-upload","react-widget"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/react-widget.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-04T12:17:48.000Z","updated_at":"2020-07-05T04:16:58.000Z","dependencies_parsed_at":"2022-08-28T01:40:20.037Z","dependency_job_id":null,"html_url":"https://github.com/react-widget/upload","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-widget%2Fupload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-widget%2Fupload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-widget%2Fupload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-widget%2Fupload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react-widget","download_url":"https://codeload.github.com/react-widget/upload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241681828,"owners_count":20002383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react-upload","react-widget"],"created_at":"2024-11-14T08:26:54.449Z","updated_at":"2025-03-03T14:30:09.897Z","avatar_url":"https://github.com/react-widget.png","language":"TypeScript","readme":"# react-widget-upload\n\nUpload基础组件\n\n\n## 安装\n\n```\nnpm install --save react-widget-upload\n```\n\n## 使用\n\n[![Edit react-widget-upload](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/winter-morning-7uuhn?fontsize=14\u0026hidenavigation=1\u0026theme=dark)\n\n```js\nimport Upload from 'react-widget-upload';\nimport 'react-widget-upload/style';\n\n\u003cUpload onChange={files =\u003e {...}}\u003e选择文件\u003c/Upload\u003e;\n\n```\n\n### Interfaces\n\n```ts\nexport interface RWFile extends File {\n    webkitRelativePath?: string;\n}\nexport interface UploadProps extends Omit\u003cReact.HTMLAttributes\u003cany\u003e, \"onChange\"\u003e {\n    /** 组件样式前缀 */\n    prefixCls?: string;\n    /** 组件标签 */\n    tagName?: string;\n    /** input name属性 */\n    name?: string;\n    /** input accept */\n    accept?: string;\n    /** input multiple */\n    multiple?: boolean;\n    /** input key，用于部分情况下重新创建input */\n    inputKey?: React.Key;\n    /** 是否支持文件夹上传 */\n    directory?: boolean;\n    /** 禁用 */\n    disabled?: boolean;\n    /** 禁用，相比disabled只是默认样式不同 */\n    readOnly?: boolean;\n    /** 点击时打开系统文件选择窗口 */\n    openFileDialogOnClick?: boolean;\n    /** 是否支持拖拽上传 */\n    droppable?: boolean;\n    /** 设置选择onChange接收的最大文件数，默认为无限 */\n    maxFiles?: number;\n    /** 用户选择或取消选择后的回调 */\n    onChange?: (files: RWFile[]) =\u003e void;\n}\n\n```\n\n### defaultProps\n\n```js\n{\n\tprefixCls: \"rw-upload\",\n\ttagName: \"div\",\n\ttabIndex: 0,\n\tmaxFiles: Number.MAX_VALUE,\n\tdroppable: true,\n\topenFileDialogOnClick: true,\n}\n```\n\n### 基础样式\n\n```css\n.rw-upload {\n    cursor: pointer;\n}\n\n\n```\n\n### FAQ\n\n`react-widget-upload`只负责将用户选择后的文件回传给使用者，并不进行实际的文件上传，使用者需要自行构建`FormData`，示例：\n\n```js\n\nfunction handleChange(files){\n    if(!files.length) return;\n    const file = files[0];\n\n    const formData = new FormData();\n\n    formData.append('file', file, file.name);\n\n    post(url, formData);\n}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-widget%2Fupload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact-widget%2Fupload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-widget%2Fupload/lists"}