storybook-prebuilt
Version:
A prebuilt storybook version for web components
3 lines (2 loc) • 26.1 kB
JavaScript
function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}import{c as t}from"./storybook-prebuilt-3ba63d3f.js";import"./storybook-prebuilt-4dae7756.js";import"./storybook-prebuilt-c9cef5f5.js";import{r as n}from"./storybook-prebuilt-9dd61b75.js";import{b as i}from"./storybook-prebuilt-29c1a26d.js";import{r as o}from"./storybook-prebuilt-685049dd.js";var r=function(t,n,i,o){var r=i?i.call(o,t,n):void 0;if(void 0!==r)return!!r;if(t===n)return!0;if("object"!==e(t)||!t||"object"!==e(n)||!n)return!1;var a=Object.keys(t),l=Object.keys(n);if(a.length!==l.length)return!1;for(var s=Object.prototype.hasOwnProperty.bind(n),c=0;c<a.length;c++){var d=a[c];if(!s(d))return!1;var u=t[d],f=n[d];if(!1===(r=i?i.call(o,u,f,d):void 0)||void 0===r&&u!==f)return!1}return!0};function a(e,t,n,i){var o,r=!1,a=0;function l(){o&&clearTimeout(o)}function s(){var s=this,c=Date.now()-a,d=arguments;function u(){a=Date.now(),n.apply(s,d)}function f(){o=void 0}r||(i&&!o&&u(),l(),void 0===i&&c>e?u():!0!==t&&(o=setTimeout(i?f:u,void 0===i?e-c:e)))}return"boolean"!=typeof t&&(i=n,n=t,t=void 0),s.cancel=function(){l(),r=!0},s}var l=Object.freeze({__proto__:null,throttle:a,debounce:function(e,t,n){return void 0===n?a(e,t,!1):a(e,n,!1!==t)}}),s=t((function(e){(e.exports={}).forEach=function(e,t){for(var n=0;n<e.length;n++){var i=t(e[n]);if(i)return i}}})),c=t((function(e){var t=e.exports={};t.isIE=function(e){return(-1!==(t=navigator.userAgent.toLowerCase()).indexOf("msie")||-1!==t.indexOf("trident")||-1!==t.indexOf(" edge/"))&&(!e||e===function(){var e=3,t=document.createElement("div"),n=t.getElementsByTagName("i");do{t.innerHTML="\x3c!--[if gt IE "+ ++e+"]><i></i><![endif]--\x3e"}while(n[0]);return e>4?e:void 0}());var t},t.isLegacyOpera=function(){return!!window.opera}})),d=t((function(e){(e.exports={}).getOption=function(e,t,n){var i=e[t];if(null==i&&void 0!==n)return n;return i}})),u=function(e){var t=(e=e||{}).reporter,n=d.getOption(e,"async",!0),i=d.getOption(e,"auto",!0);i&&!n&&(t&&t.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),n=!0);var o,r=f(),a=!1;function l(){for(a=!0;r.size();){var e=r;r=f(),e.process()}a=!1}function s(){var e;e=l,o=setTimeout(e,0)}return{add:function(e,t){!a&&i&&n&&0===r.size()&&s(),r.add(e,t)},force:function(e){a||(void 0===e&&(e=n),o&&(clearTimeout(o),o=null),e?s():l())}}};function f(){var e={},t=0,n=0,i=0;return{add:function(o,r){r||(r=o,o=0),o>n?n=o:o<i&&(i=o),e[o]||(e[o]=[]),e[o].push(r),t++},process:function(){for(var t=i;t<=n;t++)for(var o=e[t],r=0;r<o.length;r++){(0,o[r])()}},size:function(){return t}}}function h(e){return e._erd}var p={initState:function(e){return e._erd={},h(e)},getState:h,cleanState:function(e){delete e._erd}},m=s.forEach,v=function(e){var t=(e=e||{}).reporter,n=e.batchProcessor,i=e.stateHandler.getState,o=(e.stateHandler.hasState,e.idHandler);if(!n)throw new Error("Missing required dependency: batchProcessor");if(!t)throw new Error("Missing required dependency: reporter.");var r=function(){var e=document.createElement("div");e.style.cssText=l(["position: absolute","width: 1000px","height: 1000px","visibility: hidden","margin: 0","padding: 0"]);var t=document.createElement("div");t.style.cssText=l(["position: absolute","width: 500px","height: 500px","overflow: scroll","visibility: none","top: -1500px","left: -1500px","visibility: hidden","margin: 0","padding: 0"]),t.appendChild(e),document.body.insertBefore(t,document.body.firstChild);var n=500-t.clientWidth,i=500-t.clientHeight;return document.body.removeChild(t),{width:n,height:i}}();function a(e){!function(e,t,n){if(!e.getElementById(t)){var i=n+"_animation",o=n+"_animation_active",r="/* Created by the element-resize-detector library. */\n";r+="."+n+" > div::-webkit-scrollbar { "+l(["display: none"])+" }\n\n",r+="."+o+" { "+l(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+i,"animation-name: "+i])+" }\n",r+="@-webkit-keyframes "+i+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }\n",function(n,i){i=i||function(t){e.head.appendChild(t)};var o=e.createElement("style");o.innerHTML=n,o.id=t,i(o)}(r+="@keyframes "+i+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }")}}(e,"erd_scroll_detection_scrollbar_style","erd_scroll_detection_container")}function l(t){var n=e.important?" !important; ":"; ";return(t.join(n)+n).trim()}function s(e,n,i){if(e.addEventListener)e.addEventListener(n,i);else{if(!e.attachEvent)return t.error("[scroll] Don't know how to add event listeners.");e.attachEvent("on"+n,i)}}function c(e,n,i){if(e.removeEventListener)e.removeEventListener(n,i);else{if(!e.detachEvent)return t.error("[scroll] Don't know how to remove event listeners.");e.detachEvent("on"+n,i)}}function d(e){return i(e).container.childNodes[0].childNodes[0].childNodes[0]}function u(e){return i(e).container.childNodes[0].childNodes[0].childNodes[1]}return a(window.document),{makeDetectable:function(e,a,c){function f(){if(e.debug){var n=Array.prototype.slice.call(arguments);if(n.unshift(o.get(a),"Scroll: "),t.log.apply)t.log.apply(null,n);else for(var i=0;i<n.length;i++)t.log(n[i])}}function h(e){var t=i(e).container.childNodes[0],n=window.getComputedStyle(t);return!n.width||-1===n.width.indexOf("px")}function p(){var e=window.getComputedStyle(a),t={};return t.position=e.position,t.width=a.offsetWidth,t.height=a.offsetHeight,t.top=e.top,t.right=e.right,t.bottom=e.bottom,t.left=e.left,t.widthCSS=e.width,t.heightCSS=e.height,t}function v(){if(f("storeStyle invoked."),i(a)){var e=p();i(a).style=e}else f("Aborting because element has been uninstalled")}function g(e,t,n){i(e).lastWidth=t,i(e).lastHeight=n}function b(){return 2*r.width+1}function y(){return 2*r.height+1}function w(e){return e+10+b()}function S(e){return e+10+y()}function E(e,t,n){var i=d(e),o=u(e),r=w(t),a=S(n),l=function(e){return 2*e+b()}(t),s=function(e){return 2*e+y()}(n);i.scrollLeft=r,i.scrollTop=a,o.scrollLeft=l,o.scrollTop=s}function k(){var e=i(a).container;if(!e){(e=document.createElement("div")).className="erd_scroll_detection_container",e.style.cssText=l(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),i(a).container=e,function(e){e.className+=" erd_scroll_detection_container_animation_active"}(e),a.appendChild(e);var t=function(){i(a).onRendered&&i(a).onRendered()};s(e,"animationstart",t),i(a).onAnimationStart=t}return e}function O(){if(f("Injecting elements"),i(a)){!function(){var n=i(a).style;if("static"===n.position){a.style.setProperty("position","relative",e.important?"important":"");var o=function(e,t,n,i){var o=n[i];"auto"!==o&&"0"!==function(e){return e.replace(/[^-\d\.]/g,"")}(o)&&(e.warn("An element that is positioned static has style."+i+"="+o+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+i+" will be set to 0. Element: ",t),t.style[i]=0)};o(t,a,n,"top"),o(t,a,n,"right"),o(t,a,n,"bottom"),o(t,a,n,"left")}}();var n=i(a).container;n||(n=k());var o,c,d,u,h=r.width,p=r.height,m=l(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),v=l(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(["left: "+(o=(o=-(1+h))?o+"px":"0"),"top: "+(c=(c=-(1+p))?c+"px":"0"),"right: "+(u=(u=-h)?u+"px":"0"),"bottom: "+(d=(d=-p)?d+"px":"0")])),g=l(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),b=l(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),y=l(["position: absolute","left: 0","top: 0"]),w=l(["position: absolute","width: 200%","height: 200%"]),S=document.createElement("div"),E=document.createElement("div"),O=document.createElement("div"),z=document.createElement("div"),x=document.createElement("div"),j=document.createElement("div");S.dir="ltr",S.style.cssText=m,S.className="erd_scroll_detection_container",E.className="erd_scroll_detection_container",E.style.cssText=v,O.style.cssText=g,z.style.cssText=y,x.style.cssText=b,j.style.cssText=w,O.appendChild(z),x.appendChild(j),E.appendChild(O),E.appendChild(x),S.appendChild(E),n.appendChild(S),s(O,"scroll",D),s(x,"scroll",C),i(a).onExpandScroll=D,i(a).onShrinkScroll=C}else f("Aborting because element has been uninstalled");function D(){i(a).onExpand&&i(a).onExpand()}function C(){i(a).onShrink&&i(a).onShrink()}}function z(){function r(t,n,i){var o=function(e){return d(e).childNodes[0]}(t),r=w(n),a=S(i);o.style.setProperty("width",r+"px",e.important?"important":""),o.style.setProperty("height",a+"px",e.important?"important":"")}function l(l){var c=a.offsetWidth,d=a.offsetHeight,u=c!==i(a).lastWidth||d!==i(a).lastHeight;f("Storing current size",c,d),g(a,c,d),n.add(0,(function(){if(u)if(i(a))if(s()){if(e.debug){var n=a.offsetWidth,l=a.offsetHeight;n===c&&l===d||t.warn(o.get(a),"Scroll: Size changed before updating detector elements.")}r(a,c,d)}else f("Aborting because element container has not been initialized");else f("Aborting because element has been uninstalled")})),n.add(1,(function(){i(a)?s()?E(a,c,d):f("Aborting because element container has not been initialized"):f("Aborting because element has been uninstalled")})),u&&l&&n.add(2,(function(){i(a)?s()?l():f("Aborting because element container has not been initialized"):f("Aborting because element has been uninstalled")}))}function s(){return!!i(a).container}function c(){f("notifyListenersIfNeeded invoked");var e=i(a);return void 0===i(a).lastNotifiedWidth&&e.lastWidth===e.startSize.width&&e.lastHeight===e.startSize.height?f("Not notifying: Size is the same as the start size, and there has been no notification yet."):e.lastWidth===e.lastNotifiedWidth&&e.lastHeight===e.lastNotifiedHeight?f("Not notifying: Size already notified"):(f("Current size not notified, notifying..."),e.lastNotifiedWidth=e.lastWidth,e.lastNotifiedHeight=e.lastHeight,void m(i(a).listeners,(function(e){e(a)})))}function p(){f("Scroll detected."),h(a)?f("Scroll event fired while unrendered. Ignoring..."):l(c)}if(f("registerListenersAndPositionElements invoked."),i(a)){i(a).onRendered=function(){if(f("startanimation triggered."),h(a))f("Ignoring since element is still unrendered...");else{f("Element rendered.");var e=d(a),t=u(a);0!==e.scrollLeft&&0!==e.scrollTop&&0!==t.scrollLeft&&0!==t.scrollTop||(f("Scrollbars out of sync. Updating detector elements..."),l(c))}},i(a).onExpand=p,i(a).onShrink=p;var v=i(a).style;r(a,v.width,v.height)}else f("Aborting because element has been uninstalled")}function x(){if(f("finalizeDomMutation invoked."),i(a)){var e=i(a).style;g(a,e.width,e.height),E(a,e.width,e.height)}else f("Aborting because element has been uninstalled")}function j(){c(a)}function D(){var e;f("Installing..."),i(a).listeners=[],e=p(),i(a).startSize={width:e.width,height:e.height},f("Element start size",i(a).startSize),n.add(0,v),n.add(1,O),n.add(2,z),n.add(3,x),n.add(4,j)}c||(c=a,a=e,e=null),e=e||{},f("Making detectable..."),!function(e){return!function(e){return e===e.ownerDocument.body||e.ownerDocument.body.contains(e)}(e)||null===window.getComputedStyle(e)}(a)?D():(f("Element is detached"),k(),f("Waiting until element is attached..."),i(a).onRendered=function(){f("Element is now attached"),D()})},addListener:function(e,t){if(!i(e).listeners.push)throw new Error("Cannot add listener to an element that is not detectable.");i(e).listeners.push(t)},uninstall:function(e){var t=i(e);t&&(t.onExpandScroll&&c(d(e),"scroll",t.onExpandScroll),t.onShrinkScroll&&c(u(e),"scroll",t.onShrinkScroll),t.onAnimationStart&&c(t.container,"animationstart",t.onAnimationStart),t.container&&e.removeChild(t.container))},initDocument:a}},g=s.forEach;function b(e){return Array.isArray(e)||void 0!==e.length}function y(e){if(Array.isArray(e))return e;var t=[];return g(e,(function(e){t.push(e)})),t}function w(e){return e&&1===e.nodeType}function S(e,t,n){var i=e[t];return null==i&&void 0!==n?n:i}function E(t){return t&&"object"===e(t)&&"default"in t?t.default:t}var k=E(n),O=E(o),z=E(i),x=E((function(e){var t,n;if((e=e||{}).idHandler)t={get:function(t){return e.idHandler.get(t,!0)},set:e.idHandler.set};else{var i=function(e){var t=e.idGenerator,n=e.stateHandler.getState;return{get:function(e){var t=n(e);return t&&void 0!==t.id?t.id:null},set:function(e){var i=n(e);if(!i)throw new Error("setId required the element to have a resize detection state.");var o=t.generate();return i.id=o,o}}}({idGenerator:(n=1,{generate:function(){return n++}}),stateHandler:p});t=i}var o=e.reporter;o||(o=function(e){function t(){}var n={log:t,warn:t,error:t};if(!e&&window.console){var i=function(e,t){e[t]=function(){var e=console[t];if(e.apply)e.apply(console,arguments);else for(var n=0;n<arguments.length;n++)e(arguments[n])}};i(n,"log"),i(n,"warn"),i(n,"error")}return n}(!1===o));var r=S(e,"batchProcessor",u({reporter:o})),a={};a.callOnAdd=!!S(e,"callOnAdd",!0),a.debug=!!S(e,"debug",!1);var l,s=function(e){var t={};function n(n){var i=e.get(n);return void 0===i?[]:t[i]||[]}return{get:n,add:function(n,i){var o=e.get(n);t[o]||(t[o]=[]),t[o].push(i)},removeListener:function(e,t){for(var i=n(e),o=0,r=i.length;o<r;++o)if(i[o]===t){i.splice(o,1);break}},removeAllListeners:function(e){var t=n(e);t&&(t.length=0)}}}(t),d=function(e){var t=e.stateHandler.getState;return{isDetectable:function(e){var n=t(e);return n&&!!n.isDetectable},markAsDetectable:function(e){t(e).isDetectable=!0},isBusy:function(e){return!!t(e).busy},markBusy:function(e,n){t(e).busy=!!n}}}({stateHandler:p}),f=S(e,"strategy","object"),h=S(e,"important",!1),m={reporter:o,batchProcessor:r,stateHandler:p,idHandler:t,important:h};if("scroll"===f&&(c.isLegacyOpera()?(o.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),f="object"):c.isIE(9)&&(o.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),f="object")),"scroll"===f)l=v(m);else{if("object"!==f)throw new Error("Invalid strategy name: "+f);l=function(e){var t=(e=e||{}).reporter,n=e.batchProcessor,i=e.stateHandler.getState;if(!t)throw new Error("Missing required dependency: reporter.");function o(t){var n=e.important?" !important; ":"; ";return(t.join(n)+n).trim()}function r(e){return i(e).object}return{makeDetectable:function(e,r,a){a||(a=r,r=e,e=null),(e=e||{}).debug,c.isIE(8)?a(r):function(r,a){var l=o(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),s=!1,d=window.getComputedStyle(r),u=r.offsetWidth,f=r.offsetHeight;function h(){function n(){if("static"===d.position){r.style.setProperty("position","relative",e.important?"important":"");var n=function(t,n,i,o){var r=i[o];"auto"!==r&&"0"!==function(e){return e.replace(/[^-\d\.]/g,"")}(r)&&(t.warn("An element that is positioned static has style."+o+"="+r+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+o+" will be set to 0. Element: ",n),n.style.setProperty(o,"0",e.important?"important":""))};n(t,r,d,"top"),n(t,r,d,"right"),n(t,r,d,"bottom"),n(t,r,d,"left")}}""!==d.position&&(n(),s=!0);var o=document.createElement("object");o.style.cssText=l,o.tabIndex=-1,o.type="text/html",o.setAttribute("aria-hidden","true"),o.onload=function(){s||n(),function e(t,n){if(!t.contentDocument){var o=i(t);return o.checkForObjectDocumentTimeoutId&&window.clearTimeout(o.checkForObjectDocumentTimeoutId),void(o.checkForObjectDocumentTimeoutId=setTimeout((function(){o.checkForObjectDocumentTimeoutId=0,e(t,n)}),100))}n(t.contentDocument)}(this,(function(e){a(r)}))},c.isIE()||(o.data="about:blank"),i(r)&&(r.appendChild(o),i(r).object=o,c.isIE()&&(o.data="about:blank"))}i(r).startSize={width:u,height:f},n?n.add(h):h()}(r,a)},addListener:function(e,t){function n(){t(e)}if(c.isIE(8))i(e).object={proxy:n},e.attachEvent("onresize",n);else{var o=r(e);if(!o)throw new Error("Element is not detectable by this strategy.");o.contentDocument.defaultView.addEventListener("resize",n)}},uninstall:function(e){if(i(e)){var t=r(e);t&&(c.isIE(8)?e.detachEvent("onresize",t.proxy):e.removeChild(t),i(e).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(e).checkForObjectDocumentTimeoutId),delete i(e).object)}}}}(m)}var E={};return{listenTo:function(e,n,i){function r(e){var t=s.get(e);g(t,(function(t){t(e)}))}function c(e,t,n){s.add(t,n),e&&n(t)}if(i||(i=n,n=e,e={}),!n)throw new Error("At least one element required.");if(!i)throw new Error("Listener required.");if(w(n))n=[n];else{if(!b(n))return o.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");n=y(n)}var u=0,f=S(e,"callOnAdd",a.callOnAdd),m=S(e,"onReady",(function(){})),v=S(e,"debug",a.debug);g(n,(function(e){p.getState(e)||(p.initState(e),t.set(e));var a=t.get(e);if(v&&o.log("Attaching listener to element",a,e),!d.isDetectable(e))return v&&o.log(a,"Not detectable."),d.isBusy(e)?(v&&o.log(a,"System busy making it detectable"),c(f,e,i),E[a]=E[a]||[],void E[a].push((function(){++u===n.length&&m()}))):(v&&o.log(a,"Making detectable..."),d.markBusy(e,!0),l.makeDetectable({debug:v,important:h},e,(function(e){if(v&&o.log(a,"onElementDetectable"),p.getState(e)){d.markAsDetectable(e),d.markBusy(e,!1),l.addListener(e,r),c(f,e,i);var t=p.getState(e);if(t&&t.startSize){var s=e.offsetWidth,h=e.offsetHeight;t.startSize.width===s&&t.startSize.height===h||r(e)}E[a]&&g(E[a],(function(e){e()}))}else v&&o.log(a,"Element uninstalled before being detectable.");delete E[a],++u===n.length&&m()})));v&&o.log(a,"Already detecable, adding listener."),c(f,e,i),u++})),u===n.length&&m()},removeListener:s.removeListener,removeAllListeners:s.removeAllListeners,uninstall:function(e){if(!e)return o.error("At least one element is required.");if(w(e))e=[e];else{if(!b(e))return o.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");e=y(e)}g(e,(function(e){s.removeAllListeners(e),l.uninstall(e),p.cleanState(e)}))},initDocument:function(e){l.initDocument&&l.initDocument(e)}}})),j=E(r);function D(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function P(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),e}function A(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(){return(_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function N(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?N(Object(n),!0).forEach((function(t){A(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&M(e,t)}function H(e){return(H=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function M(e,t){return(M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function L(e,t){if(null==e)return{};var n,i,o=function(e,t){if(null==e)return{};var n,i,o={},r=Object.keys(e);for(i=0;i<r.length;i++)n=r[i],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)n=r[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function W(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(t,n){return!n||"object"!==e(n)&&"function"!=typeof n?W(t):n}var B={};function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"scroll";return B[e]||(B[e]=x({strategy:e})),B[e]}var F="react-sizeme: an error occurred whilst stopping to listen to node size changes",G={monitorWidth:!0,monitorHeight:!1,monitorPosition:!1,refreshRate:16,refreshMode:"throttle",noPlaceholder:!1,resizeDetectorStrategy:"scroll"};function U(e){return e.displayName||e.name||"Component"}var V=function(e){function t(){return D(this,t),R(this,H(t).apply(this,arguments))}return I(t,n.Component),P(t,[{key:"render",value:function(){return n.Children.only(this.props.children)}}]),t}();function Y(e){var t=e.className,n=e.style,i={};return t||n?(t&&(i.className=t),n&&(i.style=n)):i.style={width:"100%",height:"100%"},k.createElement("div",i)}A(V,"displayName","SizeMeReferenceWrapper"),Y.displayName="SizeMePlaceholder";var J=function(e){function t(t){var n=t.explicitRef,i=t.className,o=t.style,r=t.size,a=t.disablePlaceholder,l=(t.onSize,L(t,["explicitRef","className","style","size","disablePlaceholder","onSize"])),s=(null==r||null==r.width&&null==r.height&&null==r.position)&&!a,c={className:i,style:o};null!=r&&(c.size=r);var d=s?k.createElement(Y,{className:i,style:o}):k.createElement(e,_({},c,l));return k.createElement(V,{ref:n},d)}return t.displayName="SizeMeRenderer(".concat(U(e),")"),t};function K(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:G,t=e.monitorWidth,n=void 0===t?G.monitorWidth:t,i=e.monitorHeight,o=void 0===i?G.monitorHeight:i,r=e.monitorPosition,a=void 0===r?G.monitorPosition:r,s=e.refreshRate,c=void 0===s?G.refreshRate:s,d=e.refreshMode,u=void 0===d?G.refreshMode:d,f=e.noPlaceholder,h=void 0===f?G.noPlaceholder:f,p=e.resizeDetectorStrategy,m=void 0===p?G.resizeDetectorStrategy:p;z(n||o||a,'You have to monitor at least one of the width, height, or position when using "sizeMe"'),z(c>=16,"It is highly recommended that you don't put your refreshRate lower than 16 as this may cause layout thrashing."),z("throttle"===u||"debounce"===u,'The refreshMode should have a value of "throttle" or "debounce"');var v="throttle"===u?l.throttle:l.debounce;return function(e){var t=J(e),i=function(e){function i(){var e,t;D(this,i);for(var r=arguments.length,l=new Array(r),s=0;s<r;s++)l[s]=arguments[s];return A(W(t=R(this,(e=H(i)).call.apply(e,[this].concat(l)))),"domEl",null),A(W(t),"state",{width:void 0,height:void 0,position:void 0}),A(W(t),"uninstall",(function(){if(t.domEl){try{t.detector.uninstall(t.domEl)}catch(e){console.warn(F)}t.domEl=null}})),A(W(t),"determineStrategy",(function(e){e.onSize?(t.callbackState||(t.callbackState=T({},t.state)),t.strategy="callback"):t.strategy="render"})),A(W(t),"strategisedSetState",(function(e){"callback"===t.strategy&&(t.callbackState=e,t.props.onSize(e)),t.setState(e)})),A(W(t),"strategisedGetState",(function(){return"callback"===t.strategy?t.callbackState:t.state})),A(W(t),"refCallback",(function(e){t.element=e})),A(W(t),"hasSizeChanged",(function(e,t){var i=e,r=t,l=i.position||{},s=r.position||{};return n&&i.width!==r.width||o&&i.height!==r.height||a&&(l.top!==s.top||l.left!==s.left||l.bottom!==s.bottom||l.right!==s.right)})),A(W(t),"checkIfSizeChanged",v(c,(function(e){var i=e.getBoundingClientRect(),r=i.width,l=i.height,s=i.right,c=i.left,d=i.top,u=i.bottom,f={width:n?r:null,height:o?l:null,position:a?{right:s,left:c,top:d,bottom:u}:null};t.hasSizeChanged(t.strategisedGetState(),f)&&t.strategisedSetState(f)}))),t}return I(i,k.Component),P(i,[{key:"componentDidMount",value:function(){this.detector=q(m),this.determineStrategy(this.props),this.handleDOMNode()}},{key:"componentDidUpdate",value:function(){this.determineStrategy(this.props),this.handleDOMNode()}},{key:"componentWillUnmount",value:function(){this.hasSizeChanged=function(){},this.checkIfSizeChanged=function(){},this.uninstall()}},{key:"handleDOMNode",value:function(){var e=this.element&&O.findDOMNode(this.element);e?this.domEl?(this.domEl.isSameNode&&!this.domEl.isSameNode(e)||this.domEl!==e)&&(this.uninstall(),this.domEl=e,this.detector.listenTo(this.domEl,this.checkIfSizeChanged)):(this.domEl=e,this.detector.listenTo(this.domEl,this.checkIfSizeChanged)):this.uninstall()}},{key:"render",value:function(){var e=K.enableSSRBehaviour||K.noPlaceholders||h||"callback"===this.strategy,n=T({},this.state);return k.createElement(t,_({explicitRef:this.refCallback,size:"callback"===this.strategy?null:n,disablePlaceholder:e},this.props))}}]),i}();return A(i,"displayName","SizeMe(".concat(U(e),")")),i.WrappedComponent=e,i}}K.enableSSRBehaviour=!1,K.noPlaceholders=!1;var Q=function(e){function t(e){var n;D(this,t),A(W(n=R(this,H(t).call(this,e))),"createComponent",(function(e){n.SizeAware=K(e)((function(e){return e.children}))})),A(W(n),"onSize",(function(e){return n.setState({size:e})}));e.children,e.render;var i=L(e,["children","render"]);return n.createComponent(i),n.state={size:{width:void 0,height:void 0}},n}return I(t,n.Component),P(t,[{key:"componentDidUpdate",value:function(e){var t=this.props,n=(t.children,t.render,L(t,["children","render"])),i=(e.children,e.render,L(e,["children","render"]));j(n,i)||this.createComponent(n)}},{key:"render",value:function(){var e=this.SizeAware,t=this.props.children||this.props.render;return k.createElement(e,{onSize:this.onSize},t({size:this.state.size}))}}]),t}();A(Q,"defaultProps",{children:void 0,render:void 0}),K.SizeMe=Q,K.withSize=K;var X=K;export{X as _,r as i};
//# sourceMappingURL=storybook-prebuilt-31092c1e.js.map