@s_mart/nps 10.0.3-beta.0 → 11.0.0-beta.2

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.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { CSSProperties } from 'react';
3
3
  import { z } from 'zod';
4
+ import { DialogProps } from '@s_mart/core';
4
5
 
5
6
  declare const schema: z.ZodObject<{
6
7
  nota: z.ZodNumber;
@@ -29,7 +30,7 @@ interface DropzoneOnNotificationProps {
29
30
  duration: number;
30
31
  variant: 'warning' | 'error' | 'success' | 'info';
31
32
  }
32
- interface NPSProps {
33
+ interface NPSProps$1 {
33
34
  sistemaNome: string;
34
35
  /**
35
36
  * Determina se o backdrop aparecerá no fundo
@@ -62,6 +63,36 @@ interface NPSProps {
62
63
  onNotification(params: DropzoneOnNotificationProps): void;
63
64
  }
64
65
 
65
- declare const NPS: ({ onFinalizar, mostrarBackdrop, sistemaNome, onClose, shouldCloseOnBackdropClick, onSelecionarNota, paperStyle, ...rest }: NPSProps) => react_jsx_runtime.JSX.Element;
66
+ declare const NPS$1: ({ onFinalizar, mostrarBackdrop, sistemaNome, onClose, shouldCloseOnBackdropClick, onSelecionarNota, paperStyle, ...rest }: NPSProps$1) => react_jsx_runtime.JSX.Element;
66
67
 
67
- export { NPS, type NPSProps };
68
+ type NotaValue = number | null;
69
+ type SubmitValues = {
70
+ nota: NonNullable<NotaValue>;
71
+ feedback: string;
72
+ };
73
+ type NPSCloseValues = {
74
+ nota: NotaValue;
75
+ };
76
+ type NPSProps = {
77
+ isOpen: boolean;
78
+ onSubmit(values: SubmitValues): void;
79
+ onClose(values: NPSCloseValues): void;
80
+ onChangeAvaliacao(nota: NotaValue): void;
81
+ onChangeEtapa(etapa: NPSEtapas): void;
82
+ slotProps?: Partial<{
83
+ dialog?: Partial<DialogProps>;
84
+ avaliacao?: Partial<AvaliacaoContentProps>;
85
+ feedback?: Partial<FeedbackContentProps>;
86
+ }>;
87
+ };
88
+ type AvaliacaoContentProps = {
89
+ title: string;
90
+ };
91
+ type FeedbackContentProps = {
92
+ title: string;
93
+ };
94
+ type NPSEtapas = 'avaliacao' | 'feedback';
95
+
96
+ declare function NPS(props: NPSProps): react_jsx_runtime.JSX.Element;
97
+
98
+ export { NPS as NPSDialog, type NPSProps as NPSDialogProps, NPS$1 as NPSPopover, type NPSProps$1 as NPSPopoverProps };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{LIcon as j}from"@s_mart/core";import{Checkbox as U,Form as L}from"@s_mart/form";import{lineTimes as O}from"@s_mart/regular-icons";import{Button as Q,Backdrop as _,IconButton as G,Typography as x,useTheme as H}from"@mui/material";import{Button as T,Typography as f,useMediaQuery as w}from"@mui/material";import{colorPalette as y}from"@s_mart/tokens";import{useFormContext as B,useWatch as I}from"react-hook-form";import{Fragment as $,jsx as m,jsxs as v}from"react/jsx-runtime";var E=({onSelecionarNota:e})=>{let{control:i,setValue:t}=B(),a=w("(max-width: 500px)"),l=I({control:i,name:"nota"}),n=p=>{l!==p&&(t("nota",p),e?.(p))},s=m(f,{variant:"bodyXS",color:y.neutral[100],children:"Pouco prov\xE1vel"});return v($,{children:[a&&m("div",{style:{marginBottom:"0.5rem"},children:s}),m("div",{style:{display:"flex",gap:"0.3rem",flexWrap:"wrap",justifyContent:"center"},children:Array.from({length:11}).map((p,r)=>m(T,{variant:l===r?"contained":"outlined",style:{minWidth:"3rem"},onClick:()=>n(r),children:r},r))}),v("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem"},children:[m("span",{children:!a&&s}),m(f,{variant:"bodyXS",color:y.neutral[100],children:"Muito prov\xE1vel"})]})]})},b=E;import{TextField as A}from"@s_mart/form";import{jsx as M}from"react/jsx-runtime";var D=({tipo:e,sistemaNome:i})=>M(A,{name:"feedback",placeholder:e==="promotor"?`Para mim o ${i} \xE9...`:"Eu acho que...",multiline:!0,size:"large",minRows:2}),h=D;import{styled as R}from"@mui/material";import{colorPalette as V}from"@s_mart/tokens";var P=R("div")(({theme:e})=>({display:"flex",flexDirection:"column",gap:"1.5rem",padding:"1.5rem",borderRadius:Number.parseFloat(e.shape.borderRadius.toString())*1.5,boxShadow:e.shadows[6],border:`1px solid ${e.palette.primary?.main}`,background:V.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 W}from"react";var q=({onEnviarNota:e,onNotification:i})=>{let[t,a]=W("selecionarNota");return{step:t,handleEnviar:(n,s)=>{t==="selecionarNota"?(e?.(n),n>=9?a("feedbackPromotor"):a("feedbackDetrator")):(s(),i({variant:"success",title:"Avalia\xE7\xE3o enviada",message:"Agradecemos muito pela sua avalia\xE7\xE3o.",duration:5e3}))}}},g=q;import{z as d}from"zod";var X=d.object({nota:d.number(),feedback:d.string().optional(),autorizoPublicacao:d.coerce.boolean()}),S=X;import{Fragment as Y,jsx as o,jsxs as c}from"react/jsx-runtime";var J=({onFinalizar:e,mostrarBackdrop:i,sistemaNome:t,onClose:a,shouldCloseOnBackdropClick:l,onSelecionarNota:n,paperStyle:s,...p})=>{let{step:r,handleEnviar:k}=g(p),N=H(),F={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 o(L,{onSubmit:e,schema:S,children:({watch:C,onSubmit:z})=>{let u=C("nota");return c(Y,{children:[!!i&&o(_,{open:!0,onClick:l?a:void 0,style:{zIndex:99}}),c(P,{style:s,children:[c("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o(x,{variant:"titleSM",color:N.palette.grey[700],children:F[r]}),o(G,{size:"small",onClick:a,children:o(j,{icon:O,removeMargin:!0,size:"25px"})})]}),o("div",{children:r==="selecionarNota"?o(b,{onSelecionarNota:n}):o(h,{tipo:r==="feedbackPromotor"?"promotor":"detrator",sistemaNome:t})}),c("div",{style:{display:"flex",justifyContent:"space-between"},children:[o("div",{children:r==="feedbackPromotor"&&o(U,{name:"autorizoPublicacao",label:c(x,{variant:"bodyXS",children:["Autorizo a publica\xE7\xE3o deste coment\xE1rio no site e em redes sociais do ",t]})})}),o("div",{children:o(Q,{disabled:u===void 0,onClick:()=>k(u,z),children:"Enviar"})})]})]})]})}})},K=J;export{K as NPS};
1
+ import{LIcon as ao}from"@s_mart/core";import{Checkbox as ro,Form as no}from"@s_mart/form";import{lineTimes as io}from"@s_mart/regular-icons";import{Button as lo,Backdrop as so,IconButton as po,Typography as V,useTheme as co}from"@mui/material";import{Button as X,Typography as T,useMediaQuery as L}from"@mui/material";import{colorPalette as B}from"@s_mart/tokens";import{useFormContext as Q,useWatch as U}from"react-hook-form";import{Fragment as G,jsx as f,jsxs as D}from"react/jsx-runtime";var _=({onSelecionarNota:o})=>{let{control:e,setValue:t}=Q(),a=L("(max-width: 500px)"),n=U({control:e,name:"nota"}),d=s=>{n!==s&&(t("nota",s),o?.(s))},l=f(T,{variant:"bodyXS",color:B.neutral[100],children:"Pouco prov\xE1vel"});return D(G,{children:[a&&f("div",{style:{marginBottom:"0.5rem"},children:l}),f("div",{style:{display:"flex",gap:"0.3rem",flexWrap:"wrap",justifyContent:"center"},children:Array.from({length:11}).map((s,i)=>f(X,{variant:n===i?"contained":"outlined",style:{minWidth:"3rem"},onClick:()=>d(i),children:i},i))}),D("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem"},children:[f("span",{children:!a&&l}),f(T,{variant:"bodyXS",color:B.neutral[100],children:"Muito prov\xE1vel"})]})]})},w=_;import{TextField as J}from"@s_mart/form";import{jsx as Y}from"react/jsx-runtime";var K=({tipo:o,sistemaNome:e})=>Y(J,{name:"feedback",placeholder:o==="promotor"?`Para mim o ${e} \xE9...`:"Eu acho que...",multiline:!0,size:"large",minRows:2}),A=K;import{styled as Z}from"@mui/material";import{colorPalette as j}from"@s_mart/tokens";var H=Z("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:j.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 oo}from"react";var eo=({onEnviarNota:o,onNotification:e})=>{let[t,a]=oo("selecionarNota");return{step:t,handleEnviar:(d,l)=>{t==="selecionarNota"?(o?.(d),d>=9?a("feedbackPromotor"):a("feedbackDetrator")):(l(),e({variant:"success",title:"Avalia\xE7\xE3o enviada",message:"Agradecemos muito pela sua avalia\xE7\xE3o.",duration:5e3}))}}},M=eo;import{z as v}from"zod";var to=v.object({nota:v.number(),feedback:v.string().optional(),autorizoPublicacao:v.coerce.boolean()}),z=to;import{Fragment as uo,jsx as p,jsxs as S}from"react/jsx-runtime";var mo=({onFinalizar:o,mostrarBackdrop:e,sistemaNome:t,onClose:a,shouldCloseOnBackdropClick:n,onSelecionarNota:d,paperStyle:l,...s})=>{let{step:i,handleEnviar:u}=M(s),P=co(),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(no,{onSubmit:o,schema:z,children:({watch:g,onSubmit:E})=>{let y=g("nota");return S(uo,{children:[!!e&&p(so,{open:!0,onClick:n?a:void 0,style:{zIndex:99}}),S(H,{style:l,children:[S("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p(V,{variant:"titleSM",color:P.palette.grey[700],children:C[i]}),p(po,{size:"small",onClick:a,children:p(ao,{icon:io,removeMargin:!0,size:"25px"})})]}),p("div",{children:i==="selecionarNota"?p(w,{onSelecionarNota:d}):p(A,{tipo:i==="feedbackPromotor"?"promotor":"detrator",sistemaNome:t})}),S("div",{style:{display:"flex",justifyContent:"space-between"},children:[p("div",{children:i==="feedbackPromotor"&&p(ro,{name:"autorizoPublicacao",label:S(V,{variant:"bodyXS",children:["Autorizo a publica\xE7\xE3o deste coment\xE1rio no site e em redes sociais do ",t]})})}),p("div",{children:p(lo,{disabled:y===void 0,onClick:()=>u(y,E),children:"Enviar"})})]})]})]})}})};import{Dialog as Do}from"@s_mart/core";import{createContext as wo,useContext as Ao}from"react";import{useCallback as fo,useMemo as Po,useState as x}from"react";import{mergeSlotProps as So,useMediaQuery as bo,useTheme as yo}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 W(o){let[e,t]=x(""),[a,n]=x(null),[d,l]=x("avaliacao"),s=yo(),i=bo(s.breakpoints.down("sm")),u=Po(()=>So(o.slotProps,{...k,dialog:{fullScreen:i,...k}}),[o.slotProps,i]),P=y=>{o.onChangeAvaliacao?.(y),n(null)},C=()=>{o.onClose({nota:a}),setTimeout(()=>{n(null),t(""),l("avaliacao")},100)},g=fo(()=>{o.onSubmit({nota:a,feedback:e})},[o.onSubmit,a,e]);return{feedback:e,setFeedback:t,nota:a,handleChangeAvaliacao:P,handleProximaEtapa:()=>{l("feedback"),o.onChangeEtapa?.("feedback")},etapa:d,setEtapa:l,handleSubmit:g,handleClose:C,slotProps:u}}import{Button as Co}from"@mui/material";import{Dialog as N}from"@s_mart/core";import{TextField as vo}from"@mui/material";import{jsx as ho}from"react/jsx-runtime";var I=o=>{let{feedback:e,setFeedback:t}=m();return ho(vo,{autoFocus:!0,fullWidth:!0,rows:3,multiline:!0,...o,value:e,onChange:n=>{t(n.target.value.trim()),o.onChange?.(n)}})};import{Fragment as go,jsx as b,jsxs as ko}from"react/jsx-runtime";function R(o){let{handleSubmit:e,feedback:t}=m();return ko(go,{children:[b(N.Header,{children:o.title}),b(N.Content,{children:b(I,{})}),b(N.Footer,{children:b(Co,{fullWidth:!0,disabled:!t,onClick:e,children:"Enviar"})})]})}import{Button as Fo,styled as Eo}from"@mui/material";import{Dialog as F}from"@s_mart/core";import{Button as xo}from"@mui/material";import{jsx as No}from"react/jsx-runtime";var c=o=>{let{handleChangeAvaliacao:e}=m(),t=()=>e(o.notaSelecionada===o.nota?null:o.nota);return No(xo,{sx:{padding:0,minWidth:"3rem"},...o,variant:o.nota===o.notaSelecionada?"contained":"outlined",onClick:t,children:o.nota})};import{Fragment as Bo,jsx as r,jsxs as $}from"react/jsx-runtime";function q(o){let{nota:e,setEtapa:t,handleProximaEtapa:a}=m();return $(Bo,{children:[r(F.Header,{children:o.title}),r(F.Content,{children:$(To,{children:[r(c,{notaSelecionada:e,nota:0,color:"feedbackHard"}),r(c,{notaSelecionada:e,nota:1,color:"feedbackHard"}),r(c,{notaSelecionada:e,nota:2,color:"feedbackHard"}),r(c,{notaSelecionada:e,nota:3,color:"feedbackHard"}),r(c,{notaSelecionada:e,nota:4,color:"feedbackHard"}),r(c,{notaSelecionada:e,nota:5,color:"feedbackHard"}),r(c,{notaSelecionada:e,nota:6,color:"feedbackHard"}),r(c,{notaSelecionada:e,nota:7,color:"feedbackMedium"}),r(c,{notaSelecionada:e,nota:8,color:"feedbackMedium"}),r(c,{notaSelecionada:e,nota:9,color:"feedbackVeryEasy"}),r(c,{notaSelecionada:e,nota:10,color:"feedbackVeryEasy"})]})}),r(F.Footer,{children:r(Fo,{disabled:e===null,onClick:a,fullWidth:!0,children:"Enviar"})})]})}var To=Eo("div")({display:"flex",gap:"0.25rem",flexWrap:"wrap",justifyContent:"center",paddingBlock:"0.25rem"});import{styled as Ho}from"@mui/material";import{Fragment as Vo,jsx as h,jsxs as Wo}from"react/jsx-runtime";var O=wo(null);function Mo(o){let{feedback:e,nota:t,setFeedback:a,handleChangeAvaliacao:n,handleClose:d,handleProximaEtapa:l,etapa:s,setEtapa:i,slotProps:u,handleSubmit:P}=W(o);return h(zo,{open:o.isOpen,onClose:d,...u.dialog,children:h(O.Provider,{value:{handleSubmit:P,feedback:e,setFeedback:a,nota:t,handleChangeAvaliacao:n,handleProximaEtapa:l,etapa:s},children:Wo(Vo,{children:[s==="avaliacao"&&h(q,{...u.avaliacao}),s==="feedback"&&h(R,{...u.feedback})]})})})}var m=()=>{let o=Ao(O);if(!o)throw new Error("useNPSContext must be used within a NPSProvider");return o},zo=Ho(Do)(({theme:o})=>({[o.breakpoints.down("sm")]:{".MuiPaper-root":{position:"absolute",bottom:0,height:"auto"}}}));export{Mo as NPSDialog,mo as NPSPopover};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s_mart/nps",
3
- "version": "10.0.3-beta.0",
3
+ "version": "11.0.0-beta.2",
4
4
  "main": "./dist/index.mjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -28,8 +28,8 @@
28
28
  "react-dom": "^18.3.1",
29
29
  "react-hook-form": "^7.51.0",
30
30
  "zod": "^3.22.4",
31
- "@s_mart/core": "10.0.2-beta.0",
32
- "@s_mart/form": "10.0.3-beta.0",
31
+ "@s_mart/core": "10.0.2-beta.1",
32
+ "@s_mart/form": "10.0.3-beta.1",
33
33
  "@s_mart/regular-icons": "6.0.11",
34
34
  "@s_mart/tokens": "6.0.0"
35
35
  },
@@ -49,8 +49,8 @@
49
49
  "react-dom": "^18.3.1",
50
50
  "react-hook-form": "^7.51.0",
51
51
  "zod": "^3.22.4",
52
- "@s_mart/core": "10.0.2-beta.0",
53
- "@s_mart/form": "10.0.3-beta.0",
52
+ "@s_mart/core": "10.0.2-beta.1",
53
+ "@s_mart/form": "10.0.3-beta.1",
54
54
  "@s_mart/regular-icons": "6.0.11",
55
55
  "@s_mart/tokens": "6.0.0"
56
56
  },
@@ -58,7 +58,7 @@
58
58
  "react-is": "^18.3.1"
59
59
  },
60
60
  "scripts": {
61
- "build": "tsup src/index.tsx --minify --format esm --dts --external react",
62
- "dev": "tsup src/index.tsx --format esm --watch --dts --external react"
61
+ "build": "tsup src/index.ts --minify --format esm --dts --external react",
62
+ "dev": "tsup src/index.ts --format esm --watch --dts --external react"
63
63
  }
64
64
  }