@hzab/form-render 1.6.5 → 1.6.7

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/CHANGELOG.md CHANGED
@@ -1,11 +1,15 @@
1
- # @hzab/form-render@1.6.4
1
+ # @hzab/form-render@1.6.7
2
2
 
3
- fix: 修复LocationListPicker组件在编辑时第一次无法正确渲染的bug。
4
- feat: LocationPicker渲染时增加范围
3
+ fix: 修复 LocationListPicker 组件在编辑时第一次无法正确渲染的 bug。
4
+
5
+ # @hzab/form-render@1.6.5
6
+
7
+ fix: 修复 LocationListPicker 组件在编辑时第一次无法正确渲染的 bug。
8
+ feat: LocationPicker 渲染时增加范围
5
9
 
6
10
  # @hzab/form-render@1.6.3
7
11
 
8
- fix: 修复LocationListPicker组件的Pupup弹窗在某些时候漂移的bug。
12
+ fix: 修复 LocationListPicker 组件的 Pupup 弹窗在某些时候漂移的 bug。
9
13
 
10
14
  # @hzab/form-render@1.6.2
11
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/form-render",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -48,8 +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)
52
- const [mapInitCompleted, setMapInitCompleted] = useState(false);
51
+ const mapBoxRef = useRef(null);
53
52
 
54
53
  useEffect(() => {
55
54
  return () => {
@@ -61,22 +60,24 @@ export const LocationListPicker = observer((props) => {
61
60
  }, []);
62
61
 
63
62
  useEffect(() => {
64
-
65
- if (!Array.isArray(value) || value?.length == 0 || !mapInitCompleted) {
63
+ if (!Array.isArray(value) || value?.length == 0) {
66
64
  return;
67
65
  }
66
+ listRef.current = value || [];
68
67
  // 处理 id
69
68
  value?.forEach((it) => {
70
69
  if (!it.id) {
71
70
  it.id = nanoid();
72
71
  }
73
72
  });
74
- listRef.current = value || [];
75
- renderMarker(value);
76
- }, [value, mapInitCompleted]);
73
+ if (!mapUtilsRef.current) {
74
+ return;
75
+ }
76
+ renderMarker();
77
+ }, [value]);
77
78
 
78
- function renderMarker(value = []) {
79
- (listRef.current || value)?.forEach((item) => {
79
+ function renderMarker() {
80
+ listRef.current?.forEach((item) => {
80
81
  if (item.type === "polygon") {
81
82
  mapUtilsRef.current.setPolygon({
82
83
  ...item,
@@ -91,6 +92,7 @@ export const LocationListPicker = observer((props) => {
91
92
  mapUtilsRef.current.setCircle(item.longitude, item.latitude, item.range, { ...item });
92
93
  }
93
94
  });
95
+ mapUtilsRef.current.setFitView();
94
96
  clearActive();
95
97
  }
96
98
 
@@ -107,9 +109,7 @@ export const LocationListPicker = observer((props) => {
107
109
  onClick: onPolygonClick,
108
110
  });
109
111
 
110
- mapUtils && setMapInitCompleted(true);
111
112
  renderMarker();
112
- mapUtilsRef.current.setFitView();
113
113
  }
114
114
 
115
115
  function onAddClick() {