@hzab/form-render 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useRef, forwardRef, useImperativeHandle, useState } from "react";
|
1
|
+
import { useRef, forwardRef, useImperativeHandle, useState, useEffect } from "react";
|
2
2
|
import { createPortal } from "react-dom";
|
3
3
|
import { Button } from "antd";
|
4
4
|
|
@@ -15,6 +15,7 @@ export interface IPopupProps {
|
|
15
15
|
schema;
|
16
16
|
initialValues?: Object;
|
17
17
|
};
|
18
|
+
mountElement?: HTMLElement;
|
18
19
|
}
|
19
20
|
|
20
21
|
export interface IData {
|
@@ -24,7 +25,7 @@ export interface IData {
|
|
24
25
|
}
|
25
26
|
|
26
27
|
export const Popup = forwardRef((props: IPopupProps, parentRef) => {
|
27
|
-
const { formProps = { schema: RangeSchema } } = props;
|
28
|
+
const { formProps = { schema: RangeSchema }, mountElement } = props;
|
28
29
|
|
29
30
|
const [data, setData] = useState<IData>();
|
30
31
|
|
@@ -62,9 +63,10 @@ export const Popup = forwardRef((props: IPopupProps, parentRef) => {
|
|
62
63
|
|
63
64
|
const schema = mergeSchema(AddressSchema, formProps?.schema ?? RangeSchema);
|
64
65
|
|
66
|
+
|
65
67
|
return data
|
66
68
|
? createPortal(
|
67
|
-
<div className="popup-box"
|
69
|
+
<div className="popup-box">
|
68
70
|
<div className="popup-body">
|
69
71
|
{/* TODO: schema 中插入地址字段 text 格式 */}
|
70
72
|
<div>地址:{data?.address}</div>
|
@@ -82,7 +84,7 @@ export const Popup = forwardRef((props: IPopupProps, parentRef) => {
|
|
82
84
|
<Button onClick={onCancel}>取消</Button>
|
83
85
|
</div>
|
84
86
|
</div>,
|
85
|
-
|
87
|
+
mountElement || document.body,
|
86
88
|
)
|
87
89
|
: null;
|
88
90
|
});
|
@@ -48,6 +48,7 @@ export const LocationListPicker = observer((props) => {
|
|
48
48
|
const currentItemRef = useRef();
|
49
49
|
const popupRef = useRef();
|
50
50
|
const isEditingRef = useRef();
|
51
|
+
const mapBoxRef = useRef(null)
|
51
52
|
|
52
53
|
useEffect(() => {
|
53
54
|
return () => {
|
@@ -469,7 +470,7 @@ export const LocationListPicker = observer((props) => {
|
|
469
470
|
|
470
471
|
return (
|
471
472
|
<div className="location-list-picker">
|
472
|
-
<div className="map-box">
|
473
|
+
<div className="map-box" ref={mapBoxRef}>
|
473
474
|
<AMapCom init={mapInit} loading={loading} markerIconConf={markerIconConf} />
|
474
475
|
{!readOnly && !disabled && <MapSearch setPoint={setPoint} isAutoSearch={isAutoSearch} />}
|
475
476
|
{showTip && (
|
@@ -485,7 +486,7 @@ export const LocationListPicker = observer((props) => {
|
|
485
486
|
新增地址
|
486
487
|
</Button>
|
487
488
|
)}
|
488
|
-
<Popup ref={popupRef} {...popupProps} />
|
489
|
+
<Popup ref={popupRef} mountElement={mapBoxRef.current} {...popupProps} />
|
489
490
|
</div>
|
490
491
|
<AddrList
|
491
492
|
{...listProps}
|