primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 27.1 kB
JavaScript
import e from"primevue/icons/chevrondown";import t from"primevue/icons/chevronright";import{ObjectUtils as n,DomHandler as i,UniqueComponentId as s}from"primevue/utils";import o from"primevue/basecomponent";import{useStyle as a}from"primevue/usestyle";import r from"primevue/ripple";import{mergeProps as c,resolveComponent as l,resolveDirective as u,openBlock as m,createElementBlock as d,normalizeClass as p,Fragment as h,renderList as f,createElementVNode as I,createBlock as g,withCtx as v,withDirectives as y,resolveDynamicComponent as b,createCommentVNode as P,toDisplayString as x,createVNode as k,Transition as A,vShow as w,renderSlot as E}from"vue";var K=a("\n.p-panelmenu .p-panelmenu-header-action {\n display: flex;\n align-items: center;\n user-select: none;\n cursor: pointer;\n position: relative;\n text-decoration: none;\n}\n\n.p-panelmenu .p-panelmenu-header-action:focus {\n z-index: 1;\n}\n\n.p-panelmenu .p-submenu-list {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.p-panelmenu .p-menuitem-link {\n display: flex;\n align-items: center;\n user-select: none;\n cursor: pointer;\n text-decoration: none;\n position: relative;\n overflow: hidden;\n}\n\n.p-panelmenu .p-menuitem-text {\n line-height: 1;\n}\n",{name:"panelmenu",manual:!0}),O={name:"BasePanelMenu",extends:o,props:{model:{type:Array,default:null},expandedKeys:{type:Object,default:null},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:0}},css:{classes:{root:"p-panelmenu p-component",panel:"p-panelmenu-panel",header:function(e){var t=e.instance,n=e.item;return["p-panelmenu-header",{"p-highlight":t.isItemActive(n),"p-disabled":t.isItemDisabled(n)}]},headerContent:"p-panelmenu-header-content",headerAction:function(e){return["p-panelmenu-header-action",{"router-link-active":e.isActive,"router-link-active-exact":e.instance.exact&&e.isExactActive}]},headerIcon:"p-menuitem-icon",headerLabel:"p-menuitem-text",toggleableContent:"p-toggleable-content",menuContent:"p-panelmenu-content",menu:"p-panelmenu-root-list",menuitem:function(e){var t=e.instance,n=e.processedItem;return["p-menuitem",{"p-focus":t.isItemFocused(n),"p-disabled":t.isItemDisabled(n)}]},content:"p-menuitem-content",action:function(e){return["p-menuitem-link",{"router-link-active":e.isActive,"router-link-active-exact":e.props.exact&&e.isExactActive}]},icon:"p-menuitem-icon",label:"p-menuitem-text",submenuIcon:"p-submenu-icon",submenu:"p-submenu-list",separator:"p-menuitem-separator"},loadStyle:K.load},provide:function(){return{$parentInstance:this}}},H={name:"PanelMenuSub",hostName:"PanelMenu",extends:o,emits:["item-toggle"],props:{panelId:{type:String,default:null},focusedItemId:{type:String,default:null},items:{type:Array,default:null},level:{type:Number,default:0},templates:{type:Object,default:null},activeItemPath:{type:Object,default:null},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:-1}},methods:{getItemId:function(e){return"".concat(this.panelId,"_").concat(e.key)},getItemKey:function(e){return this.getItemId(e)},getItemProp:function(e,t,i){return e&&e.item?n.getItemValue(e.item[t],i):void 0},getItemLabel:function(e){return this.getItemProp(e,"label")},getPTOptions:function(e,t,n){return this.ptm(e,{context:{item:t,index:n,active:this.isItemActive(t),focused:this.isItemFocused(t)}})},isItemActive:function(e){return this.activeItemPath.some((function(t){return t.key===e.key}))},isItemVisible:function(e){return!1!==this.getItemProp(e,"visible")},isItemDisabled:function(e){return this.getItemProp(e,"disabled")},isItemFocused:function(e){return this.focusedItemId===this.getItemId(e)},isItemGroup:function(e){return n.isNotEmpty(e.items)},onItemClick:function(e,t){this.getItemProp(t,"command",{originalEvent:e,item:t.item}),this.$emit("item-toggle",{processedItem:t,expanded:!this.isItemActive(t)})},onItemToggle:function(e){this.$emit("item-toggle",e)},onItemActionClick:function(e,t){t&&t(e)},getAriaSetSize:function(){var e=this;return this.items.filter((function(t){return e.isItemVisible(t)&&!e.getItemProp(t,"separator")})).length},getAriaPosInset:function(e){var t=this;return e-this.items.slice(0,e).filter((function(e){return t.isItemVisible(e)&&t.getItemProp(e,"separator")})).length+1},getMenuItemProps:function(e,t){return{action:c({class:this.cx("action"),tabindex:-1,"aria-hidden":!0},this.getPTOptions("action",e,t)),icon:c({class:[this.cx("icon"),this.getItemProp(e,"icon")]},this.getPTOptions("icon",e,t)),label:c({class:this.cx("label")},this.getPTOptions("label",e,t)),submenuicon:c({class:this.cx("submenuIcon")},this.getPTOptions("submenuicon",e,t))}}},components:{ChevronRightIcon:t,ChevronDownIcon:e},directives:{ripple:r}},T=["tabindex"],C=["id","aria-label","aria-expanded","aria-level","aria-setsize","aria-posinset","data-p-focused","data-p-disabled"],S=["onClick"],D=["href","onClick"],L=["href","target"];function F(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function N(e,t){if(e){if("string"==typeof e)return V(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)?V(e,t):void 0}}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function j(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,s,o,a,r=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(r.push(i.value),r.length!==t);c=!0);}catch(e){l=!0,s=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw s}}return r}}function $(e){if(Array.isArray(e))return e}H.render=function(e,t,n,i,s,o){var a=l("router-link"),r=l("PanelMenuSub",!0),E=u("ripple");return m(),d("ul",{class:p(e.cx("submenu")),tabindex:n.tabindex},[(m(!0),d(h,null,f(n.items,(function(t,i){return m(),d(h,{key:o.getItemKey(t)},[o.isItemVisible(t)&&!o.getItemProp(t,"separator")?(m(),d("li",c({key:0,id:o.getItemId(t),class:[e.cx("menuitem",{processedItem:t}),o.getItemProp(t,"class")],style:o.getItemProp(t,"style"),role:"treeitem","aria-label":o.getItemLabel(t),"aria-expanded":o.isItemGroup(t)?o.isItemActive(t):void 0,"aria-level":n.level+1,"aria-setsize":o.getAriaSetSize(),"aria-posinset":o.getAriaPosInset(i)},o.getPTOptions("menuitem",t,i),{"data-p-focused":o.isItemFocused(t),"data-p-disabled":o.isItemDisabled(t)}),[I("div",c({class:e.cx("content"),onClick:function(e){return o.onItemClick(e,t)}},o.getPTOptions("content",t,i)),[n.templates.item?(m(),g(b(n.templates.item),{key:1,item:t.item,hasSubmenu:o.isItemGroup(t),label:o.getItemLabel(t),props:o.getMenuItemProps(t,i)},null,8,["item","hasSubmenu","label","props"])):(m(),d(h,{key:0},[o.getItemProp(t,"to")&&!o.isItemDisabled(t)?(m(),g(a,{key:0,to:o.getItemProp(t,"to"),custom:""},{default:v((function(s){var a=s.navigate,r=s.href,l=s.isActive,u=s.isExactActive;return[y((m(),d("a",c({href:r,class:e.cx("action",{isActive:l,isExactActive:u}),tabindex:"-1","aria-hidden":"true",onClick:function(e){return o.onItemActionClick(e,a)}},o.getPTOptions("action",t,i)),[n.templates.itemicon?(m(),g(b(n.templates.itemicon),{key:0,item:t.item,class:p([e.cx("icon"),o.getItemProp(t,"icon")])},null,8,["item","class"])):o.getItemProp(t,"icon")?(m(),d("span",c({key:1,class:[e.cx("icon"),o.getItemProp(t,"icon")]},o.getPTOptions("icon",t,i)),null,16)):P("",!0),I("span",c({class:e.cx("label")},o.getPTOptions("label",t,i)),x(o.getItemLabel(t)),17)],16,D)),[[E]])]})),_:2},1032,["to"])):y((m(),d("a",c({key:1,href:o.getItemProp(t,"url"),class:e.cx("action"),target:o.getItemProp(t,"target"),tabindex:"-1","aria-hidden":"true"},o.getPTOptions("action",t,i)),[o.isItemGroup(t)?(m(),d(h,{key:0},[n.templates.submenuicon?(m(),g(b(n.templates.submenuicon),c({key:0,class:e.cx("submenuIcon"),active:o.isItemActive(t)},o.getPTOptions("submenuIcon",t,i)),null,16,["class","active"])):(m(),g(b(o.isItemActive(t)?"ChevronDownIcon":"ChevronRightIcon"),c({key:1,class:e.cx("submenuIcon")},o.getPTOptions("submenuIcon",t,i)),null,16,["class"]))],64)):P("",!0),n.templates.itemicon?(m(),g(b(n.templates.itemicon),{key:1,item:t.item,class:p([e.cx("icon"),o.getItemProp(t,"icon")])},null,8,["item","class"])):o.getItemProp(t,"icon")?(m(),d("span",c({key:2,class:[e.cx("icon"),o.getItemProp(t,"icon")]},o.getPTOptions("icon",t,i)),null,16)):P("",!0),I("span",c({class:e.cx("label")},o.getPTOptions("label",t,i)),x(o.getItemLabel(t)),17)],16,L)),[[E]])],64))],16,S),k(A,c({name:"p-toggleable-content"},e.ptm("transition")),{default:v((function(){return[y(I("div",c({class:e.cx("toggleableContent")},e.ptm("toggleableContent")),[o.isItemVisible(t)&&o.isItemGroup(t)?(m(),g(r,c({key:0,id:o.getItemId(t)+"_list",role:"group",panelId:n.panelId,focusedItemId:n.focusedItemId,items:t.items,level:n.level+1,templates:n.templates,activeItemPath:n.activeItemPath,exact:n.exact,onItemToggle:o.onItemToggle,pt:e.pt,unstyled:e.unstyled},e.ptm("submenu")),null,16,["id","panelId","focusedItemId","items","level","templates","activeItemPath","exact","onItemToggle","pt","unstyled"])):P("",!0)],16),[[w,o.isItemActive(t)]])]})),_:2},1040)],16,C)):P("",!0),o.isItemVisible(t)&&o.getItemProp(t,"separator")?(m(),d("li",c({key:1,style:o.getItemProp(t,"style"),class:[e.cx("separator"),o.getItemProp(t,"class")],role:"separator"},e.ptm("separator")),null,16)):P("",!0)],64)})),128))],10,T)};var M={name:"PanelMenuList",hostName:"PanelMenu",extends:o,emits:["item-toggle","header-focus"],props:{panelId:{type:String,default:null},items:{type:Array,default:null},templates:{type:Object,default:null},expandedKeys:{type:Object,default:null},exact:{type:Boolean,default:!0}},searchTimeout:null,searchValue:null,data:function(){return{focused:!1,focusedItem:null,activeItemPath:[]}},watch:{expandedKeys:function(e){this.autoUpdateActiveItemPath(e)}},mounted:function(){this.autoUpdateActiveItemPath(this.expandedKeys)},methods:{getItemProp:function(e,t){return e&&e.item?n.getItemValue(e.item[t]):void 0},getItemLabel:function(e){return this.getItemProp(e,"label")},isItemVisible:function(e){return!1!==this.getItemProp(e,"visible")},isItemDisabled:function(e){return this.getItemProp(e,"disabled")},isItemActive:function(e){return this.activeItemPath.some((function(t){return t.key===e.parentKey}))},isItemGroup:function(e){return n.isNotEmpty(e.items)},onFocus:function(e){this.focused=!0,this.focusedItem=this.focusedItem||(this.isElementInPanel(e,e.relatedTarget)?this.findFirstItem():this.findLastItem())},onBlur:function(){this.focused=!1,this.focusedItem=null,this.searchValue=""},onKeyDown:function(e){var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"ArrowLeft":this.onArrowLeftKey(e);break;case"ArrowRight":this.onArrowRightKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Space":this.onSpaceKey(e);break;case"Enter":this.onEnterKey(e);break;case"Escape":case"Tab":case"PageDown":case"PageUp":case"Backspace":case"ShiftLeft":case"ShiftRight":break;default:!t&&n.isPrintableCharacter(e.key)&&this.searchItems(e,e.key)}},onArrowDownKey:function(e){var t=n.isNotEmpty(this.focusedItem)?this.findNextItem(this.focusedItem):this.findFirstItem();this.changeFocusedItem({originalEvent:e,processedItem:t,focusOnNext:!0}),e.preventDefault()},onArrowUpKey:function(e){var t=n.isNotEmpty(this.focusedItem)?this.findPrevItem(this.focusedItem):this.findLastItem();this.changeFocusedItem({originalEvent:e,processedItem:t,selfCheck:!0}),e.preventDefault()},onArrowLeftKey:function(e){var t=this;n.isNotEmpty(this.focusedItem)&&(this.activeItemPath.some((function(e){return e.key===t.focusedItem.key}))?this.activeItemPath=this.activeItemPath.filter((function(e){return e.key!==t.focusedItem.key})):this.focusedItem=n.isNotEmpty(this.focusedItem.parent)?this.focusedItem.parent:this.focusedItem,e.preventDefault())},onArrowRightKey:function(e){var t=this;if(n.isNotEmpty(this.focusedItem)){if(this.isItemGroup(this.focusedItem))this.activeItemPath.some((function(e){return e.key===t.focusedItem.key}))?this.onArrowDownKey(e):(this.activeItemPath=this.activeItemPath.filter((function(e){return e.parentKey!==t.focusedItem.parentKey})),this.activeItemPath.push(this.focusedItem));e.preventDefault()}},onHomeKey:function(e){this.changeFocusedItem({originalEvent:e,processedItem:this.findFirstItem(),allowHeaderFocus:!1}),e.preventDefault()},onEndKey:function(e){this.changeFocusedItem({originalEvent:e,processedItem:this.findLastItem(),focusOnNext:!0,allowHeaderFocus:!1}),e.preventDefault()},onEnterKey:function(e){if(n.isNotEmpty(this.focusedItem)){var t=i.findSingle(this.$el,'li[id="'.concat("".concat(this.focusedItemId),'"]')),s=t&&(i.findSingle(t,'[data-pc-section="action"]')||i.findSingle(t,"a,button"));s?s.click():t&&t.click()}e.preventDefault()},onSpaceKey:function(e){this.onEnterKey(e)},onItemToggle:function(e){var t=e.processedItem,n=e.expanded;this.expandedKeys?this.$emit("item-toggle",{item:t.item,expanded:n}):(this.activeItemPath=this.activeItemPath.filter((function(e){return e.parentKey!==t.parentKey})),n&&this.activeItemPath.push(t)),this.focusedItem=t,i.focus(this.$el)},isElementInPanel:function(e,t){var n=e.currentTarget.closest('[data-pc-section="panel"]');return n&&n.contains(t)},isItemMatched:function(e){return this.isValidItem(e)&&this.getItemLabel(e).toLocaleLowerCase(this.searchLocale).startsWith(this.searchValue.toLocaleLowerCase(this.searchLocale))},isVisibleItem:function(e){return!!e&&(0===e.level||this.isItemActive(e))&&this.isItemVisible(e)},isValidItem:function(e){return!!e&&!this.isItemDisabled(e)},findFirstItem:function(){var e=this;return this.visibleItems.find((function(t){return e.isValidItem(t)}))},findLastItem:function(){var e=this;return n.findLast(this.visibleItems,(function(t){return e.isValidItem(t)}))},findNextItem:function(e){var t=this,n=this.visibleItems.findIndex((function(t){return t.key===e.key}));return(n<this.visibleItems.length-1?this.visibleItems.slice(n+1).find((function(e){return t.isValidItem(e)})):void 0)||e},findPrevItem:function(e){var t=this,i=this.visibleItems.findIndex((function(t){return t.key===e.key}));return(i>0?n.findLast(this.visibleItems.slice(0,i),(function(e){return t.isValidItem(e)})):void 0)||e},searchItems:function(e,t){var i=this;this.searchValue=(this.searchValue||"")+t;var s=null,o=!1;if(n.isNotEmpty(this.focusedItem)){var a=this.visibleItems.findIndex((function(e){return e.key===i.focusedItem.key}));s=this.visibleItems.slice(a).find((function(e){return i.isItemMatched(e)})),s=n.isEmpty(s)?this.visibleItems.slice(0,a).find((function(e){return i.isItemMatched(e)})):s}else s=this.visibleItems.find((function(e){return i.isItemMatched(e)}));return n.isNotEmpty(s)&&(o=!0),n.isEmpty(s)&&n.isEmpty(this.focusedItem)&&(s=this.findFirstItem()),n.isNotEmpty(s)&&this.changeFocusedItem({originalEvent:e,processedItem:s,allowHeaderFocus:!1}),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((function(){i.searchValue="",i.searchTimeout=null}),500),o},changeFocusedItem:function(e){var t=e.originalEvent,i=e.processedItem,s=e.focusOnNext,o=e.selfCheck,a=e.allowHeaderFocus,r=void 0===a||a;n.isNotEmpty(this.focusedItem)&&this.focusedItem.key!==i.key?(this.focusedItem=i,this.scrollInView()):r&&this.$emit("header-focus",{originalEvent:t,focusOnNext:s,selfCheck:o})},scrollInView:function(){var e=i.findSingle(this.$el,'li[id="'.concat("".concat(this.focusedItemId),'"]'));e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest",inline:"start"})},autoUpdateActiveItemPath:function(e){var t=this;this.activeItemPath=Object.entries(e||{}).reduce((function(e,n){var i,s,o=(s=2,$(i=n)||j(i,s)||N(i,s)||F());if(o[1]){var a=t.findProcessedItemByItemKey(o[0]);a&&e.push(a)}return e}),[])},findProcessedItemByItemKey:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!(t=t||0===n&&this.processedItems))return null;for(var i=0;i<t.length;i++){var s=t[i];if(this.getItemProp(s,"key")===e)return s;var o=this.findProcessedItemByItemKey(e,s.items,n+1);if(o)return o}},createProcessedItems:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=[];return e&&e.forEach((function(e,a){var r=(""!==s?s+"_":"")+a,c={item:e,index:a,level:n,key:r,parent:i,parentKey:s};c.items=t.createProcessedItems(e.items,n+1,c,r),o.push(c)})),o},flatItems:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e&&e.forEach((function(e){t.isVisibleItem(e)&&(n.push(e),t.flatItems(e.items,n))})),n}},computed:{processedItems:function(){return this.createProcessedItems(this.items||[])},visibleItems:function(){return this.flatItems(this.processedItems)},focusedItemId:function(){return n.isNotEmpty(this.focusedItem)?"".concat(this.panelId,"_").concat(this.focusedItem.key):null}},components:{PanelMenuSub:H}};function B(e){return B="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},B(e)}function _(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function R(e,t,n){return(t=G(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e){var t=z(e,"string");return"symbol"===B(t)?t:String(t)}function z(e,t){if("object"!==B(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==B(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}M.render=function(e,t,n,i,s,o){var a=l("PanelMenuSub");return m(),g(a,c({id:n.panelId+"_list",class:e.cx("menu"),role:"tree",tabindex:-1,"aria-activedescendant":s.focused?o.focusedItemId:void 0,panelId:n.panelId,focusedItemId:s.focused?o.focusedItemId:void 0,items:o.processedItems,templates:n.templates,activeItemPath:s.activeItemPath,exact:n.exact,onFocus:o.onFocus,onBlur:o.onBlur,onKeydown:o.onKeyDown,onItemToggle:o.onItemToggle,pt:e.pt,unstyled:e.unstyled},e.ptm("menu")),null,16,["id","class","aria-activedescendant","panelId","focusedItemId","items","templates","activeItemPath","exact","onFocus","onBlur","onKeydown","onItemToggle","pt","unstyled"])};var q={name:"PanelMenu",extends:O,emits:["update:expandedKeys","panel-open","panel-close"],data:function(){return{id:this.$attrs.id,activeItem:null}},watch:{"$attrs.id":function(e){this.id=e||s()}},beforeMount:function(){this.$slots.item||console.warn("In future versions, vue-router support will be removed. Item templating should be used.")},mounted:function(){this.id=this.id||s()},methods:{getItemProp:function(e,t){return e?n.getItemValue(e[t]):void 0},getItemLabel:function(e){return this.getItemProp(e,"label")},getPTOptions:function(e,t,n){return this.ptm(e,{context:{index:n,active:this.isItemActive(t),focused:this.isItemFocused(t)}})},isItemActive:function(e){return this.expandedKeys?this.expandedKeys[this.getItemProp(e,"key")]:n.equals(e,this.activeItem)},isItemVisible:function(e){return!1!==this.getItemProp(e,"visible")},isItemDisabled:function(e){return this.getItemProp(e,"disabled")},isItemFocused:function(e){return n.equals(e,this.activeItem)},getPanelId:function(e){return"".concat(this.id,"_").concat(e)},getPanelKey:function(e){return this.getPanelId(e)},getHeaderId:function(e){return"".concat(this.getPanelId(e),"_header")},getContentId:function(e){return"".concat(this.getPanelId(e),"_content")},onHeaderClick:function(e,t){this.isItemDisabled(t)?e.preventDefault():(t.command&&t.command({originalEvent:e,item:t}),this.changeActiveItem(e,t),i.focus(e.currentTarget))},onHeaderKeyDown:function(e,t){switch(e.code){case"ArrowDown":this.onHeaderArrowDownKey(e);break;case"ArrowUp":this.onHeaderArrowUpKey(e);break;case"Home":this.onHeaderHomeKey(e);break;case"End":this.onHeaderEndKey(e);break;case"Enter":case"Space":this.onHeaderEnterKey(e,t)}},onHeaderArrowDownKey:function(e){var t=!0===i.getAttribute(e.currentTarget,"data-p-highlight")?i.findSingle(e.currentTarget.nextElementSibling,'[data-pc-section="menu"]'):null;t?i.focus(t):this.updateFocusedHeader({originalEvent:e,focusOnNext:!0}),e.preventDefault()},onHeaderArrowUpKey:function(e){var t=this.findPrevHeader(e.currentTarget.parentElement)||this.findLastHeader(),n=!0===i.getAttribute(t,"data-p-highlight")?i.findSingle(t.nextElementSibling,'[data-pc-section="menu"]'):null;n?i.focus(n):this.updateFocusedHeader({originalEvent:e,focusOnNext:!1}),e.preventDefault()},onHeaderHomeKey:function(e){this.changeFocusedHeader(e,this.findFirstHeader()),e.preventDefault()},onHeaderEndKey:function(e){this.changeFocusedHeader(e,this.findLastHeader()),e.preventDefault()},onHeaderEnterKey:function(e,t){var n=i.findSingle(e.currentTarget,'[data-pc-section="headeraction"]');n?n.click():this.onHeaderClick(e,t),e.preventDefault()},onHeaderActionClick:function(e,t){t&&t(e)},findNextHeader:function(e){var t=i.findSingle(arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e:e.nextElementSibling,'[data-pc-section="header"]');return t?i.getAttribute(t,"data-p-disabled")?this.findNextHeader(t.parentElement):t:null},findPrevHeader:function(e){var t=i.findSingle(arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e:e.previousElementSibling,'[data-pc-section="header"]');return t?i.getAttribute(t,"data-p-disabled")?this.findPrevHeader(t.parentElement):t:null},findFirstHeader:function(){return this.findNextHeader(this.$el.firstElementChild,!0)},findLastHeader:function(){return this.findPrevHeader(this.$el.lastElementChild,!0)},updateFocusedHeader:function(e){var t=e.originalEvent,n=e.focusOnNext,s=e.selfCheck,o=t.currentTarget.closest('[data-pc-section="panel"]'),a=s?i.findSingle(o,'[data-pc-section="header"]'):n?this.findNextHeader(o):this.findPrevHeader(o);a?this.changeFocusedHeader(t,a):n?this.onHeaderHomeKey(t):this.onHeaderEndKey(t)},changeActiveItem:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.isItemDisabled(t)){var s=this.isItemActive(t),o=s?"panel-close":"panel-open";this.activeItem=i?t:this.activeItem&&n.equals(t,this.activeItem)?null:t,this.changeExpandedKeys({item:t,expanded:!s}),this.$emit(o,{originalEvent:e,item:t})}},changeExpandedKeys:function(e){var t=e.item,n=e.expanded,i=void 0!==n&&n;if(this.expandedKeys){var s=U({},this.expandedKeys);i?s[t.key]=!0:delete s[t.key],this.$emit("update:expandedKeys",s)}},changeFocusedHeader:function(e,t){t&&i.focus(t)}},components:{PanelMenuList:M,ChevronRightIcon:t,ChevronDownIcon:e}},W=["id"],J=["id","tabindex","aria-label","aria-expanded","aria-controls","aria-disabled","onClick","onKeydown","data-p-highlight","data-p-disabled"],Q=["href","onClick"],X=["href"],Y=["id","aria-labelledby"];q.render=function(e,t,n,i,s,o){var a=l("router-link"),r=l("PanelMenuList");return m(),d("div",c({id:s.id,class:e.cx("root")},e.ptm("root"),{"data-pc-name":"panelmenu"}),[(m(!0),d(h,null,f(e.model,(function(t,n){return m(),d(h,{key:o.getPanelKey(n)},[o.isItemVisible(t)?(m(),d("div",c({key:0,style:o.getItemProp(t,"style"),class:[e.cx("panel"),o.getItemProp(t,"class")]},e.ptm("panel")),[I("div",c({id:o.getHeaderId(n),class:[e.cx("header",{item:t}),o.getItemProp(t,"headerClass")],tabindex:o.isItemDisabled(t)?-1:e.tabindex,role:"button","aria-label":o.getItemLabel(t),"aria-expanded":o.isItemActive(t),"aria-controls":o.getContentId(n),"aria-disabled":o.isItemDisabled(t),onClick:function(e){return o.onHeaderClick(e,t)},onKeydown:function(e){return o.onHeaderKeyDown(e,t)}},o.getPTOptions("header",t,n),{"data-p-highlight":o.isItemActive(t),"data-p-disabled":o.isItemDisabled(t)}),[I("div",c({class:e.cx("headerContent")},o.getPTOptions("headerContent",t,n)),[e.$slots.item?(m(),g(b(e.$slots.item),{key:1,item:t},null,8,["item"])):(m(),d(h,{key:0},[o.getItemProp(t,"to")&&!o.isItemDisabled(t)?(m(),g(a,{key:0,to:o.getItemProp(t,"to"),custom:""},{default:v((function(i){var s=i.navigate;return[I("a",c({href:i.href,class:e.cx("headerAction",{isActive:i.isActive,isExactActive:i.isExactActive}),tabindex:-1,onClick:function(e){return o.onHeaderActionClick(e,s)}},o.getPTOptions("headerAction",t,n)),[e.$slots.headericon?(m(),g(b(e.$slots.headericon),{key:0,item:t,class:p([e.cx("headerIcon"),o.getItemProp(t,"icon")])},null,8,["item","class"])):o.getItemProp(t,"icon")?(m(),d("span",c({key:1,class:[e.cx("headerIcon"),o.getItemProp(t,"icon")]},o.getPTOptions("headerIcon",t,n)),null,16)):P("",!0),I("span",c({class:e.cx("headerLabel")},o.getPTOptions("headerLabel",t,n)),x(o.getItemLabel(t)),17)],16,Q)]})),_:2},1032,["to"])):(m(),d("a",c({key:1,href:o.getItemProp(t,"url"),class:e.cx("headerAction"),tabindex:-1},o.getPTOptions("headerAction",t,n)),[o.getItemProp(t,"items")?E(e.$slots,"submenuicon",{key:0,active:o.isItemActive(t)},(function(){return[(m(),g(b(o.isItemActive(t)?"ChevronDownIcon":"ChevronRightIcon"),c({class:e.cx("submenuIcon")},o.getPTOptions("submenuIcon",t,n)),null,16,["class"]))]})):P("",!0),e.$slots.headericon?(m(),g(b(e.$slots.headericon),{key:1,item:t,class:p([e.cx("headerIcon"),o.getItemProp(t,"icon")])},null,8,["item","class"])):o.getItemProp(t,"icon")?(m(),d("span",c({key:2,class:[e.cx("headerIcon"),o.getItemProp(t,"icon")]},o.getPTOptions("headerIcon",t,n)),null,16)):P("",!0),I("span",c({class:e.cx("headerLabel")},o.getPTOptions("headerLabel",t,n)),x(o.getItemLabel(t)),17)],16,X))],64))],16)],16,J),k(A,c({name:"p-toggleable-content"},e.ptm("transition")),{default:v((function(){return[y(I("div",c({id:o.getContentId(n),class:e.cx("toggleableContent"),role:"region","aria-labelledby":o.getHeaderId(n)},e.ptm("toggleableContent")),[o.getItemProp(t,"items")?(m(),d("div",c({key:0,class:e.cx("menuContent")},e.ptm("menuContent")),[k(r,{panelId:o.getPanelId(n),items:o.getItemProp(t,"items"),templates:e.$slots,expandedKeys:e.expandedKeys,onItemToggle:o.changeExpandedKeys,onHeaderFocus:o.updateFocusedHeader,exact:e.exact,pt:e.pt,unstyled:e.unstyled},null,8,["panelId","items","templates","expandedKeys","onItemToggle","onHeaderFocus","exact","pt","unstyled"])],16)):P("",!0)],16,Y),[[w,o.isItemActive(t)]])]})),_:2},1040)],16)):P("",!0)],64)})),128))],16,W)};export{q as default};