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