import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as i,useEffect as o}from"react";import a from"prop-types";import c from"classnames";import l from"react-draggable";import{makeStyles as d}from"@material-ui/core/styles";import{TableCell as s}from"@material-ui/core";function u(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function p(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var m=d((function(e){return{resizableColumnHeader:{display:"flex",paddingRight:0,justifyContent:"space-between"},tableResizer:{width:6,borderRadius:10,opacity:.7,cursor:"col-resize",marginRight:-11,marginTop:-16,marginBottom:-16},hovered:{backgroundColor:e.palette.primary.main}}})),f=function(e){var r;return null===(r=document.getElementById(e))||void 0===r?void 0:r.offsetWidth};function v(a){var d,u,v=a.children,h=a.cellName,b=a.nextCellName,y=a.widths,g=a.handleWidthsUpdate,O=m(),j=i(!1),w=r(j,2),R=w[0],x=w[1],P=i(),z=r(P,2),C=z[0],N=z[1],q=i(),D=r(q,2),E=D[0],S=D[1];if(o((function(){var r=f("content-".concat(h)),t=f("content-".concat(b));void 0!==r&&N(r+12),void 0!==t&&S(t+12);var n=f(h);void 0!==n&&g(e({},h,n))}),[]),!v)return null;return t(s,p(p({width:y[h],id:h},v.props),{},{children:n("div",{className:O.resizableColumnHeader,children:[t("div",{id:"content-".concat(h),children:null!==(d=null==v||null===(u=v.props)||void 0===u?void 0:u.children)&&void 0!==d?d:null}),t(l,{axis:"x",onDrag:function(r,t){!function(r){var t,n=y[h]+r,i=y[b]-r;n<0||void 0!==C&&n<C||void 0!==E&&i<E||g((e(t={},h,n),e(t,b,i),t))}(t.deltaX)},position:{x:0},zIndex:999,onStart:function(){x(!0)},onStop:function(){var r=f(h);void 0!==r&&y[h]!==r&&g(e({},h,r)),x(!1)},children:t("div",{className:c(O.tableResizer,R&&O.hovered),onMouseEnter:function(){return x(!0)},onMouseLeave:function(){return x(!1)}})})]})}))}var h={children:a.element.isRequired,cellName:a.string.isRequired,nextCellName:a.string.isRequired,widths:a.shape({}).isRequired,handleWidthsUpdate:a.func.isRequired};v.propTypes=h;export{v as default};
//# sourceMappingURL=ResizableTableHeaderCell.js.map
