@afeefa/vue-app 0.0.133 → 0.0.134

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.
@@ -1 +1 @@
1
- 0.0.133
1
+ 0.0.134
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.133",
3
+ "version": "0.0.134",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -8,6 +8,7 @@
8
8
  @keydown.tab.prevent.exact="keyenter"
9
9
  @keydown.space.prevent="keyenter"
10
10
  @keydown.tab.shift.prevent="$emit('backtab')"
11
+ @keydown.exact="keyinput"
11
12
  >
12
13
  <template v-if="models_.length">
13
14
  <a-table v-bind="$attrs">
@@ -56,6 +57,7 @@ import { ListViewMixin } from '@a-vue/components/list/ListViewMixin'
56
57
  })
57
58
  export default class SearchSelectList extends Mixins(ListViewMixin) {
58
59
  activeModelIndex = -1
60
+ localSearchKey = ''
59
61
 
60
62
  get hasHeader () {
61
63
  return this.$slots.header && this.$slots.header.length > 1
@@ -88,6 +90,19 @@ export default class SearchSelectList extends Mixins(ListViewMixin) {
88
90
  }
89
91
  }
90
92
 
93
+ keyinput (event) {
94
+ if (event.key.length !== 1) {
95
+ return
96
+ }
97
+
98
+ this.localSearchKey = event.key
99
+ this.activeModelIndex = this.findActiveIndexForLocalSearch()
100
+
101
+ setTimeout(() => {
102
+ this.localSearchKey = ''
103
+ }, 200)
104
+ }
105
+
91
106
  keydown () {
92
107
  this.activeModelIndex++
93
108
  if (this.activeModelIndex > this.models_.length - 1) {
@@ -131,6 +146,19 @@ export default class SearchSelectList extends Mixins(ListViewMixin) {
131
146
  }
132
147
  return -1
133
148
  }
149
+
150
+ findActiveIndexForLocalSearch () {
151
+ for (const [index, model] of this.models_.entries()) {
152
+ const regex = new RegExp(`^${this.localSearchKey}`, 'i')
153
+ if (model.getTitle().match(regex)) {
154
+ if (this.activeModelIndex === index) {
155
+ continue
156
+ }
157
+ return index
158
+ }
159
+ }
160
+ return this.activeModelIndex
161
+ }
134
162
  }
135
163
  </script>
136
164