@enso-ui/select 3.0.12 → 3.0.13

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/select",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "description": "Select",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,8 +1,9 @@
1
1
  <template>
2
2
  <vue-select v-bind="$attrs"
3
+ :http="http"
3
4
  :i18n="i18n"
4
5
  :error-handler="errorHandler"
5
- :source="source ? route(source) : null"
6
+ :source="source ? route(source) : null"
6
7
  ref="select">
7
8
  <template #option="props">
8
9
  <slot name="option"
@@ -19,7 +20,7 @@ export default {
19
20
 
20
21
  components: { VueSelect },
21
22
 
22
- inject: ['errorHandler', 'i18n', 'route'],
23
+ inject: ['errorHandler', 'http', 'i18n', 'route'],
23
24
 
24
25
  props: {
25
26
  source: {
@@ -29,6 +29,10 @@ export default {
29
29
  throw error;
30
30
  },
31
31
  },
32
+ http: {
33
+ default: null,
34
+ type: Function,
35
+ },
32
36
  i18n: {
33
37
  type: Function,
34
38
  default: v => v,
@@ -227,6 +231,10 @@ export default {
227
231
  },
228
232
 
229
233
  created() {
234
+ if(!this.http && this.source !== null) {
235
+ throw Error('Using the serverside mode requires providing a http client');
236
+ }
237
+
230
238
  this.init();
231
239
  },
232
240
 
@@ -278,10 +286,10 @@ export default {
278
286
  this.ongoingRequest.cancel();
279
287
  }
280
288
 
281
- this.ongoingRequest = axios.CancelToken.source();
289
+ this.ongoingRequest = this.http.CancelToken.source();
282
290
  this.loading = true;
283
291
 
284
- axios.get(this.source, {
292
+ this.http.get(this.source, {
285
293
  params: this.requestParams(),
286
294
  cancelToken: this.ongoingRequest.token,
287
295
  }).then(({ data }) => {
@@ -291,7 +299,7 @@ export default {
291
299
  this.loading = false;
292
300
  }).catch(error => {
293
301
  this.loading = false;
294
- if (!axios.isCancel(error)) {
302
+ if (!this.http.isCancel(error)) {
295
303
  this.errorHandler(error);
296
304
  }
297
305
  });