@dxos/react-ui-geo 0.8.4-main.7ace549 → 0.8.4-main.8360d9e660

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