@zydon/common-csr 2.0.73 → 2.0.74

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.
@@ -27,6 +27,6 @@ import F from '@zydon/common/form/Autocomplete';
27
27
  import ce from '@zydon/common/form/Field';
28
28
  import we from '@mui/material/ToggleButton';
29
29
 
30
- var N=styled(B)(({theme:o})=>({borderBottom:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderTop:`1px solid ${alpha(o.palette.grey[500],.32)}`,padding:16})),oo=styled(B)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,padding:12,"& .MuiInputBase-root":{background:o.palette.grey[100]}})),eo=styled(B)(({theme:o})=>({display:"flex",textAlign:"center",flexDirection:"row",alignItems:"center",width:"100%",gap:8,height:34,backgroundColor:"#fff",padding:"8px 16px",borderRadius:8,border:`1px solid ${alpha(o.palette.grey[500],.24)}`,cursor:"pointer",color:o.palette.text.disabled,"&:hover, &:focus":{border:`1px solid ${o.palette.primary.main}`,backgroundColor:alpha(o.palette.primary.main,.05)}})),to=styled(B)(({theme:o})=>({width:"100%","& fieldset":{border:`1px solid ${alpha(o.palette.grey[500],.24)}`,borderRadius:8,"& legend":{color:o.palette.text.disabled,fontSize:12}}})),q=styled(Po)({padding:0});var Fo=({openPopover:o,handleClose:e,argumentsValues:a,filter:n,onExecute:i})=>{let[l,p]=useState([]),m=(t,s)=>{if(s&&s!=="")l.filter(d=>d.name===t).length>0?p(l.map(d=>d.name===t?{name:t,value:s}:d)):p([...l||[],{name:t,value:s}]);else {let c=l.filter(d=>d.name===t);p(c);}},f=()=>{let t=n||"";return l.forEach(s=>{t=t.replace(`$ARG[${s.name}]`,`'${s.value}'`);}),t};return jsxs(Bo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,title:"Pr\xE9-visualizar",children:[jsx(po,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(N,{children:a?.map((t,s)=>jsx(Mo,{name:t,label:t,size:"small",onChange:c=>m(t,c.target.value),required:!0},s))}),jsxs(B,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(ro,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(ro,{variant:"contained",color:"primary",size:"small",startIcon:jsx(V,{icon:"PLAY_SIMPLE"}),onClick:()=>i(f()),disabled:l.length<a.length,children:"Executar"})]})]})},io=Fo;var Ho=({openPopover:o,handleClose:e,addItem:a})=>{let[n,i]=useState("");return jsxs(Bo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,sx:{maxWidth:464},title:"Novo Argumento",children:[jsx(po,{variant:"subtitle1",color:"text.primary",p:1,children:"Novo Argumento"}),jsx(N,{children:jsx(Mo,{value:n,onChange:p=>i(p.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(B,{p:1,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(ro,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(ro,{variant:"contained",color:"primary",size:"small",startIcon:jsx(V,{icon:"SAVE_MARK"}),disabled:!n||n==="",onClick:()=>{a(n),e(),i("");},children:"Salvar"})]})]})},so=Ho;var Yo=({label:o,itens:e,argumentsValues:a,fields:n,addItem:i,removeItem:l,insertItemSQL:p})=>{let[m,f]=useState(!1),t=Ko(),s=()=>{f(!m);},c=(u,g)=>{u.stopPropagation(),l&&l(g);},d=u=>{p(a?` $ARG[${u}]`:n?` this.${u}`:` ${u}`);};return jsxs(B,{children:[jsxs(B,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(q,{edge:"end",onClick:s,children:jsx(V,{icon:m?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(po,{variant:"overline",color:"text.primary",children:o}),i&&jsxs(Fragment,{children:[jsx(q,{edge:"end",onClick:t.onOpen,children:jsx(V,{icon:"SIMPLE_ADD"})}),jsx(so,{addItem:i,handleClose:t.onClose,openPopover:t.open})]})]}),m&&jsx(B,{spacing:.5,children:jsx(Wo,{sx:{maxHeight:150},children:e?.map((u,g)=>jsxs(eo,{direction:"row",justifyContent:"space-between",onClick:()=>d(u),children:[jsx(po,{variant:"caption",textAlign:"center",width:"100%",children:u}),l&&jsx(Po,{edge:"end",onClick:w=>c(w,u),children:jsx(V,{icon:"DELETE_MARK_BUTTON_02"})})]},g))})})]})},k=Yo;var oe=({fieldsSelect:o,argumentsValues:e,onChangeArguments:a,sql:n,setSql:i,setFilterRule:l})=>{let p=mo.default||mo,[m,f]=useState(),{setValue:t}=useFormContext(),[s,c]=useState(1),[d,u]=useState(),g=r=>{d.session.insert(s,` ${r} `);},w=r=>{a([...e||[],r]);},P=r=>{a(e?.filter(R=>R!==r));},D=r=>{i(r),l(r),t("groups",void 0);},S=m?o.filter(r=>r.id.toString().toLocaleLowerCase().includes(m)||r.description.toString().toLocaleLowerCase().includes(m)||r.name?.toString().toLocaleLowerCase().includes(m)):o;return jsxs(B,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(oo,{children:[jsx(Jo,{value:m,trigger:"change",onSearch:r=>f(r?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(k,{label:"Campos",fields:!0,itens:S.map(r=>r.name),insertItemSQL:g}),jsx(k,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:w,removeItem:P,insertItemSQL:g}),jsx(k,{label:"Operadores",insertItemSQL:g,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(k,{label:"Filtros",fields:!0,insertItemSQL:g,itens:S.map(r=>r.name)})]}),jsx(to,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(p,{width:"100%",mode:"sql",theme:"chrome",name:"rule",fontSize:14,onChange:D,onCursorChange:r=>c(r.getCursor()),value:n,onLoad:r=>u(r),showPrintMargin:!1,showGutter:!1,highlightActiveLine:!1,setOptions:{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:!1,tabSize:2}})]})})]})},co=oe;var re=({data:o,fields:e,isLoading:a,isError:n})=>jsxs(B,{children:[jsx(po,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),n&&jsx(B,{children:"Falha ao gerar resultado"}),o&&jsx(B,{height:400,children:jsx(te,{columns:e?.map(i=>({field:i,headerName:i,width:150,type:"string"})),loading:a,rows:o,disableRowSelectionOnClick:!0,disableColumnMenu:!0,disableColumnResize:!0,showColumnVerticalBorder:!0,hideFooter:!0})})]}),uo=re;var go=styled(B)(({theme:o})=>({border:`1px solid ${alpha(o.palette.primary.main,.32)}`,backgroundColor:alpha(o.palette.primary.main,.08),borderRadius:8,padding:8,paddingLeft:24,alignItems:"center"})),vo=styled(Po)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),O=styled(F)(()=>({width:230}));var de=({index:o,indexGroup:e,removeConditional:a,fieldsSelect:n})=>{let{watch:i}=useFormContext(),l=`groups.[${e}].conditionals[${o}].field`,p=`groups.[${e}].conditionals[${o}].conditional`,m=`groups.[${e}].conditionals[${o}].type`,f=`groups.[${e}].conditionals[${o}].value`,t=[{value:"=",label:"Igual a"},{value:">",label:"Maior que"},{value:"<",label:"Menor que"},{value:"<=",label:"Menor ou igual a"},{value:">=",label:"Maior ou igual a"},{value:"!=",label:"Diferente de"},{value:"IS NULL",label:"Est\xE1 vazio"},{value:"IN",label:"Contido em"},{value:"LIKE",label:"Contendo"},{value:"NOT IN",label:"N\xE3o contido em"},{value:"NOT LIKE",label:"N\xE3o cont\xE9m"},{value:"IS NOT NULL",label:"N\xE3o est\xE1 vazio"}],s=i(m);return jsxs(B,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx(F,{label:"Se",name:l,size:"small",fullWidth:!0,options:n?.map(c=>({value:c.name,label:c.description}))}),jsx(F,{label:"Estado",name:p,size:"small",fullWidth:!0,options:t}),jsx(F,{label:"Objetivo",name:`groups.[${e}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),s==="value"?jsx(ce,{label:"Valor",name:f,size:"small",fullWidth:!0}):jsx(F,{label:"Se",name:f,size:"small",fullWidth:!0,options:n?.map(c=>({value:c.name,label:c.description}))}),jsx(vo,{color:"error",onClick:()=>{a(o);},children:jsx(V,{icon:"DELETE_MARK_BUTTON_02"})})]})},ho=de;var Ie=({index:o,removeGroup:e,fieldsSelect:a})=>{let{control:n}=useFormContext(),i=`groups.[${o}].operator`,{fields:l,append:p,remove:m}=useFieldArray({name:`groups.${o}.conditionals`,control:n});return jsx(Ce,{name:`GRUPO ${o+1}`,description:"EXIBIR A LISTAGEM QUANDO ATENDER UMA DAS CONDI\xC7\xD5ES",header:jsx(O,{name:i,size:"small",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]}),onDelete:()=>e(o),children:jsxs(B,{spacing:1.5,alignItems:"flex-start",children:[l.map((f,t)=>jsx(ho,{index:t,indexGroup:o,removeConditional:s=>m(s),fieldsSelect:a},f.id)),jsx(he,{actionType:"NEW",onClick:()=>p({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},Co=Ie;var Ee=({fieldsSelect:o})=>{let{control:e}=useFormContext(),{fields:a,append:n,remove:i}=useFieldArray({name:"groups",control:e});return jsxs(B,{gap:1.5,children:[jsxs(go,{direction:"row",spacing:1.5,children:[jsx(po,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(B,{children:jsx(O,{size:"small",name:"operator",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]})}),jsxs(po,{variant:"body2",color:"text.light.primary",children:["regra de ",jsx("strong",{children:"todos os grupos"})," \u201CSe\u201D forem cumpridas,"," ",jsx("strong",{children:"ir\xE1 exibir a listagem."})]})]}),a.map((l,p)=>jsx(Co,{index:p,removeGroup:m=>i(m),fieldsSelect:o},l.id)),jsx(ro,{size:"large",color:"inherit",startIcon:jsx(V,{icon:"SIMPLE_ADD"}),variant:"outlined",fullWidth:!0,onClick:()=>{n({operator:"or",conditionals:[{field:"",conditional:"=",type:"value",value:""}]});},children:"Adicionar grupo"})]})},So=Ee;var yo=styled(B)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,marginTop:24})),xo=styled(B)(()=>({padding:12,borderBottom:"1px solid #e0e0e0"})),J=styled(we)(()=>({lineHeight:"1em"})),Ao=styled(B)(()=>({padding:12}));var ze=({argumentsValues:o,onChangeArguments:e,fieldsSelect:a$1,onChangeRule:n,onChangeSqlProcessed:i,defaultMode:l,defaultFilter:p,dataPreview:m,errorPreview:f,loadingPreview:t})=>{let[s,c]=useState(p||""),[d,u]=Me(),[g,w]=useState(l||"simple"),{watch:P,setValue:D}=useFormContext(),S=Ko(),r=P("operator"),R=P("groups");useEffect(()=>()=>{D("config",{});},[]);let wo=(C,x)=>{if(x==="advanced"){let U=a(R,r);c(U),i(U),n(U);}w(x);},To=C=>{let x=a(R,r);c(x),i(x),n(x),d||g==="simple"||o.length===0?u():S.onOpen(C);},ko=C=>{u(),i(C);};return jsx(Fragment,{children:jsxs(yo,{children:[jsxs(xo,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(Re,{color:"primary",value:g,size:"small",exclusive:!0,onChange:wo,children:[jsx(J,{value:"simple",size:"small",children:"Modo simplificado"}),jsx(J,{value:"advanced",size:"small",children:"Modo avan\xE7ado"})]}),jsx(ro,{variant:"outlined",color:"inherit",onClick:C=>To(C),startIcon:!d&&jsx(V,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:d?"Voltar":"Executar"}),!!S.open&&jsx(io,{handleClose:S.onClose,openPopover:S.open,argumentsValues:o,filter:s,onExecute:C=>ko(C)})]}),jsx(Ao,{children:d?jsx(uo,{fields:a$1.map(C=>C.name),data:m,isError:f,isLoading:t}):jsx(Fragment,{children:g==="simple"?jsx(So,{fieldsSelect:a$1,sql:s,setSql:c}):jsx(co,{fieldsSelect:a$1,argumentsValues:o,onChangeArguments:e,sql:s,setSql:c,setFilterRule:n})})})]})})},Rr=ze;
30
+ var N=styled(B)(({theme:o})=>({borderBottom:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderTop:`1px solid ${alpha(o.palette.grey[500],.32)}`,padding:16})),oo=styled(B)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,padding:12,"& .MuiInputBase-root":{background:o.palette.grey[100]}})),eo=styled(B)(({theme:o})=>({display:"flex",textAlign:"center",flexDirection:"row",alignItems:"center",width:"100%",gap:8,height:34,backgroundColor:"#fff",padding:"8px 16px",borderRadius:8,border:`1px solid ${alpha(o.palette.grey[500],.24)}`,cursor:"pointer",color:o.palette.text.disabled,"&:hover, &:focus":{border:`1px solid ${o.palette.primary.main}`,backgroundColor:alpha(o.palette.primary.main,.05)}})),to=styled(B)(({theme:o})=>({width:"100%","& fieldset":{border:`1px solid ${alpha(o.palette.grey[500],.24)}`,borderRadius:8,"& legend":{color:o.palette.text.disabled,fontSize:12}}})),q=styled(Po)({padding:0});var Fo=({openPopover:o,handleClose:e,argumentsValues:a,filter:n,onExecute:i})=>{let[l,p]=useState([]),m=(t,s)=>{if(s&&s!=="")l.filter(d=>d.name===t).length>0?p(l.map(d=>d.name===t?{name:t,value:s}:d)):p([...l||[],{name:t,value:s}]);else {let c=l.filter(d=>d.name===t);p(c);}},g=()=>{let t=n||"";return l.forEach(s=>{t=t.replace(`$ARG[${s.name}]`,`'${s.value}'`);}),t};return jsxs(Bo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,title:"Pr\xE9-visualizar",children:[jsx(po,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(N,{children:a?.map((t,s)=>jsx(Mo,{name:t,label:t,size:"small",onChange:c=>m(t,c.target.value),required:!0},s))}),jsxs(B,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(ro,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(ro,{variant:"contained",color:"primary",size:"small",startIcon:jsx(V,{icon:"PLAY_SIMPLE"}),onClick:()=>i(g()),disabled:l.length<a.length,children:"Executar"})]})]})},io=Fo;var Ho=({openPopover:o,handleClose:e,addItem:a})=>{let[n,i]=useState("");return jsxs(Bo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,sx:{maxWidth:464},title:"Novo Argumento",children:[jsx(po,{variant:"subtitle1",color:"text.primary",p:1,children:"Novo Argumento"}),jsx(N,{children:jsx(Mo,{value:n,onChange:p=>i(p.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(B,{p:1,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(ro,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(ro,{variant:"contained",color:"primary",size:"small",startIcon:jsx(V,{icon:"SAVE_MARK"}),disabled:!n||n==="",onClick:()=>{a(n),e(),i("");},children:"Salvar"})]})]})},so=Ho;var Yo=({label:o,itens:e,argumentsValues:a,fields:n,addItem:i,removeItem:l,insertItemSQL:p})=>{let[m,g]=useState(!1),t=Ko(),s=()=>{g(!m);},c=(u,f)=>{u.stopPropagation(),l&&l(f);},d=u=>{p(a?` $ARG[${u}]`:n?` this.${u}`:` ${u}`);};return jsxs(B,{children:[jsxs(B,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(q,{edge:"end",onClick:s,children:jsx(V,{icon:m?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(po,{variant:"overline",color:"text.primary",children:o}),i&&jsxs(Fragment,{children:[jsx(q,{edge:"end",onClick:t.onOpen,children:jsx(V,{icon:"SIMPLE_ADD"})}),jsx(so,{addItem:i,handleClose:t.onClose,openPopover:t.open})]})]}),m&&jsx(B,{spacing:.5,children:jsx(Wo,{sx:{maxHeight:150},children:e?.map((u,f)=>jsxs(eo,{direction:"row",justifyContent:"space-between",onClick:()=>d(u),children:[jsx(po,{variant:"caption",textAlign:"center",width:"100%",children:u}),l&&jsx(Po,{edge:"end",onClick:L=>c(L,u),children:jsx(V,{icon:"DELETE_MARK_BUTTON_02"})})]},f))})})]})},T=Yo;var oe=({fieldsSelect:o,argumentsValues:e,onChangeArguments:a,sql:n,setSql:i,setFilterRule:l})=>{let p=mo.default||mo,[m,g]=useState(),{setValue:t}=useFormContext(),[s,c]=useState(1),[d,u]=useState(),f=r=>{d.session.insert(s,` ${r} `);},L=r=>{a([...e||[],r]);},k=r=>{a(e?.filter(P=>P!==r));},D=r=>{i(r),l(r),t("groups",void 0);},S=m?o.filter(r=>r.id.toString().toLocaleLowerCase().includes(m)||r.description.toString().toLocaleLowerCase().includes(m)||r.name?.toString().toLocaleLowerCase().includes(m)):o;return jsxs(B,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(oo,{children:[jsx(Jo,{value:m,trigger:"change",onSearch:r=>g(r?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(T,{label:"Campos",fields:!0,itens:S.map(r=>r.name),insertItemSQL:f}),jsx(T,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:L,removeItem:k,insertItemSQL:f}),jsx(T,{label:"Operadores",insertItemSQL:f,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(T,{label:"Filtros",fields:!0,insertItemSQL:f,itens:S.map(r=>r.name)})]}),jsx(to,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(p,{width:"100%",mode:"sql",theme:"chrome",name:"rule",fontSize:14,onChange:D,onCursorChange:r=>c(r.getCursor()),value:n,onLoad:r=>u(r),showPrintMargin:!1,showGutter:!1,highlightActiveLine:!1,setOptions:{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:!1,tabSize:2}})]})})]})},co=oe;var re=({data:o,fields:e,isLoading:a,isError:n})=>jsxs(B,{height:424,gap:2,children:[jsx(po,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),n&&jsx(B,{children:"Falha ao gerar resultado"}),o&&jsx(B,{children:jsx(te,{columns:e?.map(i=>({field:i,headerName:i,width:150,type:"string"})),loading:a,rows:o,disableRowSelectionOnClick:!0,disableColumnMenu:!0,disableColumnResize:!0,showColumnVerticalBorder:!0,hideFooter:!0})})]}),uo=re;var fo=styled(B)(({theme:o})=>({border:`1px solid ${alpha(o.palette.primary.main,.32)}`,backgroundColor:alpha(o.palette.primary.main,.08),borderRadius:8,padding:8,paddingLeft:24,alignItems:"center"})),vo=styled(Po)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),O=styled(F)(()=>({width:230}));var de=({index:o,indexGroup:e,removeConditional:a,fieldsSelect:n})=>{let{watch:i}=useFormContext(),l=`groups.[${e}].conditionals[${o}].field`,p=`groups.[${e}].conditionals[${o}].conditional`,m=`groups.[${e}].conditionals[${o}].type`,g=`groups.[${e}].conditionals[${o}].value`,t=[{value:"=",label:"Igual a"},{value:">",label:"Maior que"},{value:"<",label:"Menor que"},{value:"<=",label:"Menor ou igual a"},{value:">=",label:"Maior ou igual a"},{value:"!=",label:"Diferente de"},{value:"IS NULL",label:"Est\xE1 vazio"},{value:"IN",label:"Contido em"},{value:"LIKE",label:"Contendo"},{value:"NOT IN",label:"N\xE3o contido em"},{value:"NOT LIKE",label:"N\xE3o cont\xE9m"},{value:"IS NOT NULL",label:"N\xE3o est\xE1 vazio"}],s=i(m);return jsxs(B,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx(F,{label:"Se",name:l,size:"small",fullWidth:!0,options:n?.map(c=>({value:c.name,label:c.description}))}),jsx(F,{label:"Estado",name:p,size:"small",fullWidth:!0,options:t}),jsx(F,{label:"Objetivo",name:`groups.[${e}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),s==="value"?jsx(ce,{label:"Valor",name:g,size:"small",fullWidth:!0}):jsx(F,{label:"Se",name:g,size:"small",fullWidth:!0,options:n?.map(c=>({value:c.name,label:c.description}))}),jsx(vo,{color:"error",onClick:()=>{a(o);},children:jsx(V,{icon:"DELETE_MARK_BUTTON_02"})})]})},ho=de;var Ie=({index:o,removeGroup:e,fieldsSelect:a})=>{let{control:n}=useFormContext(),i=`groups.[${o}].operator`,{fields:l,append:p,remove:m}=useFieldArray({name:`groups.${o}.conditionals`,control:n});return jsx(Ce,{name:`GRUPO ${o+1}`,description:"EXIBIR A LISTAGEM QUANDO ATENDER UMA DAS CONDI\xC7\xD5ES",header:jsx(O,{name:i,size:"small",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]}),onDelete:()=>e(o),children:jsxs(B,{spacing:1.5,alignItems:"flex-start",children:[l.map((g,t)=>jsx(ho,{index:t,indexGroup:o,removeConditional:s=>m(s),fieldsSelect:a},g.id)),jsx(he,{actionType:"NEW",onClick:()=>p({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},Co=Ie;var Ee=({fieldsSelect:o})=>{let{control:e}=useFormContext(),{fields:a,append:n,remove:i}=useFieldArray({name:"groups",control:e});return jsxs(B,{gap:1.5,children:[jsxs(fo,{direction:"row",spacing:1.5,children:[jsx(po,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(B,{children:jsx(O,{size:"small",name:"operator",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]})}),jsxs(po,{variant:"body2",color:"text.light.primary",children:["regra de ",jsx("strong",{children:"todos os grupos"})," \u201CSe\u201D forem cumpridas,"," ",jsx("strong",{children:"ir\xE1 exibir a listagem."})]})]}),a.map((l,p)=>jsx(Co,{index:p,removeGroup:m=>i(m),fieldsSelect:o},l.id)),jsx(ro,{size:"large",color:"inherit",startIcon:jsx(V,{icon:"SIMPLE_ADD"}),variant:"outlined",fullWidth:!0,onClick:()=>{n({operator:"or",conditionals:[{field:"",conditional:"=",type:"value",value:""}]});},children:"Adicionar grupo"})]})},So=Ee;var yo=styled(B)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,marginTop:24})),xo=styled(B)(()=>({padding:12,borderBottom:"1px solid #e0e0e0"})),J=styled(we)(()=>({lineHeight:"1em"})),Ao=styled(B)(()=>({padding:12}));var ze=({argumentsValues:o,onChangeArguments:e,fieldsSelect:a$1,onChangeRule:n,onChangeSqlProcessed:i,defaultMode:l,defaultFilter:p,dataPreview:m,errorPreview:g,loadingPreview:t})=>{let[s,c]=useState(p||""),[d,u]=Me(),[f,L]=useState(l||"simple"),{watch:k,setValue:D}=useFormContext(),S=Ko(),r=k("operator"),P=k("groups");useEffect(()=>()=>{D("config",{});},[]);let wo=(C,R)=>{if(R==="advanced"){let U=a(P,r);c(U),i(U),n(U);}L(R);},To=C=>{let R=a(P,r);i(R),d||f==="simple"||o.length===0?u():S.onOpen(C);},ko=C=>{u(),i(C);};return jsx(Fragment,{children:jsxs(yo,{children:[jsxs(xo,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(Re,{color:"primary",value:f,size:"small",exclusive:!0,onChange:wo,children:[jsx(J,{value:"simple",size:"small",children:"Modo simplificado"}),jsx(J,{value:"advanced",size:"small",children:"Modo avan\xE7ado"})]}),jsx(ro,{variant:"outlined",color:"inherit",onClick:C=>To(C),startIcon:!d&&jsx(V,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:d?"Voltar":"Executar"}),!!S.open&&jsx(io,{handleClose:S.onClose,openPopover:S.open,argumentsValues:o,filter:s,onExecute:C=>ko(C)})]}),jsx(Ao,{children:d?jsx(uo,{fields:a$1.map(C=>C.name),data:m,isError:g,isLoading:t}):jsx(Fragment,{children:f==="simple"?jsx(So,{fieldsSelect:a$1,sql:s,setSql:c}):jsx(co,{fieldsSelect:a$1,argumentsValues:o,onChangeArguments:e,sql:s,setSql:c,setFilterRule:n})})})]})})},Rr=ze;
31
31
 
32
32
  export { Rr as default };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.73",
2
+ "version": "2.0.74",
3
3
  "name": "@zydon/common-csr",
4
4
  "description": "Zydon common resources for React projects (only Client-Side Rendering (CSR))",
5
5
  "license": "MIT",