@dxos/react-ui-geo 0.8.4-main.fffef41 → 0.8.4-staging.ac66bdf99f

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