@zydon/common-csr 2.0.38 → 2.0.40
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,25 +1,25 @@
|
|
|
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
|
|
4
|
+
import to from '@mui/material/Button';
|
|
5
5
|
import ke from '@mui/material/ToggleButtonGroup';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import _ from '@zydon/common/components/Icon';
|
|
7
|
+
import Ko from '@zydon/common/hooks/usePopover';
|
|
8
8
|
import Me from '@zydon/common/hooks/useToggle';
|
|
9
|
-
import
|
|
9
|
+
import Bo from '@mui/material/Popover';
|
|
10
10
|
import R from '@mui/material/Stack';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
11
|
+
import Mo from '@mui/material/TextField';
|
|
12
|
+
import so from '@mui/material/Typography';
|
|
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
16
|
import 'ace-builds/src-noconflict/ace';
|
|
17
17
|
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
|
-
import
|
|
20
|
+
import po from 'react-ace';
|
|
21
21
|
import Jo from '@zydon/common/components/SearchInput';
|
|
22
|
-
import
|
|
22
|
+
import Wo from '@zydon/common/components/Scrollbar';
|
|
23
23
|
import te from '@zydon/common/components/DataGrid';
|
|
24
24
|
import he from '@zydon/common/components/ActionButton';
|
|
25
25
|
import Ce from '@zydon/common/components/ExpandableGroup';
|
|
@@ -27,6 +27,6 @@ import M 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 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})),J=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)}})),oo=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(To)({padding:0});var Oo=({openPopover:o,handleClose:t,argumentsValues:a,filter:i,onExecute:l})=>{let[s,n]=useState([]),d=(r,p)=>{if(p&&p!=="")s.filter(u=>u.name===r).length>0?n(s.map(u=>u.name===r?{name:r,value:p}:u)):n([...s||[],{name:r,value:p}]);else {let m=s.filter(u=>u.name===r);n(m);}},f=()=>{let r=i||"";return s.forEach(p=>{r=r.replace(`$ARG[${p.name}]`,`'${p.value}'`);}),r};return jsxs(ko,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:t,title:"Pr\xE9-visualizar",children:[jsx(lo,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(k,{children:a?.map((r,p)=>jsx(No,{name:r,label:r,size:"small",onChange:m=>d(r,m.target.value),required:!0},p))}),jsxs(R,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(eo,{variant:"outlined",color:"inherit",size:"small",onClick:t,children:"Cancelar"}),jsx(eo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"PLAY_SIMPLE"}),onClick:()=>l(f()),disabled:s.length<a.length,children:"Executar"})]})]})},ro=Oo;var qo=({openPopover:o,handleClose:t,addItem:a})=>{let[i,l]=useState("");return jsxs(ko,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:t,sx:{maxWidth:464},title:"Novo Argumento",children:[jsx(lo,{variant:"subtitle1",color:"text.primary",p:1,children:"Novo Argumento"}),jsx(k,{children:jsx(No,{value:i,onChange:n=>l(n.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(R,{p:1,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(eo,{variant:"outlined",color:"inherit",size:"small",onClick:t,children:"Cancelar"}),jsx(eo,{variant:"contained",color:"primary",size:"small",startIcon:jsx(U,{icon:"SAVE_MARK"}),disabled:!i||i==="",onClick:()=>{a(i),t(),l("");},children:"Salvar"})]})]})},ao=qo;var Ko=({label:o,itens:t,argumentsValues:a,fields:i,addItem:l,removeItem:s,insertItemSQL:n})=>{let[d,f]=useState(!1),r=Wo(),p=()=>{f(!d);},m=(c,C)=>{c.stopPropagation(),s&&s(C);},u=c=>{n(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(lo,{variant:"overline",color:"text.primary",children:o}),l&&jsxs(Fragment,{children:[jsx(G,{edge:"end",onClick:r.onOpen,children:jsx(U,{icon:"SIMPLE_ADD"})}),jsx(ao,{addItem:l,handleClose:r.onClose,openPopover:r.open})]})]}),d&&jsx(R,{spacing:.5,children:jsx(Qo,{sx:{maxHeight:150},children:t?.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(To,{edge:"end",onClick:E=>m(E,c),children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]},C))})})]})},w=Ko;var oe=({fieldsSelect:o,argumentsValues:t,onChangeArguments:a,sql:i,setSql:l,setFilterRule:s})=>{let[n,d]=useState(),{setValue:f}=useFormContext(),[r,p]=useState(1),[m,u]=useState(),c=e=>{m.session.insert(r,` ${e} `);},C=e=>{a([...t||[],e]);},E=e=>{a(t?.filter(F=>F!==e));},P=e=>{l(e),s(e),f("groups",void 0);},T=n?o.filter(e=>e.id.toString().toLocaleLowerCase().includes(n)||e.description.toString().toLocaleLowerCase().includes(n)||e.name?.toString().toLocaleLowerCase().includes(n)):o;return jsxs(R,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(J,{children:[jsx(Jo,{value:n,trigger:"change",onSearch:e=>d(e?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(w,{label:"Campos",fields:!0,itens:T.map(e=>e.name),insertItemSQL:c}),jsx(w,{label:"Argumentos",argumentsValues:!0,itens:t,addItem:C,removeItem:E,insertItemSQL:c}),jsx(w,{label:"Operadores",insertItemSQL:c,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(w,{label:"Filtros",fields:!0,insertItemSQL:c,itens:T.map(e=>e.name)})]}),jsx(oo,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(Xo.default,{width:"100%",mode:"sql",theme:"chrome",name:"rule",fontSize:14,onChange:P,onCursorChange:e=>p(e.getCursor()),value:i,onLoad:e=>u(e),showPrintMargin:!1,showGutter:!1,highlightActiveLine:!1,setOptions:{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:!1,tabSize:2}})]})})]})},so=oe;var re=({data:o,fields:t,isLoading:a,isError:i})=>jsxs(R,{children:[jsx(lo,{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(te,{columns:t?.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(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"})),fo=styled(To)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),N=styled(M)(()=>({width:230}));var de=({index:o,indexGroup:t,removeConditional:a,fieldsSelect:i})=>{let{watch:l}=useFormContext(),s=`groups.[${t}].conditionals[${o}].field`,n=`groups.[${t}].conditionals[${o}].conditional`,d=`groups.[${t}].conditionals[${o}].type`,f=`groups.[${t}].conditionals[${o}].value`,r=[{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(M,{label:"Se",name:s,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(M,{label:"Estado",name:n,size:"small",fullWidth:!0,options:r}),jsx(M,{label:"Objetivo",name:`groups.[${t}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),p==="value"?jsx(ce,{label:"Valor",name:f,size:"small",fullWidth:!0}):jsx(M,{label:"Se",name:f,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(fo,{color:"error",onClick:()=>{a(o);},children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]})},go=de;var Ie=({index:o,removeGroup:t,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:()=>t(o),children:jsxs(R,{spacing:1.5,alignItems:"flex-start",children:[s.map((f,r)=>jsx(go,{index:r,indexGroup:o,removeConditional:p=>d(p),fieldsSelect:a},f.id)),jsx(he,{actionType:"NEW",onClick:()=>n({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},vo=Ie;var Ee=({fieldsSelect:o})=>{let{control:t}=useFormContext(),{fields:a,append:i,remove:l}=useFieldArray({name:"groups",control:t});return jsxs(R,{gap:1.5,children:[jsxs(uo,{direction:"row",spacing:1.5,children:[jsx(lo,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(R,{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"})]})},Io=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"})),K=styled(we)(()=>({lineHeight:"1em"})),yo=styled(R)(()=>({padding:12}));var ze=({argumentsValues:o,onChangeArguments:t,fieldsSelect:a$1,onChangeRule:i,onChangeSqlProcessed:l,defaultMode:s,defaultFilter:n,dataPreview:d,errorPreview:f,loadingPreview:r})=>{let[p,m]=useState(n||""),[u,c]=Me(),[C,E]=useState(s||"simple"),{watch:P,setValue:T}=useFormContext(),e=Wo(),F=P("operator"),Eo=P("groups");useEffect(()=>()=>{T("config",{});},[]);let Lo=(h,X)=>{if(X==="advanced"){let $=a(Eo,F);m($),l($),i($);}E(X);},wo=h=>{u||C==="simple"||o.length===0?c():e.onOpen(h);},Po=h=>{c(),l(h);};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:Lo,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:h=>wo(h),startIcon:!u&&jsx(U,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:u?"Voltar":"Executar"}),!!e.open&&jsx(ro,{handleClose:e.onClose,openPopover:e.open,argumentsValues:o,filter:p,onExecute:h=>Po(h)})]}),jsx(yo,{children:u?jsx(mo,{fields:a$1.map(h=>h.name),data:d,isError:f,isLoading:r}):jsx(Fragment,{children:C==="simple"?jsx(Io,{fieldsSelect:a$1,sql:p,setSql:m}):jsx(so,{fieldsSelect:a$1,argumentsValues:o,onChangeArguments:t,sql:p,setSql:m,setFilterRule:i})})})]})})},kr=ze;
|
|
30
|
+
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})),j=styled(R)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,padding:12,"& .MuiInputBase-root":{background:o.palette.grey[100]}})),oo=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)}})),eo=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}}})),D=styled(Ro)({padding:0});var Fo=({openPopover:o,handleClose:e,argumentsValues:i,filter:n,onExecute:a})=>{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(so,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(k,{children:i?.map((t,s)=>jsx(Mo,{name:t,label:t,size:"small",onChange:c=>m(t,c.target.value),required:!0},s))}),jsxs(R,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(to,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(to,{variant:"contained",color:"primary",size:"small",startIcon:jsx(_,{icon:"PLAY_SIMPLE"}),onClick:()=>a(f()),disabled:l.length<i.length,children:"Executar"})]})]})},no=Fo;var Ho=({openPopover:o,handleClose:e,addItem:i})=>{let[n,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(so,{variant:"subtitle1",color:"text.primary",p:1,children:"Novo Argumento"}),jsx(k,{children:jsx(Mo,{value:n,onChange:p=>a(p.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(R,{p:1,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(to,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancelar"}),jsx(to,{variant:"contained",color:"primary",size:"small",startIcon:jsx(_,{icon:"SAVE_MARK"}),disabled:!n||n==="",onClick:()=>{i(n),e(),a("");},children:"Salvar"})]})]})},lo=Ho;var Yo=({label:o,itens:e,argumentsValues:i,fields:n,addItem:a,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(i?` $ARG[${u}]`:n?` this.${u}`:` ${u}`);};return jsxs(R,{children:[jsxs(R,{direction:"row",alignItems:"center",spacing:1.5,padding:1,paddingLeft:0,children:[jsx(D,{edge:"end",onClick:s,children:jsx(_,{icon:m?"CHEVRON_UP":"CHEVRON_RIGHT"})}),jsx(so,{variant:"overline",color:"text.primary",children:o}),a&&jsxs(Fragment,{children:[jsx(D,{edge:"end",onClick:t.onOpen,children:jsx(_,{icon:"SIMPLE_ADD"})}),jsx(lo,{addItem:a,handleClose:t.onClose,openPopover:t.open})]})]}),m&&jsx(R,{spacing:.5,children:jsx(Wo,{sx:{maxHeight:150},children:e?.map((u,g)=>jsxs(oo,{direction:"row",justifyContent:"space-between",onClick:()=>d(u),children:[jsx(so,{variant:"caption",textAlign:"center",width:"100%",children:u}),l&&jsx(Ro,{edge:"end",onClick:L=>c(L,u),children:jsx(_,{icon:"DELETE_MARK_BUTTON_02"})})]},g))})})]})},P=Yo;var oe=({fieldsSelect:o,argumentsValues:e,onChangeArguments:i,sql:n,setSql:a,setFilterRule:l})=>{let p=po.default||po,[m,f]=useState(),{setValue:t}=useFormContext(),[s,c]=useState(1),[d,u]=useState(),g=r=>{d.session.insert(s,` ${r} `);},L=r=>{i([...e||[],r]);},T=r=>{i(e?.filter($=>$!==r));},F=r=>{a(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(R,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(j,{children:[jsx(Jo,{value:m,trigger:"change",onSearch:r=>f(r?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(P,{label:"Campos",fields:!0,itens:S.map(r=>r.name),insertItemSQL:g}),jsx(P,{label:"Argumentos",argumentsValues:!0,itens:e,addItem:L,removeItem:T,insertItemSQL:g}),jsx(P,{label:"Operadores",insertItemSQL:g,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(P,{label:"Filtros",fields:!0,insertItemSQL:g,itens:S.map(r=>r.name)})]}),jsx(eo,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(p,{width:"100%",mode:"sql",theme:"chrome",name:"rule",fontSize:14,onChange:F,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}})]})})]})},mo=oe;var re=({data:o,fields:e,isLoading:i,isError:n})=>jsxs(R,{children:[jsx(so,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),n&&jsx(R,{children:"Falha ao gerar resultado"}),o&&jsx(te,{columns:e?.map(a=>({field:a,headerName:a,width:150,type:"string"})),loading:i,rows:o,disableRowSelectionOnClick:!0,disableColumnMenu:!0,disableColumnResize:!0,showColumnVerticalBorder:!0,hideFooter:!0})]}),uo=re;var go=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"})),vo=styled(Ro)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),N=styled(M)(()=>({width:230}));var de=({index:o,indexGroup:e,removeConditional:i,fieldsSelect:n})=>{let{watch:a}=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=a(m);return jsxs(R,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx(M,{label:"Se",name:l,size:"small",fullWidth:!0,options:n?.map(c=>({value:c.name,label:c.description}))}),jsx(M,{label:"Estado",name:p,size:"small",fullWidth:!0,options:t}),jsx(M,{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(M,{label:"Se",name:f,size:"small",fullWidth:!0,options:n?.map(c=>({value:c.name,label:c.description}))}),jsx(vo,{color:"error",onClick:()=>{i(o);},children:jsx(_,{icon:"DELETE_MARK_BUTTON_02"})})]})},ho=de;var Ie=({index:o,removeGroup:e,fieldsSelect:i})=>{let{control:n}=useFormContext(),a=`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(N,{name:a,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:[l.map((f,t)=>jsx(ho,{index:t,indexGroup:o,removeConditional:s=>m(s),fieldsSelect:i},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:i,append:n,remove:a}=useFieldArray({name:"groups",control:e});return jsxs(R,{gap:1.5,children:[jsxs(go,{direction:"row",spacing:1.5,children:[jsx(so,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(R,{children:jsx(N,{size:"small",name:"operator",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]})}),jsxs(so,{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."})]})]}),i.map((l,p)=>jsx(Co,{index:p,removeGroup:m=>a(m),fieldsSelect:o},l.id)),jsx(to,{size:"large",color:"inherit",startIcon:jsx(_,{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(R)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,marginTop:24})),xo=styled(R)(()=>({padding:12,borderBottom:"1px solid #e0e0e0"})),Y=styled(we)(()=>({lineHeight:"1em"})),Ao=styled(R)(()=>({padding:12}));var ze=({argumentsValues:o,onChangeArguments:e,fieldsSelect:i,onChangeRule:n,onChangeSqlProcessed:a$1,defaultMode:l,defaultFilter:p,dataPreview:m,errorPreview:f,loadingPreview:t})=>{let[s,c]=useState(p||""),[d,u]=Me(),[g,L]=useState(l||"simple"),{watch:T,setValue:F}=useFormContext(),S=Ko(),r=T("operator"),$=T("groups");useEffect(()=>()=>{F("config",{});},[]);let wo=(C,Z)=>{if(Z==="advanced"){let G=a($,r);c(G),a$1(G),n(G);}L(Z);},Po=C=>{d||g==="simple"||o.length===0?u():S.onOpen(C);},To=C=>{u(),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:g,size:"small",exclusive:!0,onChange:wo,children:[jsx(Y,{value:"simple",size:"small",children:"Modo simplificado"}),jsx(Y,{value:"advanced",size:"small",children:"Modo avan\xE7ado"})]}),jsx(to,{variant:"outlined",color:"inherit",onClick:C=>Po(C),startIcon:!d&&jsx(_,{icon:"PLAY_SIMPLE",color:"primary.main"}),children:d?"Voltar":"Executar"}),!!S.open&&jsx(no,{handleClose:S.onClose,openPopover:S.open,argumentsValues:o,filter:s,onExecute:C=>To(C)})]}),jsx(Ao,{children:d?jsx(uo,{fields:i.map(C=>C.name),data:m,isError:f,isLoading:t}):jsx(Fragment,{children:g==="simple"?jsx(So,{fieldsSelect:i,sql:s,setSql:c}):jsx(mo,{fieldsSelect:i,argumentsValues:o,onChangeArguments:e,sql:s,setSql:c,setFilterRule:n})})})]})})},kr=ze;
|
|
31
31
|
|
|
32
32
|
export { kr as default };
|
package/package.json
CHANGED