@zydon/common-csr 2.0.23 → 2.0.24

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.
@@ -13,9 +13,6 @@ import ao from '@mui/material/Typography';
13
13
  import Ro from '@mui/material/IconButton';
14
14
  import { styled, alpha } from '@mui/material/styles';
15
15
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
16
- import 'ace-builds/src-noconflict/mode-mysql';
17
- import 'ace-builds/src-noconflict/theme-github';
18
- import 'ace-builds/src-noconflict/ext-language_tools';
19
16
  import Zo from '@zydon/common/components/SearchInput';
20
17
  import Qo from '@zydon/common/components/Scrollbar';
21
18
  import ee from '@zydon/common/components/DataGrid';
@@ -25,6 +22,6 @@ import N from '@zydon/common/form/Autocomplete';
25
22
  import me from '@zydon/common/form/Field';
26
23
  import Te from '@mui/material/ToggleButton';
27
24
 
28
- var k=styled(R)(({theme:o})=>({borderBottom:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderTop:`1px solid ${alpha(o.palette.grey[500],.32)}`,padding:16})),Z=styled(R)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,padding:12,"& .MuiInputBase-root":{background:o.palette.grey[100]}})),J=styled(R)(({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)}})),j=styled(R)(({theme:o})=>({width:"100%","& fieldset":{border:`1px solid ${alpha(o.palette.grey[500],.24)}`,borderRadius:8,"& legend":{color:o.palette.text.disabled,fontSize:12}}})),G=styled(Ro)({padding:0});var zo=({openPopover:o,handleClose:e,argumentsValues:a,filter:i,onExecute:l})=>{let[s,r]=useState([]),d=(t,p)=>{if(p&&p!=="")s.filter(u=>u.name===t).length>0?r(s.map(u=>u.name===t?{name:t,value:p}:u)):r([...s||[],{name:t,value:p}]);else {let m=s.filter(u=>u.name===t);r(m);}},g=()=>{let t=i||"";return s.forEach(p=>{t=t.replace(`$ARG[${p.name}]`,`'${p.value}'`);}),t};return jsxs(wo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,title:"Pr\xE9-visualizar",children:[jsx(ao,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(k,{children:a?.map((t,p)=>jsx(No,{name:t,label:t,size:"small",onChange:m=>d(t,m.target.value),required:!0},p))}),jsxs(R,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(oo,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(oo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"PLAY_SIMPLE"}),onClick:()=>l(g()),disabled:s.length<a.length,children:"Executar"})]})]})},to=zo;var Ho=({openPopover:o,handleClose:e,addItem:a})=>{let[i,l]=useState("");return jsxs(wo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,sx:{maxWidth:464},title:"Novo Argumento",children:[jsx(ao,{variant:"subtitle1",color:"text.primary",p:1,children:"Novo Argumento"}),jsx(k,{children:jsx(No,{value:i,onChange:r=>l(r.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(R,{p:1,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(oo,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(oo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"SAVE_MARK"}),disabled:!i||i==="",onClick:()=>{a(i),e(),l("");},children:"Salvar"})]})]})},io=Ho;var Ko=({label:o,itens:e,argumentsValues:a,fields:i,addItem:l,removeItem:s,insertItemSQL:r})=>{let[d,g]=useState(!1),t=Wo(),p=()=>{g(!d);},m=(c,C)=>{c.stopPropagation(),s&&s(C);},u=c=>{r(a?` $ARG[${c}]`:i?` this.${c}`:` ${c}`);};return jsxs(R,{children:[jsxs(R,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(G,{edge:"end",onClick:p,children:jsx(U,{icon:d?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(ao,{variant:"overline",color:"text.primary",children:o}),l&&jsxs(Fragment,{children:[jsx(G,{edge:"end",onClick:t.onOpen,children:jsx(U,{icon:"SIMPLE_ADD"})}),jsx(io,{addItem:l,handleClose:t.onClose,openPopover:t.open})]})]}),d&&jsx(R,{spacing:.5,children:jsx(Qo,{sx:{maxHeight:150},children:e?.map((c,C)=>jsxs(J,{direction:"row",justifyContent:"space-between",onClick:()=>u(c),children:[jsx(ao,{variant:"caption",textAlign:"center",width:"100%",children:c}),s&&jsx(Ro,{edge:"end",onClick:A=>m(A,c),children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]},C))})})]})},L=Ko;var jo=({fieldsSelect:o,argumentsValues:e,onChangeArguments:a,sql:i,setSql:l,setFilterRule:s})=>{let [r,d]=useState();useFormContext();let [t,p]=useState(1),[m,u]=useState(),c=n=>{m.session.insert(t,` ${n} `);},C=n=>{a([...e||[],n]);},A=n=>{a(e?.filter(F=>F!==n));},P=r?o.filter(n=>n.id.toString().toLocaleLowerCase().includes(r)||n.description.toString().toLocaleLowerCase().includes(r)||n.name?.toString().toLocaleLowerCase().includes(r)):o;return console.log({"remove ace":i}),jsxs(R,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(Z,{children:[jsx(Zo,{value:r,trigger:"change",onSearch:n=>d(n?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(L,{label:"Campos",fields:!0,itens:P.map(n=>n.name),insertItemSQL:c}),jsx(L,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:C,removeItem:A,insertItemSQL:c}),jsx(L,{label:"Operadores",insertItemSQL:c,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(L,{label:"Filtros",fields:!0,insertItemSQL:c,itens:P.map(n=>n.name)})]}),jsx(j,{children:jsx("fieldset",{children:jsx("legend",{children:"Regras de listagem"})})})]})},so=jo;var te=({data:o,fields:e,isLoading:a,isError:i})=>jsxs(R,{children:[jsx(ao,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),i&&jsx(R,{children:"Falha ao gerar resultado"}),o&&jsx(ee,{columns:e?.map(l=>({field:l,headerName:l,width:150,type:"string"})),loading:a,rows:o,disableRowSelectionOnClick:!0,disableColumnMenu:!0,disableColumnResize:!0,showColumnVerticalBorder:!0,hideFooter:!0})]}),mo=te;var uo=styled(R)(({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"})),go=styled(Ro)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),B=styled(N)(()=>({width:230}));var ce=({index:o,indexGroup:e,removeConditional:a,fieldsSelect:i})=>{let{watch:l}=useFormContext(),s=`groups.[${e}].conditionals[${o}].field`,r=`groups.[${e}].conditionals[${o}].conditional`,d=`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"}],p=l(d);return jsxs(R,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx(N,{label:"Se",name:s,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(N,{label:"Estado",name:r,size:"small",fullWidth:!0,options:t}),jsx(N,{label:"Objetivo",name:`groups.[${e}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),p==="value"?jsx(me,{label:"Valor",name:g,size:"small",fullWidth:!0}):jsx(N,{label:"Se",name:g,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(go,{color:"error",onClick:()=>{a(o);},children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]})},fo=ce;var Ce=({index:o,removeGroup:e,fieldsSelect:a})=>{let{control:i}=useFormContext(),l=`groups.[${o}].operator`,{fields:s,append:r,remove:d}=useFieldArray({name:`groups.${o}.conditionals`,control:i});return jsx(Ie,{name:`GRUPO ${o+1}`,description:"EXIBIR A LISTAGEM QUANDO ATENDER UMA DAS CONDI\xC7\xD5ES",header:jsx(B,{name:l,size:"small",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]}),onDelete:()=>e(o),children:jsxs(R,{spacing:1.5,alignItems:"flex-start",children:[s.map((g,t)=>jsx(fo,{index:t,indexGroup:o,removeConditional:p=>d(p),fieldsSelect:a},g.id)),jsx(ve,{actionType:"NEW",onClick:()=>r({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},vo=Ce;var Ee=({fieldsSelect:o})=>{let{control:e}=useFormContext(),{fields:a,append:i,remove:l}=useFieldArray({name:"groups",control:e});return jsxs(R,{gap:1.5,children:[jsxs(uo,{direction:"row",spacing:1.5,children:[jsx(ao,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(R,{children:jsx(B,{size:"small",name:"operator",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]})}),jsxs(ao,{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((s,r)=>jsx(vo,{index:r,removeGroup:d=>l(d),fieldsSelect:o},s.id)),jsx(oo,{size:"large",color:"inherit",startIcon:jsx(U,{icon:"SIMPLE_ADD"}),variant:"outlined",fullWidth:!0,onClick:()=>{i({operator:"or",conditionals:[{field:"",conditional:"=",type:"value",value:""}]});},children:"Adicionar grupo"})]})},ho=Ee;var bo=styled(R)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,marginTop:24})),So=styled(R)(()=>({padding:12,borderBottom:"1px solid #e0e0e0"})),W=styled(Te)(()=>({lineHeight:"1em"})),yo=styled(R)(()=>({padding:12}));var Me=({argumentsValues:o,onChangeArguments:e,fieldsSelect:a$1,onChangeRule:i,onChangeSqlProcessed:l,defaultMode:s,defaultFilter:r,dataPreview:d,errorPreview:g,loadingPreview:t})=>{let[p,m]=useState(r||""),[u,c]=Ne(),[C,A]=useState(s||"simple"),{watch:z,setValue:P}=useFormContext(),n=Wo(),F=z("operator"),Ao=z("groups");useEffect(()=>()=>{P("config",{});},[]);let To=(I,Y)=>{if(Y==="advanced"){let $=a(Ao,F);m($),l($),i($);}A(Y);},Lo=I=>{u||C==="simple"||o.length===0?c():n.onOpen(I);},Po=I=>{c(),l(I);};return jsx(Fragment,{children:jsxs(bo,{children:[jsxs(So,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(ke,{color:"primary",value:C,size:"small",exclusive:!0,onChange:To,children:[jsx(W,{value:"simple",size:"small",children:"Modo simplificado"}),jsx(W,{value:"advanced",size:"small",children:"Modo avan\xE7ado"})]}),jsx(oo,{variant:"outlined",color:"inherit",onClick:I=>Lo(I),startIcon:!u&&jsx(U,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:u?"Voltar":"Executar"}),!!n.open&&jsx(to,{handleClose:n.onClose,openPopover:n.open,argumentsValues:o,filter:p,onExecute:I=>Po(I)})]}),jsx(yo,{children:u?jsx(mo,{fields:a$1.map(I=>I.name),data:d,isError:g,isLoading:t}):jsx(Fragment,{children:C==="simple"?jsx(ho,{fieldsSelect:a$1,sql:p,setSql:m}):jsx(so,{fieldsSelect:a$1,argumentsValues:o,onChangeArguments:e,sql:p,setSql:m,setFilterRule:i})})})]})})},Lr=Me;
25
+ var k=styled(R)(({theme:o})=>({borderBottom:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderTop:`1px solid ${alpha(o.palette.grey[500],.32)}`,padding:16})),Z=styled(R)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,padding:12,"& .MuiInputBase-root":{background:o.palette.grey[100]}})),J=styled(R)(({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)}})),j=styled(R)(({theme:o})=>({width:"100%","& fieldset":{border:`1px solid ${alpha(o.palette.grey[500],.24)}`,borderRadius:8,"& legend":{color:o.palette.text.disabled,fontSize:12}}})),G=styled(Ro)({padding:0});var zo=({openPopover:o,handleClose:e,argumentsValues:a,filter:i,onExecute:l})=>{let[s,r]=useState([]),d=(t,p)=>{if(p&&p!=="")s.filter(u=>u.name===t).length>0?r(s.map(u=>u.name===t?{name:t,value:p}:u)):r([...s||[],{name:t,value:p}]);else {let m=s.filter(u=>u.name===t);r(m);}},g=()=>{let t=i||"";return s.forEach(p=>{t=t.replace(`$ARG[${p.name}]`,`'${p.value}'`);}),t};return jsxs(wo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,title:"Pr\xE9-visualizar",children:[jsx(ao,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(k,{children:a?.map((t,p)=>jsx(No,{name:t,label:t,size:"small",onChange:m=>d(t,m.target.value),required:!0},p))}),jsxs(R,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(oo,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(oo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"PLAY_SIMPLE"}),onClick:()=>l(g()),disabled:s.length<a.length,children:"Executar"})]})]})},to=zo;var Ho=({openPopover:o,handleClose:e,addItem:a})=>{let[i,l]=useState("");return jsxs(wo,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:e,sx:{maxWidth:464},title:"Novo Argumento",children:[jsx(ao,{variant:"subtitle1",color:"text.primary",p:1,children:"Novo Argumento"}),jsx(k,{children:jsx(No,{value:i,onChange:r=>l(r.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(R,{p:1,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(oo,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(oo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"SAVE_MARK"}),disabled:!i||i==="",onClick:()=>{a(i),e(),l("");},children:"Salvar"})]})]})},io=Ho;var Ko=({label:o,itens:e,argumentsValues:a,fields:i,addItem:l,removeItem:s,insertItemSQL:r})=>{let[d,g]=useState(!1),t=Wo(),p=()=>{g(!d);},m=(c,C)=>{c.stopPropagation(),s&&s(C);},u=c=>{r(a?` $ARG[${c}]`:i?` this.${c}`:` ${c}`);};return jsxs(R,{children:[jsxs(R,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(G,{edge:"end",onClick:p,children:jsx(U,{icon:d?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(ao,{variant:"overline",color:"text.primary",children:o}),l&&jsxs(Fragment,{children:[jsx(G,{edge:"end",onClick:t.onOpen,children:jsx(U,{icon:"SIMPLE_ADD"})}),jsx(io,{addItem:l,handleClose:t.onClose,openPopover:t.open})]})]}),d&&jsx(R,{spacing:.5,children:jsx(Qo,{sx:{maxHeight:150},children:e?.map((c,C)=>jsxs(J,{direction:"row",justifyContent:"space-between",onClick:()=>u(c),children:[jsx(ao,{variant:"caption",textAlign:"center",width:"100%",children:c}),s&&jsx(Ro,{edge:"end",onClick:A=>m(A,c),children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]},C))})})]})},L=Ko;var jo=({fieldsSelect:o,argumentsValues:e,onChangeArguments:a,sql:i,setSql:l,setFilterRule:s})=>{let [r,d]=useState();useFormContext();let [t,p]=useState(1),[m,u]=useState(),c=n=>{m.session.insert(t,` ${n} `);},C=n=>{a([...e||[],n]);},A=n=>{a(e?.filter(F=>F!==n));},P=r?o.filter(n=>n.id.toString().toLocaleLowerCase().includes(r)||n.description.toString().toLocaleLowerCase().includes(r)||n.name?.toString().toLocaleLowerCase().includes(r)):o;return console.log({"remove ace":i}),jsxs(R,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(Z,{children:[jsx(Zo,{value:r,trigger:"change",onSearch:n=>d(n?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(L,{label:"Campos",fields:!0,itens:P.map(n=>n.name),insertItemSQL:c}),jsx(L,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:C,removeItem:A,insertItemSQL:c}),jsx(L,{label:"Operadores",insertItemSQL:c,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(L,{label:"Filtros",fields:!0,insertItemSQL:c,itens:P.map(n=>n.name)})]}),jsx(j,{children:jsx("fieldset",{children:jsx("legend",{children:"Regras de listagem"})})})]})},so=jo;var te=({data:o,fields:e,isLoading:a,isError:i})=>jsxs(R,{children:[jsx(ao,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),i&&jsx(R,{children:"Falha ao gerar resultado"}),o&&jsx(ee,{columns:e?.map(l=>({field:l,headerName:l,width:150,type:"string"})),loading:a,rows:o,disableRowSelectionOnClick:!0,disableColumnMenu:!0,disableColumnResize:!0,showColumnVerticalBorder:!0,hideFooter:!0})]}),mo=te;var uo=styled(R)(({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"})),go=styled(Ro)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),B=styled(N)(()=>({width:230}));var ce=({index:o,indexGroup:e,removeConditional:a,fieldsSelect:i})=>{let{watch:l}=useFormContext(),s=`groups.[${e}].conditionals[${o}].field`,r=`groups.[${e}].conditionals[${o}].conditional`,d=`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"}],p=l(d);return jsxs(R,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx(N,{label:"Se",name:s,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(N,{label:"Estado",name:r,size:"small",fullWidth:!0,options:t}),jsx(N,{label:"Objetivo",name:`groups.[${e}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),p==="value"?jsx(me,{label:"Valor",name:g,size:"small",fullWidth:!0}):jsx(N,{label:"Se",name:g,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(go,{color:"error",onClick:()=>{a(o);},children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]})},fo=ce;var Ce=({index:o,removeGroup:e,fieldsSelect:a})=>{let{control:i}=useFormContext(),l=`groups.[${o}].operator`,{fields:s,append:r,remove:d}=useFieldArray({name:`groups.${o}.conditionals`,control:i});return jsx(Ie,{name:`GRUPO ${o+1}`,description:"EXIBIR A LISTAGEM QUANDO ATENDER UMA DAS CONDI\xC7\xD5ES",header:jsx(B,{name:l,size:"small",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]}),onDelete:()=>e(o),children:jsxs(R,{spacing:1.5,alignItems:"flex-start",children:[s.map((g,t)=>jsx(fo,{index:t,indexGroup:o,removeConditional:p=>d(p),fieldsSelect:a},g.id)),jsx(ve,{actionType:"NEW",onClick:()=>r({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},vo=Ce;var Ee=({fieldsSelect:o})=>{let{control:e}=useFormContext(),{fields:a,append:i,remove:l}=useFieldArray({name:"groups",control:e});return jsxs(R,{gap:1.5,children:[jsxs(uo,{direction:"row",spacing:1.5,children:[jsx(ao,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(R,{children:jsx(B,{size:"small",name:"operator",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]})}),jsxs(ao,{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((s,r)=>jsx(vo,{index:r,removeGroup:d=>l(d),fieldsSelect:o},s.id)),jsx(oo,{size:"large",color:"inherit",startIcon:jsx(U,{icon:"SIMPLE_ADD"}),variant:"outlined",fullWidth:!0,onClick:()=>{i({operator:"or",conditionals:[{field:"",conditional:"=",type:"value",value:""}]});},children:"Adicionar grupo"})]})},ho=Ee;var bo=styled(R)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,marginTop:24})),So=styled(R)(()=>({padding:12,borderBottom:"1px solid #e0e0e0"})),W=styled(Te)(()=>({lineHeight:"1em"})),yo=styled(R)(()=>({padding:12}));var Me=({argumentsValues:o,onChangeArguments:e,fieldsSelect:a$1,onChangeRule:i,onChangeSqlProcessed:l,defaultMode:s,defaultFilter:r,dataPreview:d,errorPreview:g,loadingPreview:t})=>{let[p,m]=useState(r||""),[u,c]=Ne(),[C,A]=useState(s||"simple"),{watch:z,setValue:P}=useFormContext(),n=Wo(),F=z("operator"),Ao=z("groups");useEffect(()=>()=>{P("config",{});},[]);let To=(I,Y)=>{if(Y==="advanced"){let $=a(Ao,F);m($),l($),i($);}A(Y);},Lo=I=>{u||C==="simple"||o.length===0?c():n.onOpen(I);},Po=I=>{c(),l(I);};return jsx(Fragment,{children:jsxs(bo,{children:[jsxs(So,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(ke,{color:"primary",value:C,size:"small",exclusive:!0,onChange:To,children:[jsx(W,{value:"simple",size:"small",children:"Modo simplificado"}),jsx(W,{value:"advanced",size:"small",children:"Modo avan\xE7ado"})]}),jsx(oo,{variant:"outlined",color:"inherit",onClick:I=>Lo(I),startIcon:!u&&jsx(U,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:u?"Voltar":"Executar"}),!!n.open&&jsx(to,{handleClose:n.onClose,openPopover:n.open,argumentsValues:o,filter:p,onExecute:I=>Po(I)})]}),jsx(yo,{children:u?jsx(mo,{fields:a$1.map(I=>I.name),data:d,isError:g,isLoading:t}):jsx(Fragment,{children:C==="simple"?jsx(ho,{fieldsSelect:a$1,sql:p,setSql:m}):jsx(so,{fieldsSelect:a$1,argumentsValues:o,onChangeArguments:e,sql:p,setSql:m,setFilterRule:i})})})]})})},Er=Me;
29
26
 
30
- export { Lr as default };
27
+ export { Er as default };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.23",
2
+ "version": "2.0.24",
3
3
  "name": "@zydon/common-csr",
4
4
  "description": "Zydon common resources for React projects (only Client-Side Rendering (CSR))",
5
5
  "license": "MIT",