@baishuyun/ui-mobile 0.5.0 → 0.6.0

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 (47) hide show
  1. package/dist/AMap/AMap-BWZ2lhXr.js +683 -0
  2. package/dist/AMap/index.js +5 -0
  3. package/dist/ActionSheet/{ActionSheet-Ok-UTVMn.js → ActionSheet-DbrKxa_y.js} +1 -1
  4. package/dist/ActionSheet/index.js +3 -3
  5. package/dist/Calendar/{Calendar-ipjycVqK.js → Calendar-Bd6CS8y7.js} +2 -2
  6. package/dist/Calendar/index.js +4 -4
  7. package/dist/ConfigProvider/{ConfigProvider-CNhaKMJa.js → ConfigProvider-DnlakyRE.js} +36 -9
  8. package/dist/ConfigProvider/index.js +4 -4
  9. package/dist/{vendors/useLocale-CMHIlzlj.js → ConfigProvider/useLocale-CP8NRZoj.js} +19 -2
  10. package/dist/Gantt/{Gantt-DDItjDkR.js → Gantt-CR7eRNVP.js} +176 -181
  11. package/dist/Gantt/index.js +6 -6
  12. package/dist/Icon/index.js +1 -1
  13. package/dist/components/AMap/AMap.d.ts +3 -0
  14. package/dist/components/AMap/Controls/Controls.d.ts +3 -0
  15. package/dist/components/AMap/Controls/index.d.ts +1 -0
  16. package/dist/components/AMap/Locate/Locate.d.ts +3 -0
  17. package/dist/components/AMap/Locate/index.d.ts +1 -0
  18. package/dist/components/AMap/Markers/Markers.d.ts +3 -0
  19. package/dist/components/AMap/Markers/index.d.ts +1 -0
  20. package/dist/components/AMap/PoiSearch/PoiSearch.d.ts +3 -0
  21. package/dist/components/AMap/PoiSearch/index.d.ts +1 -0
  22. package/dist/components/AMap/context.d.ts +7 -0
  23. package/dist/components/AMap/ensureAMap.d.ts +7 -0
  24. package/dist/components/AMap/index.d.ts +15 -0
  25. package/dist/components/AMap/interface.d.ts +66 -0
  26. package/dist/components/AMap/utils/cx.d.ts +1 -0
  27. package/dist/components/AMap/utils/geometry.d.ts +21 -0
  28. package/dist/components/AMap/utils/markerHtml.d.ts +21 -0
  29. package/dist/components/AMap/utils/searchPois.d.ts +6 -0
  30. package/dist/components/ConfigProvider/ConfigContext.d.ts +11 -0
  31. package/dist/components/ConfigProvider/ConfigProvider.d.ts +1 -1
  32. package/dist/components/ConfigProvider/context.d.ts +14 -0
  33. package/dist/components/ConfigProvider/index.d.ts +2 -1
  34. package/dist/components/Gantt/GanttBar.d.ts +3 -1
  35. package/dist/components/Gantt/index.d.ts +1 -1
  36. package/dist/components/Gantt/{calcTodayLeft.d.ts → utils/calcTodayLeft.d.ts} +1 -1
  37. package/dist/components/index.d.ts +4 -2
  38. package/dist/index.js +10 -9
  39. package/dist/locale/lang/en-US.json.d.ts +11 -0
  40. package/dist/locale/lang/zh-CN.json.d.ts +11 -0
  41. package/dist/locale/lang/zh-TW.json.d.ts +11 -0
  42. package/dist/style.css +1 -1
  43. package/dist/vendors/{version-3D9AaDf3.js → version-qi3OapTz.js} +1 -1
  44. package/package.json +2 -1
  45. package/dist/locale/context/LocaleContext.d.ts +0 -7
  46. /package/dist/Calendar/{timeUtils-CPYfw0pt.js → timeUtils-t4A3-Hr6.js} +0 -0
  47. /package/dist/components/Gantt/{msUntilNextDay.d.ts → utils/msUntilNextDay.d.ts} +0 -0
@@ -0,0 +1,683 @@
1
+ import { t as e } from "../Icon/Icon-CFvcrGGg.js";
2
+ import { r as t, t as n } from "../ConfigProvider/useLocale-CP8NRZoj.js";
3
+ import { createContext as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
4
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
5
+ //#region src/components/AMap/AMap.module.scss
6
+ var f = {
7
+ "bsy-mobile-amap": "_bsy-mobile-amap_1j885_1",
8
+ "bsy-mobile-amap__canvas": "_bsy-mobile-amap__canvas_1j885_6"
9
+ }, p = r(null), m = () => {
10
+ let e = a(p);
11
+ return e ? {
12
+ map: e.map,
13
+ ready: e.ready
14
+ } : {
15
+ map: null,
16
+ ready: !1
17
+ };
18
+ }, h = () => a(p), g = "script[src*=\"webapi.amap.com/maps\"]", _ = 15e3, v = 50, y = null, b = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Map(), S = () => typeof window < "u" && typeof window.AMap?.Map == "function", C = () => typeof document > "u" ? null : document.querySelector(g), w = (e, t) => new Promise((n, r) => {
19
+ if (e()) {
20
+ n();
21
+ return;
22
+ }
23
+ let i = Date.now(), a = window.setInterval(() => {
24
+ if (e()) {
25
+ window.clearInterval(a), n();
26
+ return;
27
+ }
28
+ Date.now() - i >= _ && (window.clearInterval(a), r(Error(t)));
29
+ }, v);
30
+ }), T = (e) => new Promise((t, n) => {
31
+ if (S()) {
32
+ t();
33
+ return;
34
+ }
35
+ e.addEventListener("load", () => {
36
+ w(S, "AMap script loaded but AMap.Map is missing").then(t, n);
37
+ }, { once: !0 }), e.addEventListener("error", () => n(/* @__PURE__ */ Error("AMap script failed to load")), { once: !0 }), w(S, "Timed out waiting for existing AMap script").then(t, n);
38
+ }), E = async ({ key: e, securityJsCode: t }) => {
39
+ if (!e) throw Error("AMap key is required when the maps script is not loaded");
40
+ t && !window._AMapSecurityConfig && (window._AMapSecurityConfig = { securityJsCode: t });
41
+ let { default: n } = await import("@amap/amap-jsapi-loader");
42
+ if (await n.load({
43
+ key: e,
44
+ version: "2.0",
45
+ plugins: []
46
+ }), !S()) throw Error("AMap loader finished but AMap.Map is missing");
47
+ }, D = (e = {}) => S() ? Promise.resolve(window.AMap) : y || (y = (async () => {
48
+ let t = C();
49
+ return t ? (await T(t), window.AMap) : (await E(e), window.AMap);
50
+ })().catch((e) => {
51
+ throw y = null, e;
52
+ }), y), O = (e) => {
53
+ if (e.every((e) => b.has(e))) return Promise.resolve();
54
+ let t = [...e].sort().join(","), n = x.get(t);
55
+ if (n) return n;
56
+ let r = new Promise((t, n) => {
57
+ let r = window.AMap;
58
+ if (typeof r?.plugin != "function") {
59
+ n(/* @__PURE__ */ Error("AMap.plugin is not available"));
60
+ return;
61
+ }
62
+ r.plugin(e, () => {
63
+ e.forEach((e) => b.add(e)), t();
64
+ });
65
+ }).finally(() => {
66
+ x.delete(t);
67
+ });
68
+ return x.set(t, r), r;
69
+ }, k = (...e) => e.filter(Boolean).join(" "), A = ({ mapKey: e, securityJsCode: n, zoom: r, center: i, className: a, children: m, onReady: h, onError: g }) => {
70
+ let _ = t(), v = c(null), y = c(null), [b, x] = l(null), S = c(h), C = c(g);
71
+ S.current = h, C.current = g;
72
+ let w = e ?? _?.key, T = n ?? _?.securityJsCode;
73
+ o(() => {
74
+ let e = v.current;
75
+ if (!e) return;
76
+ let t = !1;
77
+ return (async () => {
78
+ try {
79
+ let n = await D({
80
+ key: w,
81
+ securityJsCode: T
82
+ });
83
+ if (t || y.current || (await O(["AMap.Scale"]).catch((e) => {
84
+ console.warn("[AMap] failed to load Scale plugin", e);
85
+ }), t)) return;
86
+ let a = new n.Map(e, {
87
+ resizeEnable: !0,
88
+ animateEnable: !1,
89
+ zooms: [3, 20],
90
+ ...r === void 0 ? {} : { zoom: r },
91
+ ...i ? { center: i } : {}
92
+ });
93
+ typeof n.Scale == "function" && a.addControl(new n.Scale()), y.current = a, x(n), S.current?.(a);
94
+ } catch (e) {
95
+ t || C.current?.(e instanceof Error ? e : Error(String(e)));
96
+ }
97
+ })(), () => {
98
+ t = !0, y.current?.destroy?.(), y.current = null, x(null);
99
+ };
100
+ }, [
101
+ w,
102
+ T,
103
+ r,
104
+ i
105
+ ]);
106
+ let E = s(() => ({
107
+ map: y.current,
108
+ ready: b !== null,
109
+ AMapNS: b
110
+ }), [b]);
111
+ return /* @__PURE__ */ u(p.Provider, {
112
+ value: E,
113
+ children: /* @__PURE__ */ d("div", {
114
+ className: k(f["bsy-mobile-amap"], a),
115
+ children: [/* @__PURE__ */ u("div", {
116
+ ref: v,
117
+ className: f["bsy-mobile-amap__canvas"]
118
+ }), m]
119
+ })
120
+ });
121
+ }, j = { "bsy-mobile-amap__controls": "_bsy-mobile-amap__controls_8fnp9_1" }, M = ({ children: e, className: t }) => /* @__PURE__ */ u("div", {
122
+ className: k(j["bsy-mobile-amap__controls"], t),
123
+ children: e
124
+ }), N = {
125
+ small: 22,
126
+ middle: 34,
127
+ large: 46
128
+ }, P = {
129
+ paddingLeft: 4,
130
+ paddingRight: 10,
131
+ iconWidth: 22,
132
+ gap: 6,
133
+ digitWidth: 11
134
+ }, F = "Address", I = (e, t) => {
135
+ if (typeof e?.Pixel != "function") return null;
136
+ let n = N[t];
137
+ return new e.Pixel(-(n / 2), -(n / 2));
138
+ }, L = (e) => P.paddingLeft + P.iconWidth + P.gap + String(e ?? 0).length * P.digitWidth + P.paddingRight, R = (e) => typeof document < "u" && !!document.getElementById(`icon-${e}`), z = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;"), B = ({ color: e, labelText: t, iconType: n, iconSize: r, iconAvailable: i, highlightActive: a, highlightNonce: o, labelColor: s }) => {
139
+ let c = Math.max(6, Math.round(r * .36)), l = `map-marker-highlight-${o}`, u = i ? `<svg width="${r}" height="${r}" viewBox="0 0 1024 1024" style="color:${e};display:block;line-height:1;">
140
+ <use xlink:href="#icon-${n}"></use>
141
+ </svg>` : `<div style="
142
+ width:${r}px;
143
+ height:${r}px;
144
+ border-radius:${r}px ${r}px ${r}px 0;
145
+ transform:rotate(-45deg);
146
+ background:${e};
147
+ position:relative;
148
+ box-shadow:0 2px 6px rgba(0,0,0,0.2);
149
+ ">
150
+ <div style="
151
+ position:absolute;
152
+ width:${c}px;
153
+ height:${c}px;
154
+ border-radius:50%;
155
+ background:#fff;
156
+ top:50%;
157
+ left:50%;
158
+ transform:translate(-50%, -50%) rotate(45deg);
159
+ "></div>
160
+ </div>`, d = t ? `<div style="
161
+ position:absolute;
162
+ left:calc(100% + 8px);
163
+ top:50%;
164
+ transform:translateY(-50%);
165
+ height:34px;
166
+ display:inline-flex;
167
+ align-items:center;
168
+ padding:0 10px;
169
+ border-radius:4px;
170
+ max-width:200px;
171
+ overflow:hidden;
172
+ box-shadow:0 0 16px rgba(0,0,0,0.1);
173
+ font-size:14px;
174
+ font-weight:400;
175
+ color:${s === "light" ? "#121111" : "#ffffff"};
176
+ background:${s === "light" ? "#ffffff" : "#121111"};
177
+ "><span style="
178
+ overflow:hidden;
179
+ white-space:nowrap;
180
+ text-overflow:ellipsis;
181
+ ">${z(t)}</span></div>` : "";
182
+ return `
183
+ <div style="
184
+ position:relative;
185
+ width:${r}px;
186
+ height:${r}px;
187
+ display:flex;
188
+ align-items:center;
189
+ justify-content:center;
190
+ overflow:visible;
191
+ cursor:pointer;
192
+ ">
193
+ ${a ? `<style>
194
+ @keyframes ${l} {
195
+ 0% { transform: scale(1); }
196
+ 28% { transform: scale(1.12); }
197
+ 55% { transform: scale(0.96); }
198
+ 100% { transform: scale(1); }
199
+ }
200
+ </style>` : ""}
201
+ <div style="
202
+ width:100%;
203
+ height:100%;
204
+ display:flex;
205
+ align-items:center;
206
+ justify-content:center;
207
+ transform-origin:center bottom;
208
+ animation:${a ? `${l} 1.4s cubic-bezier(0.25, 0.8, 0.25, 1) 1` : "none"};
209
+ ">
210
+ ${u}
211
+ </div>
212
+ ${d}
213
+ </div>
214
+ `;
215
+ }, V = (e) => `
216
+ <div style="
217
+ display:flex;
218
+ align-items:center;
219
+ justify-content:center;
220
+ gap:6px;
221
+ padding:5px 10px 5px 4px;
222
+ border-radius:100px;
223
+ background:#fff;
224
+ box-shadow:0 0 10px rgba(0,0,0,0.06);
225
+ max-width:200px;
226
+ overflow:hidden;
227
+ white-space:nowrap;
228
+ text-overflow:ellipsis;
229
+ pointer-events:none;
230
+ ">
231
+ <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
232
+ <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"/>
233
+ </svg>
234
+ <div style="
235
+ font-size:18px;
236
+ line-height:normal;
237
+ font-weight:700;
238
+ color:#030303;
239
+ overflow:hidden;
240
+ text-overflow:ellipsis;
241
+ white-space:nowrap;
242
+ ">${e}</div>
243
+ </div>
244
+ `, H = () => "\n <div style=\"\n position: relative;\n width: 30px;\n height: 30px;\n pointer-events: none;\n transform: translateZ(0);\n will-change: transform;\n \">\n <div style=\"position: absolute; inset: 0; pointer-events: none;\">\n <div style=\"\n position: absolute;\n top: 50%;\n left: 50%;\n width: 22px;\n height: 22px;\n margin: -11px 0 0 -11px;\n border-radius: 50%;\n background: rgba(2, 101, 255, 0.2);\n \"></div>\n <div style=\"\n position: absolute;\n top: 50%;\n left: 50%;\n width: 14px;\n height: 14px;\n margin: -7px 0 0 -7px;\n border-radius: 50%;\n background: #0265ff;\n animation: map-current-location-ripple 2.4s ease-out infinite;\n \"></div>\n </div>\n <div style=\"\n position: absolute;\n top: 50%;\n left: 50%;\n width: 24px;\n height: 24px;\n margin: -12px 0 0 -12px;\n border-radius: 50%;\n background: #fff;\n border: 1px solid rgba(2, 101, 255, 0.2);\n \"></div>\n <div style=\"\n position: absolute;\n top: 50%;\n left: 50%;\n width: 14px;\n height: 14px;\n margin: -7px 0 0 -7px;\n border-radius: 50%;\n background: #0265ff;\n \"></div>\n <style>\n @keyframes map-current-location-ripple {\n 0% { transform: scale(1); opacity: 0.38; }\n 100% { transform: scale(3); opacity: 0; }\n }\n </style>\n </div>\n", ee = { "bsy-mobile-amap__control-btn": "_bsy-mobile-amap__control-btn_wwc06_1" }, U = ({ onLocate: t, onError: r }) => {
245
+ let { t: a } = n(), o = h(), s = o?.map, l = o?.AMapNS, d = c(null), f = c(!1), p = c(null), m = i((e) => {
246
+ if (!s || !l) return;
247
+ d.current?.remove?.();
248
+ let t = new l.Marker({
249
+ position: e,
250
+ anchor: "center",
251
+ content: H()
252
+ });
253
+ s.add(t), d.current = t;
254
+ }, [l, s]), g = async () => {
255
+ if (!(!s || !l || f.current)) {
256
+ f.current = !0;
257
+ try {
258
+ await O(["AMap.Geolocation"]);
259
+ let e = await new Promise((e, t) => {
260
+ p.current ??= new l.Geolocation({
261
+ timeout: 1e4,
262
+ showButton: !1,
263
+ showMarker: !1,
264
+ showCircle: !1,
265
+ panToLocation: !1,
266
+ zoomToAccuracy: !1
267
+ }), p.current.getCurrentPosition((n, r) => {
268
+ if (n === "complete" && r.info === "SUCCESS") {
269
+ e([r.position.lng, r.position.lat]);
270
+ return;
271
+ }
272
+ t(Error(r?.message || a("amap.locate.failed")));
273
+ });
274
+ });
275
+ s.setZoomAndCenter(17, e), m(e), t?.(e);
276
+ } catch (e) {
277
+ r?.(e instanceof Error ? e : Error(String(e)));
278
+ } finally {
279
+ f.current = !1;
280
+ }
281
+ }
282
+ };
283
+ return /* @__PURE__ */ u("button", {
284
+ type: "button",
285
+ className: ee["bsy-mobile-amap__control-btn"],
286
+ "aria-label": a("amap.locate.ariaLabel"),
287
+ onClick: () => {
288
+ g();
289
+ },
290
+ children: /* @__PURE__ */ u(e, {
291
+ name: "Positioning",
292
+ size: 26,
293
+ color: "#121111"
294
+ })
295
+ });
296
+ }, W = [
297
+ 48,
298
+ 48,
299
+ 48,
300
+ 48
301
+ ], G = ({ AMap: e, map: t, points: n, singleMarkerZoom: r = 17, maxZoom: i, avoid: a = [...W] }) => {
302
+ if (!t || !Array.isArray(n) || n.length === 0) return !1;
303
+ if (n.length === 1) return t.setZoomAndCenter(r, [n[0].lng, n[0].lat]), !0;
304
+ let o = n.map((e) => e.lng), s = n.map((e) => e.lat), c = new e.LngLat(Math.min(...o), Math.min(...s)), l = new e.LngLat(Math.max(...o), Math.max(...s)), u = new e.Bounds(c, l), d = i === void 0 ? t.getFitZoomAndCenterByBounds(u, a) : t.getFitZoomAndCenterByBounds(u, a, i), [f, p] = Array.isArray(d) ? d : [];
305
+ return typeof f != "number" || !p ? !1 : (t.setZoomAndCenter(f, p), !0);
306
+ }, K = [], q = (e) => {
307
+ let t = e?.lnglat;
308
+ if (Array.isArray(t) && t.length >= 2) {
309
+ let [e, n] = t.map(Number);
310
+ if (Number.isFinite(e) && Number.isFinite(n)) return [e, n];
311
+ }
312
+ return t && Number.isFinite(t.lng) && Number.isFinite(t.lat) ? [Number(t.lng), Number(t.lat)] : null;
313
+ }, J = ({ items: e = K, cluster: t = !1, icon: n = F, size: r = "middle", labelColor: i = "dark", highlightId: a = null, fitView: l = !1, onClick: u, onDisplayChange: d }) => {
314
+ let f = h(), p = f?.map, m = !!f?.ready, g = f?.AMapNS, _ = c(/* @__PURE__ */ new Map()), v = c(null), y = c(u), b = c(d), x = c({
315
+ id: a,
316
+ nonce: 0
317
+ }), S = c("");
318
+ y.current = u, b.current = d, x.current.id !== a && (x.current = {
319
+ id: a,
320
+ nonce: x.current.nonce + 1
321
+ });
322
+ let C = N[r], w = R(n), T = s(() => e.map((e) => `${e.id}:${e.lng},${e.lat}`).join("|"), [e]), E = (e) => B({
323
+ color: e.color || "#0265ff",
324
+ labelText: e.label ?? null,
325
+ iconType: n,
326
+ iconSize: C,
327
+ iconAvailable: w,
328
+ highlightActive: x.current.id === e.id,
329
+ highlightNonce: x.current.nonce,
330
+ labelColor: i
331
+ });
332
+ return o(() => {
333
+ if (!m || !p || !g) return;
334
+ let n = () => {
335
+ _.current.forEach((e) => {
336
+ e?.off?.("click"), e?.remove?.();
337
+ }), _.current.clear();
338
+ }, i = () => {
339
+ v.current?.setMap?.(null), v.current = null;
340
+ };
341
+ if (!t) return i(), n(), e.forEach((e) => {
342
+ let t = new g.Marker({
343
+ position: [e.lng, e.lat],
344
+ offset: I(g, r),
345
+ content: E(e),
346
+ extData: e
347
+ });
348
+ t.on("click", () => y.current?.(e)), p.add(t), _.current.set(e.id, t), b.current?.({
349
+ type: "standalone",
350
+ id: e.id
351
+ });
352
+ }), () => {
353
+ n();
354
+ };
355
+ n();
356
+ let a = !1;
357
+ return (async () => {
358
+ await O(["AMap.MarkerCluster"]), !(a || !p) && (v.current || (v.current = new g.MarkerCluster(p, [], {
359
+ gridSize: 60,
360
+ averageCenter: !0,
361
+ renderMarker: (e) => {
362
+ let t = e.data?.[0]?.extData;
363
+ t && (e.marker.setExtData?.(t), e.marker.setOffset(I(g, r)), e.marker.setContent(E(t)), b.current?.({
364
+ type: "standalone",
365
+ id: t.id
366
+ }));
367
+ },
368
+ renderClusterMarker: (e) => {
369
+ let t = (e.clusterData ?? []).map((e) => e?.extData?.id).filter(Boolean);
370
+ t.length && b.current?.({
371
+ type: "clustered",
372
+ ids: t
373
+ }), e.marker.setOffset(new g.Pixel(-(L(e.count) / 2), -16)), e.marker.setContent(V(e.count));
374
+ }
375
+ }), v.current.on?.("click", (e) => {
376
+ let t = e?.clusterData || [];
377
+ if (t.length <= 1) {
378
+ let t = e?.marker?.getExtData?.();
379
+ t && y.current?.(t);
380
+ return;
381
+ }
382
+ G({
383
+ AMap: g,
384
+ map: p,
385
+ points: t.map((e) => q(e)).filter((e) => e !== null).map((e) => ({
386
+ lng: e[0],
387
+ lat: e[1]
388
+ })),
389
+ maxZoom: p.getZooms?.()?.[1] ?? 20
390
+ });
391
+ })), v.current?.setData(e.map((e) => ({
392
+ lnglat: [e.lng, e.lat],
393
+ weight: 1,
394
+ extData: e
395
+ }))));
396
+ })(), () => {
397
+ a = !0, i();
398
+ };
399
+ }, [
400
+ g,
401
+ t,
402
+ n,
403
+ w,
404
+ C,
405
+ e,
406
+ i,
407
+ p,
408
+ m,
409
+ r,
410
+ a
411
+ ]), o(() => {
412
+ if (!(!l || !m || !p || !g)) {
413
+ if (!T) {
414
+ S.current = "";
415
+ return;
416
+ }
417
+ S.current !== T && G({
418
+ AMap: g,
419
+ map: p,
420
+ points: e
421
+ }) && (S.current = T);
422
+ }
423
+ }, [
424
+ g,
425
+ l,
426
+ e,
427
+ p,
428
+ m,
429
+ T
430
+ ]), null;
431
+ }, te = (e) => {
432
+ if (!e) return null;
433
+ if (typeof e?.getLng == "function" && typeof e?.getLat == "function") return {
434
+ lng: e.getLng(),
435
+ lat: e.getLat()
436
+ };
437
+ if (Array.isArray(e) && e.length >= 2) {
438
+ let [t, n] = e;
439
+ if (Number.isFinite(t) && Number.isFinite(n)) return {
440
+ lng: t,
441
+ lat: n
442
+ };
443
+ }
444
+ return Number.isFinite(e?.lng) && Number.isFinite(e?.lat) ? {
445
+ lng: e.lng,
446
+ lat: e.lat
447
+ } : null;
448
+ }, ne = (e) => [e?.district, e?.address].filter(Boolean).join(""), re = (e) => [
449
+ e.id || "",
450
+ e.title || "",
451
+ e.lng ?? "",
452
+ e.lat ?? ""
453
+ ].join("|"), Y = (e = []) => (Array.isArray(e) ? e : []).map((e) => {
454
+ let t = te(e?.location);
455
+ return t ? {
456
+ id: e?.id || e?.uid || e?.name || e?.title || "",
457
+ title: e?.name || e?.title || "",
458
+ address: ne(e),
459
+ lng: t.lng,
460
+ lat: t.lat
461
+ } : null;
462
+ }).filter((e) => e !== null), ie = (...e) => {
463
+ let t = /* @__PURE__ */ new Set();
464
+ return e.flat().filter((e) => {
465
+ let n = re(e);
466
+ return t.has(n) ? !1 : (t.add(n), !0);
467
+ });
468
+ }, ae = ({ AMap: e, keyword: t }) => new Promise((n, r) => {
469
+ let i = e?.AutoComplete || e?.Autocomplete;
470
+ if (typeof i != "function") {
471
+ n([]);
472
+ return;
473
+ }
474
+ new i({ datatype: "poi" }).search(t, (e, t) => {
475
+ if (e !== "complete") {
476
+ r(t || /* @__PURE__ */ Error("autocomplete search failed"));
477
+ return;
478
+ }
479
+ n(Y(t?.tips));
480
+ });
481
+ }), oe = ({ AMap: e, keyword: t, pageSize: n }) => new Promise((r, i) => {
482
+ if (typeof e?.PlaceSearch != "function") {
483
+ r([]);
484
+ return;
485
+ }
486
+ new e.PlaceSearch({
487
+ citylimit: !1,
488
+ pageSize: n,
489
+ pageIndex: 1
490
+ }).search(t, (e, t) => {
491
+ if (e !== "complete") {
492
+ i(t || /* @__PURE__ */ Error("place search failed"));
493
+ return;
494
+ }
495
+ r(Y(t?.poiList?.pois));
496
+ });
497
+ }), se = async ({ AMap: e, keyword: t, pageSize: n }) => {
498
+ let r = `${t || ""}`.trim();
499
+ if (!r) return [];
500
+ await O(["AMap.PlaceSearch", "AMap.AutoComplete"]);
501
+ let i = await Promise.allSettled([ae({
502
+ AMap: e,
503
+ keyword: r
504
+ }), oe({
505
+ AMap: e,
506
+ keyword: r,
507
+ pageSize: n
508
+ })]), a = i.filter((e) => e.status === "fulfilled").map((e) => e.value);
509
+ if (!a.length) throw i[0]?.status === "rejected" ? i[0].reason : /* @__PURE__ */ Error("poi search failed");
510
+ return ie(...a).slice(0, n);
511
+ }, X = {
512
+ "bsy-mobile-amap__poi": "_bsy-mobile-amap__poi_138ca_1",
513
+ "bsy-mobile-amap__poi-box": "_bsy-mobile-amap__poi-box_138ca_9",
514
+ "bsy-mobile-amap__poi-input": "_bsy-mobile-amap__poi-input_138ca_27",
515
+ "bsy-mobile-amap__poi-clear": "_bsy-mobile-amap__poi-clear_138ca_42",
516
+ "bsy-mobile-amap__poi-dropdown": "_bsy-mobile-amap__poi-dropdown_138ca_51",
517
+ "bsy-mobile-amap__poi-dropdown--open": "_bsy-mobile-amap__poi-dropdown--open_138ca_59",
518
+ "bsy-mobile-amap__poi-dropdown--closing": "_bsy-mobile-amap__poi-dropdown--closing_138ca_65",
519
+ "bsy-mobile-amap__poi-dropdown-clip": "_bsy-mobile-amap__poi-dropdown-clip_138ca_71",
520
+ "bsy-mobile-amap__poi-panel": "_bsy-mobile-amap__poi-panel_138ca_75",
521
+ "bsy-mobile-amap__poi-list": "_bsy-mobile-amap__poi-list_138ca_83",
522
+ "bsy-mobile-amap__poi-option": "_bsy-mobile-amap__poi-option_138ca_88",
523
+ "bsy-mobile-amap__poi-option-body": "_bsy-mobile-amap__poi-option-body_138ca_103",
524
+ "bsy-mobile-amap__poi-title-wrap": "_bsy-mobile-amap__poi-title-wrap_138ca_110",
525
+ "bsy-mobile-amap__poi-title": "_bsy-mobile-amap__poi-title_138ca_110",
526
+ "bsy-mobile-amap__poi-address": "_bsy-mobile-amap__poi-address_138ca_126",
527
+ "bsy-mobile-amap__poi-highlight": "_bsy-mobile-amap__poi-highlight_138ca_136",
528
+ "bsy-mobile-amap__poi-status": "_bsy-mobile-amap__poi-status_138ca_139"
529
+ }, ce = 20, Z = 14, le = 240, ue = 250, Q = 246, de = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), fe = (e, t, n) => n ? `${e || ""}`.split(n).map((e, n) => e ? e.toLowerCase() === t.toLowerCase() ? /* @__PURE__ */ u("span", {
530
+ className: X["bsy-mobile-amap__poi-highlight"],
531
+ children: e
532
+ }, `${e}-${n}`) : /* @__PURE__ */ u("span", { children: e }, `${e}-${n}`) : null) : e, pe = ({ onSelect: t }) => {
533
+ let { t: r } = n(), a = h(), s = a?.map, f = a?.AMapNS, p = c(null), m = c(null), g = c(null), [_, v] = l(""), [y, b] = l(""), [x, S] = l([]), [C, w] = l(!1), [T, E] = l(!1), [D, O] = l("collapsed"), [A, j] = l(Q), M = c(null), N = c(null), P = c(null), F = c(0), I = c(!1), L = c("collapsed"), R = c(!0), z = i(() => {
534
+ g.current?.remove?.(), g.current = null;
535
+ }, []), B = i(() => {
536
+ N.current !== null && (window.clearTimeout(N.current), N.current = null), M.current !== null && (window.clearTimeout(M.current), M.current = null), L.current !== "expanded" && (O("collapsed"), L.current = "collapsed", N.current = window.setTimeout(() => {
537
+ R.current && (O("expanded"), L.current = "expanded", N.current = null);
538
+ }, 1));
539
+ }, []), V = i(() => {
540
+ L.current !== "collapsed" && (N.current !== null && (window.clearTimeout(N.current), N.current = null), O("closing"), L.current = "closing", M.current !== null && window.clearTimeout(M.current), M.current = window.setTimeout(() => {
541
+ O("collapsed"), b(""), S([]), L.current = "collapsed", M.current = null;
542
+ }, le));
543
+ }, []), H = i(() => {
544
+ N.current !== null && (window.clearTimeout(N.current), N.current = null), M.current !== null && (window.clearTimeout(M.current), M.current = null), O("collapsed"), b(""), S([]), w(!1), L.current = "collapsed";
545
+ }, []);
546
+ o(() => {
547
+ let e = p.current?.parentElement, t = () => {
548
+ let t = e?.getBoundingClientRect?.().height || 0;
549
+ if (!t) {
550
+ j(Q);
551
+ return;
552
+ }
553
+ j(Math.min(Math.max(t - 58, 0), Q));
554
+ };
555
+ if (t(), !e || typeof ResizeObserver != "function") return;
556
+ let n = new ResizeObserver(t);
557
+ return n.observe(e), () => n.disconnect();
558
+ }, []), o(() => {
559
+ if (P.current !== null && window.clearTimeout(P.current), I.current) {
560
+ I.current = !1;
561
+ return;
562
+ }
563
+ return P.current = window.setTimeout(() => {
564
+ let e = _.trim();
565
+ if (!e) {
566
+ F.current += 1, w(!1), z(), V();
567
+ return;
568
+ }
569
+ if (!f) return;
570
+ let t = F.current + 1;
571
+ F.current = t, b(e), w(!0), se({
572
+ AMap: f,
573
+ keyword: e,
574
+ pageSize: ce
575
+ }).then((e) => {
576
+ !R.current || F.current !== t || (S(e), B());
577
+ }).catch((e) => {
578
+ !R.current || F.current !== t || (console.warn("[AMap] POI search failed", e), S([]), B());
579
+ }).finally(() => {
580
+ !R.current || F.current !== t || w(!1);
581
+ });
582
+ }, ue), () => {
583
+ P.current !== null && (window.clearTimeout(P.current), P.current = null);
584
+ };
585
+ }, [
586
+ f,
587
+ z,
588
+ V,
589
+ B,
590
+ _
591
+ ]), o(() => (R.current = !0, () => {
592
+ R.current = !1, P.current !== null && window.clearTimeout(P.current), N.current !== null && window.clearTimeout(N.current), M.current !== null && window.clearTimeout(M.current), z();
593
+ }), [z]);
594
+ let ee = (e) => {
595
+ let t = e.target.value;
596
+ t.trim() || z(), v(t);
597
+ }, U = () => {
598
+ P.current !== null && (window.clearTimeout(P.current), P.current = null), F.current += 1, z(), v(""), H(), m.current?.focus();
599
+ }, W = (e) => {
600
+ if (z(), I.current = !0, v(e.title || ""), typeof f?.Marker == "function" && s) {
601
+ let t = new f.Marker({ position: [e.lng, e.lat] });
602
+ s.add(t), g.current = t;
603
+ }
604
+ let n = typeof s?.getZoom == "function" ? s.getZoom() : Z;
605
+ typeof s?.setZoomAndCenter == "function" && s.setZoomAndCenter(Math.max(n || 0, Z), [e.lng, e.lat], !0), F.current += 1, w(!1), V(), t?.(e);
606
+ }, G = D === "expanded", K = D === "closing", q = !!_.trim() && T, J = y.trim() ? RegExp(`(${de(y)})`, "ig") : null;
607
+ return /* @__PURE__ */ d("div", {
608
+ ref: p,
609
+ className: X["bsy-mobile-amap__poi"],
610
+ "data-testid": "map-poi-search-panel",
611
+ children: [/* @__PURE__ */ d("div", {
612
+ className: X["bsy-mobile-amap__poi-box"],
613
+ children: [/* @__PURE__ */ u("input", {
614
+ ref: m,
615
+ className: X["bsy-mobile-amap__poi-input"],
616
+ value: _,
617
+ onChange: ee,
618
+ onFocus: () => E(!0),
619
+ onBlur: () => E(!1),
620
+ placeholder: r("amap.poi.placeholder"),
621
+ "data-testid": "map-poi-search-input"
622
+ }), q ? /* @__PURE__ */ u("button", {
623
+ type: "button",
624
+ className: X["bsy-mobile-amap__poi-clear"],
625
+ onMouseDown: (e) => e.preventDefault(),
626
+ onClick: U,
627
+ children: /* @__PURE__ */ u(e, {
628
+ name: "close",
629
+ size: 16,
630
+ color: "#666666"
631
+ })
632
+ }) : /* @__PURE__ */ u(e, {
633
+ name: "search",
634
+ size: 16,
635
+ color: "#666666"
636
+ })]
637
+ }), /* @__PURE__ */ u("div", {
638
+ className: k(X["bsy-mobile-amap__poi-dropdown"], G && X["bsy-mobile-amap__poi-dropdown--open"], K && X["bsy-mobile-amap__poi-dropdown--closing"]),
639
+ "data-panel-state": D,
640
+ children: /* @__PURE__ */ u("div", {
641
+ className: X["bsy-mobile-amap__poi-dropdown-clip"],
642
+ children: /* @__PURE__ */ u("div", {
643
+ className: X["bsy-mobile-amap__poi-panel"],
644
+ style: {
645
+ opacity: K ? 0 : 1,
646
+ transform: G ? "translateY(0)" : "translateY(12px)"
647
+ },
648
+ children: /* @__PURE__ */ u("div", {
649
+ className: X["bsy-mobile-amap__poi-list"],
650
+ style: { maxHeight: A },
651
+ children: x.length > 0 ? x.map((t) => /* @__PURE__ */ u("button", {
652
+ type: "button",
653
+ className: X["bsy-mobile-amap__poi-option"],
654
+ onClick: () => W(t),
655
+ children: /* @__PURE__ */ d("div", {
656
+ className: X["bsy-mobile-amap__poi-option-body"],
657
+ children: [/* @__PURE__ */ d("div", {
658
+ className: X["bsy-mobile-amap__poi-title-wrap"],
659
+ children: [/* @__PURE__ */ u(e, {
660
+ name: "Address",
661
+ size: 16
662
+ }), /* @__PURE__ */ u("div", {
663
+ className: X["bsy-mobile-amap__poi-title"],
664
+ children: fe(t.title, y, J)
665
+ })]
666
+ }), /* @__PURE__ */ u("div", {
667
+ className: X["bsy-mobile-amap__poi-address"],
668
+ children: fe(t.address, y, J)
669
+ })]
670
+ })
671
+ }, `${t.id}-${t.lng}-${t.lat}`)) : /* @__PURE__ */ u("div", {
672
+ className: X["bsy-mobile-amap__poi-status"],
673
+ children: r(C ? "amap.poi.loading" : "amap.poi.empty")
674
+ })
675
+ })
676
+ })
677
+ })
678
+ })]
679
+ });
680
+ }, $ = A;
681
+ $.Markers = J, $.PoiSearch = pe, $.Controls = M, $.Locate = U;
682
+ //#endregion
683
+ export { m as n, $ as t };
@@ -0,0 +1,5 @@
1
+ import "../vendors/version-qi3OapTz.js";
2
+ import "../Icon/Icon-CFvcrGGg.js";
3
+ import { n as e, t } from "./AMap-BWZ2lhXr.js";
4
+ import "../ConfigProvider/useLocale-CP8NRZoj.js";
5
+ export { t as default, e as useAMap };
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "../Icon/Icon-CFvcrGGg.js";
2
- import { t } from "../vendors/useLocale-CMHIlzlj.js";
2
+ import { t } from "../ConfigProvider/useLocale-CP8NRZoj.js";
3
3
  import { useEffect as n, useId as r, useLayoutEffect as i, useRef as a, useState as o } from "react";
4
4
  import { createPortal as s } from "react-dom";
5
5
  import { jsx as c, jsxs as l } from "react/jsx-runtime";