Liferay.Loader.define("data-engine-js-components-web@1.0.86/js/core/components/ResizableColumn.es",["module","exports","require","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../actions/eventTypes.es","../hooks/useForm.es","./Field/ParentFieldContext.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r("@liferay/frontend-js-react-web"),o=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(r("liferay!frontend-js-react-web$classnames")),a=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=n?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),i=r("../actions/eventTypes.es"),c=r("../hooks/useForm.es"),l=r("./Field/ParentFieldContext.es");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(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 _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e={LEFT:"left",RIGHT:"right"},d=12,ResizableColumn=({children:t,currentLoc:r,disabled:u,instanceId:s,onResizing:f,resizeInfoRef:p,rowRef:b})=>{const{loc:y=[]}=(0,a.useContext)(l.ParentFieldContext),m=(0,c.useForm)(),handleMouseDown=(e,t)=>{e.preventDefault(),e.stopPropagation(),p.current=_objectSpread(_objectSpread({},p.current),{},{direction:t,instanceId:s}),f(!0)},j=(0,a.useCallback)((e=>{if(p.current&&p.current.instanceId===s){var t,n;let o=Math.floor((e.clientX-(null===(t=b.current)||void 0===t?void 0:t.getBoundingClientRect().left))*(10*d)/(null===(n=b.current)||void 0===n?void 0:n.clientWidth)/10);o>d-1&&(o=d-1),o>=0&&o!==p.current.lastColumnValue&&(p.current=_objectSpread(_objectSpread({},p.current),{},{lastColumnValue:o}),m({payload:{column:o,direction:p.current.direction,loc:[...y,r]},type:i.EVENT_TYPES.DND.RESIZE}))}}),[r,m,s,y,p,b]),v=(0,a.useCallback)((()=>{f(!1),p.current=null}),[f,p]);return(0,n.useEventListener)("mousemove",j,!1,document.body),(0,n.useEventListener)("mouseup",v,{passive:!0},document.body),a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{className:(0,o.default)("ddm-resize-handle ddm-resize-handle-left",{hide:u}),onMouseDown:t=>handleMouseDown(t,e.LEFT)}),t,a.default.createElement("div",{className:(0,o.default)("ddm-resize-handle ddm-resize-handle-right",{hide:u}),onMouseDown:t=>handleMouseDown(t,e.RIGHT)}))};ResizableColumn.displayName="ResizableColumn";var u=ResizableColumn;t.default=u}}));
//# sourceMappingURL=ResizableColumn.es.js.map