UNPKG

@mint-ui/map

Version:

- React map library - Control various map with one interface - Google, Naver, Kakao map supported now - Typescript supported - Canvas marker supported

62 lines (53 loc) 1.97 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib = require('tslib'); var React = require('react'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var React__default = /*#__PURE__*/_interopDefaultLegacy(React); function SVGRect(_a) { var _b = _a.width, width = _b === void 0 ? 100 : _b, _c = _a.height, height = _c === void 0 ? 100 : _c, _d = _a.background, background = _d === void 0 ? 'lightblue' : _d, _e = _a.svgProperties, svgProperties = _e === void 0 ? {} : _e, _f = _a.shapeProperties, shapeProperties = _f === void 0 ? {} : _f, children = _a.children; var getViewHeight = React.useCallback(function (width, height) { return Number((100 * height / width).toFixed(0)); }, []); var viewWidth = React.useRef(100); var _g = React.useState(getViewHeight(width, height)), viewHeight = _g[0], setViewHeight = _g[1]; React.useEffect(function () { setViewHeight(getViewHeight(width, height)); }, [width, height]); return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("svg", tslib.__assign({ pointerEvents: "none", width: width, height: height, viewBox: "0 0 ".concat(viewWidth.current, " ").concat(viewHeight), overflow: 'visible' }, svgProperties), React__default["default"].createElement("rect", tslib.__assign({ pointerEvents: "visiblepainted", x: "0", y: "0", width: viewWidth.current, height: viewHeight, fill: background }, shapeProperties))), React__default["default"].createElement("div", { style: { pointerEvents: 'none', position: 'absolute', left: '0px', top: '0px', width: "".concat(width, "px"), height: "".concat(height, "px") } }, children)); } exports.SVGRect = SVGRect;