@enso-ui/uploader 2.0.5 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enso-ui/uploader",
3
- "version": "2.0.5",
3
+ "version": "2.0.9",
4
4
  "description": "File Uploader",
5
5
  "main": "bulma/index.js",
6
6
  "scripts": {
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <uploader v-bind="$attrs"
3
- :i18n="i18n"
3
+ :http="http"
4
+ :i18n="i18n"
4
5
  ref="uploader"/>
5
6
  </template>
6
7
 
@@ -12,7 +13,7 @@ export default {
12
13
 
13
14
  components: { Uploader },
14
15
 
15
- inject: ['i18n'],
16
+ inject: ['http', 'i18n'],
16
17
 
17
18
  methods: {
18
19
  browseFiles() {
@@ -1,11 +1,11 @@
1
1
  <template>
2
- <core-uploader v-bind="$attrs"
3
- ref="uploader">
4
- <template #default="{
2
+ <form class="is-marginless"
3
+ @submit.prevent>
4
+ <core-uploader v-bind="$attrs"
5
+ ref="uploader">
6
+ <template #default="{
5
7
  compact, controlEvents, files, inputBindings, inputEvents, label, manual,
6
8
  }">
7
- <form class="is-marginless"
8
- @submit.prevent>
9
9
  <input class="is-hidden"
10
10
  v-bind="inputBindings"
11
11
  v-on="inputEvents">
@@ -24,9 +24,9 @@
24
24
  </span>
25
25
  </a>
26
26
  </slot>
27
- </form>
28
- </template>
29
- </core-uploader>
27
+ </template>
28
+ </core-uploader>
29
+ </form>
30
30
  </template>
31
31
 
32
32
  <script>
@@ -19,6 +19,10 @@ export default {
19
19
  default: 20 * 1024 * 1024,
20
20
  type: Number,
21
21
  },
22
+ http: {
23
+ required: true,
24
+ type: Function,
25
+ },
22
26
  i18n: {
23
27
  default: (v) => v,
24
28
  type: Function,
@@ -45,6 +49,13 @@ export default {
45
49
  },
46
50
  },
47
51
 
52
+ emits: [
53
+ 'change', 'input', 'open-file-browser', 'upload-start',
54
+ 'upload-successful', 'upload-error',
55
+ ],
56
+
57
+ inheritAttrs: false,
58
+
48
59
  data: () => ({
49
60
  formData: new FormData(),
50
61
  succesfull: 0,
@@ -66,7 +77,7 @@ export default {
66
77
  : this.i18n('File');
67
78
  },
68
79
  input() {
69
- return !!this.$el && this.$el.querySelector('input');
80
+ return !!this.$parent.$el && this.$parent.$el.querySelector('input');
70
81
  },
71
82
  },
72
83
 
@@ -91,7 +102,7 @@ export default {
91
102
  return;
92
103
  }
93
104
 
94
- axios.post(this.url, this.formData).then((response) => {
105
+ this.http.post(this.url, this.formData).then((response) => {
95
106
  this.reset();
96
107
  this.$emit('upload-successful', response.data);
97
108
  }).catch((error) => {
@@ -157,7 +168,7 @@ export default {
157
168
  return true;
158
169
  },
159
170
  reset() {
160
- this.$el.reset();
171
+ this.$parent.$el.reset();
161
172
  this.formData = new FormData();
162
173
  this.succesfull = 0;
163
174
  this.files = false;