{"version":3,"file":"CMS_Dropdown.BSF2-RnC.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/NDtnTj0HprvIgRdY39i0/7CwX0tj6cEGSt888egpJ/CMS_Dropdown.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect,useCallback}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// ---- Google Fonts Loader ----\nconst FONT_LINK_ID=\"cms-dropdown-fonts\";function loadFonts(){if(typeof document===\"undefined\")return;if(document.getElementById(FONT_LINK_ID))return;const link=document.createElement(\"link\");link.id=FONT_LINK_ID;link.rel=\"stylesheet\";link.href=\"https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700&family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&display=swap\";document.head.appendChild(link);}// ---- Find native Framer <select> dropdown ----\nfunction findNativeSelect(labelText){// Strategy 1: Find by the label text near the select\nconst labels=document.querySelectorAll('[data-framer-name=\"Category Dropdown\"] select');if(labels.length>0)return labels[0];// Strategy 2: Find any select whose options include \"All Categories\"\nconst allSelects=document.querySelectorAll(\"select\");for(const sel of allSelects){const opts=Array.from(sel.options).map(o=>o.text);if(opts.some(o=>o.includes(\"All\"))){return sel;}}// Strategy 3: Find by label text match\nconst allLabels=document.querySelectorAll(\"label\");for(const lbl of allLabels){if(lbl.textContent?.includes(labelText)||lbl.getAttribute(\"data-framer-name\")?.toLowerCase().includes(\"category\")){const sel=lbl.querySelector(\"select\");if(sel)return sel;}}return null;}// ---- Component ----\nexport default function CMSDropdown({nativeDropdownLabel=\"Category Dropdown\",hideNativeDropdown=true,label=\"Search by Category\",defaultText=\"All Categories\",cardBgColor=\"#FFFFFF\",dropdownBgColor=\"#FFFFFF\",textColor=\"#2D2926\",labelColor=\"#2D2926\",accentColor=\"#177881\",borderColor=\"#E9EAEB\",cardBorderRadius=12,dropdownBorderRadius=8,labelFontSize=14,labelFontWeight=600,optionFontSize=14,cardPadding=16,dropdownHeight=48}){const[open,setOpen]=useState(false);const[selected,setSelected]=useState(null);const[options,setOptions]=useState([]);const ref=useRef(null);const nativeSelectRef=useRef(null);// Load fonts\nuseEffect(()=>{loadFonts();},[]);// Find the native select, extract options, and optionally hide it\nuseEffect(()=>{const init=()=>{const sel=findNativeSelect(nativeDropdownLabel);if(!sel)return false;nativeSelectRef.current=sel;// Extract options (skip \"All Categories\" — we add it ourselves)\nconst opts=Array.from(sel.options).map(o=>o.text.trim()).filter(o=>o&&o.toLowerCase()!==\"all categories\"&&o.toLowerCase()!==\"all\");setOptions(opts);// Hide the native dropdown and walk up to hide its\n// closest meaningful wrapper (removes leftover shadow/line)\nif(hideNativeDropdown){const label=sel.closest(`[data-framer-name=\"${nativeDropdownLabel}\"]`)||sel.closest(\"label\");if(label){label.style.display=\"none\";}// Walk up from the label to find a parent wrapper that\n// only contains this dropdown (safe to hide entirely)\nlet wrapper=label?.parentElement;while(wrapper){const children=wrapper.children;const visibleChildren=Array.from(children).filter(c=>window.getComputedStyle(c).display!==\"none\");if(visibleChildren.length===0){wrapper.style.display=\"none\";wrapper=wrapper.parentElement;}else{break;}}}return true;};// Try immediately, then retry with delays for Framer's async rendering\nif(!init()){const t1=setTimeout(()=>{if(!init()){const t2=setTimeout(init,1500);return()=>clearTimeout(t2);}},500);return()=>clearTimeout(t1);}},[nativeDropdownLabel,hideNativeDropdown]);// Close on outside click\nuseEffect(()=>{const handler=e=>{if(ref.current&&!ref.current.contains(e.target)){setOpen(false);}};document.addEventListener(\"mousedown\",handler);return()=>document.removeEventListener(\"mousedown\",handler);},[]);// When user selects, trigger the native select's change event\nconst handleSelect=useCallback(option=>{setSelected(option);setOpen(false);const sel=nativeSelectRef.current;if(!sel)return;// Find the matching option in the native select\nconst targetValue=option??\"\";for(let i=0;i<sel.options.length;i++){const optText=sel.options[i].text.trim();if(option===null?optText.toLowerCase().includes(\"all\"):optText===option){sel.selectedIndex=i;break;}}// Dispatch events so Framer picks up the change\nsel.dispatchEvent(new Event(\"input\",{bubbles:true}));sel.dispatchEvent(new Event(\"change\",{bubbles:true}));},[]);// ---- Font families ----\nconst labelFont=\"'Nunito Sans', sans-serif\";const optionFont=\"'Fraunces', serif\";// ---- Shadow ----\nconst shadow=\"0px 4px 16px 0px rgba(0, 0, 0, 0.12)\";// ---- Styles ----\nconst cardStyle={width:\"100%\",background:cardBgColor,border:`1px solid ${borderColor}`,borderRadius:cardBorderRadius,boxShadow:shadow,padding:cardPadding,boxSizing:\"border-box\"};const labelStyle={fontSize:labelFontSize,fontWeight:labelFontWeight,color:labelColor,marginBottom:4,fontFamily:labelFont,lineHeight:1.4,opacity:.6};const triggerStyle={width:\"100%\",height:dropdownHeight,display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",padding:\"0\",background:dropdownBgColor,color:textColor,fontSize:optionFontSize,fontFamily:optionFont,lineHeight:\"1.2em\",border:\"none\",borderRadius:dropdownBorderRadius,cursor:\"pointer\",transition:\"background 0.2s\",outline:\"none\",boxSizing:\"border-box\"};const panelStyle={position:\"absolute\",top:dropdownHeight+24,left:-cardPadding,width:`calc(100% + ${cardPadding*2}px)`,maxHeight:280,overflowY:\"auto\",background:dropdownBgColor,borderRadius:cardBorderRadius,border:`1px solid ${borderColor}`,boxShadow:shadow,zIndex:999,padding:\"4px 0\",boxSizing:\"border-box\"};const optionBase={padding:`10px ${cardPadding}px`,fontSize:optionFontSize,fontFamily:optionFont,lineHeight:\"1.2em\",cursor:\"pointer\",transition:\"background 0.15s, color 0.15s\",color:textColor};const dividerStyle={height:1,background:borderColor,margin:`4px ${cardPadding}px`};// Chevron SVG\nconst chevron=/*#__PURE__*/_jsx(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:open?accentColor:\"#1F313A\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:{transition:\"transform 0.2s, stroke 0.2s\",transform:open?\"rotate(180deg)\":\"rotate(0deg)\",flexShrink:0},children:/*#__PURE__*/_jsx(\"polyline\",{points:\"6 9 12 15 18 9\"})});const renderOption=(optLabel,value,isActive)=>/*#__PURE__*/_jsx(\"div\",{onClick:()=>handleSelect(value),style:{...optionBase,background:isActive?`${accentColor}14`:\"transparent\",fontWeight:isActive?600:400,color:isActive?accentColor:textColor},onMouseEnter:e=>{if(!isActive)e.currentTarget.style.background=\"#f5f5f5\";},onMouseLeave:e=>{e.currentTarget.style.background=isActive?`${accentColor}14`:\"transparent\";},children:optLabel},optLabel);return /*#__PURE__*/_jsxs(\"div\",{style:cardStyle,children:[label&&/*#__PURE__*/_jsx(\"div\",{style:labelStyle,children:label}),/*#__PURE__*/_jsxs(\"div\",{ref:ref,style:{position:\"relative\",width:\"100%\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:triggerStyle,onClick:()=>setOpen(!open),children:[/*#__PURE__*/_jsx(\"span\",{style:{overflow:\"hidden\",textOverflow:\"ellipsis\",whiteSpace:\"nowrap\",marginRight:8},children:selected??defaultText}),chevron]}),open&&/*#__PURE__*/_jsxs(\"div\",{style:panelStyle,children:[renderOption(defaultText,null,selected===null),/*#__PURE__*/_jsx(\"div\",{style:dividerStyle}),options.length>0?options.map(opt=>renderOption(opt,opt,opt===selected)):renderOption(\"No categories found\",null,false)]})]})]});}// ---- Framer Property Controls ----\naddPropertyControls(CMSDropdown,{nativeDropdownLabel:{type:ControlType.String,title:\"Native Dropdown Name\",defaultValue:\"Category Dropdown\",description:\"The data-framer-name of Framer's native dropdown to sync with.\"},hideNativeDropdown:{type:ControlType.Boolean,title:\"Hide Native Dropdown\",defaultValue:true,description:\"Hides Framer's native select dropdown from the page.\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Search by Category\"},defaultText:{type:ControlType.String,title:\"Default Text\",defaultValue:\"All Categories\"},cardBgColor:{type:ControlType.Color,title:\"Card Background\",defaultValue:\"#FFFFFF\"},dropdownBgColor:{type:ControlType.Color,title:\"Dropdown Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#2D2926\"},labelColor:{type:ControlType.Color,title:\"Label Color\",defaultValue:\"#2D2926\"},accentColor:{type:ControlType.Color,title:\"Accent Color\",defaultValue:\"#177881\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#E9EAEB\"},cardBorderRadius:{type:ControlType.Number,title:\"Card Border Radius\",defaultValue:12,min:0,max:30,step:1},dropdownBorderRadius:{type:ControlType.Number,title:\"Dropdown Border Radius\",defaultValue:8,min:0,max:24,step:1},cardPadding:{type:ControlType.Number,title:\"Card Padding\",defaultValue:16,min:8,max:40,step:2},labelFontSize:{type:ControlType.Number,title:\"Label Font Size\",defaultValue:14,min:10,max:24,step:1},labelFontWeight:{type:ControlType.Number,title:\"Label Font Weight\",defaultValue:600,min:400,max:800,step:100},optionFontSize:{type:ControlType.Number,title:\"Option Font Size\",defaultValue:14,min:10,max:24,step:1},dropdownHeight:{type:ControlType.Number,title:\"Dropdown Height\",defaultValue:48,min:36,max:64,step:2}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSDropdown\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMS_Dropdown.map"],"mappings":"qNACwC,SAAS,GAAW,CAAyC,GAArC,OAAO,SAAW,KAAsB,SAAS,eAAe,CAAY,EAAE,OAAO,IAAM,EAAK,SAAS,cAAc,MAAM,EAAE,EAAK,GAAG,EAAa,EAAK,IAAI,aAAa,EAAK,KAAK,gJAAgJ,SAAS,KAAK,YAAY,CAAI,CAAE,CACpa,SAAS,EAAiB,EAAU,CACpC,IAAM,EAAO,SAAS,iBAAiB,+CAA+C,EAAE,GAAG,EAAO,OAAO,EAAE,OAAO,EAAO,GACzH,IAAM,EAAW,SAAS,iBAAiB,QAAQ,EAAE,IAAI,IAAM,KAAO,EAA8D,GAAvC,MAAM,KAAK,EAAI,O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