{"version":3,"file":"FilterBar.BYtDVCKx.mjs","names":["useState","c"],"sources":["https:/framerusercontent.com/modules/TLN6KE7fnXsHAZaxDBtZ/MpkcVTl6iJqp5jv6IE1J/FilterBar.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{C,useTheme}from\"https://framerusercontent.com/modules/cbMRVrUUIur5pqBJymJQ/DFZkrAdDZpFII6exxvRJ/Theme.js\";/**\n * Filter Bar — category chips that filter a CMS list on the same page.\n * Setup:\n *  1. Name your Collection List layer so it contains \"[filter-target]\".\n *  2. Inside each item, name the text that holds the category \"Category\".\n *  3. Type the categories below, separated by commas.\n * Colours and font follow your colour and text styles (see Theme.tsx).\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function FilterBar(props){const{allLabel,categories,showCount,text,muted,chip,chipOn,line,font}=useTheme(props);const cats=[allLabel,...String(categories).split(\",\").map(c=>c.trim()).filter(Boolean)];const[active,setActive]=useState(allLabel);const[counts,setCounts]=useState({});const items=()=>{const target=document.querySelector('[data-framer-name*=\"[filter-target]\"]');return target?Array.from(target.children):[];};const catOf=el=>(el.querySelector('[data-framer-name=\"Category\"]')?.textContent||\"\").trim().toLowerCase();useEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas||typeof document===\"undefined\")return;const all=items();const c={[allLabel]:all.length};all.forEach(el=>{const k=catOf(el);cats.forEach(cat=>{if(cat.toLowerCase()===k)c[cat]=(c[cat]||0)+1;});});setCounts(c);},[categories]);useEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas||typeof document===\"undefined\")return;items().forEach(el=>{const ok=active===allLabel||catOf(el)===active.toLowerCase();el.style.display=ok?\"\":\"none\";if(ok){el.classList.add(\"nx-in\");el.querySelectorAll(\".nx-hidden\").forEach(x=>x.classList.add(\"nx-in\"));}});},[active]);return /*#__PURE__*/_jsx(\"div\",{role:\"group\",\"aria-label\":\"Filter\",style:{display:\"flex\",flexWrap:\"wrap\",gap:8,fontFamily:`\"${font}\", sans-serif`},children:cats.map(c=>{const on=c===active;return /*#__PURE__*/_jsxs(\"button\",{type:\"button\",\"aria-pressed\":on,onClick:()=>setActive(c),style:{display:\"inline-flex\",alignItems:\"center\",gap:6,height:36,padding:\"0 15px\",borderRadius:99,border:0,cursor:\"pointer\",fontFamily:\"inherit\",fontSize:14,background:on?chipOn:chip,color:on?C.onLight:muted,boxShadow:on?\"none\":`inset 0 0 0 1px ${line}`,transition:\"background .3s, color .3s\"},children:[c,showCount&&counts[c]!=null&&/*#__PURE__*/_jsx(\"sup\",{style:{fontSize:10,opacity:.6},children:counts[c]})]},c);})});}FilterBar.defaultProps={allLabel:\"All\",categories:\"Education, Field tools, Fintech, Health & sleep, Lifestyle, Sport & fitness\",showCount:true,text:\"#F1F2EC\",muted:\"rgba(241,242,236,0.6)\",chip:\"rgba(241,242,236,0.06)\",chipOn:\"#F1F2EC\",line:\"rgba(241,242,236,0.1)\",font:\"Geist\"};addPropertyControls(FilterBar,{allLabel:{type:ControlType.String,title:\"All label\",defaultValue:\"All\"},categories:{type:ControlType.String,title:\"Categories\",displayTextArea:true,defaultValue:\"Education, Field tools, Fintech, Health & sleep, Lifestyle, Sport & fitness\"},showCount:{type:ControlType.Boolean,title:\"Counts\",defaultValue:true},font:{type:ControlType.String,title:\"Font\",defaultValue:\"Geist\",description:\"Geist follows your text styles.\"},muted:{type:ControlType.Color,title:\"Text\",defaultValue:\"rgba(241,242,236,0.6)\"},chip:{type:ControlType.Color,title:\"Chip\",defaultValue:\"rgba(241,242,236,0.06)\"},chipOn:{type:ControlType.Color,title:\"Chip on\",defaultValue:\"#F1F2EC\"},line:{type:ControlType.Color,title:\"Outline\",defaultValue:\"rgba(241,242,236,0.1)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FilterBar\",\"slots\":[],\"annotations\":{\"framerContractVersion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