{"version":3,"file":"ResetFiltersButton.UE-0_3ZZ.mjs","names":[],"sources":["https:/framerusercontent.com/modules/cofcLfq9sG8s2L5CLlUI/7DntF72wwp3OmVaFRVA0/ResetFiltersButton.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect}from\"react\";import{useFilterState,useSearchState,buttonPropertyControls,Button}from\"https://framerusercontent.com/modules/7bVBRRDmBffLAodYcm8x/PyjG5PhY0gS63nuWBx2V/SuperfieldsShared.js\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function ResetFiltersButton(props){const{border}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const id=props.id??\"a\"+String(Math.floor(Math.random()*999999999));const[filterState,setFilterState]=useFilterState();const[searchState,setSearchState]=useSearchState();const ids=props.useMultipleIds?props.superfieldsIds:[props.superfieldsId];function onButtonClick(){const filterUpdates={};const searchUpdates={};ids.forEach(superfieldsId=>{if(props.resetFilters&&filterState[superfieldsId]){filterUpdates[superfieldsId]={};for(const fieldName in filterState[superfieldsId]){const defaultValue=filterState[superfieldsId][fieldName]?.defaultValue;filterUpdates[superfieldsId][fieldName]={...filterState[superfieldsId][fieldName],value:defaultValue};const storageKey=`SuperfieldsFilter_${superfieldsId}_${fieldName}`;localStorage.removeItem(storageKey);}}if(props.resetSearch){searchUpdates[superfieldsId]=\"\";}});if(props.resetFilters){setFilterState(prev=>({...prev,...filterUpdates}));}if(props.resetSearch){setSearchState(prev=>({...prev,...searchUpdates}));}props.click?.();}useEffect(()=>{setFilterState({});},[]);let areFiltersActive=false;ids.forEach(superfieldsId=>{if(props.resetFilters&&filterState[superfieldsId]){for(const fieldName in filterState[superfieldsId]){const filter=filterState[superfieldsId][fieldName];if(!filter)continue;if(filter.value!==filter.defaultValue){areFiltersActive=true;break;}}}if(props.resetSearch&&searchState[superfieldsId]){areFiltersActive=true;}});if(props.autoHide&&!areFiltersActive&&!isCanvas){return /*#__PURE__*/_jsx(\"style\",{id:id,children:`\n                div:has(> #${id}) {\n                    display: none;\n                }\n            `});}return /*#__PURE__*/_jsx(Button,{props:props,onClick:onButtonClick,onMouseEnter:props.hover});}ResetFiltersButton.displayName=\"Reset Filters Button\";addPropertyControls(ResetFiltersButton,{useMultipleIds:{type:ControlType.Boolean,title:\"Multi IDs\",defaultValue:true},superfieldsIds:{type:ControlType.Array,title:\"IDs\",hidden(props){return!props.useMultipleIds;},control:{type:ControlType.Number,min:0,max:99999,step:1,displayStepper:true}},superfieldsId:{type:ControlType.Number,title:\"ID\",defaultValue:0,displayStepper:true,hidden(props){return props.useMultipleIds;}},resetFilters:{type:ControlType.Boolean,defaultValue:true},resetSearch:{type:ControlType.Boolean,defaultValue:true,description:\" \"},...buttonPropertyControls({text:\"Reset Filters\"}),autoHide:{type:ControlType.Boolean,defaultValue:false,description:\"Hide button when no filters/search are active\",title:\"Auto-Hide\"},click:{type:ControlType.EventHandler},hover:{type:ControlType.EventHandler}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ResetFiltersButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ResetFiltersButton.map"],"mappings":"waAGG,SAAwB,EAAmB,EAAM,CAA0P,GAApP,CAAC,SAAO,CAAC,EAAY,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAAG,EAAM,IAAI,IAAI,OAAO,KAAK,MAAM,KAAK,QAAQ,CAAC,UAAU,CAAC,CAAM,CAAC,EAAY,EAAe,CAAC,GAAgB,CAAM,CAAC,EAAY,EAAe,CAAC,GAAgB,CAAO,EAAI,EAAM,eAAe,EAAM,eAAe,CAAC,EAAM,aAAc,EAAC,SAAS,GAAe,CAAwB,IAAjB,EAAc,CAAE,EAAO,EAAc,CAAE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