import{taggedTemplateLiteral as e,slicedToArray as o,objectSpread2 as t,asyncToGenerator as n,regenerator as r}from"../../_virtual/_rollupPluginBabelHelpers.esm.js";import{useState as a,useEffect as i}from"react";import l from"styled-components";import{DataGrid as s,GridToolbar as c}from"@mui/x-data-grid";import{jsx as u}from"react/jsx-runtime";var d,p;function f(e){var l=a(),d=o(l,2),p=d[0],f=d[1],h=a(),g=o(h,2),v=g[0],b=g[1];function x(){return(x=n(r().m(function o(t,n){var a;return r().w(function(o){for(;;)switch(o.n){case 0:if(!e.handleRowChange){o.n=2;break}if(a={},Object.keys(t).forEach(function(e){t[e]!==n[e]&&(a[e]={old:n[e],new:t[e]})}),!(Object.keys(a).length>0)){o.n=1;break}return o.n=1,e.handleRowChange(t,n);case 1:return o.a(2,t);case 2:return o.a(2,n);case 3:return o.a(2)}},o)}))).apply(this,arguments)}return i(function(){if(e.columns&&e.rows){var o=[];e.columns.forEach(function(n){var r=0;e.rows.forEach(function(e){var o,t,a=2*function(e,o,t){var n=document.createElement("canvas").getContext("2d");n.font="".concat(o," ").concat(t);var r=n.measureText(e).width;return Math.round(r)}((o=e[n.field],t=0,null!=o?o:t));a>r&&(r=a)}),o.push(t(t({},n),{},{width:r+10,editable:n.editable}))}),f(o),b(e.rows||[])}else f(e.columns||[]),b(e.rows||[])},[e]),u(m,{children:u(w,{children:u(s,{components:{Toolbar:c},slots:{toolbar:c},slotProps:{toolbar:{csvOptions:{fileName:e.fileName||"Export File"}}},getRowClassName:function(o){return e.rowClassName?e.rowClassName(o.row):""},sx:t({},e.style),disableSelectionOnClick:!0,checkboxSelection:!0,columns:p||[],rows:v||[],showCellVerticalBorder:!0,getRowId:function(o){return o[e.rowId]},onRowDoubleClick:function(o,t){var n=o.row;e.setSelectedRow&&e.setSelectedRow(n||null)},initialState:{pagination:{paginationModel:{pageSize:e.pageSize||5,page:0}}},pageSizeOptions:e.pageSizeOptions||[5,10,25,50,100],editMode:"row",processRowUpdate:function(e,o){return x.apply(this,arguments)}})})})}var m=l.div(d||(d=e(["\n  display: flex;\n  flex-direction: column;\n  gap: 10px;\n"]))),w=l.div(p||(p=e(["\n  width: 100%;\n"])));export{f as default};
//# sourceMappingURL=DataGridComponent.esm.js.map
