@dxos/react-ui-geo 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f

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