@dxos/react-ui-geo 0.8.2-main.f11618f → 0.8.2-staging.42af850

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