magick-ui 0.2.5 → 0.2.6
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 +103 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +108 -33
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +11 -1
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +20 -0
- package/dist/schema.d.ts +20 -0
- package/dist/schema.js +11 -1
- package/dist/schema.js.map +1 -1
- package/dist/ui/index.cjs +92 -28
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +9 -1
- package/dist/ui/index.d.ts +9 -1
- package/dist/ui/index.js +97 -32
- package/dist/ui/index.js.map +1 -1
- package/package.json +2 -1
- package/schema/component-schema.json +8 -0
package/dist/index.cjs
CHANGED
|
@@ -3448,6 +3448,14 @@ var component_schema_default = {
|
|
|
3448
3448
|
showCurrentLocation: {
|
|
3449
3449
|
type: "boolean",
|
|
3450
3450
|
description: "Show a blue dot for the user's current location"
|
|
3451
|
+
},
|
|
3452
|
+
showSearch: {
|
|
3453
|
+
type: "boolean",
|
|
3454
|
+
description: "Show a search box to find places on the map"
|
|
3455
|
+
},
|
|
3456
|
+
searchPlaceholder: {
|
|
3457
|
+
type: "string",
|
|
3458
|
+
description: "Placeholder text for the search box"
|
|
3451
3459
|
}
|
|
3452
3460
|
},
|
|
3453
3461
|
additionalProperties: false
|
|
@@ -5660,7 +5668,9 @@ var googleMapSchema = import_zod46.z.object({
|
|
|
5660
5668
|
width: import_zod46.z.string().optional().describe("Map width CSS value. Defaults to '100%'"),
|
|
5661
5669
|
gestureHandling: import_zod46.z.enum(["cooperative", "greedy", "none", "auto"]).optional().describe("How the map handles touch/scroll gestures. Defaults to 'cooperative'"),
|
|
5662
5670
|
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")
|
|
5671
|
+
showCurrentLocation: import_zod46.z.boolean().optional().describe("Show a blue dot for the user's current location"),
|
|
5672
|
+
showSearch: import_zod46.z.boolean().optional().describe("Show a search box to find places on the map"),
|
|
5673
|
+
searchPlaceholder: import_zod46.z.string().optional().describe("Placeholder text for the search box")
|
|
5664
5674
|
})
|
|
5665
5675
|
}).describe("An interactive Google Map with optional markers and info windows");
|
|
5666
5676
|
|
|
@@ -9585,7 +9595,6 @@ function MarkerWithInfo({
|
|
|
9585
9595
|
}
|
|
9586
9596
|
var CURRENT_LOCATION_ICON = {
|
|
9587
9597
|
path: 0,
|
|
9588
|
-
// google.maps.SymbolPath.CIRCLE
|
|
9589
9598
|
scale: 8,
|
|
9590
9599
|
fillColor: "#4285F4",
|
|
9591
9600
|
fillOpacity: 1,
|
|
@@ -9619,12 +9628,51 @@ function CurrentLocationMarker() {
|
|
|
9619
9628
|
}
|
|
9620
9629
|
);
|
|
9621
9630
|
}
|
|
9631
|
+
function PlaceSearch({
|
|
9632
|
+
placeholder = "Search places...",
|
|
9633
|
+
onPlaceSelect
|
|
9634
|
+
}) {
|
|
9635
|
+
const map = (0, import_react_google_maps.useMap)();
|
|
9636
|
+
const placesLib = (0, import_react_google_maps.useMapsLibrary)("places");
|
|
9637
|
+
const inputRef = (0, import_react7.useRef)(null);
|
|
9638
|
+
const autocompleteRef = (0, import_react7.useRef)(null);
|
|
9639
|
+
(0, import_react7.useEffect)(() => {
|
|
9640
|
+
if (!placesLib || !inputRef.current || autocompleteRef.current) return;
|
|
9641
|
+
const autocomplete = new placesLib.Autocomplete(inputRef.current, {
|
|
9642
|
+
fields: ["geometry", "name", "formatted_address"]
|
|
9643
|
+
});
|
|
9644
|
+
autocomplete.addListener("place_changed", () => {
|
|
9645
|
+
const place = autocomplete.getPlace();
|
|
9646
|
+
if (!place.geometry?.location) return;
|
|
9647
|
+
const lat = place.geometry.location.lat();
|
|
9648
|
+
const lng = place.geometry.location.lng();
|
|
9649
|
+
map?.panTo({ lat, lng });
|
|
9650
|
+
map?.setZoom(15);
|
|
9651
|
+
onPlaceSelect?.({
|
|
9652
|
+
lat,
|
|
9653
|
+
lng,
|
|
9654
|
+
name: place.name ?? "",
|
|
9655
|
+
address: place.formatted_address ?? ""
|
|
9656
|
+
});
|
|
9657
|
+
});
|
|
9658
|
+
autocompleteRef.current = autocomplete;
|
|
9659
|
+
}, [placesLib, map, onPlaceSelect]);
|
|
9660
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "absolute top-3 left-1/2 z-10 w-[min(90%,360px)] -translate-x-1/2", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
9661
|
+
"input",
|
|
9662
|
+
{
|
|
9663
|
+
ref: inputRef,
|
|
9664
|
+
type: "text",
|
|
9665
|
+
placeholder,
|
|
9666
|
+
className: "w-full rounded-lg border border-gray-300 bg-white px-4 py-2.5 text-sm shadow-md outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20"
|
|
9667
|
+
}
|
|
9668
|
+
) });
|
|
9669
|
+
}
|
|
9622
9670
|
var DEFAULT_CENTER = { lat: 16.8661, lng: 96.1951 };
|
|
9623
9671
|
function GoogleMapView({
|
|
9624
9672
|
apiKey,
|
|
9625
9673
|
center = DEFAULT_CENTER,
|
|
9626
9674
|
zoom = 12,
|
|
9627
|
-
markers = [],
|
|
9675
|
+
markers: initialMarkers = [],
|
|
9628
9676
|
mapId,
|
|
9629
9677
|
height = "400px",
|
|
9630
9678
|
width = "100%",
|
|
@@ -9632,36 +9680,62 @@ function GoogleMapView({
|
|
|
9632
9680
|
gestureHandling = "cooperative",
|
|
9633
9681
|
disableDefaultUI = false,
|
|
9634
9682
|
showCurrentLocation = false,
|
|
9635
|
-
|
|
9683
|
+
showSearch = false,
|
|
9684
|
+
searchPlaceholder,
|
|
9685
|
+
onMarkerClick,
|
|
9686
|
+
onPlaceSelect
|
|
9636
9687
|
}) {
|
|
9637
|
-
|
|
9688
|
+
const [searchMarker, setSearchMarker] = (0, import_react7.useState)(null);
|
|
9689
|
+
const handlePlaceSelect = (0, import_react7.useCallback)(
|
|
9690
|
+
(place) => {
|
|
9691
|
+
setSearchMarker({
|
|
9692
|
+
lat: place.lat,
|
|
9693
|
+
lng: place.lng,
|
|
9694
|
+
title: place.name,
|
|
9695
|
+
description: place.address
|
|
9696
|
+
});
|
|
9697
|
+
onPlaceSelect?.(place);
|
|
9698
|
+
},
|
|
9699
|
+
[onPlaceSelect]
|
|
9700
|
+
);
|
|
9701
|
+
const allMarkers = searchMarker ? [...initialMarkers, searchMarker] : initialMarkers;
|
|
9702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_google_maps.APIProvider, { apiKey, libraries: showSearch ? ["places"] : [], children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
9638
9703
|
"div",
|
|
9639
9704
|
{
|
|
9640
|
-
className: cn("overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
9705
|
+
className: cn("relative overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
9641
9706
|
style: { height, width },
|
|
9642
|
-
children:
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9707
|
+
children: [
|
|
9708
|
+
showSearch && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
9709
|
+
PlaceSearch,
|
|
9710
|
+
{
|
|
9711
|
+
placeholder: searchPlaceholder,
|
|
9712
|
+
onPlaceSelect: handlePlaceSelect
|
|
9713
|
+
}
|
|
9714
|
+
),
|
|
9715
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
9716
|
+
import_react_google_maps.Map,
|
|
9717
|
+
{
|
|
9718
|
+
defaultCenter: center,
|
|
9719
|
+
defaultZoom: zoom,
|
|
9720
|
+
mapId,
|
|
9721
|
+
gestureHandling,
|
|
9722
|
+
disableDefaultUI,
|
|
9723
|
+
style: { width: "100%", height: "100%" },
|
|
9724
|
+
children: [
|
|
9725
|
+
showCurrentLocation && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CurrentLocationMarker, {}),
|
|
9726
|
+
allMarkers.map((marker, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
9727
|
+
MarkerWithInfo,
|
|
9728
|
+
{
|
|
9729
|
+
marker,
|
|
9730
|
+
index: i,
|
|
9731
|
+
onMarkerClick
|
|
9732
|
+
},
|
|
9733
|
+
`${marker.lat}-${marker.lng}-${i}`
|
|
9734
|
+
))
|
|
9735
|
+
]
|
|
9736
|
+
}
|
|
9737
|
+
)
|
|
9738
|
+
]
|
|
9665
9739
|
}
|
|
9666
9740
|
) });
|
|
9667
9741
|
}
|