@enso-ui/select 3.0.10 → 3.0.14

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.10",
3
+ "version": "3.0.14",
4
4
  "description": "Select",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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,6 +1,7 @@
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
7
  allowsSelection, canAddTag, clearControl, clearEvents, dropdownDisabled, disableClear,
@@ -58,15 +59,15 @@
58
59
  <dropdown-indicator :open="open" v-if="!disabled"/>
59
60
  </button>
60
61
  </template>
61
- <template #controls
62
+ <template #controls="{ keydown }"
62
63
  v-if="needsSearch">
63
- <div class="dropdown-item search">
64
+ <div class="search">
64
65
  <div class="control has-icons-right">
65
66
  <input class="input"
66
67
  v-bind="filterBindings"
67
68
  type="text"
68
69
  :placeholder="i18n(labels.search)"
69
- v-on="filterEvents"
70
+ v-on="{ ...filterEvents, keydown }"
70
71
  v-focus>
71
72
  <search-mode class="is-right icon is-small search-mode"
72
73
  v-bind="modeBindings"
@@ -142,6 +143,8 @@ export default {
142
143
 
143
144
  directives: { focus, clickOutside },
144
145
 
146
+ inheritAttrs: false,
147
+
145
148
  components: {
146
149
  CoreSelect,
147
150
  Dropdown,
@@ -199,6 +202,8 @@ export default {
199
202
 
200
203
 
201
204
  <style lang="scss">
205
+ @import 'bulma/sass/utilities/derived-variables';
206
+
202
207
  .vue-select {
203
208
  .dropdown {
204
209
  width: 100%;
@@ -211,6 +216,10 @@ export default {
211
216
  height: unset;
212
217
  min-height: 2.2125em;
213
218
 
219
+ &.has-error {
220
+ border-color: $danger;
221
+ }
222
+
214
223
  .control-display {
215
224
  &.with-clear-button {
216
225
  max-width: calc(100% - 2.5em);
@@ -291,25 +300,25 @@ export default {
291
300
  .dropdown-content {
292
301
  width: 100%;
293
302
 
303
+ .search {
304
+ padding: 0 0.375rem 0.6rem;
305
+
306
+ .input {
307
+ height: 2em;
308
+ }
309
+
310
+ .search-mode {
311
+ right: 0.3em;
312
+ pointer-events: all;
313
+ }
314
+ }
315
+
294
316
  .dropdown-item {
295
317
  text-overflow: ellipsis;
296
318
  overflow-x: hidden;
297
319
  white-space: nowrap;
298
320
  padding: 0.375rem 2rem 0.375rem 0.6rem;
299
321
 
300
- &.search {
301
- padding: 0 0.375rem 0.6rem;
302
-
303
- .input {
304
- height: 2em;
305
- }
306
-
307
- .search-mode {
308
- right: 0.3em;
309
- pointer-events: all;
310
- }
311
- }
312
-
313
322
  .label.tag {
314
323
  position: absolute;
315
324
  padding: 0.3rem;
@@ -3,9 +3,15 @@ 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
+ emits: [
9
+ 'add-tag', 'clear', 'deselect', 'fetch', 'input', 'select',
10
+ 'selection', 'update', 'update:modelValue',
11
+ ],
12
+
13
+ inheritAttrs: false,
14
+
9
15
  props: {
10
16
  customParams: {
11
17
  type: Object,
@@ -29,6 +35,10 @@ export default {
29
35
  throw error;
30
36
  },
31
37
  },
38
+ http: {
39
+ default: null,
40
+ type: Function,
41
+ },
32
42
  i18n: {
33
43
  type: Function,
34
44
  default: v => v,
@@ -101,13 +111,6 @@ export default {
101
111
  },
102
112
  },
103
113
 
104
- emits: [
105
- 'add-tag', 'clear', 'deselect', 'fetch', 'input', 'select',
106
- 'selection', 'update', 'update:modelValue',
107
- ],
108
-
109
- inheritAttrs: false,
110
-
111
114
  data: v => ({
112
115
  allowsSelection: true,
113
116
  internalValue: 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() {