UNPKG

@davedev42/react-naver-maps

Version:

React Navermaps API integration for modern development.

66 lines (64 loc) 1.62 kB
import { omitUndefined } from "./chunk-SOBCLIXD.mjs"; import { useNavermaps } from "./chunk-JX27UDSU.mjs"; import { HandleEvents } from "./chunk-TMGZDWPN.mjs"; import { Overlay } from "./chunk-P2HFB547.mjs"; // src/overlays/polyline.tsx import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; import { jsx } from "react/jsx-runtime"; var kvoKeys = [ "path", "strokeWeight", "strokeOpacity", "strokeColor", "strokeStyle", "strokeLineCap", "strokeLineJoin", "clickable", "visible", "zIndex", "startIcon", "startIconSize", "endIcon", "endIconSize" ]; var kvoEvents = kvoKeys.map((key) => `${key}_changed`); var uiEvents = [ "mousedown", "mouseup", "click", "dblclick", "rightclick", "mouseover", "mouseout", "mousemove" ]; var events = [...uiEvents, ...kvoEvents]; var Polyline = forwardRef(function Polyline2(props, ref) { const { path } = props; const options = { path, ...Object.fromEntries(kvoKeys.filter((key) => key !== "path").map((key) => [key, props[key]])) }; const navermaps = useNavermaps(); const [polyline] = useState(() => new navermaps.Polyline(options)); useImperativeHandle(ref, () => polyline); useEffect(() => { const cleanOptions = omitUndefined(options); if (Object.keys(cleanOptions).length > 0) { polyline.setOptions(cleanOptions); } }, kvoKeys.map((key) => options[key])); return /* @__PURE__ */ jsx(Overlay, { element: polyline, children: /* @__PURE__ */ jsx(HandleEvents, { events, listeners: props }) }); }); export { Polyline }; //# sourceMappingURL=chunk-M7EHJCUX.mjs.map