@krak-stack/registry 0.3.0 → 0.5.0
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/CHANGELOG.md +26 -0
- package/dist/components/ui/app-switcher.d.ts +25 -0
- package/dist/components/ui/app-switcher.js +233 -0
- package/dist/components/ui/bulk-list-input.d.ts +24 -0
- package/dist/components/ui/bulk-list-input.js +152 -0
- package/dist/components/ui/choice-cards.d.ts +32 -0
- package/dist/components/ui/choice-cards.js +88 -0
- package/dist/components/ui/color-picker.js +3 -2
- package/dist/components/ui/effect-form.js +2 -2
- package/dist/components/ui/form.js +2 -2
- package/dist/components/ui/icon-input.js +2 -2
- package/dist/components/ui/map-menu.d.ts +14 -2
- package/dist/components/ui/map-menu.js +332 -306
- package/dist/components/ui/secret-value.d.ts +19 -0
- package/dist/components/ui/secret-value.js +216 -0
- package/dist/components/ui/upload-attachment.d.ts +39 -0
- package/dist/components/ui/upload-attachment.js +286 -0
- package/dist/components/ui/virtualized-combobox.js +2 -2
- package/package.json +21 -1
|
@@ -559,12 +559,17 @@ function Input({ className, type, ...props }) {
|
|
|
559
559
|
|
|
560
560
|
// ../../src/components/ui/map-menu.tsx
|
|
561
561
|
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
562
|
-
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
562
|
+
import { jsx as jsx5, jsxs as jsxs3, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
563
563
|
var MapMenuMode;
|
|
564
564
|
((MapMenuMode) => {
|
|
565
565
|
MapMenuMode["Point"] = "point";
|
|
566
566
|
MapMenuMode["Radius"] = "radius";
|
|
567
567
|
})(MapMenuMode ||= {});
|
|
568
|
+
var MapMenuPresentation;
|
|
569
|
+
((MapMenuPresentation) => {
|
|
570
|
+
MapMenuPresentation["Dialog"] = "dialog";
|
|
571
|
+
MapMenuPresentation["Inline"] = "inline";
|
|
572
|
+
})(MapMenuPresentation ||= {});
|
|
568
573
|
var mapMenuRadiiKm = [1, 2, 5, 10, 20, 40, 60, 80, 100, 250, 500];
|
|
569
574
|
var defaultMessages2 = {
|
|
570
575
|
en: {
|
|
@@ -609,8 +614,6 @@ var defaultMessages2 = {
|
|
|
609
614
|
var MapMenu = (props) => {
|
|
610
615
|
const {
|
|
611
616
|
apiKey,
|
|
612
|
-
open,
|
|
613
|
-
onOpenChange,
|
|
614
617
|
input,
|
|
615
618
|
onInputChange,
|
|
616
619
|
selectedLocation,
|
|
@@ -630,6 +633,8 @@ var MapMenu = (props) => {
|
|
|
630
633
|
locale: localeOverride,
|
|
631
634
|
messages
|
|
632
635
|
} = props;
|
|
636
|
+
const inline = props.presentation === "inline" /* Inline */;
|
|
637
|
+
const open = inline || props.open;
|
|
633
638
|
const radiusEnabled = props.mode !== "point" /* Point */;
|
|
634
639
|
const locale = useKrakstackLocale2(localeOverride);
|
|
635
640
|
const suggestions = locationSuggestions.slice(0, 3);
|
|
@@ -650,7 +655,7 @@ var MapMenu = (props) => {
|
|
|
650
655
|
const notice = provenance === "ip" ? labels.ipNotice : provenance === "browser" ? labels.browserNotice : !selectedMatchesInput ? labels.searchHint : undefined;
|
|
651
656
|
const markerIcon = `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="48" viewBox="0 0 40 48"><path d="M20 46s15-14.3 15-27A15 15 0 1 0 5 19c0 12.7 15 27 15 27Z" fill="${overlayColor}" stroke="white" stroke-width="3"/><circle cx="20" cy="19" r="6" fill="white"/></svg>`)}`;
|
|
652
657
|
useEffect2(() => {
|
|
653
|
-
if (!open || !window.visualViewport)
|
|
658
|
+
if (inline || !open || !window.visualViewport)
|
|
654
659
|
return;
|
|
655
660
|
const viewport = window.visualViewport;
|
|
656
661
|
const sync = () => {
|
|
@@ -664,7 +669,7 @@ var MapMenu = (props) => {
|
|
|
664
669
|
viewport.removeEventListener("resize", sync);
|
|
665
670
|
viewport.removeEventListener("scroll", sync);
|
|
666
671
|
};
|
|
667
|
-
}, [open]);
|
|
672
|
+
}, [inline, open]);
|
|
668
673
|
useEffect2(() => {
|
|
669
674
|
if (dropdownOpen && activeIndex >= 0)
|
|
670
675
|
document.getElementById(`${id}-option-${activeIndex}`)?.scrollIntoView?.({ block: "nearest" });
|
|
@@ -675,7 +680,12 @@ var MapMenu = (props) => {
|
|
|
675
680
|
setDropdownOpen(false);
|
|
676
681
|
setActiveIndex(-1);
|
|
677
682
|
setConfirmFailed(false);
|
|
678
|
-
|
|
683
|
+
if (props.presentation === "inline" /* Inline */) {
|
|
684
|
+
if (!next)
|
|
685
|
+
props.onCancel();
|
|
686
|
+
} else {
|
|
687
|
+
props.onOpenChange(next);
|
|
688
|
+
}
|
|
679
689
|
};
|
|
680
690
|
const select = (location) => {
|
|
681
691
|
onInputChange(location.label);
|
|
@@ -685,7 +695,7 @@ var MapMenu = (props) => {
|
|
|
685
695
|
setActiveIndex(-1);
|
|
686
696
|
};
|
|
687
697
|
const confirm = async () => {
|
|
688
|
-
if (applying || !selectedLocation || !selectedMatchesInput)
|
|
698
|
+
if (applying || locating || !selectedLocation || !selectedMatchesInput)
|
|
689
699
|
return;
|
|
690
700
|
setApplying(true);
|
|
691
701
|
setConfirmFailed(false);
|
|
@@ -699,322 +709,337 @@ var MapMenu = (props) => {
|
|
|
699
709
|
radiusKm: props.radiusKm
|
|
700
710
|
});
|
|
701
711
|
}
|
|
702
|
-
|
|
712
|
+
if (props.presentation !== "inline" /* Inline */)
|
|
713
|
+
props.onOpenChange(false);
|
|
703
714
|
} catch {
|
|
704
715
|
setConfirmFailed(true);
|
|
705
716
|
} finally {
|
|
706
717
|
setApplying(false);
|
|
707
718
|
}
|
|
708
719
|
};
|
|
720
|
+
const content = /* @__PURE__ */ jsxs3(Fragment2, {
|
|
721
|
+
children: [
|
|
722
|
+
!inline ? /* @__PURE__ */ jsxs3(DialogHeader, {
|
|
723
|
+
className: "shrink-0 px-5 pt-6 pr-16 pb-5 text-left sm:px-7 sm:pt-[25px] sm:pb-[22px] [@media(max-height:599px)]:py-4",
|
|
724
|
+
children: [
|
|
725
|
+
/* @__PURE__ */ jsx5(DialogTitle, {
|
|
726
|
+
className: "text-2xl font-semibold",
|
|
727
|
+
children: labels.title
|
|
728
|
+
}),
|
|
729
|
+
/* @__PURE__ */ jsx5(Button, {
|
|
730
|
+
type: "button",
|
|
731
|
+
variant: "ghost",
|
|
732
|
+
size: "icon",
|
|
733
|
+
className: "absolute top-4 right-4 size-11",
|
|
734
|
+
disabled: applying,
|
|
735
|
+
"aria-label": labels.close,
|
|
736
|
+
onClick: () => changeOpen(false),
|
|
737
|
+
children: /* @__PURE__ */ jsx5(X, {})
|
|
738
|
+
})
|
|
739
|
+
]
|
|
740
|
+
}) : null,
|
|
741
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
742
|
+
className: inline ? "flex min-w-0 flex-col gap-4" : "flex min-h-0 min-w-0 flex-1 flex-col gap-[18px] overflow-y-auto px-5 pb-6 sm:px-7 [@media(max-height:599px)]:pb-3",
|
|
743
|
+
children: [
|
|
744
|
+
/* @__PURE__ */ jsxs3("fieldset", {
|
|
745
|
+
disabled: applying,
|
|
746
|
+
"data-slot": "map-menu-toolbar",
|
|
747
|
+
className: cn("grid min-w-0 shrink-0 grid-cols-1 items-end gap-3", onUseCurrentLocation && "sm:grid-cols-[minmax(0,1fr)_max-content]"),
|
|
748
|
+
children: [
|
|
749
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
750
|
+
className: "relative flex min-w-0 flex-col gap-2",
|
|
751
|
+
onBlur: (event) => {
|
|
752
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
753
|
+
setDropdownOpen(false);
|
|
754
|
+
},
|
|
755
|
+
children: [
|
|
756
|
+
/* @__PURE__ */ jsx5("label", {
|
|
757
|
+
htmlFor: `${id}-input`,
|
|
758
|
+
className: "text-sm font-medium",
|
|
759
|
+
children: labels.location
|
|
760
|
+
}),
|
|
761
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
762
|
+
className: "relative",
|
|
763
|
+
children: [
|
|
764
|
+
/* @__PURE__ */ jsx5(Search, {
|
|
765
|
+
"aria-hidden": "true",
|
|
766
|
+
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3.5 size-4 -translate-y-1/2"
|
|
767
|
+
}),
|
|
768
|
+
/* @__PURE__ */ jsx5(Input, {
|
|
769
|
+
ref: inputRef,
|
|
770
|
+
id: `${id}-input`,
|
|
771
|
+
value: input,
|
|
772
|
+
placeholder: labels.placeholder,
|
|
773
|
+
className: "bg-card h-[50px] w-full rounded-md pr-11 pl-11 text-base",
|
|
774
|
+
autoComplete: "off",
|
|
775
|
+
role: "combobox",
|
|
776
|
+
"aria-autocomplete": "list",
|
|
777
|
+
"aria-controls": `${id}-suggestions`,
|
|
778
|
+
"aria-expanded": dropdownOpen,
|
|
779
|
+
"aria-activedescendant": dropdownOpen && suggestions[activeIndex] ? `${id}-option-${activeIndex}` : undefined,
|
|
780
|
+
onFocus: () => {
|
|
781
|
+
if (input.trim() && !selectedMatchesInput)
|
|
782
|
+
setDropdownOpen(true);
|
|
783
|
+
},
|
|
784
|
+
onChange: (event) => {
|
|
785
|
+
onInputChange(event.currentTarget.value);
|
|
786
|
+
setActiveIndex(-1);
|
|
787
|
+
setConfirmFailed(false);
|
|
788
|
+
setDropdownOpen(Boolean(event.currentTarget.value.trim()));
|
|
789
|
+
},
|
|
790
|
+
onKeyDown: (event) => {
|
|
791
|
+
if (event.key === "Escape" && dropdownOpen) {
|
|
792
|
+
event.preventDefault();
|
|
793
|
+
event.stopPropagation();
|
|
794
|
+
setDropdownOpen(false);
|
|
795
|
+
}
|
|
796
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
797
|
+
event.preventDefault();
|
|
798
|
+
setDropdownOpen(true);
|
|
799
|
+
if (suggestions.length)
|
|
800
|
+
setActiveIndex((index) => index < 0 ? event.key === "ArrowDown" ? 0 : suggestions.length - 1 : (index + (event.key === "ArrowDown" ? 1 : -1) + suggestions.length) % suggestions.length);
|
|
801
|
+
}
|
|
802
|
+
if (event.key === "Enter") {
|
|
803
|
+
event.preventDefault();
|
|
804
|
+
const location = dropdownOpen ? suggestions[activeIndex] : undefined;
|
|
805
|
+
if (location)
|
|
806
|
+
select(location);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}),
|
|
810
|
+
input ? /* @__PURE__ */ jsx5("button", {
|
|
811
|
+
type: "button",
|
|
812
|
+
"aria-label": labels.clear,
|
|
813
|
+
className: "text-muted-foreground absolute top-[3px] right-1 grid size-11 cursor-pointer place-items-center rounded focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
814
|
+
onClick: () => {
|
|
815
|
+
onInputChange("");
|
|
816
|
+
setDropdownOpen(false);
|
|
817
|
+
setActiveIndex(-1);
|
|
818
|
+
inputRef.current?.focus();
|
|
819
|
+
},
|
|
820
|
+
children: /* @__PURE__ */ jsx5(X, {
|
|
821
|
+
className: "size-4"
|
|
822
|
+
})
|
|
823
|
+
}) : null
|
|
824
|
+
]
|
|
825
|
+
}),
|
|
826
|
+
dropdownOpen ? /* @__PURE__ */ jsxs3("div", {
|
|
827
|
+
id: `${id}-suggestions`,
|
|
828
|
+
role: "listbox",
|
|
829
|
+
"aria-label": labels.suggestions,
|
|
830
|
+
"aria-busy": loadingSuggestions,
|
|
831
|
+
className: "bg-popover text-popover-foreground absolute inset-x-0 top-full z-30 mt-1 max-h-[min(16rem,35dvh)] overflow-y-auto rounded-md border p-1 shadow-lg",
|
|
832
|
+
children: [
|
|
833
|
+
suggestions.map((location, index) => /* @__PURE__ */ jsxs3("button", {
|
|
834
|
+
id: `${id}-option-${index}`,
|
|
835
|
+
type: "button",
|
|
836
|
+
role: "option",
|
|
837
|
+
tabIndex: -1,
|
|
838
|
+
"aria-label": location.label,
|
|
839
|
+
"aria-selected": index === activeIndex,
|
|
840
|
+
className: cn("hover:bg-accent flex min-h-11 w-full items-center gap-3 rounded px-3 py-3 text-left", index === activeIndex && "bg-accent"),
|
|
841
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
842
|
+
onClick: () => select(location),
|
|
843
|
+
children: [
|
|
844
|
+
/* @__PURE__ */ jsx5(MapPin, {
|
|
845
|
+
"aria-hidden": "true",
|
|
846
|
+
className: "size-4 shrink-0",
|
|
847
|
+
style: { color: overlayColor }
|
|
848
|
+
}),
|
|
849
|
+
/* @__PURE__ */ jsxs3("span", {
|
|
850
|
+
className: "min-w-0",
|
|
851
|
+
children: [
|
|
852
|
+
/* @__PURE__ */ jsx5("span", {
|
|
853
|
+
className: "block text-sm font-medium wrap-anywhere",
|
|
854
|
+
children: location.title ?? location.label
|
|
855
|
+
}),
|
|
856
|
+
location.details ? /* @__PURE__ */ jsx5("span", {
|
|
857
|
+
className: "text-muted-foreground mt-1 block text-xs wrap-anywhere",
|
|
858
|
+
children: location.details
|
|
859
|
+
}) : null
|
|
860
|
+
]
|
|
861
|
+
})
|
|
862
|
+
]
|
|
863
|
+
}, location.id)),
|
|
864
|
+
loadingSuggestions ? /* @__PURE__ */ jsx5("p", {
|
|
865
|
+
role: "status",
|
|
866
|
+
className: "text-muted-foreground p-3 text-sm",
|
|
867
|
+
children: labels.loading
|
|
868
|
+
}) : suggestionsError ? /* @__PURE__ */ jsx5("p", {
|
|
869
|
+
role: "alert",
|
|
870
|
+
className: "text-destructive p-3 text-sm",
|
|
871
|
+
children: suggestionsError
|
|
872
|
+
}) : !suggestions.length ? /* @__PURE__ */ jsx5("p", {
|
|
873
|
+
className: "text-muted-foreground p-3 text-sm",
|
|
874
|
+
children: labels.noResults
|
|
875
|
+
}) : null
|
|
876
|
+
]
|
|
877
|
+
}) : null
|
|
878
|
+
]
|
|
879
|
+
}),
|
|
880
|
+
onUseCurrentLocation ? /* @__PURE__ */ jsxs3(Button, {
|
|
881
|
+
type: "button",
|
|
882
|
+
variant: "outline",
|
|
883
|
+
"data-slot": "map-menu-current",
|
|
884
|
+
disabled: locating,
|
|
885
|
+
className: "bg-card h-[50px] w-max gap-[7px] justify-self-start px-3 shadow-none",
|
|
886
|
+
onClick: onUseCurrentLocation,
|
|
887
|
+
children: [
|
|
888
|
+
/* @__PURE__ */ jsx5(LocateFixed2, {
|
|
889
|
+
className: "text-foreground size-[17px]"
|
|
890
|
+
}),
|
|
891
|
+
labels.currentLocation
|
|
892
|
+
]
|
|
893
|
+
}) : null,
|
|
894
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
895
|
+
className: "col-span-full grid text-xs leading-5",
|
|
896
|
+
children: [
|
|
897
|
+
[labels.ipNotice, labels.browserNotice, labels.searchHint].map((text) => /* @__PURE__ */ jsx5("span", {
|
|
898
|
+
"aria-hidden": "true",
|
|
899
|
+
className: "invisible col-start-1 row-start-1 pl-6",
|
|
900
|
+
children: text
|
|
901
|
+
}, text)),
|
|
902
|
+
notice ? /* @__PURE__ */ jsxs3("p", {
|
|
903
|
+
role: "status",
|
|
904
|
+
"data-slot": "map-menu-provenance",
|
|
905
|
+
className: "text-muted-foreground col-start-1 row-start-1 flex items-start gap-2",
|
|
906
|
+
children: [
|
|
907
|
+
/* @__PURE__ */ jsx5(MapPin, {
|
|
908
|
+
"aria-hidden": "true",
|
|
909
|
+
className: "text-foreground mt-0.5 size-4 shrink-0"
|
|
910
|
+
}),
|
|
911
|
+
/* @__PURE__ */ jsx5("span", {
|
|
912
|
+
className: "wrap-anywhere",
|
|
913
|
+
children: notice
|
|
914
|
+
})
|
|
915
|
+
]
|
|
916
|
+
}) : null
|
|
917
|
+
]
|
|
918
|
+
}),
|
|
919
|
+
radiusEnabled ? /* @__PURE__ */ jsxs3("div", {
|
|
920
|
+
className: "after:bg-border col-span-full flex flex-wrap items-center gap-3 after:h-px after:flex-1",
|
|
921
|
+
children: [
|
|
922
|
+
/* @__PURE__ */ jsx5("label", {
|
|
923
|
+
htmlFor: `${id}-radius`,
|
|
924
|
+
className: "text-sm font-medium",
|
|
925
|
+
children: labels.searchWithin
|
|
926
|
+
}),
|
|
927
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
928
|
+
className: "relative",
|
|
929
|
+
children: [
|
|
930
|
+
/* @__PURE__ */ jsx5("select", {
|
|
931
|
+
id: `${id}-radius`,
|
|
932
|
+
value: radiusKm,
|
|
933
|
+
className: "bg-card focus-visible:outline-ring h-11 appearance-none rounded border py-2 pr-9 pl-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
934
|
+
onChange: (event) => props.onRadiusChange(Number(event.currentTarget.value)),
|
|
935
|
+
children: radiusOptions.map((radius) => /* @__PURE__ */ jsxs3("option", {
|
|
936
|
+
value: radius,
|
|
937
|
+
children: [
|
|
938
|
+
radius,
|
|
939
|
+
" km"
|
|
940
|
+
]
|
|
941
|
+
}, radius))
|
|
942
|
+
}),
|
|
943
|
+
/* @__PURE__ */ jsx5(ChevronDown, {
|
|
944
|
+
"aria-hidden": "true",
|
|
945
|
+
className: "pointer-events-none absolute top-1/2 right-3 size-4 -translate-y-1/2"
|
|
946
|
+
})
|
|
947
|
+
]
|
|
948
|
+
})
|
|
949
|
+
]
|
|
950
|
+
}) : null
|
|
951
|
+
]
|
|
952
|
+
}),
|
|
953
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
954
|
+
"data-slot": "map-menu-map",
|
|
955
|
+
className: inline ? "relative h-80 min-w-0 sm:h-96" : "relative min-h-56 min-w-0 flex-[1_0_14rem] [@media(max-height:599px)]:min-h-[182px] [@media(max-height:599px)]:basis-[182px]",
|
|
956
|
+
children: [
|
|
957
|
+
/* @__PURE__ */ jsx5(MapMenuMap, {
|
|
958
|
+
apiKey,
|
|
959
|
+
center: selectedLocation?.center ?? { lat: 0, lng: 0 },
|
|
960
|
+
zoom: !radiusEnabled && selectedLocation ? 15 : 4,
|
|
961
|
+
marker: selectedLocation ? { icon: markerIcon } : undefined,
|
|
962
|
+
radius: radiusEnabled && selectedLocation && radiusKm !== undefined ? {
|
|
963
|
+
radiusMeters: radiusKm * 1000,
|
|
964
|
+
fillColor: overlayColor,
|
|
965
|
+
fillOpacity: 0.12,
|
|
966
|
+
strokeColor: overlayColor,
|
|
967
|
+
strokeOpacity: 0.82,
|
|
968
|
+
strokeWeight: 2
|
|
969
|
+
} : undefined,
|
|
970
|
+
fitRadius: radiusEnabled && Boolean(selectedLocation),
|
|
971
|
+
fitPadding: 40,
|
|
972
|
+
minZoom: 3,
|
|
973
|
+
maxZoom: 18,
|
|
974
|
+
locale,
|
|
975
|
+
className: "h-full min-h-0 w-full rounded-md",
|
|
976
|
+
controlsClassName: "bg-card rounded-md shadow-md"
|
|
977
|
+
}),
|
|
978
|
+
radiusEnabled && selectedLocation ? /* @__PURE__ */ jsx5("p", {
|
|
979
|
+
className: "bg-card text-muted-foreground pointer-events-none absolute bottom-[25px] left-3 m-0 max-w-[calc(100%-24px)] rounded px-2.5 py-[7px] text-xs shadow-sm",
|
|
980
|
+
children: labels.radiusHint
|
|
981
|
+
}) : null
|
|
982
|
+
]
|
|
983
|
+
})
|
|
984
|
+
]
|
|
985
|
+
}),
|
|
986
|
+
/* @__PURE__ */ jsxs3(DialogFooter, {
|
|
987
|
+
className: inline ? "gap-3 border-0 bg-transparent p-0" : "shrink-0 gap-3 border-0 bg-transparent px-5 pt-[18px] pb-[max(18px,env(safe-area-inset-bottom))] sm:px-7 [@media(max-height:599px)]:pt-3 [@media(max-height:599px)]:pb-[max(12px,env(safe-area-inset-bottom))]",
|
|
988
|
+
children: [
|
|
989
|
+
error || confirmFailed ? /* @__PURE__ */ jsx5("p", {
|
|
990
|
+
role: "alert",
|
|
991
|
+
className: "text-destructive w-full self-center text-sm sm:mr-auto sm:w-auto",
|
|
992
|
+
children: error ?? labels.confirmError
|
|
993
|
+
}) : null,
|
|
994
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
995
|
+
className: "flex gap-2",
|
|
996
|
+
children: [
|
|
997
|
+
/* @__PURE__ */ jsx5(Button, {
|
|
998
|
+
type: "button",
|
|
999
|
+
variant: "outline",
|
|
1000
|
+
className: "bg-card min-h-11 flex-1",
|
|
1001
|
+
disabled: applying,
|
|
1002
|
+
onClick: () => changeOpen(false),
|
|
1003
|
+
children: labels.cancel
|
|
1004
|
+
}),
|
|
1005
|
+
/* @__PURE__ */ jsx5(Button, {
|
|
1006
|
+
type: "button",
|
|
1007
|
+
"data-slot": "map-menu-confirm",
|
|
1008
|
+
className: cn("min-h-11 flex-[2] bg-[oklch(0.9247_0.0524_66.1732)] text-zinc-950 hover:bg-[oklch(0.9247_0.0524_66.1732)] hover:brightness-95", confirmClassName),
|
|
1009
|
+
disabled: applying || locating || !selectedMatchesInput || !selectedLocation,
|
|
1010
|
+
onClick: () => void confirm(),
|
|
1011
|
+
children: labels.confirm
|
|
1012
|
+
})
|
|
1013
|
+
]
|
|
1014
|
+
})
|
|
1015
|
+
]
|
|
1016
|
+
})
|
|
1017
|
+
]
|
|
1018
|
+
});
|
|
1019
|
+
if (inline) {
|
|
1020
|
+
return /* @__PURE__ */ jsx5("section", {
|
|
1021
|
+
role: "group",
|
|
1022
|
+
"aria-label": labels.title,
|
|
1023
|
+
"data-slot": "map-menu",
|
|
1024
|
+
"data-presentation": "inline" /* Inline */,
|
|
1025
|
+
className: cn("flex min-w-0 flex-col gap-4", className),
|
|
1026
|
+
children: content
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
709
1029
|
return /* @__PURE__ */ jsx5(Dialog, {
|
|
710
1030
|
open,
|
|
711
1031
|
onOpenChange: changeOpen,
|
|
712
1032
|
children: /* @__PURE__ */ jsxs3(DialogPortal, {
|
|
713
1033
|
children: [
|
|
714
1034
|
/* @__PURE__ */ jsx5(DialogOverlay, {}),
|
|
715
|
-
/* @__PURE__ */
|
|
1035
|
+
/* @__PURE__ */ jsx5(DialogPrimitive2.Popup, {
|
|
716
1036
|
ref: popupRef,
|
|
717
1037
|
initialFocus: inputRef,
|
|
718
1038
|
"aria-describedby": undefined,
|
|
719
1039
|
"data-slot": "map-menu",
|
|
1040
|
+
"data-presentation": "dialog" /* Dialog */,
|
|
720
1041
|
className: cn("bg-muted text-foreground fixed top-[calc(var(--map-picker-top,0px)_+_var(--map-picker-height,100dvh)/2)] left-1/2 z-50 flex h-[var(--map-picker-height,100dvh)] w-screen max-w-none -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden border p-0 outline-none sm:h-[min(46.75rem,calc(var(--map-picker-height,100dvh)_-_5rem))] sm:w-[calc(100vw-4rem)] sm:max-w-[840px] sm:rounded-[10px] [@media(max-height:599px)]:h-[var(--map-picker-height,100dvh)]", className),
|
|
721
|
-
children:
|
|
722
|
-
/* @__PURE__ */ jsxs3(DialogHeader, {
|
|
723
|
-
className: "shrink-0 px-5 pt-6 pr-16 pb-5 text-left sm:px-7 sm:pt-[25px] sm:pb-[22px] [@media(max-height:599px)]:py-4",
|
|
724
|
-
children: [
|
|
725
|
-
/* @__PURE__ */ jsx5(DialogTitle, {
|
|
726
|
-
className: "text-2xl font-semibold",
|
|
727
|
-
children: labels.title
|
|
728
|
-
}),
|
|
729
|
-
/* @__PURE__ */ jsx5(Button, {
|
|
730
|
-
type: "button",
|
|
731
|
-
variant: "ghost",
|
|
732
|
-
size: "icon",
|
|
733
|
-
className: "absolute top-4 right-4 size-11",
|
|
734
|
-
disabled: applying,
|
|
735
|
-
"aria-label": labels.close,
|
|
736
|
-
onClick: () => changeOpen(false),
|
|
737
|
-
children: /* @__PURE__ */ jsx5(X, {})
|
|
738
|
-
})
|
|
739
|
-
]
|
|
740
|
-
}),
|
|
741
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
742
|
-
className: "flex min-h-0 min-w-0 flex-1 flex-col gap-[18px] overflow-y-auto px-5 pb-6 sm:px-7 [@media(max-height:599px)]:pb-3",
|
|
743
|
-
children: [
|
|
744
|
-
/* @__PURE__ */ jsxs3("fieldset", {
|
|
745
|
-
disabled: applying,
|
|
746
|
-
"data-slot": "map-menu-toolbar",
|
|
747
|
-
className: cn("grid min-w-0 shrink-0 grid-cols-1 items-end gap-3", onUseCurrentLocation && "sm:grid-cols-[minmax(0,1fr)_max-content]"),
|
|
748
|
-
children: [
|
|
749
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
750
|
-
className: "relative flex min-w-0 flex-col gap-2",
|
|
751
|
-
onBlur: (event) => {
|
|
752
|
-
if (!event.currentTarget.contains(event.relatedTarget))
|
|
753
|
-
setDropdownOpen(false);
|
|
754
|
-
},
|
|
755
|
-
children: [
|
|
756
|
-
/* @__PURE__ */ jsx5("label", {
|
|
757
|
-
htmlFor: `${id}-input`,
|
|
758
|
-
className: "text-sm font-medium",
|
|
759
|
-
children: labels.location
|
|
760
|
-
}),
|
|
761
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
762
|
-
className: "relative",
|
|
763
|
-
children: [
|
|
764
|
-
/* @__PURE__ */ jsx5(Search, {
|
|
765
|
-
"aria-hidden": "true",
|
|
766
|
-
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3.5 size-4 -translate-y-1/2"
|
|
767
|
-
}),
|
|
768
|
-
/* @__PURE__ */ jsx5(Input, {
|
|
769
|
-
ref: inputRef,
|
|
770
|
-
id: `${id}-input`,
|
|
771
|
-
value: input,
|
|
772
|
-
placeholder: labels.placeholder,
|
|
773
|
-
className: "bg-card h-[50px] w-full rounded-md pr-11 pl-11 text-base",
|
|
774
|
-
autoComplete: "off",
|
|
775
|
-
role: "combobox",
|
|
776
|
-
"aria-autocomplete": "list",
|
|
777
|
-
"aria-controls": `${id}-suggestions`,
|
|
778
|
-
"aria-expanded": dropdownOpen,
|
|
779
|
-
"aria-activedescendant": dropdownOpen && suggestions[activeIndex] ? `${id}-option-${activeIndex}` : undefined,
|
|
780
|
-
onFocus: () => {
|
|
781
|
-
if (input.trim() && !selectedMatchesInput)
|
|
782
|
-
setDropdownOpen(true);
|
|
783
|
-
},
|
|
784
|
-
onChange: (event) => {
|
|
785
|
-
onInputChange(event.currentTarget.value);
|
|
786
|
-
setActiveIndex(-1);
|
|
787
|
-
setConfirmFailed(false);
|
|
788
|
-
setDropdownOpen(Boolean(event.currentTarget.value.trim()));
|
|
789
|
-
},
|
|
790
|
-
onKeyDown: (event) => {
|
|
791
|
-
if (event.key === "Escape" && dropdownOpen) {
|
|
792
|
-
event.preventDefault();
|
|
793
|
-
event.stopPropagation();
|
|
794
|
-
setDropdownOpen(false);
|
|
795
|
-
}
|
|
796
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
797
|
-
event.preventDefault();
|
|
798
|
-
setDropdownOpen(true);
|
|
799
|
-
if (suggestions.length)
|
|
800
|
-
setActiveIndex((index) => index < 0 ? event.key === "ArrowDown" ? 0 : suggestions.length - 1 : (index + (event.key === "ArrowDown" ? 1 : -1) + suggestions.length) % suggestions.length);
|
|
801
|
-
}
|
|
802
|
-
if (event.key === "Enter" && dropdownOpen) {
|
|
803
|
-
event.preventDefault();
|
|
804
|
-
const location = suggestions[activeIndex];
|
|
805
|
-
if (location)
|
|
806
|
-
select(location);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}),
|
|
810
|
-
input ? /* @__PURE__ */ jsx5("button", {
|
|
811
|
-
type: "button",
|
|
812
|
-
"aria-label": labels.clear,
|
|
813
|
-
className: "text-muted-foreground absolute top-[3px] right-1 grid size-11 cursor-pointer place-items-center rounded focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
814
|
-
onClick: () => {
|
|
815
|
-
onInputChange("");
|
|
816
|
-
setDropdownOpen(false);
|
|
817
|
-
setActiveIndex(-1);
|
|
818
|
-
inputRef.current?.focus();
|
|
819
|
-
},
|
|
820
|
-
children: /* @__PURE__ */ jsx5(X, {
|
|
821
|
-
className: "size-4"
|
|
822
|
-
})
|
|
823
|
-
}) : null
|
|
824
|
-
]
|
|
825
|
-
}),
|
|
826
|
-
dropdownOpen ? /* @__PURE__ */ jsxs3("div", {
|
|
827
|
-
id: `${id}-suggestions`,
|
|
828
|
-
role: "listbox",
|
|
829
|
-
"aria-label": labels.suggestions,
|
|
830
|
-
"aria-busy": loadingSuggestions,
|
|
831
|
-
className: "bg-popover text-popover-foreground absolute inset-x-0 top-full z-30 mt-1 max-h-[min(16rem,35dvh)] overflow-y-auto rounded-md border p-1 shadow-lg",
|
|
832
|
-
children: [
|
|
833
|
-
suggestions.map((location, index) => /* @__PURE__ */ jsxs3("button", {
|
|
834
|
-
id: `${id}-option-${index}`,
|
|
835
|
-
type: "button",
|
|
836
|
-
role: "option",
|
|
837
|
-
tabIndex: -1,
|
|
838
|
-
"aria-label": location.label,
|
|
839
|
-
"aria-selected": index === activeIndex,
|
|
840
|
-
className: cn("hover:bg-accent flex min-h-11 w-full items-center gap-3 rounded px-3 py-3 text-left", index === activeIndex && "bg-accent"),
|
|
841
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
842
|
-
onClick: () => select(location),
|
|
843
|
-
children: [
|
|
844
|
-
/* @__PURE__ */ jsx5(MapPin, {
|
|
845
|
-
"aria-hidden": "true",
|
|
846
|
-
className: "size-4 shrink-0",
|
|
847
|
-
style: { color: overlayColor }
|
|
848
|
-
}),
|
|
849
|
-
/* @__PURE__ */ jsxs3("span", {
|
|
850
|
-
className: "min-w-0",
|
|
851
|
-
children: [
|
|
852
|
-
/* @__PURE__ */ jsx5("span", {
|
|
853
|
-
className: "block text-sm font-medium wrap-anywhere",
|
|
854
|
-
children: location.title ?? location.label
|
|
855
|
-
}),
|
|
856
|
-
location.details ? /* @__PURE__ */ jsx5("span", {
|
|
857
|
-
className: "text-muted-foreground mt-1 block text-xs wrap-anywhere",
|
|
858
|
-
children: location.details
|
|
859
|
-
}) : null
|
|
860
|
-
]
|
|
861
|
-
})
|
|
862
|
-
]
|
|
863
|
-
}, location.id)),
|
|
864
|
-
loadingSuggestions ? /* @__PURE__ */ jsx5("p", {
|
|
865
|
-
role: "status",
|
|
866
|
-
className: "text-muted-foreground p-3 text-sm",
|
|
867
|
-
children: labels.loading
|
|
868
|
-
}) : suggestionsError ? /* @__PURE__ */ jsx5("p", {
|
|
869
|
-
role: "alert",
|
|
870
|
-
className: "text-destructive p-3 text-sm",
|
|
871
|
-
children: suggestionsError
|
|
872
|
-
}) : !suggestions.length ? /* @__PURE__ */ jsx5("p", {
|
|
873
|
-
className: "text-muted-foreground p-3 text-sm",
|
|
874
|
-
children: labels.noResults
|
|
875
|
-
}) : null
|
|
876
|
-
]
|
|
877
|
-
}) : null
|
|
878
|
-
]
|
|
879
|
-
}),
|
|
880
|
-
onUseCurrentLocation ? /* @__PURE__ */ jsxs3(Button, {
|
|
881
|
-
type: "button",
|
|
882
|
-
variant: "outline",
|
|
883
|
-
"data-slot": "map-menu-current",
|
|
884
|
-
disabled: locating,
|
|
885
|
-
className: "bg-card h-[50px] w-max gap-[7px] justify-self-start px-3 shadow-none",
|
|
886
|
-
onClick: onUseCurrentLocation,
|
|
887
|
-
children: [
|
|
888
|
-
/* @__PURE__ */ jsx5(LocateFixed2, {
|
|
889
|
-
className: "text-foreground size-[17px]"
|
|
890
|
-
}),
|
|
891
|
-
labels.currentLocation
|
|
892
|
-
]
|
|
893
|
-
}) : null,
|
|
894
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
895
|
-
className: "col-span-full grid text-xs leading-5",
|
|
896
|
-
children: [
|
|
897
|
-
[labels.ipNotice, labels.browserNotice, labels.searchHint].map((text) => /* @__PURE__ */ jsx5("span", {
|
|
898
|
-
"aria-hidden": "true",
|
|
899
|
-
className: "invisible col-start-1 row-start-1 pl-6",
|
|
900
|
-
children: text
|
|
901
|
-
}, text)),
|
|
902
|
-
notice ? /* @__PURE__ */ jsxs3("p", {
|
|
903
|
-
role: "status",
|
|
904
|
-
"data-slot": "map-menu-provenance",
|
|
905
|
-
className: "text-muted-foreground col-start-1 row-start-1 flex items-start gap-2",
|
|
906
|
-
children: [
|
|
907
|
-
/* @__PURE__ */ jsx5(MapPin, {
|
|
908
|
-
"aria-hidden": "true",
|
|
909
|
-
className: "text-foreground mt-0.5 size-4 shrink-0"
|
|
910
|
-
}),
|
|
911
|
-
/* @__PURE__ */ jsx5("span", {
|
|
912
|
-
className: "wrap-anywhere",
|
|
913
|
-
children: notice
|
|
914
|
-
})
|
|
915
|
-
]
|
|
916
|
-
}) : null
|
|
917
|
-
]
|
|
918
|
-
}),
|
|
919
|
-
radiusEnabled ? /* @__PURE__ */ jsxs3("div", {
|
|
920
|
-
className: "after:bg-border col-span-full flex flex-wrap items-center gap-3 after:h-px after:flex-1",
|
|
921
|
-
children: [
|
|
922
|
-
/* @__PURE__ */ jsx5("label", {
|
|
923
|
-
htmlFor: `${id}-radius`,
|
|
924
|
-
className: "text-sm font-medium",
|
|
925
|
-
children: labels.searchWithin
|
|
926
|
-
}),
|
|
927
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
928
|
-
className: "relative",
|
|
929
|
-
children: [
|
|
930
|
-
/* @__PURE__ */ jsx5("select", {
|
|
931
|
-
id: `${id}-radius`,
|
|
932
|
-
value: radiusKm,
|
|
933
|
-
className: "bg-card focus-visible:outline-ring h-11 appearance-none rounded border py-2 pr-9 pl-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
934
|
-
onChange: (event) => props.onRadiusChange(Number(event.currentTarget.value)),
|
|
935
|
-
children: radiusOptions.map((radius) => /* @__PURE__ */ jsxs3("option", {
|
|
936
|
-
value: radius,
|
|
937
|
-
children: [
|
|
938
|
-
radius,
|
|
939
|
-
" km"
|
|
940
|
-
]
|
|
941
|
-
}, radius))
|
|
942
|
-
}),
|
|
943
|
-
/* @__PURE__ */ jsx5(ChevronDown, {
|
|
944
|
-
"aria-hidden": "true",
|
|
945
|
-
className: "pointer-events-none absolute top-1/2 right-3 size-4 -translate-y-1/2"
|
|
946
|
-
})
|
|
947
|
-
]
|
|
948
|
-
})
|
|
949
|
-
]
|
|
950
|
-
}) : null
|
|
951
|
-
]
|
|
952
|
-
}),
|
|
953
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
954
|
-
"data-slot": "map-menu-map",
|
|
955
|
-
className: "relative min-h-56 min-w-0 flex-[1_0_14rem] [@media(max-height:599px)]:min-h-[182px] [@media(max-height:599px)]:basis-[182px]",
|
|
956
|
-
children: [
|
|
957
|
-
/* @__PURE__ */ jsx5(MapMenuMap, {
|
|
958
|
-
apiKey,
|
|
959
|
-
center: selectedLocation?.center ?? { lat: 0, lng: 0 },
|
|
960
|
-
zoom: !radiusEnabled && selectedLocation ? 15 : 4,
|
|
961
|
-
marker: selectedLocation ? { icon: markerIcon } : undefined,
|
|
962
|
-
radius: radiusEnabled && selectedLocation && radiusKm !== undefined ? {
|
|
963
|
-
radiusMeters: radiusKm * 1000,
|
|
964
|
-
fillColor: overlayColor,
|
|
965
|
-
fillOpacity: 0.12,
|
|
966
|
-
strokeColor: overlayColor,
|
|
967
|
-
strokeOpacity: 0.82,
|
|
968
|
-
strokeWeight: 2
|
|
969
|
-
} : undefined,
|
|
970
|
-
fitRadius: radiusEnabled && Boolean(selectedLocation),
|
|
971
|
-
fitPadding: 40,
|
|
972
|
-
minZoom: 3,
|
|
973
|
-
maxZoom: 18,
|
|
974
|
-
locale,
|
|
975
|
-
className: "h-full min-h-0 w-full rounded-md",
|
|
976
|
-
controlsClassName: "bg-card rounded-md shadow-md"
|
|
977
|
-
}),
|
|
978
|
-
radiusEnabled && selectedLocation ? /* @__PURE__ */ jsx5("p", {
|
|
979
|
-
className: "bg-card text-muted-foreground pointer-events-none absolute bottom-[25px] left-3 m-0 max-w-[calc(100%-24px)] rounded px-2.5 py-[7px] text-xs shadow-sm",
|
|
980
|
-
children: labels.radiusHint
|
|
981
|
-
}) : null
|
|
982
|
-
]
|
|
983
|
-
})
|
|
984
|
-
]
|
|
985
|
-
}),
|
|
986
|
-
/* @__PURE__ */ jsxs3(DialogFooter, {
|
|
987
|
-
className: "shrink-0 gap-3 border-0 bg-transparent px-5 pt-[18px] pb-[max(18px,env(safe-area-inset-bottom))] sm:px-7 [@media(max-height:599px)]:pt-3 [@media(max-height:599px)]:pb-[max(12px,env(safe-area-inset-bottom))]",
|
|
988
|
-
children: [
|
|
989
|
-
error || confirmFailed ? /* @__PURE__ */ jsx5("p", {
|
|
990
|
-
role: "alert",
|
|
991
|
-
className: "text-destructive w-full self-center text-sm sm:mr-auto sm:w-auto",
|
|
992
|
-
children: error ?? labels.confirmError
|
|
993
|
-
}) : null,
|
|
994
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
995
|
-
className: "flex gap-2",
|
|
996
|
-
children: [
|
|
997
|
-
/* @__PURE__ */ jsx5(Button, {
|
|
998
|
-
type: "button",
|
|
999
|
-
variant: "outline",
|
|
1000
|
-
className: "bg-card min-h-11 flex-1",
|
|
1001
|
-
disabled: applying,
|
|
1002
|
-
onClick: () => changeOpen(false),
|
|
1003
|
-
children: labels.cancel
|
|
1004
|
-
}),
|
|
1005
|
-
/* @__PURE__ */ jsx5(Button, {
|
|
1006
|
-
type: "button",
|
|
1007
|
-
"data-slot": "map-menu-confirm",
|
|
1008
|
-
className: cn("min-h-11 flex-[2] bg-[oklch(0.9247_0.0524_66.1732)] text-zinc-950 hover:bg-[oklch(0.9247_0.0524_66.1732)] hover:brightness-95", confirmClassName),
|
|
1009
|
-
disabled: applying || !selectedMatchesInput || !selectedLocation,
|
|
1010
|
-
onClick: () => void confirm(),
|
|
1011
|
-
children: labels.confirm
|
|
1012
|
-
})
|
|
1013
|
-
]
|
|
1014
|
-
})
|
|
1015
|
-
]
|
|
1016
|
-
})
|
|
1017
|
-
]
|
|
1042
|
+
children: content
|
|
1018
1043
|
})
|
|
1019
1044
|
]
|
|
1020
1045
|
})
|
|
@@ -1023,5 +1048,6 @@ var MapMenu = (props) => {
|
|
|
1023
1048
|
export {
|
|
1024
1049
|
MapMenu,
|
|
1025
1050
|
MapMenuMode,
|
|
1051
|
+
MapMenuPresentation,
|
|
1026
1052
|
mapMenuRadiiKm
|
|
1027
1053
|
};
|