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) 26.3 kB
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 a from"primevue/basecomponent";import{useStyle as o}from"primevue/usestyle";import r from"primevue/ripple";import{resolveComponent as c,resolveDirective as l,openBlock as u,createElementBlock as m,normalizeClass as d,Fragment as p,renderList as h,mergeProps 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 E,renderSlot as K}from"vue";var w=o("\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}),H={name:"BasePanelMenu",extends:a,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:w.load},provide:function(){return{$parentInstance:this}}},O={name:"PanelMenuSub",hostName:"PanelMenu",extends:a,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}},components:{ChevronRightIcon:t,ChevronDownIcon:e},directives:{ripple:r}},C=["tabindex"],T=["id","aria-label","aria-expanded","aria-level","aria-setsize","aria-posinset","data-p-focused","data-p-disabled"],D=["onClick"],S=["href","onClick"],F=["href","target"];function L(){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,a,o,r=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=a.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&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw s}}return r}}function $(e){if(Array.isArray(e))return e}O.render=function(e,t,n,i,s,a){var o=c("router-link"),r=c("PanelMenuSub",!0),K=l("ripple");return u(),m("ul",{class:d(e.cx("submenu")),tabindex:n.tabindex},[(u(!0),m(p,null,h(n.items,(function(t,i){return u(),m(p,{key:a.getItemKey(t)},[a.isItemVisible(t)&&!a.getItemProp(t,"separator")?(u(),m("li",f({key:0,id:a.getItemId(t),class:[e.cx("menuitem",{processedItem:t}),a.getItemProp(t,"class")],style:a.getItemProp(t,"style"),role:"treeitem","aria-label":a.getItemLabel(t),"aria-expanded":a.isItemGroup(t)?a.isItemActive(t):void 0,"aria-level":n.level+1,"aria-setsize":a.getAriaSetSize(),"aria-posinset":a.getAriaPosInset(i)},a.getPTOptions("menuitem",t,i),{"data-p-focused":a.isItemFocused(t),"data-p-disabled":a.isItemDisabled(t)}),[I("div",f({class:e.cx("content"),onClick:function(e){return a.onItemClick(e,t)}},a.getPTOptions("content",t,i)),[n.templates.item?(u(),g(b(n.templates.item),{key:1,item:t.item},null,8,["item"])):(u(),m(p,{key:0},[a.getItemProp(t,"to")&&!a.isItemDisabled(t)?(u(),g(o,{key:0,to:a.getItemProp(t,"to"),custom:""},{default:v((function(s){var o=s.navigate,r=s.href,c=s.isActive,l=s.isExactActive;return[y((u(),m("a",f({href:r,class:e.cx("action",{isActive:c,isExactActive:l}),tabindex:"-1","aria-hidden":"true",onClick:function(e){return a.onItemActionClick(e,o)}},a.getPTOptions("action",t,i)),[n.templates.itemicon?(u(),g(b(n.templates.itemicon),{key:0,item:t.item,class:d([e.cx("icon"),a.getItemProp(t,"icon")])},null,8,["item","class"])):a.getItemProp(t,"icon")?(u(),m("span",f({key:1,class:[e.cx("icon"),a.getItemProp(t,"icon")]},a.getPTOptions("icon",t,i)),null,16)):P("",!0),I("span",f({class:e.cx("label")},a.getPTOptions("label",t,i)),x(a.getItemLabel(t)),17)],16,S)),[[K]])]})),_:2},1032,["to"])):y((u(),m("a",f({key:1,href:a.getItemProp(t,"url"),class:e.cx("action"),target:a.getItemProp(t,"target"),tabindex:"-1","aria-hidden":"true"},a.getPTOptions("action",t,i)),[a.isItemGroup(t)?(u(),m(p,{key:0},[n.templates.submenuicon?(u(),g(b(n.templates.submenuicon),f({key:0,class:e.cx("submenuIcon"),active:a.isItemActive(t)},a.getPTOptions("submenuIcon",t,i)),null,16,["class","active"])):(u(),g(b(a.isItemActive(t)?"ChevronDownIcon":"ChevronRightIcon"),f({key:1,class:e.cx("submenuIcon")},a.getPTOptions("submenuIcon",t,i)),null,16,["class"]))],64)):P("",!0),n.templates.itemicon?(u(),g(b(n.templates.itemicon),{key:1,item:t.item,class:d([e.cx("icon"),a.getItemProp(t,"icon")])},null,8,["item","class"])):a.getItemProp(t,"icon")?(u(),m("span",f({key:2,class:[e.cx("icon"),a.getItemProp(t,"icon")]},a.getPTOptions("icon",t,i)),null,16)):P("",!0),I("span",f({class:e.cx("label")},a.getPTOptions("label",t,i)),x(a.getItemLabel(t)),17)],16,F)),[[K]])],64))],16,D),k(A,{name:"p-toggleable-content"},{default:v((function(){return[y(I("div",f({class:e.cx("toggleableContent")},e.ptm("toggleableContent")),[a.isItemVisible(t)&&a.isItemGroup(t)?(u(),g(r,f({key:0,id:a.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:a.onItemToggle,pt:e.pt},e.ptm("submenu")),null,16,["id","panelId","focusedItemId","items","level","templates","activeItemPath","exact","onItemToggle","pt"])):P("",!0)],16),[[E,a.isItemActive(t)]])]})),_:2},1024)],16,T)):P("",!0),a.isItemVisible(t)&&a.getItemProp(t,"separator")?(u(),m("li",f({key:1,style:a.getItemProp(t,"style"),class:[e.cx("separator"),a.getItemProp(t,"class")],role:"separator"},e.ptm("separator")),null,16)):P("",!0)],64)})),128))],10,C)};var M={name:"PanelMenuList",hostName:"PanelMenu",extends:a,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,a=!1;if(n.isNotEmpty(this.focusedItem)){var o=this.visibleItems.findIndex((function(e){return e.key===i.focusedItem.key}));s=this.visibleItems.slice(o).find((function(e){return i.isItemMatched(e)})),s=n.isEmpty(s)?this.visibleItems.slice(0,o).find((function(e){return i.isItemMatched(e)})):s}else s=this.visibleItems.find((function(e){return i.isItemMatched(e)}));return n.isNotEmpty(s)&&(a=!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),a},changeFocusedItem:function(e){var t=e.originalEvent,i=e.processedItem,s=e.focusOnNext,a=e.selfCheck,o=e.allowHeaderFocus,r=void 0===o||o;n.isNotEmpty(this.focusedItem)&&this.focusedItem.key!==i.key?(this.focusedItem=i,this.scrollInView()):r&&this.$emit("header-focus",{originalEvent:t,focusOnNext:s,selfCheck:a})},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,a=(s=2,$(i=n)||j(i,s)||N(i,s)||L());if(a[1]){var o=t.findProcessedItemByItemKey(a[0]);o&&e.push(o)}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 a=this.findProcessedItemByItemKey(e,s.items,n+1);if(a)return a}},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]:"",a=[];return e&&e.forEach((function(e,o){var r=(""!==s?s+"_":"")+o,c={item:e,index:o,level:n,key:r,parent:i,parentKey:s};c.items=t.createProcessedItems(e.items,n+1,c,r),a.push(c)})),a},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:O}};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,a){var o=c("PanelMenuSub");return u(),g(o,f({id:n.panelId+"_list",class:e.cx("menu"),role:"tree",tabindex:-1,"aria-activedescendant":s.focused?a.focusedItemId:void 0,panelId:n.panelId,focusedItemId:s.focused?a.focusedItemId:void 0,items:a.processedItems,templates:n.templates,activeItemPath:s.activeItemPath,exact:n.exact,onFocus:a.onFocus,onBlur:a.onBlur,onKeydown:a.onKeyDown,onItemToggle:a.onItemToggle,pt:e.pt},e.ptm("menu")),null,16,["id","class","aria-activedescendant","panelId","focusedItemId","items","templates","activeItemPath","exact","onFocus","onBlur","onKeydown","onItemToggle","pt"])};var q={name:"PanelMenu",extends:H,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()}},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,a=t.currentTarget.closest('[data-pc-section="panel"]'),o=s?i.findSingle(a,'[data-pc-section="header"]'):n?this.findNextHeader(a):this.findPrevHeader(a);o?this.changeFocusedHeader(t,o):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),a=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(a,{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,a){var o=c("router-link"),r=c("PanelMenuList");return u(),m("div",f({id:s.id,class:e.cx("root")},e.ptm("root"),{"data-pc-name":"panelmenu"}),[(u(!0),m(p,null,h(e.model,(function(t,n){return u(),m(p,{key:a.getPanelKey(n)},[a.isItemVisible(t)?(u(),m("div",f({key:0,style:a.getItemProp(t,"style"),class:[e.cx("panel"),a.getItemProp(t,"class")]},e.ptm("panel")),[I("div",f({id:a.getHeaderId(n),class:[e.cx("header",{item:t}),a.getItemProp(t,"headerClass")],tabindex:a.isItemDisabled(t)?-1:e.tabindex,role:"button","aria-label":a.getItemLabel(t),"aria-expanded":a.isItemActive(t),"aria-controls":a.getContentId(n),"aria-disabled":a.isItemDisabled(t),onClick:function(e){return a.onHeaderClick(e,t)},onKeydown:function(e){return a.onHeaderKeyDown(e,t)}},a.getPTOptions("header",t,n),{"data-p-highlight":a.isItemActive(t),"data-p-disabled":a.isItemDisabled(t)}),[I("div",f({class:e.cx("headerContent")},a.getPTOptions("headerContent",t,n)),[e.$slots.item?(u(),g(b(e.$slots.item),{key:1,item:t},null,8,["item"])):(u(),m(p,{key:0},[a.getItemProp(t,"to")&&!a.isItemDisabled(t)?(u(),g(o,{key:0,to:a.getItemProp(t,"to"),custom:""},{default:v((function(i){var s=i.navigate;return[I("a",f({href:i.href,class:e.cx("headerAction",{isActive:i.isActive,isExactActive:i.isExactActive}),tabindex:-1,onClick:function(e){return a.onHeaderActionClick(e,s)}},a.getPTOptions("headerAction",t,n)),[e.$slots.headericon?(u(),g(b(e.$slots.headericon),{key:0,item:t,class:d([e.cx("headerIcon"),a.getItemProp(t,"icon")])},null,8,["item","class"])):a.getItemProp(t,"icon")?(u(),m("span",f({key:1,class:[e.cx("headerIcon"),a.getItemProp(t,"icon")]},a.getPTOptions("headerIcon",t,n)),null,16)):P("",!0),I("span",f({class:e.cx("headerLabel")},a.getPTOptions("headerLabel",t,n)),x(a.getItemLabel(t)),17)],16,Q)]})),_:2},1032,["to"])):(u(),m("a",f({key:1,href:a.getItemProp(t,"url"),class:e.cx("headerAction"),tabindex:-1},a.getPTOptions("headerAction",t,n)),[a.getItemProp(t,"items")?K(e.$slots,"submenuicon",{key:0,active:a.isItemActive(t)},(function(){return[(u(),g(b(a.isItemActive(t)?"ChevronDownIcon":"ChevronRightIcon"),f({class:e.cx("submenuIcon")},a.getPTOptions("submenuIcon",t,n)),null,16,["class"]))]})):P("",!0),e.$slots.headericon?(u(),g(b(e.$slots.headericon),{key:1,item:t,class:d([e.cx("headerIcon"),a.getItemProp(t,"icon")])},null,8,["item","class"])):a.getItemProp(t,"icon")?(u(),m("span",f({key:2,class:[e.cx("headerIcon"),a.getItemProp(t,"icon")]},a.getPTOptions("headerIcon",t,n)),null,16)):P("",!0),I("span",f({class:e.cx("headerLabel")},a.getPTOptions("headerLabel",t,n)),x(a.getItemLabel(t)),17)],16,X))],64))],16)],16,J),k(A,{name:"p-toggleable-content"},{default:v((function(){return[y(I("div",f({id:a.getContentId(n),class:e.cx("toggleableContent"),role:"region","aria-labelledby":a.getHeaderId(n)},e.ptm("toggleableContent")),[a.getItemProp(t,"items")?(u(),m("div",f({key:0,class:e.cx("menuContent")},e.ptm("menuContent")),[k(r,{panelId:a.getPanelId(n),items:a.getItemProp(t,"items"),templates:e.$slots,expandedKeys:e.expandedKeys,onItemToggle:a.changeExpandedKeys,onHeaderFocus:a.updateFocusedHeader,exact:e.exact,pt:e.pt},null,8,["panelId","items","templates","expandedKeys","onItemToggle","onHeaderFocus","exact","pt"])],16)):P("",!0)],16,Y),[[E,a.isItemActive(t)]])]})),_:2},1024)],16)):P("",!0)],64)})),128))],16,W)};export{q as default};