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/ui/index.cjs
CHANGED
|
@@ -3759,7 +3759,6 @@ function MarkerWithInfo({
|
|
|
3759
3759
|
}
|
|
3760
3760
|
var CURRENT_LOCATION_ICON = {
|
|
3761
3761
|
path: 0,
|
|
3762
|
-
// google.maps.SymbolPath.CIRCLE
|
|
3763
3762
|
scale: 8,
|
|
3764
3763
|
fillColor: "#4285F4",
|
|
3765
3764
|
fillOpacity: 1,
|
|
@@ -3793,12 +3792,51 @@ function CurrentLocationMarker() {
|
|
|
3793
3792
|
}
|
|
3794
3793
|
);
|
|
3795
3794
|
}
|
|
3795
|
+
function PlaceSearch({
|
|
3796
|
+
placeholder = "Search places...",
|
|
3797
|
+
onPlaceSelect
|
|
3798
|
+
}) {
|
|
3799
|
+
const map = (0, import_react_google_maps.useMap)();
|
|
3800
|
+
const placesLib = (0, import_react_google_maps.useMapsLibrary)("places");
|
|
3801
|
+
const inputRef = (0, import_react7.useRef)(null);
|
|
3802
|
+
const autocompleteRef = (0, import_react7.useRef)(null);
|
|
3803
|
+
(0, import_react7.useEffect)(() => {
|
|
3804
|
+
if (!placesLib || !inputRef.current || autocompleteRef.current) return;
|
|
3805
|
+
const autocomplete = new placesLib.Autocomplete(inputRef.current, {
|
|
3806
|
+
fields: ["geometry", "name", "formatted_address"]
|
|
3807
|
+
});
|
|
3808
|
+
autocomplete.addListener("place_changed", () => {
|
|
3809
|
+
const place = autocomplete.getPlace();
|
|
3810
|
+
if (!place.geometry?.location) return;
|
|
3811
|
+
const lat = place.geometry.location.lat();
|
|
3812
|
+
const lng = place.geometry.location.lng();
|
|
3813
|
+
map?.panTo({ lat, lng });
|
|
3814
|
+
map?.setZoom(15);
|
|
3815
|
+
onPlaceSelect?.({
|
|
3816
|
+
lat,
|
|
3817
|
+
lng,
|
|
3818
|
+
name: place.name ?? "",
|
|
3819
|
+
address: place.formatted_address ?? ""
|
|
3820
|
+
});
|
|
3821
|
+
});
|
|
3822
|
+
autocompleteRef.current = autocomplete;
|
|
3823
|
+
}, [placesLib, map, onPlaceSelect]);
|
|
3824
|
+
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)(
|
|
3825
|
+
"input",
|
|
3826
|
+
{
|
|
3827
|
+
ref: inputRef,
|
|
3828
|
+
type: "text",
|
|
3829
|
+
placeholder,
|
|
3830
|
+
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"
|
|
3831
|
+
}
|
|
3832
|
+
) });
|
|
3833
|
+
}
|
|
3796
3834
|
var DEFAULT_CENTER = { lat: 16.8661, lng: 96.1951 };
|
|
3797
3835
|
function GoogleMapView({
|
|
3798
3836
|
apiKey,
|
|
3799
3837
|
center = DEFAULT_CENTER,
|
|
3800
3838
|
zoom = 12,
|
|
3801
|
-
markers = [],
|
|
3839
|
+
markers: initialMarkers = [],
|
|
3802
3840
|
mapId,
|
|
3803
3841
|
height = "400px",
|
|
3804
3842
|
width = "100%",
|
|
@@ -3806,36 +3844,62 @@ function GoogleMapView({
|
|
|
3806
3844
|
gestureHandling = "cooperative",
|
|
3807
3845
|
disableDefaultUI = false,
|
|
3808
3846
|
showCurrentLocation = false,
|
|
3809
|
-
|
|
3847
|
+
showSearch = false,
|
|
3848
|
+
searchPlaceholder,
|
|
3849
|
+
onMarkerClick,
|
|
3850
|
+
onPlaceSelect
|
|
3810
3851
|
}) {
|
|
3811
|
-
|
|
3852
|
+
const [searchMarker, setSearchMarker] = (0, import_react7.useState)(null);
|
|
3853
|
+
const handlePlaceSelect = (0, import_react7.useCallback)(
|
|
3854
|
+
(place) => {
|
|
3855
|
+
setSearchMarker({
|
|
3856
|
+
lat: place.lat,
|
|
3857
|
+
lng: place.lng,
|
|
3858
|
+
title: place.name,
|
|
3859
|
+
description: place.address
|
|
3860
|
+
});
|
|
3861
|
+
onPlaceSelect?.(place);
|
|
3862
|
+
},
|
|
3863
|
+
[onPlaceSelect]
|
|
3864
|
+
);
|
|
3865
|
+
const allMarkers = searchMarker ? [...initialMarkers, searchMarker] : initialMarkers;
|
|
3866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_google_maps.APIProvider, { apiKey, libraries: showSearch ? ["places"] : [], children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
3812
3867
|
"div",
|
|
3813
3868
|
{
|
|
3814
|
-
className: cn("overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
3869
|
+
className: cn("relative overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
3815
3870
|
style: { height, width },
|
|
3816
|
-
children:
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3871
|
+
children: [
|
|
3872
|
+
showSearch && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3873
|
+
PlaceSearch,
|
|
3874
|
+
{
|
|
3875
|
+
placeholder: searchPlaceholder,
|
|
3876
|
+
onPlaceSelect: handlePlaceSelect
|
|
3877
|
+
}
|
|
3878
|
+
),
|
|
3879
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
3880
|
+
import_react_google_maps.Map,
|
|
3881
|
+
{
|
|
3882
|
+
defaultCenter: center,
|
|
3883
|
+
defaultZoom: zoom,
|
|
3884
|
+
mapId,
|
|
3885
|
+
gestureHandling,
|
|
3886
|
+
disableDefaultUI,
|
|
3887
|
+
style: { width: "100%", height: "100%" },
|
|
3888
|
+
children: [
|
|
3889
|
+
showCurrentLocation && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CurrentLocationMarker, {}),
|
|
3890
|
+
allMarkers.map((marker, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3891
|
+
MarkerWithInfo,
|
|
3892
|
+
{
|
|
3893
|
+
marker,
|
|
3894
|
+
index: i,
|
|
3895
|
+
onMarkerClick
|
|
3896
|
+
},
|
|
3897
|
+
`${marker.lat}-${marker.lng}-${i}`
|
|
3898
|
+
))
|
|
3899
|
+
]
|
|
3900
|
+
}
|
|
3901
|
+
)
|
|
3902
|
+
]
|
|
3839
3903
|
}
|
|
3840
3904
|
) });
|
|
3841
3905
|
}
|