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