2 lines
9.0 KiB
JavaScript
2 lines
9.0 KiB
JavaScript
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/button"),i=require("primereact/ripple"),n=require("primereact/utils");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(e);function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function p(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&&c(e,t)}function u(e){return u="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},u(e)}function f(e,t){if(t&&("object"===u(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 d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function m(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function y(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?m(Object(i),!0).forEach((function(t){h(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):m(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return 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 v=function(r){p(O,e.Component);var c,u,m,v,k,C=(c=O,u=b(),function(){var e,t=d(c);if(u){var i=d(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return f(this,e)});function O(e){var t;return s(this,O),(t=C.call(this,e)).state={visible:!1},t.onClick=t.onClick.bind(a(t)),t.onItemClick=t.onItemClick.bind(a(t)),t}return m=O,v=[{key:"isVisible",value:function(){return this.props.onVisibleChange?this.props.visible:this.state.visible}},{key:"show",value:function(){this.props.onVisibleChange?this.props.onVisibleChange(!0):this.setState({visible:!0}),this.props.onShow&&this.props.onShow()}},{key:"hide",value:function(){this.props.onVisibleChange?this.props.onVisibleChange(!1):this.setState({visible:!1}),this.props.onHide&&this.props.onHide()}},{key:"onClick",value:function(e){this.isVisible()?this.hide():this.show(),this.props.onClick&&this.props.onClick(e),this.isItemClicked=!0}},{key:"onItemClick",value:function(e,t){t.command&&t.command({originalEvent:e,item:t}),this.hide(),this.isItemClicked=!0,e.preventDefault()}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){e.isVisible()&&e.isOutsideClicked(t)&&e.hide(),e.isItemClicked=!1},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&!(this.containe
|