@local-logic/maps 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import { jsxs as v, jsx as C } from "react/jsx-runtime";
2
- import { useState as x, useRef as Z, useCallback as h, useEffect as d } from "react";
3
- import { M as B, N as L, u as T } from "./scale-control-Dsir9fWY.js";
4
- import { u as M, D as p, a as z, m as A } from "./index-Bbgg2AcG.js";
1
+ import { jsxs as x, jsx as M } from "react/jsx-runtime";
2
+ import { useState as h, useRef as Z, useCallback as B, useEffect as g } from "react";
3
+ import { M as L, N as P, u as T } from "./scale-control-Dsir9fWY.js";
4
+ import { u as v, D as f, a as z, m as A } from "./index-eyFsWhYO.js";
5
5
  import { t as E } from "./index-DscDx7HE.js";
6
- const P = {
6
+ const y = {
7
7
  en: {
8
8
  "AttributionControl.ToggleAttribution": "Toggle attribution",
9
9
  "FullscreenControl.Enter": "Enter fullscreen",
@@ -34,78 +34,78 @@ const P = {
34
34
  "ScrollZoomBlocker.CmdMessage": "Utilisez ⌘ + défilement pour zoomer sur la carte",
35
35
  "TouchPanBlocker.Message": "Utilisez deux doigts pour déplacer la carte"
36
36
  }
37
- }, y = () => {
38
- const { current: o } = T(), { markerPoints: n, locationBoundary: l, setZoom: s, mapPadding: c } = M(), [a, f] = x(void 0), i = Z(void 0), r = h(() => {
39
- o && s(o.getZoom());
40
- }, [o, s]);
41
- return d(() => (r(), o?.on("zoom", r), () => {
37
+ }, k = () => {
38
+ const { current: o } = T(), { centerPinMarkerPoints: t, markerPoints: n, locationBoundary: s, setZoom: c, mapPadding: u } = v(), [i, d] = h(void 0), l = Z(void 0), r = B(() => {
39
+ o && c(o.getZoom());
40
+ }, [o, c]);
41
+ return g(() => (r(), o?.on("zoom", r), () => {
42
42
  o?.off("zoom", r);
43
- }), [o, r]), d(() => {
43
+ }), [o, r]), g(() => {
44
44
  if (!o)
45
45
  return;
46
46
  const e = [];
47
- if (typeof n < "u" && n.length > 0 ? e.push(...n) : e.push(...l || []), e.length === 0)
47
+ if (typeof n < "u" && n.length > 0 ? (e.push(...n), t && e.push(t)) : e.push(...s || []), e.length === 0)
48
48
  return;
49
- const t = E(A(e));
50
- (!i.current || !t.every((u, m) => u === i.current?.[m])) && (i.current = t, f(t));
51
- }, [o, n, l]), d(() => {
52
- if (!o || typeof a > "u")
49
+ const a = E(A(e));
50
+ (!l.current || !a.every((m, p) => m === l.current?.[p])) && (l.current = a, d(a));
51
+ }, [o, n, s, t]), g(() => {
52
+ if (!o || typeof i > "u")
53
53
  return;
54
- const [e, t, u, m] = a, g = (u - e) * 0.05 || 1e-3, b = (m - t) * 0.05 || 1e-3;
54
+ const [e, a, m, p] = i, b = (m - e) * 0.05 || 1e-3, C = (p - a) * 0.05 || 1e-3;
55
55
  o.fitBounds(
56
56
  [
57
- [e - g, t - b],
58
- [u + g, m + b]
57
+ [e - b, a - C],
58
+ [m + b, p + C]
59
59
  ],
60
60
  {
61
61
  // Mapbox seems to retain padding, thus further calls
62
62
  // to map.getBounds() include the padding and make calculations
63
63
  // harder. Explicitly turning this off.
64
64
  retainPadding: !1,
65
- padding: c,
65
+ padding: u,
66
66
  maxZoom: 17,
67
67
  duration: 700
68
68
  }
69
69
  );
70
- }, [o, a, c]), null;
70
+ }, [o, i, u]), null;
71
71
  };
72
- function R({ children: o }) {
72
+ function G({ children: o }) {
73
73
  const {
74
- mapProvider: n,
75
- locale: l,
74
+ mapProvider: t,
75
+ locale: n,
76
76
  center: s,
77
- zoom: c = p.zoom,
78
- minZoom: a,
79
- maxZoom: f,
80
- pitch: i = p.pitch,
81
- bearing: r = p.bearing,
82
- cooperativeGestures: e = p.cooperativeGestures,
83
- zoomPosition: t
84
- } = M();
85
- return n.name !== "mapbox" ? null : /* @__PURE__ */ v(
86
- B,
77
+ zoom: c = f.zoom,
78
+ minZoom: u,
79
+ maxZoom: i,
80
+ pitch: d = f.pitch,
81
+ bearing: l = f.bearing,
82
+ cooperativeGestures: r = f.cooperativeGestures,
83
+ zoomPosition: e
84
+ } = v();
85
+ return t.name !== "mapbox" ? null : /* @__PURE__ */ x(
86
+ L,
87
87
  {
88
- mapboxAccessToken: n.apiKey,
88
+ mapboxAccessToken: t.apiKey,
89
89
  initialViewState: {
90
90
  ...s,
91
91
  zoom: c,
92
- pitch: i,
93
- bearing: r
92
+ pitch: d,
93
+ bearing: l
94
94
  },
95
- cooperativeGestures: e,
96
- minZoom: a,
97
- maxZoom: f,
98
- mapStyle: `mapbox://styles/${n.theme || z.mapbox}`,
95
+ cooperativeGestures: r,
96
+ minZoom: u,
97
+ maxZoom: i,
98
+ mapStyle: `mapbox://styles/${t.theme || z.mapbox}`,
99
99
  interactiveLayerIds: ["road-label", "waterway-label"],
100
- locale: P[l],
100
+ locale: y[n],
101
101
  children: [
102
- /* @__PURE__ */ C(y, {}),
103
- t && /* @__PURE__ */ C(L, { position: t }),
102
+ /* @__PURE__ */ M(k, {}),
103
+ e && /* @__PURE__ */ M(P, { position: e }),
104
104
  o
105
105
  ]
106
106
  }
107
107
  );
108
108
  }
109
109
  export {
110
- R as default
110
+ G as default
111
111
  };
@@ -0,0 +1,109 @@
1
+ import { jsx as v, jsxs as x, Fragment as A } from "react/jsx-runtime";
2
+ import { useState as B, useEffect as P, useRef as C, useCallback as E } from "react";
3
+ import { APIProvider as O, Map as z, ControlPosition as L, useMap as G } from "@vis.gl/react-google-maps";
4
+ import { u as _, D as T, W as p, a as Z, m as I } from "./index-eyFsWhYO.js";
5
+ import { t as R } from "./index-DscDx7HE.js";
6
+ const F = {
7
+ "top-left": L.LEFT_TOP,
8
+ "top-right": L.RIGHT_TOP,
9
+ "bottom-left": L.LEFT_BOTTOM,
10
+ "bottom-right": L.RIGHT_BOTTOM
11
+ }, D = ({ isMapLoaded: y }) => {
12
+ const e = G(), { centerPinMarkerPoints: l, markerPoints: t, locationBoundary: c, setZoom: a, mapPadding: n } = _(), [u, g] = B(void 0), m = C(void 0), r = E(() => {
13
+ if (!e)
14
+ return;
15
+ const o = e.getZoom();
16
+ typeof o < "u" && a(o + 1);
17
+ }, [e, a]);
18
+ return P(() => {
19
+ r();
20
+ const o = e?.addListener("zoom_changed", r);
21
+ return () => {
22
+ o?.remove();
23
+ };
24
+ }, [e, r]), P(() => {
25
+ if (!e)
26
+ return;
27
+ const o = [];
28
+ typeof t < "u" && t.length > 0 ? (o.push(...t), l && o.push(l)) : o.push(...c || []);
29
+ const s = o.length === 0 ? p : R(I(o));
30
+ (!m.current || !s.every((i, d) => i === m.current?.[d])) && (m.current = s, g(s));
31
+ }, [e, t, c, l]), P(() => {
32
+ if (!e || typeof u > "u")
33
+ return;
34
+ const [o, s, i, d] = u, f = (i - o) * 0.05 || 1e-3, h = (d - s) * 0.05 || 1e-3;
35
+ e.fitBounds(
36
+ {
37
+ south: s - h,
38
+ west: o - f,
39
+ north: d + h,
40
+ east: i + f
41
+ },
42
+ n
43
+ );
44
+ }, [y, e, u, n]), null;
45
+ };
46
+ function j({ children: y }) {
47
+ const [e, l] = B(!1), [t, c] = B(!1), {
48
+ mapProvider: a,
49
+ mapPadding: n,
50
+ locale: u,
51
+ center: g,
52
+ zoom: m = T.zoom,
53
+ minZoom: r,
54
+ maxZoom: o,
55
+ pitch: s = T.pitch,
56
+ bearing: i = T.bearing,
57
+ cooperativeGestures: d = T.cooperativeGestures,
58
+ zoomPosition: f
59
+ } = _();
60
+ if (P(() => {
61
+ if (!t)
62
+ return;
63
+ const M = document.querySelector(".gm-style-moc");
64
+ M && n && (M.style.paddingLeft = `${n.left}px`, M.style.paddingRight = `${n.right}px`);
65
+ }, [t, n?.left, n?.right]), a.name !== "google")
66
+ return null;
67
+ const h = () => {
68
+ l(!0);
69
+ }, b = () => {
70
+ c(!0);
71
+ };
72
+ return /* @__PURE__ */ v(O, { apiKey: a.apiKey, language: u, onLoad: h, children: e && /* @__PURE__ */ x(A, { children: [
73
+ /* @__PURE__ */ v(D, { isMapLoaded: t }),
74
+ /* @__PURE__ */ v(
75
+ z,
76
+ {
77
+ mapId: a.theme || Z.google,
78
+ defaultCenter: {
79
+ lat: g.latitude,
80
+ lng: g.longitude
81
+ },
82
+ defaultBounds: {
83
+ north: p[3],
84
+ south: p[1],
85
+ east: p[2],
86
+ west: p[0]
87
+ },
88
+ defaultZoom: m + 1,
89
+ defaultTilt: s,
90
+ defaultHeading: i,
91
+ gestureHandling: d ? "cooperative" : "greedy",
92
+ streetViewControl: !1,
93
+ fullscreenControl: !1,
94
+ clickableIcons: !1,
95
+ mapTypeControl: !1,
96
+ zoomControlOptions: {
97
+ position: f && F[f]
98
+ },
99
+ minZoom: typeof r == "number" ? r + 1 : void 0,
100
+ maxZoom: typeof o == "number" ? o + 1 : void 0,
101
+ onTilesLoaded: b,
102
+ children: y
103
+ }
104
+ )
105
+ ] }) });
106
+ }
107
+ export {
108
+ j as default
109
+ };
@@ -1,8 +1,8 @@
1
1
  import { jsx as E } from "react/jsx-runtime";
2
2
  import { useRef as d, useEffect as M } from "react";
3
3
  import { u as D, P as H } from "./logo-control-CHapR1Dt.js";
4
- import { u as j, P as T } from "./index-Bbgg2AcG.js";
5
- import { c as x, m as A } from "./styles-C0jAgOTJ.js";
4
+ import { u as j, P as T } from "./index-eyFsWhYO.js";
5
+ import { c as x, m as A } from "./styles-BPYm8pR9.js";
6
6
  function Z({
7
7
  latitude: l,
8
8
  longitude: h,
@@ -1,9 +1,9 @@
1
1
  import { jsxs as f, jsx as i } from "react/jsx-runtime";
2
2
  import { a as k } from "./scale-control-Dsir9fWY.js";
3
3
  import "react";
4
- import { u, M } from "./index-Bbgg2AcG.js";
4
+ import { u, M } from "./index-eyFsWhYO.js";
5
5
  import { c as g, M as C } from "./index-D4t3jFAj.js";
6
- import { C as b } from "./index-Cz1bOBd_.js";
6
+ import { C as b } from "./index-DFGiNPbe.js";
7
7
  function y({
8
8
  clusters: n,
9
9
  colors: r,
@@ -1,9 +1,9 @@
1
1
  import { jsxs as f, jsx as i } from "react/jsx-runtime";
2
2
  import { a as k } from "./logo-control-CHapR1Dt.js";
3
3
  import "react";
4
- import { u, M } from "./index-Bbgg2AcG.js";
4
+ import { u, M } from "./index-eyFsWhYO.js";
5
5
  import { c as g, M as C } from "./index-D4t3jFAj.js";
6
- import { C as v } from "./index-Cz1bOBd_.js";
6
+ import { C as v } from "./index-DFGiNPbe.js";
7
7
  function y({
8
8
  clusters: n,
9
9
  colors: o,
@@ -1,9 +1,9 @@
1
- import { jsxs as v, jsx as g } from "react/jsx-runtime";
2
- import { useState as T, useRef as E, useCallback as x, useEffect as b } from "react";
3
- import { M as L, N as A, u as G } from "./logo-control-CHapR1Dt.js";
4
- import { u as M, D as m, a as F, m as S } from "./index-Bbgg2AcG.js";
5
- import { t as h } from "./index-DscDx7HE.js";
6
- const z = {
1
+ import { jsxs as T, jsx as M } from "react/jsx-runtime";
2
+ import { useState as E, useRef as x, useCallback as L, useEffect as f } from "react";
3
+ import { M as A, N as G, u as h } from "./logo-control-CHapR1Dt.js";
4
+ import { u as v, D as C, a as F, m as S } from "./index-eyFsWhYO.js";
5
+ import { t as z } from "./index-DscDx7HE.js";
6
+ const H = {
7
7
  en: {
8
8
  "AttributionControl.ToggleAttribution": "Toggle attribution",
9
9
  "AttributionControl.MapFeedback": "Map feedback",
@@ -58,72 +58,72 @@ const z = {
58
58
  "CooperativeGesturesHandler.MacHelpText": "Utilisez ⌘ + défilement pour zoomer sur la carte",
59
59
  "CooperativeGesturesHandler.MobileHelpText": "Utilisez deux doigts pour déplacer la carte"
60
60
  }
61
- }, H = () => {
62
- const { current: o } = G(), { markerPoints: r, locationBoundary: i, setZoom: s, mapPadding: u } = M(), [l, C] = T(void 0), a = E(void 0), n = x(() => {
63
- o && s(o.getZoom());
64
- }, [o, s]);
65
- return b(() => (n(), o?.on("zoom", n), () => {
66
- o?.off("zoom", n);
67
- }), [o, n]), b(() => {
68
- if (!o)
61
+ }, P = () => {
62
+ const { current: e } = h(), { centerPinMarkerPoints: t, markerPoints: r, locationBoundary: s, setZoom: u, mapPadding: c } = v(), [a, b] = E(void 0), i = x(void 0), n = L(() => {
63
+ e && u(e.getZoom());
64
+ }, [e, u]);
65
+ return f(() => (n(), e?.on("zoom", n), () => {
66
+ e?.off("zoom", n);
67
+ }), [e, n]), f(() => {
68
+ if (!e)
69
69
  return;
70
- const e = [];
71
- if (typeof r < "u" && r.length > 0 ? e.push(...r) : e.push(...i || []), e.length === 0)
70
+ const o = [];
71
+ if (typeof r < "u" && r.length > 0 ? (o.push(...r), t && o.push(t)) : o.push(...s || []), o.length === 0)
72
72
  return;
73
- const t = h(S(e));
74
- (!a.current || !t.every((c, p) => c === a.current?.[p])) && (a.current = t, C(t));
75
- }, [o, r, i]), b(() => {
76
- if (!o || typeof l > "u")
73
+ const l = z(S(o));
74
+ (!i.current || !l.every((p, m) => p === i.current?.[m])) && (i.current = l, b(l));
75
+ }, [e, r, s, t]), f(() => {
76
+ if (!e || typeof a > "u")
77
77
  return;
78
- const [e, t, c, p] = l, d = (c - e) * 0.05 || 1e-3, f = (p - t) * 0.05 || 1e-3;
79
- o.fitBounds(
78
+ const [o, l, p, m] = a, d = (p - o) * 0.05 || 1e-3, g = (m - l) * 0.05 || 1e-3;
79
+ e.fitBounds(
80
80
  [
81
- [e - d, t - f],
82
- [c + d, p + f]
81
+ [o - d, l - g],
82
+ [p + d, m + g]
83
83
  ],
84
84
  {
85
- padding: u,
85
+ padding: c,
86
86
  maxZoom: 17,
87
87
  duration: 700
88
88
  }
89
89
  );
90
- }, [o, l, u]), null;
90
+ }, [e, a, c]), null;
91
91
  };
92
- function P({ children: o }) {
92
+ function B({ children: e }) {
93
93
  const {
94
- mapProvider: r,
95
- locale: i,
94
+ mapProvider: t,
95
+ locale: r,
96
96
  center: s,
97
- zoom: u = m.zoom,
98
- minZoom: l,
99
- maxZoom: C,
100
- pitch: a = m.pitch,
101
- bearing: n = m.bearing,
102
- cooperativeGestures: e = m.cooperativeGestures,
103
- zoomPosition: t
104
- } = M();
105
- return r.name !== "maptiler" ? null : /* @__PURE__ */ v(
106
- L,
97
+ zoom: u = C.zoom,
98
+ minZoom: c,
99
+ maxZoom: a,
100
+ pitch: b = C.pitch,
101
+ bearing: i = C.bearing,
102
+ cooperativeGestures: n = C.cooperativeGestures,
103
+ zoomPosition: o
104
+ } = v();
105
+ return t.name !== "maptiler" ? null : /* @__PURE__ */ T(
106
+ A,
107
107
  {
108
108
  initialViewState: {
109
109
  ...s,
110
110
  zoom: u,
111
- pitch: a,
112
- bearing: n
111
+ pitch: b,
112
+ bearing: i
113
113
  },
114
- cooperativeGestures: e,
115
- minZoom: l,
116
- maxZoom: C,
117
- mapStyle: `https://api.maptiler.com/maps/${r.theme || F.maptiler}/style.json?key=${r.apiKey}`,
118
- locale: z[i],
114
+ cooperativeGestures: n,
115
+ minZoom: c,
116
+ maxZoom: a,
117
+ mapStyle: `https://api.maptiler.com/maps/${t.theme || F.maptiler}/style.json?key=${t.apiKey}`,
118
+ locale: H[r],
119
119
  children: [
120
- /* @__PURE__ */ g(H, {}),
121
- t && /* @__PURE__ */ g(A, { position: t }),
122
- o
120
+ /* @__PURE__ */ M(P, {}),
121
+ o && /* @__PURE__ */ M(G, { position: o }),
122
+ e
123
123
  ]
124
124
  }
125
125
  );
126
126
  }
127
127
  export {
128
- P as default
128
+ B as default
129
129
  };
@@ -1,8 +1,8 @@
1
1
  import { jsx as E } from "react/jsx-runtime";
2
2
  import { useRef as d, useEffect as M } from "react";
3
3
  import { u as z, P as D } from "./scale-control-Dsir9fWY.js";
4
- import { u as H, P as T } from "./index-Bbgg2AcG.js";
5
- import { c as j, m as A } from "./styles-C0jAgOTJ.js";
4
+ import { u as H, P as T } from "./index-eyFsWhYO.js";
5
+ import { c as j, m as A } from "./styles-BPYm8pR9.js";
6
6
  function Z({
7
7
  latitude: h,
8
8
  longitude: l,
@@ -1,6 +1,6 @@
1
1
  import { jsxs as i, jsx as e, Fragment as d } from "react/jsx-runtime";
2
2
  import { useMemo as u } from "react";
3
- import { u as f, M as n } from "./index-Bbgg2AcG.js";
3
+ import { u as f, M as n } from "./index-eyFsWhYO.js";
4
4
  import { c as o, M as v } from "./index-D4t3jFAj.js";
5
5
  const M = `
6
6
  relative flex
@@ -1,8 +1,8 @@
1
1
  import { jsx as E } from "react/jsx-runtime";
2
2
  import { useState as L, useRef as M, useCallback as N, useEffect as f, useMemo as W } from "react";
3
3
  import { useMap as _, InfoWindow as x } from "@vis.gl/react-google-maps";
4
- import { u as z, P as y } from "./index-Bbgg2AcG.js";
5
- import { c as H, m as j } from "./styles-C0jAgOTJ.js";
4
+ import { u as z, P as y } from "./index-eyFsWhYO.js";
5
+ import { c as H, m as j } from "./styles-BPYm8pR9.js";
6
6
  function Z({
7
7
  latitude: g,
8
8
  longitude: m,
@@ -1,5 +1,5 @@
1
1
  import { jsxs as t, jsx as i } from "react/jsx-runtime";
2
- import { u as a } from "./index-Bbgg2AcG.js";
2
+ import { u as a } from "./index-eyFsWhYO.js";
3
3
  const d = `
4
4
  relative w-full h-full bg-gray-200 border-2 border-gray-400
5
5
  flex flex-col overflow-hidden