@anoki/fse-ui
Version:
FSE UI components library
3 lines (2 loc) • 1.9 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./styles/typography.css');require('./components/ui/Feedback/Feedback.css');const e=require("./index.cjs237.js");;/* empty css */const M=require("./index.cjs395.js"),V=require("./index.cjs396.js"),n=require("react"),H=require("./index.cjs397.js");;/* empty css */function P({question:x,rating:m,questions:r,onSend:p,buttons:f,maxCharactersMessage:j,successMessage:w,errorMessage:R,loadingMessage:g,isLoading:h=!1,hasError:E=!1,openAnswerPlaceholder:S}){const[i,A]=n.useState(()=>m??0),[a,c]=n.useState([]),[l,b]=n.useState(""),[u,v]=n.useState(!1),[Q,k]=n.useState([]);n.useEffect(()=>{k((()=>{const t=[];return i>=3?(t[0]=r[0],t[1]=r[2]):(t[0]=r[1],t[1]=r[2]),t})()),c([])},[i,r]);const C=s=>{A(s)},N=(s,t)=>{c(o=>[...o.filter(y=>y.id!==s),{id:s,answer:[t]}])},q=s=>{b(s)},F=()=>{v(!0);const s=a.map(o=>o.answer.map(d=>d.answer)).flat();p({rating:i,closedAnswer:s,openAnswer:l})},O=()=>h?g:E?R:w;return e.jsxRuntimeExports.jsxs(H.CardComponent.Root,{children:[!u&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"p-3 d-flex flex-column gap-3 align-items-start",children:[e.jsxRuntimeExports.jsx("p",{className:"fs-5 fw-semibold",children:x}),e.jsxRuntimeExports.jsx(M.Rating,{onClick:C,rating:i})]}),i>0&&e.jsxRuntimeExports.jsx("div",{className:"feedback-questions-container",children:e.jsxRuntimeExports.jsx(V.Questions,{onSend:F,questions:Q,onChangeAnswer:N,values:a,openAnswer:l,handleOpenAnswer:q,buttons:f,maxCharactersMessage:j,openAnswerPlaceholder:S})})]}),u&&e.jsxRuntimeExports.jsx("div",{className:"steppers-content p-4","aria-live":"polite",children:e.jsxRuntimeExports.jsx("p",{className:"feedback-final-message fw-semibold fs-custom",children:O()})})]})}exports.Feedback=P;
//# sourceMappingURL=index.cjs84.js.map