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.js
CHANGED
|
@@ -3316,6 +3316,14 @@ var component_schema_default = {
|
|
|
3316
3316
|
showCurrentLocation: {
|
|
3317
3317
|
type: "boolean",
|
|
3318
3318
|
description: "Show a blue dot for the user's current location"
|
|
3319
|
+
},
|
|
3320
|
+
showSearch: {
|
|
3321
|
+
type: "boolean",
|
|
3322
|
+
description: "Show a search box to find places on the map"
|
|
3323
|
+
},
|
|
3324
|
+
searchPlaceholder: {
|
|
3325
|
+
type: "string",
|
|
3326
|
+
description: "Placeholder text for the search box"
|
|
3319
3327
|
}
|
|
3320
3328
|
},
|
|
3321
3329
|
additionalProperties: false
|
|
@@ -5528,7 +5536,9 @@ var googleMapSchema = z46.object({
|
|
|
5528
5536
|
width: z46.string().optional().describe("Map width CSS value. Defaults to '100%'"),
|
|
5529
5537
|
gestureHandling: z46.enum(["cooperative", "greedy", "none", "auto"]).optional().describe("How the map handles touch/scroll gestures. Defaults to 'cooperative'"),
|
|
5530
5538
|
disableDefaultUI: z46.boolean().optional().describe("Hide default map controls"),
|
|
5531
|
-
showCurrentLocation: z46.boolean().optional().describe("Show a blue dot for the user's current location")
|
|
5539
|
+
showCurrentLocation: z46.boolean().optional().describe("Show a blue dot for the user's current location"),
|
|
5540
|
+
showSearch: z46.boolean().optional().describe("Show a search box to find places on the map"),
|
|
5541
|
+
searchPlaceholder: z46.string().optional().describe("Placeholder text for the search box")
|
|
5532
5542
|
})
|
|
5533
5543
|
}).describe("An interactive Google Map with optional markers and info windows");
|
|
5534
5544
|
|
|
@@ -9425,9 +9435,10 @@ import {
|
|
|
9425
9435
|
Map as GoogleMap,
|
|
9426
9436
|
Marker,
|
|
9427
9437
|
InfoWindow,
|
|
9428
|
-
useMap
|
|
9438
|
+
useMap,
|
|
9439
|
+
useMapsLibrary
|
|
9429
9440
|
} from "@vis.gl/react-google-maps";
|
|
9430
|
-
import { useState as useState6, useCallback as useCallback3, useEffect as useEffect5 } from "react";
|
|
9441
|
+
import { useState as useState6, useCallback as useCallback3, useEffect as useEffect5, useRef as useRef6 } from "react";
|
|
9431
9442
|
import { Fragment as Fragment5, jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
9432
9443
|
function MarkerWithInfo({
|
|
9433
9444
|
marker,
|
|
@@ -9463,7 +9474,6 @@ function MarkerWithInfo({
|
|
|
9463
9474
|
}
|
|
9464
9475
|
var CURRENT_LOCATION_ICON = {
|
|
9465
9476
|
path: 0,
|
|
9466
|
-
// google.maps.SymbolPath.CIRCLE
|
|
9467
9477
|
scale: 8,
|
|
9468
9478
|
fillColor: "#4285F4",
|
|
9469
9479
|
fillOpacity: 1,
|
|
@@ -9497,12 +9507,51 @@ function CurrentLocationMarker() {
|
|
|
9497
9507
|
}
|
|
9498
9508
|
);
|
|
9499
9509
|
}
|
|
9510
|
+
function PlaceSearch({
|
|
9511
|
+
placeholder = "Search places...",
|
|
9512
|
+
onPlaceSelect
|
|
9513
|
+
}) {
|
|
9514
|
+
const map = useMap();
|
|
9515
|
+
const placesLib = useMapsLibrary("places");
|
|
9516
|
+
const inputRef = useRef6(null);
|
|
9517
|
+
const autocompleteRef = useRef6(null);
|
|
9518
|
+
useEffect5(() => {
|
|
9519
|
+
if (!placesLib || !inputRef.current || autocompleteRef.current) return;
|
|
9520
|
+
const autocomplete = new placesLib.Autocomplete(inputRef.current, {
|
|
9521
|
+
fields: ["geometry", "name", "formatted_address"]
|
|
9522
|
+
});
|
|
9523
|
+
autocomplete.addListener("place_changed", () => {
|
|
9524
|
+
const place = autocomplete.getPlace();
|
|
9525
|
+
if (!place.geometry?.location) return;
|
|
9526
|
+
const lat = place.geometry.location.lat();
|
|
9527
|
+
const lng = place.geometry.location.lng();
|
|
9528
|
+
map?.panTo({ lat, lng });
|
|
9529
|
+
map?.setZoom(15);
|
|
9530
|
+
onPlaceSelect?.({
|
|
9531
|
+
lat,
|
|
9532
|
+
lng,
|
|
9533
|
+
name: place.name ?? "",
|
|
9534
|
+
address: place.formatted_address ?? ""
|
|
9535
|
+
});
|
|
9536
|
+
});
|
|
9537
|
+
autocompleteRef.current = autocomplete;
|
|
9538
|
+
}, [placesLib, map, onPlaceSelect]);
|
|
9539
|
+
return /* @__PURE__ */ jsx34("div", { className: "absolute top-3 left-1/2 z-10 w-[min(90%,360px)] -translate-x-1/2", children: /* @__PURE__ */ jsx34(
|
|
9540
|
+
"input",
|
|
9541
|
+
{
|
|
9542
|
+
ref: inputRef,
|
|
9543
|
+
type: "text",
|
|
9544
|
+
placeholder,
|
|
9545
|
+
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"
|
|
9546
|
+
}
|
|
9547
|
+
) });
|
|
9548
|
+
}
|
|
9500
9549
|
var DEFAULT_CENTER = { lat: 16.8661, lng: 96.1951 };
|
|
9501
9550
|
function GoogleMapView({
|
|
9502
9551
|
apiKey,
|
|
9503
9552
|
center = DEFAULT_CENTER,
|
|
9504
9553
|
zoom = 12,
|
|
9505
|
-
markers = [],
|
|
9554
|
+
markers: initialMarkers = [],
|
|
9506
9555
|
mapId,
|
|
9507
9556
|
height = "400px",
|
|
9508
9557
|
width = "100%",
|
|
@@ -9510,36 +9559,62 @@ function GoogleMapView({
|
|
|
9510
9559
|
gestureHandling = "cooperative",
|
|
9511
9560
|
disableDefaultUI = false,
|
|
9512
9561
|
showCurrentLocation = false,
|
|
9513
|
-
|
|
9562
|
+
showSearch = false,
|
|
9563
|
+
searchPlaceholder,
|
|
9564
|
+
onMarkerClick,
|
|
9565
|
+
onPlaceSelect
|
|
9514
9566
|
}) {
|
|
9515
|
-
|
|
9567
|
+
const [searchMarker, setSearchMarker] = useState6(null);
|
|
9568
|
+
const handlePlaceSelect = useCallback3(
|
|
9569
|
+
(place) => {
|
|
9570
|
+
setSearchMarker({
|
|
9571
|
+
lat: place.lat,
|
|
9572
|
+
lng: place.lng,
|
|
9573
|
+
title: place.name,
|
|
9574
|
+
description: place.address
|
|
9575
|
+
});
|
|
9576
|
+
onPlaceSelect?.(place);
|
|
9577
|
+
},
|
|
9578
|
+
[onPlaceSelect]
|
|
9579
|
+
);
|
|
9580
|
+
const allMarkers = searchMarker ? [...initialMarkers, searchMarker] : initialMarkers;
|
|
9581
|
+
return /* @__PURE__ */ jsx34(APIProvider, { apiKey, libraries: showSearch ? ["places"] : [], children: /* @__PURE__ */ jsxs25(
|
|
9516
9582
|
"div",
|
|
9517
9583
|
{
|
|
9518
|
-
className: cn("overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
9584
|
+
className: cn("relative overflow-hidden rounded-unit-corner-radius-xl", className),
|
|
9519
9585
|
style: { height, width },
|
|
9520
|
-
children:
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9586
|
+
children: [
|
|
9587
|
+
showSearch && /* @__PURE__ */ jsx34(
|
|
9588
|
+
PlaceSearch,
|
|
9589
|
+
{
|
|
9590
|
+
placeholder: searchPlaceholder,
|
|
9591
|
+
onPlaceSelect: handlePlaceSelect
|
|
9592
|
+
}
|
|
9593
|
+
),
|
|
9594
|
+
/* @__PURE__ */ jsxs25(
|
|
9595
|
+
GoogleMap,
|
|
9596
|
+
{
|
|
9597
|
+
defaultCenter: center,
|
|
9598
|
+
defaultZoom: zoom,
|
|
9599
|
+
mapId,
|
|
9600
|
+
gestureHandling,
|
|
9601
|
+
disableDefaultUI,
|
|
9602
|
+
style: { width: "100%", height: "100%" },
|
|
9603
|
+
children: [
|
|
9604
|
+
showCurrentLocation && /* @__PURE__ */ jsx34(CurrentLocationMarker, {}),
|
|
9605
|
+
allMarkers.map((marker, i) => /* @__PURE__ */ jsx34(
|
|
9606
|
+
MarkerWithInfo,
|
|
9607
|
+
{
|
|
9608
|
+
marker,
|
|
9609
|
+
index: i,
|
|
9610
|
+
onMarkerClick
|
|
9611
|
+
},
|
|
9612
|
+
`${marker.lat}-${marker.lng}-${i}`
|
|
9613
|
+
))
|
|
9614
|
+
]
|
|
9615
|
+
}
|
|
9616
|
+
)
|
|
9617
|
+
]
|
|
9543
9618
|
}
|
|
9544
9619
|
) });
|
|
9545
9620
|
}
|
|
@@ -11067,7 +11142,7 @@ function Toggle({
|
|
|
11067
11142
|
}
|
|
11068
11143
|
|
|
11069
11144
|
// src/ui/ToggleDropdownButton/index.tsx
|
|
11070
|
-
import { useRef as
|
|
11145
|
+
import { useRef as useRef11 } from "react";
|
|
11071
11146
|
|
|
11072
11147
|
// src/ui/ToggleDropdownButton/ToggleDropdownLeftButton.tsx
|
|
11073
11148
|
import { cva as cva14 } from "class-variance-authority";
|
|
@@ -11376,7 +11451,7 @@ var ToggleDropdownButton = ({
|
|
|
11376
11451
|
onLeftButtonClick,
|
|
11377
11452
|
dropdownMenu
|
|
11378
11453
|
}) => {
|
|
11379
|
-
const rightButtonRef =
|
|
11454
|
+
const rightButtonRef = useRef11(null);
|
|
11380
11455
|
const handleRightButtonClick = () => {
|
|
11381
11456
|
onRightButtonClick?.();
|
|
11382
11457
|
};
|