@dxos/react-ui-geo 0.8.4-main.ae835ea → 0.8.4-main.bc674ce

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