2 lines
4.8 KiB
JavaScript
2 lines
4.8 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),r=require("primereact/ripple");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e);function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(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&&a(e,t)}function l(e){return l="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},l(e)}function p(e,t){if(t&&("object"===l(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(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 m,y,h,b=function(n){u(v,e.Component);var a,l,m,y,h,b=(a=v,l=d(),function(){var e,t=f(a);if(l){var r=f(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return p(this,e)});function v(e){var t;return i(this,v),(t=b.call(this,e)).state={currentIndex:-3},t.onListMouseLeave=t.onListMouseLeave.bind(s(t)),t}return m=v,(y=[{key:"onListMouseLeave",value:function(){this.setState({currentIndex:-3})}},{key:"onItemMouseEnter",value:function(e){this.setState({currentIndex:e})}},{key:"onItemClick",value:function(e,t){t.command&&t.command({originalEvent:e,item:t}),e.preventDefault()}},{key:"renderItem",value:function(e,n){var i=this,c=e.disabled,s=e.icon,a=e.label,u=e.template,l=e.url,p=e.target,f=t.classNames("p-dock-item",{"p-dock-item-second-prev":this.state.currentIndex-2===n,"p-dock-item-prev":this.state.currentIndex-1===n,"p-dock-item-current":this.state.currentIndex===n,"p-dock-item-next":this.state.currentIndex+1===n,"p-dock-item-second-next":this.state.currentIndex+2===n}),d=t.classNames("p-dock-action",{"p-disabled":c}),m=t.classNames("p-dock-action-icon",s),y="string"==typeof s?o.default.createElement("span",{className:m}):t.ObjectUtils.getJSXElement(s,this.props),h=o.default.createElement("a",{href:l||"#",role:"menuitem",className:d,target:p,"data-pr-tooltip":a,onClick:function(t){return i.onItemClick(t,e)}},y,o.default.createElement(r.Ripple,null));return u&&(h=t.ObjectUtils.getJSXElement(u,e,{onClick:function(t){return i.onItemClick(t,e)},className:d,iconClassName:m,element:h,props:this.props,index:n})),o.default.createElement("li",{key:n,className:f,role:"none",onMouseEnter:function(){return i.onItemMouseEnter(n)}},h)}},{key:"renderItems",value:function(){var e=this;return this.props.model?this.props.model.map((function(t,r){return e.renderItem(t,r)})):null}},{key:"renderHeader",value:function(){return this.props.header?o.default.createElement("div",{className:"p-dock-header"},t.ObjectUtils.getJSXElement(this.props.header,{props:this.props})):null}},{key:"renderList",value:function(){var e=this,t=this.renderItems();return o.default.createElement("ul",{ref:function(t){return e.list=t},className:"p-dock-list",role:"menu",onMouseLeave:this.onListMouseLeave},t)}},{key:"renderFooter",value:function(){return this.props.footer?o.default.createElement("div",{className:"p-dock-footer"},t.ObjectUtils.getJSXElement(this.props.footer,{props:this.props})):null}},{key:"render",value:function(){var e=t.classNames("p-dock p-component p-dock-".concat(this.props.position),{"p-dock-magnification":this.props.magnification},this.props.className),r=this.renderHeader(),n=this.renderList(),i=this.renderFooter();return o.default.createElement("div",{id:this.props.id,className:e,style:this.props.style},o.default.createElement("div",{className:"p-dock-container"},r,n,i))}}])&&c(m.prototype,y),h&&c(m,h),Object.defineProperty(m,"prototype",{writable:!1}),v}();h={id:null,style:null,className:null,model:null,position:"bottom",magnification:!0,header:null,footer:null},(y="defaultProps")in(m=b)?Object.defineProperty(m,y,{value:h,enumerable:!0,configurable:!0,writable:!0}):m[y]=h,exports.Dock=b;
|