katoikia-app/web-ui/web-react/node_modules/primereact/tabmenu/tabmenu.esm.min.js

2 lines
4.5 KiB
JavaScript

import e,{Component as t}from"react";import{DomHandler as n,classNames as r,ObjectUtils as i}from"primereact/utils";import{Ripple as o}from"primereact/ripple";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(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 c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function u(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 s(e){return s="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},s(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,t){if(t&&("object"===s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function d(){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 b,y,h,v=function(c){u(k,t);var s,p,b,y,h,v=(s=k,p=d(),function(){var e,t=m(s);if(p){var n=m(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return f(this,e)});function k(e){var t;return a(this,k),(t=v.call(this,e)).props.onTabChange||(t.state={activeIndex:e.activeIndex}),t}return b=k,(y=[{key:"itemClick",value:function(e,t,n){t.disabled?e.preventDefault():(t.url||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t}),this.props.onTabChange?this.props.onTabChange({originalEvent:e,value:t,index:n}):this.setState({activeIndex:n}))}},{key:"getActiveIndex",value:function(){return this.props.onTabChange?this.props.activeIndex:this.state.activeIndex}},{key:"isSelected",value:function(e){return e===(this.getActiveIndex()||0)}},{key:"updateInkBar",value:function(){var e=this.getActiveIndex(),t=this["tab_".concat(e)];this.inkbar.style.width=n.getWidth(t)+"px",this.inkbar.style.left=n.getOffset(t).left-n.getOffset(this.nav).left+"px"}},{key:"componentDidMount",value:function(){this.updateInkBar()}},{key:"componentDidUpdate",value:function(){this.updateInkBar()}},{key:"renderMenuItem",value:function(t,n){var a=this,l=this.isSelected(n),c=r("p-tabmenuitem",{"p-highlight":l,"p-disabled":t.disabled},t.className),u=r("p-menuitem-icon",t.icon),s=e.createElement("a",{href:t.url||"#",className:"p-menuitem-link",target:t.target,onClick:function(e){return a.itemClick(e,t,n)},role:"presentation"},t.icon&&e.createElement("span",{className:u}),t.label&&e.createElement("span",{className:"p-menuitem-text"},t.label),e.createElement(o,null));return t.template&&(s=i.getJSXElement(t.template,t,{onClick:function(e){return a.itemClick(e,t)},className:"p-menuitem-link",labelClassName:"p-menuitem-text",iconClassName:u,element:s,props:this.props,active:l,index:n})),e.createElement("li",{ref:function(e){return a["tab_".concat(n)]=e},key:t.label+"_"+n,className:c,style:t.style,role:"tab","aria-selected":l,"aria-expanded":l,"aria-disabled":t.disabled},s)}},{key:"renderItems",value:function(){var e=this;return this.props.model.map((function(t,n){return e.renderMenuItem(t,n)}))}},{key:"render",value:function(){var t=this;if(this.props.model){var n=r("p-tabmenu p-component",this.props.className),i=this.renderItems();return e.createElement("div",{id:this.props.id,className:n,style:this.props.style},e.createElement("ul",{ref:function(e){return t.nav=e},className:"p-tabmenu-nav p-reset",role:"tablist"},i,e.createElement("li",{ref:function(e){return t.inkbar=e},className:"p-tabmenu-ink-bar"})))}return null}}])&&l(b.prototype,y),h&&l(b,h),Object.defineProperty(b,"prototype",{writable:!1}),k}();h={id:null,model:null,activeIndex:0,style:null,className:null,onTabChange:null},(y="defaultProps")in(b=v)?Object.defineProperty(b,y,{value:h,enumerable:!0,configurable:!0,writable:!0}):b[y]=h;export{v as TabMenu};