UNPKG

@anoki/fse-ui

Version:

FSE UI components library

3 lines (2 loc) 2.66 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./components/ui/Feedback/Questions.css');const t=require("./index.cjs278.js");;/* empty css */const d=require("react"),h=require("./index.cjs36.js");function b({questions:n,onChangeAnswer:c,onSend:j,values:i,openAnswer:r,handleOpenAnswer:f,buttons:o,maxCharactersMessage:x,openAnswerPlaceholder:g,resetFeedback:a}){const[e,u]=d.useState(0),v=d.useCallback((s,l)=>{c(s,l)},[c]),E=()=>{j()},N=()=>{!i[e]&&n[e].type!=="OPEN"||(e<n.length-1&&u(e+1),e===n.length-1&&E())},R=()=>{if(e===0){a==null||a();return}e>0&&u(e-1)};return t.jsxRuntimeExports.jsxs("div",{className:"steppers",children:[t.jsxRuntimeExports.jsxs("div",{className:"steppers-header pb-2 align-items-center",children:[t.jsxRuntimeExports.jsx("p",{className:"steppers-header-question-title",children:n[e].question}),t.jsxRuntimeExports.jsxs("span",{className:"steppers-header-question-number",children:[e+1,"/",n.length]})]}),t.jsxRuntimeExports.jsx("div",{className:"steppers-content","aria-live":"polite",children:n[e].type==="CLOSE"?t.jsxRuntimeExports.jsx("div",{className:"list-group",children:n[e].answers.map((s,l)=>{var m,p;return t.jsxRuntimeExports.jsxs("label",{htmlFor:`checkbox-${s.id}`,className:" fw-regular fs-6 list-group-item ",children:[t.jsxRuntimeExports.jsx("input",{type:"radio",id:`checkbox-${s.id}`,name:`question-${e}`,value:s.answer,checked:((p=(m=i==null?void 0:i[e])==null?void 0:m.answer)==null?void 0:p.includes(s))||!1,onChange:()=>v(n[e].id,s),className:"custom-control-input form-check-input me-2 black-focus"}),s.answer]},`${n[e].id}-${l}`)})}):t.jsxRuntimeExports.jsxs("div",{className:"form-group d-flex flex-column gap-1",children:[t.jsxRuntimeExports.jsx("input",{type:"text",placeholder:g,className:"form-control black-focus",value:r,onChange:s=>s.target.value.length<=200&&f(s.target.value),autoFocus:!0}),t.jsxRuntimeExports.jsxs("div",{className:"d-flex justify-content-between align-items-center max-chars-container",children:[x&&t.jsxRuntimeExports.jsx("p",{className:" fs-6 fw-normal ",children:x}),r&&r.length>0&&t.jsxRuntimeExports.jsxs("p",{className:"active fs-6 fw-normal ",children:[r.length,"/200"]})]})]})}),t.jsxRuntimeExports.jsxs("nav",{className:"steppers-nav no-border shadow-none align-items-center justify-content-center gap-4 flex-wrap",children:[t.jsxRuntimeExports.jsx(h.Button,{className:"feedback-button-back",onClick:R,children:o.previous}),t.jsxRuntimeExports.jsx(h.Button,{className:"feedback-button-next",onClick:N,disabled:e===n.length,children:o.next})]})]})}exports.Questions=b; //# sourceMappingURL=index.cjs441.js.map