UNPKG

react-naver-maps

Version:

React Navermaps API integration for modern development.

72 lines (70 loc) 1.66 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/ellipse.tsx import pick from "lodash.pick"; import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; import { jsx } from "react/jsx-runtime"; var primitiveKvoKeys = [ "strokeWeight", "strokeOpacity", "strokeColor", "strokeStyle", "strokeLineCap", "strokeLineJoin", "fillColor", "fillOpacity", "clickable", "visible", "zIndex" ]; var kvoKeys = [ ...primitiveKvoKeys, "bounds" ]; var kvoEvents = kvoKeys.map((key) => `${key}_changed`); var uiEvents = [ "mousedown", "mouseup", "click", "dblclick", "rightclick", "mouseover", "mouseout", "mousemove" ]; var events = [...uiEvents, ...kvoEvents]; var Ellipse = forwardRef(function Ellipse2(props, ref) { const { bounds } = props; const navermaps = useNavermaps(); const [ellipse] = useState(() => new navermaps.Ellipse(omitUndefined(pick(props, [...kvoKeys])))); useImperativeHandle(ref, () => ellipse); useEffect(() => { ellipse.setOptions(omitUndefined(pick(props, primitiveKvoKeys))); }, primitiveKvoKeys.map((key) => props[key])); useEffect(() => { if (bounds && ellipse.getBounds().equals(bounds)) { ellipse.setBounds(bounds); } }, [bounds]); return /* @__PURE__ */ jsx(Overlay, { element: ellipse, children: /* @__PURE__ */ jsx(HandleEvents, { events, listeners: props }) }); }); export { Ellipse }; //# sourceMappingURL=chunk-4ILFNBA5.mjs.map