@davedev42/react-naver-maps
Version:
React Navermaps API integration for modern development.
64 lines (62 loc) • 1.61 kB
JavaScript
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/rectangle.tsx
import { useEffect, useState, forwardRef, useImperativeHandle } from "react";
import { jsx } from "react/jsx-runtime";
var optionKeys = [
"strokeWeight",
"strokeOpacity",
"strokeColor",
"strokeStyle",
"strokeLineCap",
"strokeLineJoin",
"fillColor",
"fillOpacity"
];
var kvoKeys = [
"bounds",
"clickable",
"visible",
"zIndex"
];
var kvoEvents = kvoKeys.map((key) => `${key}_changed`);
var uiEvents = [
"click",
"dblclick",
"mousedown",
"mouseout",
"mouseover",
"mouseup"
];
var events = [...uiEvents, ...kvoEvents];
var Rectangle = forwardRef(function Rectangle2(props, ref) {
const { bounds } = props;
const options = {
bounds,
...Object.fromEntries([...optionKeys, ...kvoKeys].filter((key) => key !== "bounds").map((key) => [key, props[key]]))
};
const navermaps = useNavermaps();
const [rectangle] = useState(() => new navermaps.Rectangle(options));
useImperativeHandle(ref, () => rectangle);
useEffect(() => {
const cleanOptions = omitUndefined(options);
if (Object.keys(cleanOptions).length > 0) {
rectangle.setOptions(cleanOptions);
}
}, kvoKeys.map((key) => options[key]));
return /* @__PURE__ */ jsx(Overlay, { element: rectangle, children: /* @__PURE__ */ jsx(HandleEvents, { events, listeners: props }) });
});
export {
Rectangle
};
//# sourceMappingURL=chunk-TB77WDMI.mjs.map