UNPKG

react-naver-maps

Version:

React Navermaps API integration for modern development.

64 lines (62 loc) 1.43 kB
import { omitUndefined } from "./chunk-RVDAKL7Q.mjs"; import { useNavermaps } from "./chunk-2R4EMKHB.mjs"; import { HandleEvents } from "./chunk-533MYCRP.mjs"; import { Overlay } from "./chunk-IV7GZJYG.mjs"; // src/overlays/polygon.tsx import pick from "lodash.pick"; import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; import { jsx } from "react/jsx-runtime"; var kvoKeys = [ "paths", "strokeWeight", "strokeOpacity", "strokeColor", "strokeStyle", "strokeLineCap", "strokeLineJoin", "fillColor", "fillOpacity", "clickable", "visible", "zIndex" ]; var kvoEvents = kvoKeys.map((key) => `${key}_changed`); var uiEvents = [ "mousedown", "mouseup", "click", "dblclick", "rightclick", "mouseover", "mouseout", "mousemove" ]; var events = [...uiEvents, ...kvoEvents]; var Polygon = forwardRef(function Polygon2(props, ref) { const options = pick(props, [...kvoKeys]); const navermaps = useNavermaps(); const [polygon] = useState(() => new navermaps.Polygon(options)); useImperativeHandle(ref, () => polygon); useEffect(() => { polygon.setOptions(omitUndefined(options)); }, kvoKeys.map((key) => options[key])); return /* @__PURE__ */ jsx(Overlay, { element: polygon, children: /* @__PURE__ */ jsx(HandleEvents, { events, listeners: props }) }); }); export { Polygon }; //# sourceMappingURL=chunk-B5TCSJRK.mjs.map