Skip to content

Commit 84db190

Browse files
committed
updated ReadMe
1 parent 0ca55ed commit 84db190

File tree

8 files changed

+10121
-35
lines changed

8 files changed

+10121
-35
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Exclude files/folders for publishing package
22

33
demo/
4-
4+
src/

README.md

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Vue File selector
2-
File selector component that supports drag-n-drop for @vuejs
2+
File selector component that supports drag-n-drop for Vuejs.
33

4-
## Install
4+
## Install
55
Run the command
66
```
7-
npm i fluent-reveal-effect@latest
7+
npm i vue-file-selector@latest
88
```
99

1010
NPM package: https://www.npmjs.com/package/vue-file-selector
1111

12+
Github source: https://github.com/d2phap/vue-file-selector
13+
1214
## Usage
15+
Please see [Demo project](https://github.com/d2phap/vue-file-selector/tree/master/demo) for full example.
1316

14-
#### Declare the plugin
17+
### Declare the plugin
1518
```js
1619
// import the library
1720
import FileSelector from 'vue-file-selector';
@@ -24,13 +27,11 @@ Vue.use(FileSelector);
2427
```html
2528
<template>
2629
<div>
27-
My App.vue comp
28-
2930
<file-selector
30-
accept-extensions=".zip"
31+
accept-extensions=".jpg"
3132
:height="300"
32-
@validate="validate"
33-
@change="change"
33+
@validated="handleFilesValidated"
34+
@changed="handleFilesChanged"
3435
>
3536
hahahah
3637
</file-selector>
@@ -41,15 +42,62 @@ Vue.use(FileSelector);
4142
export default {
4243
name: 'App',
4344
methods: {
44-
validate(result, files) {
45+
handleFilesValidated(result, files) {
4546
console.log('Validation result: ' + result);
4647
},
4748
48-
change(files) {
49-
console.log('Selected files: ', files);
49+
handleFilesChanged(files) {
50+
console.log('Selected files: ');
51+
console.table(files);
5052
},
5153
},
5254
};
5355
</script>
5456
```
5557

58+
## Slots
59+
| Name | Default | Description |
60+
| -- | -- | -- |
61+
| `default` | `Select` | Content of the `Select` button. |
62+
| `loader` | `Loading...` | Content of loading state. |
63+
| `top` | | Top section content, above the `Select` button. |
64+
| `bottom` | | Bottom section content, below the `Select` button. |
65+
66+
67+
## Props
68+
| Name | Type | Default | Description |
69+
| -- | -- | -- | -- |
70+
| `multiple` | `Boolean` | `false` | Allow multiple files selected. |
71+
| `is-loading` | `Boolean` | `false` | Show or hide the loading section (slot: `loader`). |
72+
| `accept-extensions` | `String` | ` ` | List of file extensions accepted. Each extension separated by a comma (`,`). E.g. `accept-extensions=".zip,.rar"`. |
73+
| `max-file-size` | `Number` | `NaN` | Maximum **size in byte** of every single file allowed. E.g. `:max-file-size="2*1024*1024"` (only the files that ≤2 MB are allowed). |
74+
| `height` | `Number` | `NaN` | The height of droppable section. |
75+
| `validate-fn` | `Function -> Boolean` | `() => true` | A custom validation function that returns boolean value. |
76+
77+
78+
## Events
79+
### 1. `@validated`
80+
Occurs after the selected files validated.
81+
```js
82+
Function(result: String | Boolean, files: FileList): void
83+
```
84+
- `result`: validation result,
85+
+ returns `true` if the file validation is valid, else
86+
+ returns `false` or [Error codes](#error-codes).
87+
- `files`: list of files validated.
88+
89+
### 2. `@changed`
90+
Occurs if the selected files pass validation.
91+
```js
92+
Function(files: FileList): void
93+
```
94+
- `files`: list of files validated.
95+
96+
97+
## Error codes
98+
List of error codes returned after validation.
99+
| Code | Error description |
100+
| -- | -- |
101+
| `EXTENSION_ERROR` | The selected files contain invalid extensions. |
102+
| `FILE_SIZE_ERROR` | The selected files size exceeded limit. |
103+
| `MULTIFILES_ERROR` | Multiple files selection is not allowed. |

0 commit comments

Comments
 (0)