Add missing deps, fix errors from eslint

This commit is contained in:
Viktor Denisov
2022-12-16 11:14:19 -08:00
parent 2cba776dc8
commit 6fa827823c
21 changed files with 483 additions and 229 deletions

View File

@@ -1,16 +1,8 @@
<template>
<template v-if="$slots['input']">
<slot
name="input"
v-bind="$attrs"
></slot>
<slot name="input" v-bind="$attrs"></slot>
</template>
<input
v-else-if="!$slots['input']"
ref="input"
v-bind="$attrs"
v-on="$attrs"
/>
<input v-else-if="!$slots['input']" ref="input" v-bind="$attrs" v-on="$attrs" />
</template>
<script>
@@ -49,15 +41,15 @@ const props = {
export default {
mounted() {
const _this = this;
const _this = this
this.$gmapApiPromiseLazy().then(() => {
// get correct input from fallback or slot
let refInput = _this.$refs.input
if (_this.$slots.input) {
const refName = _this.$slots.input()[0].props.ref;
const scopedInput = _this.$slots.input()[0].ref.i.ctx.$refs[refName];
const refName = _this.$slots.input()[0].props.ref
const scopedInput = _this.$slots.input()[0].ref.i.ctx.$refs[refName]
if (scopedInput) {
refInput = scopedInput.$el.getElementsByTagName('input')[0];
refInput = scopedInput.$el.getElementsByTagName('input')[0]
}
}
if (this.selectFirstOnEnter) {

View File

@@ -44,17 +44,8 @@ import MapElementMixin from './mapElementMixin'
*
*/
export default function (options) {
const {
mappedProps,
name,
ctr,
ctrArgs,
events,
beforeCreate,
afterCreate,
props,
...rest
} = options
const { mappedProps, name, ctr, ctrArgs, events, beforeCreate, afterCreate, props, ...rest } =
options
const promiseName = `$${name}Promise`
const instanceName = `$${name}Object`

View File

@@ -4,8 +4,12 @@
</div>
</template>
<script>
import {DefaultRenderer, MarkerClusterer, SuperClusterAlgorithm} from '@googlemaps/markerclusterer';
import buildComponent from './build-component.js';
import {
DefaultRenderer,
MarkerClusterer,
SuperClusterAlgorithm,
} from '@googlemaps/markerclusterer'
import buildComponent from './build-component.js'
const props = {
algorithm: {
@@ -15,15 +19,12 @@ const props = {
},
renderer: {
type: Object,
default: new DefaultRenderer,
default: new DefaultRenderer(),
noBind: true,
},
};
}
const events = [
'clusteringbegin',
'clusteringend',
];
const events = ['clusteringbegin', 'clusteringend']
export default buildComponent({
mappedProps: props,
@@ -31,28 +32,28 @@ export default buildComponent({
name: 'cluster',
ctr: () => {
if (typeof MarkerClusterer === 'undefined') {
const errorMessage = 'MarkerClusterer is not installed!';
console.error(errorMessage);
throw new Error(errorMessage);
const errorMessage = 'MarkerClusterer is not installed!'
console.error(errorMessage)
throw new Error(errorMessage)
}
return MarkerClusterer;
return MarkerClusterer
},
ctrArgs: ({map, ...otherOptions}) => [{map, ...otherOptions}],
ctrArgs: ({ map, ...otherOptions }) => [{ map, ...otherOptions }],
afterCreate(inst) {
const reinsertMarkers = () => {
const oldMarkers = inst.getMarkers();
inst.clearMarkers();
inst.addMarkers(oldMarkers);
};
const oldMarkers = inst.getMarkers()
inst.clearMarkers()
inst.addMarkers(oldMarkers)
}
for (let prop in props) {
if (props[prop].twoWay) {
this.$on(prop.toLowerCase() + '_changed', reinsertMarkers);
this.$on(prop.toLowerCase() + '_changed', reinsertMarkers)
}
}
},
updated() {
if (this.$clusterObject) {
this.$clusterObject.render();
this.$clusterObject.render()
}
},
beforeUnmount() {
@@ -60,14 +61,14 @@ export default buildComponent({
if (this.$children && this.$children.length) {
this.$children.forEach((marker) => {
if (marker.$clusterObject === this.$clusterObject) {
marker.$clusterObject = null;
marker.$clusterObject = null
}
});
})
}
if (this.$clusterObject) {
this.$clusterObject.clearMarkers();
this.$clusterObject.clearMarkers()
}
},
});
})
</script>

View File

@@ -4,16 +4,15 @@ const props = {
options: {
type: Object,
twoWay: false,
default: () => {
},
default: () => {},
},
data: {
type: Array,
twoWay: true
twoWay: true,
},
}
const events = [];
const events = []
export default buildComponent({
mappedProps: props,
@@ -21,5 +20,3 @@ export default buildComponent({
ctr: () => google.maps.visualization.HeatmapLayer,
events,
})

View File

@@ -103,7 +103,19 @@ const customMethods = {
export default {
mixins: [mountableMixin],
props: mappedPropsToVueProps({...props, ...events.reduce((obj, eventName) => ({...obj, [`on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`.replace(/[-_]+(.)?/g, (_, c) => c ? c.toUpperCase() : '')]: Function}), {}) } ),
props: mappedPropsToVueProps({
...props,
...events.reduce(
(obj, eventName) => ({
...obj,
[`on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`.replace(
/[-_]+(.)?/g,
(_, c) => (c ? c.toUpperCase() : '')
)]: Function,
}),
{}
),
}),
inheritAttrs: false,
provide() {

View File

@@ -1,10 +1,15 @@
<template>
<div @click="()=> {console.log('sdfsd')}">
<div
@click="
() => {
console.log('sdfsd')
}
"
>
<slot></slot>
</div>
</template>
<script>
import buildComponent from './build-component.js'
const props = {
@@ -112,10 +117,10 @@ export default buildComponent({
},
afterCreate(inst) {
events.forEach((event)=> {
inst.addListener(event, (payload)=> {
events.forEach((event) => {
inst.addListener(event, (payload) => {
this.$emit(event, payload)
});
})
})
if (this.$clusterPromise) {
this.$clusterPromise.then((co) => {

View File

@@ -83,9 +83,11 @@ export default buildComponent({
eventListeners.push([mvcArray, mvcArray.addListener('set_at', updatePaths)])
clearEvents = () => {
eventListeners.map((
[obj, listenerHandle] // eslint-disable-line no-unused-vars
) => google.maps.event.removeListener(listenerHandle))
eventListeners.map(
(
[obj, listenerHandle] // eslint-disable-line no-unused-vars
) => google.maps.event.removeListener(listenerHandle)
)
}
}
},
@@ -115,9 +117,11 @@ export default buildComponent({
eventListeners.push([mvcPath, mvcPath.addListener('set_at', updatePaths)])
clearEvents = () => {
eventListeners.map((
[obj, listenerHandle] // eslint-disable-line no-unused-vars
) => google.maps.event.removeListener(listenerHandle))
eventListeners.map(
(
[obj, listenerHandle] // eslint-disable-line no-unused-vars
) => google.maps.event.removeListener(listenerHandle)
)
}
}
},

View File

@@ -67,9 +67,11 @@ export default buildComponent({
eventListeners.push([mvcPath, mvcPath.addListener('set_at', updatePaths)])
clearEvents = () => {
eventListeners.map((
[obj, listenerHandle] // eslint-disable-line no-unused-vars
) => google.maps.event.removeListener(listenerHandle))
eventListeners.map(
(
[obj, listenerHandle] // eslint-disable-line no-unused-vars
) => google.maps.event.removeListener(listenerHandle)
)
}
}
},