@anoki/fse-ui
Version:
FSE UI components library
3 lines (2 loc) • 1.93 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.cjs278.js");;/* empty css */const V=require("./index.cjs440.js"),H=require("./index.cjs441.js"),n=require("react"),P=require("./index.cjs442.js");;/* empty css */function T({question:m,rating:p,questions:r,onSend:f,buttons:j,maxCharactersMessage:w,successMessage:R,errorMessage:g,loadingMessage:h,isLoading:E=!1,hasError:S=!1,openAnswerPlaceholder:A}){const[i,a]=n.useState(()=>p??0),[c,l]=n.useState([]),[u,b]=n.useState(""),[d,v]=n.useState(!1),[k,Q]=n.useState([]);n.useEffect(()=>{Q((()=>{const t=[];return i>=3?(t[0]=r[0],t[1]=r[2]):(t[0]=r[1],t[1]=r[2]),t})()),l([])},[i,r]);const C=s=>{a(s)},F=(s,t)=>{l(o=>[...o.filter(M=>M.id!==s),{id:s,answer:[t]}])},N=s=>{b(s)},q=()=>{v(!0);const s=c.map(o=>o.answer.map(x=>x.answer)).flat();f({rating:i,closedAnswer:s,openAnswer:u})},O=()=>E?h:S?g:R,y=()=>{a(0)};return e.jsxRuntimeExports.jsxs(P.CardComponent.Root,{children:[!d&&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:m}),e.jsxRuntimeExports.jsx(V.Rating,{onClick:C,rating:i})]}),i>0&&e.jsxRuntimeExports.jsx("div",{className:"feedback-questions-container",children:e.jsxRuntimeExports.jsx(H.Questions,{onSend:q,questions:k,onChangeAnswer:F,values:c,openAnswer:u,handleOpenAnswer:N,resetFeedback:y,buttons:j,maxCharactersMessage:w,openAnswerPlaceholder:A})})]}),d&&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=T;
//# sourceMappingURL=index.cjs132.js.map