Liferay.Loader.define("@liferay/frontend-data-set-web@1.0.31/views/table/dnd_table/Cell",["module","exports","require","liferay!frontend-js-react-web$classnames","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./TableContext"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=i(n("liferay!frontend-js-react-web$classnames")),o=n("frontend-js-web"),a=(i(n("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=r?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=e[o]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react"))),l=i(n("./TableContext"));function u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}function s({children:e,className:t,columnName:n,expand:u,heading:i,resizable:s}){const d=(0,a.useRef)(),c=(0,a.useRef)({current:null}),{columnDefinitions:f,draggingAllowed:p,draggingColumnName:w,isFixed:b,registerColumn:m,resizeColumn:g,updateDraggingAllowed:y,updateDraggingColumnName:v}=(0,a.useContext)(l.default),j=(0,a.useRef)(new IntersectionObserver((e=>{const t=e[0].boundingClientRect.width;t&&(m(n,t,s),j.current.disconnect())}),{root:null,threshold:1}));(0,a.useLayoutEffect)((()=>{n&&i&&!b&&j.current.observe(d.current)}),[n,b,i]);const h=(0,a.useMemo)((()=>(0,o.throttle)((e=>{if(e.clientX===c.current||!d.current)return;v(n),c.current=e.clientX;const{x:t}=d.current.getClientRects()[0],r=e.clientX-t;g(n,r,s)}),20)),[n,s,g,v]),C=(0,a.useMemo)((()=>{const e=f.get(n);return e&&b&&e.width}),[b,f,n]);return a.default.createElement("div",{className:(0,r.default)(i?"dnd-th":"dnd-td",u&&"expand",t),ref:d,style:{width:C}},e,s&&a.default.createElement("span",{className:(0,r.default)("dnd-th-resizer",{"is-active":n===w,"is-allowed":p}),onMouseDown:function(){window.addEventListener("mousemove",h),window.addEventListener("mouseup",(()=>{y(!0),v(null),window.removeEventListener("mousemove",h)}),{once:!0})}}))}s.defaultProps={expand:!1,heading:!1,resizable:!1};var d=s;t.default=d}}));
//# sourceMappingURL=Cell.js.map