UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 6.76 kB
import e from"primevue/ripple";import t from"primevue/tooltip";import{resolveComponent as n,resolveDirective as i,openBlock as o,createElementBlock as l,createElementVNode as r,Fragment as s,renderList as c,normalizeClass as a,createBlock as d,withCtx as p,withDirectives as m,resolveDynamicComponent as k,normalizeStyle as u,createVNode as f}from"vue";var b={name:"DockSub",props:{model:{type:Array,default:null},templates:{type:null,default:null},exact:{type:Boolean,default:!0},tooltipOptions:null},data:()=>({currentIndex:-3}),methods:{onListMouseLeave(){this.currentIndex=-3},onItemMouseEnter(e){this.currentIndex=e},onItemClick(e,t,n){this.disabled(t)?e.preventDefault():(t.command&&t.command({originalEvent:e,item:t}),t.to&&n&&n(e))},itemClass(e){return["p-dock-item",{"p-dock-item-second-prev":this.currentIndex-2===e,"p-dock-item-prev":this.currentIndex-1===e,"p-dock-item-current":this.currentIndex===e,"p-dock-item-next":this.currentIndex+1===e,"p-dock-item-second-next":this.currentIndex+2===e}]},linkClass(e,t){return["p-dock-action",{"p-disabled":this.disabled(e),"router-link-active":t&&t.isActive,"router-link-active-exact":this.exact&&t&&t.isExactActive}]},disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled},directives:{ripple:e,tooltip:t}};const x={class:"p-dock-list-container"},h=["onMouseenter"],y=["href","target","onClick"],g=["href","target","onClick","tabindex"];b.render=function(e,t,u,f,b,v){const w=n("router-link"),C=i("ripple"),I=i("tooltip");return o(),l("div",x,[r("ul",{ref:"list",class:"p-dock-list",role:"menu",onMouseleave:t[0]||(t[0]=(...e)=>v.onListMouseLeave&&v.onListMouseLeave(...e))},[(o(!0),l(s,null,c(u.model,((e,t)=>(o(),l("li",{class:a(v.itemClass(t)),key:t,role:"none",onMouseenter:e=>v.onItemMouseEnter(t)},[u.templates.item?(o(),d(k(u.templates.item),{key:1,item:e},null,8,["item"])):(o(),l(s,{key:0},[e.to&&!v.disabled(e)?(o(),d(w,{key:0,to:e.to,custom:""},{default:p((({navigate:t,href:n,isActive:i,isExactActive:r})=>[m((o(),l("a",{href:n,role:"menuitem",class:a(v.linkClass(e,{isActive:i,isExactActive:r})),target:e.target,onClick:n=>v.onItemClick(n,e,t)},[u.templates.icon?(o(),d(k(u.templates.icon),{key:1,item:e},null,8,["item"])):m((o(),l("span",{key:0,class:a(["p-dock-action-icon",e.icon])},null,2)),[[C]])],10,y)),[[I,{value:e.label,disabled:!u.tooltipOptions},u.tooltipOptions]])])),_:2},1032,["to"])):m((o(),l("a",{key:1,href:e.url,role:"menuitem",class:a(v.linkClass(e)),target:e.target,onClick:t=>v.onItemClick(t,e),tabindex:v.disabled(e)?null:"0"},[u.templates.icon?(o(),d(k(u.templates.icon),{key:1,item:e},null,8,["item"])):m((o(),l("span",{key:0,class:a(["p-dock-action-icon",e.icon])},null,2)),[[C]])],10,g)),[[I,{value:e.label,disabled:!u.tooltipOptions},u.tooltipOptions]])],64))],42,h)))),128))],544)])};var v={name:"Dock",props:{position:{type:String,default:"bottom"},model:null,class:null,style:null,tooltipOptions:null,exact:{type:Boolean,default:!0}},computed:{containerClass(){return["p-dock p-component",`p-dock-${this.position}`,this.class]}},components:{DockSub:b}};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&i.firstChild?i.insertBefore(o,i.firstChild):i.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("\n.p-dock {\n position: absolute;\n z-index: 1;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n pointer-events: none;\n}\n.p-dock-list-container {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n pointer-events: auto;\n}\n.p-dock-list {\n margin: 0;\n padding: 0;\n list-style: none;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n.p-dock-item {\n -webkit-transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);\n transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);\n will-change: transform;\n}\n.p-dock-action {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n position: relative;\n overflow: hidden;\n cursor: default;\n}\n.p-dock-item-second-prev,\n.p-dock-item-second-next {\n -webkit-transform: scale(1.2);\n transform: scale(1.2);\n}\n.p-dock-item-prev,\n.p-dock-item-next {\n -webkit-transform: scale(1.4);\n transform: scale(1.4);\n}\n.p-dock-item-current {\n -webkit-transform: scale(1.6);\n transform: scale(1.6);\n z-index: 1;\n}\n\n/* Position */\n/* top */\n.p-dock-top {\n left: 0;\n top: 0;\n width: 100%;\n}\n.p-dock-top .p-dock-item {\n -webkit-transform-origin: center top;\n transform-origin: center top;\n}\n\n/* bottom */\n.p-dock-bottom {\n left: 0;\n bottom: 0;\n width: 100%;\n}\n.p-dock-bottom .p-dock-item {\n -webkit-transform-origin: center bottom;\n transform-origin: center bottom;\n}\n\n/* right */\n.p-dock-right {\n right: 0;\n top: 0;\n height: 100%;\n}\n.p-dock-right .p-dock-item {\n -webkit-transform-origin: center right;\n transform-origin: center right;\n}\n.p-dock-right .p-dock-list {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n\n/* left */\n.p-dock-left {\n left: 0;\n top: 0;\n height: 100%;\n}\n.p-dock-left .p-dock-item {\n -webkit-transform-origin: center left;\n transform-origin: center left;\n}\n.p-dock-left .p-dock-list {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n"),v.render=function(e,t,i,r,s,c){const d=n("DockSub");return o(),l("div",{class:a(c.containerClass),style:u(i.style)},[f(d,{model:i.model,templates:e.$slots,exact:i.exact,tooltipOptions:i.tooltipOptions},null,8,["model","templates","exact","tooltipOptions"])],6)};export{v as default};