@zydon/common-csr 2.0.90 → 2.0.92
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,15 +2,15 @@ import { a } from '../../../chunk-75QNIQAU.mjs';
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useFormContext, useFieldArray } from 'react-hook-form';
|
|
4
4
|
import ro from '@mui/material/Button';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import we from '@mui/material/ToggleButtonGroup';
|
|
6
|
+
import Q from '@zydon/common/components/Icon';
|
|
7
7
|
import Wo from '@zydon/common/hooks/usePopover';
|
|
8
8
|
import Be from '@zydon/common/hooks/useToggle';
|
|
9
9
|
import Ro from '@mui/material/Popover';
|
|
10
10
|
import B from '@mui/material/Stack';
|
|
11
11
|
import No from '@mui/material/TextField';
|
|
12
12
|
import po from '@mui/material/Typography';
|
|
13
|
-
import
|
|
13
|
+
import wo 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';
|
|
@@ -19,7 +19,7 @@ import 'ace-builds/src-noconflict/mode-sql';
|
|
|
19
19
|
import 'ace-builds/src-noconflict/theme-chrome';
|
|
20
20
|
import mo from 'react-ace';
|
|
21
21
|
import Zo from '@zydon/common/components/SearchInput';
|
|
22
|
-
import
|
|
22
|
+
import qo from '@zydon/common/components/Scrollbar';
|
|
23
23
|
import ee from '@zydon/common/components/DataGrid';
|
|
24
24
|
import ve from '@zydon/common/components/ActionButton';
|
|
25
25
|
import Ce from '@zydon/common/components/ExpandableGroup';
|
|
@@ -27,6 +27,6 @@ import $ from '@zydon/common/form/Autocomplete';
|
|
|
27
27
|
import me from '@zydon/common/form/Field';
|
|
28
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}}})),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;
|
|
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(wo)({padding:0});var zo=({openPopover:o,handleClose:t,argumentsValues:l,filter:n,onExecute:i})=>{let[p,c]=useState([]),m=(a,e)=>{if(e&&e!=="")p.filter(u=>u.name===a).length>0?c(p.map(u=>u.name===a?{name:a,value:e}:u)):c([...p||[],{name:a,value:e}]);else {let d=p.filter(u=>u.name===a);c(d);}},f=()=>{let a=n||"";return p.forEach(e=>{a=a.replace(`$ARG[${e.name}]`,`'${e.value}'`);}),a};return jsxs(Ro,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:t,title:"Pr\xE9-visualizar",children:[jsx(po,{variant:"subtitle1",color:"text.primary",p:1,children:"Pr\xE9-visualizar"}),jsx(N,{children:l?.map((a,e)=>jsx(No,{name:a,label:a,size:"small",onChange:d=>m(a,d.target.value),required:!0},e))}),jsxs(B,{p:2,direction:"row",justifyContent:"flex-end",spacing:1,children:[jsx(ro,{variant:"outlined",color:"inherit",size:"small",onClick:t,children:"Cancelar"}),jsx(ro,{variant:"contained",color:"primary",size:"small",startIcon:jsx(Q,{icon:"PLAY_SIMPLE"}),onClick:()=>i(f()),disabled:p.length<l.length,children:"Executar"})]})]})},io=zo;var Ho=({openPopover:o,handleClose:t,addItem:l})=>{let[n,i]=useState("");return jsxs(Ro,{open:!!o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,onClose:t,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:n,onChange:c=>i(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:t,children:"Cancelar"}),jsx(ro,{variant:"contained",color:"primary",size:"small",startIcon:jsx(Q,{icon:"SAVE_MARK"}),disabled:!n||n==="",onClick:()=>{l(n),t(),i("");},children:"Salvar"})]})]})},so=Ho;var Ko=({label:o,itens:t,argumentsValues:l,fields:n,context:i,addItem:p,removeItem:c,insertItemSQL:m})=>{let[f,a]=useState(!1),e=Wo(),d=()=>{a(!f);},u=(s,S)=>{s.stopPropagation(),c&&c(S);},b=s=>{m(l?` $ARG[${s}]`:n?` this.${s}`:i?` $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:e.onOpen,children:jsx(Q,{icon:"SIMPLE_ADD"})}),jsx(so,{addItem:p,handleClose:e.onClose,openPopover:e.open})]})]}),f&&jsx(B,{spacing:.5,children:jsx(qo,{sx:{maxHeight:150},children:t?.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(wo,{edge:"end",onClick:x=>u(x,s),children:jsx(Q,{icon:"DELETE_MARK_BUTTON_02"})})]},S))})})]})},w=Ko;var jo=({fieldsSelect:o,argumentsValues:t,onChangeArguments:l,sql:n,setSql:i,setFilterRule:p})=>{let c=mo.default||mo,[m,f]=useState(),{setValue:a}=useFormContext(),[e,d]=useState(1),[u,b]=useState(),s=r=>{u.session.insert(e,` ${r} `);},S=r=>{l([...t||[],r]);},x=r=>{l(t?.filter(D=>D!==r));},A=r=>{i(r),p(r),a("groups",void 0);},P=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(B,{direction:"row",padding:1.5,spacing:1.5,children:[jsxs(oo,{children:[jsx(Zo,{value:m,trigger:"change",onSearch:r=>f(r?.toLocaleLowerCase()),fullWidth:!0,size:"small",placeholder:"Buscar",iconPosition:"start"}),jsx(w,{label:"Campos",fields:!0,itens:P.map(r=>r.name),insertItemSQL:s}),jsx(w,{label:"Argumentos",argumentsValues:!0,itens:t,addItem:S,removeItem:x,insertItemSQL:s}),jsx(w,{label:"Operadores",insertItemSQL:s,itens:["=",">","<","<=",">=","!=","IS NULL","IN","LIKE","NOT IN","NOT LIKE","IS NOT NULL"]}),jsx(w,{label:"Filtros",fields:!0,insertItemSQL:s,itens:P.map(r=>r.name)}),jsx(w,{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:r=>d(r.getCursor()),value:n,onLoad:r=>b(r),showPrintMargin:!1,showGutter:!1,highlightActiveLine:!1,setOptions:{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:!1,tabSize:2}})]})})]})},co=jo;var te=({data:o,fields:t,isLoading:l,isError:n})=>jsxs(B,{gap:2,children:[jsx(po,{variant:"subtitle2",color:"text.secondary",children:"PR\xC9 VISUALIZA\xC7\xC3O DOS RESULTADOS DA LISTAGEM"}),n&&jsx(B,{children:"Falha ao gerar resultado"}),o&&jsx(B,{height:400,children:jsx(ee,{columns:t?.map(i=>({field:i,headerName:i,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(wo)(()=>({height:"28px",marginLeft:"16px","&:hover":{backgroundColor:"transparent"}})),z=styled($)(()=>({width:230}));var ce=({index:o,indexGroup:t,removeConditional:l,fieldsSelect:n})=>{let{watch:i}=useFormContext(),p=`groups.[${t}].conditionals[${o}].field`,c=`groups.[${t}].conditionals[${o}].conditional`,m=`groups.[${t}].conditionals[${o}].type`,f=`groups.[${t}].conditionals[${o}].value`,a=[{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"}],e=i(m);return jsxs(B,{direction:"row",spacing:1.5,alignItems:"center",width:1,children:[jsx($,{label:"Se",name:p,size:"small",fullWidth:!0,options:n?.map(d=>({value:d.name,label:d.description}))}),jsx($,{label:"Estado",name:c,size:"small",fullWidth:!0,options:a}),jsx($,{label:"Objetivo",name:`groups.[${t}].conditionals[${o}].type`,size:"small",fullWidth:!0,options:[{label:"Valor",value:"value"},{label:"Campo",value:"field"}]}),e==="value"?jsx(me,{label:"Valor",name:f,size:"small",fullWidth:!0}):jsx($,{label:"Se",name:f,size:"small",fullWidth:!0,options:n?.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 Ie=({index:o,removeGroup:t,fieldsSelect:l})=>{let{control:n}=useFormContext(),i=`groups.[${o}].operator`,{fields:p,append:c,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(z,{name:i,size:"small",options:[{label:"Qualquer",value:"or"},{label:"Todas as condi\xE7\xF5es",value:"and"}]}),onDelete:()=>t(o),children:jsxs(B,{spacing:1.5,alignItems:"flex-start",children:[p.map((f,a)=>jsx(Co,{index:a,indexGroup:o,removeConditional:e=>m(e),fieldsSelect:l},f.id)),jsx(ve,{actionType:"NEW",onClick:()=>c({field:"",conditional:"=",type:"value",value:""}),variant:"text",size:"small",children:"Adicionar condi\xE7\xE3o"})]})})},Io=Ie;var Ae=({fieldsSelect:o})=>{let{control:t}=useFormContext(),{fields:l,append:n,remove:i}=useFieldArray({name:"groups",control:t});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(Io,{index:c,removeGroup:m=>i(m),fieldsSelect:o},p.id)),jsx(ro,{size:"large",color:"inherit",startIcon:jsx(Q,{icon:"SIMPLE_ADD"}),variant:"outlined",fullWidth:!0,onClick:()=>{n({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:t,fieldsSelect:l,onChangeRule:n,onChangeSqlProcessed:i,defaultMode:p,defaultFilter:c,dataPreview:m,errorPreview:f,loadingPreview:a$1})=>{let[e,d]=useState(c||""),[u,b]=Be(),[s,S]=useState(p||"simple"),{watch:x}=useFormContext(),A=Wo(),P=x("operator"),r=x("groups"),D=(C,E)=>{if(E==="advanced"){let U=a(r,P);d(U),i(U),n(U);}else E==="simple"&&e&&(n(e),i(e));E!==null&&S(E);},To=C=>{if(s==="simple"){let E=a(r,P);i(E);}else i(e);u||s==="simple"||o.length===0?b():A.onOpen(C);},ko=C=>{b(),i(C);};return jsx(Fragment,{children:jsxs(yo,{children:[jsxs(xo,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[jsxs(we,{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=>To(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:e,onExecute:C=>ko(C)})]}),jsx(Ao,{children:u?jsx(uo,{fields:l.map(C=>C.name),data:m,isError:f,isLoading:a$1}):jsx(Fragment,{children:s==="simple"?jsx(So,{fieldsSelect:l,sql:e,setSql:d}):jsx(co,{fieldsSelect:l,argumentsValues:o,onChangeArguments:t,sql:e,setSql:d,setFilterRule:n})})})]})})},wr=Ne;
|
|
31
31
|
|
|
32
|
-
export {
|
|
32
|
+
export { wr as default };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { a } from '../../../chunk-2L7N4G6V.mjs';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
import f from '@mui/material/Button';
|
|
4
|
+
import g from '@zydon/common/components/ActionButton';
|
|
5
|
+
import C from '@zydon/common/components/Modal';
|
|
5
6
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
7
|
|
|
7
|
-
var
|
|
8
|
+
var M=({rules:l,open:n,close:a$1,formId:e,loading:s,disable:d,confirm:m,initialMode:u})=>{let{reset:c}=useFormContext(),t=()=>{c(),a$1();};return jsx(Fragment,{children:jsx(C,{fullWidth:!0,maxWidth:"lg",open:n,onClose:t,dialogTitle:"Nova regra de listagem",actions:jsxs(Fragment,{children:[jsx(f,{variant:"outlined",color:"inherit",onClick:t,children:"Fechar"}),jsx(g,{form:e,loading:s,actionType:"CREATE",color:"primary",variant:"contained",disabled:d,onClick:m,children:"Salvar"})]}),children:jsx(a,{rules:l,initialMode:u})})})},T=M;
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
+
export { T as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { GridApiPremium } from '@mui/x-data-grid-premium/models/gridApiPremium';
|
|
3
|
+
|
|
4
|
+
interface Config {
|
|
5
|
+
prefix?: string;
|
|
6
|
+
page?: number;
|
|
7
|
+
perPage?: number;
|
|
8
|
+
search?: string;
|
|
9
|
+
sort?: string;
|
|
10
|
+
dir?: 'asc' | 'desc';
|
|
11
|
+
}
|
|
12
|
+
declare const useDatagrid: ({ prefix, ...initialState }?: Config) => {
|
|
13
|
+
page: number;
|
|
14
|
+
perPage: number;
|
|
15
|
+
search: string;
|
|
16
|
+
searchValue: string;
|
|
17
|
+
sort: string;
|
|
18
|
+
dir: "desc" | "asc" | undefined;
|
|
19
|
+
apiRef: MutableRefObject<GridApiPremium>;
|
|
20
|
+
handlePaginationModelChange: ({ page, pageSize }: {
|
|
21
|
+
page?: number | undefined;
|
|
22
|
+
pageSize?: number | undefined;
|
|
23
|
+
}) => void;
|
|
24
|
+
handleSearch: (search: string | undefined) => void;
|
|
25
|
+
handleSearchValue: (value: string | undefined) => void;
|
|
26
|
+
applySearchValue: () => void;
|
|
27
|
+
handleSort: (field?: string, dir?: 'asc' | 'desc') => void;
|
|
28
|
+
goToPageFirstPage: () => void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { useDatagrid as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useSearchParams } from 'react-router-dom';
|
|
3
|
+
import { useGridApiRef } from '@mui/x-data-grid-premium';
|
|
4
|
+
|
|
5
|
+
var s={page:1,perPage:25},x=({prefix:g="",...l}={})=>{let c=useGridApiRef(),[o,P]=useSearchParams(),n=(e,r)=>{let t=o.get(`${g}${e}`);if(t!==null)return e==="page"||e==="perPage"?Number(t):t;let a=l[e];return a!==void 0?a:r},i=e=>{let r=new URLSearchParams(o.toString());Object.entries(e).forEach(([t,a])=>{let m=`${g}${t}`;a==null||a===""?r.delete(m):r.set(m,String(a));}),P(r);},h=n("page",s.page),u=n("perPage",s.perPage),p=n("search"),S=n("sort"),b=n("dir"),[d,R]=useState(p?.toString()??""),f=({page:e=0,pageSize:r=s.perPage})=>{i({page:e+1,perPage:r});},V=e=>{i({search:e,page:s.page});},A=e=>{R(e);},C=()=>{i({search:d,page:s.page});},O=(e,r)=>{i({sort:e,dir:r});},$=()=>{c.current&&c.current.setPage(0),f({page:0,pageSize:u});};return {page:h-1,perPage:u,search:p,searchValue:d,sort:S,dir:b,apiRef:c,handlePaginationModelChange:f,handleSearch:V,handleSearchValue:A,applySearchValue:C,handleSort:O,goToPageFirstPage:$}},T=x;
|
|
6
|
+
|
|
7
|
+
export { T as default };
|
package/package.json
CHANGED