katoikia-app/web-ui/web-react/node_modules/primereact/scrolltop/scrolltop.cjs.min.js

2 lines
5.2 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/csstransition"),r=require("primereact/ripple"),o=require("primereact/api");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=i(e),s=i(o);function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){return p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},p(e,t)}function f(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}function h(e){return h="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},h(e)}function d(e,t){if(t&&("object"===h(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var m,v,E,w=function(o){f(w,e.Component);var i,p,h,m,v,E=(i=w,p=b(),function(){var e,t=y(i);if(p){var n=y(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return d(this,e)});function w(e){var t;return c(this,w),(t=E.call(this,e)).state={visible:!1},t.onClick=t.onClick.bind(a(t)),t.onEnter=t.onEnter.bind(a(t)),t.onEntered=t.onEntered.bind(a(t)),t.onExited=t.onExited.bind(a(t)),t.scrollElementRef=l.default.createRef(),t}return h=w,(m=[{key:"onClick",value:function(){("window"===this.props.target?window:this.helper.parentElement).scroll({top:0,behavior:this.props.behavior})}},{key:"checkVisibility",value:function(e){this.setState({visible:e>this.props.threshold})}},{key:"bindParentScrollListener",value:function(){var e=this;this.scrollListener=function(){e.checkVisibility(e.helper.parentElement.scrollTop)},this.helper.parentElement.addEventListener("scroll",this.scrollListener)}},{key:"bindDocumentScrollListener",value:function(){var e=this;this.scrollListener=function(){e.checkVisibility(t.DomHandler.getWindowScrollTop())},window.addEventListener("scroll",this.scrollListener)}},{key:"unbindParentScrollListener",value:function(){this.scrollListener&&(this.helper.parentElement.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)}},{key:"unbindDocumentScrollListener",value:function(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)}},{key:"onEnter",value:function(){t.ZIndexUtils.set("overlay",this.scrollElementRef.current,s.default.autoZIndex,s.default.zIndex.overlay)}},{key:"onEntered",value:function(){this.props.onShow&&this.props.onShow()}},{key:"onExited",value:function(){t.ZIndexUtils.clear(this.scrollElementRef.current),this.props.onHide&&this.props.onHide()}},{key:"componentDidMount",value:function(){"window"===this.props.target?this.bindDocumentScrollListener():"parent"===this.props.target&&this.bindParentScrollListener()}},{key:"componentWillUnmount",value:function(){"window"===this.props.target?this.unbindDocumentScrollListener():"parent"===this.props.target&&this.unbindParentScrollListener(),t.ZIndexUtils.clear(this.scrollElementRef.current)}},{key:"render",value:function(){var e=this,o=t.classNames("p-scrolltop p-link p-component",{"p-scrolltop-sticky":"window"!==this.props.target},this.props.className),i="parent"===this.props.target;return l.default.createElement(l.default.Fragment,null,l.default.createElement(n.CSSTransition,{nodeRef:this.scrollElementRef,classNames:"p-scrolltop",in:this.state.visible,timeout:{enter:150,exit:150},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onEnter,onEntered:this.onEntered,onExited:this.onExited},l.default.createElement("button",{ref:this.scrollElementRef,type:"button",className:o,style:this.props.style,onClick:this.onClick},t.IconUtils.getJSXIcon(this.props.icon,{className:"p-scrolltop-icon"},{props:this.props}),l.default.createElement(r.Ripple,null))),i&&l.default.createElement("span",{ref:function(t){return e.helper=t},className:"p-scrolltop-helper"}))}}])&&u(h.prototype,m),v&&u(h,v),Object.defineProperty(h,"prototype",{writable:!1}),w}();E={target:"window",threshold:400,icon:"pi pi-chevron-up",behavior:"smooth",className:null,style:null,transitionOptions:null,onShow:null,onHide:null},(v="defaultProps")in(m=w)?Object.defineProperty(m,v,{value:E,enumerable:!0,configurable:!0,writable:!0}):m[v]=E,exports.ScrollTop=w;