{"version":3,"file":"PlainText_Plus.DOctFJfq.mjs","names":["collection","useState","useRef","cmsFieldNames","_Fragment","_Fragment","BaseControls"],"sources":["https:/framerusercontent.com/modules/Zj8vwyaZ9D974JJDIpb6/s5bSditDQpoj0Ba1TtD1/Search_Plus.js","https:/framerusercontent.com/modules/xPWn77sAdxuRvon75kLo/B2UIyi7WVbdsZJvHIaDR/cmsFieldName.js","https:/framerusercontent.com/modules/rh6e2sb1Jywsg0Jg5MC9/nU76KIngapLuixkcwZx7/PlainText_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(\"🆑:\",\"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(\"🔍:\",\"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\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Search_Plus.map","import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n *\n * @framerDisableUnlink\n */export default function CMSFieldNameControl(props){return /*#__PURE__*/_jsx(_Fragment,{});}addPropertyControls(CMSFieldNameControl,{cmsFieldName:{type:ControlType.String,title:\"Field Name\",description:\"Must match exactly as the field is named in its collection.\",defaultValue:\"\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSFieldNameControl\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./cmsFieldName.map","import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,// @ts-ignore\ngetPropertyControls,ControlType}from\"framer\";import{useFilter}from\"https://framerusercontent.com/modules/uaC9hWf3ec7HqMv3sXMc/fThGQnEUZeWwDLSQMzea/Hooks.js\";import BaseControls from\"https://framerusercontent.com/modules/1abSdslctova79WmNQRw/3fHstYFUOpeaxageGRMz/Filter_Base.js\";import CollectionIDControl from\"https://framerusercontent.com/modules/Hxho9sUnioBkMjGbLBed/csoxszrftuhmv2NyuE1c/collectionID.js\";import CMSFieldNameControl from\"https://framerusercontent.com/modules/xPWn77sAdxuRvon75kLo/B2UIyi7WVbdsZJvHIaDR/cmsFieldName.js\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n *\n * @framerDisableUnlink\n */export default function PlainTextFilterPlus(props){const{applyFilter,cmsFieldName,collectionID,condition,interactionActiveFilter,interactionInactiveFilter,preserveActiveFilter,value}=props;const cmsPlusComponentName=\"Filter+ PlainText\";useFilter({cmsFieldName,cmsPlusComponentName,collectionID,condition,interactionActiveFilter,interactionInactiveFilter,isPreserving:preserveActiveFilter,value:value.trim()?value:undefined,isFilterActive:applyFilter,controlType:\"string\",valueIsRequired:!condition.includes(\"IS_SET\")});return /*#__PURE__*/_jsx(_Fragment,{});}PlainTextFilterPlus.displayName=\"Filter+ PlainText\";addPropertyControls(PlainTextFilterPlus,{...getPropertyControls(CollectionIDControl),...getPropertyControls(BaseControls),...getPropertyControls(CMSFieldNameControl),condition:{type:ControlType.Enum,title:\"Condition\",defaultValue:\"==\",optionTitles:[\"Is Set\",\"Isn't Set\",\"Equals\",\"Doesn't Equal\",\"Starts With\",\"Doesn't Start With\",\"Ends With\",\"Doesn't End With\",\"Contains\",\"Doesn't Contain\"],options:[\"IS_SET\",\"!IS_SET\",\"==\",\"!=\",\"STARTS_WITH\",\"!STARTS_WITH\",\"ENDS_WITH\",\"!ENDS_WITH\",\"CONTAINS\",\"!CONTAINS\"]},value:{type:ControlType.String,title:\"Value\",defaultValue:\"\",placeholder:\"case-sensitive\",hidden:props=>props.condition.includes(\"IS_SET\")}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PlainTextFilterPlus\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"wkBAMG,SAAwB,EAAY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