{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/Zj8vwyaZ9D974JJDIpb6/s5bSditDQpoj0Ba1TtD1/Search_Plus.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,// @ts-ignore\ngetPropertyControls,ControlType,useIsOnFramerCanvas}from\"framer\";import{useEffect,useState,useRef}from\"react\";import{useStore}from\"https://framerusercontent.com/modules/oaAH7umUjUOTeKmykfom/4GSr51yWhuxjuWu6QpOf/Stores.js\";import{useDebouncer,useConsoleLogWhenDebuggingCMSPlus}from\"https://framerusercontent.com/modules/uaC9hWf3ec7HqMv3sXMc/fThGQnEUZeWwDLSQMzea/Hooks.js\";import CollectionIDControl from\"https://framerusercontent.com/modules/Hxho9sUnioBkMjGbLBed/csoxszrftuhmv2NyuE1c/collectionID.js\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n *\n * @framerDisableUnlink\n */export default function Search_Plus(props){const{fontColor,cmsFieldNames,fontStyles,placeHolderColor,placeHolderText,preserveFilter,selectedRealTimeSearches}=props;const fieldPlusComponent=\"Search+\";const[store,setStore]=useStore();/**\n     * looks for at least one valid collection ID in store.\n     *\n     * if Search+ has multiple elements in selectedRealTimeSearches listed, then i all listed valid collections will have the same realTimeSearch.text string\n     */const foundValidCollection=selectedRealTimeSearches.find(({collectionID})=>!!store[collectionID]);const collection=store[foundValidCollection?.collectionID]||null;const collectionIsInitialized=!!collection;// gather all the real time search text form every initialized collection in the store\n// it will be used watch the value that will trigger a useEffect when any value is cleared remotely\nconst realTimeSearchTexts=Object.values(store).map(collection=>collection.realTimeSearch.text);const supportedFieldTypes=[\"string\"];const isOnFramerCanvas=useIsOnFramerCanvas();const{consoleLogWhenDebuggingCMSPlus}=useConsoleLogWhenDebuggingCMSPlus();const[userInput,setUserInput]=useState(collectionIsInitialized?collection.realTimeSearch.text:\"\");const userInputDebounced=useDebouncer({delay:200,value:userInput});const[inputHasFocus,setInputHasFocus]=useState(false);const hasMountedRef=useRef(false);const inputStyles={...props.style,...fontStyles,backgroundColor:\"transparent\",border:\"none\",color:!inputHasFocus&&!userInput?placeHolderColor:fontColor,outline:\"none\",width:\"100%\"};const handleOnInput=e=>{if(collectionIsInitialized)setUserInput(e.target.value);};const handleInputOnFocus=()=>setInputHasFocus(true);const handleInputOnBlur=()=>setInputHasFocus(false);// handles realTimeSearch.text and input change. reset the input value if the realTimeSearch.text is cleared externally from Clear+\nuseEffect(()=>{if(collectionIsInitialized&&hasMountedRef.current&&!!userInputDebounced&&!collection.realTimeSearch.text){consoleLogWhenDebuggingCMSPlus(\"\uD83C\uDD91:\",\"Search+:\",` id#s [${selectedRealTimeSearches.map(search=>search.collectionID).join(\",\")}] cleared remotely.`);setUserInput(\"\");}},[collectionIsInitialized,...realTimeSearchTexts]);// handles userInputDebounced\n// when userInputDebounced is different from userInput, it will update the realTimeSearch.text in collection's store\nuseEffect(()=>{if(collectionIsInitialized&&userInputDebounced!==collection.realTimeSearch?.text){consoleLogWhenDebuggingCMSPlus(\"\uD83D\uDD0D:\",\"Search+:\",`\"${userInputDebounced}\"`);setStore(prev=>{const newStore={...prev};// loop through each element in selectedRealTimeSearches\n// each element will contain a collectionID\nfor(let index=0;index<selectedRealTimeSearches.length;index++){const{clearAllActiveFilters,cmsFieldNames,collectionID}=selectedRealTimeSearches[index];// get the collection from store\nconst collection=newStore[collectionID];// skip if collection not initiated in store\nif(!collection)continue;// set the input text\nnewStore[collectionID].realTimeSearch.text=userInputDebounced;// the input text will be searched in these fields\nconst searchFields=[];// loop through each field in this collection\nfor(const[fieldName,{type}]of Object.entries(collection.fields)){// skip if this field does not have any filters or the type is not supported\nif(!supportedFieldTypes.includes(type))continue;// push field if clearAllActiveFilters was selected, otherwise push if included in cmsFieldNames array\nif(clearAllActiveFilters||cmsFieldNames.includes(fieldName)){searchFields.push(fieldName);}}// set the searchFields to collection store realTimeSearch\nnewStore[collectionID].realTimeSearch.fields=searchFields;}return{...newStore};});}},[collectionIsInitialized,userInputDebounced]);// clean up function to reset when user is not preserving this filter search\nuseEffect(()=>{hasMountedRef.current=true;return()=>{if(collectionIsInitialized&&!preserveFilter){setStore(prev=>{const newStore={...prev};for(let index=0;index<selectedRealTimeSearches.length;index++){const{collectionID}=selectedRealTimeSearches[index];const collection=newStore[collectionID];if(!collection)continue;newStore[collectionID].realTimeSearch={...newStore[collectionID].realTimeSearch,text:\"\",fields:[]};}return{...newStore};});}};},[collectionIsInitialized,preserveFilter]);return /*#__PURE__*/_jsx(\"input\",{style:inputStyles,type:\"text\",value:!inputHasFocus&&!userInput?placeHolderText:userInput,onChange:handleOnInput,onFocus:handleInputOnFocus,onBlur:handleInputOnBlur});}Search_Plus.displayName=\"Search+\";addPropertyControls(Search_Plus,{selectedRealTimeSearches:{type:ControlType.Array,title:\"Searches\",defaultValue:[],description:`Explore its [documentation](https://framercms.plus/documentation/component-search-plus).`,control:{type:ControlType.Object,title:\"Collections & Fields\",controls:{...getPropertyControls(CollectionIDControl),clearAllActiveFilters:{type:ControlType.Boolean,title:\"All Fields\",defaultValue:true,description:\"Slug field is included.\"},cmsFieldNames:{type:ControlType.Array,title:\"Fields\",defaultValue:[],description:\"Must match exactly as the field is named in its collection.\",control:{type:ControlType.String,title:\"Field\",defaultValue:\"\"},hidden:props=>props.clearAllActiveFilters}}}},preserveFilter:{type:ControlType.Boolean,title:\"Preserve\",defaultValue:true,description:`Input text. [Explore feature.](https://framercms.plus/documentation/preserve-settings)`},fontStyles:{type:ControlType.Font,controls:\"extended\",title:\"Font\"},fontColor:{type:ControlType.Color,title:\"Font Color\"},placeHolderText:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"CMS Plus Search+ Component\",placeholder:\"Optional\"},placeHolderColor:{type:ControlType.Color,title:\"Placeholder Color\",defaultValue:\"#b8b8b8\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Search_Plus\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHe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"selectedRealTimeSearches", "fieldPlusComponent", "store", "setStore", "useStore", "foundValidCollection", "collectionID", "collection", "collectionIsInitialized", "realTimeSearchTexts", "supportedFieldTypes", "isOnFramerCanvas", "useIsOnFramerCanvas", "consoleLogWhenDebuggingCMSPlus", "useConsoleLogWhenDebuggingCMSPlus", "userInput", "setUserInput", "ye", "userInputDebounced", "useDebouncer", "inputHasFocus", "setInputHasFocus", "hasMountedRef", "pe", "inputStyles", "handleOnInput", "handleInputOnFocus", "handleInputOnBlur", "ue", "search", "prev", "newStore", "index", "clearAllActiveFilters", "searchFields", "fieldName", "type", "p", "addPropertyControls", "ControlType", "getPropertyControls", "CollectionIDControl"]
}
