{"_id":"file-selector@5.0.2","bugs":{"url":"https://github.com/react-dropzone/file-selector/issues"},"dist":{"shasum":"83313bda80a6a364bc59c9760af9c6ba03fdfe0a","tarball":"http://registry-npm.ywwl.com/file-selector/download/file-selector-5.0.2.tgz","fileCount":27,"integrity":"sha512-1hAy178VaMCWWj/vSUITOTpLWH1PoGW3eO7i3kPIppuSyOHBm3o1cHq+CvKAM5hQKQXlazrDt/3K1HCXgs7MpQ==","signatures":[{"sig":"MEYCIQC7nlCdS6nWaraN/lF5Gw+QUyjYOmLPjoKneVqeBxnIVgIhAOs9zDl8pSE23yIij0o7Uxj5InnXqnmkKNvTWfbApN99","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDV8i4/NORHgxRi5idqsauka/IptXoMOHm1T/V4G90rRAIhALIcNbTnbJixPvEFot4PkJnha64nlt0Lcw/IlA34CeVc"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/file-selector@5.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":387392,"size":80992,"noattachment":false,"key":"/file-selector/-/file-selector-5.0.2.tgz"},"main":"./dist/index.cjs","name":"file-selector","type":"module","types":"./dist/index.d.ts","author":{"name":"Roland Groza","email":"rolandjitsu@gmail.com"},"module":"./dist/index.js","engines":{"node":">= 22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./mime":{"types":"./dist/mime.d.ts","import":"./dist/mime.js","require":"./dist/mime.cjs"},"./package.json":"./package.json"},"gitHead":"0221878a077f16b250aa40a6f74ef85aa76682e3","license":"MIT","scripts":{"dev":"tsdown --watch","lint":"oxlint","size":"size-limit","test":"vitest","build":"tsdown","clean":"rm -rf dist","format":"oxfmt .","prepare":"prek install || exit 0","presize":"npm run build","docs:dev":"vocs dev","lint:fix":"oxlint --fix","prebuild":"npm run clean","test:cov":"vitest run --coverage","test:e2e":"playwright test","hooks:run":"prek run --all-files","docs:build":"vocs build","type-check":"tsc --noEmit","pretest:cov":"npm run type-check && npm run lint && npm run format:check","pretest:e2e":"npm run build","docs:preview":"vocs preview","format:check":"oxfmt --check .","hooks:install":"prek install","test:docs:e2e":"playwright test -c playwright.docs.config.ts","lint:type-aware":"oxlint --type-aware","pretest:docs:e2e":"npm run docs:build"},"version":"5.0.2","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"b6c9da15-f786-46b2-ba3b-b9c1b12e3b32"}},"homepage":"https://github.com/react-dropzone/file-selector","keywords":["DataTransfer","File","drag-and-drop","file-api","html5"],"overrides":{"toml":"^5.0.0"},"repository":{"url":"git+https://github.com/react-dropzone/file-selector.git","type":"git"},"size-limit":[{"name":"core, esm (fromEvent + default MIME map)","path":["dist/index.js","dist/mime-default.js"],"limit":"3 kB"},{"name":"core, cjs (fromEvent + default MIME map)","path":["dist/index.cjs","dist/mime-default.cjs"],"limit":"4 kB"}],"_npmVersion":"11.21.1","description":"Convert DataTransfer object to a list of File objects","directories":{},"maintainers":[{"name":"rolandjitsu","email":"rolandjitsu@gmail.com"}],"sideEffects":false,"_nodeVersion":"22.23.4","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vocs":"^2.10.3","waku":"1.0.0-rc.1","jsdom":"^30.1.3","oxfmt":"^0.74.0","react":"^19.3.1","oxlint":"^1.89.0","tsdown":"^0.23.1","vitest":"^5.0.5","react-dom":"^19.3.1","size-limit":"^14.2.0","typescript":"^7.0.2","@types/node":"^26.6.5","oxlint-tsgolint":"^7.0.2004","@playwright/test":"^1.64.1","@size-limit/file":"^14.2.0","@vitest/coverage-v8":"^5.0.5","react-server-dom-webpack":"^19.3.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/file-selector_5.0.2_1793418859435_0.11876463294003348"},"readme":"<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/react-dropzone/.github/main/brand/assets/logo.png\" alt=\"file-selector logo\" width=\"120\" />\n</p>\n\n# file-selector\n\n> A small package for converting a [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent) or [file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file) to a list of File objects.\n\n📖 **[Documentation & live playground →](https://react-dropzone.github.io/file-selector/)**\n\n[![npm](https://img.shields.io/npm/v/file-selector.svg?style=flat-square)](https://www.npmjs.com/package/file-selector)\n![Tests](https://img.shields.io/github/actions/workflow/status/react-dropzone/file-selector/test.yml?branch=main&style=flat-square&label=tests)\n[![coverage](https://img.shields.io/coveralls/github/react-dropzone/file-selector/main?style=flat-square)](https://coveralls.io/github/react-dropzone/file-selector?branch=main)\n[![Open Collective Backers](https://img.shields.io/opencollective/backers/react-dropzone.svg?style=flat-square)](#backers)\n[![Open Collective Sponsors](https://img.shields.io/opencollective/sponsors/react-dropzone.svg?style=flat-square)](#sponsors)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?style=flat-square)](https://github.com/react-dropzone/.github/blob/main/CODE_OF_CONDUCT.md)\n\n# Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Browser Support](#browser-support)\n- [Contribute](#contribute)\n- [Credits](#credits)\n- [Support](#support)\n- [License](#license)\n\n## Installation\n\nYou can install this package from [NPM](https://www.npmjs.com):\n\n```bash\nnpm add file-selector\n```\n\n### CDN\n\nFor CDN usage, load the ESM build directly from a CDN such as [esm.sh](https://esm.sh) or [jsDelivr](https://www.jsdelivr.com/package/npm/file-selector):\n\n```html\n<script type=\"module\">\n  import {fromEvent} from \"https://esm.sh/file-selector\";\n\n  document.addEventListener(\"drop\", async evt => {\n    const files = await fromEvent(evt);\n    console.log(files);\n  });\n</script>\n```\n\n## Usage\n\n### ES6\n\nConvert a [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent) to File objects:\n\n```ts\nimport {fromEvent} from \"file-selector\";\ndocument.addEventListener(\"drop\", async evt => {\n  const files = await fromEvent(evt);\n  console.log(files);\n});\n```\n\nConvert a [change event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event) for an input type file to File objects:\n\n```ts\nimport {fromEvent} from \"file-selector\";\nconst input = document.getElementById(\"myInput\");\ninput.addEventListener(\"change\", async evt => {\n  const files = await fromEvent(evt);\n  console.log(files);\n});\n```\n\nConvert [FileSystemFileHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle) items to File objects:\n\n```ts\nimport {fromEvent} from \"file-selector\";\n\n// Open file picker\nconst handles = await window.showOpenFilePicker({multiple: true});\n// Get the files\nconst files = await fromEvent(handles);\nconsole.log(files);\n```\n\n**NOTE** The above is experimental and subject to change.\n\n### CommonJS\n\nConvert a `DragEvent` to File objects:\n\n```ts\nconst {fromEvent} = require(\"file-selector\");\ndocument.addEventListener(\"drop\", async evt => {\n  const files = await fromEvent(evt);\n  console.log(files);\n});\n```\n\n### MIME types\n\nWhen the browser doesn't set a File's `type`, `fromEvent` infers one from the file extension. By default it uses a small built-in table of the most common types, keeping the bundle lean.\n\nIf you need broader coverage, import the full extension-to-MIME table from the `file-selector/mime` subpath and pass it via the `mimeTypes` option. Because it's a separate entry point, the full table (~1,200 entries) is only included in your bundle when you import it:\n\n```ts\nimport {fromEvent} from \"file-selector\";\nimport {COMMON_MIME_TYPES} from \"file-selector/mime\";\n\nconst files = await fromEvent(evt, {mimeTypes: COMMON_MIME_TYPES});\n```\n\nYou can also pass your own `Map<extension, mimeType>` to restrict or extend the lookup:\n\n```ts\nconst files = await fromEvent(evt, {mimeTypes: new Map([[\"dwg\", \"image/vnd.dwg\"]])});\n```\n\n## Browser Support\n\nMost browser support basic File selection with drag 'n' drop or file input:\n\n- [File API](https://developer.mozilla.org/en-US/docs/Web/API/File#Browser_compatibility)\n- [Drag Event](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent#Browser_compatibility)\n- [DataTransfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer#Browser_compatibility)\n- [`<input type=\"file\">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Browser_compatibility)\n\nFor folder drop we use the [FileSystem API](https://developer.mozilla.org/en-US/docs/Web/API/FileSystem) which has very limited support:\n\n- [DataTransferItem.getAsFile()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFile#Browser_compatibility)\n- [DataTransferItem.webkitGetAsEntry()](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#Browser_compatibility)\n- [FileSystemEntry](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry#Browser_compatibility)\n- [FileSystemFileEntry.file()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry/file#Browser_compatibility)\n- [FileSystemDirectoryEntry.createReader()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry/createReader#Browser_compatibility)\n- [FileSystemDirectoryReader.readEntries()](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader/readEntries#Browser_compatibility)\n\n## Contribute\n\nCheckout the organization [CONTRIBUTING.md](https://github.com/react-dropzone/.github/blob/main/CONTRIBUTING.md).\n\n### Development\n\nDevelopment requires [Node.js](https://nodejs.org) >= 20. Install the dependencies with:\n\n```bash\nnpm install\n```\n\nThe project is built with [tsdown](https://tsdown.dev) (Rolldown), type-checked with [TypeScript](https://www.typescriptlang.org), tested with [Vitest](https://vitest.dev) and linted/formatted with [oxlint](https://oxc.rs) and [oxfmt](https://oxc.rs).\n\n| Command                   | Description                                                                      |\n| ------------------------- | -------------------------------------------------------------------------------- |\n| `npm test`                | Run the test suite in watch mode.                                                |\n| `npm run test:cov`        | Run the tests once with coverage (runs type-check, lint and format check first). |\n| `npm run type-check`      | Type-check the sources without emitting.                                         |\n| `npm run lint`            | Lint the sources (oxlint).                                                       |\n| `npm run lint:fix`        | Apply safe lint fixes.                                                           |\n| `npm run lint:type-aware` | Type-aware lint via tsgolint (alpha).                                            |\n| `npm run format`          | Format the sources (oxfmt).                                                      |\n| `npm run format:check`    | Check formatting without writing.                                                |\n| `npm run build`           | Build the outputs into `dist/`.                                                  |\n| `npm run dev`             | Build in watch mode.                                                             |\n| `npm run docs:dev`        | Run the [Vocs](https://vocs.dev) docs site locally.                              |\n| `npm run docs:build`      | Build the docs site into `site/`.                                                |\n| `npm run docs:preview`    | Preview the built docs site.                                                     |\n| `npm run hooks:install`   | Install the git hooks (`prek install`).                                          |\n| `npm run hooks:run`       | Run every git hook over the whole repo.                                          |\n\nThe build emits into `dist/`:\n\n- `dist/index.js` — ES module\n- `dist/index.cjs` — CommonJS module\n- `dist/index.d.ts` — TypeScript declarations\n\n### Git hooks\n\nGit hooks are managed with [prek](https://github.com/j178/prek), a fast Rust drop-in for the [pre-commit](https://pre-commit.com) framework (configured in [`.pre-commit-config.yaml`](.pre-commit-config.yaml)). On commit they format and lint the staged files with oxfmt/oxlint, and check the message against [Conventional Commits](https://www.conventionalcommits.org) — the same convention [semantic-release](https://semantic-release.gitbook.io) uses to cut releases.\n\nprek is a standalone binary, so install it once (e.g. `uv tool install prek`, `brew install prek`, or see the [install docs](https://github.com/j178/prek#installation)). `npm install` then wires up the hooks automatically; run `npm run hooks:install` to (re)install them by hand. The hooks are optional — CI enforces the same lint, format and commit checks — but they catch issues before you push.\n\n## Credits\n\n- [html5-file-selector](https://github.com/quarklemotion/html5-file-selector)\n\n## Support\n\n### Backers\n\nSupport us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/react-dropzone#backer)]\n\n<a href=\"https://opencollective.com/react-dropzone#backers\" target=\"_blank\"><img src=\"https://opencollective.com/react-dropzone/backers.svg?width=890\"></a>\n\n### Sponsors\n\nBecome a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/react-dropzone#sponsor)]\n\n<a href=\"https://opencollective.com/react-dropzone#sponsors\" target=\"_blank\"><img src=\"https://opencollective.com/react-dropzone/sponsors.svg?width=890\"></a>\n\n## License\n\nMIT\n","publish_time":1793418859550,"_cnpm_publish_time":1793418859550,"dist-tags":{"beta":"3.0.0-beta.6","latest":"5.0.3","release-0.1.x":"0.1.19","release-1.2.x":"1.2.0","release-2.1.x":"2.1.2"}}