{"version":3,"file":"FAQAccordion.Cybs0WNb.mjs","names":["useId","useState","useRef","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/KLJPyb9vydGOB7w96Cp0/sZZUWxIrEqLryfWHEwDE/FAQAccordion.js"],"sourcesContent":["// Instructions: Create a Framer component that follows the Framer component rules and achieves the user's goal. Goal: create a responsive FAQ accordion..\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{startTransition,useCallback,useEffect,useId,useMemo,useRef,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{AnimatePresence,motion}from\"framer-motion\";/**\n * @framerIntrinsicWidth 640\n * @framerIntrinsicHeight 420\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function FAQAccordion(props){const{items,openMode,initialOpenIndex,allowCollapseAll,backgroundColor,cardColor,borderColor,questionColor,answerColor,iconColor,radius,padding,itemGap,questionFont,answerFont,transition,style}=props;const isStatic=useIsStaticRenderer();const uid=useId();const normalizedInitialIndex=useMemo(()=>{if(!Array.isArray(items)||items.length===0)return-1;if(typeof initialOpenIndex!==\"number\")return-1;const idx=Math.round(initialOpenIndex);if(idx<0)return-1;if(idx>=items.length)return items.length-1;return idx;},[initialOpenIndex,items]);const[openIndexes,setOpenIndexes]=useState(()=>{// All items closed by default\nreturn[];});const didInitRef=useRef(false);useEffect(()=>{if(didInitRef.current)return;didInitRef.current=true;startTransition(()=>{// All items closed by default\nsetOpenIndexes([]);});// eslint-disable-next-line react-hooks/exhaustive-deps\n},[]);const isOpen=useCallback(index=>openIndexes.includes(index),[openIndexes]);const toggle=useCallback(index=>{if(isStatic)return;startTransition(()=>{setOpenIndexes(prev=>{const currentlyOpen=prev.includes(index);if(openMode===\"single\"){if(currentlyOpen){return[];}return[index];}// multiple\nif(currentlyOpen){if(!allowCollapseAll&&prev.length<=1)return prev;return prev.filter(i=>i!==index);}return[...prev,index];});});},[allowCollapseAll,isStatic,openMode]);const safeItems=useMemo(()=>{if(!Array.isArray(items)||items.length===0){return[{question:\"What is this?\",answer:\"This is a responsive FAQ accordion. Add your questions and answers in the properties panel.\"}];}return items.map(it=>({question:typeof it?.question===\"string\"&&it.question.trim().length?it.question:\"Question\",answer:typeof it?.answer===\"string\"&&it.answer.trim().length?it.answer:\"Answer\"}));},[items]);return /*#__PURE__*/_jsx(\"section\",{\"aria-label\":\"Frequently Asked Questions\",style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",background:backgroundColor,display:\"flex\",flexDirection:\"column\",gap:Math.max(0,itemGap),padding,boxSizing:\"border-box\",...style},children:safeItems.map((item,index)=>{const open=isOpen(index);const headerId=`${uid}-faq-header-${index}`;const panelId=`${uid}-faq-panel-${index}`;return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",background:cardColor,border:`1px solid ${borderColor}`,borderRadius:radius,overflow:\"hidden\",boxSizing:\"border-box\"},children:[/*#__PURE__*/_jsxs(\"button\",{type:\"button\",onClick:()=>toggle(index),\"aria-expanded\":open,\"aria-controls\":panelId,id:headerId,style:{position:\"relative\",width:\"100%\",appearance:\"none\",WebkitAppearance:\"none\",border:\"none\",background:\"transparent\",padding:\"14px 14px\",cursor:isStatic?\"default\":\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",gap:12,textAlign:\"left\",color:questionColor,boxSizing:\"border-box\",outline:\"none\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{...questionFont,minWidth:0,flex:1,display:\"block\"},children:item.question}),/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",style:{width:18,height:18,flex:\"0 0 auto\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",color:iconColor,transform:open?\"rotate(180deg)\":\"rotate(0deg)\",transition:isStatic?\"none\":\"transform 200ms ease\"},children:/*#__PURE__*/_jsx(\"svg\",{width:\"18\",height:\"18\",viewBox:\"0 0 24 24\",fill:\"none\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M6.5 9.5L12 15l5.5-5.5\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})})})]}),isStatic?open?/*#__PURE__*/_jsx(\"div\",{id:panelId,role:\"region\",\"aria-labelledby\":headerId,style:{position:\"relative\",padding:\"0 14px 14px 14px\",color:answerColor,boxSizing:\"border-box\"},children:/*#__PURE__*/_jsx(\"div\",{style:{...answerFont,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\"},children:item.answer})}):null:/*#__PURE__*/_jsx(AnimatePresence,{initial:false,children:open?/*#__PURE__*/_jsx(motion.div,{id:panelId,role:\"region\",\"aria-labelledby\":headerId,initial:{height:0,opacity:0},animate:{height:\"auto\",opacity:1},exit:{height:0,opacity:0},transition:transition,style:{position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",padding:\"0 14px 14px 14px\",color:answerColor,boxSizing:\"border-box\"},children:/*#__PURE__*/_jsx(\"div\",{style:{...answerFont,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\"},children:item.answer})})},panelId):null})]},`${headerId}`);})});}addPropertyControls(FAQAccordion,{items:{type:ControlType.Array,title:\"Items\",maxCount:20,defaultValue:[{question:\"What is Framer?\",answer:\"Framer is a design and publishing tool for building responsive websites with interactive components.\"},{question:\"Can I customize this accordion?\",answer:\"Yes. You can edit the items, colors, fonts, spacing, and animation from the properties panel.\"},{question:\"Can multiple items be open?\",answer:\"Set Open Mode to Multiple, and optionally allow collapsing all items.\"}],control:{type:ControlType.Object,controls:{question:{type:ControlType.String,title:\"Question\",defaultValue:\"Question\"},answer:{type:ControlType.String,title:\"Answer\",defaultValue:\"Answer\",displayTextArea:true}}}},openMode:{type:ControlType.Enum,title:\"Open Mode\",options:[\"single\",\"multiple\"],optionTitles:[\"Single\",\"Multiple\"],defaultValue:\"single\",displaySegmentedControl:true},initialOpenIndex:{type:ControlType.Number,title:\"Initial Open\",defaultValue:-1,min:-1,max:50,step:1},allowCollapseAll:{type:ControlType.Boolean,title:\"Collapse All\",defaultValue:true,enabledTitle:\"Allowed\",disabledTitle:\"Locked\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},cardColor:{type:ControlType.Color,title:\"Card\",defaultValue:\"#F5F5F5\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#EEEEEE\"},questionColor:{type:ControlType.Color,title:\"Question\",defaultValue:\"#000000\"},answerColor:{type:ControlType.Color,title:\"Answer\",defaultValue:\"#000000\"},iconColor:{type:ControlType.Color,title:\"Icon\",defaultValue:\"#000000\"},radius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"12px\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"16px\"},itemGap:{type:ControlType.Number,title:\"Gap\",defaultValue:10,min:0,max:40,step:1,unit:\"px\"},questionFont:{type:ControlType.Font,title:\"Question Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},answerFont:{type:ControlType.Font,title:\"Answer Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.4em\"}},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{duration:.28,ease:\"easeOut\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FAQAccordion\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"420\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"640\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FAQAccordion.map"],"mappings":"sRAOG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAA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