import e from"@babel/runtime/helpers/toConsumableArray";import t from"@babel/runtime/helpers/defineProperty";import{jsx as r,Fragment as n,jsxs as o}from"react/jsx-runtime";import{useMemo as i,useEffect as a}from"react";import l from"classnames";import{Table as c,Column as u,SortDirection as s}from"react-virtualized";import{makeStyles as f,IconButton as d,Typography as m,Tooltip as h}from"@material-ui/core";import{Settings as p,Sort as b,ArrowUpward as y,ArrowDownward as g}from"@material-ui/icons";import{getUnitDisplay as w}from"../../utils/convert.js";function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?S(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var x=f((function(e){return{table:{"& .ReactVirtualized__Table__headerRow":{textTransform:"none",borderBottom:e.isLightTheme?"1px solid rgba(224, 224, 224, 1)":"1px solid rgba(81, 81, 81, 1)"},"& .ReactVirtualized__Table__row":{borderBottom:e.isLightTheme?"1px solid rgba(224, 224, 224, 1)":"1px solid rgba(81, 81, 81, 1)"},"& .ReactVirtualized__Table__Grid":{outline:"none"},"& .ReactVirtualized__Table__headerColumn":{outline:"none"}},oddRow:{backgroundColor:e.isLightTheme?"rgba(189, 189, 189, 0.1)":"#303030"},headerLabel:{lineHeight:"14px",fontSize:"12px",fontStyle:"normal",letterSpacing:"-0.25px",display:"flex",alignItems:"center",flexWrap:"wrap"},cellData:{lineHeight:"14px",fontSize:"12px",fontWeight:"normal",fontStyle:"normal",letterSpacing:"0.15px"},unitLabel:{fontSize:"10px",opacity:.5},settingIcon:{padding:"3px",fontSize:"20px"},sortIcon:{fontSize:"16px"}}}));function O(e,t){var r=e.find((function(e){return e.key===t}))||{},n=r.unitType,o=r.customUnit;return o?"(".concat(o,")"):n?"(".concat(w(n),")"):""}function z(e,t){return(e.find((function(e){return e.key===t}))||{}).headerLabelClassName||""}function _(e,t){return(e.find((function(e){return e.key===t}))||{}).headerLabelUnitClassName||""}var C=function(f){var w=f.columns,S=f.data,C=f.useColumnSetting,j=f.useFixedColumnWidth,k=f.onOpenSettingDlg,N=f.width,D=f.height,R=f.headerHeight,T=f.rowHeight,I=f.showTopSettingIcon,L=f.customMuiStyles,P=f.isTopSettingIconShownAlways,H=f.CustomCellRenderer,B=f.CustomHeaderCellRenderer,K=f.customRowStyle,A=f.sort,E=f.sortBy,V=f.sortDirection,W=f.onScroll,F=void 0===W?function(){}:W,G=x(),M=v(v({},G),L),U=i((function(){return{label:"",key:"setting",width:C?25:0}}),[C]),Z=i((function(){return w.filter((function(e){return e.show}))}),[w]),q=i((function(){return C?[].concat(e(Z),[U]):Z}),[Z,C,U]),J=i((function(){if(N<=0)return{};var e=t({},U.key,U.width),r=[];return Z.filter((function(e){return Number.isFinite(e.width)})).forEach((function(t){e[t.key]=t.width-1,r.push(t.width-1)})),Z.filter((function(e){return!Number.isFinite(e.width)})).forEach((function(t){var n=r.reduce((function(e,t){return e+t}),0),o=Math.floor((N-n-U.width)/(Z.length-r.length)),i=t.minWidth||65,a=o<i?i:o;e[t.key]=a-1,r.push(a-1)})),e}),[N,Z,U]),Q=i((function(){return Object.values(J).reduce((function(e,t){return e+t}),0)}),[J]),X=P||Q-12.5>=N;a((function(){I(X)}),[X]);var Y=function(e){var t=e.label,n=e.dataKey,i=E||V||A;return B?r(B,{columnKey:n,columns:w,sortBy:E,sortDirection:V}):n===U.key?X?null:r(d,{size:"small","aria-label":"customize columns",className:M.settingIcon,onClick:k,children:r(p,{fontSize:"inherit"})}):o(m,{variant:"body2",className:l(M.headerLabel,z(w,n)),children:[t," ",r("span",{className:l(M.unitLabel,_(w,n)),children:O(w,n)}),i&&n!==E&&r(h,{title:"Sort A-Z",children:r(b,{fontSize:"small",className:G.sortIcon})}),i&&n===E&&(V===s.ASC?r(y,{fontSize:"small",className:G.sortIcon}):r(g,{fontSize:"small",className:G.sortIcon}))]})},$=function(e){var t=e.dataKey,n=e.rowData;return H?r(H,{columnKey:t,value:n[t],rowData:n,columns:w}):r(m,{variant:"body2",className:M.cellData,children:n[t]})};return r(n,{children:r(c,{width:j?Q:N,height:D,headerHeight:R,rowClassName:function(e){var r=e.index;return l(t({},M.oddRow,r%2==1))},rowHeight:T,rowCount:S.length,rowGetter:function(e){var t=e.index;return S[t]},rowStyle:K||{},className:M.table,sort:A,sortBy:E,sortDirection:V,onScroll:F,children:q.map((function(e){return r(u,{width:J[e.key]||0,dataKey:e.key,label:e.label,headerRenderer:Y,cellRenderer:$},e.key)}))})})};export{C as VirtualizedTableComponent,C as default};
//# sourceMappingURL=VirtualizedTable.js.map
