@enso-ui/typeahead 3.0.13 → 4.0.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 laravel-enso
3
+ Copyright (c) 2026 laravel-enso
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -28,4 +28,4 @@ Thank you to all the people who already contributed to Enso!
28
28
 
29
29
  ## License
30
30
 
31
- [ISC](https://opensource.org/licenses/ISC)
31
+ [MIT](https://opensource.org/licenses/MIT)
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "@enso-ui/typeahead",
3
- "version": "3.0.13",
3
+ "version": "4.0.0",
4
4
  "description": "Vue Typeahead",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
6
  "repository": {
10
7
  "type": "git",
11
8
  "url": "git+https://github.com/enso-ui/typeahead.git"
@@ -16,7 +13,7 @@
16
13
  "vue"
17
14
  ],
18
15
  "author": "Adrian Ocneanu <aocneanu@gmail.com>",
19
- "license": "ISC",
16
+ "license": "MIT",
20
17
  "bugs": {
21
18
  "url": "https://github.com/enso-ui/typeahead/issues"
22
19
  },
@@ -24,21 +21,10 @@
24
21
  "dependencies": {
25
22
  "@enso-ui/dropdown": "^3.0",
26
23
  "@enso-ui/search-mode": "^3.0",
27
- "@fortawesome/fontawesome-svg-core": "^1.2.2",
28
- "@fortawesome/free-solid-svg-icons": "^5.11.2",
29
- "@fortawesome/vue-fontawesome": "3.0.0-5",
24
+ "@fortawesome/fontawesome-svg-core": "^7.2.0",
25
+ "@fortawesome/free-solid-svg-icons": "^7.2.0",
26
+ "@fortawesome/vue-fontawesome": "3.1.3",
30
27
  "lodash": "^4.17.10",
31
28
  "vue": "^3.0"
32
- },
33
- "devDependencies": {
34
- "@vue/cli-plugin-babel": "5.0.0-beta.6",
35
- "@vue/cli-plugin-eslint": "5.0.0-beta.6",
36
- "@vue/eslint-config-airbnb": "^5.0.0",
37
- "autoprefixer": "^9.6.1",
38
- "babel-eslint": "^10.0.1",
39
- "cross-env": "^6.0.0",
40
- "eslint": "^7.0.0",
41
- "eslint-import-resolver-alias": "^1.1.2",
42
- "eslint-plugin-vue": "^8.0.0"
43
29
  }
44
30
  }
@@ -3,7 +3,7 @@
3
3
  ref="typeahead">
4
4
  <template #default="{
5
5
  addTag, canAddTag, clearBindings, controlEvents, disabled,
6
- invalidQuery, highlight, i18n, inputBindings, inputEvents,
6
+ invalidRegExp, highlight, i18n, inputBindings, inputEvents,
7
7
  itemEvents, items, label, loading, minQueryLength,
8
8
  modeSelector, modeBindings, modeEvents,
9
9
  readonly, query, searchControl,
@@ -14,13 +14,13 @@
14
14
  :disable-controls="items.length === 0"
15
15
  manual>
16
16
  <template #trigger="{ show, hide, selection }">
17
- <div class="field has-addons has-addons-right">
17
+ <div class="field has-addons has-addons-right mt-0">
18
18
  <div class="control is-expanded has-icons-left has-icons-right"
19
19
  :class="{ 'is-loading': loading }">
20
20
  <input class="input is-fullwidth"
21
21
  :class="[
22
22
  { 'is-rounded': isRounded },
23
- { 'is-danger': invalidQuery || hasError }
23
+ { 'is-danger': invalidRegExp || hasError }
24
24
  ]"
25
25
  v-bind="inputBindings"
26
26
  type="text"
@@ -32,7 +32,7 @@
32
32
  v-on="inputEvents(selection)"
33
33
  ref="input">
34
34
  <span class="icon is-small is-left">
35
- <fa icon="search"/>
35
+ <fa :icon="faSearch"/>
36
36
  </span>
37
37
  <search-mode class="is-right is-small search-mode"
38
38
  v-bind="modeBindings"
@@ -52,7 +52,7 @@
52
52
  {{ i18n('Add') }}
53
53
  </span>
54
54
  <span class="icon is-small">
55
- <fa icon="plus"/>
55
+ <fa :icon="faPlus"/>
56
56
  </span>
57
57
  </a>
58
58
  </div>
@@ -101,13 +101,11 @@
101
101
 
102
102
  <script>
103
103
  import { FontAwesomeIcon as Fa } from '@fortawesome/vue-fontawesome';
104
- import { library } from '@fortawesome/fontawesome-svg-core';
105
104
  import { faPlus, faSearch } from '@fortawesome/free-solid-svg-icons';
106
105
  import { Dropdown, DropdownItem } from '@enso-ui/dropdown/bulma';
107
106
  import SearchMode from '@enso-ui/search-mode/bulma';
108
107
  import CoreTypeahead from '../renderless/CoreTypeahead.vue';
109
108
 
110
- library.add(faPlus, faSearch);
111
109
  export default {
112
110
  name: 'Typeahead',
113
111
 
@@ -115,6 +113,11 @@ export default {
115
113
  CoreTypeahead, Dropdown, DropdownItem, Fa, SearchMode,
116
114
  },
117
115
 
116
+ data: () => ({
117
+ faPlus,
118
+ faSearch,
119
+ }),
120
+
118
121
  props: {
119
122
  hasError: {
120
123
  type: Boolean,
@@ -162,6 +165,15 @@ export default {
162
165
  .dropdown-trigger {
163
166
  width: 100%;
164
167
 
168
+ .input {
169
+ background-color: var(--enso-filter-control-surface);
170
+ color: var(--bulma-input-color);
171
+
172
+ &::placeholder {
173
+ color: var(--bulma-text-light);
174
+ }
175
+ }
176
+
165
177
  .search-mode {
166
178
  pointer-events: all;
167
179
  right: 1.6em;
@@ -6,15 +6,15 @@ export default {
6
6
  name: 'CoreTypeahead',
7
7
 
8
8
  props: {
9
- disabled: {
10
- type: Boolean,
11
- default: false,
12
- },
13
9
  debounce: {
14
10
  type: Number,
15
11
  default: 250,
16
12
  validator: v => v > 0,
17
13
  },
14
+ disabled: {
15
+ type: Boolean,
16
+ default: false,
17
+ },
18
18
  errorHandler: {
19
19
  type: Function,
20
20
  default: error => {
@@ -59,9 +59,7 @@ export default {
59
59
  },
60
60
  regExp: {
61
61
  type: RegExp,
62
- default() {
63
- return /(.*?)/;
64
- },
62
+ default:() => /(.*?)/,
65
63
  },
66
64
  searchControl: {
67
65
  type: Boolean,
@@ -95,21 +93,24 @@ export default {
95
93
  mode: v.searchMode,
96
94
  ongoingRequest: null,
97
95
  query: '',
98
- waitingResponse: false,
99
96
  }),
100
97
 
101
98
  computed: {
102
99
  canAddTag() {
103
- return this.taggable && !!this.query
104
- && this.queryDoesntMatch && !this.waitingResponse;
100
+ return this.taggable && this.query !== ''
101
+ && !this.loading && this.queryHasNoResults;
105
102
  },
106
103
  invalidQuery() {
107
- return this.query && !this.regExp.test(this.query);
104
+ return this.query.trim().length < this.minQueryLength
105
+ || this.invalidRegExp;
106
+ },
107
+ invalidRegExp() {
108
+ return !this.regExp.test(this.query);
108
109
  },
109
110
  modeSelector() {
110
111
  return this.searchModes.length > 1;
111
112
  },
112
- queryDoesntMatch() {
113
+ queryHasNoResults() {
113
114
  return !this.items
114
115
  .some(item => `${item[this.label]}`
115
116
  .toLowerCase() === this.query.toLowerCase());
@@ -124,12 +125,6 @@ export default {
124
125
  },
125
126
  },
126
127
 
127
- watch: {
128
- query(query) {
129
- this.waitingResponse = query !== '';
130
- },
131
- },
132
-
133
128
  created() {
134
129
  this.fetch = debounce(this.fetch, this.debounce);
135
130
  },
@@ -158,11 +153,6 @@ export default {
158
153
  return;
159
154
  }
160
155
 
161
- if (this.query.length < this.minQueryLength) {
162
- this.items = [];
163
- return;
164
- }
165
-
166
156
  if (this.ongoingRequest) {
167
157
  this.ongoingRequest.cancel();
168
158
  }
@@ -173,15 +163,9 @@ export default {
173
163
  this.http.get(this.source, {
174
164
  params: this.requestParams,
175
165
  cancelToken: this.ongoingRequest.token,
176
- }).then(({ data }) => {
177
- this.items = data;
178
- this.loading = false;
179
- this.waitingResponse = false;
180
- }).catch(error => {
181
- this.loading = false;
182
- this.waitingResponse = false;
183
- this.errorHandler(error);
184
- });
166
+ }).then(({ data }) => (this.items = data))
167
+ .catch(this.errorHandler)
168
+ .finally(() => (this.loading = false));
185
169
  },
186
170
  highlight(item) {
187
171
  this.query.split(' ')
@@ -191,7 +175,7 @@ export default {
191
175
  return item;
192
176
  },
193
177
  search(item = null) {
194
- if (this.query.length < this.minQueryLength) {
178
+ if (this.invalidQuery) {
195
179
  return;
196
180
  }
197
181
 
@@ -200,6 +184,7 @@ export default {
200
184
  }
201
185
 
202
186
  this.$emit('search', { item, query: this.query });
187
+
203
188
  this.query = '';
204
189
  },
205
190
  select(index) {
@@ -222,7 +207,7 @@ export default {
222
207
  click: this.search,
223
208
  },
224
209
  disabled: this.disabled,
225
- invalidQuery: this.invalidQuery,
210
+ invalidRegExp: this.invalidRegExp,
226
211
  highlight: this.highlight,
227
212
  i18n: this.i18n,
228
213
  inputBindings: { value: this.query },