2 lines
9.2 KiB
JavaScript
2 lines
9.2 KiB
JavaScript
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/csstransition");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(e);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e){if(Array.isArray(e))return i(e)}function s(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function o(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e){return l(e)||s(e)||o(e)||u()}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(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 f(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function h(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&&d(e,t)}function v(e){return v="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},v(e)}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){if(t&&("object"===v(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}function N(e){return N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},N(e)}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e){var t=E();return function(){var n,r=N(e);if(t){var a=N(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return b(this,n)}}function E(){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 k=function(r){h(l,e.Component);var i=g(l);function l(e){var t;return p(this,l),(t=i.call(this,e)).state={activeItem:t.findActiveItem()},t}return f(l,[{key:"onItemClick",value:function(e,t){if(t.disabled)e.preventDefault();else{t.url||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t});var n=this.state.activeItem;this.isItemActive(t)?(t.expanded=!1,this.setState({activeItem:this.props.multiple?n.filter((function(e){return e!==t})):null})):(!this.props.multiple&&n&&(n.expanded=!1),t.expanded=!0,this.setState({activeItem:this.props.multiple?[].concat(c(n||[]),[t]):t}))}}},{key:"findActiveItem",value:function(){if(this.props.model){if(this.props.multiple)return this.props.model.filter((function(e){return e.expanded}));var e=null;return this.props.model.forEach((function(t){t.expanded&&(e?t.expanded=!1:e=t)})),e}return null}},{key:"isItemActive",value:function(e){return this.state.activeItem&&(this.props.multiple?this.state.activeItem.indexOf(e)>-1:this.state.activeItem===e)}},{key:"renderSeparator",value:function(e){return a.default.createElement("li",{key:"separator_"+e,className:"p-menu-separator"})}},{key:"re
|