wave-ui 3.9.2 → 3.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wave-ui",
3
- "version": "3.9.2",
3
+ "version": "3.10.0",
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",
@@ -41,44 +41,44 @@
41
41
  "vue framework",
42
42
  "ui"
43
43
  ],
44
- "scripts": {
45
- "dev": "vite",
46
- "build": "vite build --base /wave-ui/",
47
- "build-bundle": "BUNDLE=true vite build && mv ./dist/style.css ./dist/wave-ui.css",
48
- "serve": "vite preview --base /wave-ui/",
49
- "lint": "vite lint",
50
- "publish-doc": "npm run build && npm run build-bundle && git add . && git commit -m 'Publish documentation on Github.' && git push && git push --tag"
51
- },
52
44
  "devDependencies": {
53
- "@babel/core": "^7.23.7",
54
- "@babel/eslint-parser": "^7.23.3",
55
- "@faker-js/faker": "^8.3.1",
45
+ "@babel/core": "^7.23.9",
46
+ "@babel/eslint-parser": "^7.23.10",
47
+ "@faker-js/faker": "^8.4.1",
56
48
  "@mdi/font": "^6.9.96",
57
- "@vitejs/plugin-vue": "^5.0.2",
58
- "@vue/compiler-sfc": "3.4.4",
59
- "autoprefixer": "^10.4.16",
60
- "axios": "^1.6.3",
49
+ "@vitejs/plugin-vue": "^5.0.4",
50
+ "@vue/compiler-sfc": "3.4.18",
51
+ "autoprefixer": "^10.4.17",
52
+ "axios": "^1.6.7",
61
53
  "eslint": "^8.56.0",
62
- "eslint-plugin-vue": "^9.19.2",
54
+ "eslint-plugin-vue": "^9.21.1",
63
55
  "font-awesome": "^4.7.0",
64
- "gsap": "^3.12.4",
56
+ "gsap": "^3.12.5",
65
57
  "ionicons": "^4.6.3",
66
58
  "material-design-icons": "^3.0.1",
67
- "postcss": "^8.4.32",
59
+ "postcss": "^8.4.35",
68
60
  "pug": "^3.0.2",
69
61
  "rollup-plugin-delete": "^2.0.0",
70
- "sass": "^1.69.7",
62
+ "sass": "^1.70.0",
71
63
  "simple-syntax-highlighter": "^3.0.2",
72
64
  "splitpanes": "^3.1.5",
73
65
  "standard": "^17.1.0",
74
- "vite": "^5.0.10",
66
+ "vite": "^5.1.1",
75
67
  "vite-svg-loader": "^5.1.0",
76
- "vue": "^3.4.4",
68
+ "vue": "^3.4.18",
77
69
  "vue-router": "^4.2.5",
78
70
  "vueperslides": "^3.5.1",
79
71
  "vuex": "^4.1.0"
80
72
  },
81
73
  "peerDependencies": {
82
74
  "vue": "^2.6.14 || ^3.2.0"
75
+ },
76
+ "scripts": {
77
+ "dev": "vite",
78
+ "build": "vite build --base /wave-ui/",
79
+ "build-bundle": "BUNDLE=true vite build && mv ./dist/style.css ./dist/wave-ui.css",
80
+ "serve": "vite preview --base /wave-ui/",
81
+ "lint": "vite lint",
82
+ "publish-doc": "npm run build && npm run build-bundle && git add . && git commit -m 'Publish documentation on Github.' && git push && git push --tag"
83
83
  }
84
- }
84
+ }
@@ -70,6 +70,7 @@ component(
70
70
  @update:model-value="onInput"
71
71
  @item-click="$emit('item-click', $event)"
72
72
  @item-select="onListItemSelect"
73
+ @keydown="onWListKeydown"
73
74
  @keydown:enter="noUnselect && !multiple && closeMenu()"
74
75
  @keydown:escape="showMenu && (showMenu = false) /* Will call closeMenu() from w-menu(@close). */"
75
76
  :items="selectItems"
@@ -156,7 +157,10 @@ export default {
156
157
  showMenu: false,
157
158
  menuMinWidth: 0,
158
159
  isFocused: false,
159
- selectionWrapRef: undefined
160
+ selectionWrapRef: undefined,
161
+ // Lookup a select list item from typing the first characters.
162
+ // If typing is too slow (> 1s), the lookup string is cleared.
163
+ quickLookup: { string: '', timeout: null }
160
164
  }),
161
165
 
162
166
  computed: {
@@ -299,6 +303,33 @@ export default {
299
303
  if (!allItemsAreDisabled) this.onInput(items[index])
300
304
  }
301
305
  }
306
+
307
+ // `e.key.length === 1`: only the keys that output a character.
308
+ else if (e.key.length === 1) this.focusItemOnQuickLookup(e)
309
+ },
310
+
311
+ onWListKeydown (e) {
312
+ // `e.key.length === 1`: only the keys that output a character.
313
+ if (e.key.length === 1) this.focusItemOnQuickLookup(e)
314
+ },
315
+
316
+ focusItemOnQuickLookup (e) {
317
+ // Reset the timer every time a new valid key is pressed so we concat the string of chars.
318
+ if (this.quickLookup.timeout) clearTimeout(this.quickLookup.timeout)
319
+ // On each keypress, wait for 1s and clear the lookup string unless a key is pressed again.
320
+ this.quickLookup.timeout = setTimeout(() => this.quickLookup.string = '', 1000)
321
+
322
+ // Form a lookup string that is tested (starting from the first char) on each list item until
323
+ // a match is found.
324
+ this.quickLookup.string += e.key
325
+ const re = new RegExp(`^${this.quickLookup.string}`, 'i')
326
+ const itemIndexToFocus = this.selectItems.findIndex(
327
+ item => !item.disabled && item[this.itemLabelKey].match(re)
328
+ ) + 1 // 0 if not found, more if found.
329
+ if (itemIndexToFocus) {
330
+ const selector = `.w-list__item:nth-child(${itemIndexToFocus}) .w-list__item-label`
331
+ this.$refs['w-list']?.$el?.querySelector(selector)?.focus()
332
+ }
302
333
  },
303
334
 
304
335
  // The items are given by the w-list component.
@@ -371,7 +402,7 @@ export default {
371
402
 
372
403
  this.showMenu = false
373
404
  // Set the focus back on the main w-select input.
374
- setTimeout(() => this.$refs['selection-input'].focus(), 50)
405
+ setTimeout(() => this.$refs['selection-input']?.focus(), 50)
375
406
  }
376
407
  },
377
408
 
@@ -214,19 +214,19 @@ export default {
214
214
 
215
215
  onLabelKeydown (item, e) {
216
216
  // Keys: 13 enter, 32 space, 37 arrow left, 38 arrow up, 39 arrow right, 40 arrow down.
217
- if (!(e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) && [13, 32, 37, 38, 39, 40].includes(e.which)) {
217
+ if (!(e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) && [13, 32, 37, 38, 39, 40].includes(e.keyCode)) {
218
218
  if (item.children || item.branch) {
219
- if ([13, 32].includes(e.which)) this.expandDepth(item) && e.preventDefault()
220
- else if (e.which === 37) this.expandDepth(item, false) && e.preventDefault()
221
- else if (e.which === 39) this.expandDepth(item, true) && e.preventDefault()
219
+ if ([13, 32].includes(e.keyCode)) this.expandDepth(item) && e.preventDefault()
220
+ else if (e.keyCode === 37) this.expandDepth(item, false) && e.preventDefault()
221
+ else if (e.keyCode === 39) this.expandDepth(item, true) && e.preventDefault()
222
222
  }
223
223
 
224
224
  // On arrow up or down, focus the prev or next item.
225
- if ([38, 40].includes(e.which)) {
225
+ if ([38, 40].includes(e.keyCode)) {
226
226
  const treeRoot = this.$el.closest('.w-tree--depth0')
227
227
  const treeTabbableItems = treeRoot.querySelectorAll('.w-tree__item-label[tabindex="0"]')
228
228
  const currLabel = e.target.closest('.w-tree__item-label')
229
- const indexModifier = e.which === 38 ? -1 : 1;
229
+ const indexModifier = e.keyCode === 38 ? -1 : 1;
230
230
 
231
231
  ([...treeTabbableItems]).some((item, i) => {
232
232
  if (item.isSameNode(currLabel)) {
@@ -238,7 +238,7 @@ export default {
238
238
  }
239
239
  }
240
240
 
241
- if (e.which === 13) {
241
+ if (e.keyCode === 13) {
242
242
  if (this.selectable) item.selected = !item.selected
243
243
  // Always emitting on enter keydown, but different event for selection.
244
244
  this.emitItemSelection(item, e)