@enso-ui/select 3.0.12 → 3.0.16
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 +2 -2
- package/src/bulma/EnsoSelect.vue +4 -3
- package/src/bulma/VueSelect.vue +14 -10
- package/src/renderless/CoreSelect.vue +17 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enso-ui/select",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.16",
|
|
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
|
|
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",
|
package/src/bulma/EnsoSelect.vue
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<vue-select
|
|
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: {
|
package/src/bulma/VueSelect.vue
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="vue-select"
|
|
3
|
-
|
|
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,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -255,7 +262,9 @@ export default {
|
|
|
255
262
|
const value = JSON.parse(JSON.stringify(this.modelValue));
|
|
256
263
|
|
|
257
264
|
const index = value
|
|
258
|
-
.findIndex(val =>
|
|
265
|
+
.findIndex(val => this.objects
|
|
266
|
+
? val[this.trackBy] === deselect[this.trackBy]
|
|
267
|
+
: val === deselect[this.trackBy]);
|
|
259
268
|
|
|
260
269
|
value.splice(index, 1);
|
|
261
270
|
this.update(value);
|
|
@@ -278,10 +287,10 @@ export default {
|
|
|
278
287
|
this.ongoingRequest.cancel();
|
|
279
288
|
}
|
|
280
289
|
|
|
281
|
-
this.ongoingRequest =
|
|
290
|
+
this.ongoingRequest = this.http.CancelToken.source();
|
|
282
291
|
this.loading = true;
|
|
283
292
|
|
|
284
|
-
|
|
293
|
+
this.http.get(this.source, {
|
|
285
294
|
params: this.requestParams(),
|
|
286
295
|
cancelToken: this.ongoingRequest.token,
|
|
287
296
|
}).then(({ data }) => {
|
|
@@ -291,7 +300,7 @@ export default {
|
|
|
291
300
|
this.loading = false;
|
|
292
301
|
}).catch(error => {
|
|
293
302
|
this.loading = false;
|
|
294
|
-
if (!
|
|
303
|
+
if (!this.http.isCancel(error)) {
|
|
295
304
|
this.errorHandler(error);
|
|
296
305
|
}
|
|
297
306
|
});
|