UNPKG

vue-tianditu2

Version:
1 lines 2.77 kB
{"version":3,"file":"index.mjs","sources":["../../../../packages/overlay/infowindow/index.ts"],"sourcesContent":["import { computed, defineComponent, h, onMounted, onUnmounted } from \"vue\";\nimport { useMapRoot } from \"~/use/mapRoot\";\nimport { useEvent } from \"~/use/event\";\nimport { EVENTS, NATIVE_EVENTS, PROPS, useInit, useWatch } from \"./use\";\n\nexport const TdtInfowindow = defineComponent({\n name: \"TdtInfowindow\",\n props: PROPS,\n emits: EVENTS,\n setup(props, { emit, slots }) {\n const contentRef = computed(() => {\n return h(\n \"div\",\n {\n class: \"tdt-infowindow-custom\",\n style: {\n minWidth: props.minWidth,\n maxWidth: props.maxWidth,\n maxHeight: props.maxHeight,\n display: slots.default && props.target ? \"block\" : \"none\"\n }\n },\n slots.default?.()\n );\n });\n\n onMounted(async () => {\n onUnmounted(() => tdtMap?.closeInfoWindow());\n\n const content = slots.default ? (contentRef.value.el as HTMLElement) : undefined;\n const tdtMap = await useMapRoot();\n const tdtComponent = useInit(props, content);\n useEvent({ events: NATIVE_EVENTS, emit, instance: tdtComponent, emitted });\n useWatch({ props, instance: tdtComponent, map: tdtMap });\n emit(\"init\", tdtComponent);\n });\n\n function emitted(event: string) {\n if (event === \"close\") {\n emit(\"update:target\", null);\n }\n }\n\n return () => contentRef.value;\n }\n});\n\nexport type TdtInfowindowInstance = InstanceType<typeof TdtInfowindow>;\n"],"names":["TdtInfowindow","defineComponent","PROPS","EVENTS","props","emit","slots","contentRef","computed","h","_a","onMounted","onUnmounted","tdtMap","content","useMapRoot","tdtComponent","useInit","useEvent","NATIVE_EVENTS","emitted","useWatch","event"],"mappings":";;;;;;AAKO,MAAMA,IAAgBC,EAAgB;AAAA,EAC3C,MAAM;AAAA,EACN,OAAOC;AAAA,EACP,OAAOC;AAAA,EACP,MAAMC,GAAO,EAAE,MAAAC,GAAM,OAAAC,KAAS;AACtB,UAAAC,IAAaC,EAAS,MAAM;;AACzB,aAAAC;AAAA,QACL;AAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP,OAAO;AAAA,YACL,UAAUL,EAAM;AAAA,YAChB,UAAUA,EAAM;AAAA,YAChB,WAAWA,EAAM;AAAA,YACjB,SAASE,EAAM,WAAWF,EAAM,SAAS,UAAU;AAAA,UAAA;AAAA,QAEvD;AAAA,SACAM,IAAAJ,EAAM,YAAN,gBAAAI,EAAA,KAAAJ;AAAA,MACF;AAAA,IAAA,CACD;AAED,IAAAK,EAAU,YAAY;AACR,MAAAC,EAAA,MAAMC,KAAA,gBAAAA,EAAQ,iBAAiB;AAE3C,YAAMC,IAAUR,EAAM,UAAWC,EAAW,MAAM,KAAqB,QACjEM,IAAS,MAAME,EAAW,GAC1BC,IAAeC,EAAQb,GAAOU,CAAO;AAC3C,MAAAI,EAAS,EAAE,QAAQC,GAAe,MAAAd,GAAM,UAAUW,GAAc,SAAAI,GAAS,GACzEC,EAAS,EAAE,OAAAjB,GAAO,UAAUY,GAAc,KAAKH,GAAQ,GACvDR,EAAK,QAAQW,CAAY;AAAA,IAAA,CAC1B;AAED,aAASI,EAAQE,GAAe;AAC9B,MAAIA,MAAU,WACZjB,EAAK,iBAAiB,IAAI;AAAA,IAC5B;AAGF,WAAO,MAAME,EAAW;AAAA,EAAA;AAE5B,CAAC;"}