@mhmdaljefri/revogrid
Version:
Virtual reactive data grid component - RevoGrid.
1 lines • 7.9 kB
JavaScript
var t,e=[],n="ResizeObserver loop completed with undelivered notifications.";!function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"}(t||(t={}));var i,r=function(){function t(t,e,n,i){return this.x=t,this.y=e,this.width=n,this.height=i,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,Object.freeze(this)}return t.prototype.toJSON=function(){var t=this;return{x:t.x,y:t.y,top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t}(),o=function(t){return t instanceof SVGElement&&"getBBox"in t},u=function(t){if(o(t)){var e=t.getBBox();return!e.width&&!e.height}return!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},c=function(t){var e,n,i=null===(n=null===(e=t)||void 0===e?void 0:e.ownerDocument)||void 0===n?void 0:n.defaultView;return!!(i&&t instanceof i.Element)},s="undefined"!=typeof window?window:{},a=new WeakMap,f=/auto|scroll/,h=/^tb|vertical/,v=/msie|trident/i.test(s.navigator&&s.navigator.userAgent),d=function(t){return parseFloat(t||"0")},l=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=!1),Object.freeze({inlineSize:(n?e:t)||0,blockSize:(n?t:e)||0})},b=Object.freeze({devicePixelContentBoxSize:l(),borderBoxSize:l(),contentBoxSize:l(),contentRect:new r(0,0,0,0)}),w=function(t,e){if(void 0===e&&(e=!1),a.has(t)&&!e)return a.get(t);if(u(t))return a.set(t,b),b;var n=getComputedStyle(t),i=o(t)&&t.ownerSVGElement&&t.getBBox(),c=!v&&"border-box"===n.boxSizing,s=h.test(n.writingMode||""),w=!i&&f.test(n.overflowY||""),p=!i&&f.test(n.overflowX||""),m=i?0:d(n.paddingTop),x=i?0:d(n.paddingRight),y=i?0:d(n.paddingBottom),z=i?0:d(n.paddingLeft),E=i?0:d(n.borderTopWidth),O=i?0:d(n.borderRightWidth),S=i?0:d(n.borderBottomWidth),R=z+x,g=m+y,B=(i?0:d(n.borderLeftWidth))+O,M=E+S,F=p?t.offsetHeight-M-t.clientHeight:0,T=w?t.offsetWidth-B-t.clientWidth:0,k=c?R+B:0,C=c?g+M:0,D=i?i.width:d(n.width)-k-T,A=i?i.height:d(n.height)-C-F,I=D+R+T+B,P=A+g+F+M,j=Object.freeze({devicePixelContentBoxSize:l(Math.round(D*devicePixelRatio),Math.round(A*devicePixelRatio),s),borderBoxSize:l(I,P,s),contentBoxSize:l(D,A,s),contentRect:new r(z,m,D,A)});return a.set(t,j),j},p=function(e,n,i){var r=w(e,i),o=r.borderBoxSize,u=r.contentBoxSize,c=r.devicePixelContentBoxSize;switch(n){case t.DEVICE_PIXEL_CONTENT_BOX:return c;case t.BORDER_BOX:return o;default:return u}},m=function(t){var e=w(t);this.target=t,this.contentRect=e.contentRect,this.borderBoxSize=[e.borderBoxSize],this.contentBoxSize=[e.contentBoxSize],this.devicePixelContentBoxSize=[e.devicePixelContentBoxSize]},x=function(t){if(u(t))return 1/0;for(var e=0,n=t.parentNode;n;)e+=1,n=n.parentNode;return e},y=function(){var t=1/0,n=[];e.forEach((function(e){if(0!==e.activeTargets.length){var i=[];e.activeTargets.forEach((function(e){var n=new m(e.target),r=x(e.target);i.push(n),e.lastReportedSize=p(e.target,e.observedBox),r<t&&(t=r)})),n.push((function(){e.callback.call(e.observer,i,e.observer)})),e.activeTargets.splice(0,e.activeTargets.length)}}));for(var i=0,r=n;i<r.length;i++)(0,r[i])();return t},z=function(t){e.forEach((function(e){e.activeTargets.splice(0,e.activeTargets.length),e.skippedTargets.splice(0,e.skippedTargets.length),e.observationTargets.forEach((function(n){n.isActive()&&(x(n.target)>t?e.activeTargets.push(n):e.skippedTargets.push(n))}))}))},E=[],O=0,S={attributes:!0,characterData:!0,childList:!0,subtree:!0},R=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],g=function(t){return void 0===t&&(t=0),Date.now()+t},B=!1,M=new(function(){function t(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return t.prototype.run=function(t){var r=this;if(void 0===t&&(t=250),!B){B=!0;var o,u=g(t);o=function(){var i=!1;try{i=function(){var t,i=0;for(z(i);e.some((function(t){return t.activeTargets.length>0}));)i=y(),z(i);return e.some((function(t){return t.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?t=new ErrorEvent("error",{message:n}):((t=document.createEvent("Event")).initEvent("error",!1,!1),t.message=n),window.dispatchEvent(t)),i>0}()}finally{if(B=!1,t=u-g(),!O)return;i?r.run(1e3):t>0?r.run(t):r.start()}},function(t){if(!i){var e=0,n=document.createTextNode("");new MutationObserver((function(){return E.splice(0).forEach((function(t){return t()}))})).observe(n,{characterData:!0}),i=function(){n.textContent=""+(e?e--:e++)}}E.push(t),i()}((function(){requestAnimationFrame(o)}))}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var t=this,e=function(){return t.observer&&t.observer.observe(document.body,S)};document.body?e():s.addEventListener("DOMContentLoaded",e)},t.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),R.forEach((function(e){return s.addEventListener(e,t.listener,!0)})))},t.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),R.forEach((function(e){return s.removeEventListener(e,t.listener,!0)})),this.stopped=!0)},t}()),F=function(t){!O&&t>0&&M.start(),!(O+=t)&&M.stop()},T=function(){function e(e,n){this.target=e,this.observedBox=n||t.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t,e=p(this.target,this.observedBox,!0);return o(t=this.target)||function(t){switch(t.tagName){case"INPUT":if("image"!==t.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(t)||"inline"!==getComputedStyle(t).display||(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},e}(),k=function(t,e){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=e},C=new WeakMap,D=function(t,e){for(var n=0;n<t.length;n+=1)if(t[n].target===e)return n;return-1},A=function(){function t(){}return t.connect=function(t,e){var n=new k(t,e);C.set(t,n)},t.observe=function(t,n,i){var r=C.get(t),o=0===r.observationTargets.length;D(r.observationTargets,n)<0&&(o&&e.push(r),r.observationTargets.push(new T(n,i&&i.box)),F(1),M.schedule())},t.unobserve=function(t,n){var i=C.get(t),r=D(i.observationTargets,n);r>=0&&(1===i.observationTargets.length&&e.splice(e.indexOf(i),1),i.observationTargets.splice(r,1),F(-1))},t.disconnect=function(t){var e=this,n=C.get(t);n.observationTargets.slice().forEach((function(n){return e.unobserve(t,n.target)})),n.activeTargets.splice(0,n.activeTargets.length)},t}(),I=function(){function t(t){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof t)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");A.connect(this,t)}return t.prototype.observe=function(t,e){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!c(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");A.observe(this,t,e)},t.prototype.unobserve=function(t){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!c(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");A.unobserve(this,t)},t.prototype.disconnect=function(){A.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t}();export{I as ResizeObserver,m as ResizeObserverEntry}