# @idot-digital/file-selector

> Upload, delete, filter, and select files, using Material UI's framework

Latest version **5.1.0** (published 2023-01-06) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @idot-digital/file-selector
pnpm add @idot-digital/file-selector
yarn add @idot-digital/file-selector
bun add @idot-digital/file-selector
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2023-01-06 |
| First published | 2021-03-27 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 325.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | @idot-digital |
| Maintainers | der-grosse, luiskugel, davidkopczynski |

## Links

- npm: https://www.npmjs.com/package/@idot-digital/file-selector
- npm.io page: https://npm.io/package/@idot-digital/file-selector

## Dependencies (2)

- [notistack](https://npm.io/package/notistack.md) ^2.0.3
- [react-photo-gallery](https://npm.io/package/react-photo-gallery.md) ^8.0.0

## Recent versions

- 5.1.0 (latest) — 2023-01-06
- 5.0.0 — 2021-12-19
- 4.0.1 — 2021-12-08
- 4.0.0 — 2021-12-08
- 3.2.2 — 2021-11-14
- 3.2.1 — 2021-10-18
- 3.2.0 — 2021-08-10
- 3.1.1 — 2021-07-29
- 3.1.0 — 2021-07-28
- 3.0.5 — 2021-07-28
- 3.0.4 — 2021-07-28
- 3.0.3 — 2021-07-28
- 3.0.2 — 2021-07-18
- 3.0.1 — 2021-05-18
- 3.0.0 — 2021-05-17
- … 14 more at https://npm.io/package/@idot-digital/file-selector/versions

## README

# @idot-digital/file-selector

> Upload, delete, filter, and select files, using Material UI's framework

[![NPM](https://img.shields.io/npm/v/@idot-digital/file-selector.svg)](https://www.npmjs.com/package/@idot-digital/file-selector) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save @idot-digital/file-selector
yarn add @idot-digital/file-selector
```

## Usage

```tsx
import React, { Component } from 'react';

import { createTheme, ThemeProvider } from '@material-ui/core';
import { SnackbarProvider } from 'notistack';

import { FileSelector, FileSelectorRaw, FileResponse, FileSelectorLinkSettings } from '@idot-digital/file-selector';

// Wrap ThemeProvider from Material UI around your app -- ability to tweak initial styles
// Wrap SnackbarProvider around your app -- ability to enqueue snackbars
const Index = () => {
  return (
    <ThemeProvider theme={createTheme()}>
      <SnackbarProvider preventDuplicate maxSnack={3}>
        <App />
      </SnackbarProvider>
    </ThemeProvider>
  );
};

const App = () => {
  const [open, setOpen] = React.useState(false);
  const [files, setFiles] = React.useState<string[]>([]); // Currently selected files (paths)

  return (
    <>
      <div onClick={() => setOpen(true)}>Open</div>
      <FileSelector
        // Fetch settings
        links={{
          get: {
            url: 'URL for specific request',
            method: 'Method for specific request',
            settings: {
              // Custom settings only for "get"
            },
          },
          rename: {
            //Settings as in get
          },
          delete: {
            //Settings as in get
          },
          upload: {
            //Settings as in get
          },

          // Next applies to all requests
          settings: {
            // General settings
          },
          url: 'General api URL',
          root: 'Root image URL',
        }}
        // Callback functions
        callback={(file) => console.log(file)}
        callbackDone={(files) => {
          console.log(files);
          setFiles(files.map((file) => file.path));
          setOpen(false);
        }}
        // Controlled prop to manage currently selected files
        pickedFiles={files}
        // Change link of previewed images in order to fetch low res variants
        previewImage={(filePath) => filePath.replace('...', '...')}
        // Material UI default dialog props
        open={open}
        onClose={() => setOpen(false)}
        // Custom props
        fullWidth
        maxWidth="xl"
      />
    </>
  );
};
```

## License

UNLICENSED © [@idot-digital](https://github.com/@idot-digital)

---
_Source: https://npm.io/package/@idot-digital/file-selector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
