@dxos/solid-ui-geo 0.8.4-main.cb12b3f963 → 0.8.4-main.dfabb4ec29

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,14 +4,23 @@ import {
4
4
  } from "./chunk-ICM52DKE.mjs";
5
5
 
6
6
  // src/components/Globe/Globe.tsx
7
- import { jsx as _jsx3 } from "solid-js/jsx-runtime";
7
+ import { template as _$template2 } from "solid-js/web";
8
+ import { className as _$className2 } from "solid-js/web";
9
+ import { setAttribute as _$setAttribute } from "solid-js/web";
10
+ import { effect as _$effect2 } from "solid-js/web";
11
+ import { memo as _$memo } from "solid-js/web";
12
+ import { createComponent as _$createComponent2 } from "solid-js/web";
13
+ import { insert as _$insert } from "solid-js/web";
14
+ import { use as _$use } from "solid-js/web";
15
+ import { spread as _$spread } from "solid-js/web";
16
+ import { mergeProps as _$mergeProps } from "solid-js/web";
8
17
  import { createResizeObserver } from "@solid-primitives/resize-observer";
9
18
  import { easeLinear, easeSinOut, geoMercator, geoOrthographic, geoPath as geoPath2, geoTransverseMercator, interpolateNumber, transition } from "d3";
10
19
  import { Show, createEffect as createEffect5, createMemo, createSignal as createSignal4 } from "solid-js";
11
20
  import { mx } from "@dxos/ui-theme";
12
21
 
13
22
  // src/hooks/context.tsx
14
- import { jsx as _jsx } from "solid-js/jsx-runtime";
23
+ import { createComponent as _$createComponent } from "solid-js/web";
15
24
  import { createContext, createEffect, createSignal, useContext } from "solid-js";
16
25
  import { raise } from "@dxos/debug";
17
26
  var defaults = {
@@ -36,7 +45,7 @@ var GlobeContextProvider = (props) => {
36
45
  setSize(props.size);
37
46
  }
38
47
  });
39
- return /* @__PURE__ */ _jsx(GlobeContext.Provider, {
48
+ return _$createComponent(GlobeContext.Provider, {
40
49
  value: {
41
50
  size,
42
51
  center,
@@ -48,7 +57,9 @@ var GlobeContextProvider = (props) => {
48
57
  setTranslation,
49
58
  setRotation
50
59
  },
51
- children: props.children
60
+ get children() {
61
+ return props.children;
62
+ }
52
63
  });
53
64
  };
54
65
  var useGlobeContext = () => {
@@ -619,7 +630,12 @@ var useTour = (controller, points, options = {}) => {
619
630
  };
620
631
 
621
632
  // src/components/Toolbar/Controls.tsx
622
- import { jsx as _jsx2, jsxs as _jsxs } from "solid-js/jsx-runtime";
633
+ import { template as _$template } from "solid-js/web";
634
+ import { delegateEvents as _$delegateEvents } from "solid-js/web";
635
+ import { className as _$className } from "solid-js/web";
636
+ import { effect as _$effect } from "solid-js/web";
637
+ var _tmpl$ = /* @__PURE__ */ _$template(`<div><button type=button class="dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center"title="Zoom in"><span class=text-xl>+</span></button><button type=button class="dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center"title="Zoom out"><span class=text-xl>\u2212`);
638
+ var _tmpl$2 = /* @__PURE__ */ _$template(`<div><button type=button class="dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center"title=Start><span class=text-xl>\u25B6</span></button><button type=button class="dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center"title=Toggle><span class=text-xl>\u{1F30D}`);
623
639
  var controlPositions = {
624
640
  topleft: "top-2 left-2",
625
641
  topright: "top-2 right-2",
@@ -627,61 +643,29 @@ var controlPositions = {
627
643
  bottomright: "bottom-2 right-2"
628
644
  };
629
645
  var ZoomControls = (props) => {
630
- return /* @__PURE__ */ _jsxs("div", {
631
- class: `flex flex-row gap-2 ${props.class ?? ""}`,
632
- children: [
633
- /* @__PURE__ */ _jsx2("button", {
634
- type: "button",
635
- class: "dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center",
636
- onClick: () => props.onAction?.("zoom-in"),
637
- title: "Zoom in",
638
- children: /* @__PURE__ */ _jsx2("span", {
639
- class: "text-xl",
640
- children: "+"
641
- })
642
- }),
643
- /* @__PURE__ */ _jsx2("button", {
644
- type: "button",
645
- class: "dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center",
646
- onClick: () => props.onAction?.("zoom-out"),
647
- title: "Zoom out",
648
- children: /* @__PURE__ */ _jsx2("span", {
649
- class: "text-xl",
650
- children: "\u2212"
651
- })
652
- })
653
- ]
654
- });
646
+ return (() => {
647
+ var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
648
+ _el$2.$$click = () => props.onAction?.("zoom-in");
649
+ _el$3.$$click = () => props.onAction?.("zoom-out");
650
+ _$effect(() => _$className(_el$, `flex flex-row gap-2 ${props.class ?? ""}`));
651
+ return _el$;
652
+ })();
655
653
  };
656
654
  var ActionControls = (props) => {
657
- return /* @__PURE__ */ _jsxs("div", {
658
- class: `flex flex-row gap-2 ${props.class ?? ""}`,
659
- children: [
660
- /* @__PURE__ */ _jsx2("button", {
661
- type: "button",
662
- class: "dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center",
663
- onClick: () => props.onAction?.("start"),
664
- title: "Start",
665
- children: /* @__PURE__ */ _jsx2("span", {
666
- class: "text-xl",
667
- children: "\u25B6"
668
- })
669
- }),
670
- /* @__PURE__ */ _jsx2("button", {
671
- type: "button",
672
- class: "dx-button dx-focus-ring w-10 h-10 min-h-[2.5rem] px-3 rounded-xs flex items-center justify-center",
673
- onClick: () => props.onAction?.("toggle"),
674
- title: "Toggle",
675
- children: /* @__PURE__ */ _jsx2("span", {
676
- class: "text-xl",
677
- children: "\u{1F30D}"
678
- })
679
- })
680
- ]
681
- });
655
+ return (() => {
656
+ var _el$4 = _tmpl$2(), _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling;
657
+ _el$5.$$click = () => props.onAction?.("start");
658
+ _el$6.$$click = () => props.onAction?.("toggle");
659
+ _$effect(() => _$className(_el$4, `flex flex-row gap-2 ${props.class ?? ""}`));
660
+ return _el$4;
661
+ })();
682
662
  };
663
+ _$delegateEvents(["click"]);
683
664
 
684
665
  // src/components/Globe/Globe.tsx
666
+ var _tmpl$3 = /* @__PURE__ */ _$template2(`<div>`);
667
+ var _tmpl$22 = /* @__PURE__ */ _$template2(`<canvas>`);
668
+ var _tmpl$32 = /* @__PURE__ */ _$template2(`<div><pre class="font-mono text-xs text-green-700">`);
685
669
  var defaultStyles = {
686
670
  light: {
687
671
  background: {
@@ -742,22 +726,33 @@ var GlobeRoot = (props) => {
742
726
  width: 0,
743
727
  height: 0
744
728
  });
745
- createResizeObserver(() => containerRef, ({ width, height }) => {
729
+ createResizeObserver(() => containerRef, ({
730
+ width,
731
+ height
732
+ }) => {
746
733
  setSize({
747
734
  width,
748
735
  height
749
736
  });
750
737
  });
751
- return /* @__PURE__ */ _jsx3(GlobeContextProvider, {
752
- size: size(),
753
- ...props,
754
- children: /* @__PURE__ */ _jsx3("div", {
755
- ref: containerRef,
756
- class: mx("relative dx-container"),
757
- ...props,
758
- children: props.children
759
- })
760
- });
738
+ return _$createComponent2(GlobeContextProvider, _$mergeProps({
739
+ get size() {
740
+ return size();
741
+ }
742
+ }, props, {
743
+ get children() {
744
+ var _el$ = _tmpl$3();
745
+ var _ref$ = containerRef;
746
+ typeof _ref$ === "function" ? _$use(_ref$, _el$) : containerRef = _el$;
747
+ _$spread(_el$, _$mergeProps({
748
+ get ["class"]() {
749
+ return mx("relative dx-container");
750
+ }
751
+ }, props), false, true);
752
+ _$insert(_el$, () => props.children);
753
+ return _el$;
754
+ }
755
+ }));
761
756
  };
762
757
  var GlobeCanvas = (props) => {
763
758
  const themeMode = "dark";
@@ -767,7 +762,17 @@ var GlobeCanvas = (props) => {
767
762
  const layers = createMemo(() => {
768
763
  return timer(() => createLayers(props.topology, props.features, styles()));
769
764
  });
770
- const { size, center, zoom, translation, rotation, setCenter, setZoom, setTranslation, setRotation } = useGlobeContext();
765
+ const {
766
+ size,
767
+ center,
768
+ zoom,
769
+ translation,
770
+ rotation,
771
+ setCenter,
772
+ setZoom,
773
+ setTranslation,
774
+ setRotation
775
+ } = useGlobeContext();
771
776
  let zoomValue = zoom();
772
777
  let zooming = false;
773
778
  createEffect5(() => {
@@ -828,65 +833,89 @@ var GlobeCanvas = (props) => {
828
833
  const s = size();
829
834
  if (canvasEl && proj && gen) {
830
835
  timer(() => {
831
- proj.scale(Math.min(s.width, s.height) / 2 * z).translate([
832
- s.width / 2 + (t?.x ?? 0),
833
- s.height / 2 + (t?.y ?? 0)
834
- ]).rotate(r ?? [
835
- 0,
836
- 0,
837
- 0
838
- ]);
836
+ proj.scale(Math.min(s.width, s.height) / 2 * z).translate([s.width / 2 + (t?.x ?? 0), s.height / 2 + (t?.y ?? 0)]).rotate(r ?? [0, 0, 0]);
839
837
  renderLayers(gen, layers(), z, styles());
840
838
  });
841
839
  }
842
840
  });
843
- return /* @__PURE__ */ _jsx3(Show, {
844
- when: size().width > 0 && size().height > 0,
845
- children: /* @__PURE__ */ _jsx3("canvas", {
846
- ref: setCanvas,
847
- width: size().width,
848
- height: size().height
849
- })
841
+ return _$createComponent2(Show, {
842
+ get when() {
843
+ return _$memo(() => size().width > 0)() && size().height > 0;
844
+ },
845
+ get children() {
846
+ var _el$2 = _tmpl$22();
847
+ _$use(setCanvas, _el$2);
848
+ _$effect2((_p$) => {
849
+ var _v$ = size().width, _v$2 = size().height;
850
+ _v$ !== _p$.e && _$setAttribute(_el$2, "width", _p$.e = _v$);
851
+ _v$2 !== _p$.t && _$setAttribute(_el$2, "height", _p$.t = _v$2);
852
+ return _p$;
853
+ }, {
854
+ e: void 0,
855
+ t: void 0
856
+ });
857
+ return _el$2;
858
+ }
850
859
  });
851
860
  };
852
861
  var GlobeDebug = (props) => {
853
- const { size, zoom, translation, rotation } = useGlobeContext();
854
- return /* @__PURE__ */ _jsx3("div", {
855
- class: `z-10 absolute w-96 p-2 overflow-hidden border border-green-700 rounded-sm ${controlPositions[props.position ?? "topleft"]}`,
856
- children: /* @__PURE__ */ _jsx3("pre", {
857
- class: "font-mono text-xs text-green-700",
858
- children: JSON.stringify({
859
- size,
860
- zoom: zoom(),
861
- translation: translation(),
862
- rotation: rotation()
863
- }, null, 2)
864
- })
865
- });
862
+ const {
863
+ size,
864
+ zoom,
865
+ translation,
866
+ rotation
867
+ } = useGlobeContext();
868
+ return (() => {
869
+ var _el$3 = _tmpl$32(), _el$4 = _el$3.firstChild;
870
+ _$insert(_el$4, () => JSON.stringify({
871
+ size,
872
+ zoom: zoom(),
873
+ translation: translation(),
874
+ rotation: rotation()
875
+ }, null, 2));
876
+ _$effect2(() => _$className2(_el$3, `z-10 absolute w-96 p-2 overflow-hidden border border-green-700 rounded-sm ${controlPositions[props.position ?? "topleft"]}`));
877
+ return _el$3;
878
+ })();
866
879
  };
867
880
  var GlobePanel = (props) => {
868
- return /* @__PURE__ */ _jsx3("div", {
869
- class: `z-10 absolute overflow-hidden ${controlPositions[props.position ?? "topleft"]} ${props.class ?? ""}`,
870
- children: props.children
871
- });
881
+ return (() => {
882
+ var _el$5 = _tmpl$3();
883
+ _$insert(_el$5, () => props.children);
884
+ _$effect2(() => _$className2(_el$5, `z-10 absolute overflow-hidden ${controlPositions[props.position ?? "topleft"]} ${props.class ?? ""}`));
885
+ return _el$5;
886
+ })();
872
887
  };
873
888
  var CustomControl = (props) => {
874
- return /* @__PURE__ */ _jsx3("div", {
875
- class: `z-10 absolute overflow-hidden ${controlPositions[props.position]}`,
876
- children: props.children
877
- });
889
+ return (() => {
890
+ var _el$6 = _tmpl$3();
891
+ _$insert(_el$6, () => props.children);
892
+ _$effect2(() => _$className2(_el$6, `z-10 absolute overflow-hidden ${controlPositions[props.position]}`));
893
+ return _el$6;
894
+ })();
878
895
  };
879
- var GlobeZoom = (props) => /* @__PURE__ */ _jsx3(CustomControl, {
880
- position: props.position ?? "bottomleft",
881
- children: /* @__PURE__ */ _jsx3(ZoomControls, {
882
- onAction: props.onAction
883
- })
896
+ var GlobeZoom = (props) => _$createComponent2(CustomControl, {
897
+ get position() {
898
+ return props.position ?? "bottomleft";
899
+ },
900
+ get children() {
901
+ return _$createComponent2(ZoomControls, {
902
+ get onAction() {
903
+ return props.onAction;
904
+ }
905
+ });
906
+ }
884
907
  });
885
- var GlobeAction = (props) => /* @__PURE__ */ _jsx3(CustomControl, {
886
- position: props.position ?? "bottomright",
887
- children: /* @__PURE__ */ _jsx3(ActionControls, {
888
- onAction: props.onAction
889
- })
908
+ var GlobeAction = (props) => _$createComponent2(CustomControl, {
909
+ get position() {
910
+ return props.position ?? "bottomright";
911
+ },
912
+ get children() {
913
+ return _$createComponent2(ActionControls, {
914
+ get onAction() {
915
+ return props.onAction;
916
+ }
917
+ });
918
+ }
890
919
  });
891
920
  var Globe = {
892
921
  Root: GlobeRoot,
@@ -898,10 +927,18 @@ var Globe = {
898
927
  };
899
928
 
900
929
  // src/components/Map/Map.tsx
901
- import { jsx as _jsx4, jsxs as _jsxs2 } from "solid-js/jsx-runtime";
930
+ import { template as _$template3 } from "solid-js/web";
931
+ import { memo as _$memo2 } from "solid-js/web";
932
+ import { insert as _$insert2 } from "solid-js/web";
933
+ import { createComponent as _$createComponent3 } from "solid-js/web";
934
+ import { className as _$className3 } from "solid-js/web";
935
+ import { effect as _$effect3 } from "solid-js/web";
936
+ import { use as _$use2 } from "solid-js/web";
902
937
  import "leaflet/dist/leaflet.css";
903
938
  import L, { latLngBounds } from "leaflet";
904
939
  import { Show as Show2, createContext as createContext2, createEffect as createEffect6, createSignal as createSignal5, onCleanup as onCleanup4, onMount, useContext as useContext2 } from "solid-js";
940
+ var _tmpl$4 = /* @__PURE__ */ _$template3(`<div style=z-index:0>`);
941
+ var _tmpl$23 = /* @__PURE__ */ _$template3(`<div style=display:contents>`);
905
942
  var defaults2 = {
906
943
  center: {
907
944
  lat: 51,
@@ -960,30 +997,39 @@ var MapRoot = (props) => {
960
997
  leafletMap.scrollWheelZoom.disable();
961
998
  }
962
999
  });
963
- return /* @__PURE__ */ _jsxs2(MapContext.Provider, {
964
- value: {
965
- map,
966
- attention,
967
- setAttention,
968
- onChange: props.onChange
1000
+ return _$createComponent3(MapContext.Provider, {
1001
+ get value() {
1002
+ return {
1003
+ map,
1004
+ attention,
1005
+ setAttention,
1006
+ onChange: props.onChange
1007
+ };
969
1008
  },
970
- children: [
971
- /* @__PURE__ */ _jsx4("div", {
972
- ref: mapContainer,
973
- class: `group relative grid h-full w-full bg-gray-100 dark:bg-gray-900 ${props.class ?? ""}`,
974
- style: {
975
- "z-index": "0"
1009
+ get children() {
1010
+ return [(() => {
1011
+ var _el$ = _tmpl$4();
1012
+ var _ref$ = mapContainer;
1013
+ typeof _ref$ === "function" ? _$use2(_ref$, _el$) : mapContainer = _el$;
1014
+ _$effect3(() => _$className3(_el$, `group relative grid h-full w-full bg-gray-100 dark:bg-gray-900 ${props.class ?? ""}`));
1015
+ return _el$;
1016
+ })(), _$createComponent3(Show2, {
1017
+ get when() {
1018
+ return map();
1019
+ },
1020
+ get children() {
1021
+ return props.children;
976
1022
  }
977
- }),
978
- /* @__PURE__ */ _jsx4(Show2, {
979
- when: map(),
980
- children: props.children
981
- })
982
- ]
1023
+ })];
1024
+ }
983
1025
  });
984
1026
  };
985
1027
  var MapTiles = () => {
986
- const { map, onChange, attention } = useMapContext(MapTiles.name);
1028
+ const {
1029
+ map,
1030
+ onChange,
1031
+ attention
1032
+ } = useMapContext(MapTiles.name);
987
1033
  let tileLayer = null;
988
1034
  createEffect6(() => {
989
1035
  const leafletMap = map();
@@ -1022,7 +1068,9 @@ var MapTiles = () => {
1022
1068
  return null;
1023
1069
  };
1024
1070
  var MapMarkers = (props) => {
1025
- const { map } = useMapContext(MapMarkers.name);
1071
+ const {
1072
+ map
1073
+ } = useMapContext(MapMarkers.name);
1026
1074
  const leafletMarkers = [];
1027
1075
  let lastMarkerIds = /* @__PURE__ */ new Set();
1028
1076
  onCleanup4(() => {
@@ -1036,9 +1084,7 @@ var MapMarkers = (props) => {
1036
1084
  }
1037
1085
  const markerList = props.markers?.() ?? [];
1038
1086
  const currentIds = new Set(markerList.map((m) => m.id));
1039
- if (currentIds.size === lastMarkerIds.size && [
1040
- ...currentIds
1041
- ].every((id) => lastMarkerIds.has(id)) && leafletMarkers.length > 0) {
1087
+ if (currentIds.size === lastMarkerIds.size && [...currentIds].every((id) => lastMarkerIds.has(id)) && leafletMarkers.length > 0) {
1042
1088
  return;
1043
1089
  }
1044
1090
  leafletMarkers.forEach((marker) => marker.remove());
@@ -1047,28 +1093,19 @@ var MapMarkers = (props) => {
1047
1093
  if (markerList.length > 0) {
1048
1094
  const bounds = latLngBounds(markerList.map((marker) => marker.location));
1049
1095
  leafletMap.fitBounds(bounds);
1050
- markerList.forEach(({ title, location }) => {
1096
+ markerList.forEach(({
1097
+ title,
1098
+ location
1099
+ }) => {
1051
1100
  const marker = L.marker(location, {
1052
1101
  icon: new L.Icon({
1053
1102
  iconUrl: "https://dxos.network/marker-icon.png",
1054
1103
  iconRetinaUrl: "https://dxos.network/marker-icon-2x.png",
1055
1104
  shadowUrl: "https://dxos.network/marker-shadow.png",
1056
- iconSize: [
1057
- 25,
1058
- 41
1059
- ],
1060
- iconAnchor: [
1061
- 12,
1062
- 41
1063
- ],
1064
- popupAnchor: [
1065
- 1,
1066
- -34
1067
- ],
1068
- shadowSize: [
1069
- 41,
1070
- 41
1071
- ]
1105
+ iconSize: [25, 41],
1106
+ iconAnchor: [12, 41],
1107
+ popupAnchor: [1, -34],
1108
+ shadowSize: [41, 41]
1072
1109
  })
1073
1110
  });
1074
1111
  if (title) {
@@ -1084,7 +1121,9 @@ var MapMarkers = (props) => {
1084
1121
  return null;
1085
1122
  };
1086
1123
  var CustomControl2 = (props) => {
1087
- const { map: mapAccessor } = useMapContext(CustomControl2.name);
1124
+ const {
1125
+ map: mapAccessor
1126
+ } = useMapContext(CustomControl2.name);
1088
1127
  let controlContainer;
1089
1128
  createEffect6(() => {
1090
1129
  const map = mapAccessor();
@@ -1110,25 +1149,37 @@ var CustomControl2 = (props) => {
1110
1149
  control.remove();
1111
1150
  });
1112
1151
  });
1113
- return /* @__PURE__ */ _jsx4("div", {
1114
- ref: controlContainer,
1115
- style: {
1116
- display: "contents"
1117
- },
1118
- children: props.children
1119
- });
1152
+ return (() => {
1153
+ var _el$2 = _tmpl$23();
1154
+ var _ref$2 = controlContainer;
1155
+ typeof _ref$2 === "function" ? _$use2(_ref$2, _el$2) : controlContainer = _el$2;
1156
+ _$insert2(_el$2, () => props.children);
1157
+ return _el$2;
1158
+ })();
1120
1159
  };
1121
- var MapZoom = (props) => /* @__PURE__ */ _jsx4(CustomControl2, {
1122
- position: props.position ?? "bottomleft",
1123
- children: /* @__PURE__ */ _jsx4(ZoomControls, {
1124
- onAction: props.onAction
1125
- })
1160
+ var MapZoom = (props) => _$createComponent3(CustomControl2, {
1161
+ get position() {
1162
+ return props.position ?? "bottomleft";
1163
+ },
1164
+ get children() {
1165
+ return _$createComponent3(ZoomControls, {
1166
+ get onAction() {
1167
+ return props.onAction;
1168
+ }
1169
+ });
1170
+ }
1126
1171
  });
1127
- var MapAction = (props) => /* @__PURE__ */ _jsx4(CustomControl2, {
1128
- position: props.position ?? "bottomright",
1129
- children: /* @__PURE__ */ _jsx4(ActionControls, {
1130
- onAction: props.onAction
1131
- })
1172
+ var MapAction = (props) => _$createComponent3(CustomControl2, {
1173
+ get position() {
1174
+ return props.position ?? "bottomright";
1175
+ },
1176
+ get children() {
1177
+ return _$createComponent3(ActionControls, {
1178
+ get onAction() {
1179
+ return props.onAction;
1180
+ }
1181
+ });
1182
+ }
1132
1183
  });
1133
1184
  var Map = {
1134
1185
  Root: MapRoot,