{"version":3,"file":"CountryInput.CMEgPDfC.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/txadBxzyc8xVP8tgxh1j/1tF1GrgTyNspcfcSvkWo/CountryInput.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useState,useEffect,useRef}from\"react\";import{motion}from\"framer-motion\";import{createBackground,Border,parsePadding,useInstanceId,Icon,HiddenInput}from\"https://framerusercontent.com/modules/DwWOdDzQZGCuvkNlbUjZ/hMz2wp3CWZkNwPJFGPgQ/FramerFormsShared.js\";import{countries,countryEmojis}from\"https://framerusercontent.com/modules/1LECUrurTpenvfDn1ShM/nL9gmnXABjh04Nl8aaL8/Countries.js\";import{CountryDropdown}from\"https://framerusercontent.com/modules/SRHLnHriy9CtZfYf0KJF/l79PAJhiVgI4zvdb2YN1/CountryDropdown.js\";import{dropdownProp,getSharedStyleControls}from\"https://framerusercontent.com/modules/PwJ4k4IqmEWPlM2ZI4Eu/Ow3xyrL3YR7stkg8VL2K/DropdownUtilities.js\";// ============================================================================\n// MAIN COMPONENT\n// ============================================================================\n/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 400\n * @framerDisableUnlink\n */export default function CountryInput(props){const{shadows,border,icon}=props;const id=useInstanceId();const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[focused,setFocused]=useState(false);const[invalid,setInvalid]=useState(false);const[dropdownOpen,setDropdownOpen]=useState(false);const[searchQuery,setSearchQuery]=useState(\"\");const[selectedCountry,setSelectedCountry]=useState(props.defaultValue&&props.defaultValue!==\"none\"?props.defaultValue:\"\");// Update selectedCountry when defaultValue prop changes\nuseEffect(()=>{if(props.defaultValue&&props.defaultValue!==\"none\"){setSelectedCountry(props.defaultValue);}else{setSelectedCountry(\"\");}},[props.defaultValue]);const dropdownRef=useRef(null);const searchInputRef=useRef(null);const inputRef=useRef(null);const[pt,pr,pb,pl]=parsePadding(props.padding);// Filter countries based on search query\nconst filteredCountries=searchQuery?countries.filter((country,index)=>{const searchLower=searchQuery.toLowerCase();return country.toLowerCase().includes(searchLower)||props.flagEmojis&&(countryEmojis[index]+\" \"+country).toLowerCase().includes(searchLower);}):countries;// Close dropdown when clicking outside\nuseEffect(()=>{const handleClickOutside=event=>{const target=event.target;const isOutsideDropdown=dropdownRef.current&&!dropdownRef.current.contains(target);const isOutsideInput=inputRef.current&&!inputRef.current.contains(target);if(isOutsideDropdown&&isOutsideInput){setDropdownOpen(false);setSearchQuery(\"\");setFocused(false);}};if(dropdownOpen||focused){document.addEventListener(\"mousedown\",handleClickOutside);return()=>{document.removeEventListener(\"mousedown\",handleClickOutside);};}},[dropdownOpen,focused]);// Focus search input when dropdown opens\nuseEffect(()=>{if(dropdownOpen&&searchInputRef.current){setTimeout(()=>{searchInputRef.current?.focus();},100);}},[dropdownOpen]);function onFocus(){setFocused(true);setDropdownOpen(true);props.focusEvent?.();if(invalid){setInvalid(false);}}function onBlur(event){// Don't blur if clicking on dropdown\nconst relatedTarget=event.relatedTarget;if(dropdownRef.current?.contains(relatedTarget)||searchInputRef.current===relatedTarget){return;}if(!dropdownOpen){setFocused(false);setSearchQuery(\"\");props.blurEvent?.();}}function onInputClick(){setDropdownOpen(true);setFocused(true);props.focusEvent?.();if(invalid){setInvalid(false);}}function onCountrySelect(country){setSelectedCountry(country);setDropdownOpen(false);setSearchQuery(\"\");setFocused(false);inputRef.current?.blur();}const onInvalid=event=>{event.preventDefault();setInvalid(true);props.invalidEvent?.();};// Handle value restoration from FormPersistence\nfunction onSetValueEvent(event){const value=event.detail;if(!value||value===\"none\"){setSelectedCountry(\"\");return;}if(countries.includes(value)){setSelectedCountry(value);}}// Get display text for selected country\nconst getDisplayText=()=>{if(!selectedCountry||selectedCountry===\"none\"){return props.noneSelectedText||\"Select a country...\";}const countryIndex=countries.indexOf(selectedCountry);if(props.flagEmojis&&countryIndex>=0){return`${countryEmojis[countryIndex]} ${selectedCountry}`;}return selectedCountry;};return /*#__PURE__*/_jsxs(motion.div,{\"data-framerforms\":true,id:id,style:{position:\"relative\",borderRadius:props.radius},initial:false,transition:props.transition,children:[/*#__PURE__*/_jsx(HiddenInput,{name:props.name,required:props.required&&!selectedCountry,value:selectedCountry,setInvalid:setInvalid,onSetValueEvent:onSetValueEvent}),/*#__PURE__*/_jsx(CountryDropdown,{isOpen:dropdownOpen,dropdownRef:dropdownRef,searchInputRef:searchInputRef,searchQuery:searchQuery,onSearchChange:setSearchQuery,filteredCountries:filteredCountries,selectedCountry:selectedCountry,onCountrySelect:onCountrySelect,containerId:id,fill:props.fill,color:props.color,font:props.font,isCanvas:isCanvas,showDropdown:props.showDropdown,showFlags:props.flagEmojis,showDialCodes:false,pinnedCountries:props.pinnedCountries,dropdownStyle:props.dropdown,borderRadius:props.radius,padding:props.padding,placeholderColor:props.placeholderColor||props.color+\"80\",bgBlur:props.bgBlur}),/*#__PURE__*/_jsxs(motion.div,{ref:inputRef,onClick:onInputClick,onFocus:onFocus,onBlur:onBlur,tabIndex:0,animate:{...createBackground(props.fill,null,focused,invalid),boxShadow:invalid&&shadows?.invalid||focused&&shadows?.focus||shadows?.default},style:{position:\"relative\",borderRadius:props.radius,cursor:\"pointer\",backdropFilter:props.bgBlur?`blur(${props.bgBlur}px)`:undefined,...props.style},initial:false,transition:props.transition,children:[/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",padding:icon?`${pt}px ${pr+icon.size+8}px ${pb}px ${pl}px`:props.padding,color:selectedCountry?props.color:props.placeholderColor||props.color+\"80\",textOverflow:\"ellipsis\",overflow:\"hidden\",whiteSpace:\"nowrap\",...props.font},children:getDisplayText()}),icon&&/*#__PURE__*/_jsx(Icon,{...icon,style:{position:\"absolute\",right:pr,top:\"50%\",transform:\"translateY(-50%)\",pointerEvents:\"none\"},defaultImage:`url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\"><path d=\"M 3.5 6 L 8 10.5 L 12.5 6\" fill=\"transparent\" stroke-width=\"1.5\" stroke=\"rgb(153, 153, 153)\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg>')`}),/*#__PURE__*/_jsx(Border,{...props.border,borderColor:invalid&&border?.colorInvalid||focused&&border?.colorFocus||border?.color,transition:props.transition})]}),/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:`#${id} [tabindex]:focus { outline: none; }`}})]});}CountryInput.displayName=\"Country Input\";addPropertyControls(CountryInput,{name:{type:ControlType.String,defaultValue:\"Country\"},showDropdown:{type:ControlType.Boolean,defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\",title:\"Dropdown\"},dropdown:dropdownProp(),required:{type:ControlType.Boolean,defaultValue:false},autoFocus:{type:ControlType.Boolean,defaultValue:false,title:\"Auto-Focus\"},pinnedCountries:{type:ControlType.Array,defaultValue:[],control:{type:ControlType.Enum,options:countries},title:\"Pinned\"},defaultValue:{type:ControlType.Enum,defaultValue:\"none\",options:[\"none\",...countries],optionTitles:[\"None\",...countries]},noneSelectedText:{title:\"Placeholder\",type:ControlType.String,defaultValue:\"Select a country...\",hidden:props=>props.defaultValue!==\"none\"},flagEmojis:{type:ControlType.Boolean,defaultValue:true},// Shared style controls - includes placeholderColor with default from SHARED_DEFAULTS\n// Component-specific controls (like noneSelectedText above) are defined separately\n// To override a default value, pass it as an option:\n// Example: color: \"#999999\" to override the default color\n// Example: placeholderColor: \"#666\" to override the default placeholder color\n// See DropdownUtilities.tsx SHARED_DEFAULTS for all available defaults\n...getSharedStyleControls({invalid:true})});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountryInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\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