@dxos/react-ui-geo 0.8.4-main.548089c → 0.8.4-main.59c2e9b

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.
@@ -4,15 +4,13 @@ import {
4
4
  } from "./chunk-JODBF4CC.mjs";
5
5
 
6
6
  // src/components/Globe/Globe.tsx
7
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
8
7
  import { easeLinear, easeSinOut, geoMercator, geoOrthographic, geoPath as geoPath2, geoTransverseMercator, interpolateNumber, transition } from "d3";
9
8
  import React3, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo2, useRef, useState as useState3 } from "react";
10
9
  import { useResizeDetector } from "react-resize-detector";
11
10
  import { useDynamicRef, useThemeContext } from "@dxos/react-ui";
12
- import { mx } from "@dxos/react-ui-theme";
11
+ import { mx } from "@dxos/ui-theme";
13
12
 
14
13
  // src/hooks/context.tsx
15
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
16
14
  import React, { createContext, useContext } from "react";
17
15
  import { raise } from "@dxos/debug";
18
16
  import { useControlledState } from "@dxos/react-ui";
@@ -24,29 +22,24 @@ var defaults = {
24
22
  zoom: 4
25
23
  };
26
24
  var GlobeContext = /* @__PURE__ */ createContext(void 0);
27
- var GlobeContextProvider = ({ children, size, center: centerParam = defaults.center, zoom: zoomParam = defaults.zoom, translation: translationParam, rotation: rotationParam }) => {
28
- var _effect = _useSignals();
29
- try {
30
- const [center, setCenter] = useControlledState(centerParam);
31
- const [zoom, setZoom] = useControlledState(zoomParam);
32
- const [translation, setTranslation] = useControlledState(translationParam);
33
- const [rotation, setRotation] = useControlledState(rotationParam);
34
- return /* @__PURE__ */ React.createElement(GlobeContext.Provider, {
35
- value: {
36
- size,
37
- center,
38
- zoom,
39
- translation,
40
- rotation,
41
- setCenter,
42
- setZoom,
43
- setTranslation,
44
- setRotation
45
- }
46
- }, children);
47
- } finally {
48
- _effect.f();
49
- }
25
+ var GlobeContextProvider = ({ children, size, center: centerProp = defaults.center, zoom: zoomProp = defaults.zoom, translation: translationProp, rotation: rotationProp }) => {
26
+ const [center, setCenter] = useControlledState(centerProp);
27
+ const [zoom, setZoom] = useControlledState(zoomProp);
28
+ const [translation, setTranslation] = useControlledState(translationProp);
29
+ const [rotation, setRotation] = useControlledState(rotationProp);
30
+ return /* @__PURE__ */ React.createElement(GlobeContext.Provider, {
31
+ value: {
32
+ size,
33
+ center,
34
+ zoom,
35
+ translation,
36
+ rotation,
37
+ setCenter,
38
+ setZoom,
39
+ setTranslation,
40
+ setRotation
41
+ }
42
+ }, children);
50
43
  };
51
44
  var useGlobeContext = () => {
52
45
  return useContext(GlobeContext) ?? raise(new Error("Missing GlobeContext"));
@@ -632,9 +625,25 @@ var useTour = (controller, points, options = {}) => {
632
625
  };
633
626
 
634
627
  // src/components/Toolbar/Controls.tsx
635
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
636
628
  import React2 from "react";
637
- import { IconButton, Toolbar } from "@dxos/react-ui";
629
+ import { IconButton, Toolbar, useTranslation } from "@dxos/react-ui";
630
+
631
+ // src/translations.ts
632
+ var translationKey = "@dxos/react-ui-geo";
633
+ var translations = [
634
+ {
635
+ "en-US": {
636
+ [translationKey]: {
637
+ "zoom in icon button": "Zoom in",
638
+ "zoom out icon button": "Zoom out",
639
+ "start icon button": "Start",
640
+ "toggle icon button": "Toggle"
641
+ }
642
+ }
643
+ }
644
+ ];
645
+
646
+ // src/components/Toolbar/Controls.tsx
638
647
  var controlPositions = {
639
648
  topleft: "top-2 left-2",
640
649
  topright: "top-2 right-2",
@@ -642,54 +651,42 @@ var controlPositions = {
642
651
  bottomright: "bottom-2 right-2"
643
652
  };
644
653
  var ZoomControls = ({ classNames, onAction }) => {
645
- var _effect = _useSignals2();
646
- try {
647
- return /* @__PURE__ */ React2.createElement(Toolbar.Root, {
648
- classNames: [
649
- "gap-2",
650
- classNames
651
- ]
652
- }, /* @__PURE__ */ React2.createElement(IconButton, {
653
- icon: "ph--plus--regular",
654
- label: "zoom in",
655
- iconOnly: true,
656
- classNames: "pli-0 aspect-square",
657
- onClick: () => onAction?.("zoom-in")
658
- }), /* @__PURE__ */ React2.createElement(IconButton, {
659
- icon: "ph--minus--regular",
660
- label: "zoom out",
661
- iconOnly: true,
662
- classNames: "pli-0 aspect-square",
663
- onClick: () => onAction?.("zoom-out")
664
- }));
665
- } finally {
666
- _effect.f();
667
- }
654
+ const { t } = useTranslation(translationKey);
655
+ return /* @__PURE__ */ React2.createElement(Toolbar.Root, {
656
+ classNames: [
657
+ "gap-2",
658
+ classNames
659
+ ]
660
+ }, /* @__PURE__ */ React2.createElement(IconButton, {
661
+ icon: "ph--plus--regular",
662
+ iconOnly: true,
663
+ label: t("zoom in icon button"),
664
+ onClick: () => onAction?.("zoom-in")
665
+ }), /* @__PURE__ */ React2.createElement(IconButton, {
666
+ icon: "ph--minus--regular",
667
+ iconOnly: true,
668
+ label: t("zoom out icon button"),
669
+ onClick: () => onAction?.("zoom-out")
670
+ }));
668
671
  };
669
672
  var ActionControls = ({ classNames, onAction }) => {
670
- var _effect = _useSignals2();
671
- try {
672
- return /* @__PURE__ */ React2.createElement(Toolbar.Root, {
673
- classNames: [
674
- "gap-2",
675
- classNames
676
- ]
677
- }, /* @__PURE__ */ React2.createElement(IconButton, {
678
- icon: "ph--play--regular",
679
- label: "start",
680
- iconOnly: true,
681
- classNames: "pli-0 aspect-square",
682
- onClick: () => onAction?.("start")
683
- }), /* @__PURE__ */ React2.createElement(IconButton, {
684
- icon: "ph--globe-hemisphere-west--regular",
685
- label: "toggle",
686
- iconOnly: true,
687
- classNames: "pli-0 aspect-square",
688
- onClick: () => onAction?.("toggle")
689
- }));
690
- } finally {
691
- _effect.f();
692
- }
673
+ const { t } = useTranslation(translationKey);
674
+ return /* @__PURE__ */ React2.createElement(Toolbar.Root, {
675
+ classNames: [
676
+ "gap-2",
677
+ classNames
678
+ ]
679
+ }, /* @__PURE__ */ React2.createElement(IconButton, {
680
+ icon: "ph--path--regular",
681
+ iconOnly: true,
682
+ label: t("start icon button"),
683
+ onClick: () => onAction?.("start")
684
+ }), /* @__PURE__ */ React2.createElement(IconButton, {
685
+ icon: "ph--globe-hemisphere-west--regular",
686
+ iconOnly: true,
687
+ label: t("toggle icon button"),
688
+ onClick: () => onAction?.("toggle")
689
+ }));
693
690
  };
694
691
 
695
692
  // src/components/Globe/Globe.tsx
@@ -748,185 +745,146 @@ var getProjection = (type = "orthographic") => {
748
745
  return type ?? geoOrthographic();
749
746
  };
750
747
  var GlobeRoot = ({ classNames, children, ...props }) => {
751
- var _effect = _useSignals3();
752
- try {
753
- const { ref, width, height } = useResizeDetector();
754
- return /* @__PURE__ */ React3.createElement("div", {
755
- ref,
756
- className: mx("relative flex grow overflow-hidden", classNames)
757
- }, /* @__PURE__ */ React3.createElement(GlobeContextProvider, {
758
- size: {
759
- width,
760
- height
761
- },
762
- ...props
763
- }, children));
764
- } finally {
765
- _effect.f();
766
- }
748
+ const { ref, width, height } = useResizeDetector();
749
+ return /* @__PURE__ */ React3.createElement("div", {
750
+ ref,
751
+ className: mx("relative flex grow overflow-hidden", classNames)
752
+ }, /* @__PURE__ */ React3.createElement(GlobeContextProvider, {
753
+ size: {
754
+ width,
755
+ height
756
+ },
757
+ ...props
758
+ }, children));
767
759
  };
768
- var GlobeCanvas = /* @__PURE__ */ forwardRef(({ projection: projectionParam, topology, features, styles: stylesParam }, forwardRef3) => {
769
- var _effect = _useSignals3();
770
- try {
771
- const { themeMode } = useThemeContext();
772
- const styles = useMemo2(() => stylesParam ?? defaultStyles[themeMode], [
773
- stylesParam,
774
- themeMode
775
- ]);
776
- const [canvas, setCanvas] = useState3(null);
777
- const canvasRef = (canvas2) => setCanvas(canvas2);
778
- const projection = useMemo2(() => getProjection(projectionParam), [
779
- projectionParam
780
- ]);
781
- const layers = useMemo2(() => {
782
- return timer(() => createLayers(topology, features, styles));
783
- }, [
784
- topology,
785
- features,
786
- styles
787
- ]);
788
- const { size, center, zoom, translation, rotation, setCenter, setZoom, setTranslation, setRotation } = useGlobeContext();
789
- const zoomRef = useDynamicRef(zoom);
790
- useEffect4(() => {
791
- if (center) {
792
- setZoom(1);
793
- setRotation(positionToRotation(geoToPosition(center)));
794
- }
795
- }, [
796
- center
797
- ]);
798
- const zooming = useRef(false);
799
- useImperativeHandle(forwardRef3, () => {
800
- return {
801
- canvas,
802
- projection,
803
- center,
804
- get zoom() {
805
- return zoomRef.current;
806
- },
807
- translation,
808
- rotation,
809
- setCenter,
810
- setZoom: (s) => {
811
- if (typeof s === "function") {
812
- const is = interpolateNumber(zoomRef.current, s(zoomRef.current));
813
- transition().ease(zooming.current ? easeLinear : easeSinOut).duration(200).tween("scale", () => (t) => setZoom(is(t))).on("end", () => {
814
- zooming.current = false;
815
- });
816
- } else {
817
- setZoom(s);
818
- }
819
- },
820
- setTranslation,
821
- setRotation
822
- };
823
- }, [
824
- canvas
825
- ]);
826
- const generator = useMemo2(() => canvas && projection && geoPath2(projection, canvas.getContext("2d", {
827
- alpha: false
828
- })), [
760
+ var GlobeCanvas = /* @__PURE__ */ forwardRef(({ projection: projectionProp, topology, features, styles: stylesProp }, forwardRef3) => {
761
+ const { themeMode } = useThemeContext();
762
+ const styles = useMemo2(() => stylesProp ?? defaultStyles[themeMode], [
763
+ stylesProp,
764
+ themeMode
765
+ ]);
766
+ const [canvas, setCanvas] = useState3(null);
767
+ const canvasRef = (canvas2) => setCanvas(canvas2);
768
+ const projection = useMemo2(() => getProjection(projectionProp), [
769
+ projectionProp
770
+ ]);
771
+ const layers = useMemo2(() => {
772
+ return timer(() => createLayers(topology, features, styles));
773
+ }, [
774
+ topology,
775
+ features,
776
+ styles
777
+ ]);
778
+ const { size, center, zoom, translation, rotation, setCenter, setZoom, setTranslation, setRotation } = useGlobeContext();
779
+ const zoomRef = useDynamicRef(zoom);
780
+ useEffect4(() => {
781
+ if (center) {
782
+ setZoom(1);
783
+ setRotation(positionToRotation(geoToPosition(center)));
784
+ }
785
+ }, [
786
+ center
787
+ ]);
788
+ const zooming = useRef(false);
789
+ useImperativeHandle(forwardRef3, () => {
790
+ return {
829
791
  canvas,
830
- projection
831
- ]);
832
- useEffect4(() => {
833
- if (canvas && projection) {
834
- timer(() => {
835
- projection.scale(Math.min(size.width, size.height) / 2 * zoom).translate([
836
- size.width / 2 + (translation?.x ?? 0),
837
- size.height / 2 + (translation?.y ?? 0)
838
- ]).rotate(rotation ?? [
839
- 0,
840
- 0,
841
- 0
842
- ]);
843
- renderLayers(generator, layers, zoom, styles);
844
- });
845
- }
846
- }, [
847
- generator,
848
- size,
849
- zoom,
792
+ projection,
793
+ center,
794
+ get zoom() {
795
+ return zoomRef.current;
796
+ },
850
797
  translation,
851
798
  rotation,
852
- layers
853
- ]);
854
- if (!size.width || !size.height) {
855
- return null;
799
+ setCenter,
800
+ setZoom: (s) => {
801
+ if (typeof s === "function") {
802
+ const is = interpolateNumber(zoomRef.current, s(zoomRef.current));
803
+ transition().ease(zooming.current ? easeLinear : easeSinOut).duration(200).tween("scale", () => (t) => setZoom(is(t))).on("end", () => {
804
+ zooming.current = false;
805
+ });
806
+ } else {
807
+ setZoom(s);
808
+ }
809
+ },
810
+ setTranslation,
811
+ setRotation
812
+ };
813
+ }, [
814
+ canvas
815
+ ]);
816
+ const generator = useMemo2(() => canvas && projection && geoPath2(projection, canvas.getContext("2d", {
817
+ alpha: false
818
+ })), [
819
+ canvas,
820
+ projection
821
+ ]);
822
+ useEffect4(() => {
823
+ if (canvas && projection) {
824
+ timer(() => {
825
+ projection.scale(Math.min(size.width, size.height) / 2 * zoom).translate([
826
+ size.width / 2 + (translation?.x ?? 0),
827
+ size.height / 2 + (translation?.y ?? 0)
828
+ ]).rotate(rotation ?? [
829
+ 0,
830
+ 0,
831
+ 0
832
+ ]);
833
+ renderLayers(generator, layers, zoom, styles);
834
+ });
856
835
  }
857
- return /* @__PURE__ */ React3.createElement("canvas", {
858
- ref: canvasRef,
859
- width: size.width,
860
- height: size.height
861
- });
862
- } finally {
863
- _effect.f();
836
+ }, [
837
+ generator,
838
+ size,
839
+ zoom,
840
+ translation,
841
+ rotation,
842
+ layers
843
+ ]);
844
+ if (!size.width || !size.height) {
845
+ return null;
864
846
  }
847
+ return /* @__PURE__ */ React3.createElement("canvas", {
848
+ ref: canvasRef,
849
+ width: size.width,
850
+ height: size.height
851
+ });
865
852
  });
866
853
  var GlobeDebug = ({ position = "topleft" }) => {
867
- var _effect = _useSignals3();
868
- try {
869
- const { size, zoom, translation, rotation } = useGlobeContext();
870
- return /* @__PURE__ */ React3.createElement("div", {
871
- className: mx("z-10 absolute w-96 p-2 overflow-hidden border border-green-700 rounded", controlPositions[position])
872
- }, /* @__PURE__ */ React3.createElement("pre", {
873
- className: "font-mono text-xs text-green-700"
874
- }, JSON.stringify({
875
- size,
876
- zoom,
877
- translation,
878
- rotation
879
- }, null, 2)));
880
- } finally {
881
- _effect.f();
882
- }
854
+ const { size, zoom, translation, rotation } = useGlobeContext();
855
+ return /* @__PURE__ */ React3.createElement("div", {
856
+ className: mx("z-10 absolute is-96 p-2 overflow-hidden border border-green-700 rounded", controlPositions[position])
857
+ }, /* @__PURE__ */ React3.createElement("pre", {
858
+ className: "font-mono text-xs text-green-700"
859
+ }, JSON.stringify({
860
+ size,
861
+ zoom,
862
+ translation,
863
+ rotation
864
+ }, null, 2)));
883
865
  };
884
866
  var GlobePanel = ({ position, classNames, children }) => {
885
- var _effect = _useSignals3();
886
- try {
887
- return /* @__PURE__ */ React3.createElement("div", {
888
- className: mx("z-10 absolute overflow-hidden", controlPositions[position], classNames)
889
- }, children);
890
- } finally {
891
- _effect.f();
892
- }
867
+ return /* @__PURE__ */ React3.createElement("div", {
868
+ className: mx("z-10 absolute overflow-hidden", controlPositions[position], classNames)
869
+ }, children);
893
870
  };
894
871
  var CustomControl = ({ position, children }) => {
895
- var _effect = _useSignals3();
896
- try {
897
- return /* @__PURE__ */ React3.createElement("div", {
898
- className: mx("z-10 absolute overflow-hidden", controlPositions[position])
899
- }, children);
900
- } finally {
901
- _effect.f();
902
- }
903
- };
904
- var GlobeZoom = ({ onAction, position = "bottomleft", ...props }) => {
905
- var _effect = _useSignals3();
906
- try {
907
- return /* @__PURE__ */ React3.createElement(CustomControl, {
908
- position,
909
- ...props
910
- }, /* @__PURE__ */ React3.createElement(ZoomControls, {
911
- onAction
912
- }));
913
- } finally {
914
- _effect.f();
915
- }
916
- };
917
- var GlobeAction = ({ onAction, position = "bottomright", ...props }) => {
918
- var _effect = _useSignals3();
919
- try {
920
- return /* @__PURE__ */ React3.createElement(CustomControl, {
921
- position,
922
- ...props
923
- }, /* @__PURE__ */ React3.createElement(ActionControls, {
924
- onAction
925
- }));
926
- } finally {
927
- _effect.f();
928
- }
872
+ return /* @__PURE__ */ React3.createElement("div", {
873
+ className: mx("z-10 absolute overflow-hidden", controlPositions[position])
874
+ }, children);
929
875
  };
876
+ var GlobeZoom = ({ onAction, position = "bottomleft", ...props }) => /* @__PURE__ */ React3.createElement(CustomControl, {
877
+ position,
878
+ ...props
879
+ }, /* @__PURE__ */ React3.createElement(ZoomControls, {
880
+ onAction
881
+ }));
882
+ var GlobeAction = ({ onAction, position = "bottomright", ...props }) => /* @__PURE__ */ React3.createElement(CustomControl, {
883
+ position,
884
+ ...props
885
+ }, /* @__PURE__ */ React3.createElement(ActionControls, {
886
+ onAction
887
+ }));
930
888
  var Globe = {
931
889
  Root: GlobeRoot,
932
890
  Canvas: GlobeCanvas,
@@ -937,7 +895,6 @@ var Globe = {
937
895
  };
938
896
 
939
897
  // src/components/Map/Map.tsx
940
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
941
898
  import "leaflet/dist/leaflet.css";
942
899
  import { createContext as createContext2 } from "@radix-ui/react-context";
943
900
  import L, { Control, DomEvent, DomUtil, latLngBounds } from "leaflet";
@@ -945,7 +902,7 @@ import React4, { forwardRef as forwardRef2, useEffect as useEffect5, useImperati
945
902
  import { createRoot } from "react-dom/client";
946
903
  import { MapContainer, Marker, Popup, TileLayer, useMap, useMapEvents } from "react-leaflet";
947
904
  import { ThemeProvider, Tooltip } from "@dxos/react-ui";
948
- import { defaultTx, mx as mx2 } from "@dxos/react-ui-theme";
905
+ import { defaultTx, mx as mx2 } from "@dxos/ui-theme";
949
906
  var defaults2 = {
950
907
  center: {
951
908
  lat: 51,
@@ -955,197 +912,163 @@ var defaults2 = {
955
912
  };
956
913
  var [MapContextProvier, useMapContext] = createContext2("Map");
957
914
  var MapRoot = /* @__PURE__ */ forwardRef2(({ classNames, scrollWheelZoom = true, doubleClickZoom = true, touchZoom = true, center, zoom, onChange, ...props }, forwardedRef) => {
958
- var _effect = _useSignals4();
959
- try {
960
- const [attention, setAttention] = useState4(false);
961
- const mapRef = useRef2(null);
962
- const map = mapRef.current;
963
- useImperativeHandle2(forwardedRef, () => ({
964
- setCenter: (center2, zoom2) => {
965
- mapRef.current?.setView(center2, zoom2);
966
- },
967
- setZoom: (cb) => {
968
- mapRef.current?.setZoom(cb(mapRef.current?.getZoom() ?? 0));
969
- }
970
- }), []);
971
- useEffect5(() => {
972
- if (!map) {
973
- return;
974
- }
975
- if (attention) {
976
- map.scrollWheelZoom.enable();
977
- } else {
978
- map.scrollWheelZoom.disable();
979
- }
980
- }, [
981
- map,
982
- attention
983
- ]);
984
- return /* @__PURE__ */ React4.createElement(MapContextProvier, {
985
- attention,
986
- onChange
987
- }, /* @__PURE__ */ React4.createElement(MapContainer, {
988
- ...props,
989
- ref: mapRef,
990
- className: mx2("group relative grid bs-full is-full !bg-baseSurface dx-focus-ring-inset", classNames),
991
- attributionControl: false,
992
- zoomControl: false,
993
- scrollWheelZoom,
994
- doubleClickZoom,
995
- touchZoom,
996
- center: center ?? defaults2.center,
997
- zoom: zoom ?? defaults2.zoom
998
- }));
999
- } finally {
1000
- _effect.f();
1001
- }
915
+ const [attention, setAttention] = useState4(false);
916
+ const mapRef = useRef2(null);
917
+ const map = mapRef.current;
918
+ useImperativeHandle2(forwardedRef, () => ({
919
+ setCenter: (center2, zoom2) => {
920
+ mapRef.current?.setView(center2, zoom2);
921
+ },
922
+ setZoom: (cb) => {
923
+ mapRef.current?.setZoom(cb(mapRef.current?.getZoom() ?? 0));
924
+ }
925
+ }), []);
926
+ useEffect5(() => {
927
+ if (!map) {
928
+ return;
929
+ }
930
+ if (attention) {
931
+ map.scrollWheelZoom.enable();
932
+ } else {
933
+ map.scrollWheelZoom.disable();
934
+ }
935
+ }, [
936
+ map,
937
+ attention
938
+ ]);
939
+ return /* @__PURE__ */ React4.createElement(MapContextProvier, {
940
+ attention,
941
+ onChange
942
+ }, /* @__PURE__ */ React4.createElement(MapContainer, {
943
+ ...props,
944
+ ref: mapRef,
945
+ className: mx2("group relative grid bs-full is-full !bg-baseSurface dx-focus-ring-inset", classNames),
946
+ attributionControl: false,
947
+ zoomControl: false,
948
+ scrollWheelZoom,
949
+ doubleClickZoom,
950
+ touchZoom,
951
+ center: center ?? defaults2.center,
952
+ zoom: zoom ?? defaults2.zoom
953
+ }));
1002
954
  });
1003
955
  MapRoot.displayName = "Map.Root";
1004
956
  var MapTiles = (_props) => {
1005
- var _effect = _useSignals4();
1006
- try {
1007
- const ref = useRef2(null);
1008
- const { onChange } = useMapContext(MapTiles.displayName);
1009
- useMapEvents({
1010
- zoomstart: (ev) => {
1011
- onChange?.({
1012
- center: ev.target.getCenter(),
1013
- zoom: ev.target.getZoom()
1014
- });
1015
- }
1016
- });
1017
- const { attention } = useMapContext(MapTiles.displayName);
1018
- useEffect5(() => {
1019
- if (ref.current) {
1020
- ref.current.getContainer().dataset.attention = attention ? "1" : "0";
1021
- }
1022
- }, [
1023
- attention
1024
- ]);
1025
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(TileLayer, {
1026
- ref,
1027
- "data-attention": attention,
1028
- detectRetina: true,
1029
- className: 'dark:grayscale dark:invert data-[attention="0"]:!opacity-80',
1030
- url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
1031
- keepBuffer: 4
1032
- }));
1033
- } finally {
1034
- _effect.f();
1035
- }
957
+ const ref = useRef2(null);
958
+ const { onChange } = useMapContext(MapTiles.displayName);
959
+ useMapEvents({
960
+ zoomstart: (ev) => {
961
+ onChange?.({
962
+ center: ev.target.getCenter(),
963
+ zoom: ev.target.getZoom()
964
+ });
965
+ }
966
+ });
967
+ const { attention } = useMapContext(MapTiles.displayName);
968
+ useEffect5(() => {
969
+ if (ref.current) {
970
+ ref.current.getContainer().dataset.attention = attention ? "1" : "0";
971
+ }
972
+ }, [
973
+ attention
974
+ ]);
975
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(TileLayer, {
976
+ ref,
977
+ "data-attention": attention,
978
+ detectRetina: true,
979
+ className: 'dark:grayscale dark:invert data-[attention="0"]:!opacity-80',
980
+ url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
981
+ keepBuffer: 4
982
+ }));
1036
983
  };
1037
984
  MapTiles.displayName = "Map.Tiles";
1038
985
  var MapMarkers = ({ selected, markers }) => {
1039
- var _effect = _useSignals4();
1040
- try {
1041
- const map = useMap();
1042
- useEffect5(() => {
1043
- if (markers.length > 0) {
1044
- const bounds = latLngBounds(markers.map((marker) => marker.location));
1045
- map.fitBounds(bounds);
1046
- } else {
1047
- map.setView(defaults2.center, defaults2.zoom);
1048
- }
1049
- }, [
1050
- markers
1051
- ]);
1052
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, markers?.map(({ id, title, location: { lat, lng } }) => {
1053
- return /* @__PURE__ */ React4.createElement(Marker, {
1054
- key: id,
1055
- position: {
1056
- lat,
1057
- lng
1058
- },
1059
- icon: (
1060
- // TODO(burdon): Create custom icon from bundled assets.
1061
- // TODO(burdon): Selection state.
1062
- new L.Icon({
1063
- iconUrl: "https://dxos.network/marker-icon.png",
1064
- iconRetinaUrl: "https://dxos.network/marker-icon-2x.png",
1065
- shadowUrl: "https://dxos.network/marker-shadow.png",
1066
- iconSize: [
1067
- 25,
1068
- 41
1069
- ],
1070
- iconAnchor: [
1071
- 12,
1072
- 41
1073
- ],
1074
- popupAnchor: [
1075
- 1,
1076
- -34
1077
- ],
1078
- shadowSize: [
1079
- 41,
1080
- 41
1081
- ]
1082
- })
1083
- )
1084
- }, title && /* @__PURE__ */ React4.createElement(Popup, null, title));
1085
- }));
1086
- } finally {
1087
- _effect.f();
1088
- }
986
+ const map = useMap();
987
+ useEffect5(() => {
988
+ if (markers.length > 0) {
989
+ const bounds = latLngBounds(markers.map((marker) => marker.location));
990
+ map.fitBounds(bounds);
991
+ } else {
992
+ map.setView(defaults2.center, defaults2.zoom);
993
+ }
994
+ }, [
995
+ markers
996
+ ]);
997
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, markers?.map(({ id, title, location: { lat, lng } }) => {
998
+ return /* @__PURE__ */ React4.createElement(Marker, {
999
+ key: id,
1000
+ position: {
1001
+ lat,
1002
+ lng
1003
+ },
1004
+ icon: (
1005
+ // TODO(burdon): Create custom icon from bundled assets.
1006
+ // TODO(burdon): Selection state.
1007
+ new L.Icon({
1008
+ iconUrl: "https://dxos.network/marker-icon.png",
1009
+ iconRetinaUrl: "https://dxos.network/marker-icon-2x.png",
1010
+ shadowUrl: "https://dxos.network/marker-shadow.png",
1011
+ iconSize: [
1012
+ 25,
1013
+ 41
1014
+ ],
1015
+ iconAnchor: [
1016
+ 12,
1017
+ 41
1018
+ ],
1019
+ popupAnchor: [
1020
+ 1,
1021
+ -34
1022
+ ],
1023
+ shadowSize: [
1024
+ 41,
1025
+ 41
1026
+ ]
1027
+ })
1028
+ )
1029
+ }, title && /* @__PURE__ */ React4.createElement(Popup, null, title));
1030
+ }));
1089
1031
  };
1090
1032
  MapMarkers.displayName = "Map.Markers";
1091
1033
  var CustomControl2 = ({ position, children }) => {
1092
- var _effect = _useSignals4();
1093
- try {
1094
- const map = useMap();
1095
- useEffect5(() => {
1096
- const control = new Control({
1097
- position
1098
- });
1099
- control.onAdd = () => {
1100
- const container = DomUtil.create("div", mx2("!m-0", controlPositions[position]));
1101
- DomEvent.disableClickPropagation(container);
1102
- DomEvent.disableScrollPropagation(container);
1103
- const root = createRoot(container);
1104
- root.render(/* @__PURE__ */ React4.createElement(ThemeProvider, {
1105
- tx: defaultTx
1106
- }, /* @__PURE__ */ React4.createElement(Tooltip.Provider, null, children)));
1107
- return container;
1108
- };
1109
- control.addTo(map);
1110
- return () => {
1111
- control.remove();
1112
- };
1113
- }, [
1114
- map,
1115
- position,
1116
- children
1117
- ]);
1118
- return null;
1119
- } finally {
1120
- _effect.f();
1121
- }
1122
- };
1123
- var MapZoom = ({ onAction, position = "bottomleft", ...props }) => {
1124
- var _effect = _useSignals4();
1125
- try {
1126
- return /* @__PURE__ */ React4.createElement(CustomControl2, {
1127
- position,
1128
- ...props
1129
- }, /* @__PURE__ */ React4.createElement(ZoomControls, {
1130
- onAction
1131
- }));
1132
- } finally {
1133
- _effect.f();
1134
- }
1135
- };
1136
- var MapAction = ({ onAction, position = "bottomright", ...props }) => {
1137
- var _effect = _useSignals4();
1138
- try {
1139
- return /* @__PURE__ */ React4.createElement(CustomControl2, {
1140
- position,
1141
- ...props
1142
- }, /* @__PURE__ */ React4.createElement(ActionControls, {
1143
- onAction
1144
- }));
1145
- } finally {
1146
- _effect.f();
1147
- }
1034
+ const map = useMap();
1035
+ useEffect5(() => {
1036
+ const control = new Control({
1037
+ position
1038
+ });
1039
+ control.onAdd = () => {
1040
+ const container = DomUtil.create("div", mx2("!m-0", controlPositions[position]));
1041
+ DomEvent.disableClickPropagation(container);
1042
+ DomEvent.disableScrollPropagation(container);
1043
+ const root = createRoot(container);
1044
+ root.render(/* @__PURE__ */ React4.createElement(ThemeProvider, {
1045
+ tx: defaultTx
1046
+ }, /* @__PURE__ */ React4.createElement(Tooltip.Provider, null, children)));
1047
+ return container;
1048
+ };
1049
+ control.addTo(map);
1050
+ return () => {
1051
+ control.remove();
1052
+ };
1053
+ }, [
1054
+ map,
1055
+ position,
1056
+ children
1057
+ ]);
1058
+ return null;
1148
1059
  };
1060
+ var MapZoom = ({ onAction, position = "bottomleft", ...props }) => /* @__PURE__ */ React4.createElement(CustomControl2, {
1061
+ position,
1062
+ ...props
1063
+ }, /* @__PURE__ */ React4.createElement(ZoomControls, {
1064
+ onAction
1065
+ }));
1066
+ var MapAction = ({ onAction, position = "bottomright", ...props }) => /* @__PURE__ */ React4.createElement(CustomControl2, {
1067
+ position,
1068
+ ...props
1069
+ }, /* @__PURE__ */ React4.createElement(ActionControls, {
1070
+ onAction
1071
+ }));
1149
1072
  var Map = {
1150
1073
  Root: MapRoot,
1151
1074
  Tiles: MapTiles,
@@ -1173,6 +1096,8 @@ export {
1173
1096
  renderLayers,
1174
1097
  restrictAxis,
1175
1098
  timer,
1099
+ translationKey,
1100
+ translations,
1176
1101
  useDrag,
1177
1102
  useGlobeContext,
1178
1103
  useGlobeZoomHandler,