@zydon/common-csr 2.0.23 → 2.0.25
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,30 +1,31 @@
|
|
|
1
1
|
import { a } from '../../../chunk-75QNIQAU.mjs';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { useFormContext, useFieldArray } from 'react-hook-form';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import eo from '@mui/material/Button';
|
|
5
|
+
import we from '@mui/material/ToggleButtonGroup';
|
|
6
6
|
import U from '@zydon/common/components/Icon';
|
|
7
7
|
import Wo from '@zydon/common/hooks/usePopover';
|
|
8
|
-
import
|
|
8
|
+
import Me from '@zydon/common/hooks/useToggle';
|
|
9
9
|
import wo from '@mui/material/Popover';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
10
|
+
import L from '@mui/material/Stack';
|
|
11
|
+
import Bo from '@mui/material/TextField';
|
|
12
|
+
import lo from '@mui/material/Typography';
|
|
13
|
+
import Lo 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
|
|
16
|
+
import Xo from 'react-ace';
|
|
17
|
+
import 'ace-builds/src-noconflict/mode-java';
|
|
17
18
|
import 'ace-builds/src-noconflict/theme-github';
|
|
18
19
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
20
|
+
import Jo from '@zydon/common/components/SearchInput';
|
|
21
|
+
import qo from '@zydon/common/components/Scrollbar';
|
|
22
|
+
import te from '@zydon/common/components/DataGrid';
|
|
23
|
+
import Ie from '@zydon/common/components/ActionButton';
|
|
24
|
+
import Ce from '@zydon/common/components/ExpandableGroup';
|
|
25
|
+
import B from '@zydon/common/form/Autocomplete';
|
|
26
|
+
import ce from '@zydon/common/form/Field';
|
|
26
27
|
import Te from '@mui/material/ToggleButton';
|
|
27
28
|
|
|
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;
|
|
29
|
+
var R=styled(L)(({theme:o})=>({borderBottom:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderTop:`1px solid ${alpha(o.palette.grey[500],.32)}`,padding:16})),J=styled(L)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,padding:12,"& .MuiInputBase-root":{background:o.palette.grey[100]}})),j=styled(L)(({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)}})),oo=styled(L)(({theme:o})=>({width:"100%","& fieldset":{border:`1px solid ${alpha(o.palette.grey[500],.24)}`,borderRadius:8,"& legend":{color:o.palette.text.disabled,fontSize:12}}})),D=styled(Lo)({padding:0});var Fo=({openPopover:o,handleClose:e,argumentsValues:a,filter:i,onExecute:l})=>{let[s,n]=useState([]),d=(t,p)=>{if(p&&p!=="")s.filter(u=>u.name===t).length>0?n(s.map(u=>u.name===t?{name:t,value:p}:u)):n([...s||[],{name:t,value:p}]);else {let m=s.filter(u=>u.name===t);n(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(lo,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(R,{children:a?.map((t,p)=>jsx(Bo,{name:t,label:t,size:"small",onChange:m=>d(t,m.target.value),required:!0},p))}),jsxs(L,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(eo,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(eo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"PLAY_SIMPLE"}),onClick:()=>l(g()),disabled:s.length<a.length,children:"Executar"})]})]})},ro=Fo;var Vo=({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(lo,{variant:"subtitle1",color:"text.primary",p:1,children:"Novo Argumento"}),jsx(R,{children:jsx(Bo,{value:i,onChange:n=>l(n.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(L,{p:1,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(eo,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(eo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"SAVE_MARK"}),disabled:!i||i==="",onClick:()=>{a(i),e(),l("");},children:"Salvar"})]})]})},ao=Vo;var Ko=({label:o,itens:e,argumentsValues:a,fields:i,addItem:l,removeItem:s,insertItemSQL:n})=>{let[d,g]=useState(!1),t=Wo(),p=()=>{g(!d);},m=(c,C)=>{c.stopPropagation(),s&&s(C);},u=c=>{n(a?` $ARG[${c}]`:i?` this.${c}`:` ${c}`);};return jsxs(L,{children:[jsxs(L,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(D,{edge:"end",onClick:p,children:jsx(U,{icon:d?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(lo,{variant:"overline",color:"text.primary",children:o}),l&&jsxs(Fragment,{children:[jsx(D,{edge:"end",onClick:t.onOpen,children:jsx(U,{icon:"SIMPLE_ADD"})}),jsx(ao,{addItem:l,handleClose:t.onClose,openPopover:t.open})]})]}),d&&jsx(L,{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(lo,{variant:"caption",textAlign:"center",width:"100%",children:c}),s&&jsx(Lo,{edge:"end",onClick:A=>m(A,c),children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]},C))})})]})},T=Ko;var oe=({fieldsSelect:o,argumentsValues:e,onChangeArguments:a,sql:i,setSql:l,setFilterRule:s})=>{let [n,d]=useState();useFormContext();let [t,p]=useState(1),[m,u]=useState(),c=r=>{m.session.insert(t,` ${r} `);},C=r=>{a([...e||[],r]);},A=r=>{a(e?.filter($=>$!==r));},k=n?o.filter(r=>r.id.toString().toLocaleLowerCase().includes(n)||r.description.toString().toLocaleLowerCase().includes(n)||r.name?.toString().toLocaleLowerCase().includes(n)):o;return console.log({"add ace":i}),jsxs(L,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(J,{children:[jsx(Jo,{value:n,trigger:"change",onSearch:r=>d(r?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(T,{label:"Campos",fields:!0,itens:k.map(r=>r.name),insertItemSQL:c}),jsx(T,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:C,removeItem:A,insertItemSQL:c}),jsx(T,{label:"Operadores",insertItemSQL:c,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(T,{label:"Filtros",fields:!0,insertItemSQL:c,itens:k.map(r=>r.name)})]}),jsx(oo,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(Xo,{mode:"java",theme:"github",onChange:r=>{console.log("change",r);},name:"UNIQUE_ID_OF_DIV",editorProps:{$blockScrolling:!0}})]})})]})},so=oe;var re=({data:o,fields:e,isLoading:a,isError:i})=>jsxs(L,{children:[jsx(lo,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),i&&jsx(L,{children:"Falha ao gerar resultado"}),o&&jsx(te,{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=re;var uo=styled(L)(({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(Lo)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),N=styled(B)(()=>({width:230}));var de=({index:o,indexGroup:e,removeConditional:a,fieldsSelect:i})=>{let{watch:l}=useFormContext(),s=`groups.[${e}].conditionals[${o}].field`,n=`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(L,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx(B,{label:"Se",name:s,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(B,{label:"Estado",name:n,size:"small",fullWidth:!0,options:t}),jsx(B,{label:"Objetivo",name:`groups.[${e}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),p==="value"?jsx(ce,{label:"Valor",name:g,size:"small",fullWidth:!0}):jsx(B,{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=de;var he=({index:o,removeGroup:e,fieldsSelect:a})=>{let{control:i}=useFormContext(),l=`groups.[${o}].operator`,{fields:s,append:n,remove:d}=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(N,{name:l,size:"small",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]}),onDelete:()=>e(o),children:jsxs(L,{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(Ie,{actionType:"NEW",onClick:()=>n({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},vo=he;var Ae=({fieldsSelect:o})=>{let{control:e}=useFormContext(),{fields:a,append:i,remove:l}=useFieldArray({name:"groups",control:e});return jsxs(L,{gap:1.5,children:[jsxs(uo,{direction:"row",spacing:1.5,children:[jsx(lo,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(L,{children:jsx(N,{size:"small",name:"operator",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]})}),jsxs(lo,{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,n)=>jsx(vo,{index:n,removeGroup:d=>l(d),fieldsSelect:o},s.id)),jsx(eo,{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=Ae;var bo=styled(L)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,marginTop:24})),So=styled(L)(()=>({padding:12,borderBottom:"1px solid #e0e0e0"})),K=styled(Te)(()=>({lineHeight:"1em"})),yo=styled(L)(()=>({padding:12}));var Oe=({argumentsValues:o,onChangeArguments:e,fieldsSelect:a$1,onChangeRule:i,onChangeSqlProcessed:l,defaultMode:s,defaultFilter:n,dataPreview:d,errorPreview:g,loadingPreview:t})=>{let[p,m]=useState(n||""),[u,c]=Me(),[C,A]=useState(s||"simple"),{watch:F,setValue:k}=useFormContext(),r=Wo(),$=F("operator"),Ao=F("groups");useEffect(()=>()=>{k("config",{});},[]);let Po=(I,X)=>{if(X==="advanced"){let z=a(Ao,$);m(z),l(z),i(z);}A(X);},To=I=>{u||C==="simple"||o.length===0?c():r.onOpen(I);},ko=I=>{c(),l(I);};return jsx(Fragment,{children:jsxs(bo,{children:[jsxs(So,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(we,{color:"primary",value:C,size:"small",exclusive:!0,onChange:Po,children:[jsx(K,{value:"simple",size:"small",children:"Modo simplificado"}),jsx(K,{value:"advanced",size:"small",children:"Modo avan\xE7ado"})]}),jsx(eo,{variant:"outlined",color:"inherit",onClick:I=>To(I),startIcon:!u&&jsx(U,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:u?"Voltar":"Executar"}),!!r.open&&jsx(ro,{handleClose:r.onClose,openPopover:r.open,argumentsValues:o,filter:p,onExecute:I=>ko(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=Oe;
|
|
29
30
|
|
|
30
31
|
export { Lr as default };
|
package/package.json
CHANGED