{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/L7qX7AemQ3S06o90qlGe/wejxx2GMtLPklw2f6b4S/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 #E4E4E4\"},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": "8JAA0J,SAASA,EAAYC,EAAcC,EAAU,CACvM,IAAMC,EAAe,MAAM,KAAK,SAAS,iBAAiB,iBAAiB,CAAC,EAAE,IAAIC,GAAM,CAAC,IAAIC,EAAMD,EAAK,aAAa,eAAe,EAEnG,GAAjCC,EAAMA,EAAM,MAAM,GAAG,EAAE,KAAK,GAAG,EAAKA,IAAQ,GAAY,OAAOA,CAAM,CAAC,EAAE,OAAO,OAAO,EAAE,OAAO,CAACC,EAAIF,IAAO,CAAC,GAAGE,EAAI,GAAGF,EAAK,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,EACpIG,EAAM,EACLC,EAAa,SAAS,cAAc,oCAAoC,EAAE,GAAGA,IAAe,KAAK,CAACA,EAAa,MAAM,CAAC,EAAEA,EAAa,MAAM,QAAQ,OAAOA,EAAa,MAAM,QAAQ,EAAE,IAAMC,EAAYD,EAAa,cAAc,QAAQ,EAAKC,IAAc,OAAMA,EAAY,QAAQ,IAAI,CAAC,QAAQ,IAAI,sBAAsB,EAAEC,EAAO,SAAS,OAAO,CAAE,EACjW,CACA,IAAMC,EAAgB,SAAS,iBAAiB,iCAAiC,EAAE,GAAGA,EAAgB,QAAQ,EAAE,CAAC,QAAQ,KAAK,gBAAgB,EAAE,MAAO,CACvJ,GAAGR,EAAe,SAAS,EAAE,CAACQ,EAAgB,QAAQP,GAAM,CAACA,EAAK,MAAM,QAAQ,QAAQG,GAAQ,CAAC,EAAE,MAAO,CAACI,EAAgB,QAAQ,CAACP,EAAKQ,IAAI,CAC7I,IAAIC,EAAiB,GACfC,EAAmBV,EAAK,iBAAiB,mBAAmB,EAAE,GAAGU,IAAqB,KAAM,OAAQ,IAAMC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terItems", "selectedValue", "className", "selectedValues", "item", "value", "acc", "count", "emptyElement", "emptyButton", "window", "collectionItems", "i", "hasMatchingClass", "dataFilterElements", "itemAllClasses", "MyFancySingleSelect", "props", "shouldOpenAbove", "setShouldOpenAbove", "ye", "isHovered", "setIsHovered", "isOpen", "setIsOpen", "selectedOption", "setSelectedOption", "dropdownRef", "pe", "hoveredOption", "setHoveredOption", "toggleDropdown", "radius", "padding", "itemBackgroundColor", "hoveredItemBackgroundColor", "selectedItemBackgroundColor", "options", "filterClassName", "ue", "rect", "handleClickOutside", "event", "p", "u", "optionObj", "index", "addPropertyControls", "ControlType"]
}
