mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-12-03 02:33:36 +01:00
Format all files with Prettier
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
Bootstrap component for file input. Includes label and has predefined sizes and structure for using in foris forms.
|
||||
Bootstrap component for file input. Includes label and has predefined sizes and
|
||||
structure for using in foris forms.
|
||||
|
||||
All additional `props` are passed to the `<input type="file">` HTML component.
|
||||
|
||||
```js
|
||||
import { useState } from 'react';
|
||||
import { useState } from "react";
|
||||
|
||||
const [files, setFiles] = useState([]);
|
||||
|
||||
@@ -15,27 +16,33 @@ const label = files.length === 1 ? files[0].name : "Choose file";
|
||||
files={files}
|
||||
label={label}
|
||||
helpText="Will be uploaded"
|
||||
onChange={event=>setFiles(event.target.files)}
|
||||
onChange={(event) => setFiles(event.target.files)}
|
||||
/>
|
||||
</form>
|
||||
</form>;
|
||||
```
|
||||
|
||||
### FileInput with multiple files
|
||||
|
||||
```js
|
||||
import { useState } from 'react';
|
||||
import { useState } from "react";
|
||||
|
||||
const [files, setFiles] = useState([]);
|
||||
|
||||
// Note that files is not an array but FileList.
|
||||
const label = files.length > 0 ? Array.from(files).map(file=>file.name).join(", ") : "Choose files";
|
||||
const label =
|
||||
files.length > 0
|
||||
? Array.from(files)
|
||||
.map((file) => file.name)
|
||||
.join(", ")
|
||||
: "Choose files";
|
||||
|
||||
<form className="col">
|
||||
<FileInput
|
||||
files={files}
|
||||
label={label}
|
||||
helpText="Will be uploaded"
|
||||
onChange={event=>setFiles(event.target.files)}
|
||||
onChange={(event) => setFiles(event.target.files)}
|
||||
multiple
|
||||
/>
|
||||
</form>
|
||||
</form>;
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user