magick-ui 0.2.3 → 0.2.4

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/ui/index.cjs CHANGED
@@ -3735,33 +3735,61 @@ function MarkerWithInfo({
3735
3735
  setOpen((prev) => !prev);
3736
3736
  onMarkerClick?.(marker, index);
3737
3737
  }, [marker, index, onMarkerClick]);
3738
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
3739
- import_react_google_maps.AdvancedMarker,
3738
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
3739
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3740
+ import_react_google_maps.Marker,
3741
+ {
3742
+ position: { lat: marker.lat, lng: marker.lng },
3743
+ title: marker.title,
3744
+ onClick: handleClick
3745
+ }
3746
+ ),
3747
+ open && (marker.title || marker.description) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3748
+ import_react_google_maps.InfoWindow,
3749
+ {
3750
+ position: { lat: marker.lat, lng: marker.lng },
3751
+ onCloseClick: () => setOpen(false),
3752
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "max-w-xs", children: [
3753
+ marker.title && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("h3", { className: "text-body-sm font-semibold", children: marker.title }),
3754
+ marker.description && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-body-sm text-element-inverse-gray mt-1", children: marker.description })
3755
+ ] })
3756
+ }
3757
+ )
3758
+ ] });
3759
+ }
3760
+ var CURRENT_LOCATION_ICON = {
3761
+ path: 0,
3762
+ // google.maps.SymbolPath.CIRCLE
3763
+ scale: 8,
3764
+ fillColor: "#4285F4",
3765
+ fillOpacity: 1,
3766
+ strokeColor: "#ffffff",
3767
+ strokeWeight: 2.5
3768
+ };
3769
+ function CurrentLocationMarker() {
3770
+ const map = (0, import_react_google_maps.useMap)();
3771
+ const [position, setPosition] = (0, import_react7.useState)(null);
3772
+ (0, import_react7.useEffect)(() => {
3773
+ if (!navigator.geolocation) return;
3774
+ const watchId = navigator.geolocation.watchPosition(
3775
+ (pos) => {
3776
+ const coords = { lat: pos.coords.latitude, lng: pos.coords.longitude };
3777
+ setPosition(coords);
3778
+ },
3779
+ () => {
3780
+ },
3781
+ { enableHighAccuracy: true, maximumAge: 1e4 }
3782
+ );
3783
+ return () => navigator.geolocation.clearWatch(watchId);
3784
+ }, [map]);
3785
+ if (!position) return null;
3786
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3787
+ import_react_google_maps.Marker,
3740
3788
  {
3741
- position: { lat: marker.lat, lng: marker.lng },
3742
- title: marker.title,
3743
- onClick: handleClick,
3744
- children: [
3745
- marker.color && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3746
- import_react_google_maps.Pin,
3747
- {
3748
- background: marker.color,
3749
- borderColor: marker.color,
3750
- glyphColor: "#fff"
3751
- }
3752
- ),
3753
- open && (marker.title || marker.description) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3754
- import_react_google_maps.InfoWindow,
3755
- {
3756
- position: { lat: marker.lat, lng: marker.lng },
3757
- onCloseClick: () => setOpen(false),
3758
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "max-w-xs", children: [
3759
- marker.title && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("h3", { className: "text-body-sm font-semibold", children: marker.title }),
3760
- marker.description && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-body-sm text-element-inverse-gray mt-1", children: marker.description })
3761
- ] })
3762
- }
3763
- )
3764
- ]
3789
+ position,
3790
+ title: "Your location",
3791
+ icon: CURRENT_LOCATION_ICON,
3792
+ clickable: false
3765
3793
  }
3766
3794
  );
3767
3795
  }
@@ -3777,6 +3805,7 @@ function GoogleMapView({
3777
3805
  className,
3778
3806
  gestureHandling = "cooperative",
3779
3807
  disableDefaultUI = false,
3808
+ showCurrentLocation = false,
3780
3809
  onMarkerClick
3781
3810
  }) {
3782
3811
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_google_maps.APIProvider, { apiKey, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
@@ -3784,7 +3813,7 @@ function GoogleMapView({
3784
3813
  {
3785
3814
  className: cn("overflow-hidden rounded-unit-corner-radius-xl", className),
3786
3815
  style: { height, width },
3787
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3816
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
3788
3817
  import_react_google_maps.Map,
3789
3818
  {
3790
3819
  defaultCenter: center,
@@ -3793,15 +3822,18 @@ function GoogleMapView({
3793
3822
  gestureHandling,
3794
3823
  disableDefaultUI,
3795
3824
  style: { width: "100%", height: "100%" },
3796
- children: markers.map((marker, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3797
- MarkerWithInfo,
3798
- {
3799
- marker,
3800
- index: i,
3801
- onMarkerClick
3802
- },
3803
- `${marker.lat}-${marker.lng}-${i}`
3804
- ))
3825
+ children: [
3826
+ showCurrentLocation && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CurrentLocationMarker, {}),
3827
+ markers.map((marker, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3828
+ MarkerWithInfo,
3829
+ {
3830
+ marker,
3831
+ index: i,
3832
+ onMarkerClick
3833
+ },
3834
+ `${marker.lat}-${marker.lng}-${i}`
3835
+ ))
3836
+ ]
3805
3837
  }
3806
3838
  )
3807
3839
  }