{"version":3,"file":"Awesome_Filter.Ao7qaE9S.mjs","names":["item","useState","useRef"],"sources":["https:/framerusercontent.com/modules/L7qX7AemQ3S06o90qlGe/630JjjMqyKsxJpWxS2yh/Awesome_Filter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect,useRef}from\"react\";function filterItems(selectedValue,className){// get all selected values from the filters\nconst selectedValues=Array.from(document.querySelectorAll(\".select-options\")).map(item=>{let value=item.getAttribute(\"data-selected\");// single item cannot have spaces\n// value = value.split(\" \").join(\"_\").split(\":\").join(\"_\")\nvalue=value.split(\":\").join(\"_\");if(value===\"\"){return;}return value;}).filter(Boolean).reduce((acc,item)=>[...acc,...item.split(\",\")],[])// multiselect\n;let count=0;// empty element\nconst emptyElement=document.querySelector(\"[data-filter='collection-message']\");if(emptyElement!==null){emptyElement.style={};emptyElement.style.display=\"none\";emptyElement.style.opacity=0;const emptyButton=emptyElement.querySelector(\"button\");if(emptyButton!==null){emptyButton.onclick=()=>{console.log(\"clicked clear filter\");window.location.reload();};}// return\n}// items\nconst collectionItems=document.querySelectorAll(\"[data-filter='collection-item']\");if(collectionItems.length<=0){console.warn(\"no items found\");return;}// clear filter if nothing is selected\nif(selectedValues.length===0){collectionItems.forEach(item=>{item.style.display=\"block\";count++;});return;}collectionItems.forEach((item,i)=>{// hide all elements by default\nlet hasMatchingClass=false;// search for classes to filter\nconst dataFilterElements=item.querySelectorAll(\"[data-custom-div]\");if(dataFilterElements===null){return;}const itemAllClasses=Array.from(dataFilterElements).map(item=>{let value=item.getAttribute(\"class\");// single item cannot have spaces\n// value = value.split(\" \").join(\"_\").split(\":\").join(\"_\")\nvalue=value.split(\":\").join(\"_\");if(value===\"\"){return;}return value;}).filter(Boolean).join(\" \").split(\" \");hasMatchingClass=selectedValues.every(item=>itemAllClasses.includes(item));if(hasMatchingClass){item.style.display=\"block\";count++;}else{item.style.display=\"none\";}});// show/hide empty element\nif(emptyElement!==null&&count<=0){emptyElement.style.display=\"flex\";emptyElement.style.opacity=1;}}export function MyFancySingleSelect(props){const[shouldOpenAbove,setShouldOpenAbove]=useState(false);const[isHovered,setIsHovered]=useState(false);const[isOpen,setIsOpen]=useState(false);const[selectedOption,setSelectedOption]=useState(null);const dropdownRef=useRef(null);const[hoveredOption,setHoveredOption]=useState(null);const toggleDropdown=()=>{setIsOpen(!isOpen);};// styles\nconst radius=\"8\";const padding=\"8\";const itemBackgroundColor=\"rgb(255, 255, 255)\";const hoveredItemBackgroundColor=\"rgba(0, 95, 255, 0.2)\";const selectedItemBackgroundColor=\"rgba(0, 95, 255, 0.1)\";const{options,filterClassName}=props;useEffect(()=>{if(dropdownRef.current){const rect=dropdownRef.current.getBoundingClientRect();setShouldOpenAbove(window.innerHeight-rect.bottom<250)// 250 is the estimated height of the dropdown\n;}},[isOpen]);useEffect(()=>{function handleClickOutside(event){if(dropdownRef.current&&!dropdownRef.current.contains(event.target)){setIsOpen(false);}}document.addEventListener(\"mousedown\",handleClickOutside);return()=>{document.removeEventListener(\"mousedown\",handleClickOutside);};},[]);useEffect(()=>{filterItems(selectedOption,filterClassName);},[]);useEffect(()=>{filterItems(selectedOption,filterClassName);},[selectedOption,filterClassName]);return /*#__PURE__*/_jsx(\"div\",{ref:dropdownRef,className:\"my-fancy-single-select\",children:/*#__PURE__*/_jsxs(\"div\",{onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),style:{position:\"relative\",cursor:\"pointer\"},children:[/*#__PURE__*/_jsxs(\"div\",{onClick:toggleDropdown,style:{backgroundColor:\"white\",borderRadius:`${radius}px`,minHeight:\"40px\",maxHeight:\"40px\",padding:\"10px 20px\",display:\"flex\",flexDirection:\"row\",alignItems:\"center\",justifyContent:\"space-between\",transition:\"all .5s\",border:\"1px solid #F2F2F2\"},className:\"select-options\",\"data-entity\":filterClassName,\"data-selected\":selectedOption?selectedOption.value:\"\",children:[/*#__PURE__*/_jsx(\"p\",{style:{lineHeight:\"120%\",fontSize:14,color:\"#111\"},children:selectedOption?selectedOption.label:props.placeholder}),/*#__PURE__*/_jsx(\"div\",{onClick:toggleDropdown,style:{cursor:\"pointer\"},children:/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",fill:\"none\",width:16,height:12,viewBox:\"-8 -4 24 24\",strokeWidth:2,stroke:\"currentColor\",className:\"w-6 h-6\",children:/*#__PURE__*/_jsx(\"path\",{strokeLinecap:\"round\",strokeLinejoin:\"round\",d:\"M19.5 8.25l-7.5 7.5-7.5-7.5\"})})})]}),isOpen&&/*#__PURE__*/_jsx(\"div\",{style:{display:\"inline-block\",position:\"absolute\",top:shouldOpenAbove?\"auto\":\"115%\",bottom:shouldOpenAbove?\"115%\":\"auto\",left:0,right:0,borderRadius:`${radius}px`,minWidth:\"160px\",maxHeight:\"240px\",overflowY:\"scroll\",zIndex:20,transition:\"all .5s\",backgroundColor:\"#fff\",border:\"1px solid #E4E4E4\"},children:[{label:\"All\",value:\"all\"},...options].map((optionObj,index)=>/*#__PURE__*/_jsx(\"div\",{onMouseEnter:()=>setHoveredOption(optionObj.value),onMouseLeave:()=>setHoveredOption(null),onClick:()=>{if(optionObj.value===\"all\"){setSelectedOption(null);}else{setSelectedOption(optionObj);}setIsOpen(false);},style:{width:\"auto\",display:\"flex\",flexDirection:\"row\",alignItems:\"center\",justifyContent:\"space-between\",padding:\"12px 8px\",cursor:\"pointer\",backgroundColor:selectedOption&&selectedOption.value===optionObj.value?selectedItemBackgroundColor:hoveredOption===optionObj.value?hoveredItemBackgroundColor:itemBackgroundColor},children:/*#__PURE__*/_jsx(\"p\",{style:{lineHeight:\"15px\",fontSize:15,color:\"#111\"},children:optionObj.label})},index))})]})});}addPropertyControls(MyFancySingleSelect,{options:{type:ControlType.Array,title:\"Options\",propertyControl:{type:ControlType.Object,controls:{label:{type:ControlType.String,title:\"Label\"},value:{type:ControlType.String,title:\"Value\"}}}},placeholder:{title:\"Placeholder\",type:ControlType.String,defaultValue:\"Select options\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"MyFancySingleSelect\":{\"type\":\"reactComponent\",\"name\":\"MyFancySingleSelect\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Awesome_Filter.map"],"mappings":"8MAA0J,SAAS,EAAY,EAAc,EAAU,CACvM,IAAM,EAAe,MAAM,KAAK,SAAS,iBAAiB,kBAAkB,CAAC,CAAC,IAAI,GAAM,CAAC,IAAI,EAAM,EAAK,aAAa,gBAAgB,CAErI,KAAM,EAAM,MAAM,IAAI,CAAC,KAAK,IAAI,CAAI,IAAQ,GAAY,OAAO,GAAQ,CAAC,OAAO,QAAQ,CAAC,QAAQ,EAAI,IAAO,CAAC,GAAG,EAAI,GAAG,EAAK,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CACrI,EAAM,EACL,EAAa,SAAS,cAAc,qCAAqC,CAAC,GAAG,IAAe,KAAK,CAAC,EAAa,MAAM,EAAE,CAAC,EAAa,MAAM,QAAQ,OAAO,EAAa,MAAM,QAAQ,EAAE,IAAM,EAAY,EAAa,cAAc,SAAS,CAAI,IAAc,OAAM,EAAY,YAAY,CAAC,QAAQ,IAAI,uBAAuB,CAAC,EAAO,SAAS,QAAQ,GAEhW,IAAM,EAAgB,SAAS,iBAAiB,kCAAkC,CAAC,GAAG,EAAgB,QAAQ,EAAE,CAAC,QAAQ,KAAK,iBAAiB,CAAC,OAChJ,GAAG,EAAe,SAAS,EAAE,CAAC,EAAgB,QAAQ,GAAM,CAAC,EAAK,MAAM,QAAQ,QAAQ,KAAU,CAAC,OAAQ,EAAgB,SAAS,EAAK,IAAI,CAC7I,IAAI,EAAiB,GACf,EAAmB,EAAK,iBAAiB,oBAAoB,CAAC,GAAG,IAAqB,KAAM,OAAQ,IAAM,EAAe,MAAM,KAAK,EAAmB,CAAC,IAAI,GAAM,CAAC,IAAI,EAAMA,EA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