Commit 1a3972e8 authored by Michael Underwood's avatar Michael Underwood
Browse files

WIP improve typing around options and event maps

parent 06b19a55
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -38,14 +38,14 @@ export default defineComponent({
    const { options, methods } = setupCircle(props, leafletObject, context);

    onMounted(async () => {
      const { circle, DomEvent }: typeof L = useGlobalLeaflet
      const { circle }: typeof L = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

      leafletObject.value = markRaw<L.Circle>(circle(props.latLng, options));

      const listeners = remapEvents(context.attrs);
      DomEvent.on(leafletObject.value, listeners);
      leafletObject.value.on(listeners);

      propsBinder(methods, leafletObject.value, props);

+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ export default defineComponent({
    );

    onMounted(async () => {
      const { circleMarker, DomEvent }: typeof L = useGlobalLeaflet
      const { circleMarker }: typeof L = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

@@ -54,7 +54,7 @@ export default defineComponent({
      );

      const listeners = remapEvents(context.attrs);
      DomEvent.on(leafletObject.value, listeners);
      leafletObject.value.on(listeners);

      propsBinder(methods, leafletObject.value, props);

+9 −5
Original line number Diff line number Diff line
@@ -9,7 +9,11 @@ import {
  ref,
} from "vue";

import { controlProps, render, setupControl } from "@src/functions/control";
import {
  controlProps,
  renderLControl,
  setupControl,
} from "@src/functions/control";
import {
  RegisterControlInjection,
  UseGlobalLeafletInjection,
@@ -33,7 +37,7 @@ export default defineComponent({
  },
  setup(props, context) {
    const leafletObject = ref<L.Control>();
    const root = ref(null);
    const root = ref<HTMLInputElement>();

    const useGlobalLeaflet = inject(UseGlobalLeafletInjection);
    const registerControl = assertInject(RegisterControlInjection);
@@ -55,10 +59,10 @@ export default defineComponent({
      propsBinder(methods, leafletObject.value, props);
      registerControl({ leafletObject: leafletObject.value });

      if (props.disableClickPropagation) {
      if (props.disableClickPropagation && root.value) {
        DomEvent.disableClickPropagation(root.value);
      }
      if (props.disableScrollPropagation) {
      if (props.disableScrollPropagation && root.value) {
        DomEvent.disableScrollPropagation(root.value);
      }
      nextTick(() => context.emit("ready", leafletObject.value));
@@ -67,7 +71,7 @@ export default defineComponent({
    return { root, leafletObject };
  },
  render() {
    return render(this.$slots);
    return renderLControl(this.$slots);
  },
});
</script>
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ export default defineComponent({
        : await import("leaflet/dist/leaflet-src.esm");

      leafletObject.value = markRaw<L.Control.Layers>(
        control.layers(null, null, options)
        control.layers(undefined, undefined, options)
      );

      propsBinder(methods, leafletObject.value, props);
+8 −4
Original line number Diff line number Diff line
@@ -34,17 +34,21 @@ export default defineComponent({
    const useGlobalLeaflet = inject(UseGlobalLeafletInjection);
    const addLayer = assertInject(AddLayerInjection);

    const { methods, options } = setupFeatureGroup(props, leafletObject);
    const { methods, options } = setupFeatureGroup(
      props,
      leafletObject,
      context
    );

    onMounted(async () => {
      const { featureGroup, DomEvent }: typeof L = useGlobalLeaflet
      const { featureGroup }: typeof L = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

      leafletObject.value = markRaw<L.FeatureGroup>(featureGroup(options));
      leafletObject.value = markRaw<L.FeatureGroup>(featureGroup(options)); // TODO: Feature group array of children

      const listeners = remapEvents(context.attrs);
      DomEvent.on(leafletObject.value, listeners);
      leafletObject.value.on(listeners);

      propsBinder(methods, leafletObject.value, props);
      addLayer({
Loading