@s_mart/nps 11.0.0-beta.4 → 11.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LIcon as
|
|
1
|
+
import{LIcon as io}from"@s_mart/core";import{Checkbox as lo,Form as so}from"@s_mart/form";import{lineTimes as po}from"@s_mart/regular-icons";import{Button as mo,Backdrop as co,IconButton as uo,Typography as V,useTheme as fo}from"@mui/material";import{Button as U,Typography as E,useMediaQuery as _}from"@mui/material";import{colorPalette as A}from"@s_mart/tokens";import{useFormContext as G,useWatch as J}from"react-hook-form";import{Fragment as Y,jsx as u,jsxs as D}from"react/jsx-runtime";var K=({onSelecionarNota:o})=>{let{control:e,setValue:t}=G(),a=_("(max-width: 500px)"),i=J({control:e,name:"nota"}),c=s=>{i!==s&&(t("nota",s),o?.(s))},l=u(E,{variant:"bodyXS",color:A.neutral[100],children:"Pouco prov\xE1vel"});return D(Y,{children:[a&&u("div",{style:{marginBottom:"0.5rem"},children:l}),u("div",{style:{display:"flex",gap:"0.3rem",flexWrap:"wrap",justifyContent:"center"},children:Array.from({length:11}).map((s,r)=>u(U,{variant:i===r?"contained":"outlined",style:{minWidth:"3rem"},onClick:()=>c(r),children:r},r))}),D("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem"},children:[u("span",{children:!a&&l}),u(E,{variant:"bodyXS",color:A.neutral[100],children:"Muito prov\xE1vel"})]})]})},w=K;import{TextField as Z}from"@s_mart/form";import{jsx as oo}from"react/jsx-runtime";var j=({tipo:o,sistemaNome:e})=>oo(Z,{name:"feedback",placeholder:o==="promotor"?`Para mim o ${e} \xE9...`:"Eu acho que...",multiline:!0,size:"large",minRows:2}),H=j;import{styled as eo}from"@mui/material";import{colorPalette as to}from"@s_mart/tokens";var M=eo("div")(({theme:o})=>({display:"flex",flexDirection:"column",gap:"1.5rem",padding:"1.5rem",borderRadius:Number.parseFloat(o.shape.borderRadius.toString())*1.5,boxShadow:o.shadows[6],border:`1px solid ${o.palette.primary?.main}`,background:to.neutral[0],position:"absolute",bottom:"1.5rem",right:"1.75rem",zIndex:102,"@media (max-width: 650px)":{right:"1.25rem",left:"1.25rem"}}));import{useState as ao}from"react";var ro=({onEnviarNota:o,onNotification:e})=>{let[t,a]=ao("selecionarNota");return{step:t,handleEnviar:(c,l)=>{t==="selecionarNota"?(o?.(c),c>=9?a("feedbackPromotor"):a("feedbackDetrator")):(l(),e({variant:"success",title:"Avalia\xE7\xE3o enviada",message:"Agradecemos muito pela sua avalia\xE7\xE3o.",duration:5e3}))}}},z=ro;import{z as y}from"zod";var no=y.object({nota:y.number(),feedback:y.string().optional(),autorizoPublicacao:y.coerce.boolean()}),W=no;import{Fragment as So,jsx as p,jsxs as b}from"react/jsx-runtime";var Po=({onFinalizar:o,mostrarBackdrop:e,sistemaNome:t,onClose:a,shouldCloseOnBackdropClick:i,onSelecionarNota:c,paperStyle:l,...s})=>{let{step:r,handleEnviar:P}=z(s),N=fo(),C={selecionarNota:`De 0 a 10, o quanto voc\xEA recomendaria o ${t}?`,feedbackDetrator:`Como podemos melhorar a sua experi\xEAncia no ${t}?`,feedbackPromotor:`O que voc\xEA mais gosta no ${t}?`};return p(so,{onSubmit:o,schema:W,children:({watch:g,onSubmit:T})=>{let S=g("nota");return b(So,{children:[!!e&&p(co,{open:!0,onClick:i?a:void 0,style:{zIndex:99}}),b(M,{style:l,children:[b("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p(V,{variant:"titleSM",color:N.palette.grey[700],children:C[r]}),p(uo,{size:"small",onClick:a,children:p(io,{icon:po,removeMargin:!0,size:"25px"})})]}),p("div",{children:r==="selecionarNota"?p(w,{onSelecionarNota:c}):p(H,{tipo:r==="feedbackPromotor"?"promotor":"detrator",sistemaNome:t})}),b("div",{style:{display:"flex",justifyContent:"space-between"},children:[p("div",{children:r==="feedbackPromotor"&&p(lo,{name:"autorizoPublicacao",label:b(V,{variant:"bodyXS",children:["Autorizo a publica\xE7\xE3o deste coment\xE1rio no site e em redes sociais do ",t]})})}),p("div",{children:p(mo,{disabled:S===void 0,onClick:()=>P(S,T),children:"Enviar"})})]})]})]})}})};import{Dialog as Vo}from"@s_mart/core";import{createContext as Io,useContext as Ro}from"react";import{useCallback as bo,useMemo as yo,useState as x}from"react";import{mergeSlotProps as vo,useMediaQuery as ho,useTheme as No}from"@mui/material";var k={avaliacao:{title:"O quanto voc\xEA recomendaria o sistema?"},feedback:{title:"Como podemos melhorar a sua experi\xEAncia?"},dialog:{closeIcon:!0}};function I(o){let[e,t]=x(""),[a,i]=x(null),[c,l]=x("avaliacao"),s=No(),r=ho(s.breakpoints.down("sm")),P=yo(()=>vo(o.slotProps,{...k,dialog:{fullScreen:r,...k.dialog}}),[o.slotProps,r]),N=S=>{o.onChangeAvaliacao?.(S),i(S)},C=()=>{o.onClose({nota:a}),setTimeout(()=>{i(null),t(""),l("avaliacao")},100)},g=bo(()=>{o.onSubmit({nota:a,feedback:e.trim()})},[o.onSubmit,a,e]);return{feedback:e,setFeedback:t,nota:a,handleChangeAvaliacao:N,handleProximaEtapa:()=>{l("feedback"),o.onChangeEtapa?.("feedback")},etapa:c,setEtapa:l,handleSubmit:g,handleClose:C,slotProps:P}}import{Dialog as F}from"@s_mart/core";import{TextField as Co}from"@mui/material";import{jsx as go}from"react/jsx-runtime";var R=o=>{let{feedback:e,setFeedback:t}=d();return go(Co,{autoFocus:!0,fullWidth:!0,rows:3,multiline:!0,...o,value:e,onChange:i=>{t(i.target.value),o.onChange?.(i)}})};import{Button as ko}from"@mui/material";import{jsx as xo}from"react/jsx-runtime";function $(o){let{feedback:e,handleSubmit:t}=d();return xo(ko,{fullWidth:!0,disabled:!e.trim(),...o,onClick:t})}import{Typography as Fo}from"@mui/material";import{jsx as Bo}from"react/jsx-runtime";var v=({children:o})=>Bo(Fo,{variant:"titleMD",fontSize:"18px",children:o});import{Fragment as To,jsx as f,jsxs as Eo}from"react/jsx-runtime";function q(o){return Eo(To,{children:[f(F.Header,{children:f(v,{children:o.title})}),f(F.Content,{children:f(R,{})}),f(F.Footer,{children:f($,{children:"Enviar"})})]})}import{styled as Mo}from"@mui/material";import{Dialog as B}from"@s_mart/core";import{Button as Ao}from"@mui/material";import{jsx as Do}from"react/jsx-runtime";var m=o=>{let{handleChangeAvaliacao:e}=d(),t=()=>e(o.notaSelecionada===o.nota?null:o.nota);return Do(Ao,{sx:{padding:0,minWidth:"3rem"},...o,variant:o.nota===o.notaSelecionada?"contained":"outlined",onClick:t,children:o.nota})};import{Button as wo}from"@mui/material";import{jsx as Ho}from"react/jsx-runtime";function O(o){let{nota:e,handleProximaEtapa:t}=d();return Ho(wo,{fullWidth:!0,disabled:e===null,...o,onClick:t})}import{Fragment as Wo,jsx as n,jsxs as X}from"react/jsx-runtime";function L(o){let{nota:e}=d();return X(Wo,{children:[n(B.Header,{children:n(v,{children:o.title})}),n(B.Content,{children:X(zo,{children:[n(m,{notaSelecionada:e,nota:0,color:"feedbackHard"}),n(m,{notaSelecionada:e,nota:1,color:"feedbackHard"}),n(m,{notaSelecionada:e,nota:2,color:"feedbackHard"}),n(m,{notaSelecionada:e,nota:3,color:"feedbackHard"}),n(m,{notaSelecionada:e,nota:4,color:"feedbackHard"}),n(m,{notaSelecionada:e,nota:5,color:"feedbackHard"}),n(m,{notaSelecionada:e,nota:6,color:"feedbackHard"}),n(m,{notaSelecionada:e,nota:7,color:"feedbackMedium"}),n(m,{notaSelecionada:e,nota:8,color:"feedbackMedium"}),n(m,{notaSelecionada:e,nota:9,color:"feedbackVeryEasy"}),n(m,{notaSelecionada:e,nota:10,color:"feedbackVeryEasy"})]})}),n(B.Footer,{children:n(O,{children:"Enviar"})})]})}var zo=Mo("div")({display:"flex",gap:"0.25rem",flexWrap:"wrap",justifyContent:"center",paddingBlock:"0.25rem"});import{styled as $o}from"@mui/material";import{Fragment as Xo,jsx as h,jsxs as Lo}from"react/jsx-runtime";var Q=Io(null);function qo(o){let{feedback:e,nota:t,setFeedback:a,handleChangeAvaliacao:i,handleClose:c,handleProximaEtapa:l,etapa:s,slotProps:r,handleSubmit:P}=I(o);return h(Oo,{open:o.isOpen,onClose:c,...r.dialog,children:h(Q.Provider,{value:{handleSubmit:P,feedback:e,setFeedback:a,nota:t,handleChangeAvaliacao:i,handleProximaEtapa:l,etapa:s},children:Lo(Xo,{children:[s==="avaliacao"&&h(L,{...r.avaliacao}),s==="feedback"&&h(q,{...r.feedback})]})})})}var d=()=>{let o=Ro(Q);if(!o)throw new Error("useNPSContext must be used within a NPSProvider");return o},Oo=$o(Vo)(({theme:o})=>({[o.breakpoints.down("sm")]:{".MuiPaper-root":{position:"absolute",bottom:0,height:"auto"}}}));export{qo as NPSDialog,Po as NPSPopover};
|