@baishuyun/ui-base 6.7.0 → 6.7.1

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.
@@ -1,5 +1,5 @@
1
1
  import "../AmapContext-CFmsMycg.js";
2
2
  import "../hooks-DwRvpafb.js";
3
- import "../useMarkerInfoWindowController-G-Bg-NDJ.js";
4
- import { t as e } from "../AmapMarker-CB66dQIG.js";
3
+ import "../useMarkerInfoWindowController-BvP2jo7K.js";
4
+ import { t as e } from "../AmapMarker-CMlzx_nj.js";
5
5
  export { e as AmapMarker, e as default };
@@ -0,0 +1,153 @@
1
+ import { n as e } from "./hooks-DwRvpafb.js";
2
+ import { n as t, t as n } from "./useMarkerInfoWindowController-BvP2jo7K.js";
3
+ import { Fragment as r, jsx as i } from "react/jsx-runtime";
4
+ import { useCallback as a, useEffect as o, useRef as s } from "react";
5
+ import { createRoot as c } from "react-dom/client";
6
+ //#region src/components/Amap/AmapMarker/useMarkerInfoWindow.tsx
7
+ var l = ({ AMap: e, map: t, mapReady: r, markerRef: i, infoWindow: s }) => {
8
+ let { scheduleInfoWindowOpen: c, scheduleInfoWindowClose: l, closeInfoWindow: u } = n({
9
+ AMap: e,
10
+ map: t,
11
+ mapReady: r
12
+ }), d = a(() => {
13
+ if (!s) return;
14
+ let e = i.current;
15
+ e && c(e, s);
16
+ }, [
17
+ s,
18
+ i,
19
+ c
20
+ ]);
21
+ return o(() => {
22
+ if (s) return () => {
23
+ u();
24
+ };
25
+ }, [u, s]), {
26
+ scheduleInfoWindowOpen: d,
27
+ scheduleInfoWindowClose: l,
28
+ closeInfoWindow: u
29
+ };
30
+ }, u = (e) => typeof e == "string" || typeof e == "number", d = (e) => e != null && typeof e != "boolean", f = (e) => d(e) && !u(e), p = (e) => {
31
+ queueMicrotask(() => e.unmount());
32
+ };
33
+ function m(n) {
34
+ let { AMap: a, map: m, mapReady: h } = e(), { content: g, infoWindow: _, options: v = {}, onClick: y, onMouseEnter: b, onMouseLeave: x } = n, S = !!_, C = s(null), w = s(null), T = s(null), E = s(!0), D = s(!0), O = s({
35
+ content: g,
36
+ infoWindow: _,
37
+ options: v
38
+ });
39
+ O.current = {
40
+ content: g,
41
+ infoWindow: _,
42
+ options: v
43
+ };
44
+ let { scheduleInfoWindowOpen: k, scheduleInfoWindowClose: A, closeInfoWindow: j } = l({
45
+ AMap: a,
46
+ map: m,
47
+ mapReady: h,
48
+ markerRef: C,
49
+ infoWindow: _
50
+ });
51
+ return o(() => {
52
+ if (!a || !m || !h || C.current) return;
53
+ let e = O.current, n = {
54
+ anchor: t,
55
+ ...e.options,
56
+ map: m
57
+ };
58
+ if (u(e.content)) {
59
+ let t = document.createElement("div");
60
+ t.textContent = String(e.content), T.current = t, n.content = t;
61
+ } else if (f(e.content)) {
62
+ let e = document.createElement("div");
63
+ T.current = e, n.content = e;
64
+ }
65
+ let o = new a.Marker(n);
66
+ if (C.current = o, f(e.content) && T.current) {
67
+ let t = c(T.current);
68
+ w.current = t, t.render(/* @__PURE__ */ i(r, { children: e.content }));
69
+ }
70
+ return () => {
71
+ let e = w.current;
72
+ e && p(e), w.current = null, T.current = null, j(), o.setMap(null), C.current = null;
73
+ };
74
+ }, [
75
+ a,
76
+ j,
77
+ m,
78
+ h
79
+ ]), o(() => {
80
+ let e = v.position;
81
+ if (!e) return;
82
+ let t = C.current?.getPosition?.(), n = t?.getLng?.() ?? t?.lng, r = t?.getLat?.() ?? t?.lat, i = Array.isArray(e) ? e[0] : e.lng, a = Array.isArray(e) ? e[1] : e.lat;
83
+ n === i && r === a || C.current?.setPosition(e);
84
+ }, [v.position]), o(() => {
85
+ if (D.current) {
86
+ D.current = !1;
87
+ return;
88
+ }
89
+ let e = C.current;
90
+ e && (v.visible === !1 ? e.hide?.() : v.visible === !0 && e.show?.());
91
+ }, [v.visible]), o(() => {
92
+ if (E.current) {
93
+ E.current = !1;
94
+ return;
95
+ }
96
+ let e = C.current;
97
+ if (e) {
98
+ if (!d(g)) {
99
+ w.current && p(w.current), w.current = null, T.current = null, e.setContent?.("");
100
+ return;
101
+ }
102
+ if (u(g)) {
103
+ if (w.current) {
104
+ let t = w.current;
105
+ p(t), w.current = null, T.current = document.createElement("div"), e.setContent?.(T.current);
106
+ }
107
+ T.current || (T.current = document.createElement("div"), e.setContent?.(T.current)), T.current.textContent = String(g);
108
+ return;
109
+ }
110
+ T.current || (T.current = document.createElement("div"), e.setContent?.(T.current)), w.current ||= c(T.current), w.current.render(/* @__PURE__ */ i(r, { children: g }));
111
+ }
112
+ }, [g]), o(() => {
113
+ let e = C.current;
114
+ if (!e) return;
115
+ let t = () => ({
116
+ marker: e,
117
+ AMap: a,
118
+ map: m
119
+ }), n = [];
120
+ if (y) {
121
+ let r = () => {
122
+ y?.(t());
123
+ };
124
+ e.on("click", r), n.push(() => e.off("click", r));
125
+ }
126
+ if (b || S) {
127
+ let r = () => {
128
+ S && k(), b?.(t());
129
+ };
130
+ e.on("mouseover", r), n.push(() => e.off("mouseover", r));
131
+ }
132
+ if (x || S) {
133
+ let r = () => {
134
+ S && A(), x?.(t());
135
+ };
136
+ e.on("mouseout", r), n.push(() => e.off("mouseout", r));
137
+ }
138
+ return () => {
139
+ n.forEach((e) => e());
140
+ };
141
+ }, [
142
+ a,
143
+ S,
144
+ m,
145
+ y,
146
+ b,
147
+ x,
148
+ A,
149
+ k
150
+ ]), null;
151
+ }
152
+ //#endregion
153
+ export { m as t };
@@ -1,5 +1,5 @@
1
1
  import "../AmapContext-CFmsMycg.js";
2
2
  import "../hooks-DwRvpafb.js";
3
- import "../useMarkerInfoWindowController-G-Bg-NDJ.js";
4
- import { t as e } from "../AmapMarkerCluster-DvXchCC0.js";
3
+ import "../useMarkerInfoWindowController-BvP2jo7K.js";
4
+ import { t as e } from "../AmapMarkerCluster-MDUfcIqP.js";
5
5
  export { e as AmapMarkerCluster, e as default };
@@ -1,8 +1,8 @@
1
1
  import { n as e } from "./hooks-DwRvpafb.js";
2
- import { t } from "./useMarkerInfoWindowController-G-Bg-NDJ.js";
3
- import { useCallback as n, useEffect as r, useMemo as i, useRef as a } from "react";
2
+ import { n as t, t as n } from "./useMarkerInfoWindowController-BvP2jo7K.js";
3
+ import { useCallback as r, useEffect as i, useMemo as a, useRef as o } from "react";
4
4
  //#region src/components/Amap/AmapMarkerCluster/utils.ts
5
- var o = "[ui-base] AmapMarkerCluster requires AMap.MarkerCluster plugin. Please add \"AMap.MarkerCluster\" to AmapProvider plugins.", s = {}, c = "bottom-center", l = /* @__PURE__ */ new WeakMap(), u = 0, d = (e) => Array.isArray(e) && e.length === 2 && Number.isFinite(e[0]) && Number.isFinite(e[1]), f = (e) => Array.isArray(e) ? e : [], p = (e) => e?.extData, m = (e) => {
5
+ var s = "[ui-base] AmapMarkerCluster requires AMap.MarkerCluster plugin. Please add \"AMap.MarkerCluster\" to AmapProvider plugins.", c = {}, l = /* @__PURE__ */ new WeakMap(), u = 0, d = (e) => Array.isArray(e) && e.length === 2 && Number.isFinite(e[0]) && Number.isFinite(e[1]), f = (e) => Array.isArray(e) ? e : [], p = (e) => e?.extData, m = (e) => {
6
6
  let t = { ...e };
7
7
  return delete t.renderMarker, delete t.renderClusterMarker, t;
8
8
  }, h = (e) => l.get(e) || (u += 1, l.set(e, u), u), g = (e) => e === void 0 ? "empty" : typeof e == "string" ? `string:${e}` : `element:${h(e)}`, _ = (e) => e.map((e) => [
@@ -35,15 +35,14 @@ var o = "[ui-base] AmapMarkerCluster requires AMap.MarkerCluster plugin. Please
35
35
  `, x = (e, t, n = g(t)) => {
36
36
  t === void 0 || e.__bsyAmapMarkerClusterContentSignature === n || (e.setContent?.(t), e.__bsyAmapMarkerClusterContentSignature = n);
37
37
  }, S = (e) => {
38
- e.setAnchor?.(c);
38
+ e.setAnchor?.(t);
39
39
  }, C = (e, t, n) => {
40
- if (n) {
41
- if (Array.isArray(n) && typeof e.Pixel == "function") {
42
- t.setOffset?.(new e.Pixel(n[0], n[1]));
43
- return;
44
- }
45
- t.setOffset?.(n);
40
+ let r = n ?? [0, 0];
41
+ if (Array.isArray(r) && typeof e.Pixel == "function") {
42
+ t.setOffset?.(new e.Pixel(r[0], r[1]));
43
+ return;
46
44
  }
45
+ t.setOffset?.(r);
47
46
  }, w = (e) => {
48
47
  let t = e.__bsyAmapMarkerClusterRuntime;
49
48
  if (!t) return;
@@ -52,16 +51,16 @@ var o = "[ui-base] AmapMarkerCluster requires AMap.MarkerCluster plugin. Please
52
51
  };
53
52
  //#endregion
54
53
  //#region src/components/Amap/AmapMarkerCluster/AmapMarkerCluster.tsx
55
- function T(c) {
56
- let { AMap: l, map: u, mapReady: h } = e(), { data: T, getKey: E, getPosition: D, renderMarker: O, renderCluster: k, clusterOptions: A = s, markerOffset: j, onError: M } = c, { scheduleInfoWindowOpen: N, scheduleInfoWindowClose: P, closeInfoWindow: F } = t({
54
+ function T(t) {
55
+ let { AMap: l, map: u, mapReady: h } = e(), { data: T, getKey: E, getPosition: D, renderMarker: O, renderCluster: k, clusterOptions: A = c, markerOffset: j, onError: M } = t, { scheduleInfoWindowOpen: N, scheduleInfoWindowClose: P, closeInfoWindow: F } = n({
57
56
  AMap: l,
58
57
  map: u,
59
58
  mapReady: h
60
- }), I = a(null), L = a(/* @__PURE__ */ new Set()), R = a(/* @__PURE__ */ new Map()), z = a(null), B = a(""), V = a(""), H = a(c), U = a([]), W = a(!0);
61
- H.current = c, r(() => {
62
- c.markerInfoWindow || F();
63
- }, [F, c.markerInfoWindow]);
64
- let G = i(() => {
59
+ }), I = o(null), L = o(/* @__PURE__ */ new Set()), R = o(/* @__PURE__ */ new Map()), z = o(null), B = o(""), V = o(""), H = o(t), U = o([]), W = o(!0);
60
+ H.current = t, i(() => {
61
+ t.markerInfoWindow || F();
62
+ }, [F, t.markerInfoWindow]);
63
+ let G = a(() => {
65
64
  let e = [];
66
65
  return T.forEach((t, n) => {
67
66
  let r = D(t);
@@ -80,25 +79,25 @@ function T(c) {
80
79
  D
81
80
  ]);
82
81
  U.current = G.validItems;
83
- let K = n((e) => {
82
+ let K = r((e) => {
84
83
  let t = H.current, n = v(e), r = _(e);
85
84
  n !== B.current && (B.current = n, t.onVisibleItemsChange?.(e.map((e) => e.item))), r !== V.current && (V.current = r, t.onMarkerRuntimeChange?.(e));
86
- }, []), q = n(() => {
85
+ }, []), q = r(() => {
87
86
  B.current = "", V.current = "";
88
87
  let e = H.current;
89
88
  e.onVisibleItemsChange?.([]), e.onMarkerRuntimeChange?.([]);
90
- }, []), J = n(() => {
89
+ }, []), J = r(() => {
91
90
  !H.current.onVisibleItemsChange && !H.current.onMarkerRuntimeChange || (z.current && clearTimeout(z.current), z.current = setTimeout(() => {
92
91
  z.current = null, K(Array.from(R.current.values()));
93
92
  }, 0));
94
- }, [K]), Y = n(() => {
93
+ }, [K]), Y = r(() => {
95
94
  R.current.clear(), J();
96
95
  }, [J]);
97
- return r(() => {
96
+ return i(() => {
98
97
  if (!l || !u || !h) return;
99
98
  let e = l.MarkerCluster || l.MarkerClusterer, t = R.current;
100
99
  if (!e) {
101
- M?.(Error(o));
100
+ M?.(Error(s));
102
101
  return;
103
102
  }
104
103
  let n = () => {
@@ -148,8 +147,8 @@ function T(c) {
148
147
  }
149
148
  let r = n.map((e) => new l.Marker({ position: e }));
150
149
  u.setFitView?.(r, !1, t.fitOptions?.padding, t.fitOptions?.maxZoom), r.forEach((e) => e.setMap?.(null));
151
- }, s = m(A);
152
- s.renderMarker = (e) => {
150
+ }, o = m(A);
151
+ o.renderMarker = (e) => {
153
152
  let n = f(e.data)[0], a = H.current;
154
153
  if (e.marker) {
155
154
  let o = e.marker;
@@ -170,7 +169,7 @@ function T(c) {
170
169
  }), J();
171
170
  }
172
171
  }
173
- }, s.renderClusterMarker = (e) => {
172
+ }, o.renderClusterMarker = (e) => {
174
173
  let t = H.current, n = f(e.data).map((e) => e.extData?.item).filter(Boolean);
175
174
  if (e.marker) {
176
175
  let i = e.marker;
@@ -182,7 +181,7 @@ function T(c) {
182
181
  S(i), x(i, o, s);
183
182
  }
184
183
  };
185
- let c = new e(u, U.current, s);
184
+ let c = new e(u, U.current, o);
186
185
  I.current = c, W.current = !0;
187
186
  let _ = (e) => {
188
187
  let t = e?.marker || e?.target, n = f(e?.clusterData || e?.data).map((e) => e.extData?.item).filter(Boolean);
@@ -220,7 +219,7 @@ function T(c) {
220
219
  q,
221
220
  P,
222
221
  N
223
- ]), r(() => {
222
+ ]), i(() => {
224
223
  if (I.current) {
225
224
  if (W.current) {
226
225
  W.current = !1;
@@ -1,5 +1,5 @@
1
1
  import "../../vendors/LocaleContext-CBcJzvUD.js";
2
2
  import "../../vendors/ConfigProvider-AQTr7T_c.js";
3
3
  import "../AmapContext-CFmsMycg.js";
4
- import { t as e } from "../AmapProvider-XCrqzo9W.js";
4
+ import { t as e } from "../AmapProvider-BGzdby3i.js";
5
5
  export { e as AmapProvider, e as default };
@@ -2,52 +2,53 @@ import { n as e } from "../vendors/ConfigProvider-AQTr7T_c.js";
2
2
  import { n as t } from "./AmapContext-CFmsMycg.js";
3
3
  import { Fragment as n, jsx as r } from "react/jsx-runtime";
4
4
  import { useEffect as i, useState as a } from "react";
5
+ import o from "@amap/amap-jsapi-loader";
5
6
  //#region src/components/Amap/loader.ts
6
- var o = "2.0", s = "[ui-base] AMap has already been loaded with a different key, version, or securityJsCode.", c = null, l = null, u = null, d = /* @__PURE__ */ new Map(), f = (e = []) => Array.from(new Set(e.filter(Boolean))), p = (e) => e || void 0, m = async () => (await import("@amap/amap-jsapi-loader")).default, h = (e) => {
7
- if (l && (l.key !== e.key || l.version !== e.version || p(l.securityJsCode) !== p(e.securityJsCode))) throw Error(s);
7
+ var s = "2.0", c = "[ui-base] AMap has already been loaded with a different key, version, or securityJsCode.", l = null, u = null, d = null, f = /* @__PURE__ */ new Map(), p = (e = []) => Array.from(new Set(e.filter(Boolean))), m = (e) => e || void 0, h = (e) => {
8
+ if (u && (u.key !== e.key || u.version !== e.version || m(u.securityJsCode) !== m(e.securityJsCode))) throw Error(c);
8
9
  }, g = (e) => {
9
- f(e).forEach((e) => {
10
- d.set(e, { status: "loaded" });
10
+ p(e).forEach((e) => {
11
+ f.set(e, { status: "loaded" });
11
12
  });
12
13
  }, _ = async (e, t) => {
13
- let n = f(t).filter((e) => d.get(e)?.status !== "loaded");
14
+ let n = p(t).filter((e) => f.get(e)?.status !== "loaded");
14
15
  await Promise.all(n.map((t) => {
15
- let n = d.get(t);
16
+ let n = f.get(t);
16
17
  if (n?.status === "loading" && n.promise) return n.promise;
17
18
  let r = new Promise((n, r) => {
18
19
  try {
19
20
  e.plugin([t], () => {
20
- d.set(t, { status: "loaded" }), n();
21
+ f.set(t, { status: "loaded" }), n();
21
22
  });
22
23
  } catch (e) {
23
- d.set(t, { status: "failed" }), r(e);
24
+ f.set(t, { status: "failed" }), r(e);
24
25
  }
25
26
  });
26
- return d.set(t, {
27
+ return f.set(t, {
27
28
  status: "loading",
28
29
  promise: r
29
30
  }), r;
30
31
  }));
31
32
  }, v = async (e) => {
32
- let t = e.version || o, n = f(e.plugins), r = {
33
+ let t = e.version || s, n = p(e.plugins), r = {
33
34
  key: e.key,
34
- securityJsCode: p(e.securityJsCode),
35
+ securityJsCode: m(e.securityJsCode),
35
36
  version: t
36
37
  };
37
38
  if (!e.key) throw Error("[ui-base] AMap key is required.");
38
39
  if (typeof window > "u") throw Error("[ui-base] AMap can only be loaded in the browser.");
39
- if (window.AMap || (u = null, l = null, c = null, d.clear()), h(r), r.securityJsCode && (window._AMapSecurityConfig = { securityJsCode: r.securityJsCode }), u || window.AMap) {
40
- let e = u || window.AMap;
41
- return u = e, l = r, await _(e, n), e;
40
+ if (window.AMap || (d = null, u = null, l = null, f.clear()), h(r), r.securityJsCode && (window._AMapSecurityConfig = { securityJsCode: r.securityJsCode }), d || window.AMap) {
41
+ let e = d || window.AMap;
42
+ return d = e, u = r, await _(e, n), e;
42
43
  }
43
- c ||= (await m()).load({
44
+ l ||= o.load({
44
45
  key: e.key,
45
46
  version: t,
46
47
  plugins: n
47
- }).then((e) => (u = e, l = r, window.AMap = e, g(n), e)).catch((e) => {
48
- throw c = null, u = null, l = null, d.clear(), e;
48
+ }).then((e) => (d = e, u = r, window.AMap = e, g(n), e)).catch((e) => {
49
+ throw l = null, d = null, u = null, f.clear(), e;
49
50
  });
50
- let i = await c;
51
+ let i = await l;
51
52
  return await _(i, n), i;
52
53
  }, y = (e = []) => Array.from(new Set(e.filter(Boolean))), b = [], x = "", S = (e, t) => typeof e == "function" ? e(t) : e ?? null, C = (e) => e ? y(e.split(x)) : b;
53
54
  function w(o) {
@@ -1,11 +1,11 @@
1
1
  import "../vendors/LocaleContext-CBcJzvUD.js";
2
2
  import "../vendors/ConfigProvider-AQTr7T_c.js";
3
3
  import "./AmapContext-CFmsMycg.js";
4
- import { t as e } from "./AmapProvider-XCrqzo9W.js";
4
+ import { t as e } from "./AmapProvider-BGzdby3i.js";
5
5
  import { t } from "./Amap-Dnvu_pUP.js";
6
6
  import { n, t as r } from "./hooks-DwRvpafb.js";
7
7
  import { t as i } from "./AmapCircle-Wfn43qco.js";
8
- import "./useMarkerInfoWindowController-G-Bg-NDJ.js";
9
- import { t as a } from "./AmapMarker-CB66dQIG.js";
10
- import { t as o } from "./AmapMarkerCluster-DvXchCC0.js";
8
+ import "./useMarkerInfoWindowController-BvP2jo7K.js";
9
+ import { t as a } from "./AmapMarker-CMlzx_nj.js";
10
+ import { t as o } from "./AmapMarkerCluster-MDUfcIqP.js";
11
11
  export { t as Amap, i as AmapCircle, a as AmapMarker, o as AmapMarkerCluster, e as AmapProvider, n as useAmap, r as useCurrentLocation };
@@ -2,10 +2,10 @@ import { Fragment as e, jsx as t } from "react/jsx-runtime";
2
2
  import { useCallback as n, useEffect as r, useRef as i } from "react";
3
3
  import { createRoot as a } from "react-dom/client";
4
4
  import { flushSync as o } from "react-dom";
5
- //#region src/components/Amap/AmapMarker/useMarkerInfoWindowController.tsx
6
- var s = (e) => {
5
+ //#region src/components/Amap/utils/constants.ts
6
+ var s = "bottom-center", c = (e) => {
7
7
  queueMicrotask(() => e.unmount());
8
- }, c = "bottom-center", l = 250, u = (e, t) => Array.isArray(t) && typeof e.Pixel == "function" ? new e.Pixel(t[0], t[1]) : t, d = (e) => e.options?.offset !== void 0 && e.options?.offset !== null, f = ({ AMap: f, map: p, mapReady: m }) => {
8
+ }, l = "bottom-center", u = 250, d = (e, t) => Array.isArray(t) && typeof e.Pixel == "function" ? new e.Pixel(t[0], t[1]) : t, f = (e) => e.options?.offset !== void 0 && e.options?.offset !== null, p = ({ AMap: s, map: p, mapReady: m }) => {
9
9
  let h = i(null), g = i(null), _ = i(null), v = i(null), y = i(!1), b = i({
10
10
  openDelay: null,
11
11
  openFrame: null,
@@ -17,18 +17,18 @@ var s = (e) => {
17
17
  }, []), w = n(() => {
18
18
  S(), C(), v.current = null, x.current = !1, h.current?.close?.();
19
19
  }, [C, S]), T = n(() => {
20
- w(), _.current && (_.current.onmouseenter = null, _.current.onmouseleave = null), g.current && s(g.current), g.current = null, _.current = null, h.current = null, y.current = !1;
20
+ w(), _.current && (_.current.onmouseenter = null, _.current.onmouseleave = null), g.current && c(g.current), g.current = null, _.current = null, h.current = null, y.current = !1;
21
21
  }, [w]), E = n(() => {
22
22
  S(), C(), b.current.closeDelay = window.setTimeout(() => {
23
23
  b.current.closeDelay = null, !x.current && w();
24
- }, l);
24
+ }, u);
25
25
  }, [
26
26
  C,
27
27
  S,
28
28
  w
29
29
  ]), D = n((e) => {
30
- if (!e || !f || !p || !m) return null;
31
- let t = d(e);
30
+ if (!e || !s || !p || !m) return null;
31
+ let t = f(e);
32
32
  if (y.current && !t && h.current && _.current && g.current && T(), h.current && _.current && g.current) return {
33
33
  infoWindow: h.current,
34
34
  contentElement: _.current,
@@ -38,10 +38,10 @@ var s = (e) => {
38
38
  ...e.options,
39
39
  autoMove: !1,
40
40
  isCustom: !0,
41
- anchor: c
41
+ anchor: l
42
42
  };
43
- t && (r.offset = u(f, e.options?.offset));
44
- let i = new f.InfoWindow(r), o = a(n);
43
+ t && (r.offset = d(s, e.options?.offset));
44
+ let i = new s.InfoWindow(r), o = a(n);
45
45
  return n.onmouseenter = () => {
46
46
  x.current = !0, C();
47
47
  }, n.onmouseleave = () => {
@@ -52,30 +52,30 @@ var s = (e) => {
52
52
  contentRoot: o
53
53
  };
54
54
  }, [
55
- f,
55
+ s,
56
56
  C,
57
57
  p,
58
58
  m,
59
59
  T,
60
60
  E
61
61
  ]), O = n((n, r) => {
62
- !n || !r || !f || !p || !m || (v.current = n, C(), S(), b.current.openDelay = window.setTimeout(() => {
62
+ !n || !r || !s || !p || !m || (v.current = n, C(), S(), b.current.openDelay = window.setTimeout(() => {
63
63
  b.current.openDelay = null;
64
64
  let i = D(r);
65
65
  if (!i || v.current !== n) return;
66
- let { infoWindow: a, contentElement: s, contentRoot: l } = i, m = d(r);
67
- if (a.setAnchor?.(c), m) {
68
- let e = u(f, r.options?.offset);
66
+ let { infoWindow: a, contentElement: c, contentRoot: u } = i, m = f(r);
67
+ if (a.setAnchor?.(l), m) {
68
+ let e = d(s, r.options?.offset);
69
69
  a.setOffset?.(e);
70
70
  }
71
71
  o(() => {
72
- l.render(/* @__PURE__ */ t(e, { children: r.content }));
73
- }), a.setContent?.(s), b.current.openFrame = window.requestAnimationFrame(() => {
72
+ u.render(/* @__PURE__ */ t(e, { children: r.content }));
73
+ }), a.setContent?.(c), b.current.openFrame = window.requestAnimationFrame(() => {
74
74
  b.current.openFrame = null, v.current === n && a.open?.(p, n.getPosition?.());
75
75
  });
76
- }, l));
76
+ }, u));
77
77
  }, [
78
- f,
78
+ s,
79
79
  C,
80
80
  S,
81
81
  D,
@@ -83,7 +83,7 @@ var s = (e) => {
83
83
  m
84
84
  ]);
85
85
  return r(() => () => {
86
- w(), _.current && (_.current.onmouseenter = null, _.current.onmouseleave = null), g.current && s(g.current), g.current = null, _.current = null, h.current = null, y.current = !1;
86
+ w(), _.current && (_.current.onmouseenter = null, _.current.onmouseleave = null), g.current && c(g.current), g.current = null, _.current = null, h.current = null, y.current = !1;
87
87
  }, [w]), {
88
88
  scheduleInfoWindowOpen: O,
89
89
  scheduleInfoWindowClose: E,
@@ -91,4 +91,4 @@ var s = (e) => {
91
91
  };
92
92
  };
93
93
  //#endregion
94
- export { f as t };
94
+ export { s as n, p as t };
@@ -3,7 +3,6 @@ import { AmapMarkerClusterContent, AmapMarkerClusterMarkerOffset, AmapMarkerClus
3
3
  import { ClusterPoint, ManagedMarker } from './AmapMarkerCluster.type';
4
4
  export declare const MARKER_CLUSTER_PLUGIN_ERROR = "[ui-base] AmapMarkerCluster requires AMap.MarkerCluster plugin. Please add \"AMap.MarkerCluster\" to AmapProvider plugins.";
5
5
  export declare const EMPTY_CLUSTER_OPTIONS: Record<string, any>;
6
- export declare const DEFAULT_MARKER_ANCHOR = "bottom-center";
7
6
  export declare const isValidPosition: (position: unknown) => position is LngLat;
8
7
  export declare const resolveClusterData: <T>(value: unknown) => Array<ClusterPoint<T>>;
9
8
  export declare const resolveItemContext: <T>(point?: ClusterPoint<T>) => {
@@ -0,0 +1,2 @@
1
+ /** AmapMarker 与 AmapMarkerCluster 共用 */
2
+ export declare const DEFAULT_MARKER_ANCHOR = "bottom-center";
package/dist/index.js CHANGED
@@ -3,13 +3,13 @@ import { t } from "./Icon/Icon-SQ5tu-yG.js";
3
3
  import "./vendors/LocaleContext-CBcJzvUD.js";
4
4
  import { r as n, t as r } from "./vendors/ConfigProvider-AQTr7T_c.js";
5
5
  import "./Amap/AmapContext-CFmsMycg.js";
6
- import { t as i } from "./Amap/AmapProvider-XCrqzo9W.js";
6
+ import { t as i } from "./Amap/AmapProvider-BGzdby3i.js";
7
7
  import { t as a } from "./Amap/Amap-Dnvu_pUP.js";
8
8
  import { n as o, t as s } from "./Amap/hooks-DwRvpafb.js";
9
9
  import { t as c } from "./Amap/AmapCircle-Wfn43qco.js";
10
- import "./Amap/useMarkerInfoWindowController-G-Bg-NDJ.js";
11
- import { t as l } from "./Amap/AmapMarker-CB66dQIG.js";
12
- import { t as u } from "./Amap/AmapMarkerCluster-DvXchCC0.js";
10
+ import "./Amap/useMarkerInfoWindowController-BvP2jo7K.js";
11
+ import { t as l } from "./Amap/AmapMarker-CMlzx_nj.js";
12
+ import { t as u } from "./Amap/AmapMarkerCluster-MDUfcIqP.js";
13
13
  import { t as d } from "./Card/Card-BjWdQRjq.js";
14
14
  import { t as f } from "./Modal/Modal-GGHNlZv3.js";
15
15
  import { t as p } from "./ColorPicker/ColorPicker-Hjs4Vp5a.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ui-base",
3
- "version": "6.7.0",
3
+ "version": "6.7.1",
4
4
  "type": "module",
5
5
  "description": "百数云低代码平台通用组件库",
6
6
  "author": "bsy-fe team",
@@ -1,152 +0,0 @@
1
- import { n as e } from "./hooks-DwRvpafb.js";
2
- import { t } from "./useMarkerInfoWindowController-G-Bg-NDJ.js";
3
- import { Fragment as n, jsx as r } from "react/jsx-runtime";
4
- import { useCallback as i, useEffect as a, useRef as o } from "react";
5
- import { createRoot as s } from "react-dom/client";
6
- //#region src/components/Amap/AmapMarker/useMarkerInfoWindow.tsx
7
- var c = ({ AMap: e, map: n, mapReady: r, markerRef: o, infoWindow: s }) => {
8
- let { scheduleInfoWindowOpen: c, scheduleInfoWindowClose: l, closeInfoWindow: u } = t({
9
- AMap: e,
10
- map: n,
11
- mapReady: r
12
- }), d = i(() => {
13
- if (!s) return;
14
- let e = o.current;
15
- e && c(e, s);
16
- }, [
17
- s,
18
- o,
19
- c
20
- ]);
21
- return a(() => {
22
- if (s) return () => {
23
- u();
24
- };
25
- }, [u, s]), {
26
- scheduleInfoWindowOpen: d,
27
- scheduleInfoWindowClose: l,
28
- closeInfoWindow: u
29
- };
30
- }, l = (e) => typeof e == "string" || typeof e == "number", u = (e) => e != null && typeof e != "boolean", d = (e) => u(e) && !l(e), f = (e) => {
31
- queueMicrotask(() => e.unmount());
32
- };
33
- function p(t) {
34
- let { AMap: i, map: p, mapReady: m } = e(), { content: h, infoWindow: g, options: _ = {}, onClick: v, onMouseEnter: y, onMouseLeave: b } = t, x = !!g, S = o(null), C = o(null), w = o(null), T = o(!0), E = o(!0), D = o({
35
- content: h,
36
- infoWindow: g,
37
- options: _
38
- });
39
- D.current = {
40
- content: h,
41
- infoWindow: g,
42
- options: _
43
- };
44
- let { scheduleInfoWindowOpen: O, scheduleInfoWindowClose: k, closeInfoWindow: A } = c({
45
- AMap: i,
46
- map: p,
47
- mapReady: m,
48
- markerRef: S,
49
- infoWindow: g
50
- });
51
- return a(() => {
52
- if (!i || !p || !m || S.current) return;
53
- let e = D.current, t = {
54
- ...e.options,
55
- map: p
56
- };
57
- if (l(e.content)) {
58
- let n = document.createElement("div");
59
- n.textContent = String(e.content), w.current = n, t.content = n;
60
- } else if (d(e.content)) {
61
- let e = document.createElement("div");
62
- w.current = e, t.content = e;
63
- }
64
- let a = new i.Marker(t);
65
- if (S.current = a, d(e.content) && w.current) {
66
- let t = s(w.current);
67
- C.current = t, t.render(/* @__PURE__ */ r(n, { children: e.content }));
68
- }
69
- return () => {
70
- let e = C.current;
71
- e && f(e), C.current = null, w.current = null, A(), a.setMap(null), S.current = null;
72
- };
73
- }, [
74
- i,
75
- A,
76
- p,
77
- m
78
- ]), a(() => {
79
- let e = _.position;
80
- if (!e) return;
81
- let t = S.current?.getPosition?.(), n = t?.getLng?.() ?? t?.lng, r = t?.getLat?.() ?? t?.lat, i = Array.isArray(e) ? e[0] : e.lng, a = Array.isArray(e) ? e[1] : e.lat;
82
- n === i && r === a || S.current?.setPosition(e);
83
- }, [_.position]), a(() => {
84
- if (E.current) {
85
- E.current = !1;
86
- return;
87
- }
88
- let e = S.current;
89
- e && (_.visible === !1 ? e.hide?.() : _.visible === !0 && e.show?.());
90
- }, [_.visible]), a(() => {
91
- if (T.current) {
92
- T.current = !1;
93
- return;
94
- }
95
- let e = S.current;
96
- if (e) {
97
- if (!u(h)) {
98
- C.current && f(C.current), C.current = null, w.current = null, e.setContent?.("");
99
- return;
100
- }
101
- if (l(h)) {
102
- if (C.current) {
103
- let t = C.current;
104
- f(t), C.current = null, w.current = document.createElement("div"), e.setContent?.(w.current);
105
- }
106
- w.current || (w.current = document.createElement("div"), e.setContent?.(w.current)), w.current.textContent = String(h);
107
- return;
108
- }
109
- w.current || (w.current = document.createElement("div"), e.setContent?.(w.current)), C.current ||= s(w.current), C.current.render(/* @__PURE__ */ r(n, { children: h }));
110
- }
111
- }, [h]), a(() => {
112
- let e = S.current;
113
- if (!e) return;
114
- let t = () => ({
115
- marker: e,
116
- AMap: i,
117
- map: p
118
- }), n = [];
119
- if (v) {
120
- let r = () => {
121
- v?.(t());
122
- };
123
- e.on("click", r), n.push(() => e.off("click", r));
124
- }
125
- if (y || x) {
126
- let r = () => {
127
- x && O(), y?.(t());
128
- };
129
- e.on("mouseover", r), n.push(() => e.off("mouseover", r));
130
- }
131
- if (b || x) {
132
- let r = () => {
133
- x && k(), b?.(t());
134
- };
135
- e.on("mouseout", r), n.push(() => e.off("mouseout", r));
136
- }
137
- return () => {
138
- n.forEach((e) => e());
139
- };
140
- }, [
141
- i,
142
- x,
143
- p,
144
- v,
145
- y,
146
- b,
147
- k,
148
- O
149
- ]), null;
150
- }
151
- //#endregion
152
- export { p as t };