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