UNPKG

yuang-framework-ui-pc

Version:

yuang-framework-ui-pc Library

97 lines (96 loc) 3.27 kB
import { defineComponent, ref, computed, watch, resolveComponent, createBlock, openBlock, mergeProps, createSlots, withCtx, createVNode, renderList, renderSlot, normalizeProps, guardReactiveProps } from "vue"; import { pick } from "../utils/core"; import { useLocale } from "../ele-config-provider/receiver"; import { useResponsive } from "../ele-pro-layout/util"; import EleDialog from "../ele-dialog/index"; import MapView from "./components/map-view"; import { mapPickerEmits, mapPickerProps, mapPropKeys } from "./props"; const _sfc_main = defineComponent({ name: "EleMapPicker", components: { EleDialog, MapView }, props: mapPickerProps, emits: mapPickerEmits, setup(props, { emit }) { const { lang, globalConfig } = useLocale("map", props); const isResponsive = useResponsive(props); const mapRef = ref(null); const aMapKey = computed(() => props.mapKey || globalConfig.mapKey); const mapProps = computed(() => { return pick(props, mapPropKeys); }); const updateModelValue = (visible) => { emit("update:modelValue", visible); }; const handleMapDone = (ins) => { emit("mapDone", ins); }; const handleDone = (result) => { emit("done", result); }; watch( () => props.modelValue, (visible) => { if (visible) { mapRef.value && mapRef.value.showInitSelected(); } } ); return { lang, isResponsive, mapRef, aMapKey, mapProps, updateModelValue, handleMapDone, handleDone }; } }); const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_MapView = resolveComponent("MapView"); const _component_EleDialog = resolveComponent("EleDialog"); return openBlock(), createBlock(_component_EleDialog, mergeProps({ width: "740px", title: _ctx.lang.title }, _ctx.modalProps || {}, { modelValue: _ctx.modelValue, class: ["ele-map-picker", { "is-responsive": _ctx.isResponsive }], "onUpdate:modelValue": _ctx.updateModelValue }), createSlots({ default: withCtx(() => [ createVNode(_component_MapView, mergeProps(_ctx.mapProps, { ref: "mapRef", message: _ctx.lang.message, clickMessage: _ctx.lang.clickMessage, searchPlaceholder: _ctx.lang.placeholder, okText: _ctx.lang.ok, mapKey: _ctx.aMapKey, mode: _ctx.keywordMode ? "keyword" : _ctx.mode, onMapDone: _ctx.handleMapDone, onDone: _ctx.handleDone }), null, 16, ["message", "clickMessage", "searchPlaceholder", "okText", "mapKey", "mode", "onMapDone", "onDone"]) ]), _: 2 }, [ renderList(Object.keys(_ctx.$slots).filter((k) => "default" !== k), (name) => { return { name, fn: withCtx((slotProps) => [ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps || {}))) ]) }; }) ]), 1040, ["title", "modelValue", "class", "onUpdate:modelValue"]); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };