@zydon/common-csr 2.0.36 → 2.0.38
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.
|
@@ -2,30 +2,31 @@ import { a } from '../../../chunk-75QNIQAU.mjs';
|
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { useFormContext, useFieldArray } from 'react-hook-form';
|
|
4
4
|
import eo from '@mui/material/Button';
|
|
5
|
-
import
|
|
5
|
+
import ke from '@mui/material/ToggleButtonGroup';
|
|
6
6
|
import U from '@zydon/common/components/Icon';
|
|
7
7
|
import Wo from '@zydon/common/hooks/usePopover';
|
|
8
8
|
import Me from '@zydon/common/hooks/useToggle';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import ko from '@mui/material/Popover';
|
|
10
|
+
import R from '@mui/material/Stack';
|
|
11
11
|
import No from '@mui/material/TextField';
|
|
12
12
|
import lo from '@mui/material/Typography';
|
|
13
|
-
import
|
|
13
|
+
import To 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
|
|
17
|
-
import 'ace-builds/src-noconflict/mode-sql';
|
|
18
|
-
import 'ace-builds/src-noconflict/theme-github';
|
|
16
|
+
import 'ace-builds/src-noconflict/ace';
|
|
19
17
|
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
18
|
+
import 'ace-builds/src-noconflict/mode-sql';
|
|
19
|
+
import 'ace-builds/src-noconflict/theme-chrome';
|
|
20
|
+
import Xo from 'react-ace';
|
|
20
21
|
import Jo from '@zydon/common/components/SearchInput';
|
|
21
|
-
import
|
|
22
|
+
import Qo from '@zydon/common/components/Scrollbar';
|
|
22
23
|
import te from '@zydon/common/components/DataGrid';
|
|
23
24
|
import he from '@zydon/common/components/ActionButton';
|
|
24
25
|
import Ce from '@zydon/common/components/ExpandableGroup';
|
|
25
|
-
import
|
|
26
|
+
import M from '@zydon/common/form/Autocomplete';
|
|
26
27
|
import ce from '@zydon/common/form/Field';
|
|
27
|
-
import
|
|
28
|
+
import we from '@mui/material/ToggleButton';
|
|
28
29
|
|
|
29
|
-
var B=styled(w)(({theme:o})=>({borderBottom:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderTop:`1px solid ${alpha(o.palette.grey[500],.32)}`,padding:16})),J=styled(w)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,padding:12,"& .MuiInputBase-root":{background:o.palette.grey[100]}})),j=styled(w)(({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(w)(({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 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);}},g=()=>{let r=i||"";return s.forEach(p=>{r=r.replace(`$ARG[${p.name}]`,`'${p.value}'`);}),r};return jsxs(wo,{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(B,{children:a?.map((r,p)=>jsx(No,{name:r,label:r,size:"small",onChange:m=>d(r,m.target.value),required:!0},p))}),jsxs(w,{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(g()),disabled:s.length<a.length,children:"Executar"})]})]})},ro=Oo;var qo=({openPopover:o,handleClose:t,addItem:a})=>{let[i,l]=useState("");return jsxs(wo,{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(B,{children:jsx(No,{value:i,onChange:n=>l(n.target.value),name:"item",label:"Novo argumento",size:"small"})}),jsxs(w,{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,g]=useState(!1),r=Wo(),p=()=>{g(!d);},m=(c,C)=>{c.stopPropagation(),s&&s(C);},u=c=>{n(a?` $ARG[${c}]`:i?` this.${c}`:` ${c}`);};return jsxs(w,{children:[jsxs(w,{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(w,{spacing:.5,children:jsx(Vo,{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(Ro,{edge:"end",onClick:E=>m(E,c),children:jsx(U,{icon:"DELETE_MARK_BUTTON_02"})})]},C))})})]})},P=Ko;var oe=({fieldsSelect:o,argumentsValues:t,onChangeArguments:a,sql:i,setSql:l,setFilterRule:s})=>{let[n,d]=useState(),{setValue:g}=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(T=>T!==e));},k=e=>{l(e[0]),s(e[0]),g("groups",void 0);},R=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(w,{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(P,{label:"Campos",fields:!0,itens:R.map(e=>e.name),insertItemSQL:c}),jsx(P,{label:"Argumentos",argumentsValues:!0,itens:t,addItem:C,removeItem:E,insertItemSQL:c}),jsx(P,{label:"Operadores",insertItemSQL:c,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(P,{label:"Filtros",fields:!0,insertItemSQL:c,itens:R.map(e=>e.name)})]}),jsx(oo,{children:jsxs("fieldset",{children:[jsx("legend",{children:"Regras de listagem"}),jsx(Xo.default,{mode:"mysql",theme:"github",name:"splitEditor",onChange:e=>{console.log(e),k(e);},onCursorChange:(e,T)=>{console.log({selection:e}),p(e.getCursor);},value:i,onLoad:e=>{console.log({editor:e}),u(e);},showPrintMargin:!1,showGutter:!1,highlightActiveLine:!1,setOptions:{useWorker:!1,enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:!1,tabSize:2},editorProps:{$blockScrolling:!0}})]})})]})},so=oe;var re=({data:o,fields:t,isLoading:a,isError:i})=>jsxs(w,{children:[jsx(lo,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),i&&jsx(w,{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(w)(({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"}})),M=styled(z)(()=>({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`,g=`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(w,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx(z,{label:"Se",name:s,size:"small",fullWidth:!0,options:i?.map(m=>({value:m.name,label:m.description}))}),jsx(z,{label:"Estado",name:n,size:"small",fullWidth:!0,options:r}),jsx(z,{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:g,size:"small",fullWidth:!0}):jsx(z,{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 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(M,{name:l,size:"small",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]}),onDelete:()=>t(o),children:jsxs(w,{spacing:1.5,alignItems:"flex-start",children:[s.map((g,r)=>jsx(fo,{index:r,indexGroup:o,removeConditional:p=>d(p),fieldsSelect:a},g.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(w,{gap:1.5,children:[jsxs(uo,{direction:"row",spacing:1.5,children:[jsx(lo,{variant:"body2",color:"text.light.primary",children:"Se"}),jsx(w,{children:jsx(M,{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(w)(({theme:o})=>({border:`1px solid ${alpha(o.palette.grey[500],.32)}`,borderRadius:8,marginTop:24})),So=styled(w)(()=>({padding:12,borderBottom:"1px solid #e0e0e0"})),K=styled(Pe)(()=>({lineHeight:"1em"})),yo=styled(w)(()=>({padding:12}));var ze=({argumentsValues:o,onChangeArguments:t,fieldsSelect:a$1,onChangeRule:i,onChangeSqlProcessed:l,defaultMode:s,defaultFilter:n,dataPreview:d,errorPreview:g,loadingPreview:r})=>{let[p,m]=useState(n||""),[u,c]=Me(),[C,E]=useState(s||"simple"),{watch:k,setValue:R}=useFormContext(),e=Wo(),T=k("operator"),Eo=k("groups");useEffect(()=>()=>{R("config",{});},[]);let Lo=(h,X)=>{if(X==="advanced"){let F=a(Eo,T);m(F),l(F),i(F);}E(X);},Po=h=>{u||C==="simple"||o.length===0?c():e.onOpen(h);},ko=h=>{c(),l(h);};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: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=>Po(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=>ko(h)})]}),jsx(yo,{children:u?jsx(mo,{fields:a$1.map(h=>h.name),data:d,isError:g,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})})})]})})},Rr=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]}})),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
31
|
|
|
31
|
-
export {
|
|
32
|
+
export { kr as default };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.38",
|
|
3
3
|
"name": "@zydon/common-csr",
|
|
4
4
|
"description": "Zydon common resources for React projects (only Client-Side Rendering (CSR))",
|
|
5
5
|
"license": "MIT",
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"@tiptap/react": "^2.5.9",
|
|
92
92
|
"@tiptap/starter-kit": "^2.5.9",
|
|
93
93
|
"@uiw/react-codemirror": "^4.23.0",
|
|
94
|
-
"ace-builds": "
|
|
94
|
+
"ace-builds": "1.32.9",
|
|
95
95
|
"lowlight": "^3.1.0",
|
|
96
|
-
"react-ace": "
|
|
96
|
+
"react-ace": "11.0.1",
|
|
97
97
|
"react-lazy-load-image-component": "^1.6.2"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|