@zydon/common 2.8.81 → 2.8.83
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,8 +1,8 @@
|
|
|
1
1
|
import '../../chunk-4P2L7UJA.js';
|
|
2
2
|
export { a as FilterOperator, b as SortType } from '../../chunk-M62EJMQ6.js';
|
|
3
|
-
import { a as a$
|
|
3
|
+
import { a as a$4 } from '../../chunk-WLRSUL67.js';
|
|
4
4
|
import { d, c } from '../../chunk-N7IK5EUP.js';
|
|
5
|
-
import { h, a as a$
|
|
5
|
+
import { h, a as a$6 } from '../../chunk-OF6623HG.js';
|
|
6
6
|
import { d as d$1 } from '../../chunk-Z275MVEP.js';
|
|
7
7
|
import '../../chunk-R2BCPHRH.js';
|
|
8
8
|
import '../../chunk-4F2NKGF6.js';
|
|
@@ -11,24 +11,25 @@ import '../../chunk-6U5LS7MP.js';
|
|
|
11
11
|
import '../../chunk-LZQ7OFKO.js';
|
|
12
12
|
import '../../chunk-NIQW2J3M.js';
|
|
13
13
|
import '../../chunk-PRWQQJDL.js';
|
|
14
|
-
import { a as a$
|
|
14
|
+
import { a as a$5 } from '../../chunk-3PMDTIVB.js';
|
|
15
15
|
import '../../chunk-5J35UAV6.js';
|
|
16
16
|
import { e } from '../../chunk-XUDTPZHF.js';
|
|
17
17
|
import '../../chunk-UVPQR2Q2.js';
|
|
18
18
|
import '../../chunk-RBTYTONM.js';
|
|
19
19
|
import '../../chunk-F65ZXAGV.js';
|
|
20
20
|
import '../../chunk-I4PPSW36.js';
|
|
21
|
+
import { a as a$3 } from '../../chunk-6N456D64.js';
|
|
21
22
|
import '../../chunk-CO2KQFUN.js';
|
|
22
23
|
import { a } from '../../chunk-2GTD4JW2.js';
|
|
23
24
|
import '../../chunk-PBLSVXV5.js';
|
|
24
25
|
import '../../chunk-IAOMC4C4.js';
|
|
25
26
|
import { a as a$1 } from '../../chunk-E3R7W7GK.js';
|
|
26
|
-
import { a as a$
|
|
27
|
+
import { a as a$8 } from '../../chunk-F6H765KA.js';
|
|
27
28
|
import '../../chunk-LQRRMVFN.js';
|
|
28
29
|
import { b } from '../../chunk-2ZJUGM2S.js';
|
|
29
30
|
import '../../chunk-GLRLKFPS.js';
|
|
30
31
|
import { a as a$2 } from '../../chunk-GNNZB7DN.js';
|
|
31
|
-
import { a as a$
|
|
32
|
+
import { a as a$7 } from '../../chunk-2HAPOY5M.js';
|
|
32
33
|
import '../../chunk-FJBC6QA5.js';
|
|
33
34
|
import '../../chunk-POTVACYB.js';
|
|
34
35
|
import '../../chunk-ET3WPQIO.js';
|
|
@@ -36,28 +37,26 @@ import '../../chunk-CFNATBO2.js';
|
|
|
36
37
|
import { memo, useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
|
37
38
|
import $o from 'react-fast-compare';
|
|
38
39
|
import et from '@mui/material/Badge';
|
|
39
|
-
import
|
|
40
|
+
import Fe from '@mui/material/Button';
|
|
40
41
|
import tt from '@mui/material/IconButton';
|
|
41
42
|
import Lt from '@mui/material/Stack';
|
|
42
43
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
43
44
|
import yt from '@mui/material/Divider';
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import tr from '@mui/material/CircularProgress';
|
|
52
|
-
import Z from '@mui/material/Box';
|
|
45
|
+
import be from '@mui/material/Typography';
|
|
46
|
+
import ge from '@mui/material/FormControl';
|
|
47
|
+
import Ce from '@mui/material/InputLabel';
|
|
48
|
+
import J from '@mui/material/MenuItem';
|
|
49
|
+
import ye from '@mui/material/Select';
|
|
50
|
+
import cr from '@mui/material/TextField';
|
|
51
|
+
import ee from '@mui/material/Box';
|
|
53
52
|
import { styled } from '@mui/material/styles';
|
|
54
|
-
import
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
import
|
|
58
|
-
import
|
|
53
|
+
import Lr from '@mui/material/Dialog';
|
|
54
|
+
import Pr from '@mui/material/DialogActions';
|
|
55
|
+
import Or from '@mui/material/DialogContent';
|
|
56
|
+
import kr from '@mui/material/DialogTitle';
|
|
57
|
+
import li from '@mui/material/Chip';
|
|
59
58
|
|
|
60
|
-
var Xo=({showFilterButton:e$1,isMobile:t,hasActiveFilters:o,activeFiltersCount:r,sort:i,onFilterClick:n,onSortClick:a$1})=>e$1?t?jsxs(Lt,{direction:"row",spacing:.5,children:[jsx(et,{badgeContent:r,color:"primary",invisible:r===0,sx:{"& .MuiBadge-badge":{transform:"scale(0.9) translate(10px, 9px)",opacity:r===0?0:1}},children:jsx(tt,{color:o?"primary":"default",onClick:n,size:"small","aria-label":"Filtrar",sx:{overflow:"visible"},children:jsx(a,{icon:"FILTER_VERTICAL"})})}),jsx(e,{sx:{height:16},orientation:"vertical",flexItem:!0}),jsx(tt,{color:i?"primary":"default",onClick:a$1,size:"small","aria-label":"Ordenar",children:jsx(a,{icon:i?.sortType==="DESC"?"SORTING_DESC":"SORTING_ASC"})})]}):jsx(et,{badgeContent:r,color:"primary",invisible:r===0,sx:{"& .MuiBadge-badge":r?{transform:"scale(0.9) translate(-3px, 7px)",position:"relative",opacity:1,transition:"none"}:{transition:"none",opacity:0}},children:jsx(Ie,{variant:"text",color:o?"primary":"inherit",startIcon:jsx(a,{icon:"FILTER_VERTICAL"}),onClick:n,size:"small",children:"Filtrar"})}):null,ot=memo(Xo,$o);var rt=e=>e.filter(t=>t.available_filter_conditions&&t.available_filter_conditions.length>0&&t.name!=="ACTIONS");var nt=e=>{let{type:t,available_filter_conditions:o}=e;return o.length===0?"EQUALS":t==="TEXT"&&o.includes("LIKE")?"LIKE":o[0]},X=e=>e.value.length>0||e.conditional==="IS_NULL"||e.conditional==="IS_NOT_NULL",it=e=>{if(e.length===0)return;let t=e.filter(X);if(t.length!==0)return {operator:"AND",groups:[{operator:t[0]?.operator||"AND",conditionals:t.map(o=>({fieldName:o.fieldName,conditional:o.conditional,value:o.value}))}]}};var at={["EQUALS"]:"Igual a",["NOT_EQUALS"]:"Diferente de",["LIKE"]:"Cont\xE9m",["NOT_LIKE"]:"N\xE3o cont\xE9m",["GREATER_THAN"]:"Maior que",["LESS_THAN"]:"Menor que",["GREATER_THAN_OR_EQUAL"]:"Maior ou igual a",["LESS_THAN_OR_EQUAL"]:"Menor ou igual a",["IN"]:"Em",["NOT_IN"]:"N\xE3o em",["IS_NULL"]:"\xC9 nulo",["IS_NOT_NULL"]:"N\xE3o \xE9 nulo"};var rr=({config:e,metadata:t,value:o,initialLabel:r,onChange:i,disabled:n=!1})=>{let[a,s,p]=a$1(!1),[m,c]=useState(""),u=a$2(m,400),{data:f,isLoading:y,isFetching:g}=e.useQuery({search:u||void 0,page:0,perPage:25,...e.queryParams},{skip:!a}),N=y||g,l=useMemo(()=>o?{value:o,label:r??o}:null,[o,r]),R=useMemo(()=>{let d=(f?.items??[]).map(C=>({label:String(C[t.description_field_name]??""),value:String(C[t.id_field_name]??"")})).filter(C=>C.value&&C.label);return l&&!d.some(C=>C.value===l.value)&&d.unshift(l),d},[f,t.id_field_name,t.description_field_name,l]),_=useCallback(()=>{p(!1),c("");},[p]),A=useCallback((d,C)=>{i(C?.value??"",C?.label);},[i]),B=useCallback((d,C,S)=>{S==="input"&&c(C);},[]);return jsx(er,{open:a,onOpen:s,onClose:_,value:l,onChange:A,inputValue:a?m:l?.label??"",onInputChange:B,options:R,loading:N,disabled:n,size:"small",getOptionLabel:d=>d.label,isOptionEqualToValue:(d,C)=>d.value===C.value,filterOptions:d=>d,noOptionsText:m!==u?"Buscando...":"Nenhum resultado",sx:{flex:1,minWidth:120},renderInput:d=>jsx(or,{...d,label:"Filtro",InputLabelProps:{shrink:!0},InputProps:{...d.InputProps,endAdornment:jsxs(Fragment,{children:[N&&jsx(tr,{color:"inherit",size:18}),d.InputProps.endAdornment]})}})})},st=memo(rr);var dr=({value:e,onChange:t,totalConditions:o,isFirst:r})=>o===1?null:r?jsx(Lt,{sx:{width:55,flexShrink:0}}):jsxs(be,{value:e,onChange:i=>t(i.target.value),size:"small",sx:{width:55,flexShrink:0},children:[jsx(j,{value:"AND",children:"e"}),jsx(j,{value:"OR",children:"ou"})]}),dt=memo(dr,$o);var G={whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},yr=({condition:e,fields:t,onChange:o,onRemove:r,totalConditions:i,isFirst:n,entityFilterConfig:a$1})=>{let s=useMemo(()=>t.find(l=>(l.filter_field_name??l.name)===e.fieldName),[t,e.fieldName]),p=useMemo(()=>s?.available_filter_conditions||[],[s]),m=useMemo(()=>!e.fieldName||e.conditional==="IS_NULL"||e.conditional==="IS_NOT_NULL",[e.fieldName,e.conditional]),c=useCallback(l=>{let R=t.find(A=>(A.filter_field_name??A.name)===l);if(!R)return;let _=R.available_filter_conditions[0]||"EQUALS";o({...e,fieldName:l,conditional:_,value:[]});},[t,e,o]),u=useCallback(l=>{o({...e,conditional:l});},[e,o]),f=useCallback(l=>{o({...e,value:l?[l]:[]});},[e,o]),y=useCallback((l,R)=>{let _={...e.valueLabels};l&&R&&(_[l]=R),o({...e,value:l?[l]:[],valueLabels:_});},[e,o]),g=useCallback(l=>{o({...e,operator:l});},[e,o]),N=()=>{if(s?.type==="BOOLEAN")return jsxs(Ce,{size:"small",sx:{flex:1,minWidth:120},disabled:m,children:[jsx(ye,{id:`value-label-${e.id}`,children:"Valor"}),jsxs(be,{labelId:`value-label-${e.id}`,label:"Valor",value:e.value[0]||"",onChange:l=>f(l.target.value),size:"small",sx:{"& .MuiSelect-select":G},children:[jsx(j,{value:"true",children:"Verdadeiro"}),jsx(j,{value:"false",children:"Falso"})]})]});if(s?.type==="ENTITY"&&s.metadata&&a$1?.[s.metadata.name]){let l=e.value[0]||"";return jsx(st,{config:a$1[s.metadata.name],metadata:s.metadata,value:l,initialLabel:e.valueLabels?.[l],onChange:y,disabled:m})}return jsx(or,{label:"Filtro",value:e.value[0]||"",onChange:l=>f(l.target.value),size:"small",disabled:m,InputLabelProps:{shrink:!0},sx:{flex:1,minWidth:120}})};return jsxs(Lt,{direction:"row",spacing:1,alignItems:"center",children:[jsx(tt,{onClick:r,size:"small","aria-label":"Remover filtro",sx:{flexShrink:0},children:jsx(a,{icon:"CLOSE_MARK_BUTTON",width:18})}),jsx(dt,{value:e.operator,onChange:g,totalConditions:i,isFirst:n}),jsxs(Ce,{size:"small",sx:{minWidth:150,flex:1},children:[jsx(ye,{id:`field-label-${e.id}`,children:"Coluna"}),jsx(be,{labelId:`field-label-${e.id}`,label:"Coluna",value:e.fieldName,onChange:l=>c(l.target.value),size:"small",sx:{"& .MuiSelect-select":G},children:t.map(l=>jsx(j,{value:l.filter_field_name??l.name,sx:G,title:l.description||l.name,children:l.description||l.name},l.name))})]}),jsxs(Ce,{size:"small",sx:{minWidth:90},disabled:!e.fieldName,children:[jsx(ye,{id:`condition-label-${e.id}`,children:"Condi\xE7\xE3o"}),jsx(be,{labelId:`condition-label-${e.id}`,label:"Condi\xE7\xE3o",value:e.conditional,onChange:l=>u(l.target.value),size:"small",sx:{"& .MuiSelect-select":G},children:p.map(l=>jsx(j,{value:l,sx:G,children:at[l]||l},l))})]}),N()]})},pt=memo(yr,$o);var hr=({filterableFields:e,conditions:t,onUpdateCondition:o,onRemoveCondition:r,entityFilterConfig:i})=>{let n=useCallback(m=>{o(m.id,m);},[o]),a=useCallback(m=>()=>{r(m);},[r]),s=useMemo(()=>t.map(m=>m.fieldName).filter(m=>!!m),[t]),p=useCallback(m=>e.filter(c=>!s.includes(c.name)||c.name===m),[e,s]);return e.length===0?jsx(Fe,{variant:"body2",color:"text.secondary",textAlign:"center",children:"Nenhum filtro dispon\xEDvel"}):t.length===0?jsxs(Fe,{variant:"body2",color:"text.secondary",textAlign:"center",children:["Clique em"," ",jsx(Fe,{component:"strong",variant:"body2",fontWeight:600,color:"text.primary",children:'"+"'})," ","para adicionar um filtro"]}):jsx(Fragment,{children:t.map((m,c)=>jsx(pt,{condition:m,fields:p(m.fieldName),onChange:n,onRemove:a(m.id),showOperator:c>0,totalConditions:t.length,isFirst:c===0,entityFilterConfig:i},m.id))})},ct=memo(hr,$o);var ut=styled(Z)({display:"flex",flexDirection:"column",height:"100%"}),ft=styled(Z)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(2,3)})),gt=styled(Z)(({theme:e})=>({flex:1,overflowY:"auto",padding:e.spacing(3),display:"flex",flexDirection:"column",gap:e.spacing(2)})),Ct=styled(Z)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(2)}));var Nr=({onClose:e,fields:t,conditions:o,onAddCondition:r,onUpdateCondition:i,onRemoveCondition:n,onApply:a$1,onClear:s,onCancel:p,entityFilterConfig:m})=>{let c=rt(t),u=o.length>0,f=useCallback(()=>{a$1(),e();},[a$1,e]),y=useCallback(()=>{s(),e();},[s,e]),g=useCallback(()=>{p();},[p]);return jsxs(ut,{children:[jsxs(ft,{children:[jsx(Fe,{variant:"overline",fontWeight:600,color:"text.secondary",children:"Defina as condi\xE7\xF5es para filtrar"}),jsx(tt,{onClick:r,size:"small","aria-label":"Adicionar filtro",title:"Adicionar filtro",disabled:o.length>=c.length,children:jsx(a,{icon:"SIMPLE_ADD"})})]}),jsx(yt,{}),jsx(gt,{children:jsx(ct,{filterableFields:c,conditions:o,onUpdateCondition:i,onRemoveCondition:n,entityFilterConfig:m})}),jsx(yt,{}),jsxs(Ct,{children:[jsx(Ie,{variant:"text",color:"inherit",onClick:y,children:"Limpar"}),jsxs(Lt,{direction:"row",spacing:1,children:[jsx(Ie,{variant:"outlined",color:"inherit",onClick:g,startIcon:jsx(a,{icon:"CANCEL_CIRCLE"}),children:"Cancelar"}),jsx(Ie,{variant:"contained",onClick:f,disabled:!u,startIcon:jsx(a,{icon:"SIMPLE_CHECK"}),children:"Aplicar"})]})]})]})},bt=memo(Nr,$o);var Mr=e=>jsx(a$3,{open:e.open,onClose:e.onClose,anchorEl:e.anchorEl,isMobile:e.isMobileProp,popoverProps:{slotProps:{paper:{sx:{width:520,maxWidth:"calc(100vw - 24px)",maxHeight:600,mt:1}}}},drawerProps:{anchor:"right",PaperProps:{sx:{width:"100%",maxWidth:"100%",height:"100%",maxHeight:"100%",borderRadius:0}}},children:jsx(bt,{...e})}),Ft=memo(Mr,$o);var Pr=({showFilterButton:e,isOpen:t,filterAnchorEl:o,fields:r,conditions:i,isMobile:n,onClose:a,onAddCondition:s,onUpdateCondition:p,onRemoveCondition:m,onApply:c,onClear:u,onCancel:f,entityFilterConfig:y})=>e?jsx(Ft,{open:t||!!o,anchorEl:o,onClose:a,fields:r,conditions:i,onAddCondition:s,onUpdateCondition:p,onRemoveCondition:m,onApply:c,onClear:u,onCancel:f,isMobileProp:n,entityFilterConfig:y}):null,ht=memo(Pr,$o);var It=styled(Br)(()=>({"& .MuiDialog-paper":{width:"100%"}})),Tt=styled(Gr)(({theme:e})=>({borderBottom:"1px solid",borderColor:e.palette.divider,padding:e.spacing(1.5,2)})),Rt=styled(Wr)(({theme:e})=>({padding:e.spacing(2)})),Dt=styled(Vr)(({theme:e})=>({borderTop:"1px solid",borderColor:e.palette.divider,padding:e.spacing(1.5,2)})),_t=styled(Ie)(({theme:e})=>({minWidth:24,[e.breakpoints.down(330)]:{padding:e.spacing(1)}})),Te=styled(Fe)(({theme:e})=>({fontWeight:"600",margin:e.spacing(0,1),[e.breakpoints.down(330)]:{fontSize:0,margin:0}}));var Pt=({open:e,onClose:t,fields:o,sort:r,onSortChange:i})=>{let[n,a$1]=useState(r?.fieldName||""),[s,p]=useState(r?.sortType||"ASC"),m=useMemo(()=>o.filter(g=>g.name!=="ACTIONS"&&g.access_type!=="WRITE_ONLY"),[o]),c=useMemo(()=>o.find(g=>(g.filter_field_name??g.name)===n),[o,n]),u=c?.type==="DECIMAL"||c?.type==="INTEGER";useEffect(()=>{e&&(a$1(r?.fieldName||""),p(r?.sortType||"ASC"));},[e,r]);let f=useCallback(()=>{i&&i(n?{fieldName:n,sortType:s}:void 0),t();},[i,n,s,t]),y=useCallback(()=>{i&&(a$1(""),p("ASC"),i(void 0),t());},[i,t]);return jsxs(It,{open:e,onClose:t,maxWidth:"xs",fullWidth:!0,children:[jsx(Tt,{children:jsx(Fe,{variant:"overline",color:"text.secondary",children:"Ordenar por"})}),jsx(Rt,{children:jsxs(Lt,{spacing:2,pt:2,children:[jsxs(Ce,{fullWidth:!0,size:"small",children:[jsx(ye,{id:"sort-field-label",children:"Campo"}),jsxs(be,{labelId:"sort-field-label",value:n,label:"Campo",onChange:g=>a$1(g.target.value),children:[jsx(j,{value:"",children:jsx("em",{children:"Nenhum"})}),m.map(g=>jsx(j,{value:g.filter_field_name??g.name,children:g.description||g.name},g.name))]})]}),jsxs(Ce,{fullWidth:!0,size:"small",disabled:!n,children:[jsx(ye,{id:"sort-direction-label",children:"Dire\xE7\xE3o"}),jsxs(be,{labelId:"sort-direction-label",value:s,label:"Dire\xE7\xE3o",onChange:g=>p(g.target.value),children:[jsxs(j,{value:"ASC",children:["Crescente ",u?"(1-9)":"(A-Z)"]}),jsxs(j,{value:"DESC",children:["Decrescente ",u?"(9-1)":"(Z-A)"]})]})]})]})}),jsxs(Dt,{children:[jsx(Lt,{flex:1,width:"100%",direction:"row",children:jsx(Ie,{color:"inherit",onClick:y,children:"Limpar"})}),jsxs(Ie,{onClick:t,variant:"outlined",color:"inherit",sx:{minWidth:24},children:[jsx(a,{icon:"CANCEL_CIRCLE"}),jsx(Te,{children:"Cancelar"})]}),jsxs(_t,{onClick:f,variant:"contained",children:[jsx(a,{icon:"SIMPLE_CHECK"}),jsx(Te,{children:"Aplicar"})]})]})]})};Pt.displayName="SortModal";var Ot=memo(Pt);var kt=({columns:e,fields:t,preferredFieldOrder:o})=>{let r=useMemo(()=>new Map(e.map(a=>[a.field,a])),[e]),i=useMemo(()=>new Map(t?.map(a=>[a.name,a])||[]),[t]);return {orderedColumns:useMemo(()=>{if(!o||o.length===0||!t)return e;let a="ACTIONS",s=o.filter(u=>u!==a),p=new Set,m=[],c=u=>{let f=i.get(u);if(!f)return;let y=r.get(f.name);!y||p.has(f.name)||(m.push(y),p.add(f.name));};return s.forEach(u=>{c(u);}),t.forEach(u=>{if(u.name===a||s.includes(u.name))return;let f=r.get(u.name);!f||p.has(u.name)||(m.push(f),p.add(u.name));}),c(a),m.length===0?e:m},[e,r,i,o,t]),columnsByFieldId:r,fieldsByName:i}};function Qr(e){return e.name}var Bt=({fields:e,columnsByFieldId:t,defaultVisibleFieldNames:o,columnVisibilityStorageKey:r,onColumnVisibilityModelChange:i})=>{let n=!!r,[a,s]=a$6(r||"__dynamic-data-view:columns__",void 0,{initializeWithValue:n}),p=useMemo(()=>{if(!e)return;let c={};if(e.forEach(u=>{let f=Qr(u);if(!t.has(f))return;let y;if(n&&a){let g=a[f];typeof g=="boolean"&&(y=g);}y===void 0&&o&&o.length>0&&(y=o.includes(u.name)),typeof y=="boolean"&&(c[f]=y);}),Object.keys(c).length!==0)return {columns:{columnVisibilityModel:c}}},[t,o,e,n,a]),m=useCallback(c=>{if(n){let u={...c};delete u.__check__,s(u);}i&&i(c);},[n,i,s]);return {initialState:p,handleColumnVisibilityModelChange:m}};var w={IMAGE_WIDTH:90,MIN_WIDTH:130,ENTITY_MIN_WIDTH:100,ENTITY_FLEX:.5,ID_MIN_WIDTH:200,ID_FLEX:1,ACTIONS_WIDTH:80},De={READ_ONLY:"READ_ONLY",READ_AND_WRITE:"READ_AND_WRITE"},Vt=["price","base_price","minimum_value","maximum_value","minimum_installment_value"];var Kr=(e,t)=>({field:e.name,headerName:e.description,sortable:!1,width:w.IMAGE_WIDTH,resizable:!1,headerAlign:"center",align:"center",renderCell:o=>t(e,o.row)}),Xr=(e,t)=>({field:e.name,headerName:e.description,minWidth:w.ID_MIN_WIDTH,flex:w.ID_FLEX,renderCell:o=>t(e,o.row)}),jr=(e,t)=>({field:e.name,headerName:e.description,minWidth:w.ENTITY_MIN_WIDTH,flex:w.ENTITY_FLEX,renderCell:o=>t(e,o.row)}),Jr=(e,t)=>({field:e.name,headerName:e.description,minWidth:w.MIN_WIDTH,renderCell:o=>t(e,o.row)}),Zr=(e,t)=>({field:e.name,headerName:"A\xE7\xF5es",width:w.ACTIONS_WIDTH,sortable:!1,resizable:!1,disableReorder:!0,headerAlign:"center",disableColumnMenu:!0,align:"center",renderCell:o=>t(e,o.row)}),Wt=(e,t)=>e.name===t?.id_field_name||e.name==="name"?Xr:e.name==="ACTIONS"?Zr:e.type==="FILE"?Kr:e.type==="ENTITY"?jr:Jr;var Gt=({metadata:e,renderCell:t,columnStrategies:o})=>useMemo(()=>{if(!e?.fields)return [];let r=new Map;return e.fields.filter(n=>n.access_type===De.READ_ONLY||n.access_type===De.READ_AND_WRITE?!0:n.name==="ACTIONS"||n.name===e?.id_field_name||n.name==="NAME").forEach(n=>{if(r.has(n.name))return;let s=(o?.[n.name]??Wt(n,e))(n,t,e);r.set(n.name,s);}),Array.from(r.values())},[o,e,t]);var Ut=e=>e?.groups?.[0]?.conditionals?e.groups[0].conditionals.map(t=>({id:a$7(),operator:e.groups[0].operator,fieldName:t.fieldName,conditional:t.conditional,value:t.value})):[],Ht=({fields:e,initialFilter:t})=>{let[o,r]=useState(!1),[i,n]=useState(()=>Ut(t)),[a,s]=useState(t),[p,m]=useState(()=>Ut(t)),c=useRef([]),u=useCallback(()=>{c.current=i.map(d=>({...d})),m(i.map(d=>({...d}))),r(!0);},[i]),f=()=>r(!1),y=useCallback(()=>{let d=e.filter(x=>x.available_filter_conditions?.length>0);if(d.length===0)return;let C=p.map(x=>x.fieldName),S=d.filter(x=>!C.includes(x.filter_field_name??x.name));if(S.length===0)return;let L=p.length>0?p[0].operator:"AND",I=S[0],v={id:a$7(),operator:L,fieldName:I.filter_field_name??I.name,conditional:nt(I),value:[]};m(x=>[...x,v]);},[e,p]),g=useCallback((d,C)=>{m(S=>{let L=S.find(I=>I.id===d);if(!L)return S;if(C.operator&&C.operator!==L.operator){let I=C.operator;return S.map(v=>v.id===d?{...v,...C}:{...v,operator:I})}return S.map(I=>I.id===d?{...I,...C}:I)});},[]),N=useCallback(d=>{m(C=>C.filter(S=>S.id!==d));},[]),l=()=>{m([]),n([]),s(void 0);},R=()=>{let d=it(p);return n(p.map(C=>({...C}))),s(d),r(!1),d},_=()=>{m(c.current.map(d=>({...d}))),r(!1);},A=i.some(X),B=i.filter(X).length;return {conditions:p,filter:a,isOpen:o,hasActiveFilters:A,activeFiltersCount:B,openDrawer:u,closeDrawer:f,addCondition:y,updateCondition:g,removeCondition:N,clearAllFilters:l,applyFilters:R,cancelChanges:_}};var $t=e=>{try{let t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}},Qt=(e,t)=>{try{t===void 0?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t));}catch{}},Kt=(e,t,o)=>{let r=`${e}:filter`,[i,n]=useState(()=>$t(r)||t);useEffect(()=>{t!==void 0&&n(t);},[t]);let a=useCallback(s=>{n(s),Qt(r,s),o?.(s);},[r,o]);return {filter:i,setFilter:a}},Xt=(e,t,o)=>{let r=`${e}:sort`,[i,n]=useState(()=>$t(r)||t);useEffect(()=>{t!==void 0&&n(t);},[t]);let a=useCallback(s=>{n(s),Qt(r,s),o?.(s);},[r,o]);return {sort:i,setSort:a}};var nn=(e,t)=>e?e.find(r=>r.name===t)?.filter_field_name??t:t,an=(e,t)=>e?e.find(r=>r.filter_field_name===t||r.name===t)?.name??t:t,jt=({sort:e,onSortChange:t,fields:o})=>{let r=useMemo(()=>e?[{field:an(o,e.fieldName),sort:e.sortType.toLowerCase()}]:[],[e,o]),i=useCallback(n=>{if(!t)return;let a=n[0];if(!a||!a.sort){t(void 0);return}let s={fieldName:nn(o,a.field),sortType:a.sort.toUpperCase()};t(s);},[t,o]);return {sortModel:r,handleSortModelChange:i}};var Jt=()=>({name:"ACTIONS",description:"",filter_field_name:null,type:"TEXT",metadata:null,access_type:"READ_ONLY",relation_field_name:null,available_filter_conditions:[]}),_e=e=>e.fields.some(o=>o.name==="ACTIONS")?e:{...e,fields:[...e.fields,Jt()]};var sn=({value:e,format:t})=>e==null?"-":d(e,t),xe=memo(sn);var dn=({value:e,format:t})=>e==null?"-":c(e,t),Ee=memo(dn);var un=({value:e,field:t})=>{if(!t.metadata||typeof e!="object"||e===null)return e?String(e):"-";let o=e[t.metadata.description_field_name];return o?jsx(cn,{label:String(o),variant:"outlined",size:"small",sx:{width:"fit-content",color:"text.secondary",borderColor:"divider",borderRadius:3}}):null},Ne=memo(un);var Cn=({value:e,trueIcon:t="STAR_02",falseIcon:o="STAR",color:r="primary.main",width:i=18})=>jsx(a,{icon:e?t:o,color:r,width:i}),yn=memo(Cn);var eo=styled("span")(({theme:e,isActive:t})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:e.spacing(.2,1),borderRadius:e.shape.borderRadius,fontSize:"0.75rem",fontWeight:600,width:"fit-content",height:"auto",lineHeight:"1.25rem",whiteSpace:"nowrap",margin:"auto",backgroundColor:t?e.palette.success.lighter||"#00A76F29":e.palette.warning.lighter||"#FF563029",color:t?e.palette.success.darker||"#007867":e.palette.warning.darker||"#B71D18"})),to=styled(Z,{shouldForwardProp:e=>!["size","noImage","clickable"].includes(e)})(({theme:e,size:t,noImage:o,clickable:r})=>({width:t,height:t,minWidth:t,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",cursor:r?"pointer":"default",transition:"opacity 0.2s ease-in-out",color:e.palette.text.disabled,...o&&{border:`1px dashed ${e.palette.divider}`,backgroundColor:e.palette.grey[100]},...r&&{"&:hover":{opacity:.8}},"& img":{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"},[e.breakpoints.down("sm")]:{justifyContent:"flex-start",alignItems:"flex-start"}}));var hn=({imageResourceId:e,getImageUrl:t,size:o=48,alt:r="Imagem",onClick:i,sx:n})=>{let a$1=!!e,s=a$1&&t?t(e):void 0;return jsx(to,{size:o,noImage:!a$1,clickable:!!i,onClick:i,sx:n,children:s?jsx("img",{src:s,alt:r}):jsx(a,{icon:"SEARCH_IMAGE",width:Math.round(o/2),color:"text.disabled"})})},In=memo(hn);var Rn=({id:e,displayName:t,copyMessage:o="ID copiado!"})=>jsxs(Lt,{height:1,justifyContent:"center",children:[jsx(Fe,{variant:"subtitle2",noWrap:!0,title:t,children:t}),jsxs(Lt,{direction:"row",gap:1,alignItems:"center",children:[jsxs(Fe,{color:"grey.600",variant:"body2",noWrap:!0,children:["ID: ",e]}),jsx(a$4,{toCopy:e,message:o})]})]}),Dn=memo(Rn);var Nn=({value:e,isCurrency:t=!1})=>e==null?"-":jsx(Lt,{direction:"row",alignItems:"center",height:"100%",children:jsx(Fe,{variant:"body2",noWrap:!0,width:"fit-content",children:t?h(Number(e)):a$5(Number(e))})}),Me=memo(Nn);var vn=({active:e,activeLabel:t="Ativo",inactiveLabel:o="Inativo"})=>jsx(eo,{isActive:e,children:e?t:o}),we=memo(vn);var On=e=>e.replace(/<[^>]*>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").trim(),kn=({value:e,showCopyButton:t=!1,copyMessage:o="Copiado",copyLabel:r,mask:i})=>{if(!e)return "-";let n=String(e),a=i?i(n):On(n);return t?jsxs(Lt,{direction:"row",gap:1,alignItems:"center",children:[jsx(Fe,{variant:"body2",noWrap:!0,children:a}),jsx(a$4,{toCopy:n,message:o,label:r})]}):a},Le=memo(kn);function Vn(e){return Vt.includes(e)}var lo=e=>{let{onRowAction:t}=e,o=(r,i)=>{let n=i[r.name];if(r.name==="ACTIONS")return t?.(i.id,i);switch(r.type){case"BOOLEAN":return jsx(we,{active:!!n,activeLabel:"Ativo",inactiveLabel:"Inativo"});case"DATE":return jsx(xe,{value:n});case"DATETIME":return jsx(Ee,{value:n});case"DECIMAL":case"INTEGER":return jsx(Me,{value:n,isCurrency:Vn(r.name)});case"FILE":case"ENTITY":return jsx(Ne,{value:n,field:r});case"TEXT":default:return jsx(Le,{value:n})}};return o.displayName="CellRendererComponent",o};var Un=({title:e,metadata:t,data:o,isLoading:r,isFetching:i,page:n,perPage:a,searchValue:s,onSearchChange:p,onSearch:m,onPaginationChange:c,onAdd:u,onRowAction:f,onRowDoubleClick:y,actions:g,moreActions:N,bulkActions:l,rowSelectionModel:R,onRowSelectionModelChange:_,slots:A,mobileRender:B,containerHeight:d=600,showColumnButton:C=!1,showFilterButton:S=!1,filter:L,onFilterChange:I,sort:v,onSortChange:x,defaultVisibleFieldNames:co,preferredFieldOrder:uo,columnStrategies:fo,onColumnVisibilityModelChange:go,storageKey:le,entityFilterConfig:Co})=>{let{items:H=[],total:yo=0}=o||{},z=useMemo(()=>{if(t)return t;if(H.length>0){let M=H[0],Q=Object.keys(M).map(Ue=>({name:Ue,type:"TEXT",description:Ue,filter_field_name:null,metadata:null,access_type:"READ_ONLY",relation_field_name:null,available_filter_conditions:[]}));return {name:"loading",description:"Loading...",id_field_name:"id",description_field_name:Q[0]?.name||"id",access_type:"READ_ONLY",fields:Q}}},[t,H]),V=useMemo(()=>z&&f?_e(z):z,[z,f]),Y=useMemo(()=>V?.fields||[],[V]),bo=useMemo(()=>lo({onRowAction:f}),[f]),So=Gt({metadata:V,renderCell:bo,columnStrategies:fo}),{orderedColumns:Fo,columnsByFieldId:ho}=kt({columns:So,fields:V?.fields,preferredFieldOrder:uo}),{initialState:Io,handleColumnVisibilityModelChange:To}=Bt({fields:V?.fields,columnsByFieldId:ho,defaultVisibleFieldNames:co,columnVisibilityStorageKey:`${le}:columns`,onColumnVisibilityModelChange:go}),Ro=useCallback(M=>{if(!y)return;let Q=M.id?.toString()||"";y(Q,M.row);},[y]),q=b("down","md"),[Do,se]=useState(null),{filter:_o,setFilter:$}=Kt(le,L,I),{sort:xo,setSort:Pe}=Xt(le,v,x),Eo=L??_o,me=v??xo,{sortModel:No,handleSortModelChange:Ao}=jt({sort:me,onSortChange:Pe,fields:Y}),{conditions:vo,isOpen:Mo,openDrawer:de,closeDrawer:Oe,addCondition:wo,updateCondition:Lo,removeCondition:Po,clearAllFilters:ke,applyFilters:Be,cancelChanges:Ve,hasActiveFilters:Oo,activeFiltersCount:ko}=Ht({fields:Y,initialFilter:Eo}),Bo=useCallback(()=>{let M=Be();$(M);},[Be,$]),Vo=useCallback(()=>{ke(),$(void 0);},[ke,$]),Wo=useCallback(M=>{q?de():(de(),se(M.currentTarget));},[q,de]),Go=useCallback(()=>{Ve(),se(null);},[Ve]),[Uo,We]=useState(!1),Ho=useCallback(()=>{se(null),Oe();},[Oe]),Ge=!!l?.length;return jsxs(Fragment,{children:[jsx(d$1,{title:e,columns:Fo,rows:H,mobileRender:B,rowCount:yo,loading:r||!t,fetching:i,searchValue:s,onSearch:m,onSearchChange:p,paginationModel:{page:n,pageSize:a},onPaginationChange:c,actions:g,moreActions:N,onAdd:u,onRowDoubleClick:y?Ro:void 0,bulkActions:l,checkboxSelection:Ge,rowSelectionModel:R,onRowSelectionModelChange:_,keepNonExistentRowsSelected:Ge,disableRowSelectionOnClick:!0,slots:A,initialState:Io,showColumnButton:C,containerProps:{height:d,maxHeight:d},onColumnVisibilityModelChange:To,filterButton:jsx(ot,{showFilterButton:S,isMobile:q,hasActiveFilters:Oo,activeFiltersCount:ko,sort:me,onFilterClick:Wo,onSortClick:()=>We(!0)}),sortingMode:"server",sortModel:No,onSortModelChange:Ao,disableColumnFilter:!0}),t&&jsxs(Fragment,{children:[jsx(ht,{showFilterButton:S,isOpen:Mo,filterAnchorEl:Do,fields:Y,conditions:vo,isMobile:q,onClose:Ho,onAddCondition:wo,onUpdateCondition:Lo,onRemoveCondition:Po,onApply:Bo,onClear:Vo,onCancel:Go,entityFilterConfig:Co}),jsx(Ot,{open:Uo,onClose:()=>We(!1),fields:Y,sort:me,onSortChange:Pe})]})]})},Hn=memo(Un,$o);var zn=({metadata:e,columnVisibilityModel:t,defaultVisibleFields:o})=>{if(!e?.fields)return;let i=e.fields.map(n=>n.name).filter(n=>n==="ACTIONS"?!1:t?t[n]!==!1:o?.includes(n)??!0);return o?i.sort((n,a)=>{let s=o.indexOf(n),p=o.indexOf(a);return s-p||0}):i};
|
|
59
|
+
var Xo=({showFilterButton:e$1,isMobile:t,hasActiveFilters:o,activeFiltersCount:r,sort:n,onFilterClick:i,onSortClick:a$1})=>e$1?t?jsxs(Lt,{direction:"row",spacing:.5,children:[jsx(et,{badgeContent:r,color:"primary",invisible:r===0,sx:{"& .MuiBadge-badge":{transform:"scale(0.9) translate(10px, 9px)",opacity:r===0?0:1}},children:jsx(tt,{color:o?"primary":"default",onClick:i,size:"small","aria-label":"Filtrar",sx:{overflow:"visible"},children:jsx(a,{icon:"FILTER_VERTICAL"})})}),jsx(e,{sx:{height:16},orientation:"vertical",flexItem:!0}),jsx(tt,{color:n?"primary":"default",onClick:a$1,size:"small","aria-label":"Ordenar",children:jsx(a,{icon:n?.sortType==="DESC"?"SORTING_DESC":"SORTING_ASC"})})]}):jsx(et,{badgeContent:r,color:"primary",invisible:r===0,sx:{"& .MuiBadge-badge":r?{transform:"scale(0.9) translate(-3px, 7px)",position:"relative",opacity:1,transition:"none"}:{transition:"none",opacity:0}},children:jsx(Fe,{variant:"text",color:o?"primary":"inherit",startIcon:jsx(a,{icon:"FILTER_VERTICAL"}),onClick:i,size:"small",children:"Filtrar"})}):null,ot=memo(Xo,$o);var rt=e=>e.filter(t=>t.available_filter_conditions&&t.available_filter_conditions.length>0&&t.name!=="ACTIONS");var it=e=>{let{type:t,available_filter_conditions:o}=e;return o.length===0?"EQUALS":t==="TEXT"&&o.includes("LIKE")?"LIKE":o[0]},X=e=>e.value.length>0||e.conditional==="IS_NULL"||e.conditional==="IS_NOT_NULL",nt=e=>{if(e.length===0)return;let t=e.filter(X);if(t.length!==0)return {operator:"AND",groups:[{operator:t[0]?.operator||"AND",conditionals:t.map(o=>({fieldName:o.fieldName,conditional:o.conditional,value:o.value}))}]}};var at={["EQUALS"]:"Igual a",["NOT_EQUALS"]:"Diferente de",["LIKE"]:"Cont\xE9m",["NOT_LIKE"]:"N\xE3o cont\xE9m",["GREATER_THAN"]:"Maior que",["LESS_THAN"]:"Menor que",["GREATER_THAN_OR_EQUAL"]:"Maior ou igual a",["LESS_THAN_OR_EQUAL"]:"Menor ou igual a",["IN"]:"Em",["NOT_IN"]:"N\xE3o em",["IS_NULL"]:"\xC9 nulo",["IS_NOT_NULL"]:"N\xE3o \xE9 nulo"};var er=({config:e,metadata:t,value:o,initialLabel:r,onChange:n,disabled:i=!1})=>{let[a,,l]=a$1(!1),[d,m]=useState(""),p=a$2(d,400),{data:c,isLoading:f,isFetching:C}=e.useQuery({search:p||void 0,page:0,perPage:25,...e.queryParams},{skip:!a}),g=f||C,_=useMemo(()=>o?{value:o,label:r??o}:null,[o,r]),s=useMemo(()=>{let u=(c?.items??[]).map(y=>({label:String(y[t.description_field_name]??""),value:String(y[t.id_field_name]??"")})).filter(y=>y.value&&y.label);return _&&!u.some(y=>y.value.toString()===_.value.toString())&&u.unshift(_),u},[c,t.id_field_name,t.description_field_name,_]),R=useCallback(()=>l(!0),[l]),x=useCallback(()=>{l(!1),m("");},[l]),A=useCallback(u=>{if(!u){n("",void 0);return}let y=s.find(b=>b.value.toString()===u);n(u,y?.label);},[n,s]),B=useCallback(u=>{m(u??"");},[]);return jsx(a$3,{name:`entity-filter-${t.name}`,label:"Filtro",value:o||"",options:s,onChange:A,onSearch:B,loading:g,disabled:i,size:"small",filterOptions:u=>u,noOptionsText:d!==p?"Buscando...":"Nenhum resultado",InputLabelProps:{shrink:!0},sx:{flex:1,minWidth:120},open:a,onOpen:R,onClose:x})},st=memo(er);var ar=({value:e,onChange:t,totalConditions:o,isFirst:r})=>o===1?null:r?jsx(Lt,{sx:{width:55,flexShrink:0}}):jsxs(ye,{value:e,onChange:n=>t(n.target.value),size:"small",sx:{width:55,flexShrink:0},children:[jsx(J,{value:"AND",children:"e"}),jsx(J,{value:"OR",children:"ou"})]}),dt=memo(ar,$o);var G={whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},ur=({condition:e,fields:t,onChange:o,onRemove:r,totalConditions:n,isFirst:i,entityFilterConfig:a$1})=>{let l=useMemo(()=>t.find(s=>(s.filter_field_name??s.name)===e.fieldName),[t,e.fieldName]),d=useMemo(()=>l?.available_filter_conditions||[],[l]),m=useMemo(()=>!e.fieldName||e.conditional==="IS_NULL"||e.conditional==="IS_NOT_NULL",[e.fieldName,e.conditional]),p=useCallback(s=>{let R=t.find(A=>(A.filter_field_name??A.name)===s);if(!R)return;let x=R.available_filter_conditions[0]||"EQUALS";o({...e,fieldName:s,conditional:x,value:[]});},[t,e,o]),c=useCallback(s=>{o({...e,conditional:s});},[e,o]),f=useCallback(s=>{o({...e,value:s?[s]:[]});},[e,o]),C=useCallback((s,R)=>{let x={...e.valueLabels};s&&R&&(x[s]=R),o({...e,value:s?[s]:[],valueLabels:x});},[e,o]),g=useCallback(s=>{o({...e,operator:s});},[e,o]),_=()=>{if(l?.type==="BOOLEAN")return jsxs(ge,{size:"small",sx:{flex:1,minWidth:120},disabled:m,children:[jsx(Ce,{id:`value-label-${e.id}`,children:"Valor"}),jsxs(ye,{labelId:`value-label-${e.id}`,label:"Valor",value:e.value[0]||"",onChange:s=>f(s.target.value),size:"small",sx:{"& .MuiSelect-select":G},children:[jsx(J,{value:"true",children:"Verdadeiro"}),jsx(J,{value:"false",children:"Falso"})]})]});if(l?.type==="ENTITY"&&l.metadata&&a$1?.[l.metadata.name]){let s=e.value[0]||"";return jsx(st,{config:a$1[l.metadata.name],metadata:l.metadata,value:s,initialLabel:e.valueLabels?.[s],onChange:C,disabled:m})}return jsx(cr,{label:"Filtro",value:e.value[0]||"",onChange:s=>f(s.target.value),size:"small",disabled:m,InputLabelProps:{shrink:!0},sx:{flex:1,minWidth:120}})};return jsxs(Lt,{direction:"row",spacing:1,alignItems:"center",children:[jsx(tt,{onClick:r,size:"small","aria-label":"Remover filtro",sx:{flexShrink:0},children:jsx(a,{icon:"CLOSE_MARK_BUTTON",width:18})}),jsx(dt,{value:e.operator,onChange:g,totalConditions:n,isFirst:i}),jsxs(ge,{size:"small",sx:{minWidth:150,flex:1},children:[jsx(Ce,{id:`field-label-${e.id}`,children:"Coluna"}),jsx(ye,{labelId:`field-label-${e.id}`,label:"Coluna",value:e.fieldName,onChange:s=>p(s.target.value),size:"small",sx:{"& .MuiSelect-select":G},children:t.map(s=>jsx(J,{value:s.filter_field_name??s.name,sx:G,title:s.description||s.name,children:s.description||s.name},s.name))})]}),jsxs(ge,{size:"small",sx:{minWidth:90},disabled:!e.fieldName,children:[jsx(Ce,{id:`condition-label-${e.id}`,children:"Condi\xE7\xE3o"}),jsx(ye,{labelId:`condition-label-${e.id}`,label:"Condi\xE7\xE3o",value:e.conditional,onChange:s=>c(s.target.value),size:"small",sx:{"& .MuiSelect-select":G},children:d.map(s=>jsx(J,{value:s,sx:G,children:at[s]||s},s))})]}),_()]})},pt=memo(ur,$o);var yr=({filterableFields:e,conditions:t,onUpdateCondition:o,onRemoveCondition:r,entityFilterConfig:n})=>{let i=useCallback(m=>{o(m.id,m);},[o]),a=useCallback(m=>()=>{r(m);},[r]),l=useMemo(()=>t.map(m=>m.fieldName).filter(m=>!!m),[t]),d=useCallback(m=>e.filter(p=>!l.includes(p.name)||p.name===m),[e,l]);return e.length===0?jsx(be,{variant:"body2",color:"text.secondary",textAlign:"center",children:"Nenhum filtro dispon\xEDvel"}):t.length===0?jsxs(be,{variant:"body2",color:"text.secondary",textAlign:"center",children:["Clique em"," ",jsx(be,{component:"strong",variant:"body2",fontWeight:600,color:"text.primary",children:'"+"'})," ","para adicionar um filtro"]}):jsx(Fragment,{children:t.map((m,p)=>jsx(pt,{condition:m,fields:d(m.fieldName),onChange:i,onRemove:a(m.id),showOperator:p>0,totalConditions:t.length,isFirst:p===0,entityFilterConfig:n},m.id))})},ct=memo(yr,$o);var ut=styled(ee)({display:"flex",flexDirection:"column",height:"100%"}),ft=styled(ee)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(2,3)})),gt=styled(ee)(({theme:e})=>({flex:1,overflowY:"auto",padding:e.spacing(3),display:"flex",flexDirection:"column",gap:e.spacing(2)})),Ct=styled(ee)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(2)}));var Dr=({onClose:e,fields:t,conditions:o,onAddCondition:r,onUpdateCondition:n,onRemoveCondition:i,onApply:a$1,onClear:l,onCancel:d,entityFilterConfig:m})=>{let p=rt(t),c=o.length>0,f=useCallback(()=>{a$1(),e();},[a$1,e]),C=useCallback(()=>{l(),e();},[l,e]),g=useCallback(()=>{d();},[d]);return jsxs(ut,{children:[jsxs(ft,{children:[jsx(be,{variant:"overline",fontWeight:600,color:"text.secondary",children:"Defina as condi\xE7\xF5es para filtrar"}),jsx(tt,{onClick:r,size:"small","aria-label":"Adicionar filtro",title:"Adicionar filtro",disabled:o.length>=p.length,children:jsx(a,{icon:"SIMPLE_ADD"})})]}),jsx(yt,{}),jsx(gt,{children:jsx(ct,{filterableFields:p,conditions:o,onUpdateCondition:n,onRemoveCondition:i,entityFilterConfig:m})}),jsx(yt,{}),jsxs(Ct,{children:[jsx(Fe,{variant:"text",color:"inherit",onClick:C,children:"Limpar"}),jsxs(Lt,{direction:"row",spacing:1,children:[jsx(Fe,{variant:"outlined",color:"inherit",onClick:g,startIcon:jsx(a,{icon:"CANCEL_CIRCLE"}),children:"Cancelar"}),jsx(Fe,{variant:"contained",onClick:f,disabled:!c,startIcon:jsx(a,{icon:"SIMPLE_CHECK"}),children:"Aplicar"})]})]})]})},St=memo(Dr,$o);var Nr=e=>jsx(a$4,{open:e.open,onClose:e.onClose,anchorEl:e.anchorEl,isMobile:e.isMobileProp,popoverProps:{slotProps:{paper:{sx:{width:520,maxWidth:"calc(100vw - 24px)",maxHeight:600,mt:1}}}},drawerProps:{anchor:"right",PaperProps:{sx:{width:"100%",maxWidth:"100%",height:"100%",maxHeight:"100%",borderRadius:0}}},children:jsx(St,{...e})}),ht=memo(Nr,$o);var vr=({showFilterButton:e,isOpen:t,filterAnchorEl:o,fields:r,conditions:n,isMobile:i,onClose:a,onAddCondition:l,onUpdateCondition:d,onRemoveCondition:m,onApply:p,onClear:c,onCancel:f,entityFilterConfig:C})=>e?jsx(ht,{open:t||!!o,anchorEl:o,onClose:a,fields:r,conditions:n,onAddCondition:l,onUpdateCondition:d,onRemoveCondition:m,onApply:p,onClear:c,onCancel:f,isMobileProp:i,entityFilterConfig:C}):null,Ft=memo(vr,$o);var It=styled(Lr)(()=>({"& .MuiDialog-paper":{width:"100%"}})),Tt=styled(kr)(({theme:e})=>({borderBottom:"1px solid",borderColor:e.palette.divider,padding:e.spacing(1.5,2)})),Rt=styled(Or)(({theme:e})=>({padding:e.spacing(2)})),Dt=styled(Pr)(({theme:e})=>({borderTop:"1px solid",borderColor:e.palette.divider,padding:e.spacing(1.5,2)})),_t=styled(Fe)(({theme:e})=>({minWidth:24,[e.breakpoints.down(330)]:{padding:e.spacing(1)}})),Ie=styled(be)(({theme:e})=>({fontWeight:"600",margin:e.spacing(0,1),[e.breakpoints.down(330)]:{fontSize:0,margin:0}}));var Pt=({open:e,onClose:t,fields:o,sort:r,onSortChange:n})=>{let[i,a$1]=useState(r?.fieldName||""),[l,d]=useState(r?.sortType||"ASC"),m=useMemo(()=>o.filter(g=>g.name!=="ACTIONS"&&g.access_type!=="WRITE_ONLY"),[o]),p=useMemo(()=>o.find(g=>(g.filter_field_name??g.name)===i),[o,i]),c=p?.type==="DECIMAL"||p?.type==="INTEGER";useEffect(()=>{e&&(a$1(r?.fieldName||""),d(r?.sortType||"ASC"));},[e,r]);let f=useCallback(()=>{n&&n(i?{fieldName:i,sortType:l}:void 0),t();},[n,i,l,t]),C=useCallback(()=>{n&&(a$1(""),d("ASC"),n(void 0),t());},[n,t]);return jsxs(It,{open:e,onClose:t,maxWidth:"xs",fullWidth:!0,children:[jsx(Tt,{children:jsx(be,{variant:"overline",color:"text.secondary",children:"Ordenar por"})}),jsx(Rt,{children:jsxs(Lt,{spacing:2,pt:2,children:[jsxs(ge,{fullWidth:!0,size:"small",children:[jsx(Ce,{id:"sort-field-label",children:"Campo"}),jsxs(ye,{labelId:"sort-field-label",value:i,label:"Campo",onChange:g=>a$1(g.target.value),children:[jsx(J,{value:"",children:jsx("em",{children:"Nenhum"})}),m.map(g=>jsx(J,{value:g.filter_field_name??g.name,children:g.description||g.name},g.name))]})]}),jsxs(ge,{fullWidth:!0,size:"small",disabled:!i,children:[jsx(Ce,{id:"sort-direction-label",children:"Dire\xE7\xE3o"}),jsxs(ye,{labelId:"sort-direction-label",value:l,label:"Dire\xE7\xE3o",onChange:g=>d(g.target.value),children:[jsxs(J,{value:"ASC",children:["Crescente ",c?"(1-9)":"(A-Z)"]}),jsxs(J,{value:"DESC",children:["Decrescente ",c?"(9-1)":"(Z-A)"]})]})]})]})}),jsxs(Dt,{children:[jsx(Lt,{flex:1,width:"100%",direction:"row",children:jsx(Fe,{color:"inherit",onClick:C,children:"Limpar"})}),jsxs(Fe,{onClick:t,variant:"outlined",color:"inherit",sx:{minWidth:24},children:[jsx(a,{icon:"CANCEL_CIRCLE"}),jsx(Ie,{children:"Cancelar"})]}),jsxs(_t,{onClick:f,variant:"contained",children:[jsx(a,{icon:"SIMPLE_CHECK"}),jsx(Ie,{children:"Aplicar"})]})]})]})};Pt.displayName="SortModal";var Ot=memo(Pt);var kt=({columns:e,fields:t,preferredFieldOrder:o})=>{let r=useMemo(()=>new Map(e.map(a=>[a.field,a])),[e]),n=useMemo(()=>new Map(t?.map(a=>[a.name,a])||[]),[t]);return {orderedColumns:useMemo(()=>{if(!o||o.length===0||!t)return e;let a="ACTIONS",l=o.filter(c=>c!==a),d=new Set,m=[],p=c=>{let f=n.get(c);if(!f)return;let C=r.get(f.name);!C||d.has(f.name)||(m.push(C),d.add(f.name));};return l.forEach(c=>{p(c);}),t.forEach(c=>{if(c.name===a||l.includes(c.name))return;let f=r.get(c.name);!f||d.has(c.name)||(m.push(f),d.add(c.name));}),p(a),m.length===0?e:m},[e,r,n,o,t]),columnsByFieldId:r,fieldsByName:n}};function zr(e){return e.name}var Bt=({fields:e,columnsByFieldId:t,defaultVisibleFieldNames:o,columnVisibilityStorageKey:r,onColumnVisibilityModelChange:n})=>{let i=!!r,[a,l]=a$7(r||"__dynamic-data-view:columns__",void 0,{initializeWithValue:i}),d=useMemo(()=>{if(!e)return;let p={};if(e.forEach(c=>{let f=zr(c);if(!t.has(f))return;let C;if(i&&a){let g=a[f];typeof g=="boolean"&&(C=g);}C===void 0&&o&&o.length>0&&(C=o.includes(c.name)),typeof C=="boolean"&&(p[f]=C);}),Object.keys(p).length!==0)return {columns:{columnVisibilityModel:p}}},[t,o,e,i,a]),m=useCallback(p=>{if(i){let c={...p};delete c.__check__,l(c);}n&&n(p);},[i,n,l]);return {initialState:d,handleColumnVisibilityModelChange:m}};var w={IMAGE_WIDTH:90,MIN_WIDTH:130,ENTITY_MIN_WIDTH:100,ENTITY_FLEX:.5,ID_MIN_WIDTH:200,ID_FLEX:1,ACTIONS_WIDTH:80},Re={READ_ONLY:"READ_ONLY",READ_AND_WRITE:"READ_AND_WRITE"},Wt=["price","base_price","minimum_value","maximum_value","minimum_installment_value"];var Yr=(e,t)=>({field:e.name,headerName:e.description,sortable:!1,width:w.IMAGE_WIDTH,resizable:!1,headerAlign:"center",align:"center",renderCell:o=>t(e,o.row)}),qr=(e,t)=>({field:e.name,headerName:e.description,minWidth:w.ID_MIN_WIDTH,flex:w.ID_FLEX,renderCell:o=>t(e,o.row)}),$r=(e,t)=>({field:e.name,headerName:e.description,minWidth:w.ENTITY_MIN_WIDTH,flex:w.ENTITY_FLEX,renderCell:o=>t(e,o.row)}),Qr=(e,t)=>({field:e.name,headerName:e.description,minWidth:w.MIN_WIDTH,renderCell:o=>t(e,o.row)}),Kr=(e,t)=>({field:e.name,headerName:"A\xE7\xF5es",width:w.ACTIONS_WIDTH,sortable:!1,resizable:!1,disableReorder:!0,headerAlign:"center",disableColumnMenu:!0,align:"center",renderCell:o=>t(e,o.row)}),Vt=(e,t)=>e.name===t?.id_field_name||e.name==="name"?qr:e.name==="ACTIONS"?Kr:e.type==="FILE"?Yr:e.type==="ENTITY"?$r:Qr;var Gt=({metadata:e,renderCell:t,columnStrategies:o})=>useMemo(()=>{if(!e?.fields)return [];let r=new Map;return e.fields.filter(i=>i.access_type===Re.READ_ONLY||i.access_type===Re.READ_AND_WRITE?!0:i.name==="ACTIONS"||i.name===e?.id_field_name||i.name==="NAME").forEach(i=>{if(r.has(i.name))return;let l=(o?.[i.name]??Vt(i,e))(i,t,e);r.set(i.name,l);}),Array.from(r.values())},[o,e,t]);var Ut=e=>e?.groups?.[0]?.conditionals?e.groups[0].conditionals.map(t=>({id:a$8(),operator:e.groups[0].operator,fieldName:t.fieldName,conditional:t.conditional,value:t.value})):[],Ht=({fields:e,initialFilter:t})=>{let[o,r]=useState(!1),[n,i]=useState(()=>Ut(t)),[a,l]=useState(t),[d,m]=useState(()=>Ut(t)),p=useRef([]),c=useCallback(()=>{p.current=n.map(u=>({...u})),m(n.map(u=>({...u}))),r(!0);},[n]),f=()=>r(!1),C=useCallback(()=>{let u=e.filter(N=>N.available_filter_conditions?.length>0);if(u.length===0)return;let y=d.map(N=>N.fieldName),b=u.filter(N=>!y.includes(N.filter_field_name??N.name));if(b.length===0)return;let L=d.length>0?d[0].operator:"AND",I=b[0],v={id:a$8(),operator:L,fieldName:I.filter_field_name??I.name,conditional:it(I),value:[]};m(N=>[...N,v]);},[e,d]),g=useCallback((u,y)=>{m(b=>{let L=b.find(I=>I.id===u);if(!L)return b;if(y.operator&&y.operator!==L.operator){let I=y.operator;return b.map(v=>v.id===u?{...v,...y}:{...v,operator:I})}return b.map(I=>I.id===u?{...I,...y}:I)});},[]),_=useCallback(u=>{m(y=>y.filter(b=>b.id!==u));},[]),s=()=>{m([]),i([]),l(void 0);},R=()=>{let u=nt(d);return i(d.map(y=>({...y}))),l(u),r(!1),u},x=()=>{m(p.current.map(u=>({...u}))),r(!1);},A=n.some(X),B=n.filter(X).length;return {conditions:d,filter:a,isOpen:o,hasActiveFilters:A,activeFiltersCount:B,openDrawer:c,closeDrawer:f,addCondition:C,updateCondition:g,removeCondition:_,clearAllFilters:s,applyFilters:R,cancelChanges:x}};var $t=e=>{try{let t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}},Qt=(e,t)=>{try{t===void 0?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t));}catch{}},Kt=(e,t,o)=>{let r=`${e}:filter`,[n,i]=useState(()=>$t(r)||t);useEffect(()=>{t!==void 0&&i(t);},[t]);let a=useCallback(l=>{i(l),Qt(r,l),o?.(l);},[r,o]);return {filter:n,setFilter:a}},Xt=(e,t,o)=>{let r=`${e}:sort`,[n,i]=useState(()=>$t(r)||t);useEffect(()=>{t!==void 0&&i(t);},[t]);let a=useCallback(l=>{i(l),Qt(r,l),o?.(l);},[r,o]);return {sort:n,setSort:a}};var ei=(e,t)=>e?e.find(r=>r.name===t)?.filter_field_name??t:t,ti=(e,t)=>e?e.find(r=>r.filter_field_name===t||r.name===t)?.name??t:t,jt=({sort:e,onSortChange:t,fields:o})=>{let r=useMemo(()=>e?[{field:ti(o,e.fieldName),sort:e.sortType.toLowerCase()}]:[],[e,o]),n=useCallback(i=>{if(!t)return;let a=i[0];if(!a||!a.sort){t(void 0);return}let l={fieldName:ei(o,a.field),sortType:a.sort.toUpperCase()};t(l);},[t,o]);return {sortModel:r,handleSortModelChange:n}};var Jt=()=>({name:"ACTIONS",description:"",filter_field_name:null,type:"TEXT",metadata:null,access_type:"READ_ONLY",relation_field_name:null,available_filter_conditions:[]}),De=e=>e.fields.some(o=>o.name==="ACTIONS")?e:{...e,fields:[...e.fields,Jt()]};var ri=({value:e,format:t})=>e==null?"-":d(e,t),_e=memo(ri);var ni=({value:e,format:t})=>e==null?"-":c(e,t),xe=memo(ni);var si=({value:e,field:t})=>{if(!t.metadata||typeof e!="object"||e===null)return e?String(e):"-";let o=e[t.metadata.description_field_name];return o?jsx(li,{label:String(o),variant:"outlined",size:"small",sx:{width:"fit-content",color:"text.secondary",borderColor:"divider",borderRadius:3}}):null},Ne=memo(si);var pi=({value:e,trueIcon:t="STAR_02",falseIcon:o="STAR",color:r="primary.main",width:n=18})=>jsx(a,{icon:e?t:o,color:r,width:n}),ci=memo(pi);var eo=styled("span")(({theme:e,isActive:t})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:e.spacing(.2,1),borderRadius:e.shape.borderRadius,fontSize:"0.75rem",fontWeight:600,width:"fit-content",height:"auto",lineHeight:"1.25rem",whiteSpace:"nowrap",margin:"auto",backgroundColor:t?e.palette.success.lighter||"#00A76F29":e.palette.warning.lighter||"#FF563029",color:t?e.palette.success.darker||"#007867":e.palette.warning.darker||"#B71D18"})),to=styled(ee,{shouldForwardProp:e=>!["size","noImage","clickable"].includes(e)})(({theme:e,size:t,noImage:o,clickable:r})=>({width:t,height:t,minWidth:t,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",cursor:r?"pointer":"default",transition:"opacity 0.2s ease-in-out",color:e.palette.text.disabled,...o&&{border:`1px dashed ${e.palette.divider}`,backgroundColor:e.palette.grey[100]},...r&&{"&:hover":{opacity:.8}},"& img":{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"},[e.breakpoints.down("sm")]:{justifyContent:"flex-start",alignItems:"flex-start"}}));var Ci=({imageResourceId:e,getImageUrl:t,size:o=48,alt:r="Imagem",onClick:n,sx:i})=>{let a$1=!!e,l=a$1&&t?t(e):void 0;return jsx(to,{size:o,noImage:!a$1,clickable:!!n,onClick:n,sx:i,children:l?jsx("img",{src:l,alt:r}):jsx(a,{icon:"SEARCH_IMAGE",width:Math.round(o/2),color:"text.disabled"})})},yi=memo(Ci);var bi=({id:e,displayName:t,copyMessage:o="ID copiado!"})=>jsxs(Lt,{height:1,justifyContent:"center",children:[jsx(be,{variant:"subtitle2",noWrap:!0,title:t,children:t}),jsxs(Lt,{direction:"row",gap:1,alignItems:"center",children:[jsxs(be,{color:"grey.600",variant:"body2",noWrap:!0,children:["ID: ",e]}),jsx(a$5,{toCopy:e,message:o})]})]}),hi=memo(bi);var Ri=({value:e,isCurrency:t=!1})=>e==null?"-":jsx(Lt,{direction:"row",alignItems:"center",height:"100%",children:jsx(be,{variant:"body2",noWrap:!0,width:"fit-content",children:t?h(Number(e)):a$6(Number(e))})}),ve=memo(Ri);var _i=({active:e,activeLabel:t="Ativo",inactiveLabel:o="Inativo"})=>jsx(eo,{isActive:e,children:e?t:o}),Me=memo(_i);var vi=e=>e.replace(/<[^>]*>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").trim(),Mi=({value:e,showCopyButton:t=!1,copyMessage:o="Copiado",copyLabel:r,mask:n})=>{if(!e)return "-";let i=String(e),a=n?n(i):vi(i);return t?jsxs(Lt,{direction:"row",gap:1,alignItems:"center",children:[jsx(be,{variant:"body2",noWrap:!0,children:a}),jsx(a$5,{toCopy:i,message:o,label:r})]}):a},we=memo(Mi);function Li(e){return Wt.includes(e)}var lo=e=>{let{onRowAction:t}=e,o=(r,n)=>{let i=n[r.name];if(r.name==="ACTIONS")return t?.(n.id,n);switch(r.type){case"BOOLEAN":return jsx(Me,{active:!!i,activeLabel:"Ativo",inactiveLabel:"Inativo"});case"DATE":return jsx(_e,{value:i});case"DATETIME":return jsx(xe,{value:i});case"DECIMAL":case"INTEGER":return jsx(ve,{value:i,isCurrency:Li(r.name)});case"FILE":case"ENTITY":return jsx(Ne,{value:i,field:r});case"TEXT":default:return jsx(we,{value:i})}};return o.displayName="CellRendererComponent",o};var ki=({title:e,metadata:t,data:o,isLoading:r,isFetching:n,page:i,perPage:a,searchValue:l,onSearchChange:d,onSearch:m,onPaginationChange:p,onAdd:c,onRowAction:f,onRowDoubleClick:C,actions:g,moreActions:_,bulkActions:s,rowSelectionModel:R,onRowSelectionModelChange:x,slots:A,mobileRender:B,containerHeight:u=600,showColumnButton:y=!1,showFilterButton:b$1=!1,filter:L,onFilterChange:I,sort:v,onSortChange:N,defaultVisibleFieldNames:co,preferredFieldOrder:uo,columnStrategies:fo,onColumnVisibilityModelChange:go,storageKey:se,entityFilterConfig:Co})=>{let{items:H=[],total:yo=0}=o||{},z=useMemo(()=>{if(t)return t;if(H.length>0){let M=H[0],Q=Object.keys(M).map(Ge=>({name:Ge,type:"TEXT",description:Ge,filter_field_name:null,metadata:null,access_type:"READ_ONLY",relation_field_name:null,available_filter_conditions:[]}));return {name:"loading",description:"Loading...",id_field_name:"id",description_field_name:Q[0]?.name||"id",access_type:"READ_ONLY",fields:Q}}},[t,H]),W=useMemo(()=>z&&f?De(z):z,[z,f]),Y=useMemo(()=>W?.fields||[],[W]),So=useMemo(()=>lo({onRowAction:f}),[f]),bo=Gt({metadata:W,renderCell:So,columnStrategies:fo}),{orderedColumns:ho,columnsByFieldId:Fo}=kt({columns:bo,fields:W?.fields,preferredFieldOrder:uo}),{initialState:Io,handleColumnVisibilityModelChange:To}=Bt({fields:W?.fields,columnsByFieldId:Fo,defaultVisibleFieldNames:co,columnVisibilityStorageKey:`${se}:columns`,onColumnVisibilityModelChange:go}),Ro=useCallback(M=>{if(!C)return;let Q=M.id?.toString()||"";C(Q,M.row);},[C]),q=b("down","md"),[Do,me]=useState(null),{filter:_o,setFilter:$}=Kt(se,L,I),{sort:xo,setSort:Le}=Xt(se,v,N),No=L??_o,de=v??xo,{sortModel:Eo,handleSortModelChange:Ao}=jt({sort:de,onSortChange:Le,fields:Y}),{conditions:vo,isOpen:Mo,openDrawer:pe,closeDrawer:Pe,addCondition:wo,updateCondition:Lo,removeCondition:Po,clearAllFilters:Oe,applyFilters:ke,cancelChanges:Be,hasActiveFilters:Oo,activeFiltersCount:ko}=Ht({fields:Y,initialFilter:No}),Bo=useCallback(()=>{let M=ke();$(M);},[ke,$]),Wo=useCallback(()=>{Oe(),$(void 0);},[Oe,$]),Vo=useCallback(M=>{q?pe():(pe(),me(M.currentTarget));},[q,pe]),Go=useCallback(()=>{Be(),me(null);},[Be]),[Uo,We]=useState(!1),Ho=useCallback(()=>{me(null),Pe();},[Pe]),Ve=!!s?.length;return jsxs(Fragment,{children:[jsx(d$1,{title:e,columns:ho,rows:H,mobileRender:B,rowCount:yo,loading:r||!t,fetching:n,searchValue:l,onSearch:m,onSearchChange:d,paginationModel:{page:i,pageSize:a},onPaginationChange:p,actions:g,moreActions:_,onAdd:c,onRowDoubleClick:C?Ro:void 0,bulkActions:s,checkboxSelection:Ve,rowSelectionModel:R,onRowSelectionModelChange:x,keepNonExistentRowsSelected:Ve,disableRowSelectionOnClick:!0,slots:A,initialState:Io,showColumnButton:y,containerProps:{height:u,maxHeight:u},onColumnVisibilityModelChange:To,filterButton:jsx(ot,{showFilterButton:b$1,isMobile:q,hasActiveFilters:Oo,activeFiltersCount:ko,sort:de,onFilterClick:Vo,onSortClick:()=>We(!0)}),sortingMode:"server",sortModel:Eo,onSortModelChange:Ao,disableColumnFilter:!0}),t&&jsxs(Fragment,{children:[jsx(Ft,{showFilterButton:b$1,isOpen:Mo,filterAnchorEl:Do,fields:Y,conditions:vo,isMobile:q,onClose:Ho,onAddCondition:wo,onUpdateCondition:Lo,onRemoveCondition:Po,onApply:Bo,onClear:Wo,onCancel:Go,entityFilterConfig:Co}),jsx(Ot,{open:Uo,onClose:()=>We(!1),fields:Y,sort:de,onSortChange:Le})]})]})},Bi=memo(ki,$o);var Wi=({metadata:e,columnVisibilityModel:t,defaultVisibleFields:o})=>{if(!e?.fields)return;let n=e.fields.map(i=>i.name).filter(i=>i==="ACTIONS"?!1:t?t[i]!==!1:o?.includes(i)??!0);return o?n.sort((i,a)=>{let l=o.indexOf(i),d=o.indexOf(a);return l-d||0}):n};
|
|
61
60
|
|
|
62
|
-
export {
|
|
61
|
+
export { _e as DateRenderer, xe as DateTimeRenderer, Ne as EntityRenderer, ci as IconRenderer, yi as ImageRenderer, hi as NameRenderer, ve as NumberRenderer, Me as StatusRenderer, we as TextRenderer, De as addActionsFieldToMetadata, Wi as buildVisibleFields, Jt as createActionsField, Bi as default };
|
|
63
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DynamicDataView/DynamicDataView.tsx","../../../src/components/DynamicDataView/components/FilterButton.tsx","../../../src/components/DynamicDataView/components/FiltersSection.tsx","../../../src/components/DynamicDataView/components/filters/FiltersContainer.tsx","../../../src/components/DynamicDataView/components/filters/FiltersContent.tsx","../../../src/components/DynamicDataView/utils/filter.ts","../../../src/components/DynamicDataView/components/filters/FiltersList.tsx","../../../src/components/DynamicDataView/components/filters/FilterRow.tsx","../../../src/components/DynamicDataView/constants/filter.ts","../../../src/components/DynamicDataView/components/filters/EntityFilterAutocomplete.tsx","../../../src/components/DynamicDataView/components/filters/OperatorSelect.tsx","../../../src/components/DynamicDataView/components/filters/styles.ts","../../../src/components/DynamicDataView/components/SortModal/index.tsx","../../../src/components/DynamicDataView/components/SortModal/style.ts","../../../src/components/DynamicDataView/hooks/useColumnOrdering.ts","../../../src/components/DynamicDataView/hooks/useColumnVisibility.ts","../../../src/components/DynamicDataView/hooks/useDynamicColumns.ts","../../../src/components/DynamicDataView/constants/columnDefaults.ts","../../../src/components/DynamicDataView/utils/columnStrategies.ts","../../../src/components/DynamicDataView/hooks/useFilters.ts","../../../src/components/DynamicDataView/hooks/useFilterSortStorage.ts","../../../src/components/DynamicDataView/hooks/useSorting.ts","../../../src/components/DynamicDataView/utils/addActionsField.ts","../../../src/components/DynamicDataView/renderers/DateRenderer.ts","../../../src/components/DynamicDataView/renderers/DateTimeRenderer.ts","../../../src/components/DynamicDataView/renderers/EntityRenderer.tsx","../../../src/components/DynamicDataView/renderers/IconRenderer.tsx","../../../src/components/DynamicDataView/renderers/ImageRenderer.tsx","../../../src/components/DynamicDataView/renderers/style.ts","../../../src/components/DynamicDataView/renderers/NameRenderer.tsx","../../../src/components/DynamicDataView/renderers/NumberRenderer.tsx","../../../src/components/DynamicDataView/renderers/StatusRenderer.tsx","../../../src/components/DynamicDataView/renderers/TextRenderer.tsx","../../../src/components/DynamicDataView/utils/createCellRenderer.tsx","../../../src/components/DynamicDataView/utils/fields.ts"],"names":["memo","useCallback","useMemo","useState","isEqual","Badge","Button","IconButton","Stack","jsx","jsxs","FilterButton","showFilterButton","isMobile","hasActiveFilters","activeFiltersCount","sort","onFilterClick","onSortClick","Icon_default","ToolbarActionsDivider","FilterButton_default","Divider","Typography","getFilterableFields","fields","field","getDefaultCondition","type","available_filter_conditions","isValidCondition","condition","buildFilterFromConditions","conditions","validConditions","c","FormControl","InputLabel","MenuItem","Select","TextField","CONDITION_LABELS","Autocomplete","CircularProgress","Fragment","EntityFilterAutocomplete","config","metadata","value","initialLabel","onChange","disabled","open","toggleOpen","setOpen","useToggle_default","inputValue","setInputValue","debouncedSearch","useDebounceValue_default","data","isLoading","isFetching","loading","selectedOption","options","items","item","opt","handleClose","handleChange","_event","option","handleInputChange","newInputValue","reason","val","x","params","EntityFilterAutocomplete_default","OperatorSelect","totalConditions","isFirst","e","OperatorSelect_default","ellipsisStyle","FilterRow","onRemove","entityFilterConfig","selectedField","f","availableConditions","isValueDisabled","handleFieldChange","fieldName","newField","defaultCondition","handleConditionChange","conditional","handleValueChange","handleEntityValueChange","label","valueLabels","handleOperatorChange","operator","renderValueInput","currentValue","cond","FilterRow_default","FiltersList","filterableFields","onUpdateCondition","onRemoveCondition","handleUpdateCondition","updated","handleRemoveCondition","id","usedFieldNames","name","getAvailableFields","currentFieldName","index","FiltersList_default","Box","styled","Container","Header","theme","Content","Footer","FiltersContent","onClose","onAddCondition","onApply","onClear","onCancel","hasConditions","handleApply","handleClear","handleCancel","FiltersContent_default","FiltersContainer","props","ResponsivePopover_default","FiltersContainer_default","FiltersSection","isOpen","filterAnchorEl","FiltersSection_default","useEffect","Dialog","DialogActions","DialogContent","DialogTitle","StyledDialog","StyledDialogTitle","StyledDialogContent","StyledDialogActions","ApplyButton","LabelButton","SortModal","onSortChange","setSelectedField","selectedDirection","setSelectedDirection","sortableFields","selectedFieldObj","isNumberField","SortModal_default","useColumnOrdering","columns","preferredFieldOrder","columnsByFieldId","column","fieldsByName","actionFieldName","preferredWithoutActions","usedColumnFieldIds","ordered","pushColumnForField","getColumnFieldIdFromField","useColumnVisibility","defaultVisibleFieldNames","columnVisibilityStorageKey","onColumnVisibilityModelChange","hasStorageKey","storedVisibilityModel","setStoredVisibilityModel","useLocalStorage_default","initialState","visibilityModel","columnFieldId","visible","stored","handleColumnVisibilityModelChange","model","modelToSave","COLUMN_DEFAULTS","ACCESS_TYPES","CURRENCY_FIELD_NAMES","createImageColumn","renderCell","createIdColumn","createEntityColumn","createDefaultColumn","createActionsColumn","getColumnStrategy","useDynamicColumns","columnStrategies","columnsMap","useRef","parseInitialConditions","initialFilter","uuidv4","useFilters","setIsOpen","appliedConditions","setAppliedConditions","appliedFilter","setAppliedFilter","setConditions","snapshotRef","openDrawer","closeDrawer","addCondition","availableFields","currentOperator","firstField","newCondition","prev","updateCondition","changes","targetCondition","newOperator","removeCondition","clearAllFilters","applyFilters","filter","cancelChanges","getStoredValue","key","setStoredValue","useFilterStorage","storageKey","externalFilter","onFilterChange","filterKey","internalFilter","setInternalFilter","handleFilterChange","newFilter","useSortStorage","externalSort","sortKey","internalSort","setInternalSort","handleSortChange","newSort","resolveApiFieldName","resolveColumnFieldName","useSorting","sortModel","handleSortModelChange","firstItem","createActionsField","addActionsFieldToMetadata","DateRenderer","format","fDate","DateRenderer_default","DateTimeRenderer","fDateTime","DateTimeRenderer_default","Chip","EntityRenderer","entityValue","EntityRenderer_default","IconRenderer","trueIcon","falseIcon","color","width","IconRenderer_default","StatusLabel","isActive","ImageContainer","prop","size","noImage","clickable","ImageRenderer","imageResourceId","getImageUrl","alt","onClick","sx","hasImage","imageUrl","ImageRenderer_default","NameRenderer","displayName","copyMessage","CopyButton_default","NameRenderer_default","NumberRenderer","isCurrency","fCurrencyBRL","fNumber","NumberRenderer_default","StatusRenderer","active","activeLabel","inactiveLabel","StatusRenderer_default","sanitizeHtml","text","TextRenderer","showCopyButton","copyLabel","mask","stringValue","formattedValue","TextRenderer_default","getIsCurrency","createCellRenderer","context","onRowAction","CellRendererComponent","row","DynamicDataView","title","page","perPage","searchValue","onSearchChange","onSearch","onPaginationChange","onAdd","onRowDoubleClick","actions","moreActions","bulkActions","rowSelectionModel","onRowSelectionModelChange","slots","mobileRender","containerHeight","showColumnButton","rows","total","preloadedMetadata","firstRow","effectiveMetadata","effectiveMetadataFields","orderedColumns","handleRowDoubleClick","rowId","useResponsive_default","setFilterAnchorEl","storedFilter","setStoredFilter","storedSort","setStoredSort","effectiveFilter","effectiveSort","handleApplyFilters","handleClearFilters","handleFilterButtonClick","event","handleCancelFilters","isSortModalOpen","setIsSortModalOpen","handleFiltersClose","hasSelectionActions","DataView_default","DynamicDataView_default","buildVisibleFields","columnVisibilityModel","defaultVisibleFields","a","b","indexA","indexB"],"mappings":"+xCAAA,OAAS,QAAAA,GAAM,eAAAC,EAAa,WAAAC,GAAS,YAAAC,OAAgB,QACrD,OAAOC,OAAa,qBCDpB,OAAS,QAAAJ,OAAY,QACrB,OAAOI,OAAa,qBACpB,OAAOC,OAAW,sBAClB,OAAOC,OAAY,uBACnB,OAAOC,OAAgB,2BACvB,OAAOC,OAAW,sBAoBZ,OAmBM,OAAAC,EAnBN,QAAAC,OAAA,oBAbN,IAAMC,GAAe,CAAC,CACpB,iBAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,mBAAAC,EACA,KAAAC,EACA,cAAAC,EACA,YAAAC,CACF,IACON,EAEDC,EAEAH,GAACF,GAAA,CAAM,UAAU,MAAM,QAAS,GAC9B,UAAAC,EAACJ,GAAA,CACC,aAAcU,EACd,MAAM,UACN,UAAWA,IAAuB,EAClC,GAAI,CACF,oBAAqB,CACnB,UAAW,kCACX,QAASA,IAAuB,EAAI,EAAI,CAC1C,CACF,EAEA,SAAAN,EAACF,GAAA,CACC,MAAOO,EAAmB,UAAY,UACtC,QAASG,EACT,KAAK,QACL,aAAW,UACX,GAAI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,EAClB,OAAQsI,GACR,eAAgBC,GAChB,OAAQ8M,EACR,WAAYhU,GACZ,SAAUpB,EACV,QAASuW,GACT,eAAgBpJ,GAChB,kBAAmBM,GACnB,kBAAmBI,GACnB,QAASmI,GACT,QAASC,GACT,SAAUG,GACV,mBAAoBzR,GACtB,EAEA/E,GAAC+J,GAAA,CACC,KAAM0M,GACN,QAAS,IAAMC,GAAmB,EAAK,EACvC,OAAQlB,EACR,KAAMW,GACN,aAAcF,GAChB,GACF,GAEJ,CAEJ,EAEOa,GAAQvX,GAAKyU,GAAiBrU,EAAO,EkCxSrC,IAAMoX,GAAqB,CAAC,CACjC,SAAAzU,EACA,sBAAA0U,EACA,qBAAAC,CACF,IAAsD,CACpD,GAAI,CAAC3U,GAAU,OAAQ,OAIvB,IAAMiJ,EAFYjJ,EAAS,OAAO,IAAI2C,GAAKA,EAAE,IAAI,EAEvB,OAAOI,GAC3BA,IAAc,UAAkB,GAEhC2R,EACKA,EAAsB3R,CAAS,IAAM,GAGvC4R,GAAsB,SAAS5R,CAAS,GAAK,EACrD,EAED,OAAK4R,EAEE1L,EAAQ,KAAK,CAAC2L,EAAGC,IAAM,CAC5B,IAAMC,EAASH,EAAqB,QAAQC,CAAC,EACvCG,EAASJ,EAAqB,QAAQE,CAAC,EAE7C,OAAOC,EAASC,GAAU,CAC5B,CAAC,EAPiC9L,CAQpC","sourcesContent":["import { memo, useCallback, useMemo, useState } from 'react';\nimport isEqual from 'react-fast-compare';\nimport { AccessType, DataType } from 'model/entity-metadata';\n\nimport useResponsive from 'hooks/useResponsive';\n\nimport DataView from '../DataView';\n\nimport FilterButton from './components/FilterButton';\nimport FiltersSection from './components/FiltersSection';\nimport SortModal from './components/SortModal';\nimport { useColumnOrdering } from './hooks/useColumnOrdering';\nimport { useColumnVisibility } from './hooks/useColumnVisibility';\nimport { useDynamicColumns } from './hooks/useDynamicColumns';\nimport { useFilters } from './hooks/useFilters';\nimport { useFilterStorage, useSortStorage } from './hooks/useFilterSortStorage';\nimport { useSorting } from './hooks/useSorting';\nimport { addActionsFieldToMetadata } from './utils/addActionsField';\nimport { createCellRenderer } from './utils/createCellRenderer';\nimport { DynamicDataViewProps, DynamicRowData } from './props';\n\nconst DynamicDataView = <T extends object = object>({\n title,\n metadata,\n data,\n isLoading,\n isFetching,\n page,\n perPage,\n searchValue,\n onSearchChange,\n onSearch,\n onPaginationChange,\n onAdd,\n onRowAction,\n onRowDoubleClick,\n actions,\n moreActions,\n bulkActions,\n rowSelectionModel,\n onRowSelectionModelChange,\n slots,\n mobileRender,\n containerHeight = 600,\n showColumnButton = false,\n showFilterButton = false,\n filter,\n onFilterChange,\n sort,\n onSortChange,\n defaultVisibleFieldNames,\n preferredFieldOrder,\n columnStrategies,\n onColumnVisibilityModelChange,\n storageKey,\n entityFilterConfig,\n}: DynamicDataViewProps<T>) => {\n const { items: rows = [], total = 0 } = data || {};\n\n // Criar metadata temporário baseado em data quando metadata não disponível\n const preloadedMetadata = useMemo(() => {\n if (metadata) return metadata;\n\n // Se não tem metadata mas tem dados, criar metadata baseado nas keys do primeiro item\n if (rows.length > 0) {\n const firstRow = rows[0];\n const fields = Object.keys(firstRow).map(key => ({\n name: key,\n type: DataType.TEXT,\n description: key,\n filter_field_name: null,\n metadata: null,\n access_type: AccessType.READ_ONLY,\n relation_field_name: null,\n available_filter_conditions: [],\n }));\n\n return {\n name: 'loading',\n description: 'Loading...',\n id_field_name: 'id',\n description_field_name: fields[0]?.name || 'id',\n access_type: AccessType.READ_ONLY,\n fields,\n };\n }\n\n return undefined;\n }, [metadata, rows]);\n\n const effectiveMetadata = useMemo(\n () =>\n preloadedMetadata && onRowAction\n ? addActionsFieldToMetadata(preloadedMetadata)\n : preloadedMetadata,\n [preloadedMetadata, onRowAction],\n );\n\n const effectiveMetadataFields = useMemo(\n () => effectiveMetadata?.fields || [],\n [effectiveMetadata],\n );\n\n const renderCell = useMemo(\n () =>\n createCellRenderer<T>({\n onRowAction,\n }),\n [onRowAction],\n );\n\n const columns = useDynamicColumns<T>({\n metadata: effectiveMetadata,\n renderCell,\n columnStrategies,\n });\n\n const { orderedColumns, columnsByFieldId } = useColumnOrdering({\n columns,\n fields: effectiveMetadata?.fields,\n preferredFieldOrder,\n });\n\n const { initialState, handleColumnVisibilityModelChange } =\n useColumnVisibility({\n fields: effectiveMetadata?.fields,\n columnsByFieldId,\n defaultVisibleFieldNames,\n columnVisibilityStorageKey: `${storageKey}:columns`,\n onColumnVisibilityModelChange,\n });\n\n const handleRowDoubleClick = useCallback(\n (params: { id: string | number; row: DynamicRowData<T> }) => {\n if (!onRowDoubleClick) return;\n\n const rowId = params.id?.toString() || '';\n onRowDoubleClick(rowId, params.row);\n },\n [onRowDoubleClick],\n );\n\n const isMobile = useResponsive('down', 'md');\n const [filterAnchorEl, setFilterAnchorEl] = useState<HTMLElement | null>(\n null,\n );\n\n const { filter: storedFilter, setFilter: setStoredFilter } = useFilterStorage(\n storageKey,\n filter,\n onFilterChange,\n );\n\n const { sort: storedSort, setSort: setStoredSort } = useSortStorage(\n storageKey,\n sort,\n onSortChange,\n );\n\n const effectiveFilter = filter ?? storedFilter;\n const effectiveSort = sort ?? storedSort;\n\n const { sortModel, handleSortModelChange } = useSorting({\n sort: effectiveSort,\n onSortChange: setStoredSort,\n fields: effectiveMetadataFields,\n });\n\n const {\n conditions,\n isOpen,\n openDrawer,\n closeDrawer,\n addCondition,\n updateCondition,\n removeCondition,\n clearAllFilters,\n applyFilters,\n cancelChanges,\n hasActiveFilters,\n activeFiltersCount,\n } = useFilters({\n fields: effectiveMetadataFields,\n initialFilter: effectiveFilter,\n });\n\n const handleApplyFilters = useCallback(() => {\n const newFilter = applyFilters();\n setStoredFilter(newFilter);\n }, [applyFilters, setStoredFilter]);\n\n const handleClearFilters = useCallback(() => {\n clearAllFilters();\n setStoredFilter(undefined);\n }, [clearAllFilters, setStoredFilter]);\n\n const handleFilterButtonClick = useCallback(\n (event: React.MouseEvent<HTMLElement>) => {\n if (isMobile) {\n openDrawer();\n } else {\n openDrawer();\n setFilterAnchorEl(event.currentTarget);\n }\n },\n [isMobile, openDrawer],\n );\n\n const handleCancelFilters = useCallback(() => {\n cancelChanges();\n setFilterAnchorEl(null);\n }, [cancelChanges]);\n\n const [isSortModalOpen, setIsSortModalOpen] = useState(false);\n\n const handleFiltersClose = useCallback(() => {\n setFilterAnchorEl(null);\n closeDrawer();\n }, [closeDrawer]);\n const hasSelectionActions = !!bulkActions?.length;\n\n return (\n <>\n <DataView<DynamicRowData<T>>\n title={title}\n columns={orderedColumns}\n rows={rows}\n mobileRender={mobileRender}\n rowCount={total}\n loading={isLoading || !metadata}\n fetching={isFetching}\n searchValue={searchValue}\n onSearch={onSearch}\n onSearchChange={onSearchChange}\n paginationModel={{\n page,\n pageSize: perPage,\n }}\n onPaginationChange={onPaginationChange}\n actions={actions}\n moreActions={moreActions}\n onAdd={onAdd}\n onRowDoubleClick={onRowDoubleClick ? handleRowDoubleClick : undefined}\n bulkActions={bulkActions}\n checkboxSelection={hasSelectionActions}\n rowSelectionModel={rowSelectionModel}\n onRowSelectionModelChange={onRowSelectionModelChange}\n keepNonExistentRowsSelected={hasSelectionActions}\n disableRowSelectionOnClick\n slots={slots}\n initialState={initialState}\n showColumnButton={showColumnButton}\n containerProps={{\n height: containerHeight,\n maxHeight: containerHeight,\n }}\n onColumnVisibilityModelChange={handleColumnVisibilityModelChange}\n filterButton={\n <FilterButton\n showFilterButton={showFilterButton}\n isMobile={isMobile}\n hasActiveFilters={hasActiveFilters}\n activeFiltersCount={activeFiltersCount}\n sort={effectiveSort}\n onFilterClick={handleFilterButtonClick}\n onSortClick={() => setIsSortModalOpen(true)}\n />\n }\n sortingMode=\"server\"\n sortModel={sortModel}\n onSortModelChange={handleSortModelChange}\n disableColumnFilter\n />\n {metadata && (\n <>\n <FiltersSection\n showFilterButton={showFilterButton}\n isOpen={isOpen}\n filterAnchorEl={filterAnchorEl}\n fields={effectiveMetadataFields}\n conditions={conditions}\n isMobile={isMobile}\n onClose={handleFiltersClose}\n onAddCondition={addCondition}\n onUpdateCondition={updateCondition}\n onRemoveCondition={removeCondition}\n onApply={handleApplyFilters}\n onClear={handleClearFilters}\n onCancel={handleCancelFilters}\n entityFilterConfig={entityFilterConfig}\n />\n\n <SortModal\n open={isSortModalOpen}\n onClose={() => setIsSortModalOpen(false)}\n fields={effectiveMetadataFields}\n sort={effectiveSort}\n onSortChange={setStoredSort}\n />\n </>\n )}\n </>\n );\n};\n\nexport default memo(DynamicDataView, isEqual) as typeof DynamicDataView;\nexport type { DynamicDataViewProps, DynamicRowData } from './props';\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport Badge from '@mui/material/Badge';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport Stack from '@mui/material/Stack';\n\nimport { ToolbarActionsDivider } from 'components/DataView';\nimport Icon from 'components/Icon';\n\nimport { FilterButtonProps } from '../props';\n\nconst FilterButton = ({\n showFilterButton,\n isMobile,\n hasActiveFilters,\n activeFiltersCount,\n sort,\n onFilterClick,\n onSortClick,\n}: FilterButtonProps) => {\n if (!showFilterButton) return null;\n\n if (isMobile) {\n return (\n <Stack direction=\"row\" spacing={0.5}>\n <Badge\n badgeContent={activeFiltersCount}\n color=\"primary\"\n invisible={activeFiltersCount === 0}\n sx={{\n '& .MuiBadge-badge': {\n transform: 'scale(0.9) translate(10px, 9px)',\n opacity: activeFiltersCount === 0 ? 0 : 1,\n },\n }}\n >\n <IconButton\n color={hasActiveFilters ? 'primary' : 'default'}\n onClick={onFilterClick}\n size=\"small\"\n aria-label=\"Filtrar\"\n sx={{ overflow: 'visible' }}\n >\n <Icon icon=\"FILTER_VERTICAL\" />\n </IconButton>\n </Badge>\n\n <ToolbarActionsDivider\n sx={{ height: 16 }}\n orientation=\"vertical\"\n flexItem\n />\n\n <IconButton\n color={sort ? 'primary' : 'default'}\n onClick={onSortClick}\n size=\"small\"\n aria-label=\"Ordenar\"\n >\n <Icon\n icon={sort?.sortType === 'DESC' ? 'SORTING_DESC' : 'SORTING_ASC'}\n />\n </IconButton>\n </Stack>\n );\n }\n\n return (\n <Badge\n badgeContent={activeFiltersCount}\n color=\"primary\"\n invisible={activeFiltersCount === 0}\n sx={{\n '& .MuiBadge-badge': activeFiltersCount\n ? {\n transform: 'scale(0.9) translate(-3px, 7px)',\n position: 'relative',\n opacity: 1,\n transition: 'none',\n }\n : {\n transition: 'none',\n opacity: 0,\n },\n }}\n >\n <Button\n variant=\"text\"\n color={hasActiveFilters ? 'primary' : 'inherit'}\n startIcon={<Icon icon=\"FILTER_VERTICAL\" />}\n onClick={onFilterClick}\n size=\"small\"\n >\n Filtrar\n </Button>\n </Badge>\n );\n};\n\nexport default memo(FilterButton, isEqual);\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\n\nimport { FiltersSectionProps } from '../props';\n\nimport FiltersContainer from './filters/FiltersContainer';\n\nconst FiltersSection = ({\n showFilterButton,\n isOpen,\n filterAnchorEl,\n fields,\n conditions,\n isMobile,\n onClose,\n onAddCondition,\n onUpdateCondition,\n onRemoveCondition,\n onApply,\n onClear,\n onCancel,\n entityFilterConfig,\n}: FiltersSectionProps) => {\n if (!showFilterButton) return null;\n\n return (\n <FiltersContainer\n open={isOpen || Boolean(filterAnchorEl)}\n anchorEl={filterAnchorEl}\n onClose={onClose}\n fields={fields}\n conditions={conditions}\n onAddCondition={onAddCondition}\n onUpdateCondition={onUpdateCondition}\n onRemoveCondition={onRemoveCondition}\n onApply={onApply}\n onClear={onClear}\n onCancel={onCancel}\n isMobileProp={isMobile}\n entityFilterConfig={entityFilterConfig}\n />\n );\n};\n\nexport default memo(FiltersSection, isEqual);\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\n\nimport ResponsivePopover from 'components/ResponsivePopover';\n\nimport FiltersContent from './FiltersContent';\nimport type { FiltersContainerProps } from './props';\n\nconst FiltersContainer = (props: FiltersContainerProps) => {\n return (\n <ResponsivePopover\n open={props.open}\n onClose={props.onClose}\n anchorEl={props.anchorEl}\n isMobile={props.isMobileProp}\n popoverProps={{\n slotProps: {\n paper: {\n sx: {\n width: 520,\n maxWidth: 'calc(100vw - 24px)',\n maxHeight: 600,\n mt: 1,\n },\n },\n },\n }}\n drawerProps={{\n anchor: 'right',\n PaperProps: {\n sx: {\n width: '100%',\n maxWidth: '100%',\n height: '100%',\n maxHeight: '100%',\n borderRadius: 0,\n },\n },\n }}\n >\n <FiltersContent {...props} />\n </ResponsivePopover>\n );\n};\n\nexport default memo(FiltersContainer, isEqual);\n","import { memo, useCallback } from 'react';\nimport isEqual from 'react-fast-compare';\nimport Button from '@mui/material/Button';\nimport Divider from '@mui/material/Divider';\nimport IconButton from '@mui/material/IconButton';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport Icon from 'components/Icon';\n\nimport { getFilterableFields } from '../../utils/filter';\n\nimport FiltersList from './FiltersList';\nimport type { FiltersPopoverProps } from './props';\nimport { Container, Content, Footer, Header } from './styles';\n\nconst FiltersContent = ({\n onClose,\n fields,\n conditions,\n onAddCondition,\n onUpdateCondition,\n onRemoveCondition,\n onApply,\n onClear,\n onCancel,\n entityFilterConfig,\n}: FiltersPopoverProps) => {\n const filterableFields = getFilterableFields(fields);\n const hasConditions = conditions.length > 0;\n\n const handleApply = useCallback(() => {\n onApply();\n onClose();\n }, [onApply, onClose]);\n\n const handleClear = useCallback(() => {\n onClear();\n onClose();\n }, [onClear, onClose]);\n\n const handleCancel = useCallback(() => {\n onCancel();\n }, [onCancel]);\n\n return (\n <Container>\n <Header>\n <Typography variant=\"overline\" fontWeight={600} color=\"text.secondary\">\n Defina as condições para filtrar\n </Typography>\n\n <IconButton\n onClick={onAddCondition}\n size=\"small\"\n aria-label=\"Adicionar filtro\"\n title=\"Adicionar filtro\"\n disabled={conditions.length >= filterableFields.length}\n >\n <Icon icon=\"SIMPLE_ADD\" />\n </IconButton>\n </Header>\n\n <Divider />\n\n <Content>\n <FiltersList\n filterableFields={filterableFields}\n conditions={conditions}\n onUpdateCondition={onUpdateCondition}\n onRemoveCondition={onRemoveCondition}\n entityFilterConfig={entityFilterConfig}\n />\n </Content>\n\n <Divider />\n\n <Footer>\n <Button variant=\"text\" color=\"inherit\" onClick={handleClear}>\n Limpar\n </Button>\n\n <Stack direction=\"row\" spacing={1}>\n <Button\n variant=\"outlined\"\n color=\"inherit\"\n onClick={handleCancel}\n startIcon={<Icon icon=\"CANCEL_CIRCLE\" />}\n >\n Cancelar\n </Button>\n <Button\n variant=\"contained\"\n onClick={handleApply}\n disabled={!hasConditions}\n startIcon={<Icon icon=\"SIMPLE_CHECK\" />}\n >\n Aplicar\n </Button>\n </Stack>\n </Footer>\n </Container>\n );\n};\n\nexport default memo(FiltersContent, isEqual);\n","import { Condition, DataType, Field } from 'model/entity-metadata';\nimport {\n Filter,\n FilterCondition,\n FilterOperator,\n FilterState,\n} from 'model/filter';\n\n/**\n * Campos filtráveis (campos com condições disponíveis)\n */\nexport const getFilterableFields = (fields: Field[]): Field[] => {\n return fields.filter(\n field =>\n field.available_filter_conditions &&\n field.available_filter_conditions.length > 0 &&\n field.name !== 'ACTIONS',\n );\n};\n\n/**\n * Converte FilterState para formato de API\n */\nexport const buildFilterFromState = (\n state: FilterState,\n): Filter | undefined => {\n const entries = Object.entries(state).filter(\n ([, value]) => value.value.length > 0,\n );\n if (entries.length === 0) return undefined;\n return {\n operator: FilterOperator.AND,\n groups: [\n {\n operator: FilterOperator.AND,\n conditionals: entries.map(([, filterValue]) => ({\n fieldName: filterValue.fieldName,\n conditional: filterValue.conditional,\n value: filterValue.value,\n })),\n },\n ],\n };\n};\n\n/**\n * Retorna o conditional padrão para um tipo de campo\n */\nexport const getDefaultCondition = (field: Field): Condition => {\n const { type, available_filter_conditions } = field;\n if (available_filter_conditions.length === 0) return Condition.EQUALS;\n if (\n type === DataType.TEXT &&\n available_filter_conditions.includes(Condition.LIKE)\n ) {\n return Condition.LIKE;\n }\n return available_filter_conditions[0];\n};\n\n/**\n * Verifica se uma condição é válida (tem valor ou não requer valor)\n */\nexport const isValidCondition = (condition: FilterCondition): boolean => {\n return (\n condition.value.length > 0 ||\n condition.conditional === Condition.IS_NULL ||\n condition.conditional === Condition.IS_NOT_NULL\n );\n};\n\n/**\n * Converte array de FilterCondition para Filter API\n */\nexport const buildFilterFromConditions = (\n conditions: FilterCondition[],\n): Filter | undefined => {\n if (conditions.length === 0) return undefined;\n\n const validConditions = conditions.filter(isValidCondition);\n if (validConditions.length === 0) return undefined;\n\n return {\n operator: FilterOperator.AND,\n groups: [\n {\n operator: validConditions[0]?.operator || FilterOperator.AND,\n conditionals: validConditions.map(c => ({\n fieldName: c.fieldName,\n conditional: c.conditional,\n value: c.value,\n })),\n },\n ],\n };\n};\n","import { memo, useCallback, useMemo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport Typography from '@mui/material/Typography';\nimport type { FilterCondition } from 'model/filter';\n\nimport FilterRow from './FilterRow';\nimport type { FiltersListProps } from './props';\n\nconst FiltersList = ({\n filterableFields,\n conditions,\n onUpdateCondition,\n onRemoveCondition,\n entityFilterConfig,\n}: FiltersListProps) => {\n const handleUpdateCondition = useCallback(\n (updated: FilterCondition) => {\n onUpdateCondition(updated.id, updated);\n },\n [onUpdateCondition],\n );\n\n const handleRemoveCondition = useCallback(\n (id: string) => () => {\n onRemoveCondition(id);\n },\n [onRemoveCondition],\n );\n\n const usedFieldNames = useMemo(\n () =>\n conditions.map(c => c.fieldName).filter((name): name is string => !!name),\n [conditions],\n );\n\n const getAvailableFields = useCallback(\n (currentFieldName: string | undefined) =>\n filterableFields.filter(\n field =>\n !usedFieldNames.includes(field.name) ||\n field.name === currentFieldName,\n ),\n [filterableFields, usedFieldNames],\n );\n\n if (filterableFields.length === 0) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\" textAlign=\"center\">\n Nenhum filtro disponível\n </Typography>\n );\n }\n\n if (conditions.length === 0) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\" textAlign=\"center\">\n Clique em{' '}\n <Typography\n component=\"strong\"\n variant=\"body2\"\n fontWeight={600}\n color=\"text.primary\"\n >\n "+"\n </Typography>{' '}\n para adicionar um filtro\n </Typography>\n );\n }\n\n return (\n <>\n {conditions.map((condition, index) => (\n <FilterRow\n key={condition.id}\n condition={condition}\n fields={getAvailableFields(condition.fieldName)}\n onChange={handleUpdateCondition}\n onRemove={handleRemoveCondition(condition.id)}\n showOperator={index > 0}\n totalConditions={conditions.length}\n isFirst={index === 0}\n entityFilterConfig={entityFilterConfig}\n />\n ))}\n </>\n );\n};\n\nexport default memo(FiltersList, isEqual);\n","import { memo, useCallback, useMemo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport FormControl from '@mui/material/FormControl';\nimport IconButton from '@mui/material/IconButton';\nimport InputLabel from '@mui/material/InputLabel';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select from '@mui/material/Select';\nimport Stack from '@mui/material/Stack';\nimport TextField from '@mui/material/TextField';\nimport { Condition } from 'model/entity-metadata';\nimport { FilterOperator } from 'model/filter';\n\nimport Icon from 'components/Icon';\n\nimport { CONDITION_LABELS } from '../../constants/filter';\n\nimport EntityFilterAutocomplete from './EntityFilterAutocomplete';\nimport OperatorSelect from './OperatorSelect';\nimport type { FilterRowProps } from './props';\n\nconst ellipsisStyle = {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n} as const;\n\nconst FilterRow = ({\n condition,\n fields,\n onChange,\n onRemove,\n totalConditions,\n isFirst,\n entityFilterConfig,\n}: FilterRowProps) => {\n const selectedField = useMemo(\n () =>\n fields.find(f => (f.filter_field_name ?? f.name) === condition.fieldName),\n [fields, condition.fieldName],\n );\n\n const availableConditions = useMemo(\n () => selectedField?.available_filter_conditions || [],\n [selectedField],\n );\n\n const isValueDisabled = useMemo(\n () =>\n !condition.fieldName ||\n condition.conditional === 'IS_NULL' ||\n condition.conditional === 'IS_NOT_NULL',\n [condition.fieldName, condition.conditional],\n );\n\n const handleFieldChange = useCallback(\n (fieldName: string) => {\n const newField = fields.find(\n f => (f.filter_field_name ?? f.name) === fieldName,\n );\n if (!newField) return;\n\n const defaultCondition =\n newField.available_filter_conditions[0] || 'EQUALS';\n\n onChange({\n ...condition,\n fieldName,\n conditional: defaultCondition,\n value: [],\n });\n },\n [fields, condition, onChange],\n );\n\n const handleConditionChange = useCallback(\n (conditional: Condition) => {\n onChange({\n ...condition,\n conditional,\n });\n },\n [condition, onChange],\n );\n\n const handleValueChange = useCallback(\n (value: string) => {\n onChange({\n ...condition,\n value: value ? [value] : [],\n });\n },\n [condition, onChange],\n );\n\n const handleEntityValueChange = useCallback(\n (value: string, label?: string) => {\n const valueLabels = { ...condition.valueLabels };\n if (value && label) {\n valueLabels[value] = label;\n }\n onChange({\n ...condition,\n value: value ? [value] : [],\n valueLabels,\n });\n },\n [condition, onChange],\n );\n\n const handleOperatorChange = useCallback(\n (operator: FilterOperator) => {\n onChange({\n ...condition,\n operator,\n });\n },\n [condition, onChange],\n );\n\n const renderValueInput = () => {\n if (selectedField?.type === 'BOOLEAN') {\n return (\n <FormControl\n size=\"small\"\n sx={{ flex: 1, minWidth: 120 }}\n disabled={isValueDisabled}\n >\n <InputLabel id={`value-label-${condition.id}`}>Valor</InputLabel>\n <Select\n labelId={`value-label-${condition.id}`}\n label=\"Valor\"\n value={condition.value[0] || ''}\n onChange={e => handleValueChange(e.target.value)}\n size=\"small\"\n sx={{\n '& .MuiSelect-select': ellipsisStyle,\n }}\n >\n <MenuItem value=\"true\">Verdadeiro</MenuItem>\n <MenuItem value=\"false\">Falso</MenuItem>\n </Select>\n </FormControl>\n );\n }\n\n if (\n selectedField?.type === 'ENTITY' &&\n selectedField.metadata &&\n entityFilterConfig?.[selectedField.metadata.name]\n ) {\n const currentValue = condition.value[0] || '';\n return (\n <EntityFilterAutocomplete\n config={entityFilterConfig[selectedField.metadata.name]}\n metadata={selectedField.metadata}\n value={currentValue}\n initialLabel={condition.valueLabels?.[currentValue]}\n onChange={handleEntityValueChange}\n disabled={isValueDisabled}\n />\n );\n }\n\n return (\n <TextField\n label=\"Filtro\"\n value={condition.value[0] || ''}\n onChange={e => handleValueChange(e.target.value)}\n size=\"small\"\n disabled={isValueDisabled}\n InputLabelProps={{ shrink: true }}\n sx={{ flex: 1, minWidth: 120 }}\n />\n );\n };\n\n return (\n <Stack direction=\"row\" spacing={1} alignItems=\"center\">\n <IconButton\n onClick={onRemove}\n size=\"small\"\n aria-label=\"Remover filtro\"\n sx={{ flexShrink: 0 }}\n >\n <Icon icon=\"CLOSE_MARK_BUTTON\" width={18} />\n </IconButton>\n\n <OperatorSelect\n value={condition.operator}\n onChange={handleOperatorChange}\n totalConditions={totalConditions}\n isFirst={isFirst}\n />\n\n <FormControl size=\"small\" sx={{ minWidth: 150, flex: 1 }}>\n <InputLabel id={`field-label-${condition.id}`}>Coluna</InputLabel>\n <Select\n labelId={`field-label-${condition.id}`}\n label=\"Coluna\"\n value={condition.fieldName}\n onChange={e => handleFieldChange(e.target.value)}\n size=\"small\"\n sx={{\n '& .MuiSelect-select': ellipsisStyle,\n }}\n >\n {fields.map(field => (\n <MenuItem\n key={field.name}\n value={field.filter_field_name ?? field.name}\n sx={ellipsisStyle}\n title={field.description || field.name}\n >\n {field.description || field.name}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n <FormControl\n size=\"small\"\n sx={{ minWidth: 90 }}\n disabled={!condition.fieldName}\n >\n <InputLabel id={`condition-label-${condition.id}`}>Condição</InputLabel>\n <Select\n labelId={`condition-label-${condition.id}`}\n label=\"Condição\"\n value={condition.conditional}\n onChange={e => handleConditionChange(e.target.value as Condition)}\n size=\"small\"\n sx={{\n '& .MuiSelect-select': ellipsisStyle,\n }}\n >\n {availableConditions.map(cond => (\n <MenuItem key={cond} value={cond} sx={ellipsisStyle}>\n {CONDITION_LABELS[cond as Condition] || cond}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n {renderValueInput()}\n </Stack>\n );\n};\n\nexport default memo(FilterRow, isEqual);\n","import { Condition } from 'model/entity-metadata';\n\nexport const CONDITION_LABELS: Record<Condition, string> = {\n [Condition.EQUALS]: 'Igual a',\n [Condition.NOT_EQUALS]: 'Diferente de',\n [Condition.LIKE]: 'Contém',\n [Condition.NOT_LIKE]: 'Não contém',\n [Condition.GREATER_THAN]: 'Maior que',\n [Condition.LESS_THAN]: 'Menor que',\n [Condition.GREATER_THAN_OR_EQUAL]: 'Maior ou igual a',\n [Condition.LESS_THAN_OR_EQUAL]: 'Menor ou igual a',\n [Condition.IN]: 'Em',\n [Condition.NOT_IN]: 'Não em',\n [Condition.IS_NULL]: 'É nulo',\n [Condition.IS_NOT_NULL]: 'Não é nulo',\n};\n","import { memo, useCallback, useMemo, useState } from 'react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport TextField from '@mui/material/TextField';\n\nimport useDebounceValue from 'hooks/useDebounceValue';\nimport useToggle from 'hooks/useToggle';\n\nimport type {\n EntityFilterAutocompleteProps,\n EntityFilterOption,\n} from './props';\n\nconst EntityFilterAutocomplete = ({\n config,\n metadata,\n value,\n initialLabel,\n onChange,\n disabled = false,\n}: EntityFilterAutocompleteProps) => {\n const [open, toggleOpen, setOpen] = useToggle(false);\n const [inputValue, setInputValue] = useState('');\n const debouncedSearch = useDebounceValue(inputValue, 400);\n\n const { data, isLoading, isFetching } = config.useQuery(\n {\n search: debouncedSearch || undefined,\n page: 0,\n perPage: 25,\n ...config.queryParams,\n },\n { skip: !open },\n );\n\n const loading = isLoading || isFetching;\n\n const selectedOption = useMemo<EntityFilterOption | null>(() => {\n if (!value) return null;\n return { value, label: initialLabel ?? value };\n }, [value, initialLabel]);\n\n const options: EntityFilterOption[] = useMemo(() => {\n const items = (data?.items ?? [])\n .map(item => ({\n label: String(item[metadata.description_field_name] ?? ''),\n value: String(item[metadata.id_field_name] ?? ''),\n }))\n .filter(opt => opt.value && opt.label);\n\n if (\n selectedOption &&\n !items.some(opt => opt.value === selectedOption.value)\n ) {\n items.unshift(selectedOption);\n }\n\n return items;\n }, [\n data,\n metadata.id_field_name,\n metadata.description_field_name,\n selectedOption,\n ]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n setInputValue('');\n }, [setOpen]);\n\n const handleChange = useCallback(\n (_event: React.SyntheticEvent, option: EntityFilterOption | null) => {\n onChange(option?.value ?? '', option?.label);\n },\n [onChange],\n );\n\n const handleInputChange = useCallback(\n (_event: React.SyntheticEvent, newInputValue: string, reason: string) => {\n if (reason === 'input') {\n setInputValue(newInputValue);\n }\n },\n [],\n );\n\n return (\n <Autocomplete<EntityFilterOption, false, false, false>\n open={open}\n onOpen={toggleOpen}\n onClose={handleClose}\n value={selectedOption}\n onChange={handleChange}\n inputValue={open ? inputValue : (selectedOption?.label ?? '')}\n onInputChange={handleInputChange}\n options={options}\n loading={loading}\n disabled={disabled}\n size=\"small\"\n getOptionLabel={opt => opt.label}\n isOptionEqualToValue={(opt, val) => opt.value === val.value}\n filterOptions={x => x}\n noOptionsText={\n inputValue !== debouncedSearch ? 'Buscando...' : 'Nenhum resultado'\n }\n sx={{ flex: 1, minWidth: 120 }}\n renderInput={params => (\n <TextField\n {...params}\n label=\"Filtro\"\n InputLabelProps={{ shrink: true }}\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <>\n {loading && <CircularProgress color=\"inherit\" size={18} />}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n )}\n />\n );\n};\n\nexport default memo(EntityFilterAutocomplete);\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select from '@mui/material/Select';\nimport Stack from '@mui/material/Stack';\nimport { FilterOperator } from 'model/filter';\n\nimport type { OperatorSelectProps } from './props';\n\nconst OperatorSelect = ({\n value,\n onChange,\n totalConditions,\n isFirst,\n}: OperatorSelectProps) => {\n if (totalConditions === 1) {\n return null;\n }\n\n if (isFirst) {\n return <Stack sx={{ width: 55, flexShrink: 0 }} />;\n }\n\n return (\n <Select\n value={value}\n onChange={e => onChange(e.target.value as FilterOperator)}\n size=\"small\"\n sx={{ width: 55, flexShrink: 0 }}\n >\n <MenuItem value={FilterOperator.AND}>e</MenuItem>\n <MenuItem value={FilterOperator.OR}>ou</MenuItem>\n </Select>\n );\n};\n\nexport default memo(OperatorSelect, isEqual);\n","import Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\n\n// Estilos baseados no Drawer/Popover para garantir consistência\nexport const Container = styled(Box)({\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n // No popover, a altura será controlada pelo max-height do container\n});\n\nexport const Header = styled(Box)(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: theme.spacing(2, 3),\n}));\n\nexport const Content = styled(Box)(({ theme }) => ({\n flex: 1,\n overflowY: 'auto',\n padding: theme.spacing(3),\n display: 'flex',\n flexDirection: 'column',\n gap: theme.spacing(2),\n}));\n\nexport const Footer = styled(Box)(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: theme.spacing(2),\n}));\n","import { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport Button from '@mui/material/Button';\nimport FormControl from '@mui/material/FormControl';\nimport InputLabel from '@mui/material/InputLabel';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select from '@mui/material/Select';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\nimport { SortType } from 'model/filter';\n\nimport Icon from 'components/Icon';\n\nimport { SortModalProps } from './props';\nimport {\n ApplyButton,\n LabelButton,\n StyledDialog,\n StyledDialogActions,\n StyledDialogContent,\n StyledDialogTitle,\n} from './style';\n\nconst SortModal = ({\n open,\n onClose,\n fields,\n sort,\n onSortChange,\n}: SortModalProps) => {\n const [selectedField, setSelectedField] = useState<string>(\n sort?.fieldName || '',\n );\n const [selectedDirection, setSelectedDirection] = useState<SortType>(\n sort?.sortType || SortType.ASC,\n );\n\n const sortableFields = useMemo(\n () =>\n fields.filter(\n field => field.name !== 'ACTIONS' && field.access_type !== 'WRITE_ONLY',\n ),\n [fields],\n );\n\n const selectedFieldObj = useMemo(\n () =>\n fields.find(\n field => (field.filter_field_name ?? field.name) === selectedField,\n ),\n [fields, selectedField],\n );\n\n const isNumberField =\n selectedFieldObj?.type === 'DECIMAL' ||\n selectedFieldObj?.type === 'INTEGER';\n\n useEffect(() => {\n if (open) {\n setSelectedField(sort?.fieldName || '');\n setSelectedDirection(sort?.sortType || SortType.ASC);\n }\n }, [open, sort]);\n\n const handleApply = useCallback(() => {\n if (onSortChange) {\n if (!selectedField) {\n onSortChange(undefined);\n } else {\n onSortChange({\n fieldName: selectedField,\n sortType: selectedDirection,\n });\n }\n }\n onClose();\n }, [onSortChange, selectedField, selectedDirection, onClose]);\n\n const handleClear = useCallback(() => {\n if (!onSortChange) return;\n\n setSelectedField('');\n setSelectedDirection(SortType.ASC);\n\n onSortChange(undefined);\n onClose();\n }, [onSortChange, onClose]);\n\n return (\n <StyledDialog open={open} onClose={onClose} maxWidth=\"xs\" fullWidth>\n <StyledDialogTitle>\n <Typography variant=\"overline\" color=\"text.secondary\">\n Ordenar por\n </Typography>\n </StyledDialogTitle>\n <StyledDialogContent>\n <Stack spacing={2} pt={2}>\n <FormControl fullWidth size=\"small\">\n <InputLabel id=\"sort-field-label\">Campo</InputLabel>\n <Select\n labelId=\"sort-field-label\"\n value={selectedField}\n label=\"Campo\"\n onChange={e => setSelectedField(e.target.value)}\n >\n <MenuItem value=\"\">\n <em>Nenhum</em>\n </MenuItem>\n {sortableFields.map(field => (\n <MenuItem\n key={field.name}\n value={field.filter_field_name ?? field.name}\n >\n {field.description || field.name}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n <FormControl fullWidth size=\"small\" disabled={!selectedField}>\n <InputLabel id=\"sort-direction-label\">Direção</InputLabel>\n <Select\n labelId=\"sort-direction-label\"\n value={selectedDirection}\n label=\"Direção\"\n onChange={e => setSelectedDirection(e.target.value as SortType)}\n >\n <MenuItem value={SortType.ASC}>\n Crescente {isNumberField ? '(1-9)' : '(A-Z)'}\n </MenuItem>\n <MenuItem value={SortType.DESC}>\n Decrescente {isNumberField ? '(9-1)' : '(Z-A)'}\n </MenuItem>\n </Select>\n </FormControl>\n </Stack>\n </StyledDialogContent>\n <StyledDialogActions>\n <Stack flex={1} width=\"100%\" direction=\"row\">\n <Button color=\"inherit\" onClick={handleClear}>\n Limpar\n </Button>\n </Stack>\n <Button\n onClick={onClose}\n variant=\"outlined\"\n color=\"inherit\"\n sx={{ minWidth: 24 }}\n >\n <Icon icon=\"CANCEL_CIRCLE\" />\n <LabelButton>Cancelar</LabelButton>\n </Button>\n <ApplyButton onClick={handleApply} variant=\"contained\">\n <Icon icon=\"SIMPLE_CHECK\" />\n <LabelButton>Aplicar</LabelButton>\n </ApplyButton>\n </StyledDialogActions>\n </StyledDialog>\n );\n};\n\nSortModal.displayName = 'SortModal';\n\nexport default memo(SortModal);\n","import Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nexport const StyledDialog = styled(Dialog)(() => ({\n '& .MuiDialog-paper': { width: '100%' },\n}));\n\nexport const StyledDialogTitle = styled(DialogTitle)(({ theme }) => ({\n borderBottom: '1px solid',\n borderColor: theme.palette.divider,\n padding: theme.spacing(1.5, 2),\n}));\n\nexport const StyledDialogContent = styled(DialogContent)(({ theme }) => ({\n padding: theme.spacing(2),\n}));\n\nexport const StyledDialogActions = styled(DialogActions)(({ theme }) => ({\n borderTop: '1px solid',\n borderColor: theme.palette.divider,\n padding: theme.spacing(1.5, 2),\n}));\n\nexport const ApplyButton = styled(Button)(({ theme }) => ({\n minWidth: 24,\n [theme.breakpoints.down(330)]: {\n padding: theme.spacing(1),\n },\n}));\n\nexport const LabelButton = styled(Typography)(({ theme }) => ({\n fontWeight: '600',\n margin: theme.spacing(0, 1),\n [theme.breakpoints.down(330)]: {\n fontSize: 0,\n margin: 0,\n },\n}));\n","import { useMemo } from 'react';\nimport type { GridColDef } from '@mui/x-data-grid-premium';\n\nimport { UseColumnOrderingParams } from '../props';\n\nexport const useColumnOrdering = ({\n columns,\n fields,\n preferredFieldOrder,\n}: UseColumnOrderingParams) => {\n const columnsByFieldId = useMemo(\n () => new Map(columns.map(column => [column.field, column])),\n [columns],\n );\n\n const fieldsByName = useMemo(\n () => new Map(fields?.map(f => [f.name, f]) || []),\n [fields],\n );\n\n const orderedColumns = useMemo(() => {\n if (!preferredFieldOrder || preferredFieldOrder.length === 0 || !fields) {\n return columns;\n }\n\n const actionFieldName = 'ACTIONS';\n const preferredWithoutActions = preferredFieldOrder.filter(\n fieldName => fieldName !== actionFieldName,\n );\n\n const usedColumnFieldIds = new Set<string>();\n const ordered: GridColDef[] = [];\n\n const pushColumnForField = (fieldName: string) => {\n const field = fieldsByName.get(fieldName);\n if (!field) return;\n\n const column = columnsByFieldId.get(field.name);\n\n if (!column || usedColumnFieldIds.has(field.name)) return;\n\n ordered.push(column);\n usedColumnFieldIds.add(field.name);\n };\n\n preferredWithoutActions.forEach(fieldName => {\n pushColumnForField(fieldName);\n });\n\n fields.forEach(field => {\n if (field.name === actionFieldName) return;\n if (preferredWithoutActions.includes(field.name)) return;\n\n const column = columnsByFieldId.get(field.name);\n\n if (!column || usedColumnFieldIds.has(field.name)) return;\n\n ordered.push(column);\n usedColumnFieldIds.add(field.name);\n });\n\n pushColumnForField(actionFieldName);\n\n return ordered.length === 0 ? columns : ordered;\n }, [columns, columnsByFieldId, fieldsByName, preferredFieldOrder, fields]);\n\n return { orderedColumns, columnsByFieldId, fieldsByName };\n};\n","import { useCallback, useMemo } from 'react';\nimport type { GridColumnVisibilityModel } from '@mui/x-data-grid-premium';\nimport { Field } from 'model/entity-metadata';\n\nimport useLocalStorage from 'hooks/useLocalStorage';\n\nimport { UseColumnVisibilityParams } from '../props';\n\nfunction getColumnFieldIdFromField(field: Field): string {\n return field.name;\n}\n\nexport const useColumnVisibility = ({\n fields,\n columnsByFieldId,\n defaultVisibleFieldNames,\n columnVisibilityStorageKey,\n onColumnVisibilityModelChange,\n}: UseColumnVisibilityParams) => {\n const hasStorageKey = Boolean(columnVisibilityStorageKey);\n\n const [storedVisibilityModel, setStoredVisibilityModel] = useLocalStorage<\n GridColumnVisibilityModel | undefined\n >(columnVisibilityStorageKey || '__dynamic-data-view:columns__', undefined, {\n initializeWithValue: hasStorageKey,\n });\n\n const initialState = useMemo(() => {\n if (!fields) return undefined;\n\n const visibilityModel: GridColumnVisibilityModel = {};\n\n fields.forEach(field => {\n const columnFieldId = getColumnFieldIdFromField(field);\n if (!columnsByFieldId.has(columnFieldId)) return;\n\n let visible: boolean | undefined;\n\n if (hasStorageKey && storedVisibilityModel) {\n const stored = storedVisibilityModel[columnFieldId];\n if (typeof stored === 'boolean') {\n visible = stored;\n }\n }\n\n if (\n visible === undefined &&\n defaultVisibleFieldNames &&\n defaultVisibleFieldNames.length > 0\n ) {\n visible = defaultVisibleFieldNames.includes(field.name);\n }\n\n if (typeof visible === 'boolean') {\n visibilityModel[columnFieldId] = visible;\n }\n });\n\n if (Object.keys(visibilityModel).length === 0) return undefined;\n\n return {\n columns: {\n columnVisibilityModel: visibilityModel,\n },\n };\n }, [\n columnsByFieldId,\n defaultVisibleFieldNames,\n fields,\n hasStorageKey,\n storedVisibilityModel,\n ]);\n\n const handleColumnVisibilityModelChange = useCallback(\n (model: GridColumnVisibilityModel) => {\n if (hasStorageKey) {\n const modelToSave = { ...model };\n // Prevents __check__ (checkboxSelection column) from being permanently hidden in local storage\n delete modelToSave['__check__'];\n setStoredVisibilityModel(modelToSave);\n }\n\n if (onColumnVisibilityModelChange) {\n onColumnVisibilityModelChange(model);\n }\n },\n [hasStorageKey, onColumnVisibilityModelChange, setStoredVisibilityModel],\n );\n\n return {\n initialState,\n handleColumnVisibilityModelChange,\n };\n};\n","import { useMemo } from 'react';\nimport { GridColDef } from '@mui/x-data-grid-premium';\n\nimport { Columns } from 'types/datagrid';\n\nimport { ACCESS_TYPES } from '../constants/columnDefaults';\nimport { UseDynamicColumnsProps } from '../props';\nimport { getColumnStrategy } from '../utils/columnStrategies';\n\nexport const useDynamicColumns = <T extends object>({\n metadata,\n renderCell,\n columnStrategies,\n}: UseDynamicColumnsProps<T>): Columns => {\n return useMemo(() => {\n if (!metadata?.fields) return [];\n\n const columnsMap = new Map<string, GridColDef>();\n\n const visibleFields = metadata.fields.filter(field => {\n if (\n field.access_type === ACCESS_TYPES.READ_ONLY ||\n field.access_type === ACCESS_TYPES.READ_AND_WRITE\n ) {\n return true;\n }\n\n return (\n field.name === 'ACTIONS' ||\n field.name === metadata?.id_field_name ||\n field.name === 'NAME'\n );\n });\n\n visibleFields.forEach(field => {\n if (columnsMap.has(field.name)) {\n return;\n }\n\n const strategy =\n columnStrategies?.[field.name] ?? getColumnStrategy<T>(field, metadata);\n const column = strategy(field, renderCell, metadata);\n\n columnsMap.set(field.name, column);\n });\n\n return Array.from(columnsMap.values());\n }, [columnStrategies, metadata, renderCell]);\n};\n","export const COLUMN_DEFAULTS = {\n IMAGE_WIDTH: 90,\n MIN_WIDTH: 130,\n ENTITY_MIN_WIDTH: 100,\n ENTITY_FLEX: 0.5,\n ID_MIN_WIDTH: 200,\n ID_FLEX: 1,\n ACTIONS_WIDTH: 80,\n} as const;\n\nexport const ACCESS_TYPES = {\n READ_ONLY: 'READ_ONLY',\n READ_AND_WRITE: 'READ_AND_WRITE',\n} as const;\n\nexport const CURRENCY_FIELD_NAMES: readonly string[] = [\n 'price',\n 'base_price',\n 'minimum_value',\n 'maximum_value',\n 'minimum_installment_value',\n];\n","import { GridColDef, GridRenderCellParams } from '@mui/x-data-grid-premium';\nimport { Field } from 'model/entity-metadata';\n\nimport { COLUMN_DEFAULTS } from '../constants/columnDefaults';\nimport { CellRenderer, ColumnStrategy, DynamicRowData } from '../props';\n\nconst createImageColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n sortable: false,\n width: COLUMN_DEFAULTS.IMAGE_WIDTH,\n resizable: false,\n headerAlign: 'center',\n align: 'center',\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createIdColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n minWidth: COLUMN_DEFAULTS.ID_MIN_WIDTH,\n flex: COLUMN_DEFAULTS.ID_FLEX,\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createEntityColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n minWidth: COLUMN_DEFAULTS.ENTITY_MIN_WIDTH,\n flex: COLUMN_DEFAULTS.ENTITY_FLEX,\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createDefaultColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n minWidth: COLUMN_DEFAULTS.MIN_WIDTH,\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createActionsColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: 'Ações',\n width: COLUMN_DEFAULTS.ACTIONS_WIDTH,\n sortable: false,\n resizable: false,\n disableReorder: true,\n headerAlign: 'center',\n disableColumnMenu: true,\n align: 'center',\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nexport const getColumnStrategy = <T extends object>(\n field: Field,\n metadata?: { id_field_name?: string },\n): ColumnStrategy<T> => {\n if (field.name === metadata?.id_field_name || field.name === 'name') {\n return createIdColumn;\n }\n\n if (field.name === 'ACTIONS') {\n return createActionsColumn;\n }\n\n if (field.type === 'FILE') {\n return createImageColumn;\n }\n\n if (field.type === 'ENTITY') {\n return createEntityColumn;\n }\n\n return createDefaultColumn;\n};\n","import { useCallback, useRef, useState } from 'react';\nimport {\n type Filter,\n type FilterCondition,\n FilterOperator,\n} from 'model/filter';\n\nimport uuidv4 from 'utils/uuidv4';\n\nimport { UseFiltersProps, UseFiltersReturn } from '../props';\nimport {\n buildFilterFromConditions,\n getDefaultCondition,\n isValidCondition,\n} from '../utils/filter';\n\n// Converte filtro inicial em condições\nconst parseInitialConditions = (initialFilter?: Filter): FilterCondition[] => {\n if (!initialFilter?.groups?.[0]?.conditionals) return [];\n return initialFilter.groups[0].conditionals.map(cond => ({\n id: uuidv4(),\n operator: initialFilter.groups[0].operator,\n fieldName: cond.fieldName,\n conditional: cond.conditional,\n value: cond.value,\n }));\n};\n\n/**\n * Hook para gerenciar estado de filtros do DynamicDataView com condições dinâmicas\n *\n * - conditions: estado de edição (o que o usuário vê no popover)\n * - appliedConditions: estado aplicado (o que está efetivamente filtrando)\n * - hasActiveFilters/activeFiltersCount: calculados com base em appliedConditions\n */\nexport const useFilters = ({\n fields,\n initialFilter,\n}: UseFiltersProps): UseFiltersReturn => {\n const [isOpen, setIsOpen] = useState(false);\n\n // Estado aplicado (efetivamente filtrando)\n const [appliedConditions, setAppliedConditions] = useState<FilterCondition[]>(\n () => parseInitialConditions(initialFilter),\n );\n const [appliedFilter, setAppliedFilter] = useState<Filter | undefined>(\n initialFilter,\n );\n\n // Estado de edição (o que o usuário vê/edita no popover)\n const [conditions, setConditions] = useState<FilterCondition[]>(() =>\n parseInitialConditions(initialFilter),\n );\n\n // Referência para snapshot antes de abrir o popover\n const snapshotRef = useRef<FilterCondition[]>([]);\n\n const openDrawer = useCallback(() => {\n // Salva snapshot das condições atuais (aplicadas) ao abrir\n snapshotRef.current = appliedConditions.map(c => ({ ...c }));\n // Sincroniza edição com aplicado ao abrir\n setConditions(appliedConditions.map(c => ({ ...c })));\n setIsOpen(true);\n }, [appliedConditions]);\n\n const closeDrawer = () => setIsOpen(false);\n\n const addCondition = useCallback(() => {\n const filterableFields = fields.filter(\n f => f.available_filter_conditions?.length > 0,\n );\n if (filterableFields.length === 0) return;\n\n const usedFieldNames = conditions.map(c => c.fieldName);\n const availableFields = filterableFields.filter(\n f => !usedFieldNames.includes(f.filter_field_name ?? f.name),\n );\n if (availableFields.length === 0) return;\n\n const currentOperator =\n conditions.length > 0 ? conditions[0].operator : FilterOperator.AND;\n const firstField = availableFields[0];\n const newCondition: FilterCondition = {\n id: uuidv4(),\n operator: currentOperator,\n fieldName: firstField.filter_field_name ?? firstField.name,\n conditional: getDefaultCondition(firstField),\n value: [],\n };\n\n setConditions(prev => [...prev, newCondition]);\n }, [fields, conditions]);\n\n const updateCondition = useCallback(\n (id: string, changes: Partial<FilterCondition>) => {\n setConditions(prev => {\n const targetCondition = prev.find(c => c.id === id);\n if (!targetCondition) return prev;\n\n if (changes.operator && changes.operator !== targetCondition.operator) {\n const newOperator = changes.operator;\n return prev.map(c => {\n if (c.id === id) {\n return { ...c, ...changes };\n }\n return { ...c, operator: newOperator };\n });\n }\n\n return prev.map(c => (c.id === id ? { ...c, ...changes } : c));\n });\n },\n [],\n );\n\n const removeCondition = useCallback((id: string) => {\n setConditions(prev => prev.filter(c => c.id !== id));\n }, []);\n\n const clearAllFilters = () => {\n setConditions([]);\n setAppliedConditions([]);\n setAppliedFilter(undefined);\n };\n\n const applyFilters = () => {\n const filter = buildFilterFromConditions(conditions);\n setAppliedConditions(conditions.map(c => ({ ...c })));\n setAppliedFilter(filter);\n setIsOpen(false);\n return filter;\n };\n\n const cancelChanges = () => {\n // Reverte para o snapshot salvo ao abrir\n setConditions(snapshotRef.current.map(c => ({ ...c })));\n setIsOpen(false);\n };\n\n // Calculado com base nos filtros APLICADOS (não em edição)\n const hasActiveFilters = appliedConditions.some(isValidCondition);\n const activeFiltersCount = appliedConditions.filter(isValidCondition).length;\n\n return {\n conditions,\n filter: appliedFilter,\n isOpen,\n hasActiveFilters,\n activeFiltersCount,\n openDrawer,\n closeDrawer,\n addCondition,\n updateCondition,\n removeCondition,\n clearAllFilters,\n applyFilters,\n cancelChanges,\n };\n};\n\nexport default useFilters;\n","import { useCallback, useEffect, useState } from 'react';\nimport { Filter, Sort } from 'model/filter';\n\nconst getStoredValue = <T>(key: string): T | undefined => {\n try {\n const item = localStorage.getItem(key);\n return item ? JSON.parse(item) : undefined;\n } catch {\n return undefined;\n }\n};\n\nconst setStoredValue = <T>(key: string, value: T | undefined): void => {\n try {\n if (value === undefined) {\n localStorage.removeItem(key);\n } else {\n localStorage.setItem(key, JSON.stringify(value));\n }\n } catch {\n // Silently ignore localStorage errors\n }\n};\n\nexport const useFilterStorage = (\n storageKey: string,\n externalFilter?: Filter,\n onFilterChange?: (filter: Filter | undefined) => void,\n) => {\n const filterKey = `${storageKey}:filter`;\n\n const [internalFilter, setInternalFilter] = useState<Filter | undefined>(\n () => {\n return getStoredValue<Filter>(filterKey) || externalFilter;\n },\n );\n\n // Sync with external filter\n useEffect(() => {\n if (externalFilter !== undefined) {\n setInternalFilter(externalFilter);\n }\n }, [externalFilter]);\n\n const handleFilterChange = useCallback(\n (newFilter: Filter | undefined) => {\n setInternalFilter(newFilter);\n setStoredValue(filterKey, newFilter);\n onFilterChange?.(newFilter);\n },\n [filterKey, onFilterChange],\n );\n\n return {\n filter: internalFilter,\n setFilter: handleFilterChange,\n };\n};\n\nexport const useSortStorage = (\n storageKey: string,\n externalSort?: Sort,\n onSortChange?: (sort: Sort | undefined) => void,\n) => {\n const sortKey = `${storageKey}:sort`;\n\n const [internalSort, setInternalSort] = useState<Sort | undefined>(() => {\n return getStoredValue<Sort>(sortKey) || externalSort;\n });\n\n // Sync with external sort\n useEffect(() => {\n if (externalSort !== undefined) {\n setInternalSort(externalSort);\n }\n }, [externalSort]);\n\n const handleSortChange = useCallback(\n (newSort: Sort | undefined) => {\n setInternalSort(newSort);\n setStoredValue(sortKey, newSort);\n onSortChange?.(newSort);\n },\n [sortKey, onSortChange],\n );\n\n return {\n sort: internalSort,\n setSort: handleSortChange,\n };\n};\n","import { useCallback, useMemo } from 'react';\nimport type { GridSortModel } from '@mui/x-data-grid-premium';\nimport { Field } from 'model/entity-metadata';\nimport { Sort, SortType } from 'model/filter';\n\nimport { UseSortingParams } from '../props';\n\n/**\n * Mapeia field.name (coluna do DataGrid) → filter_field_name (campo da API).\n * Usado quando o usuário clica no header da coluna para ordenar.\n */\nconst resolveApiFieldName = (\n fields: Field[] | undefined,\n fieldName: string,\n): string => {\n if (!fields) return fieldName;\n const field = fields.find(f => f.name === fieldName);\n return field?.filter_field_name ?? fieldName;\n};\n\n/**\n * Mapeia filter_field_name (campo da API) → field.name (coluna do DataGrid).\n * Usado para o sortModel destacar a coluna correta na UI.\n */\nconst resolveColumnFieldName = (\n fields: Field[] | undefined,\n fieldName: string,\n): string => {\n if (!fields) return fieldName;\n const field = fields.find(\n f => f.filter_field_name === fieldName || f.name === fieldName,\n );\n return field?.name ?? fieldName;\n};\n\nexport const useSorting = ({\n sort,\n onSortChange,\n fields,\n}: UseSortingParams) => {\n const sortModel: GridSortModel = useMemo(() => {\n if (!sort) return [];\n return [\n {\n field: resolveColumnFieldName(fields, sort.fieldName),\n sort: sort.sortType.toLowerCase() as 'asc' | 'desc',\n },\n ];\n }, [sort, fields]);\n\n const handleSortModelChange = useCallback(\n (model: GridSortModel) => {\n if (!onSortChange) return;\n\n const firstItem = model[0];\n if (!firstItem || !firstItem.sort) {\n onSortChange(undefined);\n return;\n }\n\n const newSort: Sort = {\n fieldName: resolveApiFieldName(fields, firstItem.field),\n sortType: firstItem.sort.toUpperCase() as SortType,\n };\n onSortChange(newSort);\n },\n [onSortChange, fields],\n );\n\n return {\n sortModel,\n handleSortModelChange,\n };\n};\n","import {\n AccessType,\n DataType,\n EntityMetadataResponse,\n Field,\n} from 'model/entity-metadata';\n\nexport const createActionsField = (): Field => ({\n name: 'ACTIONS',\n description: '',\n filter_field_name: null,\n type: DataType.TEXT,\n metadata: null,\n access_type: AccessType.READ_ONLY,\n relation_field_name: null,\n available_filter_conditions: [],\n});\n\nexport const addActionsFieldToMetadata = (\n metadata: EntityMetadataResponse,\n): EntityMetadataResponse => {\n const hasActionsField = metadata.fields.some(\n field => field.name === 'ACTIONS',\n );\n\n if (hasActionsField) {\n return metadata;\n }\n\n return {\n ...metadata,\n fields: [...metadata.fields, createActionsField()],\n };\n};\n","import { memo, ReactNode } from 'react';\n\nimport { DatePickerFormat, fDate } from 'utils/formatTime';\n\nimport type { DateRendererProps } from './props';\n\nconst DateRenderer = ({ value, format }: DateRendererProps): ReactNode => {\n if (value === null || value === undefined) return '-';\n\n return fDate(value as DatePickerFormat, format);\n};\n\nexport default memo(DateRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport { DatePickerFormat, fDateTime } from 'utils/formatTime';\n\nimport type { DateTimeRendererProps } from './props';\n\nconst DateTimeRenderer = ({\n value,\n format,\n}: DateTimeRendererProps): ReactNode => {\n if (value === null || value === undefined) return '-';\n\n return fDateTime(value as DatePickerFormat, format);\n};\n\nexport default memo(DateTimeRenderer);\n","import { memo, ReactNode } from 'react';\nimport Chip from '@mui/material/Chip';\n\nimport { EntityRendererProps } from './props';\n\nconst EntityRenderer = ({ value, field }: EntityRendererProps): ReactNode => {\n if (!field.metadata || typeof value !== 'object' || value === null) {\n return value ? String(value) : '-';\n }\n\n const entityValue = (value as Record<string, unknown>)[\n field.metadata.description_field_name\n ];\n\n if (!entityValue) return null;\n\n return (\n <Chip\n label={String(entityValue)}\n variant=\"outlined\"\n size=\"small\"\n sx={{\n width: 'fit-content',\n color: 'text.secondary',\n borderColor: 'divider',\n borderRadius: 3,\n }}\n />\n );\n};\n\nexport default memo(EntityRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport Icon, { IconEnum } from '../../Icon';\n\nimport { IconRendererProps } from './props';\n\nconst IconRenderer = ({\n value,\n trueIcon = IconEnum.STAR_02,\n falseIcon = IconEnum.STAR,\n color = 'primary.main',\n width = 18,\n}: IconRendererProps): ReactNode => {\n return (\n <Icon icon={value ? trueIcon : falseIcon} color={color} width={width} />\n );\n};\n\nexport default memo(IconRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport Icon from 'components/Icon';\n\nimport { ImageRendererProps } from './props';\nimport { ImageContainer } from './style';\n\nconst ImageRenderer = ({\n imageResourceId,\n getImageUrl,\n size = 48,\n alt = 'Imagem',\n onClick,\n sx,\n}: ImageRendererProps): ReactNode => {\n const hasImage = !!imageResourceId;\n const imageUrl =\n hasImage && getImageUrl ? getImageUrl(imageResourceId) : undefined;\n const clickable = !!onClick;\n\n return (\n <ImageContainer\n size={size}\n noImage={!hasImage}\n clickable={clickable}\n onClick={onClick}\n sx={sx}\n >\n {imageUrl ? (\n <img src={imageUrl} alt={alt} />\n ) : (\n <Icon\n icon=\"SEARCH_IMAGE\"\n width={Math.round(size / 2)}\n color=\"text.disabled\"\n />\n )}\n </ImageContainer>\n );\n};\n\nexport default memo(ImageRenderer);\n","import Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\n\n// StatusRenderer styles\nexport interface StatusLabelProps {\n isActive: boolean;\n}\n\nexport const StatusLabel = styled('span')<StatusLabelProps>(\n ({ theme, isActive }) => ({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: theme.spacing(0.2, 1),\n borderRadius: theme.shape.borderRadius,\n fontSize: '0.75rem',\n fontWeight: 600,\n width: 'fit-content',\n height: 'auto',\n lineHeight: '1.25rem',\n whiteSpace: 'nowrap',\n margin: 'auto',\n backgroundColor: isActive\n ? theme.palette.success.lighter || '#00A76F29'\n : theme.palette.warning.lighter || '#FF563029',\n color: isActive\n ? theme.palette.success.darker || '#007867'\n : theme.palette.warning.darker || '#B71D18',\n }),\n);\n\n// ImageRenderer styles\nexport interface ImageContainerProps {\n size: number;\n noImage: boolean;\n clickable: boolean;\n}\n\nexport const ImageContainer = styled(Box, {\n shouldForwardProp: prop =>\n !['size', 'noImage', 'clickable'].includes(prop as string),\n})<ImageContainerProps>(({ theme, size, noImage, clickable }) => ({\n width: size,\n height: size,\n minWidth: size,\n borderRadius: '50%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n cursor: clickable ? 'pointer' : 'default',\n transition: 'opacity 0.2s ease-in-out',\n color: theme.palette.text.disabled,\n ...(noImage && {\n border: `1px dashed ${theme.palette.divider}`,\n backgroundColor: theme.palette.grey[100],\n }),\n ...(clickable && {\n '&:hover': {\n opacity: 0.8,\n },\n }),\n '& img': {\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n borderRadius: '50%',\n },\n [theme.breakpoints.down('sm')]: {\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n },\n}));\n","import { memo, ReactNode } from 'react';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport CopyButton from 'components/CopyButton';\n\nimport { NameRendererProps } from './props';\n\nconst NameRenderer = ({\n id,\n displayName,\n copyMessage = 'ID copiado!',\n}: NameRendererProps): ReactNode => {\n return (\n <Stack height={1} justifyContent=\"center\">\n <Typography variant=\"subtitle2\" noWrap title={displayName}>\n {displayName}\n </Typography>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <Typography color=\"grey.600\" variant=\"body2\" noWrap>\n ID: {id}\n </Typography>\n <CopyButton toCopy={id} message={copyMessage} />\n </Stack>\n </Stack>\n );\n};\n\nexport default memo(NameRenderer);\n","import { memo, ReactNode } from 'react';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport { fCurrencyBRL, fNumber } from 'utils/formatNumber';\n\nimport { NumberRendererProps } from './props';\n\nconst NumberRenderer = ({\n value,\n isCurrency = false,\n}: NumberRendererProps): ReactNode => {\n if (value === null || value === undefined) return '-';\n\n return (\n <Stack direction=\"row\" alignItems=\"center\" height=\"100%\">\n <Typography variant=\"body2\" noWrap width=\"fit-content\">\n {isCurrency ? fCurrencyBRL(Number(value)) : fNumber(Number(value))}\n </Typography>\n </Stack>\n );\n};\n\nexport default memo(NumberRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport { StatusRendererProps } from './props';\nimport { StatusLabel } from './style';\n\nconst StatusRenderer = ({\n active,\n activeLabel = 'Ativo',\n inactiveLabel = 'Inativo',\n}: StatusRendererProps): ReactNode => {\n return (\n <StatusLabel isActive={active}>\n {active ? activeLabel : inactiveLabel}\n </StatusLabel>\n );\n};\n\nexport default memo(StatusRenderer);\n","import { memo, ReactNode } from 'react';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport CopyButton from 'components/CopyButton';\n\nimport { TextRendererProps } from './props';\n\nconst sanitizeHtml = (text: string): string => {\n const withoutTags = text.replace(/<[^>]*>/g, '');\n return (\n withoutTags\n .replace(/ /g, ' ')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n // prettier-ignore\n .replace(/'/g, '\\'')\n .trim()\n );\n};\n\nconst TextRenderer = ({\n value,\n showCopyButton = false,\n copyMessage = 'Copiado',\n copyLabel,\n mask,\n}: TextRendererProps): ReactNode => {\n if (!value) return '-';\n\n const stringValue = String(value);\n const formattedValue = mask ? mask(stringValue) : sanitizeHtml(stringValue);\n\n if (showCopyButton) {\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <Typography variant=\"body2\" noWrap>\n {formattedValue}\n </Typography>\n <CopyButton\n toCopy={stringValue}\n message={copyMessage}\n label={copyLabel}\n />\n </Stack>\n );\n }\n\n return formattedValue;\n};\n\nexport default memo(TextRenderer);\n","import { ReactNode } from 'react';\nimport { Field } from 'model/entity-metadata';\n\nimport { CURRENCY_FIELD_NAMES } from '../constants/columnDefaults';\nimport { CellRenderer, DynamicRowData } from '../props';\nimport {\n DateRenderer,\n DateTimeRenderer,\n EntityRenderer,\n NumberRenderer,\n StatusRenderer,\n TextRenderer,\n} from '../renderers';\n\nfunction getIsCurrency(fieldName: string): boolean {\n return CURRENCY_FIELD_NAMES.includes(fieldName);\n}\n\nexport const createCellRenderer = <T extends object = object>(context: {\n onRowAction?: (rowId: string, row: DynamicRowData<T>) => ReactNode;\n}): CellRenderer<T> => {\n const { onRowAction } = context;\n\n const CellRendererComponent = (\n field: Field,\n row: DynamicRowData<T>,\n ): ReactNode => {\n const value = row[field.name];\n\n if (field.name === 'ACTIONS') {\n return onRowAction?.(row.id, row);\n }\n\n switch (field.type) {\n case 'BOOLEAN':\n return (\n <StatusRenderer\n active={Boolean(value)}\n activeLabel=\"Ativo\"\n inactiveLabel=\"Inativo\"\n />\n );\n\n case 'DATE':\n return <DateRenderer value={value} />;\n\n case 'DATETIME':\n return <DateTimeRenderer value={value} />;\n\n case 'DECIMAL':\n case 'INTEGER':\n return (\n <NumberRenderer\n value={value}\n isCurrency={getIsCurrency(field.name)}\n />\n );\n\n case 'FILE':\n case 'ENTITY':\n return <EntityRenderer value={value} field={field} />;\n case 'TEXT':\n default:\n return <TextRenderer value={value} />;\n }\n };\n\n CellRendererComponent.displayName = 'CellRendererComponent';\n return CellRendererComponent;\n};\n","import { GridColumnVisibilityModel } from '@mui/x-data-grid-premium';\nimport { EntityMetadataResponse } from 'model/entity-metadata';\n\ninterface BuildVisibleFieldsParams {\n metadata?: EntityMetadataResponse;\n columnVisibilityModel?: GridColumnVisibilityModel;\n defaultVisibleFields?: string[];\n}\n\nexport const buildVisibleFields = ({\n metadata,\n columnVisibilityModel,\n defaultVisibleFields,\n}: BuildVisibleFieldsParams): string[] | undefined => {\n if (!metadata?.fields) return undefined;\n\n const allFields = metadata.fields.map(f => f.name);\n\n const visible = allFields.filter(fieldName => {\n if (fieldName === 'ACTIONS') return false;\n\n if (columnVisibilityModel) {\n return columnVisibilityModel[fieldName] !== false;\n }\n\n return defaultVisibleFields?.includes(fieldName) ?? true;\n });\n\n if (!defaultVisibleFields) return visible;\n\n return visible.sort((a, b) => {\n const indexA = defaultVisibleFields.indexOf(a);\n const indexB = defaultVisibleFields.indexOf(b);\n\n return indexA - indexB || 0;\n });\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DynamicDataView/DynamicDataView.tsx","../../../src/components/DynamicDataView/components/FilterButton.tsx","../../../src/components/DynamicDataView/components/FiltersSection.tsx","../../../src/components/DynamicDataView/components/filters/FiltersContainer.tsx","../../../src/components/DynamicDataView/components/filters/FiltersContent.tsx","../../../src/components/DynamicDataView/utils/filter.ts","../../../src/components/DynamicDataView/components/filters/FiltersList.tsx","../../../src/components/DynamicDataView/components/filters/FilterRow.tsx","../../../src/components/DynamicDataView/constants/filter.ts","../../../src/components/DynamicDataView/components/filters/EntityFilter.tsx","../../../src/components/DynamicDataView/components/filters/OperatorSelect.tsx","../../../src/components/DynamicDataView/components/filters/styles.ts","../../../src/components/DynamicDataView/components/SortModal/index.tsx","../../../src/components/DynamicDataView/components/SortModal/style.ts","../../../src/components/DynamicDataView/hooks/useColumnOrdering.ts","../../../src/components/DynamicDataView/hooks/useColumnVisibility.ts","../../../src/components/DynamicDataView/hooks/useDynamicColumns.ts","../../../src/components/DynamicDataView/constants/columnDefaults.ts","../../../src/components/DynamicDataView/utils/columnStrategies.ts","../../../src/components/DynamicDataView/hooks/useFilters.ts","../../../src/components/DynamicDataView/hooks/useFilterSortStorage.ts","../../../src/components/DynamicDataView/hooks/useSorting.ts","../../../src/components/DynamicDataView/utils/addActionsField.ts","../../../src/components/DynamicDataView/renderers/DateRenderer.ts","../../../src/components/DynamicDataView/renderers/DateTimeRenderer.ts","../../../src/components/DynamicDataView/renderers/EntityRenderer.tsx","../../../src/components/DynamicDataView/renderers/IconRenderer.tsx","../../../src/components/DynamicDataView/renderers/ImageRenderer.tsx","../../../src/components/DynamicDataView/renderers/style.ts","../../../src/components/DynamicDataView/renderers/NameRenderer.tsx","../../../src/components/DynamicDataView/renderers/NumberRenderer.tsx","../../../src/components/DynamicDataView/renderers/StatusRenderer.tsx","../../../src/components/DynamicDataView/renderers/TextRenderer.tsx","../../../src/components/DynamicDataView/utils/createCellRenderer.tsx","../../../src/components/DynamicDataView/utils/fields.ts"],"names":["memo","useCallback","useMemo","useState","isEqual","Badge","Button","IconButton","Stack","jsx","jsxs","FilterButton","showFilterButton","isMobile","hasActiveFilters","activeFiltersCount","sort","onFilterClick","onSortClick","Icon_default","ToolbarActionsDivider","FilterButton_default","Divider","Typography","getFilterableFields","fields","field","getDefaultCondition","type","available_filter_conditions","isValidCondition","condition","buildFilterFromConditions","conditions","validConditions","c","FormControl","InputLabel","MenuItem","Select","TextField","CONDITION_LABELS","EntityFilter","config","metadata","value","initialLabel","onChange","disabled","open","setOpen","useToggle_default","searchInput","setSearchInput","debouncedSearch","useDebounceValue_default","data","isLoading","isFetching","loading","selectedOption","options","items","item","opt","handleOpen","handleClose","handleChange","newValue","option","handleSearch","val","Autocomplete_default","x","EntityFilter_default","OperatorSelect","totalConditions","isFirst","e","OperatorSelect_default","ellipsisStyle","FilterRow","onRemove","entityFilterConfig","selectedField","f","availableConditions","isValueDisabled","handleFieldChange","fieldName","newField","defaultCondition","handleConditionChange","conditional","handleValueChange","handleEntityValueChange","label","valueLabels","handleOperatorChange","operator","renderValueInput","currentValue","cond","FilterRow_default","Fragment","FiltersList","filterableFields","onUpdateCondition","onRemoveCondition","handleUpdateCondition","updated","handleRemoveCondition","id","usedFieldNames","name","getAvailableFields","currentFieldName","index","FiltersList_default","Box","styled","Container","Header","theme","Content","Footer","FiltersContent","onClose","onAddCondition","onApply","onClear","onCancel","hasConditions","handleApply","handleClear","handleCancel","FiltersContent_default","FiltersContainer","props","ResponsivePopover_default","FiltersContainer_default","FiltersSection","isOpen","filterAnchorEl","FiltersSection_default","useEffect","Dialog","DialogActions","DialogContent","DialogTitle","StyledDialog","StyledDialogTitle","StyledDialogContent","StyledDialogActions","ApplyButton","LabelButton","SortModal","onSortChange","setSelectedField","selectedDirection","setSelectedDirection","sortableFields","selectedFieldObj","isNumberField","SortModal_default","useColumnOrdering","columns","preferredFieldOrder","columnsByFieldId","column","fieldsByName","actionFieldName","preferredWithoutActions","usedColumnFieldIds","ordered","pushColumnForField","getColumnFieldIdFromField","useColumnVisibility","defaultVisibleFieldNames","columnVisibilityStorageKey","onColumnVisibilityModelChange","hasStorageKey","storedVisibilityModel","setStoredVisibilityModel","useLocalStorage_default","initialState","visibilityModel","columnFieldId","visible","stored","handleColumnVisibilityModelChange","model","modelToSave","COLUMN_DEFAULTS","ACCESS_TYPES","CURRENCY_FIELD_NAMES","createImageColumn","renderCell","params","createIdColumn","createEntityColumn","createDefaultColumn","createActionsColumn","getColumnStrategy","useDynamicColumns","columnStrategies","columnsMap","useRef","parseInitialConditions","initialFilter","uuidv4","useFilters","setIsOpen","appliedConditions","setAppliedConditions","appliedFilter","setAppliedFilter","setConditions","snapshotRef","openDrawer","closeDrawer","addCondition","availableFields","currentOperator","firstField","newCondition","prev","updateCondition","changes","targetCondition","newOperator","removeCondition","clearAllFilters","applyFilters","filter","cancelChanges","getStoredValue","key","setStoredValue","useFilterStorage","storageKey","externalFilter","onFilterChange","filterKey","internalFilter","setInternalFilter","handleFilterChange","newFilter","useSortStorage","externalSort","sortKey","internalSort","setInternalSort","handleSortChange","newSort","resolveApiFieldName","resolveColumnFieldName","useSorting","sortModel","handleSortModelChange","firstItem","createActionsField","addActionsFieldToMetadata","DateRenderer","format","fDate","DateRenderer_default","DateTimeRenderer","fDateTime","DateTimeRenderer_default","Chip","EntityRenderer","entityValue","EntityRenderer_default","IconRenderer","trueIcon","falseIcon","color","width","IconRenderer_default","StatusLabel","isActive","ImageContainer","prop","size","noImage","clickable","ImageRenderer","imageResourceId","getImageUrl","alt","onClick","sx","hasImage","imageUrl","ImageRenderer_default","NameRenderer","displayName","copyMessage","CopyButton_default","NameRenderer_default","NumberRenderer","isCurrency","fCurrencyBRL","fNumber","NumberRenderer_default","StatusRenderer","active","activeLabel","inactiveLabel","StatusRenderer_default","sanitizeHtml","text","TextRenderer","showCopyButton","copyLabel","mask","stringValue","formattedValue","TextRenderer_default","getIsCurrency","createCellRenderer","context","onRowAction","CellRendererComponent","row","DynamicDataView","title","page","perPage","searchValue","onSearchChange","onSearch","onPaginationChange","onAdd","onRowDoubleClick","actions","moreActions","bulkActions","rowSelectionModel","onRowSelectionModelChange","slots","mobileRender","containerHeight","showColumnButton","rows","total","preloadedMetadata","firstRow","effectiveMetadata","effectiveMetadataFields","orderedColumns","handleRowDoubleClick","rowId","useResponsive_default","setFilterAnchorEl","storedFilter","setStoredFilter","storedSort","setStoredSort","effectiveFilter","effectiveSort","handleApplyFilters","handleClearFilters","handleFilterButtonClick","event","handleCancelFilters","isSortModalOpen","setIsSortModalOpen","handleFiltersClose","hasSelectionActions","DataView_default","DynamicDataView_default","buildVisibleFields","columnVisibilityModel","defaultVisibleFields","a","b","indexA","indexB"],"mappings":"40CAAA,OAAS,QAAAA,GAAM,eAAAC,EAAa,WAAAC,GAAS,YAAAC,OAAgB,QACrD,OAAOC,OAAa,qBCDpB,OAAS,QAAAJ,OAAY,QACrB,OAAOI,OAAa,qBACpB,OAAOC,OAAW,sBAClB,OAAOC,OAAY,uBACnB,OAAOC,OAAgB,2BACvB,OAAOC,OAAW,sBAoBZ,OAmBM,OAAAC,EAnBN,QAAAC,OAAA,oBAbN,IAAMC,GAAe,CAAC,CACpB,iBAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,mBAAAC,EACA,KAAAC,EACA,cAAAC,EACA,YAAAC,CACF,IACON,EAEDC,EAEAH,GAACF,GAAA,CAAM,UAAU,MAAM,QAAS,GAC9B,UAAAC,EAACJ,GAAA,CACC,aAAcU,EACd,MAAM,UACN,UAAWA,IAAuB,EAClC,GAAI,CACF,oBAAqB,CACnB,UAAW,kCACX,QAASA,IAAuB,EAAI,EAAI,CAC1C,CACF,EAEA,SAAAN,EAACF,GAAA,CACC,MAAOO,EAAmB,UAAY,UACtC,QAASG,EACT,KAAK,QACL,aAAW,UACX,GAAI,CAAE,SAAU,SAAU,EAE1B,SAAAR,EAACU,EAAA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GACF,GAEJ,CAEJ,EAEOa,GAAQpX,GAAKsU,GAAiBlU,EAAO,EkCxSrC,IAAMiX,GAAqB,CAAC,CACjC,SAAAzU,EACA,sBAAA0U,EACA,qBAAAC,CACF,IAAsD,CACpD,GAAI,CAAC3U,GAAU,OAAQ,OAIvB,IAAMgJ,EAFYhJ,EAAS,OAAO,IAAIyC,GAAKA,EAAE,IAAI,EAEvB,OAAOI,GAC3BA,IAAc,UAAkB,GAEhC6R,EACKA,EAAsB7R,CAAS,IAAM,GAGvC8R,GAAsB,SAAS9R,CAAS,GAAK,EACrD,EAED,OAAK8R,EAEE3L,EAAQ,KAAK,CAAC4L,EAAGC,IAAM,CAC5B,IAAMC,EAASH,EAAqB,QAAQC,CAAC,EACvCG,EAASJ,EAAqB,QAAQE,CAAC,EAE7C,OAAOC,EAASC,GAAU,CAC5B,CAAC,EAPiC/L,CAQpC","sourcesContent":["import { memo, useCallback, useMemo, useState } from 'react';\nimport isEqual from 'react-fast-compare';\nimport { AccessType, DataType } from 'model/entity-metadata';\n\nimport useResponsive from 'hooks/useResponsive';\n\nimport DataView from '../DataView';\n\nimport FilterButton from './components/FilterButton';\nimport FiltersSection from './components/FiltersSection';\nimport SortModal from './components/SortModal';\nimport { useColumnOrdering } from './hooks/useColumnOrdering';\nimport { useColumnVisibility } from './hooks/useColumnVisibility';\nimport { useDynamicColumns } from './hooks/useDynamicColumns';\nimport { useFilters } from './hooks/useFilters';\nimport { useFilterStorage, useSortStorage } from './hooks/useFilterSortStorage';\nimport { useSorting } from './hooks/useSorting';\nimport { addActionsFieldToMetadata } from './utils/addActionsField';\nimport { createCellRenderer } from './utils/createCellRenderer';\nimport { DynamicDataViewProps, DynamicRowData } from './props';\n\nconst DynamicDataView = <T extends object = object>({\n title,\n metadata,\n data,\n isLoading,\n isFetching,\n page,\n perPage,\n searchValue,\n onSearchChange,\n onSearch,\n onPaginationChange,\n onAdd,\n onRowAction,\n onRowDoubleClick,\n actions,\n moreActions,\n bulkActions,\n rowSelectionModel,\n onRowSelectionModelChange,\n slots,\n mobileRender,\n containerHeight = 600,\n showColumnButton = false,\n showFilterButton = false,\n filter,\n onFilterChange,\n sort,\n onSortChange,\n defaultVisibleFieldNames,\n preferredFieldOrder,\n columnStrategies,\n onColumnVisibilityModelChange,\n storageKey,\n entityFilterConfig,\n}: DynamicDataViewProps<T>) => {\n const { items: rows = [], total = 0 } = data || {};\n\n // Criar metadata temporário baseado em data quando metadata não disponível\n const preloadedMetadata = useMemo(() => {\n if (metadata) return metadata;\n\n // Se não tem metadata mas tem dados, criar metadata baseado nas keys do primeiro item\n if (rows.length > 0) {\n const firstRow = rows[0];\n const fields = Object.keys(firstRow).map(key => ({\n name: key,\n type: DataType.TEXT,\n description: key,\n filter_field_name: null,\n metadata: null,\n access_type: AccessType.READ_ONLY,\n relation_field_name: null,\n available_filter_conditions: [],\n }));\n\n return {\n name: 'loading',\n description: 'Loading...',\n id_field_name: 'id',\n description_field_name: fields[0]?.name || 'id',\n access_type: AccessType.READ_ONLY,\n fields,\n };\n }\n\n return undefined;\n }, [metadata, rows]);\n\n const effectiveMetadata = useMemo(\n () =>\n preloadedMetadata && onRowAction\n ? addActionsFieldToMetadata(preloadedMetadata)\n : preloadedMetadata,\n [preloadedMetadata, onRowAction],\n );\n\n const effectiveMetadataFields = useMemo(\n () => effectiveMetadata?.fields || [],\n [effectiveMetadata],\n );\n\n const renderCell = useMemo(\n () =>\n createCellRenderer<T>({\n onRowAction,\n }),\n [onRowAction],\n );\n\n const columns = useDynamicColumns<T>({\n metadata: effectiveMetadata,\n renderCell,\n columnStrategies,\n });\n\n const { orderedColumns, columnsByFieldId } = useColumnOrdering({\n columns,\n fields: effectiveMetadata?.fields,\n preferredFieldOrder,\n });\n\n const { initialState, handleColumnVisibilityModelChange } =\n useColumnVisibility({\n fields: effectiveMetadata?.fields,\n columnsByFieldId,\n defaultVisibleFieldNames,\n columnVisibilityStorageKey: `${storageKey}:columns`,\n onColumnVisibilityModelChange,\n });\n\n const handleRowDoubleClick = useCallback(\n (params: { id: string | number; row: DynamicRowData<T> }) => {\n if (!onRowDoubleClick) return;\n\n const rowId = params.id?.toString() || '';\n onRowDoubleClick(rowId, params.row);\n },\n [onRowDoubleClick],\n );\n\n const isMobile = useResponsive('down', 'md');\n const [filterAnchorEl, setFilterAnchorEl] = useState<HTMLElement | null>(\n null,\n );\n\n const { filter: storedFilter, setFilter: setStoredFilter } = useFilterStorage(\n storageKey,\n filter,\n onFilterChange,\n );\n\n const { sort: storedSort, setSort: setStoredSort } = useSortStorage(\n storageKey,\n sort,\n onSortChange,\n );\n\n const effectiveFilter = filter ?? storedFilter;\n const effectiveSort = sort ?? storedSort;\n\n const { sortModel, handleSortModelChange } = useSorting({\n sort: effectiveSort,\n onSortChange: setStoredSort,\n fields: effectiveMetadataFields,\n });\n\n const {\n conditions,\n isOpen,\n openDrawer,\n closeDrawer,\n addCondition,\n updateCondition,\n removeCondition,\n clearAllFilters,\n applyFilters,\n cancelChanges,\n hasActiveFilters,\n activeFiltersCount,\n } = useFilters({\n fields: effectiveMetadataFields,\n initialFilter: effectiveFilter,\n });\n\n const handleApplyFilters = useCallback(() => {\n const newFilter = applyFilters();\n setStoredFilter(newFilter);\n }, [applyFilters, setStoredFilter]);\n\n const handleClearFilters = useCallback(() => {\n clearAllFilters();\n setStoredFilter(undefined);\n }, [clearAllFilters, setStoredFilter]);\n\n const handleFilterButtonClick = useCallback(\n (event: React.MouseEvent<HTMLElement>) => {\n if (isMobile) {\n openDrawer();\n } else {\n openDrawer();\n setFilterAnchorEl(event.currentTarget);\n }\n },\n [isMobile, openDrawer],\n );\n\n const handleCancelFilters = useCallback(() => {\n cancelChanges();\n setFilterAnchorEl(null);\n }, [cancelChanges]);\n\n const [isSortModalOpen, setIsSortModalOpen] = useState(false);\n\n const handleFiltersClose = useCallback(() => {\n setFilterAnchorEl(null);\n closeDrawer();\n }, [closeDrawer]);\n const hasSelectionActions = !!bulkActions?.length;\n\n return (\n <>\n <DataView<DynamicRowData<T>>\n title={title}\n columns={orderedColumns}\n rows={rows}\n mobileRender={mobileRender}\n rowCount={total}\n loading={isLoading || !metadata}\n fetching={isFetching}\n searchValue={searchValue}\n onSearch={onSearch}\n onSearchChange={onSearchChange}\n paginationModel={{\n page,\n pageSize: perPage,\n }}\n onPaginationChange={onPaginationChange}\n actions={actions}\n moreActions={moreActions}\n onAdd={onAdd}\n onRowDoubleClick={onRowDoubleClick ? handleRowDoubleClick : undefined}\n bulkActions={bulkActions}\n checkboxSelection={hasSelectionActions}\n rowSelectionModel={rowSelectionModel}\n onRowSelectionModelChange={onRowSelectionModelChange}\n keepNonExistentRowsSelected={hasSelectionActions}\n disableRowSelectionOnClick\n slots={slots}\n initialState={initialState}\n showColumnButton={showColumnButton}\n containerProps={{\n height: containerHeight,\n maxHeight: containerHeight,\n }}\n onColumnVisibilityModelChange={handleColumnVisibilityModelChange}\n filterButton={\n <FilterButton\n showFilterButton={showFilterButton}\n isMobile={isMobile}\n hasActiveFilters={hasActiveFilters}\n activeFiltersCount={activeFiltersCount}\n sort={effectiveSort}\n onFilterClick={handleFilterButtonClick}\n onSortClick={() => setIsSortModalOpen(true)}\n />\n }\n sortingMode=\"server\"\n sortModel={sortModel}\n onSortModelChange={handleSortModelChange}\n disableColumnFilter\n />\n {metadata && (\n <>\n <FiltersSection\n showFilterButton={showFilterButton}\n isOpen={isOpen}\n filterAnchorEl={filterAnchorEl}\n fields={effectiveMetadataFields}\n conditions={conditions}\n isMobile={isMobile}\n onClose={handleFiltersClose}\n onAddCondition={addCondition}\n onUpdateCondition={updateCondition}\n onRemoveCondition={removeCondition}\n onApply={handleApplyFilters}\n onClear={handleClearFilters}\n onCancel={handleCancelFilters}\n entityFilterConfig={entityFilterConfig}\n />\n\n <SortModal\n open={isSortModalOpen}\n onClose={() => setIsSortModalOpen(false)}\n fields={effectiveMetadataFields}\n sort={effectiveSort}\n onSortChange={setStoredSort}\n />\n </>\n )}\n </>\n );\n};\n\nexport default memo(DynamicDataView, isEqual) as typeof DynamicDataView;\nexport type { DynamicDataViewProps, DynamicRowData } from './props';\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport Badge from '@mui/material/Badge';\nimport Button from '@mui/material/Button';\nimport IconButton from '@mui/material/IconButton';\nimport Stack from '@mui/material/Stack';\n\nimport { ToolbarActionsDivider } from 'components/DataView';\nimport Icon from 'components/Icon';\n\nimport { FilterButtonProps } from '../props';\n\nconst FilterButton = ({\n showFilterButton,\n isMobile,\n hasActiveFilters,\n activeFiltersCount,\n sort,\n onFilterClick,\n onSortClick,\n}: FilterButtonProps) => {\n if (!showFilterButton) return null;\n\n if (isMobile) {\n return (\n <Stack direction=\"row\" spacing={0.5}>\n <Badge\n badgeContent={activeFiltersCount}\n color=\"primary\"\n invisible={activeFiltersCount === 0}\n sx={{\n '& .MuiBadge-badge': {\n transform: 'scale(0.9) translate(10px, 9px)',\n opacity: activeFiltersCount === 0 ? 0 : 1,\n },\n }}\n >\n <IconButton\n color={hasActiveFilters ? 'primary' : 'default'}\n onClick={onFilterClick}\n size=\"small\"\n aria-label=\"Filtrar\"\n sx={{ overflow: 'visible' }}\n >\n <Icon icon=\"FILTER_VERTICAL\" />\n </IconButton>\n </Badge>\n\n <ToolbarActionsDivider\n sx={{ height: 16 }}\n orientation=\"vertical\"\n flexItem\n />\n\n <IconButton\n color={sort ? 'primary' : 'default'}\n onClick={onSortClick}\n size=\"small\"\n aria-label=\"Ordenar\"\n >\n <Icon\n icon={sort?.sortType === 'DESC' ? 'SORTING_DESC' : 'SORTING_ASC'}\n />\n </IconButton>\n </Stack>\n );\n }\n\n return (\n <Badge\n badgeContent={activeFiltersCount}\n color=\"primary\"\n invisible={activeFiltersCount === 0}\n sx={{\n '& .MuiBadge-badge': activeFiltersCount\n ? {\n transform: 'scale(0.9) translate(-3px, 7px)',\n position: 'relative',\n opacity: 1,\n transition: 'none',\n }\n : {\n transition: 'none',\n opacity: 0,\n },\n }}\n >\n <Button\n variant=\"text\"\n color={hasActiveFilters ? 'primary' : 'inherit'}\n startIcon={<Icon icon=\"FILTER_VERTICAL\" />}\n onClick={onFilterClick}\n size=\"small\"\n >\n Filtrar\n </Button>\n </Badge>\n );\n};\n\nexport default memo(FilterButton, isEqual);\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\n\nimport { FiltersSectionProps } from '../props';\n\nimport FiltersContainer from './filters/FiltersContainer';\n\nconst FiltersSection = ({\n showFilterButton,\n isOpen,\n filterAnchorEl,\n fields,\n conditions,\n isMobile,\n onClose,\n onAddCondition,\n onUpdateCondition,\n onRemoveCondition,\n onApply,\n onClear,\n onCancel,\n entityFilterConfig,\n}: FiltersSectionProps) => {\n if (!showFilterButton) return null;\n\n return (\n <FiltersContainer\n open={isOpen || Boolean(filterAnchorEl)}\n anchorEl={filterAnchorEl}\n onClose={onClose}\n fields={fields}\n conditions={conditions}\n onAddCondition={onAddCondition}\n onUpdateCondition={onUpdateCondition}\n onRemoveCondition={onRemoveCondition}\n onApply={onApply}\n onClear={onClear}\n onCancel={onCancel}\n isMobileProp={isMobile}\n entityFilterConfig={entityFilterConfig}\n />\n );\n};\n\nexport default memo(FiltersSection, isEqual);\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\n\nimport ResponsivePopover from 'components/ResponsivePopover';\n\nimport FiltersContent from './FiltersContent';\nimport type { FiltersContainerProps } from './props';\n\nconst FiltersContainer = (props: FiltersContainerProps) => {\n return (\n <ResponsivePopover\n open={props.open}\n onClose={props.onClose}\n anchorEl={props.anchorEl}\n isMobile={props.isMobileProp}\n popoverProps={{\n slotProps: {\n paper: {\n sx: {\n width: 520,\n maxWidth: 'calc(100vw - 24px)',\n maxHeight: 600,\n mt: 1,\n },\n },\n },\n }}\n drawerProps={{\n anchor: 'right',\n PaperProps: {\n sx: {\n width: '100%',\n maxWidth: '100%',\n height: '100%',\n maxHeight: '100%',\n borderRadius: 0,\n },\n },\n }}\n >\n <FiltersContent {...props} />\n </ResponsivePopover>\n );\n};\n\nexport default memo(FiltersContainer, isEqual);\n","import { memo, useCallback } from 'react';\nimport isEqual from 'react-fast-compare';\nimport Button from '@mui/material/Button';\nimport Divider from '@mui/material/Divider';\nimport IconButton from '@mui/material/IconButton';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport Icon from 'components/Icon';\n\nimport { getFilterableFields } from '../../utils/filter';\n\nimport FiltersList from './FiltersList';\nimport type { FiltersPopoverProps } from './props';\nimport { Container, Content, Footer, Header } from './styles';\n\nconst FiltersContent = ({\n onClose,\n fields,\n conditions,\n onAddCondition,\n onUpdateCondition,\n onRemoveCondition,\n onApply,\n onClear,\n onCancel,\n entityFilterConfig,\n}: FiltersPopoverProps) => {\n const filterableFields = getFilterableFields(fields);\n const hasConditions = conditions.length > 0;\n\n const handleApply = useCallback(() => {\n onApply();\n onClose();\n }, [onApply, onClose]);\n\n const handleClear = useCallback(() => {\n onClear();\n onClose();\n }, [onClear, onClose]);\n\n const handleCancel = useCallback(() => {\n onCancel();\n }, [onCancel]);\n\n return (\n <Container>\n <Header>\n <Typography variant=\"overline\" fontWeight={600} color=\"text.secondary\">\n Defina as condições para filtrar\n </Typography>\n\n <IconButton\n onClick={onAddCondition}\n size=\"small\"\n aria-label=\"Adicionar filtro\"\n title=\"Adicionar filtro\"\n disabled={conditions.length >= filterableFields.length}\n >\n <Icon icon=\"SIMPLE_ADD\" />\n </IconButton>\n </Header>\n\n <Divider />\n\n <Content>\n <FiltersList\n filterableFields={filterableFields}\n conditions={conditions}\n onUpdateCondition={onUpdateCondition}\n onRemoveCondition={onRemoveCondition}\n entityFilterConfig={entityFilterConfig}\n />\n </Content>\n\n <Divider />\n\n <Footer>\n <Button variant=\"text\" color=\"inherit\" onClick={handleClear}>\n Limpar\n </Button>\n\n <Stack direction=\"row\" spacing={1}>\n <Button\n variant=\"outlined\"\n color=\"inherit\"\n onClick={handleCancel}\n startIcon={<Icon icon=\"CANCEL_CIRCLE\" />}\n >\n Cancelar\n </Button>\n <Button\n variant=\"contained\"\n onClick={handleApply}\n disabled={!hasConditions}\n startIcon={<Icon icon=\"SIMPLE_CHECK\" />}\n >\n Aplicar\n </Button>\n </Stack>\n </Footer>\n </Container>\n );\n};\n\nexport default memo(FiltersContent, isEqual);\n","import { Condition, DataType, Field } from 'model/entity-metadata';\nimport {\n Filter,\n FilterCondition,\n FilterOperator,\n FilterState,\n} from 'model/filter';\n\n/**\n * Campos filtráveis (campos com condições disponíveis)\n */\nexport const getFilterableFields = (fields: Field[]): Field[] => {\n return fields.filter(\n field =>\n field.available_filter_conditions &&\n field.available_filter_conditions.length > 0 &&\n field.name !== 'ACTIONS',\n );\n};\n\n/**\n * Converte FilterState para formato de API\n */\nexport const buildFilterFromState = (\n state: FilterState,\n): Filter | undefined => {\n const entries = Object.entries(state).filter(\n ([, value]) => value.value.length > 0,\n );\n if (entries.length === 0) return undefined;\n return {\n operator: FilterOperator.AND,\n groups: [\n {\n operator: FilterOperator.AND,\n conditionals: entries.map(([, filterValue]) => ({\n fieldName: filterValue.fieldName,\n conditional: filterValue.conditional,\n value: filterValue.value,\n })),\n },\n ],\n };\n};\n\n/**\n * Retorna o conditional padrão para um tipo de campo\n */\nexport const getDefaultCondition = (field: Field): Condition => {\n const { type, available_filter_conditions } = field;\n if (available_filter_conditions.length === 0) return Condition.EQUALS;\n if (\n type === DataType.TEXT &&\n available_filter_conditions.includes(Condition.LIKE)\n ) {\n return Condition.LIKE;\n }\n return available_filter_conditions[0];\n};\n\n/**\n * Verifica se uma condição é válida (tem valor ou não requer valor)\n */\nexport const isValidCondition = (condition: FilterCondition): boolean => {\n return (\n condition.value.length > 0 ||\n condition.conditional === Condition.IS_NULL ||\n condition.conditional === Condition.IS_NOT_NULL\n );\n};\n\n/**\n * Converte array de FilterCondition para Filter API\n */\nexport const buildFilterFromConditions = (\n conditions: FilterCondition[],\n): Filter | undefined => {\n if (conditions.length === 0) return undefined;\n\n const validConditions = conditions.filter(isValidCondition);\n if (validConditions.length === 0) return undefined;\n\n return {\n operator: FilterOperator.AND,\n groups: [\n {\n operator: validConditions[0]?.operator || FilterOperator.AND,\n conditionals: validConditions.map(c => ({\n fieldName: c.fieldName,\n conditional: c.conditional,\n value: c.value,\n })),\n },\n ],\n };\n};\n","import { memo, useCallback, useMemo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport Typography from '@mui/material/Typography';\nimport type { FilterCondition } from 'model/filter';\n\nimport FilterRow from './FilterRow';\nimport type { FiltersListProps } from './props';\n\nconst FiltersList = ({\n filterableFields,\n conditions,\n onUpdateCondition,\n onRemoveCondition,\n entityFilterConfig,\n}: FiltersListProps) => {\n const handleUpdateCondition = useCallback(\n (updated: FilterCondition) => {\n onUpdateCondition(updated.id, updated);\n },\n [onUpdateCondition],\n );\n\n const handleRemoveCondition = useCallback(\n (id: string) => () => {\n onRemoveCondition(id);\n },\n [onRemoveCondition],\n );\n\n const usedFieldNames = useMemo(\n () =>\n conditions.map(c => c.fieldName).filter((name): name is string => !!name),\n [conditions],\n );\n\n const getAvailableFields = useCallback(\n (currentFieldName: string | undefined) =>\n filterableFields.filter(\n field =>\n !usedFieldNames.includes(field.name) ||\n field.name === currentFieldName,\n ),\n [filterableFields, usedFieldNames],\n );\n\n if (filterableFields.length === 0) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\" textAlign=\"center\">\n Nenhum filtro disponível\n </Typography>\n );\n }\n\n if (conditions.length === 0) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\" textAlign=\"center\">\n Clique em{' '}\n <Typography\n component=\"strong\"\n variant=\"body2\"\n fontWeight={600}\n color=\"text.primary\"\n >\n "+"\n </Typography>{' '}\n para adicionar um filtro\n </Typography>\n );\n }\n\n return (\n <>\n {conditions.map((condition, index) => (\n <FilterRow\n key={condition.id}\n condition={condition}\n fields={getAvailableFields(condition.fieldName)}\n onChange={handleUpdateCondition}\n onRemove={handleRemoveCondition(condition.id)}\n showOperator={index > 0}\n totalConditions={conditions.length}\n isFirst={index === 0}\n entityFilterConfig={entityFilterConfig}\n />\n ))}\n </>\n );\n};\n\nexport default memo(FiltersList, isEqual);\n","import { memo, useCallback, useMemo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport FormControl from '@mui/material/FormControl';\nimport IconButton from '@mui/material/IconButton';\nimport InputLabel from '@mui/material/InputLabel';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select from '@mui/material/Select';\nimport Stack from '@mui/material/Stack';\nimport TextField from '@mui/material/TextField';\nimport { Condition } from 'model/entity-metadata';\nimport { FilterOperator } from 'model/filter';\n\nimport Icon from 'components/Icon';\n\nimport { CONDITION_LABELS } from '../../constants/filter';\n\nimport EntityFilter from './EntityFilter';\nimport OperatorSelect from './OperatorSelect';\nimport type { FilterRowProps } from './props';\n\nconst ellipsisStyle = {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n} as const;\n\nconst FilterRow = ({\n condition,\n fields,\n onChange,\n onRemove,\n totalConditions,\n isFirst,\n entityFilterConfig,\n}: FilterRowProps) => {\n const selectedField = useMemo(\n () =>\n fields.find(f => (f.filter_field_name ?? f.name) === condition.fieldName),\n [fields, condition.fieldName],\n );\n\n const availableConditions = useMemo(\n () => selectedField?.available_filter_conditions || [],\n [selectedField],\n );\n\n const isValueDisabled = useMemo(\n () =>\n !condition.fieldName ||\n condition.conditional === 'IS_NULL' ||\n condition.conditional === 'IS_NOT_NULL',\n [condition.fieldName, condition.conditional],\n );\n\n const handleFieldChange = useCallback(\n (fieldName: string) => {\n const newField = fields.find(\n f => (f.filter_field_name ?? f.name) === fieldName,\n );\n if (!newField) return;\n\n const defaultCondition =\n newField.available_filter_conditions[0] || 'EQUALS';\n\n onChange({\n ...condition,\n fieldName,\n conditional: defaultCondition,\n value: [],\n });\n },\n [fields, condition, onChange],\n );\n\n const handleConditionChange = useCallback(\n (conditional: Condition) => {\n onChange({\n ...condition,\n conditional,\n });\n },\n [condition, onChange],\n );\n\n const handleValueChange = useCallback(\n (value: string) => {\n onChange({\n ...condition,\n value: value ? [value] : [],\n });\n },\n [condition, onChange],\n );\n\n const handleEntityValueChange = useCallback(\n (value: string, label?: string) => {\n const valueLabels = { ...condition.valueLabels };\n if (value && label) {\n valueLabels[value] = label;\n }\n onChange({\n ...condition,\n value: value ? [value] : [],\n valueLabels,\n });\n },\n [condition, onChange],\n );\n\n const handleOperatorChange = useCallback(\n (operator: FilterOperator) => {\n onChange({\n ...condition,\n operator,\n });\n },\n [condition, onChange],\n );\n\n const renderValueInput = () => {\n if (selectedField?.type === 'BOOLEAN') {\n return (\n <FormControl\n size=\"small\"\n sx={{ flex: 1, minWidth: 120 }}\n disabled={isValueDisabled}\n >\n <InputLabel id={`value-label-${condition.id}`}>Valor</InputLabel>\n <Select\n labelId={`value-label-${condition.id}`}\n label=\"Valor\"\n value={condition.value[0] || ''}\n onChange={e => handleValueChange(e.target.value)}\n size=\"small\"\n sx={{\n '& .MuiSelect-select': ellipsisStyle,\n }}\n >\n <MenuItem value=\"true\">Verdadeiro</MenuItem>\n <MenuItem value=\"false\">Falso</MenuItem>\n </Select>\n </FormControl>\n );\n }\n\n if (\n selectedField?.type === 'ENTITY' &&\n selectedField.metadata &&\n entityFilterConfig?.[selectedField.metadata.name]\n ) {\n const currentValue = condition.value[0] || '';\n return (\n <EntityFilter\n config={entityFilterConfig[selectedField.metadata.name]}\n metadata={selectedField.metadata}\n value={currentValue}\n initialLabel={condition.valueLabels?.[currentValue]}\n onChange={handleEntityValueChange}\n disabled={isValueDisabled}\n />\n );\n }\n\n return (\n <TextField\n label=\"Filtro\"\n value={condition.value[0] || ''}\n onChange={e => handleValueChange(e.target.value)}\n size=\"small\"\n disabled={isValueDisabled}\n InputLabelProps={{ shrink: true }}\n sx={{ flex: 1, minWidth: 120 }}\n />\n );\n };\n\n return (\n <Stack direction=\"row\" spacing={1} alignItems=\"center\">\n <IconButton\n onClick={onRemove}\n size=\"small\"\n aria-label=\"Remover filtro\"\n sx={{ flexShrink: 0 }}\n >\n <Icon icon=\"CLOSE_MARK_BUTTON\" width={18} />\n </IconButton>\n\n <OperatorSelect\n value={condition.operator}\n onChange={handleOperatorChange}\n totalConditions={totalConditions}\n isFirst={isFirst}\n />\n\n <FormControl size=\"small\" sx={{ minWidth: 150, flex: 1 }}>\n <InputLabel id={`field-label-${condition.id}`}>Coluna</InputLabel>\n <Select\n labelId={`field-label-${condition.id}`}\n label=\"Coluna\"\n value={condition.fieldName}\n onChange={e => handleFieldChange(e.target.value)}\n size=\"small\"\n sx={{\n '& .MuiSelect-select': ellipsisStyle,\n }}\n >\n {fields.map(field => (\n <MenuItem\n key={field.name}\n value={field.filter_field_name ?? field.name}\n sx={ellipsisStyle}\n title={field.description || field.name}\n >\n {field.description || field.name}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n <FormControl\n size=\"small\"\n sx={{ minWidth: 90 }}\n disabled={!condition.fieldName}\n >\n <InputLabel id={`condition-label-${condition.id}`}>Condição</InputLabel>\n <Select\n labelId={`condition-label-${condition.id}`}\n label=\"Condição\"\n value={condition.conditional}\n onChange={e => handleConditionChange(e.target.value as Condition)}\n size=\"small\"\n sx={{\n '& .MuiSelect-select': ellipsisStyle,\n }}\n >\n {availableConditions.map(cond => (\n <MenuItem key={cond} value={cond} sx={ellipsisStyle}>\n {CONDITION_LABELS[cond as Condition] || cond}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n {renderValueInput()}\n </Stack>\n );\n};\n\nexport default memo(FilterRow, isEqual);\n","import { Condition } from 'model/entity-metadata';\n\nexport const CONDITION_LABELS: Record<Condition, string> = {\n [Condition.EQUALS]: 'Igual a',\n [Condition.NOT_EQUALS]: 'Diferente de',\n [Condition.LIKE]: 'Contém',\n [Condition.NOT_LIKE]: 'Não contém',\n [Condition.GREATER_THAN]: 'Maior que',\n [Condition.LESS_THAN]: 'Menor que',\n [Condition.GREATER_THAN_OR_EQUAL]: 'Maior ou igual a',\n [Condition.LESS_THAN_OR_EQUAL]: 'Menor ou igual a',\n [Condition.IN]: 'Em',\n [Condition.NOT_IN]: 'Não em',\n [Condition.IS_NULL]: 'É nulo',\n [Condition.IS_NOT_NULL]: 'Não é nulo',\n};\n","import { memo, useCallback, useMemo, useState } from 'react';\n\nimport Autocomplete from 'components/Autocomplete';\nimport useDebounceValue from 'hooks/useDebounceValue';\nimport useToggle from 'hooks/useToggle';\nimport type { Option } from 'types/option';\n\nimport type { EntityFilterProps } from './props';\n\nconst EntityFilter = ({\n config,\n metadata,\n value,\n initialLabel,\n onChange,\n disabled = false,\n}: EntityFilterProps) => {\n const [open, , setOpen] = useToggle(false);\n const [searchInput, setSearchInput] = useState('');\n const debouncedSearch = useDebounceValue(searchInput, 400);\n\n const { data, isLoading, isFetching } = config.useQuery(\n {\n search: debouncedSearch || undefined,\n page: 0,\n perPage: 25,\n ...config.queryParams,\n },\n { skip: !open },\n );\n\n const loading = isLoading || isFetching;\n\n const selectedOption = useMemo<Option | null>(() => {\n if (!value) return null;\n return { value, label: initialLabel ?? value };\n }, [value, initialLabel]);\n\n const options = useMemo<Option[]>(() => {\n const items: Option[] = (data?.items ?? [])\n .map(item => ({\n label: String(item[metadata.description_field_name] ?? ''),\n value: String(item[metadata.id_field_name] ?? ''),\n }))\n .filter(opt => opt.value && opt.label);\n\n if (\n selectedOption &&\n !items.some(\n opt => opt.value.toString() === selectedOption.value.toString(),\n )\n ) {\n items.unshift(selectedOption);\n }\n\n return items;\n }, [\n data,\n metadata.id_field_name,\n metadata.description_field_name,\n selectedOption,\n ]);\n\n const handleOpen = useCallback(() => setOpen(true), [setOpen]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n setSearchInput('');\n }, [setOpen]);\n\n const handleChange = useCallback(\n (newValue: string) => {\n if (!newValue) {\n onChange('', undefined);\n return;\n }\n const option = options.find(opt => opt.value.toString() === newValue);\n onChange(newValue, option?.label);\n },\n [onChange, options],\n );\n\n const handleSearch = useCallback((val?: string) => {\n setSearchInput(val ?? '');\n }, []);\n\n return (\n <Autocomplete\n name={`entity-filter-${metadata.name}`}\n label=\"Filtro\"\n value={value || ''}\n options={options}\n onChange={handleChange}\n onSearch={handleSearch}\n loading={loading}\n disabled={disabled}\n size=\"small\"\n filterOptions={x => x}\n noOptionsText={\n searchInput !== debouncedSearch ? 'Buscando...' : 'Nenhum resultado'\n }\n InputLabelProps={{ shrink: true }}\n sx={{ flex: 1, minWidth: 120 }}\n open={open}\n onOpen={handleOpen}\n onClose={handleClose}\n />\n );\n};\n\nexport default memo(EntityFilter);\n","import { memo } from 'react';\nimport isEqual from 'react-fast-compare';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select from '@mui/material/Select';\nimport Stack from '@mui/material/Stack';\nimport { FilterOperator } from 'model/filter';\n\nimport type { OperatorSelectProps } from './props';\n\nconst OperatorSelect = ({\n value,\n onChange,\n totalConditions,\n isFirst,\n}: OperatorSelectProps) => {\n if (totalConditions === 1) {\n return null;\n }\n\n if (isFirst) {\n return <Stack sx={{ width: 55, flexShrink: 0 }} />;\n }\n\n return (\n <Select\n value={value}\n onChange={e => onChange(e.target.value as FilterOperator)}\n size=\"small\"\n sx={{ width: 55, flexShrink: 0 }}\n >\n <MenuItem value={FilterOperator.AND}>e</MenuItem>\n <MenuItem value={FilterOperator.OR}>ou</MenuItem>\n </Select>\n );\n};\n\nexport default memo(OperatorSelect, isEqual);\n","import Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\n\n// Estilos baseados no Drawer/Popover para garantir consistência\nexport const Container = styled(Box)({\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n // No popover, a altura será controlada pelo max-height do container\n});\n\nexport const Header = styled(Box)(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: theme.spacing(2, 3),\n}));\n\nexport const Content = styled(Box)(({ theme }) => ({\n flex: 1,\n overflowY: 'auto',\n padding: theme.spacing(3),\n display: 'flex',\n flexDirection: 'column',\n gap: theme.spacing(2),\n}));\n\nexport const Footer = styled(Box)(({ theme }) => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: theme.spacing(2),\n}));\n","import { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport Button from '@mui/material/Button';\nimport FormControl from '@mui/material/FormControl';\nimport InputLabel from '@mui/material/InputLabel';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select from '@mui/material/Select';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\nimport { SortType } from 'model/filter';\n\nimport Icon from 'components/Icon';\n\nimport { SortModalProps } from './props';\nimport {\n ApplyButton,\n LabelButton,\n StyledDialog,\n StyledDialogActions,\n StyledDialogContent,\n StyledDialogTitle,\n} from './style';\n\nconst SortModal = ({\n open,\n onClose,\n fields,\n sort,\n onSortChange,\n}: SortModalProps) => {\n const [selectedField, setSelectedField] = useState<string>(\n sort?.fieldName || '',\n );\n const [selectedDirection, setSelectedDirection] = useState<SortType>(\n sort?.sortType || SortType.ASC,\n );\n\n const sortableFields = useMemo(\n () =>\n fields.filter(\n field => field.name !== 'ACTIONS' && field.access_type !== 'WRITE_ONLY',\n ),\n [fields],\n );\n\n const selectedFieldObj = useMemo(\n () =>\n fields.find(\n field => (field.filter_field_name ?? field.name) === selectedField,\n ),\n [fields, selectedField],\n );\n\n const isNumberField =\n selectedFieldObj?.type === 'DECIMAL' ||\n selectedFieldObj?.type === 'INTEGER';\n\n useEffect(() => {\n if (open) {\n setSelectedField(sort?.fieldName || '');\n setSelectedDirection(sort?.sortType || SortType.ASC);\n }\n }, [open, sort]);\n\n const handleApply = useCallback(() => {\n if (onSortChange) {\n if (!selectedField) {\n onSortChange(undefined);\n } else {\n onSortChange({\n fieldName: selectedField,\n sortType: selectedDirection,\n });\n }\n }\n onClose();\n }, [onSortChange, selectedField, selectedDirection, onClose]);\n\n const handleClear = useCallback(() => {\n if (!onSortChange) return;\n\n setSelectedField('');\n setSelectedDirection(SortType.ASC);\n\n onSortChange(undefined);\n onClose();\n }, [onSortChange, onClose]);\n\n return (\n <StyledDialog open={open} onClose={onClose} maxWidth=\"xs\" fullWidth>\n <StyledDialogTitle>\n <Typography variant=\"overline\" color=\"text.secondary\">\n Ordenar por\n </Typography>\n </StyledDialogTitle>\n <StyledDialogContent>\n <Stack spacing={2} pt={2}>\n <FormControl fullWidth size=\"small\">\n <InputLabel id=\"sort-field-label\">Campo</InputLabel>\n <Select\n labelId=\"sort-field-label\"\n value={selectedField}\n label=\"Campo\"\n onChange={e => setSelectedField(e.target.value)}\n >\n <MenuItem value=\"\">\n <em>Nenhum</em>\n </MenuItem>\n {sortableFields.map(field => (\n <MenuItem\n key={field.name}\n value={field.filter_field_name ?? field.name}\n >\n {field.description || field.name}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n <FormControl fullWidth size=\"small\" disabled={!selectedField}>\n <InputLabel id=\"sort-direction-label\">Direção</InputLabel>\n <Select\n labelId=\"sort-direction-label\"\n value={selectedDirection}\n label=\"Direção\"\n onChange={e => setSelectedDirection(e.target.value as SortType)}\n >\n <MenuItem value={SortType.ASC}>\n Crescente {isNumberField ? '(1-9)' : '(A-Z)'}\n </MenuItem>\n <MenuItem value={SortType.DESC}>\n Decrescente {isNumberField ? '(9-1)' : '(Z-A)'}\n </MenuItem>\n </Select>\n </FormControl>\n </Stack>\n </StyledDialogContent>\n <StyledDialogActions>\n <Stack flex={1} width=\"100%\" direction=\"row\">\n <Button color=\"inherit\" onClick={handleClear}>\n Limpar\n </Button>\n </Stack>\n <Button\n onClick={onClose}\n variant=\"outlined\"\n color=\"inherit\"\n sx={{ minWidth: 24 }}\n >\n <Icon icon=\"CANCEL_CIRCLE\" />\n <LabelButton>Cancelar</LabelButton>\n </Button>\n <ApplyButton onClick={handleApply} variant=\"contained\">\n <Icon icon=\"SIMPLE_CHECK\" />\n <LabelButton>Aplicar</LabelButton>\n </ApplyButton>\n </StyledDialogActions>\n </StyledDialog>\n );\n};\n\nSortModal.displayName = 'SortModal';\n\nexport default memo(SortModal);\n","import Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nexport const StyledDialog = styled(Dialog)(() => ({\n '& .MuiDialog-paper': { width: '100%' },\n}));\n\nexport const StyledDialogTitle = styled(DialogTitle)(({ theme }) => ({\n borderBottom: '1px solid',\n borderColor: theme.palette.divider,\n padding: theme.spacing(1.5, 2),\n}));\n\nexport const StyledDialogContent = styled(DialogContent)(({ theme }) => ({\n padding: theme.spacing(2),\n}));\n\nexport const StyledDialogActions = styled(DialogActions)(({ theme }) => ({\n borderTop: '1px solid',\n borderColor: theme.palette.divider,\n padding: theme.spacing(1.5, 2),\n}));\n\nexport const ApplyButton = styled(Button)(({ theme }) => ({\n minWidth: 24,\n [theme.breakpoints.down(330)]: {\n padding: theme.spacing(1),\n },\n}));\n\nexport const LabelButton = styled(Typography)(({ theme }) => ({\n fontWeight: '600',\n margin: theme.spacing(0, 1),\n [theme.breakpoints.down(330)]: {\n fontSize: 0,\n margin: 0,\n },\n}));\n","import { useMemo } from 'react';\nimport type { GridColDef } from '@mui/x-data-grid-premium';\n\nimport { UseColumnOrderingParams } from '../props';\n\nexport const useColumnOrdering = ({\n columns,\n fields,\n preferredFieldOrder,\n}: UseColumnOrderingParams) => {\n const columnsByFieldId = useMemo(\n () => new Map(columns.map(column => [column.field, column])),\n [columns],\n );\n\n const fieldsByName = useMemo(\n () => new Map(fields?.map(f => [f.name, f]) || []),\n [fields],\n );\n\n const orderedColumns = useMemo(() => {\n if (!preferredFieldOrder || preferredFieldOrder.length === 0 || !fields) {\n return columns;\n }\n\n const actionFieldName = 'ACTIONS';\n const preferredWithoutActions = preferredFieldOrder.filter(\n fieldName => fieldName !== actionFieldName,\n );\n\n const usedColumnFieldIds = new Set<string>();\n const ordered: GridColDef[] = [];\n\n const pushColumnForField = (fieldName: string) => {\n const field = fieldsByName.get(fieldName);\n if (!field) return;\n\n const column = columnsByFieldId.get(field.name);\n\n if (!column || usedColumnFieldIds.has(field.name)) return;\n\n ordered.push(column);\n usedColumnFieldIds.add(field.name);\n };\n\n preferredWithoutActions.forEach(fieldName => {\n pushColumnForField(fieldName);\n });\n\n fields.forEach(field => {\n if (field.name === actionFieldName) return;\n if (preferredWithoutActions.includes(field.name)) return;\n\n const column = columnsByFieldId.get(field.name);\n\n if (!column || usedColumnFieldIds.has(field.name)) return;\n\n ordered.push(column);\n usedColumnFieldIds.add(field.name);\n });\n\n pushColumnForField(actionFieldName);\n\n return ordered.length === 0 ? columns : ordered;\n }, [columns, columnsByFieldId, fieldsByName, preferredFieldOrder, fields]);\n\n return { orderedColumns, columnsByFieldId, fieldsByName };\n};\n","import { useCallback, useMemo } from 'react';\nimport type { GridColumnVisibilityModel } from '@mui/x-data-grid-premium';\nimport { Field } from 'model/entity-metadata';\n\nimport useLocalStorage from 'hooks/useLocalStorage';\n\nimport { UseColumnVisibilityParams } from '../props';\n\nfunction getColumnFieldIdFromField(field: Field): string {\n return field.name;\n}\n\nexport const useColumnVisibility = ({\n fields,\n columnsByFieldId,\n defaultVisibleFieldNames,\n columnVisibilityStorageKey,\n onColumnVisibilityModelChange,\n}: UseColumnVisibilityParams) => {\n const hasStorageKey = Boolean(columnVisibilityStorageKey);\n\n const [storedVisibilityModel, setStoredVisibilityModel] = useLocalStorage<\n GridColumnVisibilityModel | undefined\n >(columnVisibilityStorageKey || '__dynamic-data-view:columns__', undefined, {\n initializeWithValue: hasStorageKey,\n });\n\n const initialState = useMemo(() => {\n if (!fields) return undefined;\n\n const visibilityModel: GridColumnVisibilityModel = {};\n\n fields.forEach(field => {\n const columnFieldId = getColumnFieldIdFromField(field);\n if (!columnsByFieldId.has(columnFieldId)) return;\n\n let visible: boolean | undefined;\n\n if (hasStorageKey && storedVisibilityModel) {\n const stored = storedVisibilityModel[columnFieldId];\n if (typeof stored === 'boolean') {\n visible = stored;\n }\n }\n\n if (\n visible === undefined &&\n defaultVisibleFieldNames &&\n defaultVisibleFieldNames.length > 0\n ) {\n visible = defaultVisibleFieldNames.includes(field.name);\n }\n\n if (typeof visible === 'boolean') {\n visibilityModel[columnFieldId] = visible;\n }\n });\n\n if (Object.keys(visibilityModel).length === 0) return undefined;\n\n return {\n columns: {\n columnVisibilityModel: visibilityModel,\n },\n };\n }, [\n columnsByFieldId,\n defaultVisibleFieldNames,\n fields,\n hasStorageKey,\n storedVisibilityModel,\n ]);\n\n const handleColumnVisibilityModelChange = useCallback(\n (model: GridColumnVisibilityModel) => {\n if (hasStorageKey) {\n const modelToSave = { ...model };\n // Prevents __check__ (checkboxSelection column) from being permanently hidden in local storage\n delete modelToSave['__check__'];\n setStoredVisibilityModel(modelToSave);\n }\n\n if (onColumnVisibilityModelChange) {\n onColumnVisibilityModelChange(model);\n }\n },\n [hasStorageKey, onColumnVisibilityModelChange, setStoredVisibilityModel],\n );\n\n return {\n initialState,\n handleColumnVisibilityModelChange,\n };\n};\n","import { useMemo } from 'react';\nimport { GridColDef } from '@mui/x-data-grid-premium';\n\nimport { Columns } from 'types/datagrid';\n\nimport { ACCESS_TYPES } from '../constants/columnDefaults';\nimport { UseDynamicColumnsProps } from '../props';\nimport { getColumnStrategy } from '../utils/columnStrategies';\n\nexport const useDynamicColumns = <T extends object>({\n metadata,\n renderCell,\n columnStrategies,\n}: UseDynamicColumnsProps<T>): Columns => {\n return useMemo(() => {\n if (!metadata?.fields) return [];\n\n const columnsMap = new Map<string, GridColDef>();\n\n const visibleFields = metadata.fields.filter(field => {\n if (\n field.access_type === ACCESS_TYPES.READ_ONLY ||\n field.access_type === ACCESS_TYPES.READ_AND_WRITE\n ) {\n return true;\n }\n\n return (\n field.name === 'ACTIONS' ||\n field.name === metadata?.id_field_name ||\n field.name === 'NAME'\n );\n });\n\n visibleFields.forEach(field => {\n if (columnsMap.has(field.name)) {\n return;\n }\n\n const strategy =\n columnStrategies?.[field.name] ?? getColumnStrategy<T>(field, metadata);\n const column = strategy(field, renderCell, metadata);\n\n columnsMap.set(field.name, column);\n });\n\n return Array.from(columnsMap.values());\n }, [columnStrategies, metadata, renderCell]);\n};\n","export const COLUMN_DEFAULTS = {\n IMAGE_WIDTH: 90,\n MIN_WIDTH: 130,\n ENTITY_MIN_WIDTH: 100,\n ENTITY_FLEX: 0.5,\n ID_MIN_WIDTH: 200,\n ID_FLEX: 1,\n ACTIONS_WIDTH: 80,\n} as const;\n\nexport const ACCESS_TYPES = {\n READ_ONLY: 'READ_ONLY',\n READ_AND_WRITE: 'READ_AND_WRITE',\n} as const;\n\nexport const CURRENCY_FIELD_NAMES: readonly string[] = [\n 'price',\n 'base_price',\n 'minimum_value',\n 'maximum_value',\n 'minimum_installment_value',\n];\n","import { GridColDef, GridRenderCellParams } from '@mui/x-data-grid-premium';\nimport { Field } from 'model/entity-metadata';\n\nimport { COLUMN_DEFAULTS } from '../constants/columnDefaults';\nimport { CellRenderer, ColumnStrategy, DynamicRowData } from '../props';\n\nconst createImageColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n sortable: false,\n width: COLUMN_DEFAULTS.IMAGE_WIDTH,\n resizable: false,\n headerAlign: 'center',\n align: 'center',\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createIdColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n minWidth: COLUMN_DEFAULTS.ID_MIN_WIDTH,\n flex: COLUMN_DEFAULTS.ID_FLEX,\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createEntityColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n minWidth: COLUMN_DEFAULTS.ENTITY_MIN_WIDTH,\n flex: COLUMN_DEFAULTS.ENTITY_FLEX,\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createDefaultColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: field.description,\n minWidth: COLUMN_DEFAULTS.MIN_WIDTH,\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nconst createActionsColumn = <T extends object>(\n field: Field,\n renderCell: CellRenderer<T>,\n): GridColDef => ({\n field: field.name,\n headerName: 'Ações',\n width: COLUMN_DEFAULTS.ACTIONS_WIDTH,\n sortable: false,\n resizable: false,\n disableReorder: true,\n headerAlign: 'center',\n disableColumnMenu: true,\n align: 'center',\n renderCell: (params: GridRenderCellParams) =>\n renderCell(field, params.row as DynamicRowData<T>),\n});\n\nexport const getColumnStrategy = <T extends object>(\n field: Field,\n metadata?: { id_field_name?: string },\n): ColumnStrategy<T> => {\n if (field.name === metadata?.id_field_name || field.name === 'name') {\n return createIdColumn;\n }\n\n if (field.name === 'ACTIONS') {\n return createActionsColumn;\n }\n\n if (field.type === 'FILE') {\n return createImageColumn;\n }\n\n if (field.type === 'ENTITY') {\n return createEntityColumn;\n }\n\n return createDefaultColumn;\n};\n","import { useCallback, useRef, useState } from 'react';\nimport {\n type Filter,\n type FilterCondition,\n FilterOperator,\n} from 'model/filter';\n\nimport uuidv4 from 'utils/uuidv4';\n\nimport { UseFiltersProps, UseFiltersReturn } from '../props';\nimport {\n buildFilterFromConditions,\n getDefaultCondition,\n isValidCondition,\n} from '../utils/filter';\n\n// Converte filtro inicial em condições\nconst parseInitialConditions = (initialFilter?: Filter): FilterCondition[] => {\n if (!initialFilter?.groups?.[0]?.conditionals) return [];\n return initialFilter.groups[0].conditionals.map(cond => ({\n id: uuidv4(),\n operator: initialFilter.groups[0].operator,\n fieldName: cond.fieldName,\n conditional: cond.conditional,\n value: cond.value,\n }));\n};\n\n/**\n * Hook para gerenciar estado de filtros do DynamicDataView com condições dinâmicas\n *\n * - conditions: estado de edição (o que o usuário vê no popover)\n * - appliedConditions: estado aplicado (o que está efetivamente filtrando)\n * - hasActiveFilters/activeFiltersCount: calculados com base em appliedConditions\n */\nexport const useFilters = ({\n fields,\n initialFilter,\n}: UseFiltersProps): UseFiltersReturn => {\n const [isOpen, setIsOpen] = useState(false);\n\n // Estado aplicado (efetivamente filtrando)\n const [appliedConditions, setAppliedConditions] = useState<FilterCondition[]>(\n () => parseInitialConditions(initialFilter),\n );\n const [appliedFilter, setAppliedFilter] = useState<Filter | undefined>(\n initialFilter,\n );\n\n // Estado de edição (o que o usuário vê/edita no popover)\n const [conditions, setConditions] = useState<FilterCondition[]>(() =>\n parseInitialConditions(initialFilter),\n );\n\n // Referência para snapshot antes de abrir o popover\n const snapshotRef = useRef<FilterCondition[]>([]);\n\n const openDrawer = useCallback(() => {\n // Salva snapshot das condições atuais (aplicadas) ao abrir\n snapshotRef.current = appliedConditions.map(c => ({ ...c }));\n // Sincroniza edição com aplicado ao abrir\n setConditions(appliedConditions.map(c => ({ ...c })));\n setIsOpen(true);\n }, [appliedConditions]);\n\n const closeDrawer = () => setIsOpen(false);\n\n const addCondition = useCallback(() => {\n const filterableFields = fields.filter(\n f => f.available_filter_conditions?.length > 0,\n );\n if (filterableFields.length === 0) return;\n\n const usedFieldNames = conditions.map(c => c.fieldName);\n const availableFields = filterableFields.filter(\n f => !usedFieldNames.includes(f.filter_field_name ?? f.name),\n );\n if (availableFields.length === 0) return;\n\n const currentOperator =\n conditions.length > 0 ? conditions[0].operator : FilterOperator.AND;\n const firstField = availableFields[0];\n const newCondition: FilterCondition = {\n id: uuidv4(),\n operator: currentOperator,\n fieldName: firstField.filter_field_name ?? firstField.name,\n conditional: getDefaultCondition(firstField),\n value: [],\n };\n\n setConditions(prev => [...prev, newCondition]);\n }, [fields, conditions]);\n\n const updateCondition = useCallback(\n (id: string, changes: Partial<FilterCondition>) => {\n setConditions(prev => {\n const targetCondition = prev.find(c => c.id === id);\n if (!targetCondition) return prev;\n\n if (changes.operator && changes.operator !== targetCondition.operator) {\n const newOperator = changes.operator;\n return prev.map(c => {\n if (c.id === id) {\n return { ...c, ...changes };\n }\n return { ...c, operator: newOperator };\n });\n }\n\n return prev.map(c => (c.id === id ? { ...c, ...changes } : c));\n });\n },\n [],\n );\n\n const removeCondition = useCallback((id: string) => {\n setConditions(prev => prev.filter(c => c.id !== id));\n }, []);\n\n const clearAllFilters = () => {\n setConditions([]);\n setAppliedConditions([]);\n setAppliedFilter(undefined);\n };\n\n const applyFilters = () => {\n const filter = buildFilterFromConditions(conditions);\n setAppliedConditions(conditions.map(c => ({ ...c })));\n setAppliedFilter(filter);\n setIsOpen(false);\n return filter;\n };\n\n const cancelChanges = () => {\n // Reverte para o snapshot salvo ao abrir\n setConditions(snapshotRef.current.map(c => ({ ...c })));\n setIsOpen(false);\n };\n\n // Calculado com base nos filtros APLICADOS (não em edição)\n const hasActiveFilters = appliedConditions.some(isValidCondition);\n const activeFiltersCount = appliedConditions.filter(isValidCondition).length;\n\n return {\n conditions,\n filter: appliedFilter,\n isOpen,\n hasActiveFilters,\n activeFiltersCount,\n openDrawer,\n closeDrawer,\n addCondition,\n updateCondition,\n removeCondition,\n clearAllFilters,\n applyFilters,\n cancelChanges,\n };\n};\n\nexport default useFilters;\n","import { useCallback, useEffect, useState } from 'react';\nimport { Filter, Sort } from 'model/filter';\n\nconst getStoredValue = <T>(key: string): T | undefined => {\n try {\n const item = localStorage.getItem(key);\n return item ? JSON.parse(item) : undefined;\n } catch {\n return undefined;\n }\n};\n\nconst setStoredValue = <T>(key: string, value: T | undefined): void => {\n try {\n if (value === undefined) {\n localStorage.removeItem(key);\n } else {\n localStorage.setItem(key, JSON.stringify(value));\n }\n } catch {\n // Silently ignore localStorage errors\n }\n};\n\nexport const useFilterStorage = (\n storageKey: string,\n externalFilter?: Filter,\n onFilterChange?: (filter: Filter | undefined) => void,\n) => {\n const filterKey = `${storageKey}:filter`;\n\n const [internalFilter, setInternalFilter] = useState<Filter | undefined>(\n () => {\n return getStoredValue<Filter>(filterKey) || externalFilter;\n },\n );\n\n // Sync with external filter\n useEffect(() => {\n if (externalFilter !== undefined) {\n setInternalFilter(externalFilter);\n }\n }, [externalFilter]);\n\n const handleFilterChange = useCallback(\n (newFilter: Filter | undefined) => {\n setInternalFilter(newFilter);\n setStoredValue(filterKey, newFilter);\n onFilterChange?.(newFilter);\n },\n [filterKey, onFilterChange],\n );\n\n return {\n filter: internalFilter,\n setFilter: handleFilterChange,\n };\n};\n\nexport const useSortStorage = (\n storageKey: string,\n externalSort?: Sort,\n onSortChange?: (sort: Sort | undefined) => void,\n) => {\n const sortKey = `${storageKey}:sort`;\n\n const [internalSort, setInternalSort] = useState<Sort | undefined>(() => {\n return getStoredValue<Sort>(sortKey) || externalSort;\n });\n\n // Sync with external sort\n useEffect(() => {\n if (externalSort !== undefined) {\n setInternalSort(externalSort);\n }\n }, [externalSort]);\n\n const handleSortChange = useCallback(\n (newSort: Sort | undefined) => {\n setInternalSort(newSort);\n setStoredValue(sortKey, newSort);\n onSortChange?.(newSort);\n },\n [sortKey, onSortChange],\n );\n\n return {\n sort: internalSort,\n setSort: handleSortChange,\n };\n};\n","import { useCallback, useMemo } from 'react';\nimport type { GridSortModel } from '@mui/x-data-grid-premium';\nimport { Field } from 'model/entity-metadata';\nimport { Sort, SortType } from 'model/filter';\n\nimport { UseSortingParams } from '../props';\n\n/**\n * Mapeia field.name (coluna do DataGrid) → filter_field_name (campo da API).\n * Usado quando o usuário clica no header da coluna para ordenar.\n */\nconst resolveApiFieldName = (\n fields: Field[] | undefined,\n fieldName: string,\n): string => {\n if (!fields) return fieldName;\n const field = fields.find(f => f.name === fieldName);\n return field?.filter_field_name ?? fieldName;\n};\n\n/**\n * Mapeia filter_field_name (campo da API) → field.name (coluna do DataGrid).\n * Usado para o sortModel destacar a coluna correta na UI.\n */\nconst resolveColumnFieldName = (\n fields: Field[] | undefined,\n fieldName: string,\n): string => {\n if (!fields) return fieldName;\n const field = fields.find(\n f => f.filter_field_name === fieldName || f.name === fieldName,\n );\n return field?.name ?? fieldName;\n};\n\nexport const useSorting = ({\n sort,\n onSortChange,\n fields,\n}: UseSortingParams) => {\n const sortModel: GridSortModel = useMemo(() => {\n if (!sort) return [];\n return [\n {\n field: resolveColumnFieldName(fields, sort.fieldName),\n sort: sort.sortType.toLowerCase() as 'asc' | 'desc',\n },\n ];\n }, [sort, fields]);\n\n const handleSortModelChange = useCallback(\n (model: GridSortModel) => {\n if (!onSortChange) return;\n\n const firstItem = model[0];\n if (!firstItem || !firstItem.sort) {\n onSortChange(undefined);\n return;\n }\n\n const newSort: Sort = {\n fieldName: resolveApiFieldName(fields, firstItem.field),\n sortType: firstItem.sort.toUpperCase() as SortType,\n };\n onSortChange(newSort);\n },\n [onSortChange, fields],\n );\n\n return {\n sortModel,\n handleSortModelChange,\n };\n};\n","import {\n AccessType,\n DataType,\n EntityMetadataResponse,\n Field,\n} from 'model/entity-metadata';\n\nexport const createActionsField = (): Field => ({\n name: 'ACTIONS',\n description: '',\n filter_field_name: null,\n type: DataType.TEXT,\n metadata: null,\n access_type: AccessType.READ_ONLY,\n relation_field_name: null,\n available_filter_conditions: [],\n});\n\nexport const addActionsFieldToMetadata = (\n metadata: EntityMetadataResponse,\n): EntityMetadataResponse => {\n const hasActionsField = metadata.fields.some(\n field => field.name === 'ACTIONS',\n );\n\n if (hasActionsField) {\n return metadata;\n }\n\n return {\n ...metadata,\n fields: [...metadata.fields, createActionsField()],\n };\n};\n","import { memo, ReactNode } from 'react';\n\nimport { DatePickerFormat, fDate } from 'utils/formatTime';\n\nimport type { DateRendererProps } from './props';\n\nconst DateRenderer = ({ value, format }: DateRendererProps): ReactNode => {\n if (value === null || value === undefined) return '-';\n\n return fDate(value as DatePickerFormat, format);\n};\n\nexport default memo(DateRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport { DatePickerFormat, fDateTime } from 'utils/formatTime';\n\nimport type { DateTimeRendererProps } from './props';\n\nconst DateTimeRenderer = ({\n value,\n format,\n}: DateTimeRendererProps): ReactNode => {\n if (value === null || value === undefined) return '-';\n\n return fDateTime(value as DatePickerFormat, format);\n};\n\nexport default memo(DateTimeRenderer);\n","import { memo, ReactNode } from 'react';\nimport Chip from '@mui/material/Chip';\n\nimport { EntityRendererProps } from './props';\n\nconst EntityRenderer = ({ value, field }: EntityRendererProps): ReactNode => {\n if (!field.metadata || typeof value !== 'object' || value === null) {\n return value ? String(value) : '-';\n }\n\n const entityValue = (value as Record<string, unknown>)[\n field.metadata.description_field_name\n ];\n\n if (!entityValue) return null;\n\n return (\n <Chip\n label={String(entityValue)}\n variant=\"outlined\"\n size=\"small\"\n sx={{\n width: 'fit-content',\n color: 'text.secondary',\n borderColor: 'divider',\n borderRadius: 3,\n }}\n />\n );\n};\n\nexport default memo(EntityRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport Icon, { IconEnum } from '../../Icon';\n\nimport { IconRendererProps } from './props';\n\nconst IconRenderer = ({\n value,\n trueIcon = IconEnum.STAR_02,\n falseIcon = IconEnum.STAR,\n color = 'primary.main',\n width = 18,\n}: IconRendererProps): ReactNode => {\n return (\n <Icon icon={value ? trueIcon : falseIcon} color={color} width={width} />\n );\n};\n\nexport default memo(IconRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport Icon from 'components/Icon';\n\nimport { ImageRendererProps } from './props';\nimport { ImageContainer } from './style';\n\nconst ImageRenderer = ({\n imageResourceId,\n getImageUrl,\n size = 48,\n alt = 'Imagem',\n onClick,\n sx,\n}: ImageRendererProps): ReactNode => {\n const hasImage = !!imageResourceId;\n const imageUrl =\n hasImage && getImageUrl ? getImageUrl(imageResourceId) : undefined;\n const clickable = !!onClick;\n\n return (\n <ImageContainer\n size={size}\n noImage={!hasImage}\n clickable={clickable}\n onClick={onClick}\n sx={sx}\n >\n {imageUrl ? (\n <img src={imageUrl} alt={alt} />\n ) : (\n <Icon\n icon=\"SEARCH_IMAGE\"\n width={Math.round(size / 2)}\n color=\"text.disabled\"\n />\n )}\n </ImageContainer>\n );\n};\n\nexport default memo(ImageRenderer);\n","import Box from '@mui/material/Box';\nimport { styled } from '@mui/material/styles';\n\n// StatusRenderer styles\nexport interface StatusLabelProps {\n isActive: boolean;\n}\n\nexport const StatusLabel = styled('span')<StatusLabelProps>(\n ({ theme, isActive }) => ({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: theme.spacing(0.2, 1),\n borderRadius: theme.shape.borderRadius,\n fontSize: '0.75rem',\n fontWeight: 600,\n width: 'fit-content',\n height: 'auto',\n lineHeight: '1.25rem',\n whiteSpace: 'nowrap',\n margin: 'auto',\n backgroundColor: isActive\n ? theme.palette.success.lighter || '#00A76F29'\n : theme.palette.warning.lighter || '#FF563029',\n color: isActive\n ? theme.palette.success.darker || '#007867'\n : theme.palette.warning.darker || '#B71D18',\n }),\n);\n\n// ImageRenderer styles\nexport interface ImageContainerProps {\n size: number;\n noImage: boolean;\n clickable: boolean;\n}\n\nexport const ImageContainer = styled(Box, {\n shouldForwardProp: prop =>\n !['size', 'noImage', 'clickable'].includes(prop as string),\n})<ImageContainerProps>(({ theme, size, noImage, clickable }) => ({\n width: size,\n height: size,\n minWidth: size,\n borderRadius: '50%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n cursor: clickable ? 'pointer' : 'default',\n transition: 'opacity 0.2s ease-in-out',\n color: theme.palette.text.disabled,\n ...(noImage && {\n border: `1px dashed ${theme.palette.divider}`,\n backgroundColor: theme.palette.grey[100],\n }),\n ...(clickable && {\n '&:hover': {\n opacity: 0.8,\n },\n }),\n '& img': {\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n borderRadius: '50%',\n },\n [theme.breakpoints.down('sm')]: {\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n },\n}));\n","import { memo, ReactNode } from 'react';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport CopyButton from 'components/CopyButton';\n\nimport { NameRendererProps } from './props';\n\nconst NameRenderer = ({\n id,\n displayName,\n copyMessage = 'ID copiado!',\n}: NameRendererProps): ReactNode => {\n return (\n <Stack height={1} justifyContent=\"center\">\n <Typography variant=\"subtitle2\" noWrap title={displayName}>\n {displayName}\n </Typography>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <Typography color=\"grey.600\" variant=\"body2\" noWrap>\n ID: {id}\n </Typography>\n <CopyButton toCopy={id} message={copyMessage} />\n </Stack>\n </Stack>\n );\n};\n\nexport default memo(NameRenderer);\n","import { memo, ReactNode } from 'react';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport { fCurrencyBRL, fNumber } from 'utils/formatNumber';\n\nimport { NumberRendererProps } from './props';\n\nconst NumberRenderer = ({\n value,\n isCurrency = false,\n}: NumberRendererProps): ReactNode => {\n if (value === null || value === undefined) return '-';\n\n return (\n <Stack direction=\"row\" alignItems=\"center\" height=\"100%\">\n <Typography variant=\"body2\" noWrap width=\"fit-content\">\n {isCurrency ? fCurrencyBRL(Number(value)) : fNumber(Number(value))}\n </Typography>\n </Stack>\n );\n};\n\nexport default memo(NumberRenderer);\n","import { memo, ReactNode } from 'react';\n\nimport { StatusRendererProps } from './props';\nimport { StatusLabel } from './style';\n\nconst StatusRenderer = ({\n active,\n activeLabel = 'Ativo',\n inactiveLabel = 'Inativo',\n}: StatusRendererProps): ReactNode => {\n return (\n <StatusLabel isActive={active}>\n {active ? activeLabel : inactiveLabel}\n </StatusLabel>\n );\n};\n\nexport default memo(StatusRenderer);\n","import { memo, ReactNode } from 'react';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport CopyButton from 'components/CopyButton';\n\nimport { TextRendererProps } from './props';\n\nconst sanitizeHtml = (text: string): string => {\n const withoutTags = text.replace(/<[^>]*>/g, '');\n return (\n withoutTags\n .replace(/ /g, ' ')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/"/g, '\"')\n // prettier-ignore\n .replace(/'/g, '\\'')\n .trim()\n );\n};\n\nconst TextRenderer = ({\n value,\n showCopyButton = false,\n copyMessage = 'Copiado',\n copyLabel,\n mask,\n}: TextRendererProps): ReactNode => {\n if (!value) return '-';\n\n const stringValue = String(value);\n const formattedValue = mask ? mask(stringValue) : sanitizeHtml(stringValue);\n\n if (showCopyButton) {\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <Typography variant=\"body2\" noWrap>\n {formattedValue}\n </Typography>\n <CopyButton\n toCopy={stringValue}\n message={copyMessage}\n label={copyLabel}\n />\n </Stack>\n );\n }\n\n return formattedValue;\n};\n\nexport default memo(TextRenderer);\n","import { ReactNode } from 'react';\nimport { Field } from 'model/entity-metadata';\n\nimport { CURRENCY_FIELD_NAMES } from '../constants/columnDefaults';\nimport { CellRenderer, DynamicRowData } from '../props';\nimport {\n DateRenderer,\n DateTimeRenderer,\n EntityRenderer,\n NumberRenderer,\n StatusRenderer,\n TextRenderer,\n} from '../renderers';\n\nfunction getIsCurrency(fieldName: string): boolean {\n return CURRENCY_FIELD_NAMES.includes(fieldName);\n}\n\nexport const createCellRenderer = <T extends object = object>(context: {\n onRowAction?: (rowId: string, row: DynamicRowData<T>) => ReactNode;\n}): CellRenderer<T> => {\n const { onRowAction } = context;\n\n const CellRendererComponent = (\n field: Field,\n row: DynamicRowData<T>,\n ): ReactNode => {\n const value = row[field.name];\n\n if (field.name === 'ACTIONS') {\n return onRowAction?.(row.id, row);\n }\n\n switch (field.type) {\n case 'BOOLEAN':\n return (\n <StatusRenderer\n active={Boolean(value)}\n activeLabel=\"Ativo\"\n inactiveLabel=\"Inativo\"\n />\n );\n\n case 'DATE':\n return <DateRenderer value={value} />;\n\n case 'DATETIME':\n return <DateTimeRenderer value={value} />;\n\n case 'DECIMAL':\n case 'INTEGER':\n return (\n <NumberRenderer\n value={value}\n isCurrency={getIsCurrency(field.name)}\n />\n );\n\n case 'FILE':\n case 'ENTITY':\n return <EntityRenderer value={value} field={field} />;\n case 'TEXT':\n default:\n return <TextRenderer value={value} />;\n }\n };\n\n CellRendererComponent.displayName = 'CellRendererComponent';\n return CellRendererComponent;\n};\n","import { GridColumnVisibilityModel } from '@mui/x-data-grid-premium';\nimport { EntityMetadataResponse } from 'model/entity-metadata';\n\ninterface BuildVisibleFieldsParams {\n metadata?: EntityMetadataResponse;\n columnVisibilityModel?: GridColumnVisibilityModel;\n defaultVisibleFields?: string[];\n}\n\nexport const buildVisibleFields = ({\n metadata,\n columnVisibilityModel,\n defaultVisibleFields,\n}: BuildVisibleFieldsParams): string[] | undefined => {\n if (!metadata?.fields) return undefined;\n\n const allFields = metadata.fields.map(f => f.name);\n\n const visible = allFields.filter(fieldName => {\n if (fieldName === 'ACTIONS') return false;\n\n if (columnVisibilityModel) {\n return columnVisibilityModel[fieldName] !== false;\n }\n\n return defaultVisibleFields?.includes(fieldName) ?? true;\n });\n\n if (!defaultVisibleFields) return visible;\n\n return visible.sort((a, b) => {\n const indexA = defaultVisibleFields.indexOf(a);\n const indexB = defaultVisibleFields.indexOf(b);\n\n return indexA - indexB || 0;\n });\n};\n"]}
|