From da0e0a17d206458bc0c3b3635ec3767bd0dd9dd9 Mon Sep 17 00:00:00 2001 From: Touch Date: Sat, 26 Jun 2021 21:18:54 +0700 Subject: [PATCH] chore: :tada: added before slot to autocomplet component --- lib/components/Autocomplete.vue | 25 ++++++++++++++----------- lib/components/Map.vue | 1 + package.json | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/components/Autocomplete.vue b/lib/components/Autocomplete.vue index f604791..825b046 100644 --- a/lib/components/Autocomplete.vue +++ b/lib/components/Autocomplete.vue @@ -16,11 +16,10 @@ -
- - - + + +
@@ -47,8 +46,8 @@ export default { FindElement, Ready ], - props: { + value: null, model: String, placeholder: { type: String, @@ -67,13 +66,21 @@ export default { default: true } }, - + computed: { + autocompleteModel: { + get () { + return this.value + }, + set (value) { + this.$emit('input', value) + } + } + }, data () { return { localTypes: this.$props.types } }, - methods: { ...redirectMethods({ target () { @@ -85,12 +92,10 @@ export default { this.$emit('update:model', event.target.value) } }, - watch: { localTypes: 'setTypes', types: 'setTypes' }, - created () { const mapAncestor = this.$_findAncestor( a => a.$options.name === 'GoogleMap' @@ -100,12 +105,10 @@ export default { } this.$_mapAncestor = mapAncestor }, - async googleMapsPrepare () { const mapComp = this.$_mapAncestor this.$_map = mapComp ? await mapComp.$_getMap() : null }, - googleMapsReady () { this.$_autocomplete = new window.google.maps.places.Autocomplete(this.$refs.input) this.$_autocomplete.setTypes(this.$props.types) diff --git a/lib/components/Map.vue b/lib/components/Map.vue index 7337b8b..ef7ba3f 100644 --- a/lib/components/Map.vue +++ b/lib/components/Map.vue @@ -1,5 +1,6 @@