@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.
- package/dist/lib/browser/index.mjs +418 -331
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +418 -331
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +418 -331
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
- package/dist/types/src/hooks/context.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrag.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
- package/dist/types/src/hooks/useTour.d.ts.map +1 -1
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/inertia.d.ts.map +1 -1
- package/dist/types/src/util/path.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/src/components/Globe/Globe.stories.tsx +1 -1
- package/src/components/Map/Map.stories.tsx +1 -1
|
@@ -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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
classNames
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
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
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
classNames
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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
|
-
|
|
729
|
-
|
|
730
|
-
ref,
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
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
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
themeMode
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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
|
-
|
|
774
|
-
|
|
775
|
-
|
|
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
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
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
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
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
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
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
|
-
|
|
848
|
-
|
|
849
|
-
|
|
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
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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 }) =>
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
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
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
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
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
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
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
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
|
-
|
|
1007
|
-
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
control.
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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 }) =>
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
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,
|