@enso-ui/select 3.0.11 → 3.0.15

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.11",
3
+ "version": "3.0.15",
4
4
  "description": "Select",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  "@enso-ui/search-mode": "^3.0",
30
30
  "@fortawesome/fontawesome-free": "^5.2.0",
31
31
  "@fortawesome/fontawesome-svg-core": "^1.2.2",
32
- "@fortawesome/free-solid-svg-icons": "^5.2.0",
32
+ "@fortawesome/free-solid-svg-icons": "^5.11.2",
33
33
  "@fortawesome/vue-fontawesome": "3.0.0-5",
34
34
  "bulma": "^0.9.0",
35
35
  "lodash": "^4.17.10",
@@ -1,8 +1,9 @@
1
1
  <template>
2
- <vue-select v-bind="$attrs"
2
+ <vue-select
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: {
@@ -1,14 +1,17 @@
1
1
  <template>
2
- <div class="vue-select">
3
- <core-select v-bind="{...$attrs, class: undefined}"
2
+ <div class="vue-select"
3
+ :class="$attrs.class">
4
+ <core-select v-bind="$attrs"
4
5
  ref="select">
5
6
  <template #default="{
6
- allowsSelection, canAddTag, clearControl, clearEvents, dropdownDisabled, disableClear,
7
- disabled, displayLabel, filterBindings, filterEvents, hasOptions, hasSelection,
8
- highlight, i18n, isSelected, itemEvents, modeSelector, modeBindings, modeEvents,
9
- multiple, needsSearch, noResults, reload, loading, options, query, reset,
10
- selection, selectionBindings, selectionEvents, taggable, taggableBindings,
11
- taggableEvents, trackBy,
7
+ allowsSelection, canAddTag, clearControl, clearEvents,
8
+ dropdownDisabled, disableClear, disabled, displayLabel,
9
+ filterBindings, filterEvents, hasOptions, hasSelection,
10
+ highlight, i18n, isSelected, itemEvents, modeSelector,
11
+ modeBindings, modeEvents, multiple, needsSearch, noResults,
12
+ reload, loading, options, query, reset, selection,
13
+ selectionBindings, selectionEvents, taggable,
14
+ taggableBindings, taggableEvents, trackBy,
12
15
  }">
13
16
  <dropdown :disabled="dropdownDisabled"
14
17
  :manual="multiple || canAddTag || !allowsSelection"
@@ -127,7 +130,7 @@
127
130
  import { FontAwesomeIcon as Fa } from '@fortawesome/vue-fontawesome';
128
131
  import { library } from '@fortawesome/fontawesome-svg-core';
129
132
  import { faCheck }
130
- from '@fortawesome/free-solid-svg-icons';
133
+ from '@fortawesome/free-solid-svg-icons';
131
134
  import { focus, clickOutside } from '@enso-ui/directives';
132
135
  import { Dropdown, DropdownItem } from '@enso-ui/dropdown/bulma';
133
136
  import DropdownIndicator from '@enso-ui/dropdown-indicator';
@@ -152,6 +155,8 @@ export default {
152
155
  SearchMode,
153
156
  },
154
157
 
158
+ inheritAttrs: false,
159
+
155
160
  props: {
156
161
  hasError: {
157
162
  type: Boolean,
@@ -197,7 +202,6 @@ export default {
197
202
  };
198
203
  </script>
199
204
 
200
-
201
205
  <style lang="scss">
202
206
  @import 'bulma/sass/utilities/derived-variables';
203
207
 
@@ -3,9 +3,10 @@ import { debounce } from 'lodash';
3
3
  import Modes from '@enso-ui/search-mode/src/modes';
4
4
 
5
5
  export default {
6
-
7
6
  name: 'CoreSelect',
8
7
 
8
+ inheritAttrs: false,
9
+
9
10
  props: {
10
11
  customParams: {
11
12
  type: Object,
@@ -29,6 +30,10 @@ export default {
29
30
  throw error;
30
31
  },
31
32
  },
33
+ http: {
34
+ default: null,
35
+ type: Function,
36
+ },
32
37
  i18n: {
33
38
  type: Function,
34
39
  default: v => v,
@@ -106,8 +111,6 @@ export default {
106
111
  'selection', 'update', 'update:modelValue',
107
112
  ],
108
113
 
109
- inheritAttrs: false,
110
-
111
114
  data: v => ({
112
115
  allowsSelection: true,
113
116
  internalValue: null,
@@ -162,7 +165,7 @@ export default {
162
165
  ? this.optionList.filter(option => this.modelValue
163
166
  .some(val => this.valueMatchesOption(val, option)))
164
167
  : this.optionList
165
- .find(option => this.valueMatchesOption(this.modelValue, option)) || null;
168
+ .find(option => this.valueMatchesOption(this.modelValue, option)) || null;
166
169
  },
167
170
  serverSide() {
168
171
  return this.source !== null;
@@ -227,6 +230,10 @@ export default {
227
230
  },
228
231
 
229
232
  created() {
233
+ if (!this.http && this.source !== null) {
234
+ throw Error('Using the serverside mode requires providing a http client');
235
+ }
236
+
230
237
  this.init();
231
238
  },
232
239
 
@@ -278,10 +285,10 @@ export default {
278
285
  this.ongoingRequest.cancel();
279
286
  }
280
287
 
281
- this.ongoingRequest = axios.CancelToken.source();
288
+ this.ongoingRequest = this.http.CancelToken.source();
282
289
  this.loading = true;
283
290
 
284
- axios.get(this.source, {
291
+ this.http.get(this.source, {
285
292
  params: this.requestParams(),
286
293
  cancelToken: this.ongoingRequest.token,
287
294
  }).then(({ data }) => {
@@ -291,7 +298,7 @@ export default {
291
298
  this.loading = false;
292
299
  }).catch(error => {
293
300
  this.loading = false;
294
- if (!axios.isCancel(error)) {
301
+ if (!this.http.isCancel(error)) {
295
302
  this.errorHandler(error);
296
303
  }
297
304
  });
@@ -361,7 +368,7 @@ export default {
361
368
  },
362
369
  reload() {
363
370
  if (!this.hasOptions && !this.readonly && !this.disabled) {
364
- this.fetch();
371
+ this.fetchIfServerSide();
365
372
  }
366
373
  },
367
374
  requestParams() {