{"version":3,"file":"SearchBar.THjr15k7.mjs","names":["superfieldsId"],"sources":["https:/framerusercontent.com/modules/SCy7FLdHzkNZj7inEGxN/kLEGFWcuWYJvzUFTVGij/SearchBar.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useRef,useEffect}from\"react\";import{Border,borderPropertyControl,fillProp,createBackground,superfieldsId,useInstanceId}from\"https://framerusercontent.com/modules/FZjYlw33eNo8pxLbSFLX/NS2M1g7qVI7y5CFDNb6m/SuperfieldsShared.js\";import useSuperfieldsStore from\"https://framerusercontent.com/modules/OoGHZMzWDzm2mNN7bmeR/UmOIjvpgKrLZznysVdbK/Store.js\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 500\n * @framerDisableUnlink\n */export default function SearchBar(props){const{superfieldsId,placeholderColor,searchIcon,xButton}=props;const id=useInstanceId();const inputRef=useRef(null);const[focused,setFocused]=useState(false);const[initialized,setInitialized]=useState(false);const[search,totalItems,setSearch]=useSuperfieldsStore(superfieldsId,state=>[state.search,state.totalItems,state.setSearch]);useEffect(()=>{setInitialized(true);},[]);function onXClick(){setSearch(\"\");}// Top, right, bottom, left\nconst paddingValues=parsePadding(props.padding);return /*#__PURE__*/_jsxs(\"div\",{\"data-superfields\":true,id:id,style:{position:\"relative\",...createBackground(props.fill),color:props.fontColor,borderRadius:props.radius,boxShadow:props.shadows,display:\"flex\",flexDirection:\"row\",alignItems:\"center\",padding:props.padding,gap:props.gap,cursor:\"text\",overflow:\"hidden\",backdropFilter:props.bgBlur?`blur(${props.bgBlur}px)`:undefined,...props.font,...props.style},onClick:()=>{inputRef.current?.focus();},children:[searchIcon&&/*#__PURE__*/_jsxs(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:searchIcon.size,height:searchIcon.size,viewBox:\"0 0 24 24\",fill:\"none\",stroke:searchIcon.color,\"stroke-width\":searchIcon.lineWidth,\"stroke-linecap\":\"round\",\"stroke-linejoin\":\"round\",style:{opacity:searchIcon.opacity,display:\"block\",pointerEvents:\"none\"},children:[/*#__PURE__*/_jsx(\"path\",{d:\"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M21 21l-6 -6\"})]}),/*#__PURE__*/_jsx(\"input\",{ref:inputRef,type:\"text\",style:{border:\"none\",color:props.fontColor,background:\"none\",...props.font,...props.style},placeholder:props.placeholderText.replace(\"[items]\",String(!initialized||!totalItems?0:totalItems)),autoFocus:props.autoFocus,value:search??\"\",onChange:event=>{setSearch(event.target.value);},onFocus:()=>setFocused(true),onBlur:()=>setFocused(false)}),search&&initialized&&xButton&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:xButton.size,display:\"flex\",alignItems:\"center\",alignSelf:\"stretch\"},children:[/*#__PURE__*/_jsxs(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:xButton.size,height:xButton.size,viewBox:\"0 0 24 24\",fill:\"none\",stroke:xButton.color,\"stroke-width\":xButton.lineWidth,\"stroke-linecap\":\"round\",\"stroke-linejoin\":\"round\",style:{display:\"block\",opacity:xButton.opacity},children:[/*#__PURE__*/_jsx(\"path\",{d:\"M18 6l-12 12\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M6 6l12 12\"})]}),/*#__PURE__*/_jsx(\"button\",{style:{position:\"absolute\",left:-props.gap,top:-paddingValues[0],right:-paddingValues[1],bottom:-paddingValues[2],cursor:\"pointer\",background:\"none\",border:\"none\"},onClick:onXClick,onFocus:()=>setFocused(true),onBlur:()=>setFocused(false)})]}),/*#__PURE__*/_jsx(Border,{...props.border}),/*#__PURE__*/_jsx(Border,{...props.focus,animate:{opacity:focused?1:0}}),/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:`\n                        #${id} input::placeholder { color: ${placeholderColor}; user-select: none; }\n                        #${id} input::-webkit-input-placeholder { color: ${placeholderColor}; user-select: none; }\n                        #${id} input::-moz-placeholder { color: ${placeholderColor}; user-select: none; }\n                        #${id} input:-ms-input-placeholder { color: ${placeholderColor}; user-select: none; }\n                        #${id} input:-moz-placeholder { color: ${placeholderColor}; user-select: none; }\n                        #${id} input:focus { outline: none; }`}})]});}SearchBar.displayName=\"Search Bar\";addPropertyControls(SearchBar,{...superfieldsId(),placeholderText:{type:ControlType.String,defaultValue:\"Search [items] items...\",title:\"Placeholder\",description:\"*[items]*: number of CMS items\"},autoFocus:{type:ControlType.Boolean,defaultValue:false,title:\"Auto-Focus\"},fill:fillProp({color:\"#EFEFEF\"}),fontColor:{type:ControlType.Color,defaultValue:\"#000\"},placeholderColor:{type:ControlType.Color,defaultValue:\"rgba(0, 0, 0, 0.5)\"},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1.4}},searchIcon:{type:ControlType.Object,optional:true,defaultValue:{color:\"$000\",size:16,lineWidth:2.5,opacity:.5},controls:{color:{type:ControlType.Color,defaultValue:\"$000\"},size:{type:ControlType.Number,defaultValue:16,min:1,step:1},lineWidth:{type:ControlType.Number,defaultValue:2.5,min:.1,max:5,step:.1},opacity:{type:ControlType.Number,defaultValue:1,min:0,max:1,step:.01}}},xButton:{type:ControlType.Object,optional:true,defaultValue:{color:\"#000\",size:14,lineWidth:2.5,opacity:.5},controls:{color:{type:ControlType.Color,defaultValue:\"#000\"},size:{type:ControlType.Number,defaultValue:14,min:1,step:1},lineWidth:{type:ControlType.Number,defaultValue:2.5,min:.1,max:5,step:.1},opacity:{type:ControlType.Number,defaultValue:.5,min:0,max:1,step:.01}}},gap:{type:ControlType.Number,defaultValue:8,min:0,step:1},padding:{type:ControlType.Padding,defaultValue:\"8px 12px 8px 12px\"},radius:{type:ControlType.BorderRadius,defaultValue:\"8px\"},border:borderPropertyControl(),shadows:{type:ControlType.BoxShadow},bgBlur:{type:ControlType.Number,min:0,max:100,step:1,displayStepper:true,title:\"BG Blur\"},focus:{type:ControlType.Object,optional:true,defaultValue:{color:\"#0075FF\",width:2,style:\"solid\"},buttonTitle:\"Border\",controls:{color:{type:ControlType.Color,defaultValue:\"#0075FF\",title:\"Color\"},width:{type:ControlType.FusedNumber,defaultValue:2,toggleKey:\"widthIsMixed\",toggleTitles:[\"All\",\"Individual\"],valueKeys:[\"widthTop\",\"widthRight\",\"widthBottom\",\"widthLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0},style:{type:ControlType.Enum,defaultValue:\"solid\",options:[\"solid\",\"dashed\",\"dotted\",\"double\"],optionTitles:[\"Solid\",\"Dashed\",\"Dotted\",\"Double\"]},transition:{type:ControlType.Transition,defaultValue:{type:\"spring\",duration:.2,bounce:0}}}}});function parsePadding(padding){// Split the input string by spaces and convert each to an integer\nconst values=padding.trim().split(/\\s+/).map(val=>parseInt(val,10));// If only one value is provided, replicate it four times\nif(values.length===1){return[values[0],values[0],values[0],values[0]];}else if(values.length===4){return values;}else{throw new Error(\"Invalid padding input. Provide either one or four padding values.\");}}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SearchBar\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerDisableUnlink\":\"\",\"framerIntrinsicWidth\":\"500\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"+hBAKG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,cAAA,EAAc,mBAAiB,aAAW,UAAQ,CAAC,EAAY,EAAG,GAAe,CAAO,EAAS,EAAO,KAAK,CAAM,CAAC,EAAQ,EAAW,CAAC,GAAS,EAAM,CAAM,CAAC,EAAY,EAAe,CAAC,GAAS,EAAM,CAAM,CAAC,EAAO,EAAW,EAAU,CAAC,EAAoBA,EAAc,GAAO,CAAC,EAAM,OAAO,EAAM,WAAW,EAAM,SAAU,EAAC,CAAC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