magick-ui 0.2.4 → 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.d.cts
CHANGED
|
@@ -602,9 +602,17 @@ interface MapProps {
|
|
|
602
602
|
gestureHandling?: "cooperative" | "greedy" | "none" | "auto";
|
|
603
603
|
disableDefaultUI?: boolean;
|
|
604
604
|
showCurrentLocation?: boolean;
|
|
605
|
+
showSearch?: boolean;
|
|
606
|
+
searchPlaceholder?: string;
|
|
605
607
|
onMarkerClick?: (marker: MapMarker, index: number) => void;
|
|
608
|
+
onPlaceSelect?: (place: {
|
|
609
|
+
lat: number;
|
|
610
|
+
lng: number;
|
|
611
|
+
name: string;
|
|
612
|
+
address: string;
|
|
613
|
+
}) => void;
|
|
606
614
|
}
|
|
607
|
-
declare function GoogleMapView({ apiKey, center, zoom, markers, mapId, height, width, className, gestureHandling, disableDefaultUI, showCurrentLocation, onMarkerClick, }: MapProps): react_jsx_runtime.JSX.Element;
|
|
615
|
+
declare function GoogleMapView({ apiKey, center, zoom, markers: initialMarkers, mapId, height, width, className, gestureHandling, disableDefaultUI, showCurrentLocation, showSearch, searchPlaceholder, onMarkerClick, onPlaceSelect, }: MapProps): react_jsx_runtime.JSX.Element;
|
|
608
616
|
|
|
609
617
|
interface MediaProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof mediaVariants> {
|
|
610
618
|
src: string;
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -602,9 +602,17 @@ interface MapProps {
|
|
|
602
602
|
gestureHandling?: "cooperative" | "greedy" | "none" | "auto";
|
|
603
603
|
disableDefaultUI?: boolean;
|
|
604
604
|
showCurrentLocation?: boolean;
|
|
605
|
+
showSearch?: boolean;
|
|
606
|
+
searchPlaceholder?: string;
|
|
605
607
|
onMarkerClick?: (marker: MapMarker, index: number) => void;
|
|
608
|
+
onPlaceSelect?: (place: {
|
|
609
|
+
lat: number;
|
|
610
|
+
lng: number;
|
|
611
|
+
name: string;
|
|
612
|
+
address: string;
|
|
613
|
+
}) => void;
|
|
606
614
|
}
|
|
607
|
-
declare function GoogleMapView({ apiKey, center, zoom, markers, mapId, height, width, className, gestureHandling, disableDefaultUI, showCurrentLocation, onMarkerClick, }: MapProps): react_jsx_runtime.JSX.Element;
|
|
615
|
+
declare function GoogleMapView({ apiKey, center, zoom, markers: initialMarkers, mapId, height, width, className, gestureHandling, disableDefaultUI, showCurrentLocation, showSearch, searchPlaceholder, onMarkerClick, onPlaceSelect, }: MapProps): react_jsx_runtime.JSX.Element;
|
|
608
616
|
|
|
609
617
|
interface MediaProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof mediaVariants> {
|
|
610
618
|
src: string;
|
package/dist/ui/index.js
CHANGED
|
@@ -3610,9 +3610,10 @@ import {
|
|
|
3610
3610
|
Map as GoogleMap,
|
|
3611
3611
|
Marker,
|
|
3612
3612
|
InfoWindow,
|
|
3613
|
-
useMap
|
|
3613
|
+
useMap,
|
|
3614
|
+
useMapsLibrary
|
|
3614
3615
|
} from "@vis.gl/react-google-maps";
|
|
3615
|
-
import { useState as useState6, useCallback as useCallback3, useEffect as useEffect5 } from "react";
|
|
3616
|
+
import { useState as useState6, useCallback as useCallback3, useEffect as useEffect5, useRef as useRef6 } from "react";
|
|
3616
3617
|
import { Fragment as Fragment5, jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3617
3618
|
function MarkerWithInfo({
|
|
3618
3619
|
marker,
|
|
@@ -3648,7 +3649,6 @@ function MarkerWithInfo({
|
|
|
3648
3649
|
}
|
|
3649
3650
|
var CURRENT_LOCATION_ICON = {
|
|
3650
3651
|
path: 0,
|
|
3651
|
-
// google.maps.SymbolPath.CIRCLE
|
|
3652
3652
|
scale: 8,
|
|
3653
3653
|
fillColor: "#4285F4",
|
|
3654
3654
|
fillOpacity: 1,
|
|
@@ -3682,12 +3682,51 @@ function CurrentLocationMarker() {
|
|
|
3682
3682
|
}
|
|
3683
3683
|
);
|
|
3684
3684
|
}
|
|
3685
|
+
function PlaceSearch({
|
|
3686
|
+
placeholder = "Search places...",
|
|
3687
|
+
onPlaceSelect
|
|
3688
|
+
}) {
|
|
3689
|
+
const map = useMap();
|
|
3690
|
+
const placesLib = useMapsLibrary("places");
|
|
3691
|
+
const inputRef = useRef6(null);
|
|
3692
|
+
const autocompleteRef = useRef6(null);
|
|
3693
|
+
useEffect5(() => {
|
|
3694
|
+
if (!placesLib || !inputRef.current || autocompleteRef.current) return;
|
|
3695
|
+
const autocomplete = new placesLib.Autocomplete(inputRef.current, {
|
|
3696
|
+
fields: ["geometry", "name", "formatted_address"]
|
|
3697
|
+
});
|
|
3698
|
+
autocomplete.addListener("place_changed", () => {
|
|
3699
|
+
const place = autocomplete.getPlace();
|
|
3700
|
+
if (!place.geometry?.location) return;
|
|
3701
|
+
const lat = place.geometry.location.lat();
|
|
3702
|
+
const lng = place.geometry.location.lng();
|
|
3703
|
+
map?.panTo({ lat, lng });
|
|
3704
|
+
map?.setZoom(15);
|
|
3705
|
+
onPlaceSelect?.({
|
|
3706
|
+
lat,
|
|
3707
|
+
lng,
|
|
3708
|
+
name: place.name ?? "",
|
|
3709
|
+
address: place.formatted_address ?? ""
|
|
3710
|
+
});
|
|
3711
|
+
});
|
|
3712
|
+
autocompleteRef.current = autocomplete;
|
|
3713
|
+
}, [placesLib, map, onPlaceSelect]);
|
|
3714
|
+
return /* @__PURE__ */ jsx34("div", { className: "absolute top-3 left-1/2 z-10 w-[min(90%,360px)] -translate-x-1/2", children: /* @__PURE__ */ jsx34(
|
|
3715
|
+
"input",
|
|
3716
|
+
{
|
|
3717
|
+
ref: inputRef,
|
|
3718
|
+
type: "text",
|
|
3719
|
+
placeholder,
|
|
3720
|
+
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"
|
|
3721
|
+
}
|
|
3722
|
+
) });
|
|
3723
|
+
}
|
|
3685
3724
|
var DEFAULT_CENTER = { lat: 16.8661, lng: 96.1951 };
|
|
3686
3725
|
function GoogleMapView({
|
|
3687
3726
|
apiKey,
|
|
3688
3727
|
center = DEFAULT_CENTER,
|
|
3689
3728
|
zoom = 12,
|
|
3690
|
-
markers = [],
|
|
3729
|
+
markers: initialMarkers = [],
|
|
3691
3730
|
mapId,
|
|
3692
3731
|
height = "400px",
|
|
3693
3732
|
width = "100%",
|
|
@@ -3695,36 +3734,62 @@ function GoogleMapView({
|
|
|
3695
3734
|
gestureHandling = "cooperative",
|
|
3696
3735
|
disableDefaultUI = false,
|
|
3697
3736
|
showCurrentLocation = false,
|
|
3698
|
-
|
|
3737
|
+
showSearch = false,
|
|
3738
|
+
searchPlaceholder,
|
|
3739
|
+
onMarkerClick,
|
|
3740
|
+
onPlaceSelect
|
|
3699
3741
|
}) {
|
|
3700
|
-
|
|
3742
|
+
const [searchMarker, setSearchMarker] = useState6(null);
|
|
3743
|
+
const handlePlaceSelect = useCallback3(
|
|
3744
|
+
(place) => {
|
|
3745
|
+
setSearchMarker({
|
|
3746
|
+
lat: place.lat,
|
|
3747
|
+
lng: place.lng,
|
|
3748
|
+
title: place.name,
|
|
3749
|
+
description: place.address
|
|
3750
|
+
});
|
|
3751
|
+
onPlaceSelect?.(place);
|
|
3752
|
+
},
|
|
3753
|
+
[onPlaceSelect]
|
|
3754
|
+
);
|
|
3755
|
+
const allMarkers = searchMarker ? [...initialMarkers, searchMarker] : initialMarkers;
|
|
3756
|
+
return /* @__PURE__ */ jsx34(APIProvider, { apiKey, libraries: showSearch ? ["places"] : [], children: /* @__PURE__ */ jsxs25(
|
|
3701
3757
|
"div",
|
|
3702
3758
|
{
|
|
3703
|
-
className: cn("overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
3759
|
+
className: cn("relative overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
3704
3760
|
style: { height, width },
|
|
3705
|
-
children:
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3761
|
+
children: [
|
|
3762
|
+
showSearch && /* @__PURE__ */ jsx34(
|
|
3763
|
+
PlaceSearch,
|
|
3764
|
+
{
|
|
3765
|
+
placeholder: searchPlaceholder,
|
|
3766
|
+
onPlaceSelect: handlePlaceSelect
|
|
3767
|
+
}
|
|
3768
|
+
),
|
|
3769
|
+
/* @__PURE__ */ jsxs25(
|
|
3770
|
+
GoogleMap,
|
|
3771
|
+
{
|
|
3772
|
+
defaultCenter: center,
|
|
3773
|
+
defaultZoom: zoom,
|
|
3774
|
+
mapId,
|
|
3775
|
+
gestureHandling,
|
|
3776
|
+
disableDefaultUI,
|
|
3777
|
+
style: { width: "100%", height: "100%" },
|
|
3778
|
+
children: [
|
|
3779
|
+
showCurrentLocation && /* @__PURE__ */ jsx34(CurrentLocationMarker, {}),
|
|
3780
|
+
allMarkers.map((marker, i) => /* @__PURE__ */ jsx34(
|
|
3781
|
+
MarkerWithInfo,
|
|
3782
|
+
{
|
|
3783
|
+
marker,
|
|
3784
|
+
index: i,
|
|
3785
|
+
onMarkerClick
|
|
3786
|
+
},
|
|
3787
|
+
`${marker.lat}-${marker.lng}-${i}`
|
|
3788
|
+
))
|
|
3789
|
+
]
|
|
3790
|
+
}
|
|
3791
|
+
)
|
|
3792
|
+
]
|
|
3728
3793
|
}
|
|
3729
3794
|
) });
|
|
3730
3795
|
}
|
|
@@ -5252,7 +5317,7 @@ function Toggle({
|
|
|
5252
5317
|
}
|
|
5253
5318
|
|
|
5254
5319
|
// src/ui/ToggleDropdownButton/index.tsx
|
|
5255
|
-
import { useRef as
|
|
5320
|
+
import { useRef as useRef11 } from "react";
|
|
5256
5321
|
|
|
5257
5322
|
// src/ui/ToggleDropdownButton/ToggleDropdownLeftButton.tsx
|
|
5258
5323
|
import { cva as cva14 } from "class-variance-authority";
|
|
@@ -5561,7 +5626,7 @@ var ToggleDropdownButton = ({
|
|
|
5561
5626
|
onLeftButtonClick,
|
|
5562
5627
|
dropdownMenu
|
|
5563
5628
|
}) => {
|
|
5564
|
-
const rightButtonRef =
|
|
5629
|
+
const rightButtonRef = useRef11(null);
|
|
5565
5630
|
const handleRightButtonClick = () => {
|
|
5566
5631
|
onRightButtonClick?.();
|
|
5567
5632
|
};
|