├── .envrc
├── .gitignore
├── README.md
├── bin
└── publish
├── demo
├── App.vue
├── index.html
├── index.js
└── style.css
├── dist
└── v-file-upload.js
├── docs
├── client.6175ae69.js
├── index.html
├── manifest.e3152fb8.js
└── vendor.00ca08e4.js
├── package.json
├── poi.config.demo.js
├── poi.config.js
├── src
├── FileUpload.js
├── FileUpload.vue
└── v-file-upload.js
├── types
└── index.d.ts
└── yarn.lock
/.envrc:
--------------------------------------------------------------------------------
1 | PATH_add bin
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | npm-debug.log
4 | yarn-error.log
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # v-file-upload
2 |
3 | > File upload component for Vue.js
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | ## Installation
12 |
13 | ### Using yarn
14 |
15 | `yarn add v-file-upload`
16 |
17 | ### Using npm
18 |
19 | `npm i --save v-file-upload`
20 |
21 | ## Demo
22 |
23 | [DEMO](http://dflourusso.github.io/v-file-upload)
24 |
25 | ## Usage
26 |
27 | ### As component
28 |
29 | ```js
30 | import Vue from 'vue'
31 |
32 | import FileUpload from 'v-file-upload'
33 |
34 | Vue.use(FileUpload)
35 | ```
36 |
37 | ### As service
38 |
39 | ```js
40 | import { FileUploadService } from 'v-file-upload'
41 | ```
42 |
43 | ## Examples
44 |
45 | ### As component
46 |
47 | ```html
48 |
49 |
50 |
51 |
52 |
76 | ```
77 |
78 | #### Properties
79 |
80 | | Name | Type | Required | Default | Info |
81 | | ----------------------- | -------- | -------- | --------------- | --------------------------------------------------------------------------- |
82 | | **url** | String | True | | Url to POST the files |
83 | | **thumb-url** | Function | True | | Method that should returns the thumb url for the uploaded file |
84 | | **accept** | String | False | .png,.jpg | File input accept filter |
85 | | **headers** | Object | False | {} | Headers for the request. You can pass auth tokens for example |
86 | | **btn-label** | String | False | Select a file | Label for the button |
87 | | **btn-uploading-label** | String | False | Uploading files | Label for the button when the upload is in progress |
88 | | **max-size** | Number | False | 15728640 //15Mb | Max size for the file |
89 | | **additional-data** | Object | False | {} | Additional data for the request |
90 | | **unique-id** | String | False | '000' | Helpful when using more than one instance of the component on the same page |
91 |
92 | #### Events
93 |
94 | | Name | Params | Info |
95 | | ------------ | -------------------------------- | -------------------------------------------------------------------------- |
96 | | **success** | _event_: XMLHttpRequest event | Triggered after POST success |
97 | | **error** | _event_: XMLHttpRequest event | Triggered after POST error |
98 | | **change** | _files_: Array of uploaded files | Triggered after add or remove a file |
99 | | **progress** | _progress_: Progress percentage | Triggered while the upload is in progress indicating the upload percentage |
100 |
101 | ### As service
102 |
103 | ```js
104 | import { FileUploadService } from 'v-file-upload'
105 | export default {
106 | data() {
107 | return {
108 | url: 'http://your-post.url',
109 | headers: { 'access-token': '' }
110 | }
111 | },
112 | methods: {
113 | mySaveMethod(file) {
114 | let fileUpload = new FileUploadService(
115 | this.url,
116 | this.headers,
117 | this.onProgress
118 | )
119 | fileUpload
120 | .upload(file, { doc_id: 1 })
121 | .then(e => {
122 | // Handle success
123 | })
124 | .catch(e => {
125 | // Handle error
126 | })
127 | },
128 | onProgress(event) {
129 | // Handdle the progress
130 | }
131 | }
132 | }
133 | ```
134 |
135 | ## Development
136 |
137 | `yarn dist`
138 |
139 | ## Author
140 |
141 | * [Daniel Fernando Lourusso](http://dflourusso.com.br)
142 |
143 | ## License
144 |
145 | This project is licensed under
146 | [MIT License](http://en.wikipedia.org/wiki/MIT_License)
147 |
--------------------------------------------------------------------------------
/bin/publish:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | version=${1:-patch}
5 | git up
6 | npm version $version
7 | git push -v --progress
8 | git push --tags
9 | npm publish
10 |
--------------------------------------------------------------------------------
/demo/App.vue:
--------------------------------------------------------------------------------
1 |
2 | div(style="text-align: center;")
3 | div.input-group
4 | file-upload(url='https://postman-echo.com/post', :thumb-url='thumbUrl', @success="onSucess", @error="onError", :additional-data="additionalData")
5 | .red {{error}}
6 |
7 |
8 |
41 |
42 |
43 |
48 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | v-file-upload
9 |
10 |
11 |
16 |
17 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/demo/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | import App from './App.vue'
4 |
5 | new Vue({...App}).$mount('#app')
6 |
--------------------------------------------------------------------------------
/demo/style.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
2 | /** 1. Set default font family to sans-serif. 2. Prevent iOS text size adjust after orientation change, without disabling user zoom. */
3 | html { font-family: sans-serif; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ }
4 |
5 | /** Remove default margin. */
6 | body { margin: 0; }
7 |
8 | /* HTML5 display definitions ========================================================================== */
9 | /** Correct `block` display not defined for any HTML5 element in IE 8/9. Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. Correct `block` display not defined for `main` in IE 11. */
10 | article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; }
11 |
12 | /** 1. Correct `inline-block` display not defined in IE 8/9. 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. */
13 | audio, canvas, progress, video { display: inline-block; /* 1 */ vertical-align: baseline; /* 2 */ }
14 |
15 | /** Prevent modern browsers from displaying `audio` without controls. Remove excess height in iOS 5 devices. */
16 | audio:not([controls]) { display: none; height: 0; }
17 |
18 | /** Address `[hidden]` styling not present in IE 8/9/10. Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. */
19 | [hidden], template { display: none; }
20 |
21 | /* Links ========================================================================== */
22 | /** Remove the gray background color from active links in IE 10. */
23 | a { background-color: transparent; }
24 |
25 | /** Improve readability when focused and also mouse hovered in all browsers. */
26 | a:active, a:hover { outline: 0; }
27 |
28 | /* Text-level semantics ========================================================================== */
29 | /** Address styling not present in IE 8/9/10/11, Safari, and Chrome. */
30 | abbr[title] { border-bottom: 1px dotted; }
31 |
32 | /** Address style set to `bolder` in Firefox 4+, Safari, and Chrome. */
33 | b, strong { font-weight: bold; }
34 |
35 | /** Address styling not present in Safari and Chrome. */
36 | dfn { font-style: italic; }
37 |
38 | /** Address variable `h1` font-size and margin within `section` and `article` contexts in Firefox 4+, Safari, and Chrome. */
39 | h1 { font-size: 2em; margin: 0.67em 0; }
40 |
41 | /** Address styling not present in IE 8/9. */
42 | mark { background: #ff0; color: #000; }
43 |
44 | /** Address inconsistent and variable font size in all browsers. */
45 | small { font-size: 80%; }
46 |
47 | /** Prevent `sub` and `sup` affecting `line-height` in all browsers. */
48 | sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
49 |
50 | sup { top: -0.5em; }
51 |
52 | sub { bottom: -0.25em; }
53 |
54 | /* Embedded content ========================================================================== */
55 | /** Remove border when inside `a` element in IE 8/9/10. */
56 | img { border: 0; }
57 |
58 | /** Correct overflow not hidden in IE 9/10/11. */
59 | svg:not(:root) { overflow: hidden; }
60 |
61 | /* Grouping content ========================================================================== */
62 | /** Address margin not present in IE 8/9 and Safari. */
63 | figure { margin: 1em 40px; }
64 |
65 | /** Address differences between Firefox and other browsers. */
66 | hr { box-sizing: content-box; height: 0; }
67 |
68 | /** Contain overflow in all browsers. */
69 | pre { overflow: auto; }
70 |
71 | /** Address odd `em`-unit font size rendering in all browsers. */
72 | code, kbd, pre, samp { font-family: monospace, monospace; font-size: 1em; }
73 |
74 | /* Forms ========================================================================== */
75 | /** Known limitation: by default, Chrome and Safari on OS X allow very limited styling of `select`, unless a `border` property is set. */
76 | /** 1. Correct color not being inherited. Known issue: affects color of disabled elements. 2. Correct font properties not being inherited. 3. Address margins set differently in Firefox 4+, Safari, and Chrome. */
77 | button, input, optgroup, select, textarea { color: inherit; /* 1 */ font: inherit; /* 2 */ margin: 0; /* 3 */ }
78 |
79 | /** Address `overflow` set to `hidden` in IE 8/9/10/11. */
80 | button { overflow: visible; }
81 |
82 | /** Address inconsistent `text-transform` inheritance for `button` and `select`. All other form control elements do not inherit `text-transform` values. Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. Correct `select` style inheritance in Firefox. */
83 | button, select { text-transform: none; }
84 |
85 | /** 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls. 2. Correct inability to style clickable `input` types in iOS. 3. Improve usability and consistency of cursor style between image-type `input` and others. */
86 | button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ }
87 |
88 | /** Re-set default cursor for disabled elements. */
89 | button[disabled], html input[disabled] { cursor: default; }
90 |
91 | /** Remove inner padding and border in Firefox 4+. */
92 | button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
93 |
94 | /** Address Firefox 4+ setting `line-height` on `input` using `!important` in the UA stylesheet. */
95 | input { line-height: normal; }
96 |
97 | /** It's recommended that you don't attempt to style these elements. Firefox's implementation doesn't respect box-sizing, padding, or width. 1. Address box sizing set to `content-box` in IE 8/9/10. 2. Remove excess padding in IE 8/9/10. */
98 | input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ }
99 |
100 | /** Fix the cursor style for Chrome's increment/decrement buttons. For certain `font-size` values of the `input`, it causes the cursor style of the decrement button to change from `default` to `text`. */
101 | input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; }
102 |
103 | /** 1. Address `appearance` set to `searchfield` in Safari and Chrome. 2. Address `box-sizing` set to `border-box` in Safari and Chrome (include `-moz` to future-proof). */
104 | input[type="search"] { -webkit-appearance: textfield; /* 1 */ /* 2 */ box-sizing: content-box; }
105 |
106 | /** Remove inner padding and search cancel button in Safari and Chrome on OS X. Safari (but not Chrome) clips the cancel button when the search input has padding (and `textfield` appearance). */
107 | input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
108 |
109 | /** Define consistent border, margin, and padding. */
110 | fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; }
111 |
112 | /** 1. Correct `color` not being inherited in IE 8/9/10/11. 2. Remove padding so people aren't caught out if they zero out fieldsets. */
113 | legend { border: 0; /* 1 */ padding: 0; /* 2 */ }
114 |
115 | /** Remove default vertical scrollbar in IE 8/9/10/11. */
116 | textarea { overflow: auto; }
117 |
118 | /** Don't inherit the `font-weight` (applied by a rule above). NOTE: the default cannot safely be changed in Chrome and Safari on OS X. */
119 | optgroup { font-weight: bold; }
120 |
121 | /* Tables ========================================================================== */
122 | /** Remove most spacing between table cells. */
123 | table { border-collapse: collapse; border-spacing: 0; }
124 |
125 | td, th { padding: 0; }
126 |
127 | .highlight table td { padding: 5px; }
128 |
129 | .highlight table pre { margin: 0; }
130 |
131 | .highlight .cm { color: #999988; font-style: italic; }
132 |
133 | .highlight .cp { color: #999999; font-weight: bold; }
134 |
135 | .highlight .c1 { color: #999988; font-style: italic; }
136 |
137 | .highlight .cs { color: #999999; font-weight: bold; font-style: italic; }
138 |
139 | .highlight .c, .highlight .cd { color: #999988; font-style: italic; }
140 |
141 | .highlight .err { color: #a61717; background-color: #e3d2d2; }
142 |
143 | .highlight .gd { color: #000000; background-color: #ffdddd; }
144 |
145 | .highlight .ge { color: #000000; font-style: italic; }
146 |
147 | .highlight .gr { color: #aa0000; }
148 |
149 | .highlight .gh { color: #999999; }
150 |
151 | .highlight .gi { color: #000000; background-color: #ddffdd; }
152 |
153 | .highlight .go { color: #888888; }
154 |
155 | .highlight .gp { color: #555555; }
156 |
157 | .highlight .gs { font-weight: bold; }
158 |
159 | .highlight .gu { color: #aaaaaa; }
160 |
161 | .highlight .gt { color: #aa0000; }
162 |
163 | .highlight .kc { color: #000000; font-weight: bold; }
164 |
165 | .highlight .kd { color: #000000; font-weight: bold; }
166 |
167 | .highlight .kn { color: #000000; font-weight: bold; }
168 |
169 | .highlight .kp { color: #000000; font-weight: bold; }
170 |
171 | .highlight .kr { color: #000000; font-weight: bold; }
172 |
173 | .highlight .kt { color: #445588; font-weight: bold; }
174 |
175 | .highlight .k, .highlight .kv { color: #000000; font-weight: bold; }
176 |
177 | .highlight .mf { color: #009999; }
178 |
179 | .highlight .mh { color: #009999; }
180 |
181 | .highlight .il { color: #009999; }
182 |
183 | .highlight .mi { color: #009999; }
184 |
185 | .highlight .mo { color: #009999; }
186 |
187 | .highlight .m, .highlight .mb, .highlight .mx { color: #009999; }
188 |
189 | .highlight .sb { color: #d14; }
190 |
191 | .highlight .sc { color: #d14; }
192 |
193 | .highlight .sd { color: #d14; }
194 |
195 | .highlight .s2 { color: #d14; }
196 |
197 | .highlight .se { color: #d14; }
198 |
199 | .highlight .sh { color: #d14; }
200 |
201 | .highlight .si { color: #d14; }
202 |
203 | .highlight .sx { color: #d14; }
204 |
205 | .highlight .sr { color: #009926; }
206 |
207 | .highlight .s1 { color: #d14; }
208 |
209 | .highlight .ss { color: #990073; }
210 |
211 | .highlight .s { color: #d14; }
212 |
213 | .highlight .na { color: #008080; }
214 |
215 | .highlight .bp { color: #999999; }
216 |
217 | .highlight .nb { color: #0086B3; }
218 |
219 | .highlight .nc { color: #445588; font-weight: bold; }
220 |
221 | .highlight .no { color: #008080; }
222 |
223 | .highlight .nd { color: #3c5d5d; font-weight: bold; }
224 |
225 | .highlight .ni { color: #800080; }
226 |
227 | .highlight .ne { color: #990000; font-weight: bold; }
228 |
229 | .highlight .nf { color: #990000; font-weight: bold; }
230 |
231 | .highlight .nl { color: #990000; font-weight: bold; }
232 |
233 | .highlight .nn { color: #555555; }
234 |
235 | .highlight .nt { color: #000080; }
236 |
237 | .highlight .vc { color: #008080; }
238 |
239 | .highlight .vg { color: #008080; }
240 |
241 | .highlight .vi { color: #008080; }
242 |
243 | .highlight .nv { color: #008080; }
244 |
245 | .highlight .ow { color: #000000; font-weight: bold; }
246 |
247 | .highlight .o { color: #000000; font-weight: bold; }
248 |
249 | .highlight .w { color: #bbbbbb; }
250 |
251 | .highlight { background-color: #f8f8f8; }
252 |
253 | * { box-sizing: border-box; }
254 |
255 | body { padding: 0; margin: 0; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; color: #606c71; }
256 |
257 | a { color: #1e6bb8; text-decoration: none; }
258 | a:hover { text-decoration: underline; }
259 |
260 | .btn { display: inline-block; margin-bottom: 1rem; color: rgba(255, 255, 255, 0.7); background-color: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); border-style: solid; border-width: 1px; border-radius: 0.3rem; transition: color 0.2s, background-color 0.2s, border-color 0.2s; }
261 | .btn:hover { color: rgba(255, 255, 255, 0.8); text-decoration: none; background-color: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.3); }
262 | .btn + .btn { margin-left: 1rem; }
263 | @media screen and (min-width: 64em) { .btn { padding: 0.75rem 1rem; } }
264 | @media screen and (min-width: 42em) and (max-width: 64em) { .btn { padding: 0.6rem 0.9rem; font-size: 0.9rem; } }
265 | @media screen and (max-width: 42em) { .btn { display: block; width: 100%; padding: 0.75rem; font-size: 0.9rem; }
266 | .btn + .btn { margin-top: 1rem; margin-left: 0; } }
267 |
268 | .page-header { color: #fff; text-align: center; background-color: #159957; background-image: linear-gradient(120deg, #155799, #159957); }
269 | @media screen and (min-width: 64em) { .page-header { padding: 5rem 6rem; } }
270 | @media screen and (min-width: 42em) and (max-width: 64em) { .page-header { padding: 3rem 4rem; } }
271 | @media screen and (max-width: 42em) { .page-header { padding: 2rem 1rem; } }
272 |
273 | .project-name { margin-top: 0; margin-bottom: 0.1rem; }
274 | @media screen and (min-width: 64em) { .project-name { font-size: 3.25rem; } }
275 | @media screen and (min-width: 42em) and (max-width: 64em) { .project-name { font-size: 2.25rem; } }
276 | @media screen and (max-width: 42em) { .project-name { font-size: 1.75rem; } }
277 |
278 | .project-tagline { margin-bottom: 2rem; font-weight: normal; opacity: 0.7; }
279 | @media screen and (min-width: 64em) { .project-tagline { font-size: 1.25rem; } }
280 | @media screen and (min-width: 42em) and (max-width: 64em) { .project-tagline { font-size: 1.15rem; } }
281 | @media screen and (max-width: 42em) { .project-tagline { font-size: 1rem; } }
282 |
283 | .main-content { word-wrap: break-word; }
284 | .main-content :first-child { margin-top: 0; }
285 | @media screen and (min-width: 64em) { .main-content { max-width: 80rem; padding: 2rem 6rem; margin: 0 auto; font-size: 1.1rem; } }
286 | @media screen and (min-width: 42em) and (max-width: 64em) { .main-content { padding: 2rem 4rem; font-size: 1.1rem; } }
287 | @media screen and (max-width: 42em) { .main-content { padding: 2rem 1rem; font-size: 1rem; } }
288 | .main-content img { max-width: 100%; }
289 | .main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 { margin-top: 2rem; margin-bottom: 1rem; font-weight: normal; color: #159957; }
290 | .main-content p { margin-bottom: 1em; }
291 | .main-content code { padding: 2px 4px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.9rem; color: #567482; background-color: #f3f6fa; border-radius: 0.3rem; }
292 | .main-content pre { padding: 0.8rem; margin-top: 0; margin-bottom: 1rem; font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace; color: #567482; word-wrap: normal; background-color: #f3f6fa; border: solid 1px #dce6f0; border-radius: 0.3rem; }
293 | .main-content pre > code { padding: 0; margin: 0; font-size: 0.9rem; color: #567482; word-break: normal; white-space: pre; background: transparent; border: 0; }
294 | .main-content .highlight { margin-bottom: 1rem; }
295 | .main-content .highlight pre { margin-bottom: 0; word-break: normal; }
296 | .main-content .highlight pre, .main-content pre { padding: 0.8rem; overflow: auto; font-size: 0.9rem; line-height: 1.45; border-radius: 0.3rem; -webkit-overflow-scrolling: touch; }
297 | .main-content pre code, .main-content pre tt { display: inline; max-width: initial; padding: 0; margin: 0; overflow: initial; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; }
298 | .main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after { content: normal; }
299 | .main-content ul, .main-content ol { margin-top: 0; }
300 | .main-content blockquote { padding: 0 1rem; margin-left: 0; color: #819198; border-left: 0.3rem solid #dce6f0; }
301 | .main-content blockquote > :first-child { margin-top: 0; }
302 | .main-content blockquote > :last-child { margin-bottom: 0; }
303 | .main-content table { display: block; width: 100%; overflow: auto; word-break: normal; word-break: keep-all; -webkit-overflow-scrolling: touch; }
304 | .main-content table th { font-weight: bold; }
305 | .main-content table th, .main-content table td { padding: 0.5rem 1rem; border: 1px solid #e9ebec; }
306 | .main-content dl { padding: 0; }
307 | .main-content dl dt { padding: 0; margin-top: 1rem; font-size: 1rem; font-weight: bold; }
308 | .main-content dl dd { padding: 0; margin-bottom: 1rem; }
309 | .main-content hr { height: 2px; padding: 0; margin: 1rem 0; background-color: #eff0f1; border: 0; }
310 |
311 | .site-footer { padding-top: 2rem; margin-top: 2rem; border-top: solid 1px #eff0f1; }
312 | @media screen and (min-width: 64em) { .site-footer { font-size: 1rem; } }
313 | @media screen and (min-width: 42em) and (max-width: 64em) { .site-footer { font-size: 1rem; } }
314 | @media screen and (max-width: 42em) { .site-footer { font-size: 0.9rem; } }
315 |
316 | .site-footer-owner { display: block; font-weight: bold; }
317 |
318 | .site-footer-credits { color: #819198; }
319 | .ui.form select {
320 | height: 38px;
321 | }
322 |
--------------------------------------------------------------------------------
/dist/v-file-upload.js:
--------------------------------------------------------------------------------
1 | module.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=2)}([function(e,t,n){"use strict";var r=n(1);t.a={props:{url:{type:String,required:!0},thumbUrl:{type:Function,default:function(){}},accept:{type:String,default:".png,.jpg"},headers:{type:Object,default:function(){return{}}},btnLabel:{type:String,default:"Select a file"},btnUploadingLabel:{type:String,default:"Uploading file"},maxSize:{type:Number,default:15728640},additionalData:{type:Object,default:function(){return{}}},requestType:{type:String,default:"POST"}},data:function(){return{progress:0,anexo:{}}},computed:{uploading:function(){return this.progress>0},progressStyle:function(){return{width:this.progress+"%",display:this.uploading?"block":"none"}},inputWrapperStyle:function(){return{opacity:this.uploading?"0.7":"1"}}},methods:{onChangeInputFile:function(e){var t=e.target.files||e.dataTransfer.files;if(t.length){var n=t[0];if(n.size>this.maxSize)return void this.$emit("error",{code:"max_size_exceded",message:"File max size exceded, upload a file smaller than "+this.maxSize});this.upload(n)}},upload:function(e){var t=this;this.progress=.1,new r.a(this.url,this.headers,this.onProgress,this.requestType).upload(e,this.additionalData).then(function(e){t.anexo=e.target.response,t.onChangeAnexo(),t.$emit("success",e),t.progress=0,t.cleanInput()}).catch(function(e){t.$emit("error",e),t.progress=0,t.cleanInput()})},cleanInput:function(){var e=this.$refs.input;e&&(e.value="")},onProgress:function(e){this.progress=parseInt(100*e.loaded/e.total),this.$emit("progress",this.progress)},onChangeAnexo:function(){this.$emit("change",this.anexo)}}}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"POST";r(this,e),this.url=t,this.headers=n,this.onProgress=i,this.type=o}return i(e,[{key:"upload",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new XMLHttpRequest;n.open(this.type,this.url,!0),n.responseType="json",this._setXhrHeaders(n),n.upload.addEventListener("progress",this.onProgress,!1);var r=new Promise(function(e,t){n.onload=function(r){return n.status>=200&&n.status<400?e(r):t(r)},n.onerror=function(e){return t(e)}}),i=new FormData;return i.append("file",e),Object.keys(t).forEach(function(e){i.append(e,t[e])}),n.send(i),r}},{key:"_setXhrHeaders",value:function(e){var t=this;Object.keys(this.headers).forEach(function(n){return e.setRequestHeader(n,t.headers[n])})}}]),e}();t.a=o},function(e,t,n){e.exports=n(3)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(4),i=n(1);n.d(t,"FileUploadService",function(){return i.a}),t.default=Object.assign({},r.a,{install:function(e){return e.component("file-upload",r.a)}})},function(e,t,n){"use strict";function r(e){n(5)}var i=n(0),o=n(11),a=n(10),s=r,u=a(i.a,o.a,!1,s,null,null);t.a=u.exports},function(e,t,n){var r=n(6);"string"==typeof r&&(r=[[e.i,r,""]]),r.locals&&(e.exports=r.locals);n(8)("757bc36f",r,!0,{sourceMap:!1})},function(e,t,n){t=e.exports=n(7)(!1),t.push([e.i,".file-upload .input-wrapper{text-align:center;position:relative;background-color:#307dbf;height:80px}.file-upload .input-wrapper:hover{background-color:#2c70ac}.file-upload .input-wrapper #file-upload-input{width:.1px;height:.1px;opacity:0;overflow:hidden;position:absolute;z-index:-1}.file-upload .input-wrapper .file-upload-label{width:100%;font-size:1.25em;color:#fff;display:inline-block;padding:10px;position:absolute;left:0;right:0;z-index:2;line-height:1.4em}.file-upload .input-wrapper .file-upload-label:hover{cursor:pointer}.file-upload .input-wrapper .file-upload-label .file-upload-icon{display:inline-block;text-align:center;font-weight:700;font-size:40px}.file-upload .input-wrapper .file-upload-label .file-upload-icon.file-upload-icon-pulse{-webkit-animation:fade 1.5s infinite .5s;animation:fade 1.5s infinite .5s}.file-upload .input-wrapper .file-upload-progress{position:absolute;background-color:#47b04b;height:100%;max-width:100%;z-index:1;-webkit-transition:width .6s ease;transition:width .6s ease}.file-upload .thumb-preview{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-flow:row wrap;flex-flow:row wrap}.file-upload .thumb-preview .thumb-preview-item{border-radius:5px;margin:5px;background-color:#ccc;height:150px;width:150px;padding:0;position:relative}.file-upload .thumb-preview .thumb-preview-item img{border-radius:5px}@-webkit-keyframes fade{0%{opacity:1}to{opacity:0}}@keyframes fade{0%{opacity:1}to{opacity:0}}",""])},function(e,t){function n(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var o=r(i);return[n].concat(i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"})).concat([o]).join("\n")}return[n].join("\n")}function r(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r=n(t,e);return t[2]?"@media "+t[2]+"{"+r+"}":r}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},i=0;in.parts.length&&(r.parts.length=n.parts.length)}else{for(var a=[],i=0;icode{padding:0;margin:0;font-size:.9rem;color:#567482;word-break:normal;white-space:pre;background:transparent;border:0}.main-content .highlight{margin-bottom:1rem}.main-content .highlight pre{margin-bottom:0;word-break:normal}.main-content .highlight pre,.main-content pre{padding:.8rem;overflow:auto;font-size:.9rem;line-height:1.45;border-radius:.3rem;-webkit-overflow-scrolling:touch}.main-content pre code,.main-content pre tt{display:inline;max-width:none;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.main-content pre code:after,.main-content pre code:before,.main-content pre tt:after,.main-content pre tt:before{content:normal}.main-content ol,.main-content ul{margin-top:0}.main-content blockquote{padding:0 1rem;margin-left:0;color:#819198;border-left:.3rem solid #dce6f0}.main-content blockquote>:first-child{margin-top:0}.main-content blockquote>:last-child{margin-bottom:0}.main-content table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all;-webkit-overflow-scrolling:touch}.main-content table th{font-weight:700}.main-content table td,.main-content table th{padding:.5rem 1rem;border:1px solid #e9ebec}.main-content dl{padding:0}.main-content dl dt{padding:0;margin-top:1rem;font-size:1rem;font-weight:700}.main-content dl dd{padding:0;margin-bottom:1rem}.main-content hr{height:2px;padding:0;margin:1rem 0;background-color:#eff0f1;border:0}.site-footer{padding-top:2rem;margin-top:2rem;border-top:1px solid #eff0f1}@media screen and (min-width:64em){.site-footer{font-size:1rem}}@media screen and (min-width:42em) and (max-width:64em){.site-footer{font-size:1rem}}@media screen and (max-width:42em){.site-footer{font-size:.9rem}}.site-footer-owner{display:block;font-weight:700}.site-footer-credits{color:#819198}.ui.form select{height:38px}",""])},,function(e,t,i){var o=i(15);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);i(1)("2f5e5fcc",o,!0)},function(e,t,i){t=e.exports=i(0)(!1),t.push([e.i,".red{color:red}",""])},function(e,t,i){"use strict";var o=i(2),n=i(17);o.a.component("file-upload",n.a),t.a={name:"demo",data:function(){return{success:!1,error:"",additionalData:{doc_id:1}}},methods:{thumbUrl:function(e){return e&&e.id||this.success?"https://vuejs.org/images/logo.png":""},onSucess:function(){this.error="",this.success=!0},onError:function(e){this.error=e}}}},function(e,t,i){"use strict";function o(e){i(18)}var n=i(20),r=i(22),a=i(4),l=o,s=a(n.a,r.a,!1,l,null,null);t.a=s.exports},function(e,t,i){var o=i(19);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);i(1)("4be48b74",o,!0)},function(e,t,i){t=e.exports=i(0)(!1),t.push([e.i,".file-upload .input-wrapper{text-align:center;position:relative;background-color:#307dbf;height:80px}.file-upload .input-wrapper:hover{background-color:#2c70ac}.file-upload .input-wrapper #file-upload-input{width:.1px;height:.1px;opacity:0;overflow:hidden;position:absolute;z-index:-1}.file-upload .input-wrapper .file-upload-label{width:100%;font-size:1.25em;color:#fff;display:inline-block;padding:10px;position:absolute;left:0;right:0;z-index:2;line-height:1.4em}.file-upload .input-wrapper .file-upload-label:hover{cursor:pointer}.file-upload .input-wrapper .file-upload-label .file-upload-icon{display:inline-block;text-align:center;font-weight:700;font-size:40px}.file-upload .input-wrapper .file-upload-label .file-upload-icon.file-upload-icon-pulse{-webkit-animation:fade 1.5s infinite .5s;animation:fade 1.5s infinite .5s}.file-upload .input-wrapper .file-upload-progress{position:absolute;background-color:#47b04b;height:100%;max-width:100%;z-index:1;-webkit-transition:width .6s ease;transition:width .6s ease}.file-upload .thumb-preview{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-flow:row wrap;flex-flow:row wrap}.file-upload .thumb-preview .thumb-preview-item{border-radius:5px;margin:5px;background-color:#ccc;height:150px;width:150px;padding:0;position:relative}.file-upload .thumb-preview .thumb-preview-item img{border-radius:5px}@-webkit-keyframes fade{0%{opacity:1}to{opacity:0}}@keyframes fade{0%{opacity:1}to{opacity:0}}",""])},function(e,t,i){"use strict";var o=i(21);t.a={props:{url:{type:String,required:!0},thumbUrl:{type:Function,default:function(){}},accept:{type:String,default:".png,.jpg"},headers:{type:Object,default:function(){return{}}},btnLabel:{type:String,default:"Select a file"},btnUploadingLabel:{type:String,default:"Uploading file"},maxSize:{type:Number,default:15728640},additionalData:{type:Object,default:function(){return{}}}},data:function(){return{progress:0,anexo:{}}},computed:{uploading:function(){return this.progress>0},progressStyle:function(){return{width:this.progress+"%",display:this.uploading?"block":"none"}},inputWrapperStyle:function(){return{opacity:this.uploading?"0.7":"1"}}},methods:{onChangeInputFile:function(e){var t=e.target.files||e.dataTransfer.files;if(t.length){var i=t[0];if(i.size>this.maxSize)return void this.$emit("error",{code:"max_size_exceded",message:"File max size exceded, upload a file smaller than "+this.maxSize});this.upload(i)}},upload:function(e){var t=this;this.progress=.1,new o.a(this.url,this.headers,this.onProgress).upload(e,this.additionalData).then(function(e){t.anexo=e.target.response,t.onChangeAnexo(),t.$emit("success",e),t.progress=0,t.cleanInput()}).catch(function(e){t.$emit("error",e),t.progress=0,t.cleanInput()})},cleanInput:function(){var e=window.document.getElementById("file-upload-input");e&&(e.value="")},onProgress:function(e){this.progress=parseInt(100*e.loaded/e.total),this.$emit("progress",this.progress)},onChangeAnexo:function(){this.$emit("change",this.anexo)}}}},function(e,t,i){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};o(this,e),this.url=t,this.headers=i,this.onProgress=n}return n(e,[{key:"upload",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=new XMLHttpRequest;i.responseType="json",i.open("POST",this.url,!0),this._setXhrHeaders(i),i.upload.addEventListener("progress",this.onProgress,!1);var o=new Promise(function(e,t){i.onload=function(o){return i.status>=200&&i.status<400?e(o):t(o)},i.onerror=function(e){return t(e)}}),n=new FormData;return n.append("file",e),Object.keys(t).forEach(function(e){n.append(e,t[e])}),i.send(n),o}},{key:"_setXhrHeaders",value:function(e){var t=this;Object.keys(this.headers).forEach(function(i){return e.setRequestHeader(i,t.headers[i])})}}]),e}();t.a=r},function(e,t,i){"use strict";var o=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"file-upload"},[e.thumbUrl(e.anexo)?i("div",{staticClass:"thumb-preview"},[i("div",{staticClass:"thumb-preview-item"},[i("img",{attrs:{src:e.thumbUrl(e.anexo)}})])]):e._e(),i("div",{staticClass:"input-wrapper",style:e.inputWrapperStyle},[i("input",{attrs:{id:"file-upload-input",type:"file",name:"file",accept:e.accept,multiple:!1,disabled:e.uploading},on:{change:e.onChangeInputFile}}),i("label",{staticClass:"file-upload-label",attrs:{for:"file-upload-input"}},[i("span",{staticClass:"file-upload-icon",class:{"file-upload-icon-pulse":e.uploading}},[e._v("⇪")]),i("div",[e._v(e._s(e.uploading?e.btnUploadingLabel:e.btnLabel))])]),i("div",{staticClass:"file-upload-progress",style:e.progressStyle})])])},n=[],r={render:o,staticRenderFns:n};t.a=r},function(e,t,i){"use strict";var o=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticStyle:{"text-align":"center"}},[i("div",{staticClass:"input-group"},[i("file-upload",{attrs:{url:"https://postman-echo.com/post","thumb-url":e.thumbUrl,"additional-data":e.additionalData},on:{success:e.onSucess,error:e.onError}}),i("div",{staticClass:"red"},[e._v(e._s(e.error))])],1)])},n=[],r={render:o,staticRenderFns:n};t.a=r}],[5]);
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 | v-file-upload
--------------------------------------------------------------------------------
/docs/manifest.e3152fb8.js:
--------------------------------------------------------------------------------
1 | (function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var a,i,f,l=0,p=[];ln.parts.length&&(r.parts.length=n.parts.length)}else{for(var a=[],o=0;o=0&&Math.floor(e)===e&&isFinite(t)}function d(t){return null==t?"":"object"==typeof t?JSON.stringify(t,null,2):String(t)}function p(t){var e=parseFloat(t);return isNaN(e)?t:e}function v(t,e){for(var n=Object.create(null),r=t.split(","),o=0;o-1)return t.splice(n,1)}}function m(t,e){return vr.call(t,e)}function y(t){var e=Object.create(null);return function(n){return e[n]||(e[n]=t(n))}}function g(t,e){function n(n){var r=arguments.length;return r?r>1?t.apply(e,arguments):t.call(e,n):t.call(e)}return n._length=t.length,n}function _(t,e){e=e||0;for(var n=t.length-e,r=new Array(n);n--;)r[n]=t[n+e];return r}function b(t,e){for(var n in e)t[n]=e[n];return t}function C(t){for(var e={},n=0;n0&&(a=ht(a,(e||"")+"_"+n),vt(a[0])&&vt(u)&&(l[c]=I(u.text+a[0].text),a.shift()),l.push.apply(l,a)):s(a)?vt(u)?l[c]=I(u.text+a):""!==a&&l.push(I(a)):vt(a)&&vt(u)?l[c]=I(u.text+a.text):(i(t._isVList)&&o(a.tag)&&r(a.key)&&o(e)&&(a.key="__vlist"+e+"_"+n+"__"),l.push(a)));return l}function mt(t,e){return(t.__esModule||Hr&&"Module"===t[Symbol.toStringTag])&&(t=t.default),c(t)?e.extend(t):t}function yt(t,e,n,r,o){var i=Xr();return i.asyncFactory=t,i.asyncMeta={data:e,context:n,children:r,tag:o},i}function gt(t,e,n){if(i(t.error)&&o(t.errorComp))return t.errorComp;if(o(t.resolved))return t.resolved;if(i(t.loading)&&o(t.loadingComp))return t.loadingComp;if(!o(t.contexts)){var a=t.contexts=[n],s=!0,u=function(){for(var t=0,e=a.length;tCo&&mo[n].id>t.id;)n--;mo.splice(n+1,0,t)}else mo.push(t);_o||(_o=!0,at(Dt))}}function Bt(t){$o.clear(),Vt(t,$o)}function Vt(t,e){var n,r,o=Array.isArray(t);if((o||c(t))&&Object.isExtensible(t)){if(t.__ob__){var i=t.__ob__.dep.id;if(e.has(i))return;e.add(i)}if(o)for(n=t.length;n--;)Vt(t[n],e);else for(r=Object.keys(t),n=r.length;n--;)Vt(t[r[n]],e)}}function Ht(t,e,n){xo.get=function(){return this[e][n]},xo.set=function(t){this[e][n]=t},Object.defineProperty(t,n,xo)}function zt(t){t._watchers=[];var e=t.$options;e.props&&Wt(t,e.props),e.methods&&Zt(t,e.methods),e.data?qt(t):P(t._data={},!0),e.computed&&Gt(t,e.computed),e.watch&&e.watch!==Dr&&Qt(t,e.watch)}function Wt(t,e){var n=t.$options.propsData||{},r=t._props={},o=t.$options._propKeys=[],i=!t.$parent;to.shouldConvert=i;for(var a in e)(function(i){o.push(i);var a=Z(i,e,n,t);R(r,i,a),i in t||Ht(t,"_props",i)})(a);to.shouldConvert=!0}function qt(t){var e=t.$options.data;e=t._data="function"==typeof e?Kt(e,t):e||{},u(e)||(e={});for(var n=Object.keys(e),r=t.$options.props,o=(t.$options.methods,n.length);o--;){var i=n[o];r&&m(r,i)||k(i)||Ht(t,"_data",i)}P(e,!0)}function Kt(t,e){try{return t.call(e,e)}catch(t){return et(t,e,"data()"),{}}}function Gt(t,e){var n=t._computedWatchers=Object.create(null),r=Br();for(var o in e){var i=e[o],a="function"==typeof i?i:i.get;r||(n[o]=new Ao(t,a||w,w,ko)),o in t||Jt(t,o,i)}}function Jt(t,e,n){var r=!Br();"function"==typeof n?(xo.get=r?Xt(e):n,xo.set=w):(xo.get=n.get?r&&!1!==n.cache?Xt(e):n.get:w,xo.set=n.set?n.set:w),Object.defineProperty(t,e,xo)}function Xt(t){return function(){var e=this._computedWatchers&&this._computedWatchers[t];if(e)return e.dirty&&e.evaluate(),qr.target&&e.depend(),e.value}}function Zt(t,e){t.$options.props;for(var n in e)t[n]=null==e[n]?w:g(e[n],t)}function Qt(t,e){for(var n in e){var r=e[n];if(Array.isArray(r))for(var o=0;o=0||n.indexOf(t[o])<0)&&r.push(t[o]);return r}return t}function Ee(t){this._init(t)}function je(t){t.use=function(t){var e=this._installedPlugins||(this._installedPlugins=[]);if(e.indexOf(t)>-1)return this;var n=_(arguments,1);return n.unshift(this),"function"==typeof t.install?t.install.apply(t,n):"function"==typeof t&&t.apply(null,n),e.push(t),this}}function Ie(t){t.mixin=function(t){return this.options=J(this.options,t),this}}function Le(t){t.cid=0;var e=1;t.extend=function(t){t=t||{};var n=this,r=n.cid,o=t._Ctor||(t._Ctor={});if(o[r])return o[r];var i=t.name||n.options.name,a=function(t){this._init(t)};return a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.cid=e++,a.options=J(n.options,t),a.super=n,a.options.props&&Me(a),a.options.computed&&Ne(a),a.extend=n.extend,a.mixin=n.mixin,a.use=n.use,Ar.forEach(function(t){a[t]=n[t]}),i&&(a.options.components[i]=a),a.superOptions=n.options,a.extendOptions=t,a.sealedOptions=b({},a.options),o[r]=a,a}}function Me(t){var e=t.options.props;for(var n in e)Ht(t.prototype,"_props",n)}function Ne(t){var e=t.options.computed;for(var n in e)Jt(t.prototype,n,e[n])}function De(t){Ar.forEach(function(e){t[e]=function(t,n){return n?("component"===e&&u(n)&&(n.name=n.name||t,n=this.options._base.extend(n)),"directive"===e&&"function"==typeof n&&(n={bind:n,update:n}),this.options[e+"s"][t]=n,n):this.options[e+"s"][t]}})}function Pe(t){return t&&(t.Ctor.options.name||t.tag)}function Re(t,e){return Array.isArray(t)?t.indexOf(e)>-1:"string"==typeof t?t.split(",").indexOf(e)>-1:!!l(t)&&t.test(e)}function Ue(t,e){var n=t.cache,r=t.keys,o=t._vnode;for(var i in n){var a=n[i];if(a){var s=Pe(a.componentOptions);s&&!e(s)&&Fe(n,i,r,o)}}}function Fe(t,e,n,r){var o=t[e];o&&o!==r&&o.componentInstance.$destroy(),t[e]=null,h(n,e)}function Be(t){for(var e=t.data,n=t,r=t;o(r.componentInstance);)r=r.componentInstance._vnode,r.data&&(e=Ve(r.data,e));for(;o(n=n.parent);)n.data&&(e=Ve(e,n.data));return He(e.staticClass,e.class)}function Ve(t,e){return{staticClass:ze(t.staticClass,e.staticClass),class:o(t.class)?[t.class,e.class]:e.class}}function He(t,e){return o(t)||o(e)?ze(t,We(e)):""}function ze(t,e){return t?e?t+" "+e:t:e||""}function We(t){return Array.isArray(t)?qe(t):c(t)?Ke(t):"string"==typeof t?t:""}function qe(t){for(var e,n="",r=0,i=t.length;r-1?Xo[t]=e.constructor===window.HTMLUnknownElement||e.constructor===window.HTMLElement:Xo[t]=/HTMLUnknownElement/.test(e.toString())}function Xe(t){if("string"==typeof t){var e=document.querySelector(t);return e||document.createElement("div")}return t}function Ze(t,e){var n=document.createElement(t);return"select"!==t?n:(e.data&&e.data.attrs&&void 0!==e.data.attrs.multiple&&n.setAttribute("multiple","multiple"),n)}function Qe(t,e){return document.createElementNS(qo[t],e)}function Ye(t){return document.createTextNode(t)}function tn(t){return document.createComment(t)}function en(t,e,n){t.insertBefore(e,n)}function nn(t,e){t.removeChild(e)}function rn(t,e){t.appendChild(e)}function on(t){return t.parentNode}function an(t){return t.nextSibling}function sn(t){return t.tagName}function cn(t,e){t.textContent=e}function un(t,e,n){t.setAttribute(e,n)}function ln(t,e){var n=t.data.ref;if(n){var r=t.context,o=t.componentInstance||t.elm,i=r.$refs;e?Array.isArray(i[n])?h(i[n],o):i[n]===o&&(i[n]=void 0):t.data.refInFor?Array.isArray(i[n])?i[n].indexOf(o)<0&&i[n].push(o):i[n]=[o]:i[n]=o}}function fn(t,e){return t.key===e.key&&(t.tag===e.tag&&t.isComment===e.isComment&&o(t.data)===o(e.data)&&dn(t,e)||i(t.isAsyncPlaceholder)&&t.asyncFactory===e.asyncFactory&&r(e.asyncFactory.error))}function dn(t,e){if("input"!==t.tag)return!0;var n,r=o(n=t.data)&&o(n=n.attrs)&&n.type,i=o(n=e.data)&&o(n=n.attrs)&&n.type;return r===i||Zo(r)&&Zo(i)}function pn(t,e,n){var r,i,a={};for(r=e;r<=n;++r)i=t[r].key,o(i)&&(a[i]=r);return a}function vn(t,e){(t.data.directives||e.data.directives)&&hn(t,e)}function hn(t,e){var n,r,o,i=t===ti,a=e===ti,s=mn(t.data.directives,t.context),c=mn(e.data.directives,e.context),u=[],l=[];for(n in c)r=s[n],o=c[n],r?(o.oldValue=r.value,gn(o,"update",e,t),o.def&&o.def.componentUpdated&&l.push(o)):(gn(o,"bind",e,t),o.def&&o.def.inserted&&u.push(o));if(u.length){var f=function(){for(var n=0;n-1?e.split(/\s+/).forEach(function(e){return t.classList.add(e)}):t.classList.add(e);else{var n=" "+(t.getAttribute("class")||"")+" ";n.indexOf(" "+e+" ")<0&&t.setAttribute("class",(n+e).trim())}}function Dn(t,e){if(e&&(e=e.trim()))if(t.classList)e.indexOf(" ")>-1?e.split(/\s+/).forEach(function(e){return t.classList.remove(e)}):t.classList.remove(e),t.classList.length||t.removeAttribute("class");else{for(var n=" "+(t.getAttribute("class")||"")+" ",r=" "+e+" ";n.indexOf(r)>=0;)n=n.replace(r," ");n=n.trim(),n?t.setAttribute("class",n):t.removeAttribute("class")}}function Pn(t){if(t){if("object"==typeof t){var e={};return!1!==t.css&&b(e,gi(t.name||"v")),b(e,t),e}return"string"==typeof t?gi(t):void 0}}function Rn(t){ki(function(){ki(t)})}function Un(t,e){var n=t._transitionClasses||(t._transitionClasses=[]);n.indexOf(e)<0&&(n.push(e),Nn(t,e))}function Fn(t,e){t._transitionClasses&&h(t._transitionClasses,e),Dn(t,e)}function Bn(t,e,n){var r=Vn(t,e),o=r.type,i=r.timeout,a=r.propCount;if(!o)return n();var s=o===bi?Ai:xi,c=0,u=function(){t.removeEventListener(s,l),n()},l=function(e){e.target===t&&++c>=a&&u()};setTimeout(function(){c0&&(n=bi,l=a,f=i.length):e===Ci?u>0&&(n=Ci,l=u,f=c.length):(l=Math.max(a,u),n=l>0?a>u?bi:Ci:null,f=n?n===bi?i.length:c.length:0),{type:n,timeout:l,propCount:f,hasTransform:n===bi&&Oi.test(r[wi+"Property"])}}function Hn(t,e){for(;t.length1}function Jn(t,e){!0!==e.data.show&&Wn(e)}function Xn(t,e,n){Zn(t,e,n),(jr||Lr)&&setTimeout(function(){Zn(t,e,n)},0)}function Zn(t,e,n){var r=e.value,o=t.multiple;if(!o||Array.isArray(r)){for(var i,a,s=0,c=t.options.length;s-1,a.selected!==i&&(a.selected=i);else if(A(Yn(a),r))return void(t.selectedIndex!==s&&(t.selectedIndex=s));o||(t.selectedIndex=-1)}}function Qn(t,e){return e.every(function(e){return!A(e,t)})}function Yn(t){return"_value"in t?t._value:t.value}function tr(t){t.target.composing=!0}function er(t){t.target.composing&&(t.target.composing=!1,nr(t.target,"input"))}function nr(t,e){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0),t.dispatchEvent(n)}function rr(t){return!t.componentInstance||t.data&&t.data.transition?t:rr(t.componentInstance._vnode)}function or(t){var e=t&&t.componentOptions;return e&&e.Ctor.options.abstract?or(bt(e.children)):t}function ir(t){var e={},n=t.$options;for(var r in n.propsData)e[r]=t[r];var o=n._parentListeners;for(var i in o)e[mr(i)]=o[i];return e}function ar(t,e){if(/\d-keep-alive$/.test(e.tag))return t("keep-alive",{props:e.componentOptions.propsData})}function sr(t){for(;t=t.parent;)if(t.data.transition)return!0}function cr(t,e){return e.key===t.key&&e.tag===t.tag}function ur(t){t.elm._moveCb&&t.elm._moveCb(),t.elm._enterCb&&t.elm._enterCb()}function lr(t){t.data.newPos=t.elm.getBoundingClientRect()}function fr(t){var e=t.data.pos,n=t.data.newPos,r=e.left-n.left,o=e.top-n.top;if(r||o){t.data.moved=!0;var i=t.elm.style;i.transform=i.WebkitTransform="translate("+r+"px,"+o+"px)",i.transitionDuration="0s"}}var dr=Object.prototype.toString,pr=(v("slot,component",!0),v("key,ref,slot,slot-scope,is")),vr=Object.prototype.hasOwnProperty,hr=/-(\w)/g,mr=y(function(t){return t.replace(hr,function(t,e){return e?e.toUpperCase():""})}),yr=y(function(t){return t.charAt(0).toUpperCase()+t.slice(1)}),gr=/\B([A-Z])/g,_r=y(function(t){return t.replace(gr,"-$1").toLowerCase()}),br=function(t,e,n){return!1},Cr=function(t){return t},wr="data-server-rendered",Ar=["component","directive","filter"],$r=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],xr={optionMergeStrategies:Object.create(null),silent:!1,productionTip:!1,devtools:!1,performance:!1,errorHandler:null,warnHandler:null,ignoredElements:[],keyCodes:Object.create(null),isReservedTag:br,isReservedAttr:br,isUnknownElement:br,getTagNamespace:w,parsePlatformTagName:Cr,mustUseProp:br,_lifecycleHooks:$r},kr=Object.freeze({}),Or=/[^\w.$]/,Tr="__proto__"in{},Sr="undefined"!=typeof window,Er=Sr&&window.navigator.userAgent.toLowerCase(),jr=Er&&/msie|trident/.test(Er),Ir=Er&&Er.indexOf("msie 9.0")>0,Lr=Er&&Er.indexOf("edge/")>0,Mr=Er&&Er.indexOf("android")>0,Nr=Er&&/iphone|ipad|ipod|ios/.test(Er),Dr=(Er&&/chrome\/\d+/.test(Er),{}.watch),Pr=!1;if(Sr)try{var Rr={};Object.defineProperty(Rr,"passive",{get:function(){Pr=!0}}),window.addEventListener("test-passive",null,Rr)}catch(t){}var Ur,Fr,Br=function(){return void 0===Ur&&(Ur=!Sr&&void 0!==t&&"server"===t.process.env.VUE_ENV),Ur},Vr=Sr&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,Hr="undefined"!=typeof Symbol&&S(Symbol)&&"undefined"!=typeof Reflect&&S(Reflect.ownKeys);Fr="undefined"!=typeof Set&&S(Set)?Set:function(){function t(){this.set=Object.create(null)}return t.prototype.has=function(t){return!0===this.set[t]},t.prototype.add=function(t){this.set[t]=!0},t.prototype.clear=function(){this.set=Object.create(null)},t}();var zr=w,Wr=0,qr=function(){this.id=Wr++,this.subs=[]};qr.prototype.addSub=function(t){this.subs.push(t)},qr.prototype.removeSub=function(t){h(this.subs,t)},qr.prototype.depend=function(){qr.target&&qr.target.addDep(this)},qr.prototype.notify=function(){for(var t=this.subs.slice(),e=0,n=t.length;e1?_(n):n;for(var r=_(arguments,1),o=0,i=n.length;oparseInt(this.max)&&Fe(o,i[0],i,this._vnode)),t.data.keepAlive=!0}return t}},Mo={KeepAlive:Lo};(function(t){var e={};e.get=function(){return xr},Object.defineProperty(t,"config",e),t.util={warn:zr,extend:b,mergeOptions:J,defineReactive:R},t.set=U,t.delete=F,t.nextTick=at,t.options=Object.create(null),Ar.forEach(function(e){t.options[e+"s"]=Object.create(null)}),t.options._base=t,b(t.options.components,Mo),je(t),Ie(t),Le(t),De(t)})(Ee),Object.defineProperty(Ee.prototype,"$isServer",{get:Br}),Object.defineProperty(Ee.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Ee.version="2.5.2";var No,Do,Po=v("style,class"),Ro=v("input,textarea,option,select,progress"),Uo=function(t,e,n){return"value"===n&&Ro(t)&&"button"!==e||"selected"===n&&"option"===t||"checked"===n&&"input"===t||"muted"===n&&"video"===t},Fo=v("contenteditable,draggable,spellcheck"),Bo=v("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),Vo="http://www.w3.org/1999/xlink",Ho=function(t){return":"===t.charAt(5)&&"xlink"===t.slice(0,5)},zo=function(t){return Ho(t)?t.slice(6,t.length):""},Wo=function(t){return null==t||!1===t},qo={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},Ko=v("html,body,base,head,link,meta,style,title,address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,menuitem,summary,content,element,shadow,template,blockquote,iframe,tfoot"),Go=v("svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view",!0),Jo=function(t){return Ko(t)||Go(t)},Xo=Object.create(null),Zo=v("text,number,password,search,email,tel,url"),Qo=Object.freeze({createElement:Ze,createElementNS:Qe,createTextNode:Ye,createComment:tn,insertBefore:en,removeChild:nn,appendChild:rn,parentNode:on,nextSibling:an,tagName:sn,setTextContent:cn,setAttribute:un}),Yo={create:function(t,e){ln(e)},update:function(t,e){t.data.ref!==e.data.ref&&(ln(t,!0),ln(e))},destroy:function(t){ln(t,!0)}},ti=new Gr("",{},[]),ei=["create","activate","update","remove","destroy"],ni={create:vn,update:vn,destroy:function(t){vn(t,ti)}},ri=Object.create(null),oi=[Yo,ni],ii={create:_n,update:_n},ai={create:Cn,update:Cn},si="__r",ci="__c",ui={create:kn,update:kn},li={create:On,update:On},fi=y(function(t){var e={},n=/;(?![^(]*\))/g,r=/:(.+)/;return t.split(n).forEach(function(t){if(t){var n=t.split(r);n.length>1&&(e[n[0].trim()]=n[1].trim())}}),e}),di=/^--/,pi=/\s*!important$/,vi=function(t,e,n){if(di.test(e))t.style.setProperty(e,n);else if(pi.test(n))t.style.setProperty(e,n.replace(pi,""),"important");else{var r=mi(e);if(Array.isArray(n))for(var o=0,i=n.length;ov?(f=r(n[y+1])?null:n[y+1].elm,g(t,f,n,p,y,i)):p>y&&b(t,e,d,v)}function A(t,e,n,r){for(var i=n;i=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(8),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){(function(t,e){(function(t,n){"use strict";function r(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n1)for(var n=1;n",
6 | "typings": "types/index.d.ts",
7 | "main": "dist/v-file-upload.js",
8 | "license": "MIT",
9 | "scripts": {
10 | "dist": "poi build src/v-file-upload.js",
11 | "dist:demo": "poi build ./demo/index.js -c ./poi.config.demo.js",
12 | "start": "poi ./demo/index.js"
13 | },
14 | "files": [
15 | "dist/",
16 | "types/"
17 | ],
18 | "keywords": [
19 | "vue",
20 | "upload",
21 | "file-upload",
22 | "vue-upload",
23 | "vue-file-upload",
24 | "upload-vue",
25 | "file-upload-vue",
26 | "v-upload",
27 | "v-file-upload"
28 | ],
29 | "repository": {
30 | "type": "git",
31 | "url": "git+https://github.com/dflourusso/v-file-upload.git"
32 | },
33 | "bugs": {
34 | "url": "https://github.com/dflourusso/v-file-upload/issues"
35 | },
36 | "homepage": "https://github.com/dflourusso/v-file-upload#readme",
37 | "devDependencies": {
38 | "poi": "^9.6.13",
39 | "pug": "^2.0.3",
40 | "stylus": "^0.54.5",
41 | "stylus-loader": "^3.0.2"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/poi.config.demo.js:
--------------------------------------------------------------------------------
1 | module.exports = (options, req) => ({
2 | extractCSS: false,
3 | sourceMap: false,
4 | removeDist: true,
5 | dist: 'docs',
6 | homepage: '/v-file-upload/',
7 | html: {
8 | template: './demo/index.html'
9 | }
10 | })
11 |
--------------------------------------------------------------------------------
/poi.config.js:
--------------------------------------------------------------------------------
1 | module.exports = (options, req) => ({
2 | extractCSS: false,
3 | html: false,
4 | sourceMap: false,
5 | format: 'cjs',
6 | filename: {
7 | js: 'v-file-upload.js'
8 | },
9 | hash: false,
10 | removeDist: true
11 | })
12 |
--------------------------------------------------------------------------------
/src/FileUpload.js:
--------------------------------------------------------------------------------
1 | class FileUpload {
2 | constructor(url, headers = {}, onProgress = () => {}, type = 'POST') {
3 | this.url = url
4 | this.headers = headers
5 | this.onProgress = onProgress
6 | this.type = type
7 | }
8 |
9 | upload(file, additionalData = {}) {
10 | let xhr = new XMLHttpRequest()
11 |
12 | // Headers
13 | xhr.open(this.type, this.url, true)
14 | xhr.responseType = 'json'
15 | this._setXhrHeaders(xhr)
16 |
17 | // Events
18 | xhr.upload.addEventListener('progress', this.onProgress, false)
19 | let promise = new Promise((resolve, reject) => {
20 | xhr.onload = e =>
21 | xhr.status >= 200 && xhr.status < 400 ? resolve(e) : reject(e)
22 | xhr.onerror = e => reject(e)
23 | })
24 |
25 | // Start upload
26 | let formData = new FormData()
27 | formData.append('file', file)
28 | Object.keys(additionalData).forEach(p => {
29 | formData.append(p, additionalData[p])
30 | })
31 | xhr.send(formData)
32 |
33 | return promise
34 | }
35 |
36 | _setXhrHeaders(xhr) {
37 | Object.keys(this.headers).forEach(p =>
38 | xhr.setRequestHeader(p, this.headers[p])
39 | )
40 | }
41 | }
42 |
43 | export default FileUpload
44 |
--------------------------------------------------------------------------------
/src/FileUpload.vue:
--------------------------------------------------------------------------------
1 |
2 | .file-upload
3 | .thumb-preview(v-if='thumbUrl(anexo)')
4 | .thumb-preview-item
5 | img(:src='thumbUrl(anexo)')
6 | .input-wrapper(:style='inputWrapperStyle')
7 | input.file-upload-input(:id='fileUploadInputName' type='file', name='file', @change='onChangeInputFile', :accept='accept', :multiple='false', :disabled='uploading', ref='input')
8 | label.file-upload-label(:for='fileUploadInputName')
9 | span.file-upload-icon(:class="{'file-upload-icon-pulse': uploading}") ⇪
10 | div {{ uploading ? btnUploadingLabel : btnLabel }}
11 | div.file-upload-progress(:style='progressStyle')
12 |
13 |
14 |
117 |
118 |
217 |
--------------------------------------------------------------------------------
/src/v-file-upload.js:
--------------------------------------------------------------------------------
1 | // need to use require instead of import (changes from babel 5 to 6)
2 | import FileUpload from './FileUpload.vue'
3 | import FileUploadService from './FileUpload.js'
4 |
5 | export { FileUploadService }
6 |
7 | export default {
8 | ...FileUpload,
9 | install: vue => vue.component('file-upload', FileUpload)
10 | }
11 |
--------------------------------------------------------------------------------
/types/index.d.ts:
--------------------------------------------------------------------------------
1 | import { Component } from 'vue'
2 |
3 | export class FileUploadService {
4 | constructor(url: string, headers?: object, onProgress?: any, type?: string)
5 |
6 | upload(file: File, additionalData?: object): Promise