{"version":3,"file":"LocationRedirectDropdown.DevcBw4V.mjs","names":["useMemo","useState","useCallback","p","startTransition"],"sources":["https:/framerusercontent.com/modules/Me3fXL9Xz8qeFLQ86u5H/mKvOzPYFPIl78vE52r6U/LocationRedirectDropdown.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import*as React from\"react\";import{startTransition,useCallback,useEffect,useMemo,useState}from\"react\";// make drop down that will select between a list of locations. Oly one location can be selected. The selected location will then automatically redirect to a specific URL for each location\n/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function LocationRedirectDropdown(props){const{locations,placeholder,initialSelection,openInNewTab,disabled,arrowVisible,arrowRight,arrowSize,arrowSlot,backgroundColor,textColor,borderColor,focusBorderColor,borderRadius,padding,font,style}=props;const isStatic=useIsStaticRenderer();const safeLocations=useMemo(()=>{const list=Array.isArray(locations)?locations:[];return list.map(l=>({label:String(l?.label??\"\").trim(),url:String(l?.url??\"\").trim()})).filter(l=>l.label.length>0);},[locations]);const initialValue=useMemo(()=>{if(initialSelection===\"first\"&&safeLocations.length>0)return\"0\";return\"\";},[initialSelection,safeLocations.length]);const[value,setValue]=useState(initialValue);const[isFocused,setIsFocused]=useState(false);useEffect(()=>{startTransition(()=>setValue(initialValue));},[initialValue]);const redirectTo=useCallback(url=>{if(!url)return;if(typeof window===\"undefined\")return;if(isStatic)return;if(openInNewTab){window.open(url,\"_blank\",\"noopener,noreferrer\");}else{window.location.href=url;}},[isStatic,openInNewTab]);const onChange=useCallback(e=>{const next=e.target.value;startTransition(()=>setValue(next));if(next===\"\")return;const index=Number(next);if(!Number.isFinite(index))return;const item=safeLocations[index];if(!item?.url)return;redirectTo(item.url);},[redirectTo,safeLocations]);const computedBorder=isFocused?focusBorderColor:borderColor;const parsedPadding=useMemo(()=>{const p=padding;if(p&&typeof p===\"object\"){const top=String(p.top??p.paddingTop??\"0px\");const right=String(p.right??p.paddingRight??\"0px\");const bottom=String(p.bottom??p.paddingBottom??\"0px\");const left=String(p.left??p.paddingLeft??\"0px\");return{top,right,bottom,left};}const raw=String(p??\"\").trim();const parts=raw.length?raw.split(/\\s+/):[\"0px\"];const top=parts[0]??\"0px\";const right=parts[1]??parts[0]??\"0px\";const bottom=parts[2]??parts[0]??\"0px\";const left=parts[3]??parts[1]??parts[0]??\"0px\";return{top,right,bottom,left};},[padding]);const extraRightPadding=useMemo(()=>{if(!arrowVisible)return 0;// Reserve space so the text never overlaps the arrow.\nreturn Math.max(0,arrowSize+arrowRight+8);},[arrowRight,arrowSize,arrowVisible]);const hasArrowSlot=React.Children.count(arrowSlot)>0;return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",...style},children:[/*#__PURE__*/_jsxs(\"select\",{value:value,onChange:onChange,onFocus:()=>startTransition(()=>setIsFocused(true)),onBlur:()=>startTransition(()=>setIsFocused(false)),disabled:disabled||safeLocations.length===0,\"aria-label\":\"Location selector\",style:{width:\"100%\",height:\"100%\",boxSizing:\"border-box\",appearance:\"none\",WebkitAppearance:\"none\",MozAppearance:\"none\",border:`1px solid ${computedBorder}`,background:backgroundColor,color:textColor,borderRadius,paddingTop:parsedPadding.top,paddingRight:arrowVisible?`calc(${parsedPadding.right} + ${extraRightPadding}px)`:parsedPadding.right,paddingBottom:parsedPadding.bottom,paddingLeft:parsedPadding.left,outline:\"none\",cursor:disabled||safeLocations.length===0?\"not-allowed\":\"pointer\",opacity:disabled||safeLocations.length===0?.6:1,...font},children:[/*#__PURE__*/_jsx(\"option\",{value:\"\",disabled:true,children:placeholder}),safeLocations.map((loc,i)=>/*#__PURE__*/_jsx(\"option\",{value:String(i),children:loc.label},`${loc.label}-${i}`))]}),arrowVisible&&/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{position:\"absolute\",right:arrowRight,top:\"50%\",transform:\"translateY(-50%)\",pointerEvents:\"none\",width:arrowSize,height:arrowSize,color:textColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:hasArrowSlot?/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},children:arrowSlot}):/*#__PURE__*/_jsx(\"svg\",{width:arrowSize,height:arrowSize,viewBox:\"0 0 20 20\",fill:\"none\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M5 7.5L10 12.5L15 7.5\",stroke:\"currentColor\",strokeWidth:1.8,strokeLinecap:\"round\",strokeLinejoin:\"round\"})})})]});}addPropertyControls(LocationRedirectDropdown,{locations:{type:ControlType.Array,title:\"Locations\",maxCount:25,defaultValue:[{label:\"New York\",url:\"https://example.com/new-york\"},{label:\"London\",url:\"https://example.com/london\"},{label:\"Tokyo\",url:\"https://example.com/tokyo\"}],control:{type:ControlType.Object,controls:{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Location\"},url:{type:ControlType.Link,title:\"URL\",defaultValue:\"https://example.com\"}}}},placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Select a location…\"},initialSelection:{type:ControlType.Enum,title:\"Initial\",options:[\"none\",\"first\"],optionTitles:[\"None\",\"First\"],defaultValue:\"none\",displaySegmentedControl:true},openInNewTab:{type:ControlType.Boolean,title:\"Open\",defaultValue:false,enabledTitle:\"New tab\",disabledTitle:\"Same tab\"},disabled:{type:ControlType.Boolean,title:\"Disabled\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},arrowVisible:{type:ControlType.Boolean,title:\"Arrow\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},arrowSize:{type:ControlType.Number,title:\"Arrow Size\",defaultValue:14,min:8,max:48,step:1,unit:\"px\",hidden:({arrowVisible})=>!arrowVisible},arrowSlot:{type:ControlType.Slot,title:\"Arrow Layer\",maxCount:1,hidden:({arrowVisible})=>!arrowVisible},arrowRight:{type:ControlType.Number,title:\"Arrow Right\",defaultValue:12,min:0,max:60,step:1,unit:\"px\",hidden:({arrowVisible})=>!arrowVisible},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#EEEEEE\"},focusBorderColor:{type:ControlType.Color,title:\"Focus Border\",defaultValue:\"#000000\"},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"10px\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"10px\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LocationRedirectDropdown\",\"slots\":[\"arrowSlot\"],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LocationRedirectDropdown.map"],"mappings":"qOAIG,SAAwB,EAAyB,EAAM,CAAC,GAAK,CAAC,YAAU,cAAY,mBAAiB,eAAa,WAAS,eAAa,aAAW,YAAU,YAAU,kBAAgB,YAAU,cAAY,mBAAiB,eAAa,UAAQ,OAAK,SAAO,EAAY,EAAS,GAAqB,CAAO,EAAcA,OAAwB,MAAM,QAAQ,EAAU,CAAC,EAAU,EAAE,EAAa,IAAI,IAAI,CAAC,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,GAAG,EAAE,MAAM,OAAO,EAAE,CAAG,CAAC,EAAU,CAAC,CAAO,EAAaA,MAAgB,IAAmB,SAAS,EAAc,O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