Skip to content

Commit da0e0a1

Browse files
committed
chore: 🎉 added before slot to autocomplet component
1 parent f5b3835 commit da0e0a1

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

lib/components/Autocomplete.vue

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
</div>
1717
</slot>
1818
</div>
19-
2019
<div class="pac-input-container">
21-
<slot name="before-input"></slot>
22-
<input ref="input" type="text" :value="model" @input="onInputChange" :placeholder="placeholder">
23-
<slot name="after-input"></slot>
20+
<slot name="before-input" />
21+
<input ref="input" type="text" v-model="autocompleteModel" @input="onInputChange" :placeholder="placeholder">
22+
<slot name="after-input" />
2423
</div>
2524
</div>
2625
</template>
@@ -47,8 +46,8 @@ export default {
4746
FindElement,
4847
Ready
4948
],
50-
5149
props: {
50+
value: null,
5251
model: String,
5352
placeholder: {
5453
type: String,
@@ -67,13 +66,21 @@ export default {
6766
default: true
6867
}
6968
},
70-
69+
computed: {
70+
autocompleteModel: {
71+
get () {
72+
return this.value
73+
},
74+
set (value) {
75+
this.$emit('input', value)
76+
}
77+
}
78+
},
7179
data () {
7280
return {
7381
localTypes: this.$props.types
7482
}
7583
},
76-
7784
methods: {
7885
...redirectMethods({
7986
target () {
@@ -85,12 +92,10 @@ export default {
8592
this.$emit('update:model', event.target.value)
8693
}
8794
},
88-
8995
watch: {
9096
localTypes: 'setTypes',
9197
types: 'setTypes'
9298
},
93-
9499
created () {
95100
const mapAncestor = this.$_findAncestor(
96101
a => a.$options.name === 'GoogleMap'
@@ -100,12 +105,10 @@ export default {
100105
}
101106
this.$_mapAncestor = mapAncestor
102107
},
103-
104108
async googleMapsPrepare () {
105109
const mapComp = this.$_mapAncestor
106110
this.$_map = mapComp ? await mapComp.$_getMap() : null
107111
},
108-
109112
googleMapsReady () {
110113
this.$_autocomplete = new window.google.maps.places.Autocomplete(this.$refs.input)
111114
this.$_autocomplete.setTypes(this.$props.types)

lib/components/Map.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div class="vue-google-map">
3+
<slot name="before" />
34
<div ref="map" class="map-view" />
45
<div class="hidden-content">
56
<slot />

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vuejs-google-maps",
33
"description": "A set of Google Map components for VueJs",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"license": "MIT",
66
"main": "./dist/vuejs-google-maps.umd.js",
77
"types": "types/index.d.ts",

0 commit comments

Comments
 (0)