Skip to content

Commit

Permalink
chore: 🎉 added before slot to autocomplet component
Browse files Browse the repository at this point in the history
  • Loading branch information
TouchSek committed Jun 26, 2021
1 parent f5b3835 commit da0e0a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
25 changes: 14 additions & 11 deletions lib/components/Autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
</div>
</slot>
</div>

<div class="pac-input-container">
<slot name="before-input"></slot>
<input ref="input" type="text" :value="model" @input="onInputChange" :placeholder="placeholder">
<slot name="after-input"></slot>
<slot name="before-input" />
<input ref="input" type="text" v-model="autocompleteModel" @input="onInputChange" :placeholder="placeholder">
<slot name="after-input" />
</div>
</div>
</template>
Expand All @@ -47,8 +46,8 @@ export default {
FindElement,
Ready
],
props: {
value: null,
model: String,
placeholder: {
type: String,
Expand All @@ -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 () {
Expand All @@ -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'
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/components/Map.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="vue-google-map">
<slot name="before" />
<div ref="map" class="map-view" />
<div class="hidden-content">
<slot />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vuejs-google-maps",
"description": "A set of Google Map components for VueJs",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"main": "./dist/vuejs-google-maps.umd.js",
"types": "types/index.d.ts",
Expand Down

0 comments on commit da0e0a1

Please sign in to comment.