{"version":3,"file":"SelectField.BqaOFPPz.mjs","names":["SHARED_VISIBILITY_GROUP","useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/jGDRwUN8C3dSx4an2Rnk/0pcmsTrIaZPj0qLOK9H3/controls.js","https:/framerusercontent.com/modules/EAqQWXlNB7I0PDrJI272/VXASx3kvj2bURreDtCtm/SelectField.js"],"sourcesContent":["import{ControlType}from\"framer\";import{FIELD_BASE_GROUP,BASE_VALIDATION_GROUP,INPUT_LIKE_STYLES_GROUP,VISIBILITY_GROUP as SHARED_VISIBILITY_GROUP}from\"https://framerusercontent.com/modules/C8tNKt5QFlvgRghgBcI7/QSBiltfheNvniAd76oGI/groups.js\";// Behavior-only (base + select-specific bits)\nexport const SELECT_BEHAVIOR_CONTROLS={...FIELD_BASE_GROUP,placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Select an option\"},options:{type:ControlType.Array,title:\"Options\",propertyControl:{type:ControlType.Object,controls:{title:{type:ControlType.String,title:\"Title\",defaultValue:\"Option Label\"},value:{type:ControlType.String,title:\"Value\",defaultValue:\"option_value\"}}},defaultValue:[{title:\"First option\",value:\"1\"},{title:\"Second option\",value:\"2\"},{title:\"Third option\",value:\"3\"}]},// shared validation (regex/min/max stay conditional via BASE_VALIDATION_GROUP)\n...BASE_VALIDATION_GROUP};// One “Styles” object with nested sections from shared groups\nexport const STYLES_GROUP={styles:{type:ControlType.Object,title:\"Styles\",controls:{...INPUT_LIKE_STYLES_GROUP}}};// Visibility (shared)\nexport const VISIBILITY_GROUP=SHARED_VISIBILITY_GROUP;\nexport const __FramerMetadata__ = {\"exports\":{\"VISIBILITY_GROUP\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"STYLES_GROUP\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SELECT_BEHAVIOR_CONTROLS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useMemo,useState,useRef,useEffect}from\"react\";import{addPropertyControls,ControlType,useLocaleCode}from\"framer\";import{FieldShell}from\"https://framerusercontent.com/modules/Y7BsCDAZ62PW8UCuAxAR/eYfP4PWTX5NJfei4V1k9/FieldShell.js\";import{resolveBorderColor}from\"https://framerusercontent.com/modules/SuWmgiqEfziwld4tZjk0/vb8Ppfe3v4uGW3SEUjKK/resolveBorderColor.js\";import{resolveInputStyles}from\"https://framerusercontent.com/modules/TTk3k6z1DBNnw11HPDoi/UW2qJn2g2OkOcIXT204S/resolveInputStyles.js\";import{buildValidationConfig}from\"https://framerusercontent.com/modules/ZAzAf2l3YtTE023XEAPY/6IKs8kEebel4WFLLKexC/buildValidationConfig.js\";import{requiredWhenVisible}from\"https://framerusercontent.com/modules/e3bwJJzcbGbYL2t6KZy3/kO1TIg95YTyfRIpPfLWl/requiredWhenVisible.js\";import{useFieldController}from\"https://framerusercontent.com/modules/De6fH1u2sz6OPdwkg379/SgE9iQI5PSl3PyNwKMm7/useFieldController.js\";import{useRenderKey,useTouched}from\"https://framerusercontent.com/modules/Ax3pgpFugmVtkLyjK0aB/gjk6sN8WNzrAQFqhH8LV/formStores.js\";import{SELECT_BEHAVIOR_CONTROLS,STYLES_GROUP,VISIBILITY_GROUP}from\"https://framerusercontent.com/modules/jGDRwUN8C3dSx4an2Rnk/0pcmsTrIaZPj0qLOK9H3/controls.js\";import{getTpvOptions}from\"https://framerusercontent.com/modules/WSbRwPXG1NmB70ZmGYf5/IwMHpjtg85hsTSiZmeXS/tpvBuckets.js\";export function SelectField(props){const{// base\nlabel,apiName,required=false,errorRequired,errorInvalid,errorTooYoung,validationRule=\"none\",minLength,maxLength,regex,regexFlags,visibility,styles={},// select-specific\noptions=[],placeholder=\"Select an option\",// optional icon\nicon}=props;const{value,setValue,error,isTouched,visible,validateNow,validateSoon,markTouched,handleFocus,handleBlur,handleChange}=useFieldController({apiName,initialValue:\"\",visibility,validation:buildValidationConfig({required,errorRequired,errorInvalid,errorTooYoung,validationRule,minLength,maxLength,regex,regexFlags})});const[isFocused,setIsFocused]=useState(false);const[iconWidth,setIconWidth]=useState(0);const renderKey=useRenderKey()[0];const[,setTouched]=useTouched();const selectRef=useRef(null);const iconRef=useRef(null);const lastRenderKeyRef=useRef(renderKey);const lastEffectRenderKeyRef=useRef(renderKey);// Reset field controller state when render key changes (synchronous)\nif(lastRenderKeyRef.current!==renderKey){lastRenderKeyRef.current=renderKey;setValue(\"\")// Reset field controller state immediately\n;setTouched(prev=>({...prev,[apiName]:false}))// Clear touched state\n;}// Reset DOM select value when render key changes\nuseEffect(()=>{if(lastEffectRenderKeyRef.current!==renderKey){lastEffectRenderKeyRef.current=renderKey;if(selectRef.current){selectRef.current.value=\"\";}}},[renderKey]);useEffect(()=>{if(!iconRef.current)return;const observer=new ResizeObserver(entries=>{for(const entry of entries){setIconWidth(entry.contentRect.width);}});observer.observe(iconRef.current);return()=>observer.disconnect();},[iconRef.current]);const countryCode=useLocaleCode().split(\"-\")[1]??\"GB\";const normalizedOptions=useMemo(()=>(apiName===\"lead_expected_monthly_tpv\"?getTpvOptions(countryCode,options??[]):options??[]).map(o=>({title:o.title,value:String(o.value)})),[options,apiName,countryCode]);const{fontSize,fontWeight,letterSpacing,lineHeight,textAlign,textColor,placeholderColor,backgroundColor,borderColor,focusBorderColor,errorBorderColor,borderRadius,borderWidth,paddingV,paddingH,height,labelStyle,labelSpacing,errorStyle}=resolveInputStyles(styles);const border=resolveBorderColor({showError:isTouched,error,isFocused,errorColor:errorBorderColor,focusColor:focusBorderColor,baseColor:borderColor});const ICON_GAP=8;const hasIcon=Boolean(icon);const leftPad=hasIcon&&iconWidth>0?paddingH+iconWidth+ICON_GAP:paddingH;const wrapperStyle={position:\"relative\",width:\"100%\",display:\"flex\",alignItems:\"center\"};const selectStyle={width:\"100%\",display:\"block\",boxSizing:\"border-box\",color:value?textColor:placeholderColor,backgroundColor,borderColor:border,borderWidth,borderStyle:\"solid\",borderRadius,paddingTop:paddingV,paddingBottom:paddingV,paddingRight:paddingH,paddingLeft:leftPad,height:height?`${height}px`:undefined,outline:\"none\",fontSize,fontWeight,fontFamily:\"Figtree, sans-serif\",letterSpacing,lineHeight:`${lineHeight}px`,textAlign,transition:\"border-color 120ms ease, color 120ms ease\",appearance:\"none\"};const iconStyle={position:\"absolute\",left:paddingH,top:\"50%\",transform:\"translateY(-50%)\",display:hasIcon?\"flex\":\"none\",alignItems:\"center\",justifyContent:\"center\",pointerEvents:\"none\"};const onChange=e=>{const next=e.target.value;setValue(next);handleChange(next);validateSoon(next);};const onBlur=()=>{markTouched();validateNow(selectRef.current?.value??\"\");handleBlur();setIsFocused(false);};const onFocus=()=>{handleFocus();setIsFocused(true);};return /*#__PURE__*/_jsx(FieldShell,{visible:visible,label:label,labelStyle:labelStyle,labelSpacing:labelSpacing,error:isTouched&&error?error:null,errorStyle:errorStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:wrapperStyle,children:[icon?/*#__PURE__*/_jsx(\"div\",{ref:iconRef,style:iconStyle,children:icon}):null,/*#__PURE__*/_jsxs(\"select\",{ref:selectRef,name:apiName,required:requiredWhenVisible(required,visible),style:selectStyle,defaultValue:value??\"\",onChange:onChange,onBlur:onBlur,onFocus:onFocus,children:[/*#__PURE__*/_jsx(\"option\",{value:\"\",disabled:true,hidden:true,children:placeholder}),normalizedOptions.map(opt=>/*#__PURE__*/_jsx(\"option\",{value:opt.value,children:opt.title},opt.value))]}),/*#__PURE__*/_jsx(\"svg\",{viewBox:\"0 0 20 20\",width:\"16\",height:\"16\",fill:\"none\",stroke:textColor,strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:{position:\"absolute\",pointerEvents:\"none\",right:paddingH,top:\"50%\",transform:\"translateY(-50%)\"},children:/*#__PURE__*/_jsx(\"polyline\",{points:\"6 8 10 12 14 8\"})})]})});}addPropertyControls(SelectField,{...SELECT_BEHAVIOR_CONTROLS,...STYLES_GROUP,...VISIBILITY_GROUP,icon:{type:ControlType.ComponentInstance,title:\"Icon\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"SelectField\":{\"type\":\"reactComponent\",\"name\":\"SelectField\",\"slots\":[\"icon\"],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"geAA+B,IAAkN,EACpO,EAAyB,CAAC,GAAG,EAAiB,YAAY,CAAC,KAAK,EAAY,OAAO,MAAM,cAAc,aAAa,kBAAkB,EAAE,QAAQ,CAAC,KAAK,EAAY,MAAM,MAAM,UAAU,gBAAgB,CAAC,KAAK,EAAY,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,EAAY,OAAO,MAAM,QAAQ,aAAa,cAAc,EAAE,MAAM,CAAC,KAAK,EAAY,OAAO,MAAM,QAAQ,aAAa,cAAc,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,MAAM,eAAe,MAAM,GAAG,EAAE,CAAC,MAAM,gBAAgB,MAAM,GAAG,EAAE,CAAC,MAAM,eAAe,MAAM,GAAG,CAAC,CAAC,EAChgB,GAAG,CAAqB,EACX,EAAa,CAAC,OAAO,CAAC,KAAK,EAAY,OAAO,MAAM,SAAS,SAAS,CAAC,GAAG,CAAuB,CAAC,CAAC,EACnG,EAAiBA,KCJ00C,SAAgB,EAAY,EAAM,CAAC,GAAK,CACh5C,QAAM,UAAQ,WAAS,GAAM,gBAAc,eAAa,gBAAc,iBAAe,OAAO,YAAU,YAAU,QAAM,aAAW,aAAW,SAAO,CAAC,EACpJ,UAAQ,CAAC,EAAE,cAAY,mBACvB,QAAM,EAAW,CAAC,QAAM,WAAS,QAAM,YAAU,UAAQ,cAAY,eAAa,cAAY,eAAY,cAAW,iBAAc,EAAmB,CAAC,UAAQ,aAAa,GAAG,aAAW,WAAW,EAAsB,CAAC,WAAS,gBAAc,eAAa,gBAAc,iBAAe,YAAU,YAAU,QAAM,YAAU,CAAC,CAAC,CA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