@brightlocal/ui-components 2.14.0 → 2.16.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.
package/dist/map.js CHANGED
@@ -1,256 +1,687 @@
1
- import { jsx as l, jsxs as m } from "react/jsx-runtime";
2
- import * as s from "react";
3
- import { AlertCircle as v } from "@brightlocal/icons";
4
- import { Button as u } from "@brightlocal/ui-components/button";
5
- import { Card as h, CardContent as x } from "@brightlocal/ui-components/card";
6
- import { cn as p } from "@brightlocal/ui-components/lib/utils";
7
- import { Popover as y, PopoverAnchor as N, PopoverContent as M } from "@brightlocal/ui-components/popover";
8
- const B = {
1
+ import { jsx as c, jsxs as y } from "react/jsx-runtime";
2
+ import * as u from "react";
3
+ import { cva as K } from "class-variance-authority";
4
+ import { RefreshCw as U, TriangleAlert as W, Store as Y } from "@brightlocal/icons";
5
+ import { GlobeyFixingFault as Z, MapBackground as q } from "@brightlocal/illustrations";
6
+ import { Button as T } from "@brightlocal/ui-components/button";
7
+ import { Card as H, CardContent as J } from "@brightlocal/ui-components/card";
8
+ import { cn as g } from "@brightlocal/ui-components/lib/utils";
9
+ import { Popover as Q, PopoverAnchor as X, PopoverContent as ee } from "@brightlocal/ui-components/popover";
10
+ const Se = {
9
11
  /** Default road map view */
10
12
  ROADMAP: "roadmap",
11
- /** Satellite imagery */
13
+ /** @deprecated Satellite imagery — prefer cloud-based map styling via Map ID */
12
14
  SATELLITE: "satellite"
13
- }, w = {
14
- primary: "var(--primary)",
15
- secondary: "var(--secondary)",
16
- destructive: "var(--destructive)",
17
- outline: "var(--muted)",
18
- warning: "var(--warning-background)"
19
- }, g = s.forwardRef(
15
+ }, te = ["water", "landscape", "road", "poi", "transit"];
16
+ function re(e, t) {
17
+ return [
18
+ ...te.map((a) => ({
19
+ featureType: a,
20
+ elementType: "geometry",
21
+ stylers: [{ saturation: e, lightness: t }]
22
+ })),
23
+ {
24
+ elementType: "labels.text.fill",
25
+ stylers: [{ saturation: e, lightness: t - 10 }]
26
+ },
27
+ {
28
+ elementType: "labels.icon",
29
+ stylers: [{ saturation: e, lightness: t }]
30
+ }
31
+ ];
32
+ }
33
+ const $ = [
34
+ { elementType: "geometry", stylers: [{ color: "#444444" }] },
35
+ { elementType: "labels.text.fill", stylers: [{ color: "#aaaaaa" }] },
36
+ { elementType: "labels.text.stroke", stylers: [{ color: "#323232" }] },
37
+ {
38
+ featureType: "water",
39
+ elementType: "geometry",
40
+ stylers: [{ color: "#30405a" }]
41
+ },
42
+ {
43
+ featureType: "landscape",
44
+ elementType: "geometry",
45
+ stylers: [{ color: "#4b4b4b" }]
46
+ },
47
+ {
48
+ featureType: "road",
49
+ elementType: "geometry",
50
+ stylers: [{ color: "#5c5c5c" }]
51
+ },
52
+ {
53
+ featureType: "road",
54
+ elementType: "geometry.stroke",
55
+ stylers: [{ color: "#3e3e3e" }]
56
+ },
57
+ {
58
+ featureType: "poi",
59
+ elementType: "geometry",
60
+ stylers: [{ color: "#525252" }]
61
+ },
62
+ {
63
+ featureType: "transit",
64
+ elementType: "geometry",
65
+ stylers: [{ color: "#505050" }]
66
+ },
67
+ { elementType: "labels.icon", stylers: [{ visibility: "off" }] }
68
+ ], ae = {
69
+ default: { light: [], dark: $ },
70
+ muted: { light: re(-40, 20), dark: $ }
71
+ }, w = /* @__PURE__ */ new Set();
72
+ let M = typeof document < "u" && document.body.classList.contains("dark"), S = !1;
73
+ function oe() {
74
+ if (S || typeof document > "u") return;
75
+ S = !0, new MutationObserver(() => {
76
+ const t = document.body.classList.contains("dark");
77
+ if (t !== M) {
78
+ M = t;
79
+ for (const a of w) a();
80
+ }
81
+ }).observe(document.body, {
82
+ attributes: !0,
83
+ attributeFilter: ["class"]
84
+ });
85
+ }
86
+ function ne(e) {
87
+ return w.add(e), oe(), () => {
88
+ w.delete(e);
89
+ };
90
+ }
91
+ function se() {
92
+ return M;
93
+ }
94
+ function le() {
95
+ return !1;
96
+ }
97
+ function E() {
98
+ return u.useSyncExternalStore(
99
+ ne,
100
+ se,
101
+ le
102
+ );
103
+ }
104
+ function Te(e = "default") {
105
+ const t = E();
106
+ return ae[e][t ? "dark" : "light"];
107
+ }
108
+ const R = {
109
+ primary: "strong",
110
+ secondary: "moderate",
111
+ warning: "moderate",
112
+ destructive: "unranked",
113
+ outline: "unranked"
114
+ };
115
+ function ie(e) {
116
+ return e in R;
117
+ }
118
+ function ce(e) {
119
+ return ie(e) ? R[e] : e;
120
+ }
121
+ const x = {
122
+ strong: {
123
+ className: "bg-primary dark:bg-green-400",
124
+ cssVar: "--ds-tailwind-colors-green-400",
125
+ fallback: "#2ae855"
126
+ },
127
+ moderate: {
128
+ className: "bg-chart-4",
129
+ cssVar: "--ds-tailwind-colors-yellow-400",
130
+ fallback: "#facc15"
131
+ },
132
+ weak: {
133
+ className: "bg-orange-400",
134
+ cssVar: "--ds-tailwind-colors-orange-400",
135
+ fallback: "#fb923c"
136
+ },
137
+ unranked: {
138
+ className: "bg-red-600",
139
+ cssVar: "--ds-tailwind-colors-red-600",
140
+ fallback: "#dc2626"
141
+ },
142
+ error: {
143
+ className: "bg-warning-background dark:bg-orange-200",
144
+ cssVar: "--ds-tailwind-colors-orange-200",
145
+ fallback: "#fed7aa"
146
+ }
147
+ }, h = Object.fromEntries(
148
+ Object.entries(x).map(([e, t]) => [e, t.className])
149
+ ), de = K(
150
+ "inline-flex items-center justify-center rounded-full font-sans text-sm font-semibold text-foreground dark:text-neutral-900 border-2 border-white shadow-sm transition-shadow duration-200 ease-out hover:shadow-md",
151
+ {
152
+ variants: {
153
+ variant: {
154
+ strong: `${h.strong}`,
155
+ moderate: `${h.moderate}`,
156
+ weak: `${h.weak}`,
157
+ unranked: `${h.unranked} text-white dark:text-white`,
158
+ error: `${h.error}`
159
+ }
160
+ },
161
+ defaultVariants: {
162
+ variant: "strong"
163
+ }
164
+ }
165
+ ), O = u.forwardRef(
20
166
  ({
21
- value: t,
22
- variant: r = "primary",
23
- pulse: a = !1,
24
- dataHook: o,
25
- className: n,
26
- trackingEl: e,
167
+ value: e,
168
+ variant: t = "strong",
169
+ loading: a = !1,
170
+ pulse: s,
171
+ // eslint-disable-line @typescript-eslint/no-unused-vars -- absorbed from ...props to prevent DOM passthrough
172
+ dataHook: n,
173
+ className: o,
174
+ trackingEl: r,
27
175
  trackingLabel: i,
176
+ style: l,
28
177
  ...d
29
- }, c) => /* @__PURE__ */ l(
30
- u,
178
+ }, f) => {
179
+ const m = ce(t);
180
+ return /* @__PURE__ */ c(
181
+ "div",
182
+ {
183
+ ref: f,
184
+ className: g(
185
+ a ? "border-border bg-accent rounded-full border" : de({ variant: m }),
186
+ "size-8 p-0",
187
+ o
188
+ ),
189
+ "data-hook": n,
190
+ "data-slot": "map-grid-pin",
191
+ "data-state": a ? "loading" : void 0,
192
+ "data-tracking-el": r || "map-grid-pin",
193
+ "data-tracking-label": i,
194
+ style: l,
195
+ ...d,
196
+ children: m === "error" && !a ? /* @__PURE__ */ c(
197
+ W,
198
+ {
199
+ "aria-hidden": "true",
200
+ className: "text-warning-foreground",
201
+ size: 14
202
+ }
203
+ ) : String(e)
204
+ }
205
+ );
206
+ }
207
+ );
208
+ O.displayName = "MapGridPin";
209
+ function j() {
210
+ const t = {
211
+ colors: Object.fromEntries(
212
+ Object.entries(x).map(([s, n]) => [s, n.fallback])
213
+ ),
214
+ fontFamily: "Inter, system-ui, sans-serif",
215
+ textColor: "#111412"
216
+ };
217
+ if (typeof document > "u") return t;
218
+ const a = getComputedStyle(document.documentElement);
219
+ return {
220
+ colors: Object.fromEntries(
221
+ Object.entries(x).map(([s, { cssVar: n, fallback: o }]) => [
222
+ s,
223
+ a.getPropertyValue(n).trim() || o
224
+ ])
225
+ ),
226
+ fontFamily: a.getPropertyValue("--ds-font-font-sans").trim() || t.fontFamily,
227
+ textColor: a.getPropertyValue("--ds-tailwind-colors-neutral-950").trim() || t.textColor
228
+ };
229
+ }
230
+ function Ee() {
231
+ return j().colors;
232
+ }
233
+ const Re = Object.fromEntries(
234
+ Object.entries(x).map(([e, t]) => [e, t.fallback])
235
+ ), N = [
236
+ "strong",
237
+ "moderate",
238
+ "weak",
239
+ "unranked",
240
+ "error"
241
+ ];
242
+ function L(e, t) {
243
+ const { colors: a, fontFamily: s, textColor: n } = j(), o = 40, r = o / 2, i = 2, l = r - i, d = l * 0.55, m = [...e].sort(
244
+ (p, b) => N.indexOf(p.variant) - N.indexOf(b.variant)
245
+ ).filter((p) => p.count > 0), I = m.reduce((p, b) => p + b.count, 0) || 1, V = Math.max(Number(t) || 0, 1);
246
+ let k;
247
+ const C = m[0];
248
+ if (m.length <= 1) {
249
+ const p = C ? a[C.variant] : "#e5e7eb";
250
+ k = `<circle cx="${r}" cy="${r}" r="${l}" fill="${p}"/>`;
251
+ } else {
252
+ k = "";
253
+ let p = -Math.PI / 2;
254
+ for (const b of m) {
255
+ const P = b.count / I * Math.PI * 2, v = p + P, F = r + l * Math.cos(p), _ = r + l * Math.sin(p), z = r + l * Math.cos(v), B = r + l * Math.sin(v), G = P > Math.PI ? 1 : 0;
256
+ k += `<path d="M${r},${r}L${F.toFixed(2)},${_.toFixed(2)}A${l},${l} 0 ${G} 1 ${z.toFixed(2)},${B.toFixed(2)}Z" fill="${a[b.variant]}"/>`, p = v;
257
+ }
258
+ }
259
+ const D = Math.round(o * 0.3);
260
+ return [
261
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${o}" viewBox="0 0 ${o} ${o}" style="filter:drop-shadow(0 1px 2px rgba(0,0,0,.15))">`,
262
+ `<circle cx="${r}" cy="${r}" r="${r}" fill="white"/>`,
263
+ k,
264
+ `<circle cx="${r}" cy="${r}" r="${l}" fill="none" stroke="white" stroke-width="${i}"/>`,
265
+ `<circle cx="${r}" cy="${r}" r="${d}" fill="white"/>`,
266
+ `<text x="${r}" y="${r}" text-anchor="middle" dominant-baseline="central" font-family="${s}" font-size="${D}" font-weight="600" fill="${n}">${V}</text>`,
267
+ "</svg>"
268
+ ].join("");
269
+ }
270
+ function Oe(e) {
271
+ if (typeof DOMParser > "u")
272
+ throw new Error(
273
+ "createClusterPinElement requires a browser environment (DOMParser). Use createClusterPinSvg for SSR."
274
+ );
275
+ const { markers: t, count: a, getVariant: s } = e, n = /* @__PURE__ */ new Map();
276
+ for (const f of t) {
277
+ const m = s(f);
278
+ n.set(m, (n.get(m) ?? 0) + 1);
279
+ }
280
+ const o = [];
281
+ for (const f of N) {
282
+ const m = n.get(f);
283
+ m && o.push({ variant: f, count: m });
284
+ }
285
+ const r = L(o, a), d = new DOMParser().parseFromString(r, "image/svg+xml").documentElement;
286
+ if (!(d instanceof SVGElement))
287
+ throw new Error("createClusterPinElement: failed to parse SVG");
288
+ return d;
289
+ }
290
+ const me = u.forwardRef(
291
+ ({
292
+ segments: e,
293
+ count: t,
294
+ dataHook: a,
295
+ className: s,
296
+ trackingEl: n,
297
+ trackingLabel: o,
298
+ ...r
299
+ }, i) => {
300
+ const l = JSON.stringify(e), d = u.useMemo(
301
+ () => L(e, t),
302
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- serialised key for stable comparison
303
+ [l, t]
304
+ );
305
+ return /* @__PURE__ */ c(
306
+ "div",
307
+ {
308
+ dangerouslySetInnerHTML: { __html: d },
309
+ ref: i,
310
+ className: g("inline-flex items-center justify-center", s),
311
+ "data-hook": a,
312
+ "data-slot": "map-cluster-pin",
313
+ "data-tracking-el": n || "map-cluster-pin",
314
+ "data-tracking-label": o,
315
+ ...r
316
+ }
317
+ );
318
+ }
319
+ );
320
+ me.displayName = "MapClusterPin";
321
+ const ue = u.forwardRef(
322
+ ({
323
+ icon: e,
324
+ animateIn: t = !1,
325
+ value: a,
326
+ variant: s,
327
+ pulse: n,
328
+ dataHook: o,
329
+ className: r,
330
+ trackingEl: i,
331
+ trackingLabel: l,
332
+ ariaLabel: d,
333
+ ...f
334
+ }, m) => a !== void 0 || s !== void 0 || n !== void 0 ? /* @__PURE__ */ c(
335
+ O,
31
336
  {
32
- ref: c,
33
- className: p(
34
- "size-8 p-0",
35
- a && "animate-grid-pin-pulse transition-none motion-reduce:animate-none",
36
- n
37
- ),
337
+ ref: m,
338
+ className: r,
38
339
  dataHook: o,
39
- size: "sm",
40
- style: a ? {
41
- "--grid-pin-pulse-color": w[r]
42
- } : void 0,
43
- trackingEl: e || "map-grid-pin",
44
- trackingLabel: i,
45
- variant: r,
46
- ...d,
47
- children: String(t)
340
+ pulse: n,
341
+ trackingEl: i,
342
+ trackingLabel: l,
343
+ value: a ?? 1,
344
+ variant: s,
345
+ ...f
48
346
  }
49
- )
50
- );
51
- g.displayName = "MapGridPin";
52
- const k = s.forwardRef(
53
- ({ value: t = 1, dataHook: r, ...a }, o) => /* @__PURE__ */ l(g, { ref: o, dataHook: r, value: t, ...a })
54
- );
55
- k.displayName = "MapLocationPin";
56
- const P = s.forwardRef(
57
- ({ className: t, dataHook: r, trackingEl: a, trackingLabel: o, children: n, ...e }, i) => /* @__PURE__ */ l(
58
- u,
347
+ ) : /* @__PURE__ */ c(
348
+ "div",
59
349
  {
60
- ref: i,
61
- className: p("rounded-lg shadow-sm", t),
62
- "data-slot": "map-control-button",
63
- dataHook: r,
64
- trackingEl: a || "map-control-button",
65
- trackingLabel: o,
66
- variant: "outline",
67
- ...e,
68
- children: n
350
+ ref: m,
351
+ "aria-label": d ?? "Location",
352
+ className: g(
353
+ "relative inline-flex h-[46px] w-[38px] items-start justify-center",
354
+ r
355
+ ),
356
+ "data-hook": o,
357
+ "data-slot": "map-location-pin",
358
+ "data-tracking-el": i || "map-location-pin",
359
+ "data-tracking-label": l,
360
+ role: "img",
361
+ ...f,
362
+ children: /* @__PURE__ */ y(
363
+ "span",
364
+ {
365
+ "aria-hidden": "true",
366
+ className: g(
367
+ "relative flex size-full",
368
+ t && "animate-pop-in origin-bottom will-change-transform motion-reduce:animate-none"
369
+ ),
370
+ children: [
371
+ /* @__PURE__ */ y(
372
+ "svg",
373
+ {
374
+ "aria-hidden": "true",
375
+ className: "size-full overflow-visible drop-shadow-sm",
376
+ fill: "none",
377
+ viewBox: "0 0 38 46",
378
+ children: [
379
+ /* @__PURE__ */ c(
380
+ "path",
381
+ {
382
+ className: "fill-white",
383
+ d: "M38 19.15C38 29.21 29.4 35.77 20.38 44.63C19.61 45.39 18.37 45.41 17.58 44.67C8.01 35.79 0 29.23 0 19.15C0 8.57 8.51 0 19 0C29.49 0 38 8.57 38 19.15Z"
384
+ }
385
+ ),
386
+ /* @__PURE__ */ c("circle", { className: "fill-sky-500", cx: "19", cy: "19", r: "16" })
387
+ ]
388
+ }
389
+ ),
390
+ /* @__PURE__ */ c("span", { className: "absolute top-[19px] left-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center text-white", children: e ?? /* @__PURE__ */ c(Y, { size: 16 }) })
391
+ ]
392
+ }
393
+ )
69
394
  }
70
395
  )
71
396
  );
72
- P.displayName = "MapControlButton";
73
- const b = s.forwardRef(
397
+ ue.displayName = "MapLocationPin";
398
+ const fe = u.forwardRef(
74
399
  ({
75
- className: t,
76
- message: r = "Loading map…",
400
+ className: e,
401
+ dataHook: t,
402
+ trackingEl: a,
403
+ trackingLabel: s,
404
+ children: n,
405
+ iconOnly: o = !0,
406
+ ...r
407
+ }, i) => {
408
+ const l = E();
409
+ return /* @__PURE__ */ c(
410
+ T,
411
+ {
412
+ ref: i,
413
+ className: e,
414
+ "data-slot": "map-control-button",
415
+ dataHook: t,
416
+ iconOnly: o,
417
+ trackingEl: a || "map-control-button",
418
+ trackingLabel: s,
419
+ variant: l ? "secondary" : "outline",
420
+ ...r,
421
+ children: n
422
+ }
423
+ );
424
+ }
425
+ );
426
+ fe.displayName = "MapControlButton";
427
+ const pe = u.forwardRef(
428
+ ({
429
+ className: e,
430
+ children: t,
77
431
  dataHook: a,
78
- trackingEl: o,
432
+ trackingEl: s,
79
433
  trackingLabel: n,
80
- ...e
81
- }, i) => /* @__PURE__ */ m(
434
+ ariaLabel: o,
435
+ ...r
436
+ }, i) => /* @__PURE__ */ y(
82
437
  "div",
83
438
  {
84
439
  ref: i,
85
- "aria-live": "polite",
86
- className: p(
87
- "text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",
88
- t
440
+ "aria-label": o ?? "Loading map",
441
+ className: g(
442
+ "border-border relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg border",
443
+ e
89
444
  ),
90
445
  "data-hook": a,
91
446
  "data-slot": "map-loading-state",
92
- "data-tracking-el": o || "map-loading-state",
447
+ "data-tracking-el": s || "map-loading-state",
93
448
  "data-tracking-label": n,
94
449
  role: "status",
95
- ...e,
450
+ ...r,
96
451
  children: [
97
- /* @__PURE__ */ l(
98
- "div",
99
- {
100
- "aria-hidden": "true",
101
- className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent"
102
- }
103
- ),
104
- r
452
+ /* @__PURE__ */ c(A, {}),
453
+ t && /* @__PURE__ */ c("div", { className: "relative", children: t })
105
454
  ]
106
455
  }
107
456
  )
108
457
  );
109
- b.displayName = "MapLoadingState";
110
- const C = s.forwardRef(
458
+ pe.displayName = "MapLoadingState";
459
+ const A = u.memo(function({
460
+ rounded: t
461
+ }) {
462
+ return /* @__PURE__ */ c(
463
+ q,
464
+ {
465
+ "aria-hidden": "true",
466
+ className: g(
467
+ "absolute inset-0 h-full w-full object-cover",
468
+ t && "rounded-[inherit]"
469
+ ),
470
+ mode: "auto"
471
+ }
472
+ );
473
+ }), ge = u.forwardRef(
111
474
  ({
112
- className: t,
113
- title: r = "Unable to load map",
114
- message: a = "Something went wrong while loading the map. Please try again.",
115
- onRetry: o,
116
- dataHook: n,
117
- trackingEl: e,
118
- trackingLabel: i,
475
+ className: e,
476
+ title: t = "We couldn't load your map rankings.",
477
+ message: a = "Reloading usually fixes it, and it won't use any credits",
478
+ onRetry: s,
479
+ retryLoading: n = !1,
480
+ retryLabel: o = "Reload",
481
+ dataHook: r,
482
+ trackingEl: i,
483
+ trackingLabel: l,
119
484
  ...d
120
- }, c) => /* @__PURE__ */ m(
485
+ }, f) => /* @__PURE__ */ y(
121
486
  "div",
122
487
  {
123
- ref: c,
124
- className: p(
125
- "bg-muted/50 flex flex-col items-center justify-center gap-3 rounded-xl p-8 text-center",
126
- t
488
+ ref: f,
489
+ className: g(
490
+ "border-border relative flex h-full w-full flex-col items-center justify-center gap-4 rounded-lg border p-4 text-center sm:gap-6 sm:p-8",
491
+ e
127
492
  ),
128
- "data-hook": n,
493
+ "data-hook": r,
129
494
  "data-slot": "map-error-state",
130
- "data-tracking-el": e || "map-error-state",
131
- "data-tracking-label": i,
495
+ "data-tracking-el": i || "map-error-state",
496
+ "data-tracking-label": l,
132
497
  role: "alert",
133
498
  ...d,
134
499
  children: [
135
- /* @__PURE__ */ l(
136
- v,
137
- {
138
- "aria-hidden": "true",
139
- className: "text-muted-foreground/60",
140
- size: 40,
141
- strokeWidth: 1.5
142
- }
143
- ),
144
- /* @__PURE__ */ m("div", { className: "flex flex-col gap-1", children: [
145
- /* @__PURE__ */ l(
146
- "h3",
500
+ /* @__PURE__ */ c(A, { rounded: !0 }),
501
+ /* @__PURE__ */ y("div", { className: "relative flex flex-col items-center gap-4 sm:gap-6", children: [
502
+ /* @__PURE__ */ c(
503
+ "div",
147
504
  {
148
- className: "text-foreground text-sm font-semibold",
149
- "data-slot": "map-error-title",
150
- children: r
505
+ "aria-hidden": "true",
506
+ className: "flex items-center justify-center",
507
+ "data-slot": "map-error-illustration",
508
+ children: /* @__PURE__ */ c(Z, { className: "h-auto w-full max-w-41" })
151
509
  }
152
510
  ),
153
- a && /* @__PURE__ */ l(
154
- "p",
511
+ /* @__PURE__ */ y("div", { className: "flex flex-col gap-2", children: [
512
+ /* @__PURE__ */ c(
513
+ "h3",
514
+ {
515
+ className: "text-foreground text-lg font-medium",
516
+ "data-slot": "map-error-title",
517
+ children: t
518
+ }
519
+ ),
520
+ a && /* @__PURE__ */ c(
521
+ "p",
522
+ {
523
+ className: "text-muted-foreground text-sm",
524
+ "data-slot": "map-error-message",
525
+ children: a
526
+ }
527
+ )
528
+ ] }),
529
+ s && /* @__PURE__ */ y(
530
+ T,
155
531
  {
156
- className: "text-muted-foreground max-w-xs text-xs",
157
- "data-slot": "map-error-message",
158
- children: a
532
+ className: "mt-1",
533
+ dataHook: `${r}-retry`,
534
+ loading: n,
535
+ size: "sm",
536
+ variant: "primary",
537
+ onClick: s,
538
+ children: [
539
+ !n && /* @__PURE__ */ c(U, { "aria-hidden": "true" }),
540
+ o
541
+ ]
159
542
  }
160
543
  )
161
- ] }),
162
- o && /* @__PURE__ */ l(
163
- u,
164
- {
165
- className: "mt-1",
166
- dataHook: `${n}-retry`,
167
- size: "sm",
168
- variant: "primary",
169
- onClick: o,
170
- children: "Try again"
171
- }
172
- )
544
+ ] })
173
545
  ]
174
546
  }
175
547
  )
176
548
  );
177
- C.displayName = "MapErrorState";
178
- const A = s.forwardRef(
179
- ({ className: t, dataHook: r, trackingEl: a, trackingLabel: o, children: n, ...e }, i) => /* @__PURE__ */ l(
180
- h,
549
+ ge.displayName = "MapErrorState";
550
+ const ye = u.forwardRef(
551
+ ({ variant: e, color: t, dataHook: a, className: s, children: n, ...o }, r) => {
552
+ const i = e ? h[e] : t;
553
+ return /* @__PURE__ */ y(
554
+ "span",
555
+ {
556
+ ref: r,
557
+ className: g(
558
+ "text-foreground flex items-center gap-1 font-sans text-xs",
559
+ s
560
+ ),
561
+ "data-hook": a,
562
+ "data-slot": "map-legend-item",
563
+ ...o,
564
+ children: [
565
+ /* @__PURE__ */ c(
566
+ "span",
567
+ {
568
+ "aria-hidden": "true",
569
+ className: g("inline-block size-2 shrink-0 rounded-full", i)
570
+ }
571
+ ),
572
+ n
573
+ ]
574
+ }
575
+ );
576
+ }
577
+ );
578
+ ye.displayName = "MapLegendItem";
579
+ const be = u.forwardRef(
580
+ ({
581
+ className: e,
582
+ dataHook: t,
583
+ trackingEl: a,
584
+ trackingLabel: s,
585
+ ariaLabel: n,
586
+ children: o,
587
+ ...r
588
+ }, i) => /* @__PURE__ */ c(
589
+ H,
181
590
  {
182
591
  ref: i,
183
- className: p("inline-flex w-auto flex-row items-center", t),
592
+ "aria-label": n ?? "Map legend",
593
+ className: g(
594
+ "inline-flex w-auto max-w-none flex-row items-center bg-white font-sans dark:bg-neutral-800",
595
+ e
596
+ ),
184
597
  "data-slot": "map-legend",
185
- dataHook: r,
598
+ dataHook: t,
186
599
  density: "condensed",
187
- maxWidth: "none",
600
+ role: "group",
188
601
  trackingEl: a || "map-legend",
189
- trackingLabel: o,
190
- variant: "filled",
191
- ...e,
192
- children: /* @__PURE__ */ l(x, { className: "flex items-center gap-3", children: n })
602
+ trackingLabel: s,
603
+ variant: "border",
604
+ ...r,
605
+ children: /* @__PURE__ */ c(J, { className: "flex items-center gap-3", children: o })
193
606
  }
194
607
  )
195
608
  );
196
- A.displayName = "MapLegend";
197
- function D(t = 150) {
198
- const [r, a] = s.useState(null), [o, n] = s.useState(null), e = s.useRef(null), i = s.useCallback((f) => {
199
- e.current && clearTimeout(e.current), n(f), a(f);
200
- }, []), d = s.useCallback(() => {
201
- e.current && clearTimeout(e.current), e.current = setTimeout(() => a(null), t);
202
- }, [t]), c = s.useCallback(() => {
203
- e.current && clearTimeout(e.current);
204
- }, []);
609
+ be.displayName = "MapLegend";
610
+ function je(e) {
611
+ const { hoverWhenOpen: t = !1 } = e ?? {}, [a, s] = u.useState(null), [n, o] = u.useState(null), r = u.useCallback((d) => {
612
+ o(d), s(d);
613
+ }, []), i = u.useCallback(() => {
614
+ s(null);
615
+ }, []), l = u.useCallback(
616
+ (d) => {
617
+ const f = {
618
+ onClick: () => r(d)
619
+ };
620
+ return t && (f.onPointerEnter = (m) => {
621
+ m.pointerType === "mouse" && a != null && r(d);
622
+ }), f;
623
+ },
624
+ [t, r, a]
625
+ );
205
626
  return {
206
- activeItem: r,
207
- anchorItem: o,
208
- showItem: i,
209
- scheduleClose: d,
210
- cancelClose: c
627
+ activeItem: a,
628
+ anchorItem: n,
629
+ showItem: r,
630
+ close: i,
631
+ getInteractionProps: l
211
632
  };
212
633
  }
213
- const G = y, R = N;
214
- R.displayName = "MapPopoverAnchor";
215
- const L = s.forwardRef(
634
+ const Le = Q, he = X;
635
+ he.displayName = "MapPopoverAnchor";
636
+ const ke = u.forwardRef(
216
637
  ({
217
- className: t,
218
- side: r = "top",
638
+ className: e,
639
+ side: t = "top",
219
640
  sideOffset: a = 4,
220
- dataHook: o,
641
+ dataHook: s,
221
642
  trackingEl: n,
222
- trackingLabel: e,
223
- ...i
224
- }, d) => /* @__PURE__ */ l(
225
- M,
643
+ trackingLabel: o,
644
+ ...r
645
+ }, i) => /* @__PURE__ */ c(
646
+ ee,
226
647
  {
227
- ref: d,
228
- className: p(
229
- "w-auto p-3 data-[state=closed]:animate-none data-[state=closed]:opacity-0",
230
- t
648
+ ref: i,
649
+ className: g(
650
+ "w-auto max-w-68.25 p-3 data-[state=closed]:animate-none data-[state=closed]:opacity-0",
651
+ e
231
652
  ),
232
653
  "data-slot": "map-popover-content",
233
654
  "data-tracking-el": n || "map-popover",
234
- "data-tracking-label": e,
235
- dataHook: o,
236
- side: r,
655
+ "data-tracking-label": o,
656
+ dataHook: s,
657
+ side: t,
237
658
  sideOffset: a,
238
- onOpenAutoFocus: (c) => c.preventDefault(),
239
- ...i
659
+ onCloseAutoFocus: (l) => l.preventDefault(),
660
+ onOpenAutoFocus: (l) => l.preventDefault(),
661
+ ...r
240
662
  }
241
663
  )
242
664
  );
243
- L.displayName = "MapPopoverContent";
665
+ ke.displayName = "MapPopoverContent";
244
666
  export {
245
- P as MapControlButton,
246
- C as MapErrorState,
247
- g as MapGridPin,
248
- A as MapLegend,
249
- b as MapLoadingState,
250
- k as MapLocationPin,
251
- G as MapPopover,
252
- R as MapPopoverAnchor,
253
- L as MapPopoverContent,
254
- B as MapTypeId,
255
- D as useMapPopoverHover
667
+ ae as MAP_STYLES,
668
+ me as MapClusterPin,
669
+ fe as MapControlButton,
670
+ ge as MapErrorState,
671
+ O as MapGridPin,
672
+ be as MapLegend,
673
+ ye as MapLegendItem,
674
+ pe as MapLoadingState,
675
+ ue as MapLocationPin,
676
+ Le as MapPopover,
677
+ he as MapPopoverAnchor,
678
+ ke as MapPopoverContent,
679
+ Se as MapTypeId,
680
+ Re as clusterPinHexColors,
681
+ Oe as createClusterPinElement,
682
+ L as createClusterPinSvg,
683
+ h as mapGridPinColorMap,
684
+ Ee as resolveClusterPinColors,
685
+ je as useMapPopoverClick,
686
+ Te as useMapStyles
256
687
  };