{"version":3,"file":"Search_Plus.CSaefI4E.mjs","names":["_Fragment","collection","useState","useRef","cmsFieldNames"],"sources":["https:/framerusercontent.com/modules/VA2cGgkgZvNjSGYa8rlh/dMLfOoI9Qme0QUV9cnIk/gyGu8Wgx9.js","https:/framerusercontent.com/modules/Hxho9sUnioBkMjGbLBed/csoxszrftuhmv2NyuE1c/collectionID.js","https:/framerusercontent.com/modules/Zj8vwyaZ9D974JJDIpb6/i0Htui6PPTrQsbmPET9Z/Search_Plus.js"],"sourcesContent":["// Generated by Framer (6ca5d98)\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,cx,motion,withCSS}from\"framer\";import*as React from\"react\";import{forwardRef}from\"react\";const mask='url(\\'data:image/svg+xml,<svg display=\"block\" role=\"presentation\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M 12.5 11 L 11.71 11 L 11.43 10.73 C 12.41 9.59 13 8.11 13 6.5 C 13 2.91 10.09 0 6.5 0 C 2.91 0 0 2.91 0 6.5 C 0 10.09 2.91 13 6.5 13 C 8.11 13 9.59 12.41 10.73 11.43 L 11 11.71 L 11 12.5 L 16 17.49 L 17.49 16 Z M 6.5 11 C 4.01 11 2 8.99 2 6.5 C 2 4.01 4.01 2 6.5 2 C 8.99 2 11 4.01 11 6.5 C 11 8.99 8.99 11 6.5 11 Z\" fill=\"var(--esondr, rgb(0,0,0))\" height=\"17.49002px\" id=\"DlOXoKtG6\" transform=\"translate(3.255 3.255)\" width=\"17.490000000000002px\"/></svg>\\') alpha no-repeat center / auto var(--framer-icon-mask-mode, add), var(--framer-icon-mask, none)';const SVG=/*#__PURE__*/forwardRef((props,ref)=>{const{animated,layoutId,children,...rest}=props;return animated?/*#__PURE__*/_jsx(motion.div,{...rest,layoutId:layoutId,ref:ref}):/*#__PURE__*/_jsx(\"div\",{...rest,ref:ref});});const getProps=({fill,height,id,width,...props})=>{return{...props,K5AAorpEW:fill??props.K5AAorpEW??\"rgb(0, 0, 0)\"};};const Component=/*#__PURE__*/React.forwardRef(function(props,ref){const{style,className,layoutId,variant,K5AAorpEW,...restProps}=getProps(props);return /*#__PURE__*/_jsx(SVG,{...restProps,className:cx(\"framer-GtMBL\",className),layoutId:layoutId,ref:ref,style:{\"--esondr\":K5AAorpEW,...style}});});const css=[`.framer-GtMBL { -webkit-mask: ${mask}; aspect-ratio: 1; background-color: var(--esondr); mask: ${mask}; width: 24px; }`];/**\n * This is a generated Framer component.\n * @framerIntrinsicWidth 24\n * @framerIntrinsicHeight 24\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerVariables {\"K5AAorpEW\":\"fill\"}\n * @framerImmutableVariables true\n * @framerVector {\"name\":\"Search\",\"color\":{\"type\":\"variable\",\"value\":\"esondr\"},\"set\":{\"localId\":\"vectorSet/DnLsXE00W\",\"id\":\"DnLsXE00W\",\"moduleId\":\"JIScivAkNLgXrcOUxHXD\"}}\n * @framerDisableUnlink true\n */const Icon=withCSS(Component,css,\"framer-GtMBL\");Icon.displayName=\"Search\";export default Icon;addPropertyControls(Icon,{K5AAorpEW:{defaultValue:\"rgb(0, 0, 0)\",hidden:false,title:\"Fill\",type:ControlType.Color}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Icon\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"true\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"24\",\"framerVariables\":\"{\\\"K5AAorpEW\\\":\\\"fill\\\"}\",\"framerVector\":\"{\\\"name\\\":\\\"Search\\\",\\\"color\\\":{\\\"type\\\":\\\"variable\\\",\\\"value\\\":\\\"esondr\\\"},\\\"set\\\":{\\\"localId\\\":\\\"vectorSet/DnLsXE00W\\\",\\\"id\\\":\\\"DnLsXE00W\\\",\\\"moduleId\\\":\\\"JIScivAkNLgXrcOUxHXD\\\"}}\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"24\",\"framerContractVersion\":\"1\",\"framerImmutableVariables\":\"true\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","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 CollectionIDControl(props){return /*#__PURE__*/_jsx(_Fragment,{});}addPropertyControls(CollectionIDControl,{collectionID:{type:ControlType.Number,title:\"Collection+ ID\",defaultValue:0,min:0,displayStepper:true,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CollectionIDControl\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./collectionID.map","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,onInput}=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=>{// allows for an override to hook into the change event\nif(onInput&&typeof onInput===\"function\")onInput?.(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\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Search_Plus.map"],"mappings":"glBACiL,EAAK,8qBAAsrB,EAAiB,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,WAAS,WAAS,WAAS,GAAG,EAAK,CAAC,EAAM,OAAO,EAAsB,EAAK,EAAO,IAAI,CAAC,GAAG,EAAc,WAAa,MAAI,EAAe,EAAK,MAAM,CAAC,GAAG,EAAS,MAAI,CAAG,GAAQ,GAAU,CAAC,OAAK,SAAO,KAAG,QAAM,GAAG,EAAM,IAAU,CAAC,GAAG,EAAM,UAAU,GAAM,EAAM,WAAW,eAAe,EAAS,EAAuB,EAAiB,SAAS,EAAM,EAAI,CAAC,GAAK,CAAC,QAAM,YAAU,WAAS,UAAQ,YAAU,GAAG,EAAU,CAAC,EAAS,GAAO,OAAoB,EAAK,EAAI,CAAC,GAAG,EAAU,UAAU,EAAG,eAAe,GAAoB,WAAa,MAAI,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