@zydon/common 2.8.83 → 2.8.84

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,4 +1,4 @@
1
1
  var r=(e=>(e.AND="AND",e.OR="OR",e))(r||{}),t=(e=>(e.ASC="ASC",e.DESC="DESC",e))(t||{});
2
2
 
3
3
  export { r as a, t as b };
4
- //# sourceMappingURL=chunk-M62EJMQ6.js.map
4
+ //# sourceMappingURL=chunk-P64QBDAO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/model/filter.ts"],"names":["FilterOperator","SortType"],"mappings":"AAEO,IAAKA,OACVA,EAAA,IAAM,MACNA,EAAA,GAAK,KAFKA,OAAA,IA0CAC,OACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,OAAA","sourcesContent":["import { Condition } from './entity-metadata';\n\nexport enum FilterOperator {\n AND = 'AND',\n OR = 'OR',\n}\n\nexport interface FilterValue {\n fieldName: string;\n conditional: Condition;\n value: string[];\n}\n\nexport interface FilterState {\n [fieldName: string]: FilterValue;\n}\n\nexport interface FilterConditional {\n fieldName: string;\n conditional: Condition;\n value: string[];\n valueLabels?: Record<string, string>;\n}\n\nexport interface FilterGroup {\n operator: FilterOperator;\n conditionals: FilterConditional[];\n}\n\nexport interface Filter {\n operator: FilterOperator;\n groups: FilterGroup[];\n}\n\nexport interface FilterCondition {\n id: string;\n operator: FilterOperator;\n fieldName: string;\n conditional: Condition;\n value: string[];\n /** Labels de exibição para valores de campos ENTITY (ex: { \"uuid-da-marca\": \"Nome da Marca\" }). Usado apenas na UI. */\n valueLabels?: Record<string, string>;\n}\n\nexport enum SortType {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface Sort {\n fieldName: string;\n sortType: SortType;\n}\n\nexport interface GridQuery {\n page?: number;\n perPage?: number;\n search?: string;\n criteria?: string[];\n arguments?: Record<string, unknown>;\n filter?: Filter;\n sort?: Sort;\n}\n"]}
@@ -10,6 +10,7 @@ import * as _mui_material_styles from '@mui/material/styles';
10
10
  import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
11
11
  import * as _mui_material from '@mui/material';
12
12
  import * as _mui_material_Button from '@mui/material/Button';
13
+ import '../../../types/orderProjection.js';
13
14
 
14
15
  interface ChartItem {
15
16
  name: string;
@@ -1,5 +1,5 @@
1
1
  import '../../chunk-4P2L7UJA.js';
2
- export { a as FilterOperator, b as SortType } from '../../chunk-M62EJMQ6.js';
2
+ export { a as FilterOperator, b as SortType } from '../../chunk-P64QBDAO.js';
3
3
  import { a as a$4 } from '../../chunk-WLRSUL67.js';
4
4
  import { d, c } from '../../chunk-N7IK5EUP.js';
5
5
  import { h, a as a$6 } from '../../chunk-OF6623HG.js';
@@ -37,26 +37,26 @@ import '../../chunk-CFNATBO2.js';
37
37
  import { memo, useState, useMemo, useCallback, useEffect, useRef } from 'react';
38
38
  import $o from 'react-fast-compare';
39
39
  import et from '@mui/material/Badge';
40
- import Fe from '@mui/material/Button';
40
+ import he from '@mui/material/Button';
41
41
  import tt from '@mui/material/IconButton';
42
- import Lt from '@mui/material/Stack';
42
+ import wt from '@mui/material/Stack';
43
43
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
44
44
  import yt from '@mui/material/Divider';
45
- import be from '@mui/material/Typography';
45
+ import Se from '@mui/material/Typography';
46
46
  import ge from '@mui/material/FormControl';
47
47
  import Ce from '@mui/material/InputLabel';
48
- import J from '@mui/material/MenuItem';
48
+ import j from '@mui/material/MenuItem';
49
49
  import ye from '@mui/material/Select';
50
50
  import cr from '@mui/material/TextField';
51
- import ee from '@mui/material/Box';
51
+ import Z from '@mui/material/Box';
52
52
  import { styled } from '@mui/material/styles';
53
- import Lr from '@mui/material/Dialog';
53
+ import wr from '@mui/material/Dialog';
54
54
  import Pr from '@mui/material/DialogActions';
55
55
  import Or from '@mui/material/DialogContent';
56
56
  import kr from '@mui/material/DialogTitle';
57
57
  import li from '@mui/material/Chip';
58
58
 
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(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/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};
59
+ var Xo=({showFilterButton:e$1,isMobile:t,hasActiveFilters:o,activeFiltersCount:r,sort:n,onFilterClick:i,onSortClick:a$1})=>e$1?t?jsxs(wt,{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(he,{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,valueLabels:o.valueLabels}))}]}};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,s,d]=a$1(!1),[m,p]=useState(""),c=a$2(m,400),{data:f,isLoading:C,isFetching:g}=e.useQuery({search:c||void 0,page:0,perPage:25,...e.queryParams},{skip:!a}),L=C||g,l=useMemo(()=>o?{value:o,label:r??o}:null,[o,r]),I=useMemo(()=>{let u=(f?.items??[]).map(y=>({label:String(y[t.description_field_name]??""),value:String(y[t.id_field_name]??"")})).filter(y=>y.value&&y.label);return l&&!u.some(y=>y.value===l.value)&&u.unshift(l),u},[f,t.id_field_name,t.description_field_name,l]),_=useCallback(()=>{d(!1),p("");},[d]),E=useCallback(u=>{if(typeof u!="string"||!u){n("",void 0);return}let y=I.find(S=>S.value===u);n(u,y?.label);},[n,I]),B=useCallback((u,y,S)=>{S==="input"&&p(y);},[]);return jsx(a$3,{name:`entity-filter-${t.name}`,label:"Filtro",open:a,onOpen:s,onClose:_,value:o||"",onChange:E,inputValue:a?m:l?.label??"",onInputChange:B,options:I,loading:L,disabled:i,size:"small",filterOptions:u=>u,noOptionsText:m!==c?"Buscando...":"Nenhum resultado",sx:{flex:1,minWidth:120}})},st=memo(er);var ar=({value:e,onChange:t,totalConditions:o,isFirst:r})=>o===1?null:r?jsx(wt,{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 s=useMemo(()=>t.find(l=>(l.filter_field_name??l.name)===e.fieldName),[t,e.fieldName]),d=useMemo(()=>s?.available_filter_conditions||[],[s]),m=useMemo(()=>!e.fieldName||e.conditional==="IS_NULL"||e.conditional==="IS_NOT_NULL",[e.fieldName,e.conditional]),p=useCallback(l=>{let I=t.find(E=>(E.filter_field_name??E.name)===l);if(!I)return;let _=I.available_filter_conditions[0]||"EQUALS";o({...e,fieldName:l,conditional:_,value:[]});},[t,e,o]),c=useCallback(l=>{o({...e,conditional:l});},[e,o]),f=useCallback(l=>{o({...e,value:l?[l]:[]});},[e,o]),C=useCallback((l,I)=>{let _={...e.valueLabels};l&&I&&(_[l]=I),o({...e,value:l?[l]:[],valueLabels:_});},[e,o]),g=useCallback(l=>{o({...e,operator:l});},[e,o]),L=()=>{if(s?.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: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:C,disabled:m})}return jsx(cr,{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(wt,{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:l=>p(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(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:l=>c(l.target.value),size:"small",sx:{"& .MuiSelect-select":G},children:d.map(l=>jsx(j,{value:l,sx:G,children:at[l]||l},l))})]}),L()]})},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]),s=useMemo(()=>t.map(m=>m.fieldName).filter(m=>!!m),[t]),d=useCallback(m=>e.filter(p=>!s.includes(p.name)||p.name===m),[e,s]);return e.length===0?jsx(Se,{variant:"body2",color:"text.secondary",textAlign:"center",children:"Nenhum filtro dispon\xEDvel"}):t.length===0?jsxs(Se,{variant:"body2",color:"text.secondary",textAlign:"center",children:["Clique em"," ",jsx(Se,{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(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 Dr=({onClose:e,fields:t,conditions:o,onAddCondition:r,onUpdateCondition:n,onRemoveCondition:i,onApply:a$1,onClear:s,onCancel:d,entityFilterConfig:m})=>{let p=rt(t),c=o.length>0,f=useCallback(()=>{a$1(),e();},[a$1,e]),C=useCallback(()=>{s(),e();},[s,e]),g=useCallback(()=>{d();},[d]);return jsxs(ut,{children:[jsxs(ft,{children:[jsx(Se,{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(he,{variant:"text",color:"inherit",onClick:C,children:"Limpar"}),jsxs(wt,{direction:"row",spacing:1,children:[jsx(he,{variant:"outlined",color:"inherit",onClick:g,startIcon:jsx(a,{icon:"CANCEL_CIRCLE"}),children:"Cancelar"}),jsx(he,{variant:"contained",onClick:f,disabled:!c,startIcon:jsx(a,{icon:"SIMPLE_CHECK"}),children:"Aplicar"})]})]})]})},bt=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(bt,{...e})}),Ft=memo(Nr,$o);var Ar=({showFilterButton:e,isOpen:t,filterAnchorEl:o,fields:r,conditions:n,isMobile:i,onClose:a,onAddCondition:s,onUpdateCondition:d,onRemoveCondition:m,onApply:p,onClear:c,onCancel:f,entityFilterConfig:C})=>e?jsx(Ft,{open:t||!!o,anchorEl:o,onClose:a,fields:r,conditions:n,onAddCondition:s,onUpdateCondition:d,onRemoveCondition:m,onApply:p,onClear:c,onCancel:f,isMobileProp:i,entityFilterConfig:C}):null,ht=memo(Ar,$o);var It=styled(wr)(()=>({"& .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(he)(({theme:e})=>({minWidth:24,[e.breakpoints.down(330)]:{padding:e.spacing(1)}})),Ie=styled(Se)(({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||""),[s,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:s}:void 0),t();},[n,i,s,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(Se,{variant:"overline",color:"text.secondary",children:"Ordenar por"})}),jsx(Rt,{children:jsxs(wt,{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:s,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(wt,{flex:1,width:"100%",direction:"row",children:jsx(he,{color:"inherit",onClick:C,children:"Limpar"})}),jsxs(he,{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",s=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 s.forEach(c=>{p(c);}),t.forEach(c=>{if(c.name===a||s.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,s]=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__,s(c);}n&&n(p);},[i,n,s]);return {initialState:d,handleColumnVisibilityModelChange:m}};var M={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:M.IMAGE_WIDTH,resizable:!1,headerAlign:"center",align:"center",renderCell:o=>t(e,o.row)}),qr=(e,t)=>({field:e.name,headerName:e.description,minWidth:M.ID_MIN_WIDTH,flex:M.ID_FLEX,renderCell:o=>t(e,o.row)}),$r=(e,t)=>({field:e.name,headerName:e.description,minWidth:M.ENTITY_MIN_WIDTH,flex:M.ENTITY_FLEX,renderCell:o=>t(e,o.row)}),Qr=(e,t)=>({field:e.name,headerName:e.description,minWidth:M.MIN_WIDTH,renderCell:o=>t(e,o.row)}),Kr=(e,t)=>({field:e.name,headerName:"A\xE7\xF5es",width:M.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 s=(o?.[i.name]??Vt(i,e))(i,t,e);r.set(i.name,s);}),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,valueLabels:t.valueLabels})):[],Ht=({fields:e,initialFilter:t})=>{let[o,r]=useState(!1),[n,i]=useState(()=>Ut(t)),[a,s]=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(x=>x.available_filter_conditions?.length>0);if(u.length===0)return;let y=d.map(x=>x.fieldName),S=u.filter(x=>!y.includes(x.filter_field_name??x.name));if(S.length===0)return;let w=d.length>0?d[0].operator:"AND",T=S[0],v={id:a$8(),operator:w,fieldName:T.filter_field_name??T.name,conditional:it(T),value:[]};m(x=>[...x,v]);},[e,d]),g=useCallback((u,y)=>{m(S=>{let w=S.find(T=>T.id===u);if(!w)return S;if(y.operator&&y.operator!==w.operator){let T=y.operator;return S.map(v=>v.id===u?{...v,...y}:{...v,operator:T})}return S.map(T=>T.id===u?{...T,...y}:T)});},[]),L=useCallback(u=>{m(y=>y.filter(S=>S.id!==u));},[]),l=()=>{m([]),i([]),s(void 0);},I=()=>{let u=nt(d);return i(d.map(y=>({...y}))),s(u),r(!1),u},_=()=>{m(p.current.map(u=>({...u}))),r(!1);},E=n.some(X),B=n.filter(X).length;return {conditions:d,filter:a,isOpen:o,hasActiveFilters:E,activeFiltersCount:B,openDrawer:c,closeDrawer:f,addCondition:C,updateCondition:g,removeCondition:L,clearAllFilters:l,applyFilters:I,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`,[n,i]=useState(()=>$t(r)||t);useEffect(()=>{t!==void 0&&i(t);},[t]);let a=useCallback(s=>{i(s),Qt(r,s),o?.(s);},[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(s=>{i(s),Qt(r,s),o?.(s);},[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 s={fieldName:ei(o,a.field),sortType:a.sort.toUpperCase()};t(s);},[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(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 Ci=({imageResourceId:e,getImageUrl:t,size:o=48,alt:r="Imagem",onClick:n,sx:i})=>{let a$1=!!e,s=a$1&&t?t(e):void 0;return jsx(to,{size:o,noImage:!a$1,clickable:!!n,onClick:n,sx:i,children:s?jsx("img",{src:s,alt:r}):jsx(a,{icon:"SEARCH_IMAGE",width:Math.round(o/2),color:"text.disabled"})})},yi=memo(Ci);var Si=({id:e,displayName:t,copyMessage:o="ID copiado!"})=>jsxs(wt,{height:1,justifyContent:"center",children:[jsx(Se,{variant:"subtitle2",noWrap:!0,title:t,children:t}),jsxs(wt,{direction:"row",gap:1,alignItems:"center",children:[jsxs(Se,{color:"grey.600",variant:"body2",noWrap:!0,children:["ID: ",e]}),jsx(a$5,{toCopy:e,message:o})]})]}),Fi=memo(Si);var Ri=({value:e,isCurrency:t=!1})=>e==null?"-":jsx(wt,{direction:"row",alignItems:"center",height:"100%",children:jsx(Se,{variant:"body2",noWrap:!0,width:"fit-content",children:t?h(Number(e)):a$6(Number(e))})}),Ae=memo(Ri);var _i=({active:e,activeLabel:t="Ativo",inactiveLabel:o="Inativo"})=>jsx(eo,{isActive:e,children:e?t:o}),Me=memo(_i);var Ai=e=>e.replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/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):Ai(i);return t?jsxs(wt,{direction:"row",gap:1,alignItems:"center",children:[jsx(Se,{variant:"body2",noWrap:!0,children:a}),jsx(a$5,{toCopy:i,message:o,label:r})]}):a},Le=memo(Mi);function wi(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(Ae,{value:i,isCurrency:wi(r.name)});case"FILE":case"ENTITY":return jsx(Ne,{value:i,field:r});case"TEXT":default:return jsx(Le,{value:i})}};return o.displayName="CellRendererComponent",o};var ki=({title:e,metadata:t,data:o,isLoading:r,isFetching:n,page:i,perPage:a,searchValue:s,onSearchChange:d,onSearch:m,onPaginationChange:p,onAdd:c,onRowAction:f,onRowDoubleClick:C,actions:g,moreActions:L,bulkActions:l,rowSelectionModel:I,onRowSelectionModelChange:_,slots:E,mobileRender:B,containerHeight:u=600,showColumnButton:y=!1,showFilterButton:S=!1,filter:w,onFilterChange:T,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 A=H[0],Q=Object.keys(A).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]),bo=useMemo(()=>lo({onRowAction:f}),[f]),So=Gt({metadata:W,renderCell:bo,columnStrategies:fo}),{orderedColumns:Fo,columnsByFieldId:ho}=kt({columns:So,fields:W?.fields,preferredFieldOrder:uo}),{initialState:Io,handleColumnVisibilityModelChange:To}=Bt({fields:W?.fields,columnsByFieldId:ho,defaultVisibleFieldNames:co,columnVisibilityStorageKey:`${le}:columns`,onColumnVisibilityModelChange:go}),Ro=useCallback(A=>{if(!C)return;let Q=A.id?.toString()||"";C(Q,A.row);},[C]),q=b("down","md"),[Do,se]=useState(null),{filter:_o,setFilter:$}=Kt(le,w,T),{sort:xo,setSort:we}=Xt(le,v,x),No=w??_o,me=v??xo,{sortModel:Eo,handleSortModelChange:vo}=jt({sort:me,onSortChange:we,fields:Y}),{conditions:Ao,isOpen:Mo,openDrawer:de,closeDrawer:Pe,addCondition:Lo,updateCondition:wo,removeCondition:Po,clearAllFilters:Oe,applyFilters:ke,cancelChanges:Be,hasActiveFilters:Oo,activeFiltersCount:ko}=Ht({fields:Y,initialFilter:No}),Bo=useCallback(()=>{let A=ke();$(A);},[ke,$]),Wo=useCallback(()=>{Oe(),$(void 0);},[Oe,$]),Vo=useCallback(A=>{q?de():(de(),se(A.currentTarget));},[q,de]),Go=useCallback(()=>{Be(),se(null);},[Be]),[Uo,We]=useState(!1),Ho=useCallback(()=>{se(null),Pe();},[Pe]),Ve=!!l?.length;return jsxs(Fragment,{children:[jsx(d$1,{title:e,columns:Fo,rows:H,mobileRender:B,rowCount:yo,loading:r||!t,fetching:n,searchValue:s,onSearch:m,onSearchChange:d,paginationModel:{page:i,pageSize:a},onPaginationChange:p,actions:g,moreActions:L,onAdd:c,onRowDoubleClick:C?Ro:void 0,bulkActions:l,checkboxSelection:Ve,rowSelectionModel:I,onRowSelectionModelChange:_,keepNonExistentRowsSelected:Ve,disableRowSelectionOnClick:!0,slots:E,initialState:Io,showColumnButton:y,containerProps:{height:u,maxHeight:u},onColumnVisibilityModelChange:To,filterButton:jsx(ot,{showFilterButton:S,isMobile:q,hasActiveFilters:Oo,activeFiltersCount:ko,sort:me,onFilterClick:Vo,onSortClick:()=>We(!0)}),sortingMode:"server",sortModel:Eo,onSortModelChange:vo,disableColumnFilter:!0}),t&&jsxs(Fragment,{children:[jsx(ht,{showFilterButton:S,isOpen:Mo,filterAnchorEl:Do,fields:Y,conditions:Ao,isMobile:q,onClose:Ho,onAddCondition:Lo,onUpdateCondition:wo,onRemoveCondition:Po,onApply:Bo,onClear:Wo,onCancel:Go,entityFilterConfig:Co}),jsx(Ot,{open:Uo,onClose:()=>We(!1),fields:Y,sort:me,onSortChange:we})]})]})},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 s=o.indexOf(i),d=o.indexOf(a);return s-d||0}):n};
60
60
 
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 };
61
+ export { _e as DateRenderer, xe as DateTimeRenderer, Ne as EntityRenderer, ci as IconRenderer, yi as ImageRenderer, Fi as NameRenderer, Ae as NumberRenderer, Me as StatusRenderer, Le as TextRenderer, De as addActionsFieldToMetadata, Wi as buildVisibleFields, Jt as createActionsField, Bi as default };
62
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/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,CAAK,KAAK,kBAAkB,EAC/B,EACF,EAEAV,EAACW,GAAA,CACC,GAAI,CAAE,OAAQ,EAAG,EACjB,YAAY,WACZ,SAAQ,GACV,EAE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U,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 &quot;+&quot;\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(/&nbsp;/g, ' ')\n .replace(/&amp;/g, '&')\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&quot;/g, '\"')\n // prettier-ignore\n .replace(/&#39;/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","toggleOpen","setOpen","useToggle_default","inputValue","setInputValue","debouncedSearch","useDebounceValue_default","data","isLoading","isFetching","loading","selectedOption","options","items","item","opt","handleClose","handleChange","newValue","option","handleInputChange","_event","newInputValue","reason","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,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B,SAAUC,EACV,iBAAkBC,GAClB,mBAAoBC,GACpB,KAAM4V,GACN,cAAeG,GACf,YAAa,IAAMI,GAAmB,EAAI,EAC5C,EAEF,YAAY,SACZ,UAAW9G,GACX,kBAAmBC,GACnB,oBAAmB,GACrB,EACCzN,GACClC,GAAAgG,GAAA,CACE,UAAAjG,GAACyI,GAAA,CACC,iBAAkBtI,EAClB,OAAQoI,GACR,eAAgBC,GAChB,OAAQ+M,EACR,WAAY/T,GACZ,SAAUpB,EACV,QAASsW,GACT,eAAgBpJ,GAChB,kBAAmBM,GACnB,kBAAmBI,GACnB,QAASmI,GACT,QAASC,GACT,SAAUG,GACV,mBAAoB3R,GACtB,EAEA5E,GAAC6J,GAAA,CACC,KAAM2M,GACN,QAAS,IAAMC,GAAmB,EAAK,EACvC,OAAQlB,EACR,KAAMW,GACN,aAAcF,GAChB,GACF,GAEJ,CAEJ,EAEOa,GAAQtX,GAAKwU,GAAiBpU,EAAO,EkCxSrC,IAAMmX,GAAqB,CAAC,CACjC,SAAA3U,EACA,sBAAA4U,EACA,qBAAAC,CACF,IAAsD,CACpD,GAAI,CAAC7U,GAAU,OAAQ,OAIvB,IAAMkJ,EAFYlJ,EAAS,OAAO,IAAI2C,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 valueLabels: c.valueLabels,\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 &quot;+&quot;\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\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';\n\nimport type { EntityFilterOption, EntityFilterProps } from './props';\n\nconst EntityFilter = ({\n config,\n metadata,\n value,\n initialLabel,\n onChange,\n disabled = false,\n}: EntityFilterProps) => {\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 {\n skip: !open,\n },\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 = 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 (newValue: unknown) => {\n if (typeof newValue !== 'string' || !newValue) {\n onChange('', undefined);\n return;\n }\n const option = options.find(opt => opt.value === newValue);\n onChange(newValue, option?.label);\n },\n [onChange, options],\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\n name={`entity-filter-${metadata.name}`}\n label=\"Filtro\"\n open={open}\n onOpen={toggleOpen}\n onClose={handleClose}\n value={value || ''}\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 filterOptions={x => x}\n noOptionsText={\n inputValue !== debouncedSearch ? 'Buscando...' : 'Nenhum resultado'\n }\n sx={{ flex: 1, minWidth: 120 }}\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 valueLabels: cond.valueLabels,\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(/&nbsp;/g, ' ')\n .replace(/&amp;/g, '&')\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&quot;/g, '\"')\n // prettier-ignore\n .replace(/&#39;/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"]}
@@ -16,6 +16,7 @@ interface FilterConditional {
16
16
  fieldName: string;
17
17
  conditional: Condition;
18
18
  value: string[];
19
+ valueLabels?: Record<string, string>;
19
20
  }
20
21
  interface FilterGroup {
21
22
  operator: FilterOperator;
@@ -1,2 +1,2 @@
1
- export { a as FilterOperator, b as SortType } from '../chunk-M62EJMQ6.js';
1
+ export { a as FilterOperator, b as SortType } from '../chunk-P64QBDAO.js';
2
2
  //# sourceMappingURL=filter.js.map
@@ -0,0 +1,35 @@
1
+ declare enum Frequency {
2
+ DAILY = "DAILY",
3
+ WEEKLY = "WEEKLY",
4
+ MONTHLY = "MONTHLY",
5
+ CUSTOM = "CUSTOM"
6
+ }
7
+ declare enum DayOfWeek {
8
+ SUNDAY = "SUNDAY",
9
+ MONDAY = "MONDAY",
10
+ TUESDAY = "TUESDAY",
11
+ WEDNESDAY = "WEDNESDAY",
12
+ THURSDAY = "THURSDAY",
13
+ FRIDAY = "FRIDAY",
14
+ SATURDAY = "SATURDAY"
15
+ }
16
+ declare enum MontlhyStrategy {
17
+ FIXED_DAY = "FIXED_DAY",
18
+ SPECIFIC_DAY = "SPECIFIC_DAY"
19
+ }
20
+ declare enum CustomUnit {
21
+ DAYS = "DAYS",
22
+ WEEKS = "WEEKS",
23
+ MONTHS = "MONTHS"
24
+ }
25
+ interface Recurrence {
26
+ frequency: Frequency;
27
+ interval: number;
28
+ days_of_week: DayOfWeek[];
29
+ monthly_strategy: MontlhyStrategy;
30
+ day_of_month: number;
31
+ occurrence: number;
32
+ custom_unit: CustomUnit;
33
+ }
34
+
35
+ export { CustomUnit, DayOfWeek, Frequency, MontlhyStrategy, Recurrence };
@@ -0,0 +1,4 @@
1
+ var E=(A=>(A.DAILY="DAILY",A.WEEKLY="WEEKLY",A.MONTHLY="MONTHLY",A.CUSTOM="CUSTOM",A))(E||{}),r=(Y=>(Y.SUNDAY="SUNDAY",Y.MONDAY="MONDAY",Y.TUESDAY="TUESDAY",Y.WEDNESDAY="WEDNESDAY",Y.THURSDAY="THURSDAY",Y.FRIDAY="FRIDAY",Y.SATURDAY="SATURDAY",Y))(r||{}),T=(S=>(S.FIXED_DAY="FIXED_DAY",S.SPECIFIC_DAY="SPECIFIC_DAY",S))(T||{}),I=(D=>(D.DAYS="DAYS",D.WEEKS="WEEKS",D.MONTHS="MONTHS",D))(I||{});
2
+
3
+ export { I as CustomUnit, r as DayOfWeek, E as Frequency, T as MontlhyStrategy };
4
+ //# sourceMappingURL=orderProjection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/orderProjection.ts"],"names":["Frequency","DayOfWeek","MontlhyStrategy","CustomUnit"],"mappings":"AAAO,IAAKA,OACVA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,QAAU,UACVA,EAAA,OAAS,SAJCA,OAAA,IAOAC,OACVA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,QAAU,UACVA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,SAAW,WAPDA,OAAA,IAUAC,OACVA,EAAA,UAAY,YACZA,EAAA,aAAe,eAFLA,OAAA,IAKAC,OACVA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,OAAS,SAHCA,OAAA","sourcesContent":["export enum Frequency {\n DAILY = 'DAILY',\n WEEKLY = 'WEEKLY',\n MONTHLY = 'MONTHLY',\n CUSTOM = 'CUSTOM',\n}\n\nexport enum DayOfWeek {\n SUNDAY = 'SUNDAY',\n MONDAY = 'MONDAY',\n TUESDAY = 'TUESDAY',\n WEDNESDAY = 'WEDNESDAY',\n THURSDAY = 'THURSDAY',\n FRIDAY = 'FRIDAY',\n SATURDAY = 'SATURDAY',\n}\n\nexport enum MontlhyStrategy {\n FIXED_DAY = 'FIXED_DAY',\n SPECIFIC_DAY = 'SPECIFIC_DAY',\n}\n\nexport enum CustomUnit {\n DAYS = 'DAYS',\n WEEKS = 'WEEKS',\n MONTHS = 'MONTHS',\n}\n\nexport interface Recurrence {\n frequency: Frequency;\n interval: number;\n days_of_week: DayOfWeek[];\n monthly_strategy: MontlhyStrategy;\n day_of_month: number;\n occurrence: number;\n custom_unit: CustomUnit;\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { AbcCurve } from '../utils/partnerAnalysis.js';
2
+ import { Recurrence } from './orderProjection.js';
2
3
 
3
4
  interface RankingItem {
4
5
  partner_external_id: string;
@@ -60,7 +61,7 @@ interface DashboardPartner {
60
61
  main_seller_external_id: string;
61
62
  classification: string;
62
63
  abc_curve: string;
63
- recurrence?: Record<string, unknown>;
64
+ recurrence?: Recurrence;
64
65
  sale_analysis: DashboardPartnerSaleAnalysis;
65
66
  state: string;
66
67
  }
@@ -1,5 +1,5 @@
1
1
  import '../chunk-4P2L7UJA.js';
2
- import '../chunk-M62EJMQ6.js';
2
+ import '../chunk-P64QBDAO.js';
3
3
 
4
4
  var u=(t,e)=>{if(!(!t?.fields||!e))return t.fields.find(r=>r.name===e||r.filter_field_name===e)},i=(t,e)=>{if(!e)return;let r=u(t,e);return t?.fields?r?.filter_field_name||r?.name:e},f=(t,e)=>{if(!(!t?.fields||!e||e.length===0))return e.filter(r=>r!=="ACTIONS")},l=(t,e)=>{let r=e?.trim();if(!r)return;let n=i(t,t?.description_field_name)||i(t,"name");if(n)return {operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:n,conditional:"LIKE",value:[r]}]}]}},p=(t,e,r)=>{if(!e||!r)return;let n=i(t,e);if(n)return {fieldName:n,sortType:r==="desc"?"DESC":"ASC"}},c=({metadata:t,visibleFieldNames:e,search:r,sort:n,dir:s})=>{let o=f(t,e),d=l(t,r),a=p(t,n,s);return {...o&&{criteria:o},...d&&{filter:d},...a&&{sort:a}}},y=c;
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.8.83",
3
+ "version": "2.8.84",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/model/filter.ts"],"names":["FilterOperator","SortType"],"mappings":"AAEO,IAAKA,OACVA,EAAA,IAAM,MACNA,EAAA,GAAK,KAFKA,OAAA,IAyCAC,OACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,OAAA","sourcesContent":["import { Condition } from './entity-metadata';\n\nexport enum FilterOperator {\n AND = 'AND',\n OR = 'OR',\n}\n\nexport interface FilterValue {\n fieldName: string;\n conditional: Condition;\n value: string[];\n}\n\nexport interface FilterState {\n [fieldName: string]: FilterValue;\n}\n\nexport interface FilterConditional {\n fieldName: string;\n conditional: Condition;\n value: string[];\n}\n\nexport interface FilterGroup {\n operator: FilterOperator;\n conditionals: FilterConditional[];\n}\n\nexport interface Filter {\n operator: FilterOperator;\n groups: FilterGroup[];\n}\n\nexport interface FilterCondition {\n id: string;\n operator: FilterOperator;\n fieldName: string;\n conditional: Condition;\n value: string[];\n /** Labels de exibição para valores de campos ENTITY (ex: { \"uuid-da-marca\": \"Nome da Marca\" }). Usado apenas na UI. */\n valueLabels?: Record<string, string>;\n}\n\nexport enum SortType {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface Sort {\n fieldName: string;\n sortType: SortType;\n}\n\nexport interface GridQuery {\n page?: number;\n perPage?: number;\n search?: string;\n criteria?: string[];\n arguments?: Record<string, unknown>;\n filter?: Filter;\n sort?: Sort;\n}\n"]}