@afeefa/vue-app 0.0.167 → 0.0.168

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.167
1
+ 0.0.168
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.167",
3
+ "version": "0.0.168",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -52,7 +52,7 @@ import { PositionConfig } from '../services/PositionService'
52
52
  import { randomCssClass } from '../utils/random'
53
53
 
54
54
  @Component({
55
- props: ['value', 'validator', 'type', {dense: true, outlined: true}]
55
+ props: ['value', 'validator', 'type', {dense: true, outlined: true, focus: false}]
56
56
  })
57
57
  export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositionServiceMixin, CancelOnEscMixin) {
58
58
  value_ = null
@@ -65,6 +65,8 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositio
65
65
  }
66
66
 
67
67
  mounted () {
68
+ this.setFocus()
69
+
68
70
  this.validate()
69
71
  }
70
72
 
@@ -74,6 +76,11 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositio
74
76
  this.validate()
75
77
  }
76
78
 
79
+ @Watch('focus')
80
+ focusChanged () {
81
+ this.setFocus()
82
+ }
83
+
77
84
  get clearable () {
78
85
  if (this.validator && this.validator.getParam('filled')) {
79
86
  return false
@@ -292,6 +299,17 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositio
292
299
  }
293
300
  return []
294
301
  }
302
+
303
+ setFocus (force = false) {
304
+ const focus = this.focus || force // set focus if this.focus or else if forced from outside
305
+ if (focus) {
306
+ // if run in a v-dialog, the dialog background would
307
+ // steal the focus without requestAnimationFrame
308
+ requestAnimationFrame(() => {
309
+ this.$el.querySelector('input').focus()
310
+ })
311
+ }
312
+ }
295
313
  }
296
314
  </script>
297
315