wave-ui 3.8.0 → 3.8.1

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": "wave-ui",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "An emerging UI framework for Vue.js (2 & 3) with only the bright side. :sunny:",
5
5
  "author": "Antoni Andre <antoniandre.web@gmail.com>",
6
6
  "homepage": "https://antoniandre.github.io/wave-ui",
@@ -3,17 +3,12 @@
3
3
  template(v-if="selection.length")
4
4
  .w-autocomplete__selection(v-for="(item, i) in selection")
5
5
  span(v-html="item[itemLabelKey]")
6
- w-button(@click.stop="unselectItem(i)" icon="i-cross" xs text color="currentColor")
6
+ w-button(@click.stop="unselectItem(i)" icon="wi-cross" xs text)
7
7
  .w-autocomplete__placeholder(v-if="!selection.length && !keywords && placeholder" v-html="placeholder")
8
8
  input.w-autocomplete__input(
9
9
  ref="input"
10
- v-model="keywords"
11
- @focus="onFocus"
12
- @keydown="onKeydown"
13
- @drop="onDrop"
14
- @compositionstart="onCompositionStart"
15
- @compositionupdate="onCompositionUpdate"
16
- v-on="$listeners")
10
+ :model-value="keywords"
11
+ v-on="inputEventListeners")
17
12
  w-transition-slide-fade(y)
18
13
  ul.w-autocomplete__menu(v-if="menuOpen" ref="menu")
19
14
  li(
@@ -105,9 +100,27 @@ export default {
105
100
  return this.filteredItems.findIndex(item => item.uid === this.highlightedItem)
106
101
  },
107
102
 
103
+ inputEventListeners () {
104
+ return {
105
+ ...this.$attrs,
106
+ input: e => {
107
+ this.keywords = e.target.value
108
+ if (typeof this.$attrs.input === 'function') this.$attrs.input(this.keywords)
109
+ },
110
+ focus: this.onFocus,
111
+ keydown: this.onKeydown,
112
+ drop: this.onDrop,
113
+ compositionstart: this.onCompositionStart,
114
+ compositionupdate: this.onCompositionUpdate
115
+ }
116
+ },
117
+
108
118
  classes () {
109
119
  return {
110
- 'w-autocomplete--open': this.menuOpen
120
+ 'w-autocomplete--open': this.menuOpen,
121
+ 'w-autocomplete--filled': this.selection.length,
122
+ 'w-autocomplete--has-keywords': this.keywords,
123
+ 'w-autocomplete--empty': !this.selection.length && !this.keywords
111
124
  }
112
125
  }
113
126
  },
@@ -145,13 +158,23 @@ export default {
145
158
  if (!this.openOnKeydown) this.openMenu()
146
159
  },
147
160
 
161
+ // Can be triggered by a click outside the autocomplete, or by a tab key.
162
+ // It should not be simply triggered by input blur, because when we click a menu item it will
163
+ // blur the input for a few ms before we refocus it.
164
+ // onBlur () {
165
+ // this.closeMenu()
166
+ // },
167
+
148
168
  onKeydown (e) {
149
169
  const itemsCount = this.filteredItems.length
150
170
  // `e.key.length === 1`: is all the keyboard keys that generate a character.
151
171
  if (!this.openOnKeydown || ((this.keywords || e.key.length === 1) && !this.menuOpen)) this.openMenu()
152
172
 
173
+ // Tab key.
174
+ if (e.keyCode === 9) this.closeMenu()
175
+
153
176
  // Delete key.
154
- if (e.keyCode === 8 && (!this.keywords || (!e.target.selectionStart && !e.target.selectionEnd))) {
177
+ else if (e.keyCode === 8 && (!this.keywords || (!e.target.selectionStart && !e.target.selectionEnd))) {
155
178
  this.unselectItem()
156
179
  }
157
180
 
@@ -237,7 +260,7 @@ export default {
237
260
  gap: 4px;
238
261
  position: relative;
239
262
  border-radius: 4px;
240
- border: 1px solid rgba(#000, 0.2);
263
+ border: $border;
241
264
  padding: 2px 4px;
242
265
  user-select: none;
243
266
 
@@ -249,8 +272,8 @@ export default {
249
272
  &__selection {
250
273
  display: flex;
251
274
  align-items: center;
252
- background: rgba(#000, 0.035);
253
- border: 1px solid rgba(#000, 0.05);
275
+ background: rgba(var(--w-contrast-bg-color-rgb), 0.035);
276
+ border: 1px solid rgba(var(--w-contrast-bg-color-rgb), 0.05);
254
277
  border-radius: 4px;
255
278
  padding: 0 2px 0 4px;
256
279
  flex-shrink: 0;
@@ -269,8 +292,7 @@ export default {
269
292
  }
270
293
 
271
294
  &__placeholder {
272
- position: absolute;
273
- color: #ccc;
295
+ color: rgba(var(--w-base-color-rgb), 0.5);
274
296
  pointer-events: none;
275
297
  line-height: 18px;
276
298
  }
@@ -281,8 +303,8 @@ export default {
281
303
  max-height: clamp(20px, 400px, 80vh);
282
304
  margin-top: -1px;
283
305
  margin-left: 0;
284
- background-color: #fff;
285
- border: 1px solid rgba(#000, 0.2);
306
+ background-color: $base-bg-color;
307
+ border: 1px solid rgba(var(--w-contrast-bg-color-rgb), 0.2);
286
308
  border-top: none;
287
309
  border-bottom-left-radius: inherit;
288
310
  border-bottom-right-radius: inherit;
@@ -290,16 +312,28 @@ export default {
290
312
  z-index: 10;
291
313
 
292
314
  li {
315
+ position: relative;
293
316
  list-style-type: none;
294
317
  margin: 0;
295
318
  padding: 4px 8px;
296
- border-left: 2px solid transparent;
297
319
 
298
320
  &:hover {background-color: rgba($primary, 0.1);}
299
321
 
300
- &.highlighted {
301
- background-color: rgba($primary, 0.15);
302
- border-left-color: rgba($primary, 0.75);
322
+ &:before, &:after {
323
+ content: '';
324
+ position: absolute;
325
+ inset: 0;
326
+ }
327
+
328
+ &.highlighted:before {
329
+ border-left: 2px solid transparent;
330
+ border-left-color: $primary;
331
+ opacity: 0.3;
332
+ }
333
+
334
+ &.highlighted:after {
335
+ background-color: $primary;
336
+ opacity: 0.1;
303
337
  }
304
338
  }
305
339
  }