@baishuyun/ui-base 2.4.1 → 3.0.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.
Files changed (91) hide show
  1. package/dist/Amap/Amap-DL5dLiUm.js +77 -0
  2. package/dist/Amap/AmapCircle/index.js +4 -0
  3. package/dist/Amap/AmapCircle-BP187l-8.js +62 -0
  4. package/dist/Amap/AmapContext-JaYk1a3H.js +11 -0
  5. package/dist/Amap/AmapMarker/index.js +5 -0
  6. package/dist/Amap/AmapMarker-DYW0-8Hd.js +152 -0
  7. package/dist/Amap/AmapMarkerCluster/index.js +5 -0
  8. package/dist/Amap/AmapMarkerCluster-BRVHHMbi.js +241 -0
  9. package/dist/Amap/AmapProvider/index.js +5 -0
  10. package/dist/Amap/AmapProvider-CWbRK6QL.js +107 -0
  11. package/dist/Amap/hooks/index.js +3 -0
  12. package/dist/Amap/hooks-D1m8KgVM.js +121 -0
  13. package/dist/Amap/index.js +11 -0
  14. package/dist/Amap/useMarkerInfoWindowController-CRgf2I0Q.js +94 -0
  15. package/dist/Card/index.js +1 -1
  16. package/dist/CheckBox/{CheckBox-Cz6KW9Lw.js → CheckBox-B04hZKaC.js} +1 -1
  17. package/dist/CheckBox/index.js +2 -2
  18. package/dist/ColorPicker/{ColorPicker-C1kG_eI-.js → ColorPicker-B-KaMDAn.js} +3 -3
  19. package/dist/ColorPicker/index.js +4 -3
  20. package/dist/ConfigProvider/ConfigProvider-Bx-uxnns.js +159 -0
  21. package/dist/ConfigProvider/index.js +3 -0
  22. package/dist/DropDown/{DropDown-BAPBTglm.js → DropDown-CMKiQDrc.js} +5 -5
  23. package/dist/DropDown/index.js +6 -5
  24. package/dist/Editor/{Buttons-CsKKYGbV.js → Buttons-CZOTyAPL.js} +49 -49
  25. package/dist/Editor/ToolbarPlugin/Buttons/index.js +12 -11
  26. package/dist/Editor/index.js +12 -11
  27. package/dist/InputTag/index.js +1 -1
  28. package/dist/Loading/index.js +1 -1
  29. package/dist/Modal/index.js +1 -1
  30. package/dist/NotFoundContent/index.js +1 -1
  31. package/dist/Radio/index.js +1 -1
  32. package/dist/Segmented/index.js +1 -1
  33. package/dist/Select/{Select-DyV_1e23.js → Select-xuQGK6It.js} +7 -7
  34. package/dist/Select/{SelectInputSearch-DMY6Y9B6.js → SelectInputSearch-Dm3CI_L4.js} +1 -1
  35. package/dist/Select/index.js +10 -9
  36. package/dist/Tabs/{Tabs-BqT-_eVo.js → Tabs-Cxf7jwys.js} +3 -3
  37. package/dist/Tabs/index.js +3 -3
  38. package/dist/Tree/index.js +3 -3
  39. package/dist/components/Amap/Amap.d.ts +3 -0
  40. package/dist/components/Amap/AmapCircle/AmapCircle.d.ts +3 -0
  41. package/dist/components/Amap/AmapCircle/index.d.ts +1 -0
  42. package/dist/components/Amap/AmapMarker/AmapMarker.d.ts +3 -0
  43. package/dist/components/Amap/AmapMarker/__tests__/AmapMarker.test.d.ts +1 -0
  44. package/dist/components/Amap/AmapMarker/index.d.ts +1 -0
  45. package/dist/components/Amap/AmapMarker/useMarkerInfoWindow.d.ts +15 -0
  46. package/dist/components/Amap/AmapMarker/useMarkerInfoWindowController.d.ts +13 -0
  47. package/dist/components/Amap/AmapMarkerCluster/AmapMarkerCluster.d.ts +3 -0
  48. package/dist/components/Amap/AmapMarkerCluster/AmapMarkerCluster.type.d.ts +25 -0
  49. package/dist/components/Amap/AmapMarkerCluster/__tests__/AmapMarkerCluster.test.d.ts +1 -0
  50. package/dist/components/Amap/AmapMarkerCluster/index.d.ts +1 -0
  51. package/dist/components/Amap/AmapMarkerCluster/utils.d.ts +26 -0
  52. package/dist/components/Amap/AmapProvider/AmapProvider.d.ts +3 -0
  53. package/dist/components/Amap/AmapProvider/__tests__/AmapProvider.test.d.ts +1 -0
  54. package/dist/components/Amap/AmapProvider/index.d.ts +1 -0
  55. package/dist/components/Amap/__tests__/Amap.test.d.ts +1 -0
  56. package/dist/components/Amap/amap-types.d.ts +44 -0
  57. package/dist/components/Amap/context/AmapContext.d.ts +3 -0
  58. package/dist/components/Amap/hooks/__tests__/useCurrentLocation.test.d.ts +1 -0
  59. package/dist/components/Amap/hooks/index.d.ts +2 -0
  60. package/dist/components/Amap/hooks/useAmap.d.ts +2 -0
  61. package/dist/components/Amap/hooks/useCurrentLocation.d.ts +2 -0
  62. package/dist/components/Amap/index.d.ts +7 -0
  63. package/dist/components/Amap/interface.d.ts +142 -0
  64. package/dist/components/Amap/loader.d.ts +9 -0
  65. package/dist/components/Amap/utils/currentLocation.d.ts +18 -0
  66. package/dist/components/ConfigProvider/ConfigProvider.d.ts +3 -0
  67. package/dist/components/ConfigProvider/ConfigProvider.type.d.ts +16 -0
  68. package/dist/components/ConfigProvider/__tests__/ConfigProvider.test.d.ts +1 -0
  69. package/dist/components/ConfigProvider/context.d.ts +3 -0
  70. package/dist/components/ConfigProvider/index.d.ts +3 -0
  71. package/dist/components/index.d.ts +4 -0
  72. package/dist/index.js +49 -155
  73. package/dist/locale/LocaleProvider.d.ts +3 -0
  74. package/dist/locale/__tests__/LocaleProvider.test.d.ts +1 -0
  75. package/dist/vendors/{useLocale-BXnqO-Ju.js → LocaleContext-Jj_JGgi2.js} +7 -7
  76. package/dist/vendors/{Tree-P9E06Unm.js → Tree-Bg2UzLsC.js} +2 -2
  77. package/dist/vendors/useLocale-Mk0d7wNt.js +6 -0
  78. package/dist/vite-env.d.ts +7 -0
  79. package/package.json +4 -3
  80. /package/dist/Card/{Card-CaKTq_1y.js → Card-D__c94yx.js} +0 -0
  81. /package/dist/CheckBox/{CheckBox-l__wOnmH.js → CheckBox-DF201Nxg.js} +0 -0
  82. /package/dist/InputTag/{InputTag-V4UnUnGJ.js → InputTag-F2Dv-r56.js} +0 -0
  83. /package/dist/Loading/{Loading-Dy5A--HK.js → Loading-dsLWSWsE.js} +0 -0
  84. /package/dist/Modal/{Modal-DQ5bptu_.js → Modal-CuDbh_WD.js} +0 -0
  85. /package/dist/NotFoundContent/{NotFoundContent-1-41e1rN.js → NotFoundContent-DJUQ0_2D.js} +0 -0
  86. /package/dist/Radio/{Radio-CZOrtNyn.js → Radio-WNw-VqIS.js} +0 -0
  87. /package/dist/Segmented/{Segmented-DEGgLO-b.js → Segmented-Byw8j1hQ.js} +0 -0
  88. /package/dist/{locale/LocaleProvider.test.d.ts → components/Amap/AmapCircle/__tests__/AmapCircle.test.d.ts} +0 -0
  89. /package/dist/vendors/{animations-DvjIfVz9.js → animations-C2i5EijE.js} +0 -0
  90. /package/dist/vendors/{color-CyuNdAfc.js → color-CxdZwdYM.js} +0 -0
  91. /package/dist/vendors/{useFloatingPortal-W4pliYWU.js → useFloatingPortal-CDgiCnbb.js} +0 -0
@@ -0,0 +1,77 @@
1
+ import { n as e, t } from "./AmapContext-JaYk1a3H.js";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import { useContext as r, useEffect as i, useRef as a, useState as o } from "react";
4
+ //#region src/components/Amap/Amap.tsx
5
+ function s(s) {
6
+ let { center: c, zoom: l, options: u = {}, className: d, style: f, children: p, onReady: m, onError: h } = s, { AMap: g, loading: _, error: v } = r(e), y = a(null), b = a(null), x = a({
7
+ center: c,
8
+ zoom: l,
9
+ options: u,
10
+ onReady: m,
11
+ onError: h
12
+ }), [S, C] = o(!1);
13
+ x.current = {
14
+ center: c,
15
+ zoom: l,
16
+ options: u,
17
+ onReady: m,
18
+ onError: h
19
+ }, i(() => {
20
+ if (!g || !y.current || b.current) return;
21
+ let e = x.current, t = !1, n = new g.Map(y.current, {
22
+ resizeEnable: !0,
23
+ animateEnable: !1,
24
+ zooms: [3, 20],
25
+ ...e.options,
26
+ ...e.center ? { center: e.center } : {},
27
+ ...e.zoom !== null && e.zoom !== void 0 ? { zoom: e.zoom } : {}
28
+ });
29
+ b.current = n;
30
+ let r = () => {
31
+ t || (C(!0), x.current.onReady?.({
32
+ AMap: g,
33
+ map: n
34
+ }));
35
+ };
36
+ try {
37
+ n.on("complete", r);
38
+ } catch (e) {
39
+ x.current.onError?.(e);
40
+ }
41
+ return () => {
42
+ t = !0;
43
+ try {
44
+ n.off?.("complete", r);
45
+ } finally {
46
+ n.destroy?.(), b.current = null, C(!1);
47
+ }
48
+ };
49
+ }, [g]), i(() => {
50
+ b.current && c && b.current.setCenter?.(c);
51
+ }, [c]), i(() => {
52
+ b.current && l != null && b.current.setZoom?.(l);
53
+ }, [l]);
54
+ let w = g && b.current ? {
55
+ AMap: g,
56
+ map: b.current,
57
+ jsApiReady: !0,
58
+ mapReady: S,
59
+ loading: _,
60
+ error: v
61
+ } : null;
62
+ return /* @__PURE__ */ n("div", {
63
+ className: d,
64
+ ref: y,
65
+ style: {
66
+ width: "100%",
67
+ height: "100%",
68
+ ...f
69
+ },
70
+ children: w && S ? /* @__PURE__ */ n(t.Provider, {
71
+ value: w,
72
+ children: p
73
+ }) : null
74
+ });
75
+ }
76
+ //#endregion
77
+ export { s as t };
@@ -0,0 +1,4 @@
1
+ import "../AmapContext-JaYk1a3H.js";
2
+ import "../hooks-D1m8KgVM.js";
3
+ import { t as e } from "../AmapCircle-BP187l-8.js";
4
+ export { e as AmapCircle, e as default };
@@ -0,0 +1,62 @@
1
+ import { n as e } from "./hooks-D1m8KgVM.js";
2
+ import { useEffect as t, useRef as n } from "react";
3
+ //#region src/components/Amap/AmapCircle/AmapCircle.tsx
4
+ function r(r) {
5
+ let { AMap: i, map: a, mapReady: o } = e(), { center: s, radius: c, options: l = {}, visible: u = !0, onReady: d, onClick: f, onMouseEnter: p, onMouseLeave: m } = r, h = n(null), g = c > 0, _ = n({
6
+ center: s,
7
+ radius: c,
8
+ options: l,
9
+ onReady: d
10
+ });
11
+ return _.current = {
12
+ center: s,
13
+ radius: c,
14
+ options: l,
15
+ onReady: d
16
+ }, t(() => {
17
+ if (!i || !a || !o || h.current || !g) return;
18
+ let e = _.current, t = new i.Circle({
19
+ ...e.options,
20
+ center: e.center,
21
+ radius: e.radius
22
+ });
23
+ return a.add(t), h.current = t, e.onReady?.({
24
+ circle: t,
25
+ AMap: i,
26
+ map: a
27
+ }), () => {
28
+ a.remove(t), h.current = null;
29
+ };
30
+ }, [
31
+ i,
32
+ g,
33
+ a,
34
+ o
35
+ ]), t(() => {
36
+ h.current?.setCenter(s);
37
+ }, [s]), t(() => {
38
+ c > 0 && h.current?.setRadius(c);
39
+ }, [c]), t(() => {
40
+ let e = h.current;
41
+ e && (u ? e.show?.() : e.hide?.());
42
+ }, [u]), t(() => {
43
+ let e = h.current;
44
+ if (!e) return;
45
+ let t = () => ({
46
+ circle: e,
47
+ AMap: i,
48
+ map: a
49
+ }), n = () => f?.(t()), r = () => p?.(t()), o = () => m?.(t());
50
+ return e.on("click", n), e.on("mouseover", r), e.on("mouseout", o), () => {
51
+ e.off("click", n), e.off("mouseover", r), e.off("mouseout", o);
52
+ };
53
+ }, [
54
+ i,
55
+ a,
56
+ f,
57
+ p,
58
+ m
59
+ ]), null;
60
+ }
61
+ //#endregion
62
+ export { r as t };
@@ -0,0 +1,11 @@
1
+ import { createContext as e } from "react";
2
+ //#region src/components/Amap/context/AmapContext.ts
3
+ var t = e({
4
+ AMap: null,
5
+ status: "idle",
6
+ loading: !1,
7
+ error: null,
8
+ plugins: []
9
+ }), n = e(null);
10
+ //#endregion
11
+ export { t as n, n as t };
@@ -0,0 +1,5 @@
1
+ import "../AmapContext-JaYk1a3H.js";
2
+ import "../hooks-D1m8KgVM.js";
3
+ import "../useMarkerInfoWindowController-CRgf2I0Q.js";
4
+ import { t as e } from "../AmapMarker-DYW0-8Hd.js";
5
+ export { e as AmapMarker, e as default };
@@ -0,0 +1,152 @@
1
+ import { n as e } from "./hooks-D1m8KgVM.js";
2
+ import { t } from "./useMarkerInfoWindowController-CRgf2I0Q.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 };
@@ -0,0 +1,5 @@
1
+ import "../AmapContext-JaYk1a3H.js";
2
+ import "../hooks-D1m8KgVM.js";
3
+ import "../useMarkerInfoWindowController-CRgf2I0Q.js";
4
+ import { t as e } from "../AmapMarkerCluster-BRVHHMbi.js";
5
+ export { e as AmapMarkerCluster, e as default };
@@ -0,0 +1,241 @@
1
+ import { n as e } from "./hooks-D1m8KgVM.js";
2
+ import { t } from "./useMarkerInfoWindowController-CRgf2I0Q.js";
3
+ import { useCallback as n, useEffect as r, useMemo as i, useRef as a } from "react";
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) => {
6
+ let t = { ...e };
7
+ return delete t.renderMarker, delete t.renderClusterMarker, t;
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) => [
9
+ e.key,
10
+ h(e.marker),
11
+ g(e.content)
12
+ ].join(":")).join("|"), v = (e) => e.map((e) => e.key).join("|"), y = () => "\n <div\n class=\"bsy-amap-marker-cluster__marker\"\n style=\"width: 16px; height: 16px; border-radius: 50%; background: #1677ff; border: 3px solid #ffffff; box-shadow: 0 2px 8px rgba(22, 119, 255, 0.35); box-sizing: border-box;\"\n ></div>\n", b = (e) => `
13
+ <div
14
+ class="bsy-amap-marker-cluster__cluster"
15
+ style="display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 10px 10px 10px 4px; border-radius: 100px; background: #ffffff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.06); white-space: nowrap; box-sizing: border-box;"
16
+ >
17
+ <svg
18
+ xmlns="http://www.w3.org/2000/svg"
19
+ class="bsy-amap-marker-cluster__cluster-icon"
20
+ data-testid="map-cluster-marker-icon"
21
+ aria-hidden="true"
22
+ width="22"
23
+ height="22"
24
+ viewBox="0 0 22 22"
25
+ fill="none"
26
+ style="flex: none; width: 22px; height: 22px;"
27
+ >
28
+ <path d="M11 20.1693C9.85417 20.1693 2.75 14.6422 2.75 10.0859C2.75 5.52965 6.44371 1.83594 11 1.83594C15.5563 1.83594 19.25 5.52965 19.25 10.0859C19.25 14.6422 12.1458 20.1693 11 20.1693ZM11 12.6068C12.3922 12.6068 13.5208 11.4781 13.5208 10.0859C13.5208 8.69375 12.3922 7.5651 11 7.5651C9.60781 7.5651 8.47917 8.69375 8.47917 10.0859C8.47917 11.4781 9.60781 12.6068 11 12.6068Z" fill="#0265ff"/>
29
+ </svg>
30
+ <span
31
+ class="bsy-amap-marker-cluster__cluster-count"
32
+ style="color: #121111; font-family: Arial, sans-serif; font-size: 18px; font-weight: 700; line-height: 1.4;"
33
+ >${e}</span>
34
+ </div>
35
+ `, x = (e, t, n = g(t)) => {
36
+ t === void 0 || e.__bsyAmapMarkerClusterContentSignature === n || (e.setContent?.(t), e.__bsyAmapMarkerClusterContentSignature = n);
37
+ }, S = (e) => {
38
+ e.setAnchor?.(c);
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);
46
+ }
47
+ }, w = (e) => {
48
+ let t = e.__bsyAmapMarkerClusterRuntime;
49
+ if (!t) return;
50
+ let { handleClick: n, handleMouseEnter: r, handleMouseLeave: i, key: a } = t;
51
+ return n && e.off?.("click", n), r && e.off?.("mouseover", r), i && e.off?.("mouseout", i), e.__bsyAmapMarkerClusterRuntime = null, a;
52
+ };
53
+ //#endregion
54
+ //#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({
57
+ AMap: l,
58
+ map: u,
59
+ 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(() => {
65
+ let e = [];
66
+ return T.forEach((t, n) => {
67
+ let r = D(t);
68
+ d(r) && e.push({
69
+ lnglat: r,
70
+ extData: {
71
+ item: t,
72
+ index: n,
73
+ key: E(t)
74
+ }
75
+ });
76
+ }), { validItems: e };
77
+ }, [
78
+ T,
79
+ E,
80
+ D
81
+ ]);
82
+ U.current = G.validItems;
83
+ let K = n((e) => {
84
+ let t = H.current, n = v(e), r = _(e);
85
+ 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(() => {
87
+ B.current = "", V.current = "";
88
+ let e = H.current;
89
+ e.onVisibleItemsChange?.([]), e.onMarkerRuntimeChange?.([]);
90
+ }, []), J = n(() => {
91
+ !H.current.onVisibleItemsChange && !H.current.onMarkerRuntimeChange || (z.current && clearTimeout(z.current), z.current = setTimeout(() => {
92
+ z.current = null, K(Array.from(R.current.values()));
93
+ }, 0));
94
+ }, [K]), Y = n(() => {
95
+ R.current.clear(), J();
96
+ }, [J]);
97
+ return r(() => {
98
+ if (!l || !u || !h) return;
99
+ let e = l.MarkerCluster || l.MarkerClusterer, t = R.current;
100
+ if (!e) {
101
+ M?.(Error(o));
102
+ return;
103
+ }
104
+ let n = () => {
105
+ L.current.forEach((e) => w(e)), L.current.clear(), F();
106
+ }, r = (e) => {
107
+ let n = w(e);
108
+ n && (t.delete(n), J(), F());
109
+ }, i = (e, t) => {
110
+ let n = e, r = p(t);
111
+ if (!r) return;
112
+ let i = () => ({
113
+ item: r.item,
114
+ marker: e,
115
+ AMap: l,
116
+ map: u
117
+ });
118
+ if (H.current.onMarkerMouseEnter || H.current.markerInfoWindow) {
119
+ let t = () => {
120
+ let t = H.current, n = t.markerInfoWindow?.({
121
+ item: r.item,
122
+ index: r.index
123
+ });
124
+ n && N(e, n), t.onMarkerMouseEnter?.(i());
125
+ };
126
+ e.on?.("mouseover", t), n.__bsyAmapMarkerClusterRuntime = {
127
+ ...n.__bsyAmapMarkerClusterRuntime,
128
+ handleMouseEnter: t
129
+ };
130
+ }
131
+ if (H.current.onMarkerMouseLeave || H.current.markerInfoWindow) {
132
+ let t = () => {
133
+ let e = H.current;
134
+ e.markerInfoWindow && P(), e.onMarkerMouseLeave?.(i());
135
+ };
136
+ e.on?.("mouseout", t), n.__bsyAmapMarkerClusterRuntime = {
137
+ ...n.__bsyAmapMarkerClusterRuntime,
138
+ handleMouseLeave: t
139
+ };
140
+ }
141
+ }, a = (e) => {
142
+ let t = H.current;
143
+ if (t.autoFitOnClusterClick === !1 || e.length === 0) return;
144
+ let n = e.map((e) => t.getPosition(e)).filter(d);
145
+ if (n.length === 1) {
146
+ u.setZoomAndCenter?.(t.fitOptions?.singlePointZoom ?? u.getZoom?.() ?? 16, n[0]);
147
+ return;
148
+ }
149
+ let r = n.map((e) => new l.Marker({ position: e }));
150
+ u.setFitView?.(r, !1, t.fitOptions?.padding, t.fitOptions?.maxZoom), r.forEach((e) => e.setMap?.(null));
151
+ }, s = m(A);
152
+ s.renderMarker = (e) => {
153
+ let n = f(e.data)[0], a = H.current;
154
+ if (e.marker) {
155
+ let o = e.marker;
156
+ if (r(o), L.current.add(o), o.__bsyAmapMarkerClusterRuntime = {}, i(e.marker, n), n) {
157
+ let r = a.renderMarker ? a.renderMarker({
158
+ item: n.extData.item,
159
+ index: n.extData.index
160
+ }) : y(), i = a.renderMarker ? g(r) : "default-marker";
161
+ S(o), x(o, r, i), C(l, o, a.markerOffset), o.__bsyAmapMarkerClusterRuntime = {
162
+ ...o.__bsyAmapMarkerClusterRuntime,
163
+ key: n.extData.key
164
+ }, t.set(n.extData.key, {
165
+ item: n.extData.item,
166
+ index: n.extData.index,
167
+ key: n.extData.key,
168
+ marker: e.marker,
169
+ content: r
170
+ }), J();
171
+ }
172
+ }
173
+ }, s.renderClusterMarker = (e) => {
174
+ let t = H.current, n = f(e.data).map((e) => e.extData?.item).filter(Boolean);
175
+ if (e.marker) {
176
+ let i = e.marker;
177
+ r(i), L.current.add(i), i.__bsyAmapMarkerClusterRuntime = {};
178
+ let a = e.count ?? n.length, o = t.renderCluster ? t.renderCluster({
179
+ count: a,
180
+ items: n
181
+ }) : b(a), s = t.renderCluster ? g(o) : `default-cluster:${a}`;
182
+ S(i), x(i, o, s);
183
+ }
184
+ };
185
+ let c = new e(u, U.current, s);
186
+ I.current = c, W.current = !0;
187
+ let _ = (e) => {
188
+ let t = e?.marker || e?.target, n = f(e?.clusterData || e?.data).map((e) => e.extData?.item).filter(Boolean);
189
+ if (!t || n.length === 0) return;
190
+ if (n.length === 1) {
191
+ H.current.onMarkerClick?.({
192
+ item: n[0],
193
+ marker: t,
194
+ AMap: l,
195
+ map: u
196
+ });
197
+ return;
198
+ }
199
+ a(n);
200
+ let r = {
201
+ items: n,
202
+ marker: t,
203
+ AMap: l,
204
+ map: u
205
+ };
206
+ H.current.onClusterClick?.(r);
207
+ };
208
+ return c.on?.("click", _), () => {
209
+ z.current &&= (clearTimeout(z.current), null), c.off?.("click", _), n(), t.clear(), q(), c.clearMarkers?.(), c.setMap?.(null), I.current = null;
210
+ };
211
+ }, [
212
+ l,
213
+ A,
214
+ F,
215
+ K,
216
+ u,
217
+ h,
218
+ M,
219
+ J,
220
+ q,
221
+ P,
222
+ N
223
+ ]), r(() => {
224
+ if (I.current) {
225
+ if (W.current) {
226
+ W.current = !1;
227
+ return;
228
+ }
229
+ L.current.forEach((e) => w(e)), L.current.clear(), F(), Y(), I.current.setData?.(G.validItems);
230
+ }
231
+ }, [
232
+ Y,
233
+ F,
234
+ j,
235
+ G.validItems,
236
+ k,
237
+ O
238
+ ]), null;
239
+ }
240
+ //#endregion
241
+ export { T as t };
@@ -0,0 +1,5 @@
1
+ import "../../vendors/LocaleContext-Jj_JGgi2.js";
2
+ import "../../ConfigProvider/ConfigProvider-Bx-uxnns.js";
3
+ import "../AmapContext-JaYk1a3H.js";
4
+ import { t as e } from "../AmapProvider-CWbRK6QL.js";
5
+ export { e as AmapProvider, e as default };
@@ -0,0 +1,107 @@
1
+ import { n as e } from "../ConfigProvider/ConfigProvider-Bx-uxnns.js";
2
+ import { n as t } from "./AmapContext-JaYk1a3H.js";
3
+ import { Fragment as n, jsx as r } from "react/jsx-runtime";
4
+ import { useEffect as i, useState as a } from "react";
5
+ //#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);
8
+ }, g = (e) => {
9
+ f(e).forEach((e) => {
10
+ d.set(e, { status: "loaded" });
11
+ });
12
+ }, _ = async (e, t) => {
13
+ let n = f(t).filter((e) => d.get(e)?.status !== "loaded");
14
+ await Promise.all(n.map((t) => {
15
+ let n = d.get(t);
16
+ if (n?.status === "loading" && n.promise) return n.promise;
17
+ let r = new Promise((n, r) => {
18
+ try {
19
+ e.plugin([t], () => {
20
+ d.set(t, { status: "loaded" }), n();
21
+ });
22
+ } catch (e) {
23
+ d.set(t, { status: "failed" }), r(e);
24
+ }
25
+ });
26
+ return d.set(t, {
27
+ status: "loading",
28
+ promise: r
29
+ }), r;
30
+ }));
31
+ }, v = async (e) => {
32
+ let t = e.version || o, n = f(e.plugins), r = {
33
+ key: e.key,
34
+ securityJsCode: p(e.securityJsCode),
35
+ version: t
36
+ };
37
+ if (!e.key) throw Error("[ui-base] AMap key is required.");
38
+ 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;
42
+ }
43
+ c ||= (await m()).load({
44
+ key: e.key,
45
+ version: t,
46
+ 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;
49
+ });
50
+ let i = await c;
51
+ return await _(i, n), i;
52
+ }, 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
+ function w(o) {
54
+ let s = e(), { amapKey: c, securityJsCode: l, version: u, plugins: d = b, fallback: f = null, errorFallback: p = null, children: m } = o, h = s.amap, g = [...h?.plugins || b, ...d].filter(Boolean).join(x), [_, y] = a({
55
+ AMap: null,
56
+ status: "idle",
57
+ loading: !1,
58
+ error: null,
59
+ plugins: C(g)
60
+ });
61
+ return i(() => {
62
+ let e = !1, t = C(g);
63
+ return y({
64
+ AMap: null,
65
+ status: "loading",
66
+ loading: !0,
67
+ error: null,
68
+ plugins: t
69
+ }), v({
70
+ key: c || h?.key || "",
71
+ securityJsCode: l ?? h?.securityJsCode,
72
+ version: u || h?.version,
73
+ plugins: t
74
+ }).then((n) => {
75
+ e || y({
76
+ AMap: n,
77
+ status: "success",
78
+ loading: !1,
79
+ error: null,
80
+ plugins: t
81
+ });
82
+ }).catch((n) => {
83
+ e || y({
84
+ AMap: null,
85
+ status: "error",
86
+ loading: !1,
87
+ error: n,
88
+ plugins: t
89
+ });
90
+ }), () => {
91
+ e = !0;
92
+ };
93
+ }, [
94
+ h?.key,
95
+ h?.securityJsCode,
96
+ h?.version,
97
+ c,
98
+ g,
99
+ l,
100
+ u
101
+ ]), _.loading ? /* @__PURE__ */ r(n, { children: f }) : _.error ? /* @__PURE__ */ r(n, { children: S(p, _.error) }) : _.status === "success" ? /* @__PURE__ */ r(t.Provider, {
102
+ value: _,
103
+ children: m
104
+ }) : null;
105
+ }
106
+ //#endregion
107
+ export { w as t };
@@ -0,0 +1,3 @@
1
+ import "../AmapContext-JaYk1a3H.js";
2
+ import { n as e, t } from "../hooks-D1m8KgVM.js";
3
+ export { e as useAmap, t as useCurrentLocation };