import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/slicedToArray";import o from"@babel/runtime/helpers/objectWithoutProperties";import{useState as n,useMemo as r}from"react";import i from"prop-types";import{AutoSizer as u}from"react-virtualized";import{makeStyles as s,IconButton as l}from"@material-ui/core";import c from"@material-ui/icons/Settings";import a from"./CustomizeColumnsDialog.js";import m from"./VirtualizedTable.js";import{jsxs as p,Fragment as f,jsx as h}from"react/jsx-runtime";var g=["columns","useColumnSetting","savedColumns","onChangeColumns","customMuiStyles"];function d(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function y(t){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?d(Object(n),!0).forEach((function(o){e(t,o,n[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var C=s({vtTopSetting:{position:"relative",height:"25px"},vtTopSettingIcon:{position:"fixed",right:"20px",padding:"3px",fontSize:"20px"}});function b(e){var i=e.columns,s=e.useColumnSetting,d=e.savedColumns,b=e.onChangeColumns,S=e.customMuiStyles,O=o(e,g),v=C(),w=n(!1),j=t(w,2),P=j[0],T=j[1],x=n(!1),D=t(x,2),k=D[0],z=D[1],I=r((function(){var e=[];return d.forEach((function(t){var o=i.find((function(e){return e.key===t.key}));o&&e.push(y(y({},o),{},{show:t.show}))})),i.forEach((function(t){e.find((function(e){return e.key===t.key}))||e.push(t)})),e}),[i,d]),M=s&&k?25:0;return p(f,{children:[s&&k&&h("div",{className:v.vtTopSetting,children:h(l,{size:"small",className:v.vtTopSettingIcon,onClick:function(){return T(!0)},children:h(c,{fontSize:"inherit"})})}),h(u,{children:function(e){var t=e.width,o=e.height;return h(m,y({width:t,height:o-M,columns:I,useColumnSetting:s,onOpenSettingDlg:function(){return T(!0)},showTopSettingIcon:function(e){return z(e)},customMuiStyles:S},O))}}),h(a,{open:P,columns:I,handleCloseWithCancel:function(){return T(!1)},handleCloseWithOK:function(e){b&&b(e),T(!1)}})]})}b.propTypes={columns:i.arrayOf(i.shape({})),data:i.arrayOf(i.shape({})),useColumnSetting:i.bool,useFixedColumnWidth:i.bool,headerHeight:i.number,rowHeight:i.number,savedColumns:i.arrayOf(i.shape({})),onChangeColumns:i.func,customMuiStyles:i.shape({}),isTopSettingIconShownAlways:i.bool,CustomCellRenderer:i.func,customRowStyle:i.func,sort:i.func,sortBy:i.string,sortDirection:i.string},b.defaultProps={columns:[],data:[],useColumnSetting:!1,useFixedColumnWidth:!1,headerHeight:50,rowHeight:35,savedColumns:[],onChangeColumns:null,customMuiStyles:{},isTopSettingIconShownAlways:!1,CustomCellRenderer:null,customRowStyle:null,sort:null,sortBy:null,sortDirection:null};export{b as default};
