wave-ui 3.4.3 → 3.4.4

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.4.3",
3
+ "version": "3.4.4",
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",
@@ -47,7 +47,7 @@
47
47
  "build-bundle": "BUNDLE=true vite build && mv ./dist/style.css ./dist/wave-ui.css",
48
48
  "serve": "vite preview --base /wave-ui/",
49
49
  "lint": "vite lint",
50
- "publish": "npm run build && npm run build-bundle && git add . && git commit -m 'Publish documentation on Github.' && git push && git push tags && npm publish --tag latest"
50
+ "publish": "npm run build && npm run build-bundle && git add . && git commit -m 'Publish documentation on Github.' && git push && git push --tag && npm publish --tag latest"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/core": "^7.21.3",
@@ -2,7 +2,7 @@
2
2
  component(
3
3
  ref="formEl"
4
4
  :is="formRegister ? 'w-form-element' : 'div'"
5
- v-bind="formRegister && { validators, inputValue: selectionString, disabled: isDisabled, readonly: isReadonly }"
5
+ v-bind="formRegister && { validators, inputValue: selectionString, disabled: isDisabled, readonly: isReadonly, isFocused }"
6
6
  v-model:valid="valid"
7
7
  @reset="onReset"
8
8
  :wrap="hasLabel && labelPosition !== 'inside'"
@@ -16,6 +16,7 @@ component(
16
16
 
17
17
  w-menu(
18
18
  v-model="showMenu"
19
+ @close="!$event && closeMenu()"
19
20
  :menu-class="`w-select__menu ${menuClass || ''}`"
20
21
  transition="slide-fade-down"
21
22
  :append-to="(menuProps || {}).appendTo !== undefined ? (menuProps || {}).appendTo : undefined"
@@ -26,7 +27,7 @@ component(
26
27
  template(#activator="{ on }")
27
28
  //- Input wrapper.
28
29
  .w-select__selection-wrap(
29
- @click="!isDisabled && !isReadonly && (showMenu ? closeMenu : openMenu)()"
30
+ @click="!isDisabled && !isReadonly && onInputFieldClick()"
30
31
  role="button"
31
32
  aria-haspopup="listbox"
32
33
  :aria-expanded="showMenu ? 'true' : 'false'"
@@ -76,8 +77,8 @@ component(
76
77
  @update:model-value="onInput"
77
78
  @item-click="$emit('item-click', $event)"
78
79
  @item-select="onListItemSelect"
79
- @keydown:enter="noUnselect && !multiple && closeMenu()"
80
- @keydown:escape="closeMenu"
80
+ @keydown:enter="noUnselect && !multiple && closeMenu('la3')"
81
+ @keydown:escape="showMenu && (this.showMenu = false) /* Will call closeMenu() from w-menu(@close). */"
81
82
  :items="selectItems"
82
83
  :multiple="multiple"
83
84
  arrows-navigation
@@ -228,12 +229,18 @@ export default {
228
229
 
229
230
  methods: {
230
231
  onFocus (e) {
232
+ if (this.isFocused) return
233
+
231
234
  this.isFocused = true
232
235
  this.$emit('focus', e)
233
236
  return false
234
237
  },
235
238
 
236
239
  onBlur (e) {
240
+ // As long as the menu is open the focus is still on.
241
+ // When closing the menu, the focus is given back to the input (not blur yet).
242
+ if (this.showMenu) return
243
+
237
244
  this.isFocused = false
238
245
  this.$emit('blur', e)
239
246
  },
@@ -242,11 +249,10 @@ export default {
242
249
  // Forbid typing in contenteditable element.
243
250
  // Note: using contenteditable rather than input in order to be able to fit the select list
244
251
  // to its content with CSS. Only contenteditable divs/non-interactive elements can react to focus/blur ).
245
- e.preventDefault()
252
+ // still allow meta key & ctrl key combinations and the tab key (9).
253
+ if (!e.metaKey && !e.ctrlKey && e.keyCode !== 9) e.preventDefault()
246
254
 
247
- if ([13, 27, 38, 40].includes(e.keyCode)) e.preventDefault()
248
-
249
- if (e.keyCode === 27) this.closeMenu() // Escape.
255
+ if (e.keyCode === 27 && this.showMenu) this.closeMenu('la5') // Escape.
250
256
  else if (e.keyCode === 13) this.openMenu() // Enter.
251
257
 
252
258
  // Up & down arrows.
@@ -285,12 +291,16 @@ export default {
285
291
  this.$emit('update:modelValue', selection)
286
292
  this.$emit('input', selection)
287
293
  },
294
+ onInputFieldClick () {
295
+ if (this.showMenu) this.showMenu = false // Will call `closeMenu()` from w-menu(@close).
296
+ else this.openMenu()
297
+ },
288
298
 
289
299
  // Called on item selection: on click & `enter` keydown.
290
300
  onListItemSelect (e) {
291
301
  this.$emit('item-select', e)
292
302
  // Close menu after selection on single select, but keep open if multiple.
293
- if (!this.multiple) this.closeMenu()
303
+ if (!this.multiple) this.showMenu = false // Will call `closeMenu()` from w-menu(@close).
294
304
  },
295
305
 
296
306
  onReset () {
@@ -333,7 +343,7 @@ export default {
333
343
 
334
344
  // Close the dropdown selection list.
335
345
  closeMenu () {
336
- if ((this.menuProps || {}).hideOnMenuClick === false) return
346
+ if (this.menuProps?.hideOnMenuClick === false) return
337
347
 
338
348
  this.showMenu = false
339
349
  // Set the focus back on the main w-select input.