2 lines
1.6 KiB
JavaScript
2 lines
1.6 KiB
JavaScript
import{j as e}from"./vendor-BKmmeuxg.js";import{B as d}from"./button-BpNwv2aE.js";import{C as h}from"./checkbox-BBZKtHnN.js";import{L as j}from"./label-HmIcv5Yx.js";import"./index-WW_1X1qx.js";import"./utils-DxSsnXxD.js";const y=({question:o,answer:c,onAnswerChange:r})=>{var a;const l=(c==null?void 0:c.selected_option_ids)||[],n=(s,t)=>{const i=t?[...l,s]:l.filter(x=>x!==s);r({selected_option_ids:i})},m=()=>{var t;const s=((t=o.question_options)==null?void 0:t.map(i=>i.id))||[];r({selected_option_ids:s})},p=()=>{r({selected_option_ids:[]})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"Select all correct answers:"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"ghost",size:"sm",onClick:m,children:"Select All"}),e.jsx(d,{variant:"ghost",size:"sm",onClick:p,disabled:l.length===0,children:"Clear All"})]})]}),e.jsx("div",{className:"space-y-3",children:(a=o.question_options)==null?void 0:a.map(s=>{const t=l.includes(s.id);return e.jsxs("div",{className:`flex items-start space-x-3 rounded-lg border-2 p-4 transition-colors ${t?"border-primary bg-primary/5":"border-gray-200 hover:border-gray-300"}`,children:[e.jsx(h,{id:`option-${s.id}`,checked:t,onCheckedChange:i=>n(s.id,i),className:"mt-0.5"}),e.jsx(j,{htmlFor:`option-${s.id}`,className:"flex-1 cursor-pointer font-normal",children:s.option_text})]},s.id)})}),l.length>0&&e.jsxs("p",{className:"text-sm text-gray-600",children:["Selected: ",e.jsx("span",{className:"font-semibold",children:l.length})," option(s)"]})]})};export{y as default};
|