{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/Vu2yT07ROhLFlxTJG9gE/ABOcS68dw7Djj4qHSmKD/Survey_001.js"],
  "sourcesContent": ["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export function Survey_001({questions,buttonSelectedColor,buttonUnselectedColor,surveyMode=\"visible\"}){// \u30C7\u30D5\u30A9\u30EB\u30C8\nconst defaultQuestions=[{question:\"What is your favorite color?\",image:\"https://via.placeholder.com/600x400\",answers:[\"Red\",\"Blue\",\"Green\"]},{question:\"What is your favorite animal?\",image:\"https://via.placeholder.com/600x400\",answers:[\"Cat\",\"Dog\",\"Bird\",\"Fish\"]},{question:\"What is your favorite food?\",image:\"https://via.placeholder.com/600x400\",answers:[\"Pizza\",\"Sushi\",\"Burger\"]}];// \u5B9F\u969B\u306B\u4F7F\u3046\u8CEA\u554F\u30BB\u30C3\u30C8\nconst surveyQuestions=questions&&questions.length>0?questions.slice(0,5):defaultQuestions;// \u56DE\u7B54\u72B6\u614B\nconst[selectedAnswers,setSelectedAnswers]=useState(Array(surveyQuestions.length).fill(null));// invisible\u30E2\u30FC\u30C9: \u73FE\u5728\u8868\u793A\u4E2D\u306E\u30B9\u30E9\u30A4\u30C9\u6570\nconst[currentStep,setCurrentStep]=useState(1);// \u30B9\u30E9\u30A4\u30C9\u6570 \u2192 \u300C\u8CEA\u554F\u6570\u300D\u3068\u540C\u3058\u306B\u3059\u308B\nconst totalSlides=surveyQuestions.length;// \u56DE\u7B54\u6570\u3068\u9032\u6357\nconst answeredCount=selectedAnswers.filter(ans=>ans!==null).length;const progressPercentage=answeredCount/surveyQuestions.length*100;// \u30DC\u30BF\u30F3\u8272\nconst selectedColor=buttonSelectedColor||\"#007bff\";const unselectedColor=buttonUnselectedColor||\"#ccc\";// \u8868\u793A\u3059\u3079\u304D\u30B9\u30E9\u30A4\u30C9\u6570(visible\u306A\u3089\u5168\u3066, invisible\u306A\u3089 currentStep \u307E\u3067)\nconst slidesToRender=surveyMode===\"visible\"?totalSlides:Math.min(currentStep,totalSlides);// \u8CEA\u554F\u306B\u7B54\u3048\u305F\u3068\u304D\u306E\u51E6\u7406\nconst handleAnswer=(qIndex,ansIndex)=>{const newAns=[...selectedAnswers];newAns[qIndex]=ansIndex;setSelectedAnswers(newAns);// \u3082\u3057\u6700\u5F8C\u306E\u554F\u984C\u306B\u56DE\u7B54\u3057\u305F\u3089\u3001#finished \u306B\u79FB\u52D5\nif(qIndex===surveyQuestions.length-1){scrollToFinished();return;}// invisible\u30E2\u30FC\u30C9 \u2192 \u30B9\u30C6\u30C3\u30D7\u3092\u5897\u3084\u3057\u3066\u6B21\u306B\u9032\u3080\nif(surveyMode===\"invisible\"){if(currentStep<totalSlides){// \u4ECA\u56DE\u7B54\u3048\u305F\u306E\u304C \"currentStep-1\" \u306A\u3089 next step\nif(qIndex===currentStep-1){setCurrentStep(currentStep+1);}}}else{// visible\u30E2\u30FC\u30C9 \u2192 \u5168\u30B9\u30E9\u30A4\u30C9\u8868\u793A\u6E08\u307F\u306A\u306E\u3067\u3001\u81EA\u52D5\u30B9\u30AF\u30ED\u30FC\u30EB\nscrollToSlide(qIndex+1);}};// invisible\u30E2\u30FC\u30C9\u3067 currentStep \u304C\u5897\u3048\u305F\u3068\u304D\u81EA\u52D5\u3067\u6B21\u306B\u30B9\u30AF\u30ED\u30FC\u30EB\nuseEffect(()=>{if(surveyMode===\"invisible\"&&currentStep>1){scrollToSlide(currentStep-1);}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[currentStep]);// \u6B21\u306E\u30B9\u30E9\u30A4\u30C9\u3078\u30B9\u30AF\u30ED\u30FC\u30EB\nconst scrollToSlide=slideIndex=>{const el=document.getElementById(`slide-${slideIndex}`);if(el){window.scrollTo({top:el.getBoundingClientRect().top+window.pageYOffset,behavior:\"smooth\"});}};// \u6700\u5F8C\u306E\u56DE\u7B54\u5F8C #finished \u306B\u30B9\u30AF\u30ED\u30FC\u30EB\nconst scrollToFinished=()=>{const el=document.getElementById(\"finished\");if(el){window.scrollTo({top:el.getBoundingClientRect().top+window.pageYOffset,behavior:\"smooth\"});}};return /*#__PURE__*/_jsx(\"div\",{children:Array.from({length:slidesToRender}).map((_,i)=>{return /*#__PURE__*/_jsx(QuestionSlide,{id:`slide-${i}`,questionIndex:i,question:surveyQuestions[i],selectedAnswer:selectedAnswers[i],onAnswer:handleAnswer,selectedColor:selectedColor,unselectedColor:unselectedColor,progressPercentage:progressPercentage},i);})});}const QuestionSlide=({id,questionIndex,question,selectedAnswer,onAnswer,selectedColor,unselectedColor,progressPercentage})=>{const answers=question.answers.filter(a=>a.trim()!==\"\");return /*#__PURE__*/_jsxs(\"div\",{id:id,style:{width:\"100%\",height:\"auto\",padding:\"20px\",boxSizing:\"border-box\",scrollSnapAlign:\"start\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"15px\",backgroundColor:\"#eee\",borderRadius:\"5px\",marginBottom:\"10px\"},children:/*#__PURE__*/_jsx(\"div\",{style:{height:\"100%\",backgroundColor:selectedColor,borderRadius:\"5px\",width:`${progressPercentage}%`,transition:\"width 0.5s\"}})}),/*#__PURE__*/_jsx(\"h2\",{style:{padding:\"12px\"},children:question.question}),/*#__PURE__*/_jsx(\"img\",{src:question.image,alt:\"Question\",style:{width:\"100%\",maxWidth:600,marginBottom:20}}),/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:\"10px\"},children:answers.map((option,idx)=>/*#__PURE__*/_jsx(\"button\",{style:{padding:\"12px 20px\",border:\"none\",borderRadius:30,backgroundColor:selectedAnswer===idx?selectedColor:unselectedColor,color:\"#fff\",fontSize:\"16px\",cursor:\"pointer\"},onClick:()=>onAnswer(questionIndex,idx),children:option},idx))})]});};/** Property Controls */addPropertyControls(Survey_001,{questions:{type:ControlType.Array,title:\"Questions\",maxCount:5,propertyControl:{type:ControlType.Object,controls:{question:{type:ControlType.String,title:\"Question\",defaultValue:\"Your question\"},image:{type:ControlType.Image,title:\"Image\",defaultValue:\"https://via.placeholder.com/600x400\"},answers:{type:ControlType.Array,title:\"Answers\",maxCount:5,propertyControl:{type:ControlType.String}}}},defaultValue:[]},buttonSelectedColor:{type:ControlType.Color,title:\"Button Selected\",defaultValue:\"#007bff\"},buttonUnselectedColor:{type:ControlType.Color,title:\"Button Unselected\",defaultValue:\"#ccc\"},surveyMode:{type:ControlType.Enum,title:\"Survey Mode\",options:[\"visible\",\"invisible\"],optionTitles:[\"Visible\",\"Invisible\"],defaultValue:\"visible\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"Survey_001\":{\"type\":\"reactComponent\",\"name\":\"Survey_001\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Survey_001.map"],
  "mappings": "uJAA0J,SAASA,EAAW,CAAC,UAAAC,EAAU,oBAAAC,EAAoB,sBAAAC,EAAsB,WAAAC,EAAW,SAAS,EAAE,CACzP,IAAMC,EAAiB,CAAC,CAAC,SAAS,+BAA+B,MAAM,sCAAsC,QAAQ,CAAC,MAAM,OAAO,OAAO,CAAC,EAAE,CAAC,SAAS,gCAAgC,MAAM,sCAAsC,QAAQ,CAAC,MAAM,MAAM,OAAO,MAAM,CAAC,EAAE,CAAC,SAAS,8BAA8B,MAAM,sCAAsC,QAAQ,CAAC,QAAQ,QAAQ,QAAQ,CAAC,CAAC,EACzXC,EAAgBL,GAAWA,EAAU,OAAO,EAAEA,EAAU,MAAM,EAAE,CAAC,EAAEI,EACpE,CAACE,EAAgBC,CAAkB,EAAEC,EAAS,MAAMH,EAAgB,MAAM,EAAE,KAAK,IAAI,CAAC,EACtF,CAACI,EAAYC,CAAc,EAAEF,EAAS,CAAC,EACtCG,EAAYN,EAAgB,OACuCO,EAArDN,EAAgB,OAAOO,GAAKA,IAAM,IAAI,EAAE,OAA8CR,EAAgB,OAAO,IAC3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AAO,SAAS,CAAC,SAAS,CAAC,KAAKA,EAAY,OAAO,MAAM,WAAW,aAAa,eAAe,EAAE,MAAM,CAAC,KAAKA,EAAY,MAAM,MAAM,QAAQ,aAAa,qCAAqC,EAAE,QAAQ,CAAC,KAAKA,EAAY,MAAM,MAAM,UAAU,SAAS,EAAE,gBAAgB,CAAC,KAAKA,EAAY,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,oBAAoB,CAAC,KAAKA,EAAY,MAAM,MAAM,kBAAkB,aAAa,SAAS,EAAE,sBAAsB,CAAC,KAAKA,EAAY,MAAM,MAAM,oBAAoB,aAAa,MAAM,EAAE,WAAW,CAAC,KAAKA,EAAY,KAAK,MAAM,cAAc,QAAQ,CAAC,UAAU,WAAW,EAAE,aAAa,CAAC,UAAU,WAAW,EAAE,aAAa,SAAS,CAAC,CAAC",
  "names": ["Survey_001", "questions", "buttonSelectedColor", "buttonUnselectedColor", "surveyMode", "defaultQuestions", "surveyQuestions", "selectedAnswers", "setSelectedAnswers", "ye", "currentStep", "setCurrentStep", "totalSlides", "progressPercentage", "ans", "selectedColor", "unselectedColor", "slidesToRender", "handleAnswer", "qIndex", "ansIndex", "newAns", "scrollToFinished", "scrollToSlide", "ue", "slideIndex", "el", "window", "p", "_", "i", "QuestionSlide", "id", "questionIndex", "question", "selectedAnswer", "onAnswer", "answers", "a", "u", "option", "idx", "addPropertyControls", "ControlType"]
}
