magick-ui 0.2.3 → 0.2.5

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/index.cjs CHANGED
@@ -3444,6 +3444,10 @@ var component_schema_default = {
3444
3444
  disableDefaultUI: {
3445
3445
  type: "boolean",
3446
3446
  description: "Hide default map controls"
3447
+ },
3448
+ showCurrentLocation: {
3449
+ type: "boolean",
3450
+ description: "Show a blue dot for the user's current location"
3447
3451
  }
3448
3452
  },
3449
3453
  additionalProperties: false
@@ -5655,7 +5659,8 @@ var googleMapSchema = import_zod46.z.object({
5655
5659
  height: import_zod46.z.string().optional().describe("Map height CSS value. Defaults to '400px'"),
5656
5660
  width: import_zod46.z.string().optional().describe("Map width CSS value. Defaults to '100%'"),
5657
5661
  gestureHandling: import_zod46.z.enum(["cooperative", "greedy", "none", "auto"]).optional().describe("How the map handles touch/scroll gestures. Defaults to 'cooperative'"),
5658
- disableDefaultUI: import_zod46.z.boolean().optional().describe("Hide default map controls")
5662
+ disableDefaultUI: import_zod46.z.boolean().optional().describe("Hide default map controls"),
5663
+ showCurrentLocation: import_zod46.z.boolean().optional().describe("Show a blue dot for the user's current location")
5659
5664
  })
5660
5665
  }).describe("An interactive Google Map with optional markers and info windows");
5661
5666
 
@@ -9556,33 +9561,61 @@ function MarkerWithInfo({
9556
9561
  setOpen((prev) => !prev);
9557
9562
  onMarkerClick?.(marker, index);
9558
9563
  }, [marker, index, onMarkerClick]);
9559
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
9560
- import_react_google_maps.AdvancedMarker,
9564
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
9565
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9566
+ import_react_google_maps.Marker,
9567
+ {
9568
+ position: { lat: marker.lat, lng: marker.lng },
9569
+ title: marker.title,
9570
+ onClick: handleClick
9571
+ }
9572
+ ),
9573
+ open && (marker.title || marker.description) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9574
+ import_react_google_maps.InfoWindow,
9575
+ {
9576
+ position: { lat: marker.lat, lng: marker.lng },
9577
+ onCloseClick: () => setOpen(false),
9578
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "max-w-xs", children: [
9579
+ marker.title && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("h3", { className: "text-body-sm font-semibold", children: marker.title }),
9580
+ marker.description && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-body-sm text-element-inverse-gray mt-1", children: marker.description })
9581
+ ] })
9582
+ }
9583
+ )
9584
+ ] });
9585
+ }
9586
+ var CURRENT_LOCATION_ICON = {
9587
+ path: 0,
9588
+ // google.maps.SymbolPath.CIRCLE
9589
+ scale: 8,
9590
+ fillColor: "#4285F4",
9591
+ fillOpacity: 1,
9592
+ strokeColor: "#ffffff",
9593
+ strokeWeight: 2.5
9594
+ };
9595
+ function CurrentLocationMarker() {
9596
+ const map = (0, import_react_google_maps.useMap)();
9597
+ const [position, setPosition] = (0, import_react7.useState)(null);
9598
+ (0, import_react7.useEffect)(() => {
9599
+ if (!navigator.geolocation) return;
9600
+ const watchId = navigator.geolocation.watchPosition(
9601
+ (pos) => {
9602
+ const coords = { lat: pos.coords.latitude, lng: pos.coords.longitude };
9603
+ setPosition(coords);
9604
+ },
9605
+ () => {
9606
+ },
9607
+ { enableHighAccuracy: true, maximumAge: 1e4 }
9608
+ );
9609
+ return () => navigator.geolocation.clearWatch(watchId);
9610
+ }, [map]);
9611
+ if (!position) return null;
9612
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9613
+ import_react_google_maps.Marker,
9561
9614
  {
9562
- position: { lat: marker.lat, lng: marker.lng },
9563
- title: marker.title,
9564
- onClick: handleClick,
9565
- children: [
9566
- marker.color && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9567
- import_react_google_maps.Pin,
9568
- {
9569
- background: marker.color,
9570
- borderColor: marker.color,
9571
- glyphColor: "#fff"
9572
- }
9573
- ),
9574
- open && (marker.title || marker.description) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9575
- import_react_google_maps.InfoWindow,
9576
- {
9577
- position: { lat: marker.lat, lng: marker.lng },
9578
- onCloseClick: () => setOpen(false),
9579
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "max-w-xs", children: [
9580
- marker.title && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("h3", { className: "text-body-sm font-semibold", children: marker.title }),
9581
- marker.description && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-body-sm text-element-inverse-gray mt-1", children: marker.description })
9582
- ] })
9583
- }
9584
- )
9585
- ]
9615
+ position,
9616
+ title: "Your location",
9617
+ icon: CURRENT_LOCATION_ICON,
9618
+ clickable: false
9586
9619
  }
9587
9620
  );
9588
9621
  }
@@ -9598,6 +9631,7 @@ function GoogleMapView({
9598
9631
  className,
9599
9632
  gestureHandling = "cooperative",
9600
9633
  disableDefaultUI = false,
9634
+ showCurrentLocation = false,
9601
9635
  onMarkerClick
9602
9636
  }) {
9603
9637
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_google_maps.APIProvider, { apiKey, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
@@ -9605,7 +9639,7 @@ function GoogleMapView({
9605
9639
  {
9606
9640
  className: cn("overflow-hidden rounded-unit-corner-radius-xl", className),
9607
9641
  style: { height, width },
9608
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9642
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
9609
9643
  import_react_google_maps.Map,
9610
9644
  {
9611
9645
  defaultCenter: center,
@@ -9614,15 +9648,18 @@ function GoogleMapView({
9614
9648
  gestureHandling,
9615
9649
  disableDefaultUI,
9616
9650
  style: { width: "100%", height: "100%" },
9617
- children: markers.map((marker, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9618
- MarkerWithInfo,
9619
- {
9620
- marker,
9621
- index: i,
9622
- onMarkerClick
9623
- },
9624
- `${marker.lat}-${marker.lng}-${i}`
9625
- ))
9651
+ children: [
9652
+ showCurrentLocation && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CurrentLocationMarker, {}),
9653
+ markers.map((marker, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9654
+ MarkerWithInfo,
9655
+ {
9656
+ marker,
9657
+ index: i,
9658
+ onMarkerClick
9659
+ },
9660
+ `${marker.lat}-${marker.lng}-${i}`
9661
+ ))
9662
+ ]
9626
9663
  }
9627
9664
  )
9628
9665
  }