@zydon/common-csr 2.0.85 → 2.0.86

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.
@@ -1,16 +1,16 @@
1
1
  import { a } from '../../../chunk-75QNIQAU.mjs';
2
- import { useState, useEffect } from 'react';
2
+ import { useState } from 'react';
3
3
  import { useFormContext, useFieldArray } from 'react-hook-form';
4
4
  import ro from '@mui/material/Button';
5
- import Re from '@mui/material/ToggleButtonGroup';
5
+ import ke from '@mui/material/ToggleButtonGroup';
6
6
  import q from '@zydon/common/components/Icon';
7
- import Ko from '@zydon/common/hooks/usePopover';
8
- import Me from '@zydon/common/hooks/useToggle';
9
- import Bo from '@mui/material/Popover';
7
+ import Wo from '@zydon/common/hooks/usePopover';
8
+ import Be from '@zydon/common/hooks/useToggle';
9
+ import Ro from '@mui/material/Popover';
10
10
  import B from '@mui/material/Stack';
11
- import Mo from '@mui/material/TextField';
11
+ import No from '@mui/material/TextField';
12
12
  import po from '@mui/material/Typography';
13
- import Po from '@mui/material/IconButton';
13
+ import ko from '@mui/material/IconButton';
14
14
  import { styled, alpha } from '@mui/material/styles';
15
15
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
16
16
  import 'ace-builds/src-noconflict/ace';
@@ -18,15 +18,15 @@ import 'ace-builds/src-noconflict/ext-language_tools';
18
18
  import 'ace-builds/src-noconflict/mode-sql';
19
19
  import 'ace-builds/src-noconflict/theme-chrome';
20
20
  import mo from 'react-ace';
21
- import Jo from '@zydon/common/components/SearchInput';
22
- import Wo from '@zydon/common/components/Scrollbar';
23
- import te from '@zydon/common/components/DataGrid';
24
- import Ce from '@zydon/common/components/ActionButton';
25
- import he from '@zydon/common/components/ExpandableGroup';
21
+ import Zo from '@zydon/common/components/SearchInput';
22
+ import Qo from '@zydon/common/components/Scrollbar';
23
+ import ee from '@zydon/common/components/DataGrid';
24
+ import ve from '@zydon/common/components/ActionButton';
25
+ import Ce from '@zydon/common/components/ExpandableGroup';
26
26
  import $ from '@zydon/common/form/Autocomplete';
27
- import ce from '@zydon/common/form/Field';
28
- import we from '@mui/material/ToggleButton';
27
+ import me from '@zydon/common/form/Field';
28
+ import Le 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}}})),V=styled(Po)({padding:0});var $o=({openPopover:o,handleClose:e,argumentsValues:l,filter:i,onExecute:a})=>{let[p,c]=useState([]),m=(n,r)=>{if(r&&r!=="")p.filter(u=>u.name===n).length>0?c(p.map(u=>u.name===n?{name:n,value:r}:u)):c([...p||[],{name:n,value:r}]);else {let d=p.filter(u=>u.name===n);c(d);}},f=()=>{let n=i||"";return p.forEach(r=>{n=n.replace(`$ARG[${r.name}]`,`'${r.value}'`);}),n};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:l?.map((n,r)=>jsx(Mo,{name:n,label:n,size:"small",onChange:d=>m(n,d.target.value),required:!0},r))}),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(q,{icon:"PLAY_SIMPLE"}),onClick:()=>a(f()),disabled:p.length<l.length,children:"Executar"})]})]})},io=$o;var Ho=({openPopover:o,handleClose:e,addItem:l})=>{let[i,a]=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:i,onChange:c=>a(c.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(q,{icon:"SAVE_MARK"}),disabled:!i||i==="",onClick:()=>{l(i),e(),a("");},children:"Salvar"})]})]})},so=Ho;var Yo=({label:o,itens:e,argumentsValues:l,fields:i,context:a,addItem:p,removeItem:c,insertItemSQL:m})=>{let[f,n]=useState(!1),r=Ko(),d=()=>{n(!f);},u=(s,S)=>{s.stopPropagation(),c&&c(S);},b=s=>{m(l?` $ARG[${s}]`:i?` this.${s}`:a?` $ctx[${s}]`:` ${s}`);};return jsxs(B,{children:[jsxs(B,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(V,{edge:"end",onClick:d,children:jsx(q,{icon:f?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(po,{variant:"overline",color:"text.primary",children:o}),p&&jsxs(Fragment,{children:[jsx(V,{edge:"end",onClick:r.onOpen,children:jsx(q,{icon:"SIMPLE_ADD"})}),jsx(so,{addItem:p,handleClose:r.onClose,openPopover:r.open})]})]}),f&&jsx(B,{spacing:.5,children:jsx(Wo,{sx:{maxHeight:150},children:e?.map((s,S)=>jsxs(eo,{direction:"row",justifyContent:"space-between",onClick:()=>b(s),children:[jsx(po,{variant:"caption",textAlign:"center",width:"100%",children:s}),c&&jsx(Po,{edge:"end",onClick:A=>u(A,s),children:jsx(q,{icon:"DELETE_MARK_BUTTON_02"})})]},S))})})]})},T=Yo;var oe=({fieldsSelect:o,argumentsValues:e,onChangeArguments:l,sql:i,setSql:a,setFilterRule:p})=>{let c=mo.default||mo,[m,f]=useState(),{setValue:n}=useFormContext(),[r,d]=useState(1),[u,b]=useState(),s=t=>{u.session.insert(r,` ${t} `);},S=t=>{l([...e||[],t]);},A=t=>{l(e?.filter(P=>P!==t));},D=t=>{a(t),p(t),n("groups",void 0);},y=m?o.filter(t=>t.id.toString().toLocaleLowerCase().includes(m)||t.description.toString().toLocaleLowerCase().includes(m)||t.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:t=>f(t?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(T,{label:"Campos",fields:!0,itens:y.map(t=>t.name),insertItemSQL:s}),jsx(T,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:S,removeItem:A,insertItemSQL:s}),jsx(T,{label:"Operadores",insertItemSQL:s,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(T,{label:"Filtros",fields:!0,insertItemSQL:s,itens:y.map(t=>t.name)}),jsx(T,{label:"Contexto",context:!0,insertItemSQL:s,itens:["Vendedor.CODIGO","Empresa.CODIGO","Parceiro.CODIGO"]})]}),jsx(to,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(c,{width:"100%",mode:"sql",theme:"chrome",name:"rule",fontSize:14,onChange:D,onCursorChange:t=>d(t.getCursor()),value:i,onLoad:t=>b(t),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:l,isError:i})=>jsxs(B,{gap:2,children:[jsx(po,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),i&&jsx(B,{children:"Falha ao gerar resultado"}),o&&jsx(B,{height:400,children:jsx(te,{columns:e?.map(a=>({field:a,headerName:a,width:150,type:"string",resizable:!0})),loading:l,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"}})),z=styled($)(()=>({width:230}));var de=({index:o,indexGroup:e,removeConditional:l,fieldsSelect:i})=>{let{watch:a}=useFormContext(),p=`groups.[${e}].conditionals[${o}].field`,c=`groups.[${e}].conditionals[${o}].conditional`,m=`groups.[${e}].conditionals[${o}].type`,f=`groups.[${e}].conditionals[${o}].value`,n=[{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"}],r=a(m);return jsxs(B,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx($,{label:"Se",name:p,size:"small",fullWidth:!0,options:i?.map(d=>({value:d.name,label:d.description}))}),jsx($,{label:"Estado",name:c,size:"small",fullWidth:!0,options:n}),jsx($,{label:"Objetivo",name:`groups.[${e}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),r==="value"?jsx(ce,{label:"Valor",name:f,size:"small",fullWidth:!0}):jsx($,{label:"Se",name:f,size:"small",fullWidth:!0,options:i?.map(d=>({value:d.name,label:d.description}))}),jsx(vo,{color:"error",onClick:()=>{l(o);},children:jsx(q,{icon:"DELETE_MARK_BUTTON_02"})})]})},Co=de;var Ie=({index:o,removeGroup:e,fieldsSelect:l})=>{let{control:i}=useFormContext(),a=`groups.[${o}].operator`,{fields:p,append:c,remove:m}=useFieldArray({name:`groups.${o}.conditionals`,control:i});return jsx(he,{name:`GRUPO ${o+1}`,description:"EXIBIR A LISTAGEM QUANDO ATENDER UMA DAS CONDI\xC7\xD5ES",header:jsx(z,{name:a,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:[p.map((f,n)=>jsx(Co,{index:n,indexGroup:o,removeConditional:r=>m(r),fieldsSelect:l},f.id)),jsx(Ce,{actionType:"NEW",onClick:()=>c({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},ho=Ie;var Ee=({fieldsSelect:o})=>{let{control:e}=useFormContext(),{fields:l,append:i,remove:a}=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(z,{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."})]})]}),l.map((p,c)=>jsx(ho,{index:c,removeGroup:m=>a(m),fieldsSelect:o},p.id)),jsx(ro,{size:"large",color:"inherit",startIcon:jsx(q,{icon:"SIMPLE_ADD"}),variant:"outlined",fullWidth:!0,onClick:()=>{i({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 Oe=({argumentsValues:o,onChangeArguments:e,fieldsSelect:l,onChangeRule:i,onChangeSqlProcessed:a$1,defaultMode:p,defaultFilter:c,dataPreview:m,errorPreview:f,loadingPreview:n})=>{let[r,d]=useState(c||""),[u,b]=Me(),[s,S]=useState(p||"simple"),{watch:A,setValue:D}=useFormContext(),y=Ko(),t=A("operator"),P=A("groups");useEffect(()=>()=>{D("config",{});},[]);let wo=(C,R)=>{if(R==="advanced"){let U=a(P,t);d(U),a$1(U),i(U);}S(R);},To=C=>{if(s==="simple"){let R=a(P,t);a$1(R);}else a$1(r);u||s==="simple"||o.length===0?b():y.onOpen(C);},ko=C=>{b(),a$1(C);};return jsx(Fragment,{children:jsxs(yo,{children:[jsxs(xo,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(Re,{color:"primary",value:s,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:!u&&jsx(q,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:u?"Voltar":"Executar"}),!!y.open&&jsx(io,{handleClose:y.onClose,openPopover:y.open,argumentsValues:o,filter:r,onExecute:C=>ko(C)})]}),jsx(Ao,{children:u?jsx(uo,{fields:l.map(C=>C.name),data:m,isError:f,isLoading:n}):jsx(Fragment,{children:s==="simple"?jsx(So,{fieldsSelect:l,sql:r,setSql:d}):jsx(co,{fieldsSelect:l,argumentsValues:o,onChangeArguments:e,sql:r,setSql:d,setFilterRule:i})})})]})})},Rr=Oe;
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}}})),H=styled(ko)({padding:0});var zo=({openPopover:o,handleClose:e,argumentsValues:l,filter:i,onExecute:a})=>{let[p,c]=useState([]),m=(n,r)=>{if(r&&r!=="")p.filter(u=>u.name===n).length>0?c(p.map(u=>u.name===n?{name:n,value:r}:u)):c([...p||[],{name:n,value:r}]);else {let d=p.filter(u=>u.name===n);c(d);}},f=()=>{let n=i||"";return p.forEach(r=>{n=n.replace(`$ARG[${r.name}]`,`'${r.value}'`);}),n};return jsxs(Ro,{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:l?.map((n,r)=>jsx(No,{name:n,label:n,size:"small",onChange:d=>m(n,d.target.value),required:!0},r))}),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(q,{icon:"PLAY_SIMPLE"}),onClick:()=>a(f()),disabled:p.length<l.length,children:"Executar"})]})]})},io=zo;var Ho=({openPopover:o,handleClose:e,addItem:l})=>{let[i,a]=useState("");return jsxs(Ro,{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(No,{value:i,onChange:c=>a(c.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(q,{icon:"SAVE_MARK"}),disabled:!i||i==="",onClick:()=>{l(i),e(),a("");},children:"Salvar"})]})]})},so=Ho;var Ko=({label:o,itens:e,argumentsValues:l,fields:i,context:a,addItem:p,removeItem:c,insertItemSQL:m})=>{let[f,n]=useState(!1),r=Wo(),d=()=>{n(!f);},u=(s,S)=>{s.stopPropagation(),c&&c(S);},b=s=>{m(l?` $ARG[${s}]`:i?` this.${s}`:a?` $ctx[${s}]`:` ${s}`);};return jsxs(B,{children:[jsxs(B,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(H,{edge:"end",onClick:d,children:jsx(q,{icon:f?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(po,{variant:"overline",color:"text.primary",children:o}),p&&jsxs(Fragment,{children:[jsx(H,{edge:"end",onClick:r.onOpen,children:jsx(q,{icon:"SIMPLE_ADD"})}),jsx(so,{addItem:p,handleClose:r.onClose,openPopover:r.open})]})]}),f&&jsx(B,{spacing:.5,children:jsx(Qo,{sx:{maxHeight:150},children:e?.map((s,S)=>jsxs(eo,{direction:"row",justifyContent:"space-between",onClick:()=>b(s),children:[jsx(po,{variant:"caption",textAlign:"center",width:"100%",children:s}),c&&jsx(ko,{edge:"end",onClick:x=>u(x,s),children:jsx(q,{icon:"DELETE_MARK_BUTTON_02"})})]},S))})})]})},T=Ko;var jo=({fieldsSelect:o,argumentsValues:e,onChangeArguments:l,sql:i,setSql:a,setFilterRule:p})=>{let c=mo.default||mo,[m,f]=useState(),{setValue:n}=useFormContext(),[r,d]=useState(1),[u,b]=useState(),s=t=>{u.session.insert(r,` ${t} `);},S=t=>{l([...e||[],t]);},x=t=>{l(e?.filter(D=>D!==t));},A=t=>{a(t),p(t),n("groups",void 0);},k=m?o.filter(t=>t.id.toString().toLocaleLowerCase().includes(m)||t.description.toString().toLocaleLowerCase().includes(m)||t.name?.toString().toLocaleLowerCase().includes(m)):o;return jsxs(B,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(oo,{children:[jsx(Zo,{value:m,trigger:"change",onSearch:t=>f(t?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(T,{label:"Campos",fields:!0,itens:k.map(t=>t.name),insertItemSQL:s}),jsx(T,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:S,removeItem:x,insertItemSQL:s}),jsx(T,{label:"Operadores",insertItemSQL:s,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(T,{label:"Filtros",fields:!0,insertItemSQL:s,itens:k.map(t=>t.name)}),jsx(T,{label:"Contexto",context:!0,insertItemSQL:s,itens:["Vendedor.CODIGO","Empresa.CODIGO","Parceiro.CODIGO"]})]}),jsx(to,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(c,{width:"100%",mode:"sql",theme:"chrome",name:"rule",fontSize:14,onChange:A,onCursorChange:t=>d(t.getCursor()),value:i,onLoad:t=>b(t),showPrintMargin:!1,showGutter:!1,highlightActiveLine:!1,setOptions:{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:!1,tabSize:2}})]})})]})},co=jo;var te=({data:o,fields:e,isLoading:l,isError:i})=>jsxs(B,{gap:2,children:[jsx(po,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),i&&jsx(B,{children:"Falha ao gerar resultado"}),o&&jsx(B,{height:400,children:jsx(ee,{columns:e?.map(a=>({field:a,headerName:a,width:150,type:"string",resizable:!0})),loading:l,rows:o,disableRowSelectionOnClick:!0,disableColumnMenu:!0,disableColumnResize:!0,showColumnVerticalBorder:!0,hideFooter:!0})})]}),uo=te;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(ko)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),z=styled($)(()=>({width:230}));var ce=({index:o,indexGroup:e,removeConditional:l,fieldsSelect:i})=>{let{watch:a}=useFormContext(),p=`groups.[${e}].conditionals[${o}].field`,c=`groups.[${e}].conditionals[${o}].conditional`,m=`groups.[${e}].conditionals[${o}].type`,f=`groups.[${e}].conditionals[${o}].value`,n=[{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"}],r=a(m);return jsxs(B,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx($,{label:"Se",name:p,size:"small",fullWidth:!0,options:i?.map(d=>({value:d.name,label:d.description}))}),jsx($,{label:"Estado",name:c,size:"small",fullWidth:!0,options:n}),jsx($,{label:"Objetivo",name:`groups.[${e}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),r==="value"?jsx(me,{label:"Valor",name:f,size:"small",fullWidth:!0}):jsx($,{label:"Se",name:f,size:"small",fullWidth:!0,options:i?.map(d=>({value:d.name,label:d.description}))}),jsx(vo,{color:"error",onClick:()=>{l(o);},children:jsx(q,{icon:"DELETE_MARK_BUTTON_02"})})]})},Co=ce;var he=({index:o,removeGroup:e,fieldsSelect:l})=>{let{control:i}=useFormContext(),a=`groups.[${o}].operator`,{fields:p,append:c,remove:m}=useFieldArray({name:`groups.${o}.conditionals`,control:i});return jsx(Ce,{name:`GRUPO ${o+1}`,description:"EXIBIR A LISTAGEM QUANDO ATENDER UMA DAS CONDI\xC7\xD5ES",header:jsx(z,{name:a,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:[p.map((f,n)=>jsx(Co,{index:n,indexGroup:o,removeConditional:r=>m(r),fieldsSelect:l},f.id)),jsx(ve,{actionType:"NEW",onClick:()=>c({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},ho=he;var Ae=({fieldsSelect:o})=>{let{control:e}=useFormContext(),{fields:l,append:i,remove:a}=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(z,{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."})]})]}),l.map((p,c)=>jsx(ho,{index:c,removeGroup:m=>a(m),fieldsSelect:o},p.id)),jsx(ro,{size:"large",color:"inherit",startIcon:jsx(q,{icon:"SIMPLE_ADD"}),variant:"outlined",fullWidth:!0,onClick:()=>{i({operator:"or",conditionals:[{field:"",conditional:"=",type:"value",value:""}]});},children:"Adicionar grupo"})]})},So=Ae;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(Le)(()=>({lineHeight:"1em"})),Ao=styled(B)(()=>({padding:12}));var Ne=({argumentsValues:o,onChangeArguments:e,fieldsSelect:l,onChangeRule:i,onChangeSqlProcessed:a$1,defaultMode:p,defaultFilter:c,dataPreview:m,errorPreview:f,loadingPreview:n})=>{let[r,d]=useState(c||""),[u,b]=Be(),[s,S]=useState(p||"simple"),{watch:x}=useFormContext(),A=Wo(),k=x("operator"),t=x("groups"),D=(C,R)=>{if(R==="advanced"){let U=a(t,k);d(U),a$1(U),i(U);}S(R);},wo=C=>{if(s==="simple"){let R=a(t,k);a$1(R);}else a$1(r);u||s==="simple"||o.length===0?b():A.onOpen(C);},To=C=>{b(),a$1(C);};return jsx(Fragment,{children:jsxs(yo,{children:[jsxs(xo,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(ke,{color:"primary",value:s,size:"small",exclusive:!0,onChange:D,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=>wo(C),startIcon:!u&&jsx(q,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:u?"Voltar":"Executar"}),!!A.open&&jsx(io,{handleClose:A.onClose,openPopover:A.open,argumentsValues:o,filter:r,onExecute:C=>To(C)})]}),jsx(Ao,{children:u?jsx(uo,{fields:l.map(C=>C.name),data:m,isError:f,isLoading:n}):jsx(Fragment,{children:s==="simple"?jsx(So,{fieldsSelect:l,sql:r,setSql:d}):jsx(co,{fieldsSelect:l,argumentsValues:o,onChangeArguments:e,sql:r,setSql:d,setFilterRule:i})})})]})})},kr=Ne;
31
31
 
32
- export { Rr as default };
32
+ export { kr as default };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.85",
2
+ "version": "2.0.86",
3
3
  "name": "@zydon/common-csr",
4
4
  "description": "Zydon common resources for React projects (only Client-Side Rendering (CSR))",
5
5
  "license": "MIT",