@uiw/react-amap-info-window
Advanced tools
Comparing version 2.7.22 to 3.0.0
@@ -33,5 +33,8 @@ "use strict"; | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var InfoWindow = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) { | ||
var _useInfoWindow = (0, _useInfoWindow2.useInfoWindow)(props), | ||
infoWindow = _useInfoWindow.infoWindow; | ||
infoWindow = _useInfoWindow.infoWindow, | ||
InfoWindowPortal = _useInfoWindow.InfoWindowPortal; | ||
@@ -43,3 +46,5 @@ (0, _react.useImperativeHandle)(ref, function () { | ||
}); | ||
return null; | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoWindowPortal, { | ||
children: props.children | ||
}); | ||
}); | ||
@@ -46,0 +51,0 @@ |
@@ -11,2 +11,5 @@ /// <reference types="react" /> | ||
setInfoWindow: import("react").Dispatch<import("react").SetStateAction<AMap.InfoWindow | undefined>>; | ||
InfoWindowPortal: (props: { | ||
children: import("react").ReactNode; | ||
}) => import("react").ReactPortal | null; | ||
}; |
@@ -43,7 +43,5 @@ "use strict"; | ||
var _useRenderDom = (0, _reactAmapUtils.useRenderDom)({ | ||
children: props.children | ||
}), | ||
container = _useRenderDom.container, | ||
setContent = _useRenderDom.setContent; | ||
var _usePortal = (0, _reactAmapUtils.usePortal)(), | ||
container = _usePortal.container, | ||
Portal = _usePortal.Portal; | ||
@@ -82,7 +80,2 @@ (0, _react.useEffect)(function () { | ||
}, [props.children, container, other.content, infoWindow]); | ||
(0, _react.useEffect)(function () { | ||
if (infoWindow) { | ||
setContent(props.children); | ||
} | ||
}, [props.children, infoWindow]); | ||
(0, _react.useMemo)(function () { | ||
@@ -111,3 +104,4 @@ if (isOpen !== visiable && infoWindow && map) { | ||
infoWindow: infoWindow, | ||
setInfoWindow: setInfoWindow | ||
setInfoWindow: setInfoWindow, | ||
InfoWindowPortal: Portal | ||
}; | ||
@@ -114,0 +108,0 @@ }; |
import _extends from "@babel/runtime/helpers/extends"; | ||
import React, { useImperativeHandle } from 'react'; | ||
import { useInfoWindow } from './useInfoWindow'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
export * from './useInfoWindow'; | ||
export var InfoWindow = /*#__PURE__*/React.forwardRef((props, ref) => { | ||
var { | ||
infoWindow | ||
infoWindow, | ||
InfoWindowPortal | ||
} = useInfoWindow(props); | ||
@@ -12,4 +14,6 @@ useImperativeHandle(ref, () => _extends({}, props, { | ||
})); | ||
return null; | ||
return /*#__PURE__*/_jsx(InfoWindowPortal, { | ||
children: props.children | ||
}); | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -11,2 +11,5 @@ /// <reference types="react" /> | ||
setInfoWindow: import("react").Dispatch<import("react").SetStateAction<AMap.InfoWindow | undefined>>; | ||
InfoWindowPortal: (props: { | ||
children: import("react").ReactNode; | ||
}) => import("react").ReactPortal | null; | ||
}; |
@@ -5,3 +5,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
import { useState, useMemo, useEffect } from 'react'; | ||
import { useEventProperties, useSettingProperties, useRenderDom } from '@uiw/react-amap-utils'; | ||
import { useEventProperties, useSettingProperties, usePortal } from '@uiw/react-amap-utils'; | ||
import { useMapContext } from '@uiw/react-amap-map'; | ||
@@ -26,6 +26,4 @@ export var useInfoWindow = function useInfoWindow(props) { | ||
container, | ||
setContent | ||
} = useRenderDom({ | ||
children: props.children | ||
}); | ||
Portal | ||
} = usePortal(); | ||
useEffect(() => { | ||
@@ -63,7 +61,2 @@ if (!AMap || !map) return; | ||
}, [props.children, container, other.content, infoWindow]); | ||
useEffect(() => { | ||
if (infoWindow) { | ||
setContent(props.children); | ||
} | ||
}, [props.children, infoWindow]); | ||
useMemo(() => { | ||
@@ -92,5 +85,6 @@ if (isOpen !== visiable && infoWindow && map) { | ||
infoWindow, | ||
setInfoWindow | ||
setInfoWindow, | ||
InfoWindowPortal: Portal | ||
}; | ||
}; | ||
//# sourceMappingURL=useInfoWindow.js.map |
{ | ||
"name": "@uiw/react-amap-info-window", | ||
"version": "2.7.22", | ||
"version": "3.0.0", | ||
"description": "用于在地图上弹出一个详细信息展示窗体,地图上只允许同时展示 `1` 个信息窗体。", | ||
@@ -37,4 +37,4 @@ "homepage": "https://uiwjs.github.io/react-amap/#/info-window", | ||
"dependencies": { | ||
"@uiw/react-amap-map": "2.7.22", | ||
"@uiw/react-amap-utils": "2.7.22" | ||
"@uiw/react-amap-map": "3.0.0", | ||
"@uiw/react-amap-utils": "3.0.0" | ||
}, | ||
@@ -41,0 +41,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36798
342
+ Added@uiw/react-amap-map@3.0.0(transitive)
+ Added@uiw/react-amap-types@3.0.0(transitive)
+ Added@uiw/react-amap-utils@3.0.0(transitive)
- Removed@uiw/react-amap-map@2.7.22(transitive)
- Removed@uiw/react-amap-types@2.7.22(transitive)
- Removed@uiw/react-amap-utils@2.7.22(transitive)
Updated@uiw/react-amap-map@3.0.0
Updated@uiw/react-amap-utils@3.0.0