@dxos/react-ui-geo 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0

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