@baishuyun/ui-base 6.16.0 → 6.17.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 (140) hide show
  1. package/dist/Amap/Amap-CNsoge6e.js +826 -0
  2. package/dist/Amap/index.js +3 -10
  3. package/dist/Calendar/Calendar-BlsUX2vX.js +1608 -0
  4. package/dist/Calendar/index.js +10 -20
  5. package/dist/Card/index.js +2 -2
  6. package/dist/CheckBox/{CheckBox-B92dxWNo.js → CheckBox-CM24-quL.js} +1 -1
  7. package/dist/CheckBox/index.js +3 -3
  8. package/dist/ColorPicker/{ColorPicker-CPr5j6ZN.js → ColorPicker-B_wLqurt.js} +5 -5
  9. package/dist/ColorPicker/index.js +5 -5
  10. package/dist/ConfigProvider/index.js +1 -1
  11. package/dist/DatePicker/DatePicker-BRwPZeui.js +111 -0
  12. package/dist/DatePicker/{DatePickerPanel-CRnLvIwc.js → DatePickerPanel-UwjSXS-U.js} +3 -4
  13. package/dist/DatePicker/index.js +6 -8
  14. package/dist/DatePicker/pickerLocale-Brf7_Tnd.js +30 -0
  15. package/dist/DropDown/{DropDown-CvG9IFVk.js → DropDown-B_szM67V.js} +86 -82
  16. package/dist/DropDown/index.js +8 -9
  17. package/dist/Editor/index.js +2839 -880
  18. package/dist/Gantt/index.js +3055 -197
  19. package/dist/Icon/index.js +1 -1
  20. package/dist/InputTag/{InputTag-BfZycXw4.js → InputTag-C_5nm0eo.js} +2 -2
  21. package/dist/InputTag/index.js +4 -4
  22. package/dist/Loading/{Loading-DpbJSRYf.js → Loading-Cherk9Ax.js} +1 -1
  23. package/dist/Loading/index.js +3 -3
  24. package/dist/Modal/index.js +2 -2
  25. package/dist/NotFoundContent/index.js +2 -2
  26. package/dist/Overlay/index.js +1 -1
  27. package/dist/Radio/index.js +2 -2
  28. package/dist/ScrollBar/{ScrollBar-N2pOLv-8.js → ScrollBar-IMTuAOF5.js} +1 -1
  29. package/dist/ScrollBar/index.js +2 -2
  30. package/dist/Segmented/{Segmented-BCQRrc65.js → Segmented-DpmwFerw.js} +1 -1
  31. package/dist/Segmented/index.js +2 -2
  32. package/dist/Select/{Select-Bla1mQ8v.js → Select-VIy6OKEj.js} +262 -259
  33. package/dist/Select/{SelectInputSearch-CRgBcsq2.js → SelectInputSearch-MApQHnU9.js} +21 -10
  34. package/dist/Select/index.js +12 -13
  35. package/dist/Table/Table-8ac6xLZv.js +808 -0
  36. package/dist/Table/index.js +4 -8
  37. package/dist/Tabs/{Tabs-B9uCGlxM.js → Tabs-DnoZ8BO0.js} +3 -3
  38. package/dist/Tabs/index.js +4 -4
  39. package/dist/Tooltip/{Tooltip-nJU13gX4.js → Tooltip-DBrt3t2r.js} +3 -3
  40. package/dist/Tooltip/index.js +3 -3
  41. package/dist/Tree/index.js +4 -4
  42. package/dist/components/Editor/EditorHtmlPreview.d.ts +3 -0
  43. package/dist/components/Editor/Preview/HtmlPreview.d.ts +2 -3
  44. package/dist/components/Editor/__tests__/createTestEditor.d.ts +1 -0
  45. package/dist/components/Editor/constants/portableEditorStyles.d.ts +2 -0
  46. package/dist/components/Editor/hooks/useEditorFocus.d.ts +1 -0
  47. package/dist/components/Editor/hooks/useTextFormatsState.d.ts +1 -2
  48. package/dist/components/Editor/index.d.ts +1 -0
  49. package/dist/components/Editor/nodes/ExtendedLinkNode.d.ts +9 -0
  50. package/dist/components/Editor/utils/getToolbarItems.d.ts +14 -0
  51. package/dist/components/Editor/utils/placeProgrammaticCaret.d.ts +5 -0
  52. package/dist/components/Editor/utils/readTextFormats.d.ts +6 -0
  53. package/dist/components/Editor/utils/retainCodeSelection.d.ts +3 -0
  54. package/dist/components/Select/SelectInputSearch/SelectInputSearch.d.ts +2 -0
  55. package/dist/index.js +28 -50
  56. package/dist/style.css +1 -1
  57. package/dist/vendors/Tree-D0Q1IZ2D.js +267 -0
  58. package/dist/vendors/{version-CFii9VTt.js → version-CfjNx5v2.js} +1 -1
  59. package/package.json +1 -1
  60. package/dist/Amap/Amap-BLSziesG.js +0 -77
  61. package/dist/Amap/AmapCircle/index.js +0 -5
  62. package/dist/Amap/AmapCircle-2qupysHe.js +0 -55
  63. package/dist/Amap/AmapContext-CJBe6lld.js +0 -11
  64. package/dist/Amap/AmapMarker/index.js +0 -6
  65. package/dist/Amap/AmapMarker-xEqoVnFR.js +0 -153
  66. package/dist/Amap/AmapMarkerCluster/index.js +0 -6
  67. package/dist/Amap/AmapMarkerCluster-CvEQa3o9.js +0 -240
  68. package/dist/Amap/AmapProvider/index.js +0 -7
  69. package/dist/Amap/AmapProvider-B-R2DrkJ.js +0 -107
  70. package/dist/Amap/hooks/index.js +0 -4
  71. package/dist/Amap/hooks-BTcFpdd0.js +0 -121
  72. package/dist/Amap/useMarkerInfoWindowController-Cjx0xQXw.js +0 -94
  73. package/dist/Calendar/AllDaySection-pO7suGJM.js +0 -53
  74. package/dist/Calendar/Calendar-DUD4iffO.js +0 -795
  75. package/dist/Calendar/CurrentTimeIndicator-BF3_INSL.js +0 -65
  76. package/dist/Calendar/EventCard-DKEZQRTp.js +0 -155
  77. package/dist/Calendar/TimeAxis-DUc6EL-j.js +0 -13
  78. package/dist/Calendar/TimeGrid-BV8x9VnF.js +0 -47
  79. package/dist/Calendar/colorUtils-BbeSMnOs.js +0 -55
  80. package/dist/Calendar/context/index.js +0 -3
  81. package/dist/Calendar/context-CamSpkj3.js +0 -21
  82. package/dist/Calendar/layout-CpOabFQ2.js +0 -300
  83. package/dist/Calendar/subcomponents/AllDaySection/index.js +0 -11
  84. package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +0 -8
  85. package/dist/Calendar/subcomponents/EventCard/index.js +0 -9
  86. package/dist/Calendar/subcomponents/TimeAxis/index.js +0 -5
  87. package/dist/Calendar/subcomponents/TimeGrid/index.js +0 -7
  88. package/dist/Calendar/theme-Dc8hjcdo.js +0 -71
  89. package/dist/Calendar/utils/index.js +0 -111
  90. package/dist/Calendar/utils/layout/index.js +0 -4
  91. package/dist/Calendar/utils/theme/index.js +0 -3
  92. package/dist/DatePicker/DatePicker-BWMmI6rl.js +0 -101
  93. package/dist/DatePicker/ensureDayjsPlugins-CSqhjLS7.js +0 -15
  94. package/dist/DatePicker/pickerLocale-CcPLUbZO.js +0 -15
  95. package/dist/DatePicker/style/index.js +0 -3
  96. package/dist/DatePicker/style-W7f5wyUb.js +0 -15
  97. package/dist/DropDown/style/index.js +0 -3
  98. package/dist/DropDown/style-DZpkarne.js +0 -9
  99. package/dist/Editor/Buttons-vt3gwedu.js +0 -1841
  100. package/dist/Editor/ToolbarPlugin/Buttons/index.js +0 -21
  101. package/dist/Editor/constants/index.js +0 -61
  102. package/dist/Gantt/GanttChart/index.js +0 -21
  103. package/dist/Gantt/GanttChart-DRzJdEm-.js +0 -2292
  104. package/dist/Gantt/GanttHighlightContext-dtyoq-oj.js +0 -12
  105. package/dist/Gantt/GanttTable/index.js +0 -13
  106. package/dist/Gantt/GanttTable-fOv1Zn2-.js +0 -84
  107. package/dist/Gantt/GanttToolBar/index.js +0 -17
  108. package/dist/Gantt/GanttToolBar-4kxZP6oS.js +0 -120
  109. package/dist/Gantt/collapseKeys-BV_8sIA-.js +0 -160
  110. package/dist/Gantt/columnResize-Bkenlbab.js +0 -46
  111. package/dist/Gantt/constants-mEGQ1U1Q.js +0 -39
  112. package/dist/Gantt/highlightTarget-D3Nf9_7S.js +0 -25
  113. package/dist/Gantt/theme-B7Iap-tZ.js +0 -31
  114. package/dist/Gantt/timelineViewConfig-DNt7yi83.js +0 -118
  115. package/dist/Gantt/utils/index.js +0 -7
  116. package/dist/Gantt/utils/theme/index.js +0 -3
  117. package/dist/Select/style/index.js +0 -3
  118. package/dist/Select/style-C4A8kUd1.js +0 -9
  119. package/dist/Table/Table-3LSO0xSH.js +0 -545
  120. package/dist/Table/constants-D7wLH8Qy.js +0 -25
  121. package/dist/Table/hooks/index.js +0 -3
  122. package/dist/Table/hooks-DSBl2e4O.js +0 -108
  123. package/dist/Table/processRowspan-B6HMqw0Q.js +0 -144
  124. package/dist/Table/style/index.js +0 -3
  125. package/dist/Table/style-B8Cw8HJe.js +0 -9
  126. package/dist/Table/utils/index.js +0 -3
  127. package/dist/Tree/utils/index.js +0 -26
  128. package/dist/vendors/Tree-DSl4lDjx.js +0 -248
  129. /package/dist/Card/{Card-rJeWgxu5.js → Card-DAz0dvA3.js} +0 -0
  130. /package/dist/CheckBox/{CheckBox-DOK5N7z6.js → CheckBox-CcHskTz_.js} +0 -0
  131. /package/dist/Modal/{Modal-CRKitOOj.js → Modal-eZijJ7CB.js} +0 -0
  132. /package/dist/NotFoundContent/{NotFoundContent-BLmzWNBi.js → NotFoundContent-DJUQ0_2D.js} +0 -0
  133. /package/dist/Radio/{Radio-CX9cUqb7.js → Radio-D9jhW7K6.js} +0 -0
  134. /package/dist/vendors/{animations-Dn_5xJ7B.js → animations-ISccYUE3.js} +0 -0
  135. /package/dist/vendors/{cssVars-l4-kP_14.js → cssVars-UpriQzph.js} +0 -0
  136. /package/dist/vendors/{mergeRefs-TiJ0xjUN.js → mergeRefs-mEH9TBYV.js} +0 -0
  137. /package/dist/vendors/{useFloatingOverlay-B3M9k8nj.js → useFloatingOverlay-B66lOL8v.js} +0 -0
  138. /package/dist/vendors/{useFloatingPortal-VpzL-EPh.js → useFloatingPortal-DJ1iKmW-.js} +0 -0
  139. /package/dist/vendors/{useLatchedPopupPortalRoot-4fVhqVT4.js → useLatchedPopupPortalRoot-CC6af8t-.js} +0 -0
  140. /package/dist/vendors/{useLocale-D31qCCff.js → useLocale-Be4e7Xfn.js} +0 -0
@@ -0,0 +1,826 @@
1
+ import { n as e } from "../vendors/ConfigProvider-gZYvcwIQ.js";
2
+ import { Fragment as t, jsx as n } from "react/jsx-runtime";
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 { createRoot as u } from "react-dom/client";
5
+ import { flushSync as d } from "react-dom";
6
+ //#region src/components/Amap/context/AmapContext.ts
7
+ var f = r({
8
+ AMap: null,
9
+ status: "idle",
10
+ loading: !1,
11
+ error: null,
12
+ plugins: []
13
+ }), p = r(null), m = "2.0", h = "[ui-base] AMap has already been loaded with a different key, version, or securityJsCode.", g = null, _ = null, v = null, y = /* @__PURE__ */ new Map(), b = (e = []) => Array.from(new Set(e.filter(Boolean))), x = (e) => e || void 0, S = (e) => {
14
+ if (_ && (_.key !== e.key || _.version !== e.version || x(_.securityJsCode) !== x(e.securityJsCode))) throw Error(h);
15
+ }, C = (e) => {
16
+ b(e).forEach((e) => {
17
+ y.set(e, { status: "loaded" });
18
+ });
19
+ }, w = async (e, t) => {
20
+ let n = b(t).filter((e) => y.get(e)?.status !== "loaded");
21
+ await Promise.all(n.map((t) => {
22
+ let n = y.get(t);
23
+ if (n?.status === "loading" && n.promise) return n.promise;
24
+ let r = new Promise((n, r) => {
25
+ try {
26
+ e.plugin([t], () => {
27
+ y.set(t, { status: "loaded" }), n();
28
+ });
29
+ } catch (e) {
30
+ y.set(t, { status: "failed" }), r(e);
31
+ }
32
+ });
33
+ return y.set(t, {
34
+ status: "loading",
35
+ promise: r
36
+ }), r;
37
+ }));
38
+ }, T = async (e) => {
39
+ let t = e.version || m, n = b(e.plugins), r = {
40
+ key: e.key,
41
+ securityJsCode: x(e.securityJsCode),
42
+ version: t
43
+ };
44
+ if (!e.key) throw Error("[ui-base] AMap key is required.");
45
+ if (typeof window > "u") throw Error("[ui-base] AMap can only be loaded in the browser.");
46
+ if (window.AMap || (v = null, _ = null, g = null, y.clear()), S(r), r.securityJsCode && (window._AMapSecurityConfig = { securityJsCode: r.securityJsCode }), v || window.AMap) {
47
+ let e = v || window.AMap;
48
+ return v = e, _ = r, await w(e, n), e;
49
+ }
50
+ g ||= import("@amap/amap-jsapi-loader").then((r) => (r.default ?? r).load({
51
+ key: e.key,
52
+ version: t,
53
+ plugins: n
54
+ })).then((e) => (v = e, _ = r, window.AMap = e, C(n), e)).catch((e) => {
55
+ throw g = null, v = null, _ = null, y.clear(), e;
56
+ });
57
+ let i = await g;
58
+ return await w(i, n), i;
59
+ }, E = (e = []) => Array.from(new Set(e.filter(Boolean))), D = [], O = "", k = (e, t) => typeof e == "function" ? e(t) : e ?? null, A = (e) => e ? E(e.split(O)) : D;
60
+ function j(r) {
61
+ let i = e(), { amapKey: a, securityJsCode: s, version: c, plugins: u = D, fallback: d = null, errorFallback: p = null, children: m } = r, h = i.amap, g = [...h?.plugins || D, ...u].filter(Boolean).join(O), [_, v] = l({
62
+ AMap: null,
63
+ status: "idle",
64
+ loading: !1,
65
+ error: null,
66
+ plugins: A(g)
67
+ });
68
+ return o(() => {
69
+ let e = !1, t = A(g);
70
+ return v({
71
+ AMap: null,
72
+ status: "loading",
73
+ loading: !0,
74
+ error: null,
75
+ plugins: t
76
+ }), T({
77
+ key: a || h?.key || "",
78
+ securityJsCode: s ?? h?.securityJsCode,
79
+ version: c || h?.version,
80
+ plugins: t
81
+ }).then((n) => {
82
+ e || v({
83
+ AMap: n,
84
+ status: "success",
85
+ loading: !1,
86
+ error: null,
87
+ plugins: t
88
+ });
89
+ }).catch((n) => {
90
+ e || v({
91
+ AMap: null,
92
+ status: "error",
93
+ loading: !1,
94
+ error: n,
95
+ plugins: t
96
+ });
97
+ }), () => {
98
+ e = !0;
99
+ };
100
+ }, [
101
+ h?.key,
102
+ h?.securityJsCode,
103
+ h?.version,
104
+ a,
105
+ g,
106
+ s,
107
+ c
108
+ ]), _.loading ? /* @__PURE__ */ n(t, { children: d }) : _.error ? /* @__PURE__ */ n(t, { children: k(p, _.error) }) : _.status === "success" ? /* @__PURE__ */ n(f.Provider, {
109
+ value: _,
110
+ children: m
111
+ }) : null;
112
+ }
113
+ //#endregion
114
+ //#region src/components/Amap/Amap.tsx
115
+ function M(e) {
116
+ let { center: t, zoom: r, options: i = {}, className: s, style: u, children: d, onReady: m, onError: h } = e, { AMap: g, loading: _, error: v } = a(f), y = c(null), b = c(null), x = c({
117
+ center: t,
118
+ zoom: r,
119
+ options: i,
120
+ onReady: m,
121
+ onError: h
122
+ }), [S, C] = l(!1);
123
+ x.current = {
124
+ center: t,
125
+ zoom: r,
126
+ options: i,
127
+ onReady: m,
128
+ onError: h
129
+ }, o(() => {
130
+ if (!g || !y.current || b.current) return;
131
+ let e = x.current, t = !1, n = new g.Map(y.current, {
132
+ resizeEnable: !0,
133
+ animateEnable: !1,
134
+ zooms: [3, 20],
135
+ ...e.options,
136
+ ...e.center ? { center: e.center } : {},
137
+ ...e.zoom !== null && e.zoom !== void 0 ? { zoom: e.zoom } : {}
138
+ });
139
+ b.current = n;
140
+ let r = () => {
141
+ t || (C(!0), x.current.onReady?.({
142
+ AMap: g,
143
+ map: n
144
+ }));
145
+ };
146
+ try {
147
+ n.on("complete", r);
148
+ } catch (e) {
149
+ x.current.onError?.(e);
150
+ }
151
+ return () => {
152
+ t = !0;
153
+ try {
154
+ n.off?.("complete", r);
155
+ } finally {
156
+ n.destroy?.(), b.current = null, C(!1);
157
+ }
158
+ };
159
+ }, [g]), o(() => {
160
+ b.current && t && b.current.setCenter?.(t);
161
+ }, [t]), o(() => {
162
+ b.current && r != null && b.current.setZoom?.(r);
163
+ }, [r]);
164
+ let w = g && b.current ? {
165
+ AMap: g,
166
+ map: b.current,
167
+ jsApiReady: !0,
168
+ mapReady: S,
169
+ loading: _,
170
+ error: v
171
+ } : null;
172
+ return /* @__PURE__ */ n("div", {
173
+ className: s,
174
+ ref: y,
175
+ style: {
176
+ width: "100%",
177
+ height: "100%",
178
+ ...u
179
+ },
180
+ children: w && S ? /* @__PURE__ */ n(p.Provider, {
181
+ value: w,
182
+ children: d
183
+ }) : null
184
+ });
185
+ }
186
+ //#endregion
187
+ //#region src/components/Amap/hooks/useAmap.ts
188
+ var N = () => {
189
+ let e = a(p);
190
+ if (!e) throw Error("[ui-base] useAmap must be used within Amap.");
191
+ return e;
192
+ }, ee = (e) => !Array.isArray(e) || e.length !== 2 ? !1 : Number.isFinite(Number(e[0])) && Number.isFinite(Number(e[1])), P = (e, t) => {
193
+ let n = [Number(e), Number(t)];
194
+ return ee(n) ? n : null;
195
+ }, F = (e, t) => {
196
+ let n = t?.info ? String(t.info).toLowerCase() : "";
197
+ return e === "complete" || n === "ok";
198
+ }, I = (e, t, n) => new Promise((r, i) => {
199
+ let a = window.setTimeout(() => {
200
+ i(Error(n));
201
+ }, t);
202
+ e.then((e) => {
203
+ window.clearTimeout(a), r(e);
204
+ }).catch((e) => {
205
+ window.clearTimeout(a), i(e);
206
+ });
207
+ }), te = (e) => new Promise((t, n) => {
208
+ if (!navigator.geolocation?.getCurrentPosition) {
209
+ n(/* @__PURE__ */ Error("[ui-base] Browser geolocation is unavailable."));
210
+ return;
211
+ }
212
+ navigator.geolocation.getCurrentPosition(t, n, {
213
+ enableHighAccuracy: !1,
214
+ timeout: e,
215
+ maximumAge: 0
216
+ });
217
+ }), ne = (e, t, n) => I(new Promise((n, r) => {
218
+ if (!e?.convertFrom) {
219
+ r(/* @__PURE__ */ Error("[ui-base] AMap.convertFrom is unavailable."));
220
+ return;
221
+ }
222
+ e.convertFrom(t, "gps", (e, t) => {
223
+ if (!F(e, t)) {
224
+ r(/* @__PURE__ */ Error("[ui-base] Failed to convert browser geolocation."));
225
+ return;
226
+ }
227
+ let i = t?.locations?.[0], a = P(i?.lng, i?.lat);
228
+ if (!a) {
229
+ r(/* @__PURE__ */ Error("[ui-base] Converted geolocation is invalid."));
230
+ return;
231
+ }
232
+ n(a);
233
+ });
234
+ }), n, "[ui-base] AMap.convertFrom timed out."), re = (e, t) => I(new Promise((t, n) => {
235
+ if (typeof e?.Geolocation != "function" || typeof e?.DistrictSearch != "function") {
236
+ n(/* @__PURE__ */ Error("[ui-base] AMap city location plugins are unavailable."));
237
+ return;
238
+ }
239
+ let { Geolocation: r, DistrictSearch: i } = e;
240
+ new r().getCityInfo((e, r) => {
241
+ if (!F(e, r) || !r?.adcode) {
242
+ n(/* @__PURE__ */ Error("[ui-base] Failed to resolve current city."));
243
+ return;
244
+ }
245
+ new i({
246
+ subdistrict: 0,
247
+ extensions: "base",
248
+ level: "district"
249
+ }).search(String(r.adcode), (e, r) => {
250
+ if (!F(e, r)) {
251
+ n(/* @__PURE__ */ Error("[ui-base] Failed to resolve current city center."));
252
+ return;
253
+ }
254
+ let i = r?.districtList?.[0]?.center, a = P(i?.lng, i?.lat);
255
+ if (!a) {
256
+ n(/* @__PURE__ */ Error("[ui-base] Current city center is invalid."));
257
+ return;
258
+ }
259
+ t(a);
260
+ });
261
+ });
262
+ }), t, "[ui-base] AMap city location timed out."), ie = [116.4074, 39.9042], ae = 3e3, oe = (e = {}) => {
263
+ let { AMap: t } = a(f), n = s(() => t, [t]), r = e.defaultLocation?.[0], u = e.defaultLocation?.[1], d = s(() => P(r, u) || ie, [r, u]), p = e.fallbackToCity ?? !0, m = e.timeout ?? ae, h = c(0), g = c(!0), [_, v] = l(d), [y, b] = l(!1), [x, S] = l(null);
264
+ o(() => (g.current = !0, () => {
265
+ g.current = !1;
266
+ }), []), o(() => {
267
+ v(d);
268
+ }, [d]);
269
+ let C = i(async () => {
270
+ let e = h.current + 1;
271
+ if (h.current = e, !n) {
272
+ let e = /* @__PURE__ */ Error("[ui-base] AMap is unavailable.");
273
+ return g.current && (b(!1), S(e), v(d)), d;
274
+ }
275
+ g.current && b(!0);
276
+ let t = null, r = d;
277
+ try {
278
+ let e = await te(m), i = P(e.coords.longitude, e.coords.latitude);
279
+ if (!i) throw Error("[ui-base] Browser geolocation is invalid.");
280
+ r = await ne(n, i, m), t = null;
281
+ } catch (e) {
282
+ if (t = e, p) try {
283
+ r = await re(n, m), t = null;
284
+ } catch (e) {
285
+ t = e, r = d;
286
+ }
287
+ }
288
+ return g.current && h.current === e && (v(r), S(t), b(!1)), r;
289
+ }, [
290
+ n,
291
+ d,
292
+ p,
293
+ m
294
+ ]);
295
+ return o(() => {
296
+ C();
297
+ }, [C]), {
298
+ location: _,
299
+ loading: y,
300
+ error: x,
301
+ refresh: C
302
+ };
303
+ };
304
+ //#endregion
305
+ //#region src/components/Amap/AmapCircle/AmapCircle.tsx
306
+ function se(e) {
307
+ let { AMap: t, map: n, mapReady: r } = N(), { center: i, radius: a, options: s = {}, visible: l = !0, onMouseEnter: u, onMouseLeave: d } = e, f = c(null), p = a > 0, m = c({
308
+ center: i,
309
+ radius: a,
310
+ options: s
311
+ });
312
+ return m.current = {
313
+ center: i,
314
+ radius: a,
315
+ options: s
316
+ }, o(() => {
317
+ if (!t || !n || !r || f.current || !p) return;
318
+ let e = m.current, i = new t.Circle({
319
+ ...e.options,
320
+ center: e.center,
321
+ radius: e.radius
322
+ });
323
+ return n.add(i), f.current = i, () => {
324
+ i.setMap?.(null), f.current = null;
325
+ };
326
+ }, [
327
+ t,
328
+ p,
329
+ n,
330
+ r
331
+ ]), o(() => {
332
+ f.current?.setCenter(i);
333
+ }, [i]), o(() => {
334
+ a > 0 && f.current?.setRadius(a);
335
+ }, [a]), o(() => {
336
+ let e = f.current;
337
+ e && (l ? e.show?.() : e.hide?.());
338
+ }, [l]), o(() => {
339
+ let e = f.current;
340
+ if (!e) return;
341
+ let r = () => ({
342
+ circle: e,
343
+ AMap: t,
344
+ map: n
345
+ }), i = () => u?.(r()), a = () => d?.(r());
346
+ return e.on("mouseover", i), e.on("mouseout", a), () => {
347
+ e.off("mouseover", i), e.off("mouseout", a);
348
+ };
349
+ }, [
350
+ t,
351
+ n,
352
+ u,
353
+ d
354
+ ]), null;
355
+ }
356
+ //#endregion
357
+ //#region src/components/Amap/utils/constants.ts
358
+ var L = "bottom-center", R = (e) => {
359
+ queueMicrotask(() => e.unmount());
360
+ }, z = "bottom-center", B = 250, V = (e, t) => Array.isArray(t) && typeof e.Pixel == "function" ? new e.Pixel(t[0], t[1]) : t, H = (e) => e.options?.offset !== void 0 && e.options?.offset !== null, U = ({ AMap: e, map: r, mapReady: a }) => {
361
+ let s = c(null), l = c(null), f = c(null), p = c(null), m = c(!1), h = c({
362
+ openDelay: null,
363
+ openFrame: null,
364
+ closeDelay: null
365
+ }), g = c(!1), _ = i(() => {
366
+ h.current.openDelay !== null && (window.clearTimeout(h.current.openDelay), h.current.openDelay = null), h.current.openFrame !== null && (window.cancelAnimationFrame(h.current.openFrame), h.current.openFrame = null);
367
+ }, []), v = i(() => {
368
+ h.current.closeDelay !== null && (window.clearTimeout(h.current.closeDelay), h.current.closeDelay = null);
369
+ }, []), y = i(() => {
370
+ _(), v(), p.current = null, g.current = !1, s.current?.close?.();
371
+ }, [v, _]), b = i(() => {
372
+ y(), f.current && (f.current.onmouseenter = null, f.current.onmouseleave = null), l.current && R(l.current), l.current = null, f.current = null, s.current = null, m.current = !1;
373
+ }, [y]), x = i(() => {
374
+ _(), v(), h.current.closeDelay = window.setTimeout(() => {
375
+ h.current.closeDelay = null, !g.current && y();
376
+ }, B);
377
+ }, [
378
+ v,
379
+ _,
380
+ y
381
+ ]), S = i((t) => {
382
+ if (!t || !e || !r || !a) return null;
383
+ let n = H(t);
384
+ if (m.current && !n && s.current && f.current && l.current && b(), s.current && f.current && l.current) return {
385
+ infoWindow: s.current,
386
+ contentElement: f.current,
387
+ contentRoot: l.current
388
+ };
389
+ let i = document.createElement("div"), o = {
390
+ ...t.options,
391
+ autoMove: !1,
392
+ isCustom: !0,
393
+ anchor: z
394
+ };
395
+ n && (o.offset = V(e, t.options?.offset));
396
+ let c = new e.InfoWindow(o), d = u(i);
397
+ return i.onmouseenter = () => {
398
+ g.current = !0, v();
399
+ }, i.onmouseleave = () => {
400
+ g.current = !1, x();
401
+ }, s.current = c, f.current = i, l.current = d, m.current = n, {
402
+ infoWindow: c,
403
+ contentElement: i,
404
+ contentRoot: d
405
+ };
406
+ }, [
407
+ e,
408
+ v,
409
+ r,
410
+ a,
411
+ b,
412
+ x
413
+ ]), C = i((i, o) => {
414
+ !i || !o || !e || !r || !a || (p.current = i, v(), _(), h.current.openDelay = window.setTimeout(() => {
415
+ h.current.openDelay = null;
416
+ let a = S(o);
417
+ if (!a || p.current !== i) return;
418
+ let { infoWindow: s, contentElement: c, contentRoot: l } = a, u = H(o);
419
+ if (s.setAnchor?.(z), u) {
420
+ let t = V(e, o.options?.offset);
421
+ s.setOffset?.(t);
422
+ }
423
+ d(() => {
424
+ l.render(/* @__PURE__ */ n(t, { children: o.content }));
425
+ }), s.setContent?.(c), h.current.openFrame = window.requestAnimationFrame(() => {
426
+ h.current.openFrame = null, p.current === i && s.open?.(r, i.getPosition?.());
427
+ });
428
+ }, B));
429
+ }, [
430
+ e,
431
+ v,
432
+ _,
433
+ S,
434
+ r,
435
+ a
436
+ ]);
437
+ return o(() => () => {
438
+ y(), f.current && (f.current.onmouseenter = null, f.current.onmouseleave = null), l.current && R(l.current), l.current = null, f.current = null, s.current = null, m.current = !1;
439
+ }, [y]), {
440
+ scheduleInfoWindowOpen: C,
441
+ scheduleInfoWindowClose: x,
442
+ closeInfoWindow: y
443
+ };
444
+ }, ce = ({ AMap: e, map: t, mapReady: n, markerRef: r, infoWindow: a }) => {
445
+ let { scheduleInfoWindowOpen: s, scheduleInfoWindowClose: c, closeInfoWindow: l } = U({
446
+ AMap: e,
447
+ map: t,
448
+ mapReady: n
449
+ }), u = i(() => {
450
+ if (!a) return;
451
+ let e = r.current;
452
+ e && s(e, a);
453
+ }, [
454
+ a,
455
+ r,
456
+ s
457
+ ]);
458
+ return o(() => {
459
+ if (a) return () => {
460
+ l();
461
+ };
462
+ }, [l, a]), {
463
+ scheduleInfoWindowOpen: u,
464
+ scheduleInfoWindowClose: c,
465
+ closeInfoWindow: l
466
+ };
467
+ }, W = (e) => typeof e == "string" || typeof e == "number", G = (e) => e != null && typeof e != "boolean", K = (e) => G(e) && !W(e), q = (e) => {
468
+ queueMicrotask(() => e.unmount());
469
+ };
470
+ function le(e) {
471
+ let { AMap: r, map: i, mapReady: a } = N(), { content: s, infoWindow: l, options: d = {}, onClick: f, onMouseEnter: p, onMouseLeave: m } = e, h = !!l, g = c(null), _ = c(null), v = c(null), y = c(!0), b = c(!0), x = c({
472
+ content: s,
473
+ infoWindow: l,
474
+ options: d
475
+ });
476
+ x.current = {
477
+ content: s,
478
+ infoWindow: l,
479
+ options: d
480
+ };
481
+ let { scheduleInfoWindowOpen: S, scheduleInfoWindowClose: C, closeInfoWindow: w } = ce({
482
+ AMap: r,
483
+ map: i,
484
+ mapReady: a,
485
+ markerRef: g,
486
+ infoWindow: l
487
+ });
488
+ return o(() => {
489
+ if (!r || !i || !a || g.current) return;
490
+ let e = x.current, o = {
491
+ anchor: L,
492
+ ...e.options,
493
+ map: i
494
+ };
495
+ if (W(e.content)) {
496
+ let t = document.createElement("div");
497
+ t.textContent = String(e.content), v.current = t, o.content = t;
498
+ } else if (K(e.content)) {
499
+ let e = document.createElement("div");
500
+ v.current = e, o.content = e;
501
+ }
502
+ let s = new r.Marker(o);
503
+ if (g.current = s, K(e.content) && v.current) {
504
+ let r = u(v.current);
505
+ _.current = r, r.render(/* @__PURE__ */ n(t, { children: e.content }));
506
+ }
507
+ return () => {
508
+ let e = _.current;
509
+ e && q(e), _.current = null, v.current = null, w(), s.setMap(null), g.current = null;
510
+ };
511
+ }, [
512
+ r,
513
+ w,
514
+ i,
515
+ a
516
+ ]), o(() => {
517
+ let e = d.position;
518
+ if (!e) return;
519
+ let t = g.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;
520
+ n === i && r === a || g.current?.setPosition(e);
521
+ }, [d.position]), o(() => {
522
+ if (b.current) {
523
+ b.current = !1;
524
+ return;
525
+ }
526
+ let e = g.current;
527
+ e && (d.visible === !1 ? e.hide?.() : d.visible === !0 && e.show?.());
528
+ }, [d.visible]), o(() => {
529
+ if (y.current) {
530
+ y.current = !1;
531
+ return;
532
+ }
533
+ let e = g.current;
534
+ if (e) {
535
+ if (!G(s)) {
536
+ _.current && q(_.current), _.current = null, v.current = null, e.setContent?.("");
537
+ return;
538
+ }
539
+ if (W(s)) {
540
+ if (_.current) {
541
+ let t = _.current;
542
+ q(t), _.current = null, v.current = document.createElement("div"), e.setContent?.(v.current);
543
+ }
544
+ v.current || (v.current = document.createElement("div"), e.setContent?.(v.current)), v.current.textContent = String(s);
545
+ return;
546
+ }
547
+ v.current || (v.current = document.createElement("div"), e.setContent?.(v.current)), _.current ||= u(v.current), _.current.render(/* @__PURE__ */ n(t, { children: s }));
548
+ }
549
+ }, [s]), o(() => {
550
+ let e = g.current;
551
+ if (!e) return;
552
+ let t = () => ({
553
+ marker: e,
554
+ AMap: r,
555
+ map: i
556
+ }), n = [];
557
+ if (f) {
558
+ let r = () => {
559
+ f?.(t());
560
+ };
561
+ e.on("click", r), n.push(() => e.off("click", r));
562
+ }
563
+ if (p || h) {
564
+ let r = () => {
565
+ h && S(), p?.(t());
566
+ };
567
+ e.on("mouseover", r), n.push(() => e.off("mouseover", r));
568
+ }
569
+ if (m || h) {
570
+ let r = () => {
571
+ h && C(), m?.(t());
572
+ };
573
+ e.on("mouseout", r), n.push(() => e.off("mouseout", r));
574
+ }
575
+ return () => {
576
+ n.forEach((e) => e());
577
+ };
578
+ }, [
579
+ r,
580
+ h,
581
+ i,
582
+ f,
583
+ p,
584
+ m,
585
+ C,
586
+ S
587
+ ]), null;
588
+ }
589
+ //#endregion
590
+ //#region src/components/Amap/AmapMarkerCluster/utils.ts
591
+ var ue = "[ui-base] AmapMarkerCluster requires AMap.MarkerCluster plugin. Please add \"AMap.MarkerCluster\" to AmapProvider plugins.", de = {}, J = /* @__PURE__ */ new WeakMap(), Y = 0, fe = (e) => Array.isArray(e) && e.length === 2 && Number.isFinite(e[0]) && Number.isFinite(e[1]), X = (e) => Array.isArray(e) ? e : [], pe = (e) => e?.extData, me = (e) => {
592
+ let t = { ...e };
593
+ return delete t.renderMarker, delete t.renderClusterMarker, t;
594
+ }, he = (e) => J.get(e) || (Y += 1, J.set(e, Y), Y), Z = (e) => e === void 0 ? "empty" : typeof e == "string" ? `string:${e}` : `element:${he(e)}`, ge = (e) => e.map((e) => [
595
+ e.key,
596
+ he(e.marker),
597
+ Z(e.content)
598
+ ].join(":")).join("|"), _e = (e) => e.map((e) => e.key).join("|"), ve = () => "\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", ye = (e) => `
599
+ <div
600
+ class="bsy-amap-marker-cluster__cluster"
601
+ 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;"
602
+ >
603
+ <svg
604
+ xmlns="http://www.w3.org/2000/svg"
605
+ class="bsy-amap-marker-cluster__cluster-icon"
606
+ data-testid="map-cluster-marker-icon"
607
+ aria-hidden="true"
608
+ width="22"
609
+ height="22"
610
+ viewBox="0 0 22 22"
611
+ fill="none"
612
+ style="flex: none; width: 22px; height: 22px;"
613
+ >
614
+ <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"/>
615
+ </svg>
616
+ <span
617
+ class="bsy-amap-marker-cluster__cluster-count"
618
+ style="color: #121111; font-family: Arial, sans-serif; font-size: 18px; font-weight: 700; line-height: 1.4;"
619
+ >${e}</span>
620
+ </div>
621
+ `, be = (e, t, n = Z(t)) => {
622
+ t === void 0 || e.__bsyAmapMarkerClusterContentSignature === n || (e.setContent?.(t), e.__bsyAmapMarkerClusterContentSignature = n);
623
+ }, Q = (e) => {
624
+ e.setAnchor?.(L);
625
+ }, xe = (e, t, n) => {
626
+ let r = n ?? [0, 0];
627
+ if (Array.isArray(r) && typeof e.Pixel == "function") {
628
+ t.setOffset?.(new e.Pixel(r[0], r[1]));
629
+ return;
630
+ }
631
+ t.setOffset?.(r);
632
+ }, $ = (e) => {
633
+ let t = e.__bsyAmapMarkerClusterRuntime;
634
+ if (!t) return;
635
+ let { handleClick: n, handleMouseEnter: r, handleMouseLeave: i, key: a } = t;
636
+ return n && e.off?.("click", n), r && e.off?.("mouseover", r), i && e.off?.("mouseout", i), e.__bsyAmapMarkerClusterRuntime = null, a;
637
+ };
638
+ //#endregion
639
+ //#region src/components/Amap/AmapMarkerCluster/AmapMarkerCluster.tsx
640
+ function Se(e) {
641
+ let { AMap: t, map: n, mapReady: r } = N(), { data: a, getKey: l, getPosition: u, renderMarker: d, renderCluster: f, clusterOptions: p = de, markerOffset: m, onError: h } = e, { scheduleInfoWindowOpen: g, scheduleInfoWindowClose: _, closeInfoWindow: v } = U({
642
+ AMap: t,
643
+ map: n,
644
+ mapReady: r
645
+ }), y = c(null), b = c(/* @__PURE__ */ new Set()), x = c(/* @__PURE__ */ new Map()), S = c(null), C = c(""), w = c(""), T = c(e), E = c([]), D = c(!0);
646
+ T.current = e, o(() => {
647
+ e.markerInfoWindow || v();
648
+ }, [v, e.markerInfoWindow]);
649
+ let O = s(() => {
650
+ let e = [];
651
+ return a.forEach((t, n) => {
652
+ let r = u(t);
653
+ fe(r) && e.push({
654
+ lnglat: r,
655
+ extData: {
656
+ item: t,
657
+ index: n,
658
+ key: l(t)
659
+ }
660
+ });
661
+ }), { validItems: e };
662
+ }, [
663
+ a,
664
+ l,
665
+ u
666
+ ]);
667
+ E.current = O.validItems;
668
+ let k = i((e) => {
669
+ let t = T.current, n = _e(e), r = ge(e);
670
+ n !== C.current && (C.current = n, t.onVisibleItemsChange?.(e.map((e) => e.item))), r !== w.current && (w.current = r, t.onMarkerRuntimeChange?.(e));
671
+ }, []), A = i(() => {
672
+ C.current = "", w.current = "";
673
+ let e = T.current;
674
+ e.onVisibleItemsChange?.([]), e.onMarkerRuntimeChange?.([]);
675
+ }, []), j = i(() => {
676
+ !T.current.onVisibleItemsChange && !T.current.onMarkerRuntimeChange || (S.current && clearTimeout(S.current), S.current = setTimeout(() => {
677
+ S.current = null, k(Array.from(x.current.values()));
678
+ }, 0));
679
+ }, [k]), M = i(() => {
680
+ x.current.clear(), j();
681
+ }, [j]);
682
+ return o(() => {
683
+ if (!t || !n || !r) return;
684
+ let e = t.MarkerCluster || t.MarkerClusterer, i = x.current;
685
+ if (!e) {
686
+ h?.(Error(ue));
687
+ return;
688
+ }
689
+ let a = () => {
690
+ b.current.forEach((e) => $(e)), b.current.clear(), v();
691
+ }, o = (e) => {
692
+ let t = $(e);
693
+ t && (i.delete(t), j(), v());
694
+ }, s = (e, r) => {
695
+ let i = e, a = pe(r);
696
+ if (!a) return;
697
+ let o = () => ({
698
+ item: a.item,
699
+ marker: e,
700
+ AMap: t,
701
+ map: n
702
+ });
703
+ if (T.current.onMarkerMouseEnter || T.current.markerInfoWindow) {
704
+ let t = () => {
705
+ let t = T.current, n = t.markerInfoWindow?.({
706
+ item: a.item,
707
+ index: a.index
708
+ });
709
+ n && g(e, n), t.onMarkerMouseEnter?.(o());
710
+ };
711
+ e.on?.("mouseover", t), i.__bsyAmapMarkerClusterRuntime = {
712
+ ...i.__bsyAmapMarkerClusterRuntime,
713
+ handleMouseEnter: t
714
+ };
715
+ }
716
+ if (T.current.onMarkerMouseLeave || T.current.markerInfoWindow) {
717
+ let t = () => {
718
+ let e = T.current;
719
+ e.markerInfoWindow && _(), e.onMarkerMouseLeave?.(o());
720
+ };
721
+ e.on?.("mouseout", t), i.__bsyAmapMarkerClusterRuntime = {
722
+ ...i.__bsyAmapMarkerClusterRuntime,
723
+ handleMouseLeave: t
724
+ };
725
+ }
726
+ }, c = (e) => {
727
+ let r = T.current;
728
+ if (r.autoFitOnClusterClick === !1 || e.length === 0) return;
729
+ let i = e.map((e) => r.getPosition(e)).filter(fe);
730
+ if (i.length === 1) {
731
+ n.setZoomAndCenter?.(r.fitOptions?.singlePointZoom ?? n.getZoom?.() ?? 16, i[0]);
732
+ return;
733
+ }
734
+ let a = i.map((e) => new t.Marker({ position: e }));
735
+ n.setFitView?.(a, !1, r.fitOptions?.padding, r.fitOptions?.maxZoom), a.forEach((e) => e.setMap?.(null));
736
+ }, l = me(p);
737
+ l.renderMarker = (e) => {
738
+ let n = X(e.data)[0], r = T.current;
739
+ if (e.marker) {
740
+ let a = e.marker;
741
+ if (o(a), b.current.add(a), a.__bsyAmapMarkerClusterRuntime = {}, s(e.marker, n), n) {
742
+ let o = r.renderMarker ? r.renderMarker({
743
+ item: n.extData.item,
744
+ index: n.extData.index
745
+ }) : ve(), s = r.renderMarker ? Z(o) : "default-marker";
746
+ Q(a), be(a, o, s), xe(t, a, r.markerOffset), a.__bsyAmapMarkerClusterRuntime = {
747
+ ...a.__bsyAmapMarkerClusterRuntime,
748
+ key: n.extData.key
749
+ }, i.set(n.extData.key, {
750
+ item: n.extData.item,
751
+ index: n.extData.index,
752
+ key: n.extData.key,
753
+ marker: e.marker,
754
+ content: o
755
+ }), j();
756
+ }
757
+ }
758
+ }, l.renderClusterMarker = (e) => {
759
+ let t = T.current, n = X(e.data).map((e) => e.extData?.item).filter(Boolean);
760
+ if (e.marker) {
761
+ let r = e.marker;
762
+ o(r), b.current.add(r), r.__bsyAmapMarkerClusterRuntime = {};
763
+ let i = e.count ?? n.length, a = t.renderCluster ? t.renderCluster({
764
+ count: i,
765
+ items: n
766
+ }) : ye(i), s = t.renderCluster ? Z(a) : `default-cluster:${i}`;
767
+ Q(r), be(r, a, s);
768
+ }
769
+ };
770
+ let u = new e(n, E.current, l);
771
+ y.current = u, D.current = !0;
772
+ let d = (e) => {
773
+ let r = e?.marker || e?.target, i = X(e?.clusterData || e?.data).map((e) => e.extData?.item).filter(Boolean);
774
+ if (!r || i.length === 0) return;
775
+ if (i.length === 1) {
776
+ T.current.onMarkerClick?.({
777
+ item: i[0],
778
+ marker: r,
779
+ AMap: t,
780
+ map: n
781
+ });
782
+ return;
783
+ }
784
+ c(i);
785
+ let a = {
786
+ items: i,
787
+ marker: r,
788
+ AMap: t,
789
+ map: n
790
+ };
791
+ T.current.onClusterClick?.(a);
792
+ };
793
+ return u.on?.("click", d), () => {
794
+ S.current &&= (clearTimeout(S.current), null), u.off?.("click", d), a(), i.clear(), A(), u.clearMarkers?.(), u.setMap?.(null), y.current = null;
795
+ };
796
+ }, [
797
+ t,
798
+ p,
799
+ v,
800
+ k,
801
+ n,
802
+ r,
803
+ h,
804
+ j,
805
+ A,
806
+ _,
807
+ g
808
+ ]), o(() => {
809
+ if (y.current) {
810
+ if (D.current) {
811
+ D.current = !1;
812
+ return;
813
+ }
814
+ b.current.forEach((e) => $(e)), b.current.clear(), v(), M(), y.current.setData?.(O.validItems);
815
+ }
816
+ }, [
817
+ M,
818
+ v,
819
+ m,
820
+ O.validItems,
821
+ f,
822
+ d
823
+ ]), null;
824
+ }
825
+ //#endregion
826
+ export { N as a, oe as i, le as n, M as o, se as r, j as s, Se as t };