@data-c/pro 0.2.53 → 0.2.55

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/index.mjs CHANGED
@@ -1,4 +1,1092 @@
1
- import{ColumnsPanelTrigger as at,useGridApiRef as tt}from"@mui/x-data-grid-pro";import{useEffect as re,useMemo as We}from"react";import{Circle as fe}from"@mui/icons-material";import{LinearProgress as Ve,Stack as ze}from"@mui/material";import{DataGridPro as Xe,gridFilteredSortedRowIdsSelector as Ne}from"@mui/x-data-grid-pro";import{ptBR as Ke}from"@mui/x-data-grid-pro/locales";import{Stack as M,Typography as te}from"@mui/material";import{jsx as P,jsxs as oe}from"react/jsx-runtime";function F(){return oe(M,{alignItems:"center",justifyContent:"center",gap:2,padding:2,maxWidth:"400px",minWidth:"200px",children:[P(M,{width:"250px",height:"250px",alignItems:"center",justifyContent:"center",borderRadius:"50%",sx:{background:"linear-gradient(to top, #ffffff, #fdfcfd, #fafafa, #f8f7f8, #f5f5f6);"},children:P("img",{src:"https://datac-site-assets.s3.sa-east-1.amazonaws.com/empty-data.svg",alt:"Imagem de notifica\xE7\xE3o",width:"148px",height:"148px"})}),oe(M,{spacing:1,textAlign:"center",children:[P(te,{variant:"h4",component:"h2",fontWeight:"600",children:"Nenhum registro encontrado"}),P(te,{variant:"body2",whiteSpace:"normal",children:"Tente outra pesquisa ou adicione um novo registro."})]})]})}import{Stack as R,Typography as ue}from"@mui/material";import{jsx as k,jsxs as de}from"react/jsx-runtime";function T({errorMessage:e}){return de(R,{alignItems:"center",justifyContent:"center",gap:2,padding:2,maxWidth:"400px",minWidth:"200px",children:[k(R,{width:"250px",height:"250px",alignItems:"center",justifyContent:"center",borderRadius:"50%",sx:{background:"linear-gradient(to top, #ffffff, #fdfcfd, #fafafa, #f8f7f8, #f5f5f6);"},children:k("img",{src:"https://datac-site-assets.s3.sa-east-1.amazonaws.com/error.svg",alt:"Imagem de erro",width:"148px",height:"148px"})}),de(R,{gap:1,textAlign:"center",children:[k(ue,{variant:"h4",component:"h2",fontWeight:"600",children:"Ops! Algo deu errado"}),k(ue,{variant:"body2",children:e})]})]})}import{createContext as Oe,useContext as He,useState as b}from"react";import{useGridApiRef as Ge}from"@mui/x-data-grid-pro";import{jsx as Ee}from"react/jsx-runtime";var le=Oe({});function y({children:e}){let[a,t]=b({type:"include",ids:new Set}),[o,d]=b(!1),[l,u]=b(!1),f=Ge();function s(){t({type:"include",ids:new Set}),d(!0)}return Ee(le.Provider,{value:{apiRef:f,rowsSelectedId:a,clearCallback:o,breakpoint:l,setClearCallback:d,setBreakpoint:u,setRowsSelectedId:t,clearRowsSelectedId:s},children:e})}function p(){return He(le)}import{jsx as L,jsxs as Ze}from"react/jsx-runtime";var Qe=({apiRef:e})=>Ne(e);function q(e){let{error:a,isLoading:t,isFetching:o,data:d,columns:l,controlledRowsSelectedId:u,onClearRowsSelectedId:f,onRowSelectionChange:s,onCellKeyDown:i,onRowDoubleClick:x,stackProps:c,slots:m,...Fe}=e,{rowsSelectedId:Re,setRowsSelectedId:ee,clearCallback:ae,setClearCallback:Te,apiRef:B}=p(),be=We(()=>n=>n.map(r=>r.headerName==="A\xE7\xF5es"?{...r,minWidth:r.minWidth||80,maxWidth:r.maxWidth||r.width||80,headerClassName:"sticky-header",cellClassName:"sticky-cell"}:{...r,flex:r.flex||1,minWidth:r.minWidth||100,headerClassName:r?.enableStickyColumns?"sticky-header":"",cellClassName:r?.enableStickyColumns?"sticky-cell":""}),[l]);re(()=>{u&&ee(u)},[u]),re(()=>{ae&&(f&&f({type:"include",ids:new Set}),Te(!1))},[ae]);function ye(n,r,ve){switch(r.ctrlKey&&r.code==="KeyE"?"ctrl+e":r.code){case"Enter":r.preventDefault(),i&&i("edit",n.id);break;case"F3":r.preventDefault(),i&&i("edit",n.id);break;case"Delete":r.preventDefault(),i&&i("delete",n.id);break;case"ctrl+e":r.preventDefault(),(Ue=>{B?.current&&B.current.exportDataAsCsv(Ue)})({getRowsToExport:Qe});break;default:break}}function qe(n,r,ve){x&&x("edit",n.id)}return Ze(ze,{height:"100%",minHeight:"500px",position:"relative",...c,children:[!t&&o&&L(Ve,{sx:{position:"absolute",top:0,right:0,left:0,zIndex:999,height:"3px"}}),L(Xe,{apiRef:B,rows:d,columns:be(l),density:"compact",hideFooterPagination:!0,hideFooter:!0,loading:t,rowHeight:43,columnHeaderHeight:43,disableVirtualization:!0,onRowDoubleClick:qe,onCellKeyDown:ye,disableRowSelectionOnClick:!0,rowSelectionModel:Re,onRowSelectionModelChange:(n,r)=>{s&&s(n,r),!u&&ee(n)},slots:{booleanCellFalseIcon:()=>L(fe,{color:"error",sx:{fontSize:"10pt"}}),booleanCellTrueIcon:()=>L(fe,{color:"success",sx:{fontSize:"10pt"}}),noRowsOverlay:()=>!t&&a?L(T,{errorMessage:a}):L(F,{}),...m},slotProps:{loadingOverlay:{variant:"skeleton",noRowsVariant:"skeleton"}},disableColumnFilter:!0,localeText:Ke.components.MuiDataGrid.defaultProps.localeText,sx:{border:"none",borderRadius:0,"--DataGridPro-rowBorderColor":"#edf2f9","--DataGridPro-containerBackground":"#f4f6fa",".MuiDataGridPro-overlayWrapperInner":{display:"flex",alignItems:"center",justifyContent:"center"},".MuiDataGridPro-row":{backgroundColor:"white","&:nth-of-type(even)":{backgroundColor:"#f9fafd"},":hover":{backgroundColor:"#e9e9e9"},"&.Mui-selected":{backgroundColor:"rgb(238, 249, 252)","&:hover":{backgroundColor:"rgb(222, 243, 249)"}}},".MuiDataGridPro-cell":{fontSize:"12px",color:"#0b0e14"},".MuiDataGridPro-columnHeaders":{border:"solid 1px #edf2f9"},".MuiDataGridPro-columnHeaderTitle":{fontSize:"12px",color:"#0b0e14",fontWeight:"600"},"& .sticky-cell":{position:"sticky",right:0,background:"inherit",zIndex:1},"& .sticky-header":{position:"sticky",right:0,background:"inherit",zIndex:2}},...Fe})]})}import{GridActionsCellItem as Je}from"@mui/x-data-grid-pro";import{jsx as $e}from"react/jsx-runtime";function v(e){let{ref:a,...t}=e;return $e(Je,{...t,ref:a})}import{GridActionsCellItem as ua}from"@mui/x-data-grid-pro";import{forwardRef as je,createElement as ea}from"react";var se=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_e=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,o)=>o?o.toUpperCase():t.toLowerCase()),U=e=>{let a=_e(e);return a.charAt(0).toUpperCase()+a.slice(1)},A=(...e)=>e.filter((a,t,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===t).join(" ").trim(),ie=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0};import{forwardRef as Ye,createElement as ne}from"react";var ce={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var pe=Ye(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:d="",children:l,iconNode:u,...f},s)=>ne("svg",{ref:s,...ce,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:A("lucide",d),...!l&&!ie(f)&&{"aria-hidden":"true"},...f},[...u.map(([i,x])=>ne(i,x)),...Array.isArray(l)?l:[l]]));var I=(e,a)=>{let t=je(({className:o,...d},l)=>ea(pe,{ref:l,iconNode:a,className:A(`lucide-${se(U(e))}`,`lucide-${e}`,o),...d}));return t.displayName=U(e),t};var aa=[["path",{d:"M15 11a1 1 0 0 0 1 1h2.939a1 1 0 0 1 .75 1.811l-6.835 6.836a1.207 1.207 0 0 1-1.707 0L4.31 13.81a1 1 0 0 1 .75-1.811H8a1 1 0 0 0 1-1V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1z",key:"1eaqc3"}]],C=I("arrow-big-down",aa);var ta=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],g=I("pencil",ta);var oa=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],h=I("trash-2",oa);import{jsx as me}from"react/jsx-runtime";function O(e){let{ref:a,...t}=e;return me(ua,{color:"error",label:"Deletar",icon:me(h,{size:16}),...t,ref:a})}import{GridActionsCellItem as da}from"@mui/x-data-grid-pro";import{jsx as Le}from"react/jsx-runtime";function H(e){let{ref:a,...t}=e;return Le(da,{label:"Editar",color:"primary",icon:Le(g,{size:16}),...t,ref:a})}import{useEffect as la}from"react";import{Stack as ra,useMediaQuery as fa,useTheme as sa}from"@mui/material";import{jsx as ia}from"react/jsx-runtime";function G({children:e,breakpoints:a}){let{setBreakpoint:t}=p(),o=sa(),d=fa(o.breakpoints.down(a||"md"));return la(()=>{t(d)},[d]),ia(ra,{flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:1,marginLeft:"auto",flexGrow:1,children:e})}import{GridActionsCellItem as ca}from"@mui/x-data-grid-pro";import{jsx as Ie}from"react/jsx-runtime";function E(e){let{ref:a,...t}=e;return Ie(ca,{color:"primary",label:"Transportar",icon:Ie(C,{size:16}),...t,ref:a})}import{Button as na,CircularProgress as xe,IconButton as pa,Tooltip as ma,Box as La}from"@mui/material";import{Fragment as Ia,jsx as S,jsxs as Ce}from"react/jsx-runtime";function w(e){let{isLoading:a,startIcon:t,children:o,title:d,...l}=e,{breakpoint:u}=p();return S(Ia,{children:u?S(ma,{title:o,children:Ce(pa,{...l,color:"primary",disabled:a?!0:l.disabled,children:[t,a&&S(xe,{color:"secondary",size:14,sx:{position:"absolute",top:"25%",bottom:"25%",left:"25%",right:"25%",transform:"translate(-50%, -50%)"}})]})}):S(na,{startIcon:t,disabled:a?!0:l.disabled,sx:{position:"relative",height:"26px",minWidth:"70px",padding:"7px 8px 8px",border:"1px solid rgba(223, 226, 231, 0.8)",borderRadius:"6px",display:"flex",alignItems:"center",overflow:"hidden",whiteSpace:"nowrap",flexShrink:1,transition:"width 0.2s ease"},...l,children:Ce(La,{component:"span",sx:{transition:"opacity 0.2s ease, width 0.2s ease",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:[a&&S(xe,{color:"secondary",size:14,sx:{position:"absolute",top:"22%",left:"44%",transform:"translate(-50%, -50%)"}}),o]})})})}import{GridActionsCellItem as xa}from"@mui/x-data-grid-pro";import{jsx as ge}from"react/jsx-runtime";function W(e){let{event:a,onClick:t,...o}=e;return ge(xa,{label:"A\xE7\xE3o",onClick:()=>{},icon:ge("span",{children:"\u{1F527}"})})}import{Delete as Ca}from"@mui/icons-material";import{GridActionsCellItem as ga}from"@mui/x-data-grid-pro";import{jsx as he}from"react/jsx-runtime";function V({onClick:e,...a}){return he(ga,{icon:he(Ca,{}),label:"Delete",color:"primary",onClick:()=>{e&&e("delete")},...a})}import{Edit as ha}from"@mui/icons-material";import{GridActionsCellItem as Sa}from"@mui/x-data-grid-pro";import{jsx as Se}from"react/jsx-runtime";function z({onClick:e,...a}){return Se(Sa,{icon:Se(ha,{}),label:"Edit",color:"primary",onClick:()=>e&&e("edit"),...a})}import{Children as wa,cloneElement as Pa,isValidElement as ka}from"react";import{Fragment as Aa,jsx as Da}from"react/jsx-runtime";function X(e){let{children:a,onClick:t}=e;return Da(Aa,{children:wa.map(a,o=>{if(ka(o))return Pa(o,{onClick:t})})})}import{GetApp as Ba}from"@mui/icons-material";import{GridActionsCellItem as Ma}from"@mui/x-data-grid-pro";import{jsx as we}from"react/jsx-runtime";function N({onClick:e,...a}){return we(Ma,{icon:we(Ba,{}),label:"Transport",color:"primary",onClick:()=>e&&e("transport"),...a})}import{Stack as Fa}from"@mui/material";import{jsx as Ra}from"react/jsx-runtime";function K(e){return Ra(Fa,{direction:"row",width:"100%",flexGrow:1,alignItems:"center",gap:1.5,sx:{background:"#f4f"},...e})}import{FileDownload as Ta}from"@mui/icons-material";import{gridFilteredSortedRowIdsSelector as ba}from"@mui/x-data-grid-pro";import{jsx as Pe}from"react/jsx-runtime";var ya=({apiRef:e})=>ba(e);function Q(){let{apiRef:e}=p(),a=t=>{e?.current&&e.current.exportDataAsCsv(t)};return Pe(w,{startIcon:Pe(Ta,{}),onClick:()=>a({getRowsToExport:ya}),children:"Exportar CSV"})}import{TableFooter as qa}from"@mui/material";import{jsx as va}from"react/jsx-runtime";function Z(e){return va(qa,{...e,sx:{height:"54px",paddingX:"12px",gap:"12px",display:"flex",alignItems:"center",backgroundColor:"white",borderBottomLeftRadius:"8px",borderBottomRightRadius:"8px",borderTop:"1px solid #edf2f9"}})}import{pluralizar as ke}from"@data-c/hooks";import{MenuItem as Ua,Pagination as Oa,Stack as Ae,TextField as Ha,Typography as Ga}from"@mui/material";import{useMemo as De}from"react";import{jsx as D,jsxs as Be}from"react/jsx-runtime";function J(e){let{onChangePageSize:a,onChangePage:t,pagination:o,rowsPerPageOptions:d=[15,50,100,200]}=e,{page:l,pageSize:u=15,totalRecords:f}=o||{},s=De(()=>o?.lastPage?o.lastPage:(f||0)<u?1:Math.max(Math.ceil((f||0)/u)),[f,u]),i=De(()=>{if((f||0)<u)return`Exibindo ${ke(f||0,"registro","registros",!0)}`;let c=u;if(l===s){let m=(f||0)%u;c=m===0?u:m}return`Exibindo ${ke(c||0,"registro","registros",!0)} de ${f}`},[o,s]);return Be(Ae,{width:"100%",direction:"row",alignItems:"center",gap:2,marginLeft:"auto",children:[D(Ga,{variant:"body2",fontSize:"13px",fontWeight:"500",whiteSpace:"nowrap",children:i}),!0&&Be(Ae,{direction:"row",alignItems:"center",gap:2,marginLeft:"auto",children:[D(Ha,{sx:{width:"78px",fontSize:"8pt"},size:"small",value:u||0,select:!0,onChange:c=>{a&&a(parseInt(c.target.value))},children:d.map(c=>D(Ua,{value:c,children:c},c))}),D(Oa,{variant:"outlined",shape:"rounded",count:s||0,showFirstButton:!0,showLastButton:!0,onChange:(c,m)=>{t&&t(m)},page:l||0,color:"primary"})]})]})}import{useEffect as Ea,useRef as Wa,useState as Va}from"react";import{Stack as za}from"@mui/material";import{jsx as Me}from"react/jsx-runtime";function $({children:e,height:a,...t}){let o=Wa(null),[d,l]=Va(500);return Ea(()=>{let u=()=>{let f=o.current;if(!f)return;let s=f.getBoundingClientRect().top;l(window.innerHeight-s)};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[]),Me(za,{ref:o,sx:{backgroundColor:"#f4f6fa",border:"1px solid #edf2f9",borderRadius:2,height:a||`calc(${d}px - 16px)`,...t.sx},...t,children:Me(y,{children:e})})}import{Stack as Xa,Typography as Na}from"@mui/material";import{useMemo as Ka}from"react";import{jsx as Za,jsxs as Qa}from"react/jsx-runtime";function _(e){let{countTitle:a,gender:t}=e,{rowsSelectedId:o}=p(),d=o?.ids.size||0,l=Ka(()=>{if(!a)return"";let u=t==="feminino"?"selecionada":"selecionado",f=t==="feminino"?"selecionadas":"selecionados",s=t==="feminino"?"Nenhuma":"Nenhum";return d===1?`${a} ${u}`:d&&d>1?`${a.split(" ").map(i=>`${i}s`).join(" ")} ${f}`:`${s} ${a} ${u}`},[d]);return Za(Xa,{children:Qa(Na,{variant:"body2",fontSize:"13px",fontWeight:"500",whiteSpace:"nowrap",children:[d&&d>0?d:""," ",l]})})}import{Typography as Ja,useTheme as $a}from"@mui/material";import{jsx as _a}from"react/jsx-runtime";function Y({children:e,titleDivider:a=!1,sx:t}){let o=$a();return _a(Ja,{variant:"h6",whiteSpace:"nowrap",sx:{borderRight:a?`solid 1px ${o.palette.grey[300]}`:"none",paddingRight:1.5,...t},children:e})}import{Paper as Ya,Stack as ja}from"@mui/material";import{jsx as et}from"react/jsx-runtime";function j({children:e}){return et(ja,{component:Ya,elevation:0,gap:1.5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",p:1,borderRadius:"8px 8px 0 0",sx:{width:"100%"},children:e})}var ot={CellActionTransport:N,SelectionCounter:_,CellActionDelete:V,ExportCsvButton:Q,CellActionEdit:z,CellActions:X,CellAction:W,Pagination:J,Actions:G,Toolbar:j,Content:K,Button:w,Footer:Z,Table:q,Title:Y,Root:$,Action:v,ActionEdit:H,ActionDelete:O,ActionTransport:E,ColumnsPanelTrigger:at,useGridApiRef:tt},ut=ot;export{ut as DataTable};
1
+ // src/DataTable/index.ts
2
+ import { ColumnsPanelTrigger, useGridApiRef as useGridApiRef2 } from "@mui/x-data-grid-pro";
3
+
4
+ // src/DataTable/DataTable.tsx
5
+ import { useEffect, useMemo } from "react";
6
+ import { Circle } from "@mui/icons-material";
7
+ import { LinearProgress, Stack as Stack3 } from "@mui/material";
8
+ import {
9
+ DataGridPro,
10
+ gridFilteredSortedRowIdsSelector
11
+ } from "@mui/x-data-grid-pro";
12
+ import { ptBR } from "@mui/x-data-grid-pro/locales";
13
+
14
+ // src/DataTable/DataTableEmptyData.tsx
15
+ import { Stack, Typography } from "@mui/material";
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ function DataTableEmptyData() {
18
+ return /* @__PURE__ */ jsxs(
19
+ Stack,
20
+ {
21
+ alignItems: "center",
22
+ justifyContent: "center",
23
+ gap: 2,
24
+ padding: 2,
25
+ maxWidth: "400px",
26
+ minWidth: "200px",
27
+ children: [
28
+ /* @__PURE__ */ jsx(
29
+ Stack,
30
+ {
31
+ width: "250px",
32
+ height: "250px",
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ borderRadius: "50%",
36
+ sx: {
37
+ background: "linear-gradient(to top, #ffffff, #fdfcfd, #fafafa, #f8f7f8, #f5f5f6);"
38
+ },
39
+ children: /* @__PURE__ */ jsx(
40
+ "img",
41
+ {
42
+ src: "https://datac-site-assets.s3.sa-east-1.amazonaws.com/empty-data.svg",
43
+ alt: "Imagem de notifica\xE7\xE3o",
44
+ width: "148px",
45
+ height: "148px"
46
+ }
47
+ )
48
+ }
49
+ ),
50
+ /* @__PURE__ */ jsxs(Stack, { spacing: 1, textAlign: "center", children: [
51
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", component: "h2", fontWeight: "600", children: "Nenhum registro encontrado" }),
52
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", whiteSpace: "normal", children: "Tente outra pesquisa ou adicione um novo registro." })
53
+ ] })
54
+ ]
55
+ }
56
+ );
57
+ }
58
+
59
+ // src/DataTable/DataTableError.tsx
60
+ import { Stack as Stack2, Typography as Typography2 } from "@mui/material";
61
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
62
+ function DataTableError({
63
+ errorMessage
64
+ }) {
65
+ return /* @__PURE__ */ jsxs2(
66
+ Stack2,
67
+ {
68
+ alignItems: "center",
69
+ justifyContent: "center",
70
+ gap: 2,
71
+ padding: 2,
72
+ maxWidth: "400px",
73
+ minWidth: "200px",
74
+ children: [
75
+ /* @__PURE__ */ jsx2(
76
+ Stack2,
77
+ {
78
+ width: "250px",
79
+ height: "250px",
80
+ alignItems: "center",
81
+ justifyContent: "center",
82
+ borderRadius: "50%",
83
+ sx: {
84
+ background: "linear-gradient(to top, #ffffff, #fdfcfd, #fafafa, #f8f7f8, #f5f5f6);"
85
+ },
86
+ children: /* @__PURE__ */ jsx2(
87
+ "img",
88
+ {
89
+ src: "https://datac-site-assets.s3.sa-east-1.amazonaws.com/error.svg",
90
+ alt: "Imagem de erro",
91
+ width: "148px",
92
+ height: "148px"
93
+ }
94
+ )
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsxs2(Stack2, { gap: 1, textAlign: "center", children: [
98
+ /* @__PURE__ */ jsx2(Typography2, { variant: "h4", component: "h2", fontWeight: "600", children: "Ops! Algo deu errado" }),
99
+ /* @__PURE__ */ jsx2(Typography2, { variant: "body2", children: errorMessage })
100
+ ] })
101
+ ]
102
+ }
103
+ );
104
+ }
105
+
106
+ // src/DataTable/DataTableRootProvider.tsx
107
+ import {
108
+ createContext,
109
+ useContext,
110
+ useState
111
+ } from "react";
112
+ import { useGridApiRef } from "@mui/x-data-grid-pro";
113
+ import { jsx as jsx3 } from "react/jsx-runtime";
114
+ var TableRootContext = createContext({});
115
+ function TableRootProvider({
116
+ children
117
+ }) {
118
+ const [ids, setIds] = useState({
119
+ type: "include",
120
+ ids: /* @__PURE__ */ new Set()
121
+ });
122
+ const [clearCallback, setClearCallback] = useState(false);
123
+ const [breakpoint, setBreakpoint] = useState(false);
124
+ const apiRef = useGridApiRef();
125
+ function handleClearRowsSelectedId() {
126
+ setIds({
127
+ type: "include",
128
+ ids: /* @__PURE__ */ new Set()
129
+ });
130
+ setClearCallback(true);
131
+ }
132
+ return /* @__PURE__ */ jsx3(
133
+ TableRootContext.Provider,
134
+ {
135
+ value: {
136
+ apiRef,
137
+ rowsSelectedId: ids,
138
+ clearCallback,
139
+ breakpoint,
140
+ setClearCallback,
141
+ setBreakpoint,
142
+ setRowsSelectedId: setIds,
143
+ clearRowsSelectedId: handleClearRowsSelectedId
144
+ },
145
+ children
146
+ }
147
+ );
148
+ }
149
+ function useTableRootContext() {
150
+ return useContext(TableRootContext);
151
+ }
152
+
153
+ // src/DataTable/DataTable.tsx
154
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
155
+ var getFilteredRows = ({ apiRef }) => gridFilteredSortedRowIdsSelector(apiRef);
156
+ function Table(props) {
157
+ const {
158
+ error,
159
+ isLoading,
160
+ isFetching,
161
+ data,
162
+ columns,
163
+ controlledRowsSelectedId,
164
+ onClearRowsSelectedId,
165
+ onRowSelectionChange,
166
+ onCellKeyDown,
167
+ onRowDoubleClick,
168
+ stackProps,
169
+ slots,
170
+ ...rest
171
+ } = props;
172
+ const {
173
+ rowsSelectedId,
174
+ setRowsSelectedId,
175
+ clearCallback,
176
+ setClearCallback,
177
+ apiRef
178
+ } = useTableRootContext();
179
+ const parsedColumns = useMemo(() => {
180
+ return (columns2) => {
181
+ return columns2.map((col) => {
182
+ if (col.headerName === "A\xE7\xF5es") {
183
+ return {
184
+ ...col,
185
+ minWidth: col.minWidth || 80,
186
+ maxWidth: col.maxWidth || col.width || 80,
187
+ headerClassName: "sticky-header",
188
+ cellClassName: "sticky-cell"
189
+ };
190
+ }
191
+ return {
192
+ ...col,
193
+ flex: col.flex || 1,
194
+ minWidth: col.minWidth || 100,
195
+ headerClassName: col?.enableStickyColumns ? "sticky-header" : "",
196
+ cellClassName: col?.enableStickyColumns ? "sticky-cell" : ""
197
+ };
198
+ });
199
+ };
200
+ }, [columns]);
201
+ useEffect(() => {
202
+ if (controlledRowsSelectedId) {
203
+ setRowsSelectedId(controlledRowsSelectedId);
204
+ }
205
+ }, [controlledRowsSelectedId]);
206
+ useEffect(() => {
207
+ if (clearCallback) {
208
+ onClearRowsSelectedId && onClearRowsSelectedId({
209
+ type: "include",
210
+ ids: /* @__PURE__ */ new Set()
211
+ });
212
+ setClearCallback(false);
213
+ }
214
+ }, [clearCallback]);
215
+ function handleCellKeyDown(params, event, details) {
216
+ const eventCode = event.ctrlKey && event.code === "KeyE" ? "ctrl+e" : event.code;
217
+ switch (eventCode) {
218
+ case "Enter":
219
+ event.preventDefault();
220
+ if (onCellKeyDown)
221
+ onCellKeyDown("edit", params.id);
222
+ break;
223
+ case "F3":
224
+ event.preventDefault();
225
+ if (onCellKeyDown)
226
+ onCellKeyDown("edit", params.id);
227
+ break;
228
+ case "Delete":
229
+ event.preventDefault();
230
+ if (onCellKeyDown)
231
+ onCellKeyDown("delete", params.id);
232
+ break;
233
+ case "ctrl+e":
234
+ event.preventDefault();
235
+ const handleExport = (options) => {
236
+ if (apiRef?.current) {
237
+ apiRef.current.exportDataAsCsv(options);
238
+ }
239
+ };
240
+ handleExport({ getRowsToExport: getFilteredRows });
241
+ break;
242
+ default:
243
+ break;
244
+ }
245
+ }
246
+ function handleRowDoubleClick(params, _, details) {
247
+ if (onRowDoubleClick)
248
+ onRowDoubleClick("edit", params.id);
249
+ }
250
+ return /* @__PURE__ */ jsxs3(Stack3, { height: "100%", minHeight: "500px", position: "relative", ...stackProps, children: [
251
+ !isLoading && isFetching && /* @__PURE__ */ jsx4(
252
+ LinearProgress,
253
+ {
254
+ sx: {
255
+ position: "absolute",
256
+ top: 0,
257
+ right: 0,
258
+ left: 0,
259
+ zIndex: 999,
260
+ height: "3px"
261
+ }
262
+ }
263
+ ),
264
+ /* @__PURE__ */ jsx4(
265
+ DataGridPro,
266
+ {
267
+ apiRef,
268
+ rows: data,
269
+ columns: parsedColumns(columns),
270
+ density: "compact",
271
+ hideFooterPagination: true,
272
+ hideFooter: true,
273
+ loading: isLoading,
274
+ rowHeight: 43,
275
+ columnHeaderHeight: 43,
276
+ disableVirtualization: true,
277
+ onRowDoubleClick: handleRowDoubleClick,
278
+ onCellKeyDown: handleCellKeyDown,
279
+ disableRowSelectionOnClick: true,
280
+ rowSelectionModel: rowsSelectedId,
281
+ onRowSelectionModelChange: (rowSelectionModel, details) => {
282
+ if (onRowSelectionChange) {
283
+ onRowSelectionChange(rowSelectionModel, details);
284
+ }
285
+ if (controlledRowsSelectedId)
286
+ return;
287
+ setRowsSelectedId(rowSelectionModel);
288
+ },
289
+ slots: {
290
+ booleanCellFalseIcon: () => /* @__PURE__ */ jsx4(Circle, { color: "error", sx: { fontSize: "10pt" } }),
291
+ booleanCellTrueIcon: () => /* @__PURE__ */ jsx4(Circle, { color: "success", sx: { fontSize: "10pt" } }),
292
+ noRowsOverlay: () => !isLoading && !!error ? /* @__PURE__ */ jsx4(DataTableError, { errorMessage: error }) : /* @__PURE__ */ jsx4(DataTableEmptyData, {}),
293
+ ...slots
294
+ },
295
+ slotProps: {
296
+ loadingOverlay: {
297
+ variant: "skeleton",
298
+ noRowsVariant: "skeleton"
299
+ }
300
+ },
301
+ disableColumnFilter: true,
302
+ localeText: ptBR.components.MuiDataGrid.defaultProps.localeText,
303
+ sx: {
304
+ border: "none",
305
+ borderRadius: 0,
306
+ "--DataGrid-rowBorderColor": "#edf2f9",
307
+ "--DataGrid-containerBackground": "#f4f6fa",
308
+ ".MuiDataGrid-overlayWrapperInner": {
309
+ display: "flex",
310
+ alignItems: "center",
311
+ justifyContent: "center"
312
+ },
313
+ ".MuiDataGrid-row": {
314
+ backgroundColor: "white",
315
+ "&:nth-of-type(even)": {
316
+ backgroundColor: "#f9fafd"
317
+ },
318
+ ":hover": {
319
+ backgroundColor: "#e9e9e9"
320
+ },
321
+ "&.Mui-selected": {
322
+ backgroundColor: "rgb(238, 249, 252)",
323
+ "&:hover": {
324
+ backgroundColor: "rgb(222, 243, 249)"
325
+ }
326
+ }
327
+ },
328
+ ".MuiDataGrid-cell": {
329
+ fontSize: "12px",
330
+ color: "#0b0e14"
331
+ },
332
+ ".MuiDataGrid-columnHeaders": {
333
+ border: "solid 1px #edf2f9",
334
+ backgroundColor: "#f4f6fa"
335
+ },
336
+ ".MuiDataGrid-columnHeader": {
337
+ backgroundColor: "#f4f6fa"
338
+ },
339
+ ".MuiDataGrid-columnHeaders .MuiDataGrid-filler": {
340
+ backgroundColor: "#f4f6fa"
341
+ },
342
+ ".MuiDataGrid-columnHeaderTitle": {
343
+ fontSize: "12px",
344
+ color: "#0b0e14",
345
+ fontWeight: "600"
346
+ },
347
+ "& .sticky-cell": {
348
+ position: "sticky",
349
+ right: 0,
350
+ background: "inherit",
351
+ zIndex: 1
352
+ },
353
+ "& .sticky-header": {
354
+ position: "sticky",
355
+ right: 0,
356
+ backgroundColor: "#f4f6fa",
357
+ zIndex: 2
358
+ }
359
+ },
360
+ ...rest
361
+ }
362
+ )
363
+ ] });
364
+ }
365
+
366
+ // src/DataTable/DataTableAction.tsx
367
+ import {
368
+ GridActionsCellItem
369
+ } from "@mui/x-data-grid-pro";
370
+ import { jsx as jsx5 } from "react/jsx-runtime";
371
+ function DataTableAction(props) {
372
+ const { ref, ...rest } = props;
373
+ return /* @__PURE__ */ jsx5(
374
+ GridActionsCellItem,
375
+ {
376
+ ...rest,
377
+ ref
378
+ }
379
+ );
380
+ }
381
+
382
+ // src/DataTable/DataTableActionDelete.tsx
383
+ import {
384
+ GridActionsCellItem as GridActionsCellItem2
385
+ } from "@mui/x-data-grid-pro";
386
+
387
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
388
+ import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
389
+
390
+ // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
391
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
392
+ var toCamelCase = (string) => string.replace(
393
+ /^([A-Z])|[\s-_]+(\w)/g,
394
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
395
+ );
396
+ var toPascalCase = (string) => {
397
+ const camelCase = toCamelCase(string);
398
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
399
+ };
400
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
401
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
402
+ }).join(" ").trim();
403
+ var hasA11yProp = (props) => {
404
+ for (const prop in props) {
405
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
406
+ return true;
407
+ }
408
+ }
409
+ };
410
+
411
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
412
+ import { forwardRef, createElement } from "react";
413
+
414
+ // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
415
+ var defaultAttributes = {
416
+ xmlns: "http://www.w3.org/2000/svg",
417
+ width: 24,
418
+ height: 24,
419
+ viewBox: "0 0 24 24",
420
+ fill: "none",
421
+ stroke: "currentColor",
422
+ strokeWidth: 2,
423
+ strokeLinecap: "round",
424
+ strokeLinejoin: "round"
425
+ };
426
+
427
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
428
+ var Icon = forwardRef(
429
+ ({
430
+ color = "currentColor",
431
+ size = 24,
432
+ strokeWidth = 2,
433
+ absoluteStrokeWidth,
434
+ className = "",
435
+ children,
436
+ iconNode,
437
+ ...rest
438
+ }, ref) => createElement(
439
+ "svg",
440
+ {
441
+ ref,
442
+ ...defaultAttributes,
443
+ width: size,
444
+ height: size,
445
+ stroke: color,
446
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
447
+ className: mergeClasses("lucide", className),
448
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
449
+ ...rest
450
+ },
451
+ [
452
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
453
+ ...Array.isArray(children) ? children : [children]
454
+ ]
455
+ )
456
+ );
457
+
458
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
459
+ var createLucideIcon = (iconName, iconNode) => {
460
+ const Component = forwardRef2(
461
+ ({ className, ...props }, ref) => createElement2(Icon, {
462
+ ref,
463
+ iconNode,
464
+ className: mergeClasses(
465
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
466
+ `lucide-${iconName}`,
467
+ className
468
+ ),
469
+ ...props
470
+ })
471
+ );
472
+ Component.displayName = toPascalCase(iconName);
473
+ return Component;
474
+ };
475
+
476
+ // ../../node_modules/lucide-react/dist/esm/icons/arrow-big-down.js
477
+ var __iconNode = [
478
+ [
479
+ "path",
480
+ {
481
+ d: "M15 11a1 1 0 0 0 1 1h2.939a1 1 0 0 1 .75 1.811l-6.835 6.836a1.207 1.207 0 0 1-1.707 0L4.31 13.81a1 1 0 0 1 .75-1.811H8a1 1 0 0 0 1-1V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1z",
482
+ key: "1eaqc3"
483
+ }
484
+ ]
485
+ ];
486
+ var ArrowBigDown = createLucideIcon("arrow-big-down", __iconNode);
487
+
488
+ // ../../node_modules/lucide-react/dist/esm/icons/pencil.js
489
+ var __iconNode2 = [
490
+ [
491
+ "path",
492
+ {
493
+ d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
494
+ key: "1a8usu"
495
+ }
496
+ ],
497
+ ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
498
+ ];
499
+ var Pencil = createLucideIcon("pencil", __iconNode2);
500
+
501
+ // ../../node_modules/lucide-react/dist/esm/icons/trash-2.js
502
+ var __iconNode3 = [
503
+ ["path", { d: "M10 11v6", key: "nco0om" }],
504
+ ["path", { d: "M14 11v6", key: "outv1u" }],
505
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
506
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
507
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
508
+ ];
509
+ var Trash2 = createLucideIcon("trash-2", __iconNode3);
510
+
511
+ // src/DataTable/DataTableActionDelete.tsx
512
+ import { jsx as jsx6 } from "react/jsx-runtime";
513
+ function DataTableActionDelete(props) {
514
+ const { ref, ...rest } = props;
515
+ return /* @__PURE__ */ jsx6(
516
+ GridActionsCellItem2,
517
+ {
518
+ color: "error",
519
+ label: "Deletar",
520
+ icon: /* @__PURE__ */ jsx6(Trash2, { size: 16 }),
521
+ ...rest,
522
+ ref
523
+ }
524
+ );
525
+ }
526
+
527
+ // src/DataTable/DataTableActionEdit.tsx
528
+ import {
529
+ GridActionsCellItem as GridActionsCellItem3
530
+ } from "@mui/x-data-grid-pro";
531
+ import { jsx as jsx7 } from "react/jsx-runtime";
532
+ function DataTableActionEdit(props) {
533
+ const { ref, ...rest } = props;
534
+ return /* @__PURE__ */ jsx7(
535
+ GridActionsCellItem3,
536
+ {
537
+ label: "Editar",
538
+ color: "primary",
539
+ icon: /* @__PURE__ */ jsx7(Pencil, { size: 16 }),
540
+ ...rest,
541
+ ref
542
+ }
543
+ );
544
+ }
545
+
546
+ // src/DataTable/DataTableActions.tsx
547
+ import { useEffect as useEffect2 } from "react";
548
+ import { Stack as Stack4, useMediaQuery, useTheme } from "@mui/material";
549
+ import { jsx as jsx8 } from "react/jsx-runtime";
550
+ function Actions({ children, breakpoints }) {
551
+ const { setBreakpoint } = useTableRootContext();
552
+ const theme = useTheme();
553
+ const breakpoint = useMediaQuery(theme.breakpoints.down(breakpoints || "md"));
554
+ useEffect2(() => {
555
+ setBreakpoint(breakpoint);
556
+ }, [breakpoint]);
557
+ return /* @__PURE__ */ jsx8(
558
+ Stack4,
559
+ {
560
+ flexDirection: "row",
561
+ alignItems: "center",
562
+ justifyContent: "flex-end",
563
+ gap: 1,
564
+ marginLeft: "auto",
565
+ flexGrow: 1,
566
+ children
567
+ }
568
+ );
569
+ }
570
+
571
+ // src/DataTable/DataTableActionTransport.tsx
572
+ import {
573
+ GridActionsCellItem as GridActionsCellItem4
574
+ } from "@mui/x-data-grid-pro";
575
+ import { jsx as jsx9 } from "react/jsx-runtime";
576
+ function DataTableActionTransport(props) {
577
+ const { ref, ...rest } = props;
578
+ return /* @__PURE__ */ jsx9(
579
+ GridActionsCellItem4,
580
+ {
581
+ color: "primary",
582
+ label: "Transportar",
583
+ icon: /* @__PURE__ */ jsx9(ArrowBigDown, { size: 16 }),
584
+ ...rest,
585
+ ref
586
+ }
587
+ );
588
+ }
589
+
590
+ // src/DataTable/DataTableButton.tsx
591
+ import {
592
+ Button as MuiButton,
593
+ CircularProgress,
594
+ IconButton,
595
+ Tooltip,
596
+ Box
597
+ } from "@mui/material";
598
+ import { Fragment, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
599
+ function DataTableButton(props) {
600
+ const { isLoading, startIcon, children, title, ...rest } = props;
601
+ const { breakpoint } = useTableRootContext();
602
+ return /* @__PURE__ */ jsx10(Fragment, { children: breakpoint ? /* @__PURE__ */ jsx10(Tooltip, { title: children, children: /* @__PURE__ */ jsxs4(
603
+ IconButton,
604
+ {
605
+ ...rest,
606
+ color: "primary",
607
+ disabled: isLoading ? true : rest.disabled,
608
+ children: [
609
+ startIcon,
610
+ isLoading && /* @__PURE__ */ jsx10(
611
+ CircularProgress,
612
+ {
613
+ color: "secondary",
614
+ size: 14,
615
+ sx: {
616
+ position: "absolute",
617
+ top: "25%",
618
+ bottom: "25%",
619
+ left: "25%",
620
+ right: "25%",
621
+ transform: "translate(-50%, -50%)"
622
+ }
623
+ }
624
+ )
625
+ ]
626
+ }
627
+ ) }) : /* @__PURE__ */ jsx10(
628
+ MuiButton,
629
+ {
630
+ startIcon,
631
+ disabled: isLoading ? true : rest.disabled,
632
+ sx: {
633
+ position: "relative",
634
+ height: "26px",
635
+ minWidth: "70px",
636
+ padding: "7px 8px 8px",
637
+ border: "1px solid rgba(223, 226, 231, 0.8)",
638
+ borderRadius: "6px",
639
+ display: "flex",
640
+ alignItems: "center",
641
+ overflow: "hidden",
642
+ whiteSpace: "nowrap",
643
+ flexShrink: 1,
644
+ transition: "width 0.2s ease"
645
+ },
646
+ ...rest,
647
+ children: /* @__PURE__ */ jsxs4(
648
+ Box,
649
+ {
650
+ component: "span",
651
+ sx: {
652
+ transition: "opacity 0.2s ease, width 0.2s ease",
653
+ overflow: "hidden",
654
+ whiteSpace: "nowrap",
655
+ textOverflow: "ellipsis"
656
+ },
657
+ children: [
658
+ isLoading && /* @__PURE__ */ jsx10(
659
+ CircularProgress,
660
+ {
661
+ color: "secondary",
662
+ size: 14,
663
+ sx: {
664
+ position: "absolute",
665
+ top: "22%",
666
+ left: "44%",
667
+ transform: "translate(-50%, -50%)"
668
+ }
669
+ }
670
+ ),
671
+ children
672
+ ]
673
+ }
674
+ )
675
+ }
676
+ ) });
677
+ }
678
+
679
+ // src/DataTable/DataTableCellAction.tsx
680
+ import { GridActionsCellItem as GridActionsCellItem5 } from "@mui/x-data-grid-pro";
681
+ import { jsx as jsx11 } from "react/jsx-runtime";
682
+ function CellAction(props) {
683
+ const { event, onClick, ...rest } = props;
684
+ return /* @__PURE__ */ jsx11(
685
+ GridActionsCellItem5,
686
+ {
687
+ label: "A\xE7\xE3o",
688
+ onClick: () => {
689
+ },
690
+ icon: /* @__PURE__ */ jsx11("span", { children: "\u{1F527}" })
691
+ }
692
+ );
693
+ }
694
+
695
+ // src/DataTable/DataTableCellActionDelete.tsx
696
+ import { Delete as DeleteIcon } from "@mui/icons-material";
697
+ import { GridActionsCellItem as GridActionsCellItem6 } from "@mui/x-data-grid-pro";
698
+ import { jsx as jsx12 } from "react/jsx-runtime";
699
+ function CellActionDelete({
700
+ onClick,
701
+ ...rest
702
+ }) {
703
+ return /* @__PURE__ */ jsx12(
704
+ GridActionsCellItem6,
705
+ {
706
+ icon: /* @__PURE__ */ jsx12(DeleteIcon, {}),
707
+ label: "Delete",
708
+ color: "primary",
709
+ onClick: () => {
710
+ if (onClick)
711
+ onClick("delete");
712
+ },
713
+ ...rest
714
+ }
715
+ );
716
+ }
717
+
718
+ // src/DataTable/DataTableCellActionEdit.tsx
719
+ import { Edit as EditIcon } from "@mui/icons-material";
720
+ import { GridActionsCellItem as GridActionsCellItem7 } from "@mui/x-data-grid-pro";
721
+ import { jsx as jsx13 } from "react/jsx-runtime";
722
+ function CellActionEdit({
723
+ onClick,
724
+ ...rest
725
+ }) {
726
+ return /* @__PURE__ */ jsx13(
727
+ GridActionsCellItem7,
728
+ {
729
+ icon: /* @__PURE__ */ jsx13(EditIcon, {}),
730
+ label: "Edit",
731
+ color: "primary",
732
+ onClick: () => onClick && onClick("edit"),
733
+ ...rest
734
+ }
735
+ );
736
+ }
737
+
738
+ // src/DataTable/DataTableCellActions.tsx
739
+ import { Children, cloneElement, isValidElement } from "react";
740
+ import { Fragment as Fragment2, jsx as jsx14 } from "react/jsx-runtime";
741
+ function CellActions(props) {
742
+ const { children, onClick: onItemClick } = props;
743
+ return /* @__PURE__ */ jsx14(Fragment2, { children: Children.map(children, (child) => {
744
+ if (isValidElement(child)) {
745
+ return cloneElement(child, {
746
+ onClick: onItemClick
747
+ });
748
+ }
749
+ }) });
750
+ }
751
+
752
+ // src/DataTable/DataTableCellActionTransport.tsx
753
+ import { GetApp as TransportIcon } from "@mui/icons-material";
754
+ import { GridActionsCellItem as GridActionsCellItem8 } from "@mui/x-data-grid-pro";
755
+ import { jsx as jsx15 } from "react/jsx-runtime";
756
+ function CellActionTransport({
757
+ onClick,
758
+ ...rest
759
+ }) {
760
+ return /* @__PURE__ */ jsx15(
761
+ GridActionsCellItem8,
762
+ {
763
+ icon: /* @__PURE__ */ jsx15(TransportIcon, {}),
764
+ label: "Transport",
765
+ color: "primary",
766
+ onClick: () => onClick && onClick("transport"),
767
+ ...rest
768
+ }
769
+ );
770
+ }
771
+
772
+ // src/DataTable/DataTableContent.tsx
773
+ import { Stack as Stack5 } from "@mui/material";
774
+ import { jsx as jsx16 } from "react/jsx-runtime";
775
+ function Content(props) {
776
+ return /* @__PURE__ */ jsx16(
777
+ Stack5,
778
+ {
779
+ direction: "row",
780
+ width: "100%",
781
+ flexGrow: 1,
782
+ alignItems: "center",
783
+ gap: 1.5,
784
+ sx: { background: "#f4f" },
785
+ ...props
786
+ }
787
+ );
788
+ }
789
+
790
+ // src/DataTable/DataTableExportCsvButton.tsx
791
+ import { FileDownload as FileDownloadIcon } from "@mui/icons-material";
792
+ import {
793
+ gridFilteredSortedRowIdsSelector as gridFilteredSortedRowIdsSelector2
794
+ } from "@mui/x-data-grid-pro";
795
+ import { jsx as jsx17 } from "react/jsx-runtime";
796
+ var getFilteredRows2 = ({ apiRef }) => gridFilteredSortedRowIdsSelector2(apiRef);
797
+ function ExportCsvButton() {
798
+ const { apiRef } = useTableRootContext();
799
+ const handleExport = (options) => {
800
+ if (apiRef?.current) {
801
+ apiRef.current.exportDataAsCsv(options);
802
+ }
803
+ };
804
+ return /* @__PURE__ */ jsx17(
805
+ DataTableButton,
806
+ {
807
+ startIcon: /* @__PURE__ */ jsx17(FileDownloadIcon, {}),
808
+ onClick: () => handleExport({ getRowsToExport: getFilteredRows2 }),
809
+ children: "Exportar CSV"
810
+ }
811
+ );
812
+ }
813
+
814
+ // src/DataTable/DataTableFooter.tsx
815
+ import { TableFooter } from "@mui/material";
816
+ import { jsx as jsx18 } from "react/jsx-runtime";
817
+ function Footer(props) {
818
+ return /* @__PURE__ */ jsx18(
819
+ TableFooter,
820
+ {
821
+ ...props,
822
+ sx: {
823
+ height: "54px",
824
+ paddingX: "12px",
825
+ gap: "12px",
826
+ display: "flex",
827
+ alignItems: "center",
828
+ backgroundColor: "white",
829
+ borderBottomLeftRadius: "8px",
830
+ borderBottomRightRadius: "8px",
831
+ borderTop: "1px solid #edf2f9"
832
+ }
833
+ }
834
+ );
835
+ }
836
+
837
+ // src/DataTable/DataTablePagination.tsx
838
+ import {
839
+ pluralizar
840
+ } from "@data-c/hooks";
841
+ import {
842
+ MenuItem,
843
+ Pagination as MuiPagination,
844
+ Stack as Stack6,
845
+ TextField,
846
+ Typography as Typography3
847
+ } from "@mui/material";
848
+ import { useMemo as useMemo2 } from "react";
849
+ import { jsx as jsx19, jsxs as jsxs5 } from "react/jsx-runtime";
850
+ function Pagination(props) {
851
+ const {
852
+ onChangePageSize,
853
+ onChangePage,
854
+ pagination,
855
+ rowsPerPageOptions = [15, 50, 100, 200]
856
+ } = props;
857
+ const { page, pageSize = 15, totalRecords } = pagination || {};
858
+ const pages = useMemo2(() => {
859
+ if (pagination?.lastPage)
860
+ return pagination.lastPage;
861
+ if ((totalRecords || 0) < pageSize)
862
+ return 1;
863
+ return Math.max(Math.ceil((totalRecords || 0) / pageSize));
864
+ }, [totalRecords, pageSize]);
865
+ const totalRecordsLabel = useMemo2(() => {
866
+ if ((totalRecords || 0) < pageSize)
867
+ return `Exibindo ${pluralizar(
868
+ totalRecords || 0,
869
+ "registro",
870
+ "registros",
871
+ true
872
+ )}`;
873
+ let registrosExibidos = pageSize;
874
+ if (page === pages) {
875
+ const ultimaPaginaRegistros = (totalRecords || 0) % pageSize;
876
+ registrosExibidos = ultimaPaginaRegistros === 0 ? pageSize : ultimaPaginaRegistros;
877
+ }
878
+ return `Exibindo ${pluralizar(
879
+ registrosExibidos || 0,
880
+ "registro",
881
+ "registros",
882
+ true
883
+ )} de ${totalRecords}`;
884
+ }, [pagination, pages]);
885
+ const showPagination = true;
886
+ return /* @__PURE__ */ jsxs5(
887
+ Stack6,
888
+ {
889
+ width: "100%",
890
+ direction: "row",
891
+ alignItems: "center",
892
+ gap: 2,
893
+ marginLeft: "auto",
894
+ children: [
895
+ /* @__PURE__ */ jsx19(
896
+ Typography3,
897
+ {
898
+ variant: "body2",
899
+ fontSize: "13px",
900
+ fontWeight: "500",
901
+ whiteSpace: "nowrap",
902
+ children: totalRecordsLabel
903
+ }
904
+ ),
905
+ showPagination && /* @__PURE__ */ jsxs5(Stack6, { direction: "row", alignItems: "center", gap: 2, marginLeft: "auto", children: [
906
+ /* @__PURE__ */ jsx19(
907
+ TextField,
908
+ {
909
+ sx: {
910
+ width: "78px",
911
+ fontSize: "8pt"
912
+ },
913
+ size: "small",
914
+ value: pageSize || 0,
915
+ select: true,
916
+ onChange: (e) => {
917
+ if (onChangePageSize) {
918
+ onChangePageSize(parseInt(e.target.value));
919
+ }
920
+ },
921
+ children: rowsPerPageOptions.map((option) => /* @__PURE__ */ jsx19(MenuItem, { value: option, children: option }, option))
922
+ }
923
+ ),
924
+ /* @__PURE__ */ jsx19(
925
+ MuiPagination,
926
+ {
927
+ variant: "outlined",
928
+ shape: "rounded",
929
+ count: pages || 0,
930
+ showFirstButton: true,
931
+ showLastButton: true,
932
+ onChange: (_, _page) => {
933
+ if (onChangePage)
934
+ onChangePage(_page);
935
+ },
936
+ page: page || 0,
937
+ color: "primary"
938
+ }
939
+ )
940
+ ] })
941
+ ]
942
+ }
943
+ );
944
+ }
945
+
946
+ // src/DataTable/DataTableRoot.tsx
947
+ import { useEffect as useEffect3, useRef, useState as useState2 } from "react";
948
+ import { Stack as Stack7 } from "@mui/material";
949
+ import { jsx as jsx20 } from "react/jsx-runtime";
950
+ function Root({ children, height, ...rest }) {
951
+ const tableContainerRef = useRef(null);
952
+ const [tableHeight, setTableHeight] = useState2(500);
953
+ useEffect3(() => {
954
+ const calculateHeight = () => {
955
+ const container = tableContainerRef.current;
956
+ if (!container)
957
+ return;
958
+ const containerTop = container.getBoundingClientRect().top;
959
+ setTableHeight(window.innerHeight - containerTop);
960
+ };
961
+ calculateHeight();
962
+ window.addEventListener("resize", calculateHeight);
963
+ return () => {
964
+ window.removeEventListener("resize", calculateHeight);
965
+ };
966
+ }, []);
967
+ return /* @__PURE__ */ jsx20(
968
+ Stack7,
969
+ {
970
+ ref: tableContainerRef,
971
+ sx: {
972
+ backgroundColor: "#f4f6fa",
973
+ border: "1px solid #edf2f9",
974
+ borderRadius: 2,
975
+ height: height || `calc(${tableHeight}px - 16px)`,
976
+ ...rest.sx
977
+ },
978
+ ...rest,
979
+ children: /* @__PURE__ */ jsx20(TableRootProvider, { children })
980
+ }
981
+ );
982
+ }
983
+
984
+ // src/DataTable/DataTableSelectionCounter.tsx
985
+ import { Stack as Stack8, Typography as Typography4 } from "@mui/material";
986
+ import { useMemo as useMemo3 } from "react";
987
+ import { jsx as jsx21, jsxs as jsxs6 } from "react/jsx-runtime";
988
+ function SelectionCounter(props) {
989
+ const { countTitle, gender } = props;
990
+ const { rowsSelectedId } = useTableRootContext();
991
+ const countQuantidade = rowsSelectedId?.ids.size || 0;
992
+ const flexSufixCountTitle = useMemo3(() => {
993
+ if (!countTitle)
994
+ return "";
995
+ const selecionadoText = gender === "feminino" ? "selecionada" : "selecionado";
996
+ const selecionadosText = gender === "feminino" ? "selecionadas" : "selecionados";
997
+ const nenhumText = gender === "feminino" ? "Nenhuma" : "Nenhum";
998
+ return countQuantidade === 1 ? `${countTitle} ${selecionadoText}` : countQuantidade && countQuantidade > 1 ? `${countTitle.split(" ").map((item) => `${item}s`).join(" ")} ${selecionadosText}` : `${nenhumText} ${countTitle} ${selecionadoText}`;
999
+ }, [countQuantidade]);
1000
+ return /* @__PURE__ */ jsx21(Stack8, { children: /* @__PURE__ */ jsxs6(
1001
+ Typography4,
1002
+ {
1003
+ variant: "body2",
1004
+ fontSize: "13px",
1005
+ fontWeight: "500",
1006
+ whiteSpace: "nowrap",
1007
+ children: [
1008
+ countQuantidade && countQuantidade > 0 ? countQuantidade : "",
1009
+ " ",
1010
+ flexSufixCountTitle
1011
+ ]
1012
+ }
1013
+ ) });
1014
+ }
1015
+
1016
+ // src/DataTable/DataTableTitle.tsx
1017
+ import { Typography as Typography5, useTheme as useTheme2 } from "@mui/material";
1018
+ import { jsx as jsx22 } from "react/jsx-runtime";
1019
+ function Title({
1020
+ children,
1021
+ titleDivider = false,
1022
+ sx
1023
+ }) {
1024
+ const theme = useTheme2();
1025
+ return /* @__PURE__ */ jsx22(
1026
+ Typography5,
1027
+ {
1028
+ variant: "h6",
1029
+ whiteSpace: "nowrap",
1030
+ sx: {
1031
+ borderRight: titleDivider ? `solid 1px ${theme.palette.grey[300]}` : "none",
1032
+ paddingRight: 1.5,
1033
+ ...sx
1034
+ },
1035
+ children
1036
+ }
1037
+ );
1038
+ }
1039
+
1040
+ // src/DataTable/DataTableToolbar.tsx
1041
+ import { Paper, Stack as Stack9 } from "@mui/material";
1042
+ import { jsx as jsx23 } from "react/jsx-runtime";
1043
+ function Toolbar({ children }) {
1044
+ return /* @__PURE__ */ jsx23(
1045
+ Stack9,
1046
+ {
1047
+ component: Paper,
1048
+ elevation: 0,
1049
+ gap: 1.5,
1050
+ flexDirection: "row",
1051
+ justifyContent: "space-between",
1052
+ alignItems: "center",
1053
+ p: 1,
1054
+ borderRadius: "8px 8px 0 0",
1055
+ sx: { width: "100%" },
1056
+ children
1057
+ }
1058
+ );
1059
+ }
1060
+
1061
+ // src/DataTable/index.ts
1062
+ var DataTable = {
1063
+ CellActionTransport,
1064
+ SelectionCounter,
1065
+ CellActionDelete,
1066
+ ExportCsvButton,
1067
+ CellActionEdit,
1068
+ CellActions,
1069
+ CellAction,
1070
+ Pagination,
1071
+ Actions,
1072
+ Toolbar,
1073
+ Content,
1074
+ Button: DataTableButton,
1075
+ Footer,
1076
+ Table,
1077
+ Title,
1078
+ Root,
1079
+ Action: DataTableAction,
1080
+ ActionEdit: DataTableActionEdit,
1081
+ ActionDelete: DataTableActionDelete,
1082
+ ActionTransport: DataTableActionTransport,
1083
+ ColumnsPanelTrigger,
1084
+ useGridApiRef: useGridApiRef2
1085
+ };
1086
+ var DataTable_default = DataTable;
1087
+ export {
1088
+ DataTable_default as DataTable
1089
+ };
2
1090
  /*! Bundled license information:
3
1091
 
4
1092
  lucide-react/dist/esm/shared/src/utils.js: