primevue 3.22.2 → 3.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/accordion/Accordion.vue +7 -3
- package/accordion/accordion.cjs.js +7 -3
- package/accordion/accordion.cjs.min.js +1 -1
- package/accordion/accordion.esm.js +8 -4
- package/accordion/accordion.esm.min.js +1 -1
- package/accordion/accordion.js +7 -3
- package/accordion/accordion.min.js +1 -1
- package/autocomplete/AutoComplete.vue +6 -3
- package/autocomplete/autocomplete.cjs.js +12 -9
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +13 -10
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +12 -9
- package/autocomplete/autocomplete.min.js +1 -1
- package/breadcrumb/Breadcrumb.vue +2 -2
- package/breadcrumb/breadcrumb.cjs.js +17 -10
- package/breadcrumb/breadcrumb.cjs.min.js +1 -1
- package/breadcrumb/breadcrumb.esm.js +17 -10
- package/breadcrumb/breadcrumb.esm.min.js +1 -1
- package/breadcrumb/breadcrumb.js +17 -10
- package/breadcrumb/breadcrumb.min.js +1 -1
- package/cascadeselect/CascadeSelect.vue +6 -3
- package/cascadeselect/cascadeselect.cjs.js +9 -6
- package/cascadeselect/cascadeselect.cjs.min.js +1 -1
- package/cascadeselect/cascadeselect.esm.js +10 -7
- package/cascadeselect/cascadeselect.esm.min.js +1 -1
- package/cascadeselect/cascadeselect.js +9 -6
- package/cascadeselect/cascadeselect.min.js +1 -1
- package/contextmenu/ContextMenu.vue +6 -3
- package/contextmenu/contextmenu.cjs.js +8 -5
- package/contextmenu/contextmenu.cjs.min.js +1 -1
- package/contextmenu/contextmenu.esm.js +9 -6
- package/contextmenu/contextmenu.esm.min.js +1 -1
- package/contextmenu/contextmenu.js +8 -5
- package/contextmenu/contextmenu.min.js +1 -1
- package/core/core.js +48 -34
- package/core/core.min.js +5 -5
- package/datatable/BodyCell.vue +4 -2
- package/datatable/datatable.cjs.js +4 -2
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +4 -2
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +4 -2
- package/datatable/datatable.min.js +1 -1
- package/dock/DockSub.vue +9 -3
- package/dock/dock.cjs.js +10 -4
- package/dock/dock.cjs.min.js +1 -1
- package/dock/dock.esm.js +11 -5
- package/dock/dock.esm.min.js +1 -1
- package/dock/dock.js +10 -4
- package/dock/dock.min.js +1 -1
- package/dropdown/Dropdown.vue +6 -3
- package/dropdown/dropdown.cjs.js +13 -10
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +14 -11
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +13 -10
- package/dropdown/dropdown.min.js +1 -1
- package/listbox/Listbox.vue +6 -3
- package/listbox/listbox.cjs.js +11 -8
- package/listbox/listbox.cjs.min.js +1 -1
- package/listbox/listbox.esm.js +12 -9
- package/listbox/listbox.esm.min.js +1 -1
- package/listbox/listbox.js +11 -8
- package/listbox/listbox.min.js +1 -1
- package/megamenu/MegaMenu.vue +7 -3
- package/megamenu/megamenu.cjs.js +10 -6
- package/megamenu/megamenu.cjs.min.js +1 -1
- package/megamenu/megamenu.esm.js +11 -7
- package/megamenu/megamenu.esm.min.js +1 -1
- package/megamenu/megamenu.js +10 -6
- package/megamenu/megamenu.min.js +1 -1
- package/menu/Menu.vue +8 -3
- package/menu/menu.cjs.js +13 -8
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.esm.js +14 -9
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +13 -8
- package/menu/menu.min.js +1 -1
- package/menubar/Menubar.vue +7 -3
- package/menubar/menubar.cjs.js +10 -6
- package/menubar/menubar.cjs.min.js +1 -1
- package/menubar/menubar.esm.js +11 -7
- package/menubar/menubar.esm.min.js +1 -1
- package/menubar/menubar.js +10 -6
- package/menubar/menubar.min.js +1 -1
- package/multiselect/MultiSelect.vue +6 -3
- package/multiselect/multiselect.cjs.js +11 -8
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +12 -9
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +11 -8
- package/multiselect/multiselect.min.js +1 -1
- package/orderlist/OrderList.vue +8 -3
- package/orderlist/orderlist.cjs.js +11 -6
- package/orderlist/orderlist.cjs.min.js +1 -1
- package/orderlist/orderlist.esm.js +12 -7
- package/orderlist/orderlist.esm.min.js +1 -1
- package/orderlist/orderlist.js +11 -6
- package/orderlist/orderlist.min.js +1 -1
- package/package.json +1 -1
- package/panelmenu/PanelMenu.vue +9 -6
- package/panelmenu/PanelMenuList.vue +1 -1
- package/panelmenu/panelmenu.cjs.js +11 -8
- package/panelmenu/panelmenu.cjs.min.js +1 -1
- package/panelmenu/panelmenu.esm.js +11 -8
- package/panelmenu/panelmenu.esm.min.js +1 -1
- package/panelmenu/panelmenu.js +11 -8
- package/panelmenu/panelmenu.min.js +1 -1
- package/picklist/PickList.vue +8 -2
- package/picklist/picklist.cjs.js +8 -2
- package/picklist/picklist.cjs.min.js +1 -1
- package/picklist/picklist.esm.js +9 -3
- package/picklist/picklist.esm.min.js +1 -1
- package/picklist/picklist.js +8 -2
- package/picklist/picklist.min.js +1 -1
- package/rating/Rating.vue +9 -3
- package/rating/rating.cjs.js +11 -5
- package/rating/rating.cjs.min.js +1 -1
- package/rating/rating.esm.js +12 -6
- package/rating/rating.esm.min.js +1 -1
- package/rating/rating.js +11 -5
- package/rating/rating.min.js +1 -1
- package/resources/themes/arya-blue/theme.css +7 -0
- package/resources/themes/arya-green/theme.css +7 -0
- package/resources/themes/arya-orange/theme.css +7 -0
- package/resources/themes/arya-purple/theme.css +7 -0
- package/resources/themes/bootstrap4-dark-blue/theme.css +7 -0
- package/resources/themes/bootstrap4-dark-purple/theme.css +7 -0
- package/resources/themes/bootstrap4-light-blue/theme.css +7 -0
- package/resources/themes/bootstrap4-light-purple/theme.css +7 -0
- package/resources/themes/fluent-light/theme.css +7 -0
- package/resources/themes/lara-dark-blue/theme.css +7 -0
- package/resources/themes/lara-dark-indigo/theme.css +7 -0
- package/resources/themes/lara-dark-purple/theme.css +7 -0
- package/resources/themes/lara-dark-teal/theme.css +7 -0
- package/resources/themes/lara-light-blue/theme.css +7 -0
- package/resources/themes/lara-light-indigo/theme.css +7 -0
- package/resources/themes/lara-light-purple/theme.css +7 -0
- package/resources/themes/lara-light-teal/theme.css +7 -0
- package/resources/themes/luna-amber/theme.css +7 -0
- package/resources/themes/luna-blue/theme.css +7 -0
- package/resources/themes/luna-green/theme.css +7 -0
- package/resources/themes/luna-pink/theme.css +7 -0
- package/resources/themes/md-dark-deeppurple/theme.css +10 -2
- package/resources/themes/md-dark-indigo/theme.css +10 -2
- package/resources/themes/md-light-deeppurple/theme.css +10 -2
- package/resources/themes/md-light-indigo/theme.css +10 -2
- package/resources/themes/mdc-dark-deeppurple/theme.css +10 -2
- package/resources/themes/mdc-dark-indigo/theme.css +10 -2
- package/resources/themes/mdc-light-deeppurple/theme.css +10 -2
- package/resources/themes/mdc-light-indigo/theme.css +10 -2
- package/resources/themes/nova/theme.css +7 -0
- package/resources/themes/nova-accent/theme.css +7 -0
- package/resources/themes/nova-alt/theme.css +7 -0
- package/resources/themes/nova-vue/theme.css +7 -0
- package/resources/themes/rhea/theme.css +7 -0
- package/resources/themes/saga-blue/theme.css +7 -0
- package/resources/themes/saga-green/theme.css +7 -0
- package/resources/themes/saga-orange/theme.css +7 -0
- package/resources/themes/saga-purple/theme.css +7 -0
- package/resources/themes/tailwind-light/theme.css +7 -0
- package/resources/themes/vela-blue/theme.css +7 -0
- package/resources/themes/vela-green/theme.css +7 -0
- package/resources/themes/vela-orange/theme.css +7 -0
- package/resources/themes/vela-purple/theme.css +7 -0
- package/speeddial/SpeedDial.vue +6 -3
- package/speeddial/speeddial.cjs.js +11 -8
- package/speeddial/speeddial.cjs.min.js +1 -1
- package/speeddial/speeddial.esm.js +12 -9
- package/speeddial/speeddial.esm.min.js +1 -1
- package/speeddial/speeddial.js +11 -8
- package/speeddial/speeddial.min.js +1 -1
- package/tabview/TabView.vue +6 -3
- package/tabview/tabview.cjs.js +6 -3
- package/tabview/tabview.cjs.min.js +1 -1
- package/tabview/tabview.esm.js +7 -4
- package/tabview/tabview.esm.min.js +1 -1
- package/tabview/tabview.js +6 -3
- package/tabview/tabview.min.js +1 -1
- package/tieredmenu/TieredMenu.vue +7 -3
- package/tieredmenu/tieredmenu.cjs.js +10 -6
- package/tieredmenu/tieredmenu.cjs.min.js +1 -1
- package/tieredmenu/tieredmenu.esm.js +11 -7
- package/tieredmenu/tieredmenu.esm.min.js +1 -1
- package/tieredmenu/tieredmenu.js +10 -6
- package/tieredmenu/tieredmenu.min.js +1 -1
- package/tooltip/tooltip.cjs.js +0 -2
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +1 -3
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +0 -2
- package/tooltip/tooltip.min.js +1 -1
- package/utils/utils.cjs.js +12 -8
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +12 -8
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +12 -8
- package/utils/utils.min.js +1 -1
- package/web-types.json +1 -1
package/menu/menu.cjs.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("primevue/overlayeventbus"),t=require("primevue/portal"),i=require("primevue/utils"),n=require("primevue/ripple"),s=require("vue");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(e),a=l(t),r={name:"Menuitem",inheritAttrs:!1,emits:["item-click"],props:{item:null,template:null,exact:null,id:null,focusedOptionId:null},methods:{getItemProp:(e,t)=>e&&e.item?i.ObjectUtils.getItemValue(e.item[t]):void 0,onItemActionClick(e,t){t&&t(e)},onItemClick(e){const t=this.getItemProp(this.item,"command");t&&t({originalEvent:e,item:this.item.item}),this.$emit("item-click",{originalEvent:e,item:this.item,id:this.id})},containerClass(){return["p-menuitem",this.item.class,{"p-focus":this.id===this.focusedOptionId,"p-disabled":this.disabled()}]},linkClass(e){return["p-menuitem-link",{"router-link-active":e&&e.isActive,"router-link-active-exact":this.exact&&e&&e.isExactActive}]},visible(){return"function"==typeof this.item.visible?this.item.visible():!1!==this.item.visible},disabled(){return"function"==typeof this.item.disabled?this.item.disabled():this.item.disabled},label(){return"function"==typeof this.item.label?this.item.label():this.item.label}},directives:{ripple:l(n).default}};const d=["id","aria-label","aria-disabled"],c=["href","onClick"],u={class:"p-menuitem-text"},p=["href","target"],m={class:"p-menuitem-text"};r.render=function(e,t,i,n,l,o){const a=s.resolveComponent("router-link"),r=s.resolveDirective("ripple");return o.visible()?(s.openBlock(),s.createElementBlock("li",{key:0,id:i.id,class:s.normalizeClass(o.containerClass()),role:"menuitem",style:s.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[s.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[i.item.to&&!o.disabled()?(s.openBlock(),s.createBlock(a,{key:0,to:i.item.to,custom:""},{default:s.withCtx((({navigate:e,href:t,isActive:n,isExactActive:l})=>[s.withDirectives((s.openBlock(),s.createElementBlock("a",{href:t,class:s.normalizeClass(o.linkClass({isActive:n,isExactActive:l})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",u,s.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):s.withDirectives((s.openBlock(),s.createElementBlock("a",{key:1,href:i.item.url,class:s.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",m,s.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):s.createCommentVNode("",!0)};var h={name:"Menu",inheritAttrs:!1,emits:["show","hide","focus","blur"],props:{popup:{type:Boolean,default:!1},model:{type:Array,default:null},appendTo:{type:String,default:"body"},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:0},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},data:()=>({overlayVisible:!1,focused:!1,focusedOptionIndex:-1,selectedOptionIndex:-1}),target:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,list:null,mounted(){this.popup||(this.bindResizeListener(),this.bindOutsideClickListener())},beforeUnmount(){this.unbindResizeListener(),this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.target=null,this.container&&this.autoZIndex&&i.ZIndexUtils.clear(this.container),this.container=null},methods:{itemClick(e){const t=e.item;this.disabled(t)||(t.command&&t.command(e),t.to&&e.navigate&&e.navigate(e.originalEvent),this.overlayVisible&&this.hide(),this.popup||this.focusedOptionIndex===e.id||(this.focusedOptionIndex=e.id))},onListFocus(e){this.focused=!0,this.popup||(-1!==this.selectedOptionIndex?(this.changeFocusedOptionIndex(this.selectedOptionIndex),this.selectedOptionIndex=-1):this.changeFocusedOptionIndex(0)),this.$emit("focus",e)},onListBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onListKeyDown(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Enter":this.onEnterKey(e);break;case"Space":this.onSpaceKey(e);break;case"Escape":this.popup&&(i.DomHandler.focus(this.target),this.hide());case"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const t=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)i.DomHandler.focus(this.target),this.hide(),e.preventDefault();else{const t=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()}},onHomeKey(e){this.changeFocusedOptionIndex(0),e.preventDefault()},onEndKey(e){this.changeFocusedOptionIndex(i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)").length-1),e.preventDefault()},onEnterKey(e){const t=i.DomHandler.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),n=t&&i.DomHandler.findSingle(t,".p-menuitem-link");this.popup&&i.DomHandler.focus(this.target),n?n.click():t&&t.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t+1:0},findPrevOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t-1:0},changeFocusedOptionIndex(e){const t=i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)");let n=e>=t.length?t.length-1:e<0?0:e;n>-1&&(this.focusedOptionIndex=t[n].getAttribute("id"))},toggle(e){this.overlayVisible?this.hide():this.show(e)},show(e){this.overlayVisible=!0,this.target=e.currentTarget},hide(){this.overlayVisible=!1,this.target=null},onEnter(e){this.alignOverlay(),this.bindOutsideClickListener(),this.bindResizeListener(),this.bindScrollListener(),this.autoZIndex&&i.ZIndexUtils.set("menu",e,this.baseZIndex+this.$primevue.config.zIndex.menu),this.popup&&(i.DomHandler.focus(this.list),this.changeFocusedOptionIndex(0)),this.$emit("show")},onLeave(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.unbindScrollListener(),this.$emit("hide")},onAfterLeave(e){this.autoZIndex&&i.ZIndexUtils.clear(e)},alignOverlay(){i.DomHandler.absolutePosition(this.container,this.target),this.container.style.minWidth=i.DomHandler.getOuterWidth(this.target)+"px"},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.container&&!this.container.contains(e.target),i=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&t&&i?this.hide():!this.popup&&t&&i&&(this.focusedOptionIndex=-1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new i.ConnectedOverlayScrollHandler(this.target,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!i.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},visible:e=>"function"==typeof e.visible?e.visible():!1!==e.visible,disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled,label:e=>"function"==typeof e.label?e.label():e.label,separatorClass:e=>["p-menuitem-separator",e.class],onOverlayClick(e){o.default.emit("overlay-click",{originalEvent:e,target:this.target})},containerRef(e){this.container=e},listRef(e){this.list=e}},computed:{containerClass(){return["p-menu p-component",{"p-menu-overlay":this.popup,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},id(){return this.$attrs.id||i.UniqueComponentId()},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null}},components:{PVMenuitem:r,Portal:a.default}};const b=["id"],f=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],k=["id"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-menu-overlay {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-menu ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menu .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menu .p-menuitem-text {\n line-height: 1;\n}\n"),h.render=function(e,t,i,n,l,o){const a=s.resolveComponent("PVMenuitem"),r=s.resolveComponent("Portal");return s.openBlock(),s.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:s.withCtx((()=>[s.createVNode(s.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:s.withCtx((()=>[!i.popup||l.overlayVisible?(s.openBlock(),s.createElementBlock("div",s.mergeProps({key:0,ref:o.containerRef,id:o.id,class:o.containerClass},e.$attrs,{onClick:t[3]||(t[3]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e))}),[s.createElementVNode("ul",{ref:o.listRef,id:o.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":l.focused?o.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:t[0]||(t[0]=(...e)=>o.onListFocus&&o.onListFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onListBlur&&o.onListBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onListKeyDown&&o.onListKeyDown(...e))},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.model,((t,n)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[t.items?(s.openBlock(),s.createElementBlock("li",{key:0,id:o.id+"_"+n,class:"p-submenu-header",role:"none"},[s.renderSlot(e.$slots,"item",{item:t},(()=>[s.createTextVNode(s.toDisplayString(o.label(t)),1)]))],8,k)):s.createCommentVNode("",!0),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.items,((l,r)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:l.label+n+"_"+r},[o.visible(l)&&!l.separator?(s.openBlock(),s.createBlock(a,{key:0,id:o.id+"_"+n+"_"+r,item:l,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(l)&&l.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n+r,class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(l.style),role:"separator"},null,6)):s.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n.toString(),class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(t.style),role:"separator"},null,6)):(s.openBlock(),s.createBlock(a,{key:o.label(t)+n.toString(),id:o.id+"_"+n,item:t,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,f)],16,b)):s.createCommentVNode("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])},module.exports=h;
|
|
1
|
+
"use strict";var e=require("primevue/overlayeventbus"),t=require("primevue/portal"),i=require("primevue/utils"),n=require("primevue/ripple"),s=require("vue");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(e),a=l(t),r={name:"Menuitem",inheritAttrs:!1,emits:["item-click"],props:{item:null,template:null,exact:null,id:null,focusedOptionId:null},methods:{getItemProp:(e,t)=>e&&e.item?i.ObjectUtils.getItemValue(e.item[t]):void 0,onItemActionClick(e,t){t&&t(e)},onItemClick(e){const t=this.getItemProp(this.item,"command");t&&t({originalEvent:e,item:this.item.item}),this.$emit("item-click",{originalEvent:e,item:this.item,id:this.id})},containerClass(){return["p-menuitem",this.item.class,{"p-focus":this.id===this.focusedOptionId,"p-disabled":this.disabled()}]},linkClass(e){return["p-menuitem-link",{"router-link-active":e&&e.isActive,"router-link-active-exact":this.exact&&e&&e.isExactActive}]},visible(){return"function"==typeof this.item.visible?this.item.visible():!1!==this.item.visible},disabled(){return"function"==typeof this.item.disabled?this.item.disabled():this.item.disabled},label(){return"function"==typeof this.item.label?this.item.label():this.item.label}},directives:{ripple:l(n).default}};const d=["id","aria-label","aria-disabled"],c=["href","onClick"],u={class:"p-menuitem-text"},p=["href","target"],m={class:"p-menuitem-text"};r.render=function(e,t,i,n,l,o){const a=s.resolveComponent("router-link"),r=s.resolveDirective("ripple");return o.visible()?(s.openBlock(),s.createElementBlock("li",{key:0,id:i.id,class:s.normalizeClass(o.containerClass()),role:"menuitem",style:s.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[s.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[i.item.to&&!o.disabled()?(s.openBlock(),s.createBlock(a,{key:0,to:i.item.to,custom:""},{default:s.withCtx((({navigate:e,href:t,isActive:n,isExactActive:l})=>[s.withDirectives((s.openBlock(),s.createElementBlock("a",{href:t,class:s.normalizeClass(o.linkClass({isActive:n,isExactActive:l})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",u,s.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):s.withDirectives((s.openBlock(),s.createElementBlock("a",{key:1,href:i.item.url,class:s.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",m,s.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):s.createCommentVNode("",!0)};var h={name:"Menu",inheritAttrs:!1,emits:["show","hide","focus","blur"],props:{popup:{type:Boolean,default:!1},model:{type:Array,default:null},appendTo:{type:String,default:"body"},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:0},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},data(){return{id:this.$attrs.id,overlayVisible:!1,focused:!1,focusedOptionIndex:-1,selectedOptionIndex:-1}},watch:{"$attrs.id":function(e){this.id=e||i.UniqueComponentId()}},target:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,list:null,mounted(){this.id=this.id||i.UniqueComponentId(),this.popup||(this.bindResizeListener(),this.bindOutsideClickListener())},beforeUnmount(){this.unbindResizeListener(),this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.target=null,this.container&&this.autoZIndex&&i.ZIndexUtils.clear(this.container),this.container=null},methods:{itemClick(e){const t=e.item;this.disabled(t)||(t.command&&t.command(e),t.to&&e.navigate&&e.navigate(e.originalEvent),this.overlayVisible&&this.hide(),this.popup||this.focusedOptionIndex===e.id||(this.focusedOptionIndex=e.id))},onListFocus(e){this.focused=!0,this.popup||(-1!==this.selectedOptionIndex?(this.changeFocusedOptionIndex(this.selectedOptionIndex),this.selectedOptionIndex=-1):this.changeFocusedOptionIndex(0)),this.$emit("focus",e)},onListBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onListKeyDown(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Enter":this.onEnterKey(e);break;case"Space":this.onSpaceKey(e);break;case"Escape":this.popup&&(i.DomHandler.focus(this.target),this.hide());case"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const t=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)i.DomHandler.focus(this.target),this.hide(),e.preventDefault();else{const t=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()}},onHomeKey(e){this.changeFocusedOptionIndex(0),e.preventDefault()},onEndKey(e){this.changeFocusedOptionIndex(i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)").length-1),e.preventDefault()},onEnterKey(e){const t=i.DomHandler.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),n=t&&i.DomHandler.findSingle(t,".p-menuitem-link");this.popup&&i.DomHandler.focus(this.target),n?n.click():t&&t.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t+1:0},findPrevOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t-1:0},changeFocusedOptionIndex(e){const t=i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)");let n=e>=t.length?t.length-1:e<0?0:e;n>-1&&(this.focusedOptionIndex=t[n].getAttribute("id"))},toggle(e){this.overlayVisible?this.hide():this.show(e)},show(e){this.overlayVisible=!0,this.target=e.currentTarget},hide(){this.overlayVisible=!1,this.target=null},onEnter(e){this.alignOverlay(),this.bindOutsideClickListener(),this.bindResizeListener(),this.bindScrollListener(),this.autoZIndex&&i.ZIndexUtils.set("menu",e,this.baseZIndex+this.$primevue.config.zIndex.menu),this.popup&&(i.DomHandler.focus(this.list),this.changeFocusedOptionIndex(0)),this.$emit("show")},onLeave(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.unbindScrollListener(),this.$emit("hide")},onAfterLeave(e){this.autoZIndex&&i.ZIndexUtils.clear(e)},alignOverlay(){i.DomHandler.absolutePosition(this.container,this.target),this.container.style.minWidth=i.DomHandler.getOuterWidth(this.target)+"px"},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.container&&!this.container.contains(e.target),i=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&t&&i?this.hide():!this.popup&&t&&i&&(this.focusedOptionIndex=-1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new i.ConnectedOverlayScrollHandler(this.target,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!i.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},visible:e=>"function"==typeof e.visible?e.visible():!1!==e.visible,disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled,label:e=>"function"==typeof e.label?e.label():e.label,separatorClass:e=>["p-menuitem-separator",e.class],onOverlayClick(e){o.default.emit("overlay-click",{originalEvent:e,target:this.target})},containerRef(e){this.container=e},listRef(e){this.list=e}},computed:{containerClass(){return["p-menu p-component",{"p-menu-overlay":this.popup,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null}},components:{PVMenuitem:r,Portal:a.default}};const b=["id"],f=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],k=["id"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-menu-overlay {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-menu ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menu .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menu .p-menuitem-text {\n line-height: 1;\n}\n"),h.render=function(e,t,i,n,l,o){const a=s.resolveComponent("PVMenuitem"),r=s.resolveComponent("Portal");return s.openBlock(),s.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:s.withCtx((()=>[s.createVNode(s.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:s.withCtx((()=>[!i.popup||l.overlayVisible?(s.openBlock(),s.createElementBlock("div",s.mergeProps({key:0,ref:o.containerRef,id:l.id,class:o.containerClass},e.$attrs,{onClick:t[3]||(t[3]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e))}),[s.createElementVNode("ul",{ref:o.listRef,id:l.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":l.focused?o.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:t[0]||(t[0]=(...e)=>o.onListFocus&&o.onListFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onListBlur&&o.onListBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onListKeyDown&&o.onListKeyDown(...e))},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.model,((t,n)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[t.items?(s.openBlock(),s.createElementBlock("li",{key:0,id:l.id+"_"+n,class:"p-submenu-header",role:"none"},[s.renderSlot(e.$slots,"item",{item:t},(()=>[s.createTextVNode(s.toDisplayString(o.label(t)),1)]))],8,k)):s.createCommentVNode("",!0),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.items,((r,d)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:r.label+n+"_"+d},[o.visible(r)&&!r.separator?(s.openBlock(),s.createBlock(a,{key:0,id:l.id+"_"+n+"_"+d,item:r,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(r)&&r.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n+d,class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(r.style),role:"separator"},null,6)):s.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n.toString(),class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(t.style),role:"separator"},null,6)):(s.openBlock(),s.createBlock(a,{key:o.label(t)+n.toString(),id:l.id+"_"+n,item:t,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,f)],16,b)):s.createCommentVNode("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])},module.exports=h;
|
package/menu/menu.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OverlayEventBus from 'primevue/overlayeventbus';
|
|
2
2
|
import Portal from 'primevue/portal';
|
|
3
|
-
import { ObjectUtils, ZIndexUtils, DomHandler, ConnectedOverlayScrollHandler
|
|
3
|
+
import { ObjectUtils, UniqueComponentId, ZIndexUtils, DomHandler, ConnectedOverlayScrollHandler } from 'primevue/utils';
|
|
4
4
|
import Ripple from 'primevue/ripple';
|
|
5
5
|
import { resolveComponent, resolveDirective, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, Fragment, createBlock, withCtx, withDirectives, createCommentVNode, toDisplayString, resolveDynamicComponent, createVNode, Transition, mergeProps, renderList, renderSlot, createTextVNode } from 'vue';
|
|
6
6
|
|
|
@@ -182,12 +182,18 @@ var script = {
|
|
|
182
182
|
},
|
|
183
183
|
data() {
|
|
184
184
|
return {
|
|
185
|
+
id: this.$attrs.id,
|
|
185
186
|
overlayVisible: false,
|
|
186
187
|
focused: false,
|
|
187
188
|
focusedOptionIndex: -1,
|
|
188
189
|
selectedOptionIndex: -1
|
|
189
190
|
};
|
|
190
191
|
},
|
|
192
|
+
watch: {
|
|
193
|
+
'$attrs.id': function (newValue) {
|
|
194
|
+
this.id = newValue || UniqueComponentId();
|
|
195
|
+
}
|
|
196
|
+
},
|
|
191
197
|
target: null,
|
|
192
198
|
outsideClickListener: null,
|
|
193
199
|
scrollHandler: null,
|
|
@@ -195,6 +201,8 @@ var script = {
|
|
|
195
201
|
container: null,
|
|
196
202
|
list: null,
|
|
197
203
|
mounted() {
|
|
204
|
+
this.id = this.id || UniqueComponentId();
|
|
205
|
+
|
|
198
206
|
if (!this.popup) {
|
|
199
207
|
this.bindResizeListener();
|
|
200
208
|
this.bindOutsideClickListener();
|
|
@@ -484,9 +492,6 @@ var script = {
|
|
|
484
492
|
}
|
|
485
493
|
];
|
|
486
494
|
},
|
|
487
|
-
id() {
|
|
488
|
-
return this.$attrs.id || UniqueComponentId();
|
|
489
|
-
},
|
|
490
495
|
focusedOptionId() {
|
|
491
496
|
return this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : null;
|
|
492
497
|
}
|
|
@@ -521,14 +526,14 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
521
526
|
? (openBlock(), createElementBlock("div", mergeProps({
|
|
522
527
|
key: 0,
|
|
523
528
|
ref: $options.containerRef,
|
|
524
|
-
id: $
|
|
529
|
+
id: $data.id,
|
|
525
530
|
class: $options.containerClass
|
|
526
531
|
}, _ctx.$attrs, {
|
|
527
532
|
onClick: _cache[3] || (_cache[3] = (...args) => ($options.onOverlayClick && $options.onOverlayClick(...args)))
|
|
528
533
|
}), [
|
|
529
534
|
createElementVNode("ul", {
|
|
530
535
|
ref: $options.listRef,
|
|
531
|
-
id: $
|
|
536
|
+
id: $data.id + '_list',
|
|
532
537
|
class: "p-menu-list p-reset",
|
|
533
538
|
role: "menu",
|
|
534
539
|
tabindex: $props.tabindex,
|
|
@@ -548,7 +553,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
548
553
|
(item.items)
|
|
549
554
|
? (openBlock(), createElementBlock("li", {
|
|
550
555
|
key: 0,
|
|
551
|
-
id: $
|
|
556
|
+
id: $data.id + '_' + i,
|
|
552
557
|
class: "p-submenu-header",
|
|
553
558
|
role: "none"
|
|
554
559
|
}, [
|
|
@@ -564,7 +569,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
564
569
|
($options.visible(child) && !child.separator)
|
|
565
570
|
? (openBlock(), createBlock(_component_PVMenuitem, {
|
|
566
571
|
key: 0,
|
|
567
|
-
id: $
|
|
572
|
+
id: $data.id + '_' + i + '_' + j,
|
|
568
573
|
item: child,
|
|
569
574
|
template: _ctx.$slots.item,
|
|
570
575
|
exact: $props.exact,
|
|
@@ -591,7 +596,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
591
596
|
}, null, 6))
|
|
592
597
|
: (openBlock(), createBlock(_component_PVMenuitem, {
|
|
593
598
|
key: $options.label(item) + i.toString(),
|
|
594
|
-
id: $
|
|
599
|
+
id: $data.id + '_' + i,
|
|
595
600
|
item: item,
|
|
596
601
|
template: _ctx.$slots.item,
|
|
597
602
|
exact: $props.exact,
|
package/menu/menu.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"primevue/overlayeventbus";import t from"primevue/portal";import{ObjectUtils as i,ZIndexUtils as n,DomHandler as s,ConnectedOverlayScrollHandler as l,UniqueComponentId as o}from"primevue/utils";import a from"primevue/ripple";import{resolveComponent as r,resolveDirective as d,openBlock as c,createElementBlock as u,normalizeClass as p,normalizeStyle as h,createElementVNode as m,Fragment as b,createBlock as f,withCtx as v,withDirectives as y,createCommentVNode as k,toDisplayString as x,resolveDynamicComponent as g,createVNode as I,Transition as L,mergeProps as O,renderList as C,renderSlot as E,createTextVNode as w}from"vue";var A={name:"Menuitem",inheritAttrs:!1,emits:["item-click"],props:{item:null,template:null,exact:null,id:null,focusedOptionId:null},methods:{getItemProp:(e,t)=>e&&e.item?i.getItemValue(e.item[t]):void 0,onItemActionClick(e,t){t&&t(e)},onItemClick(e){const t=this.getItemProp(this.item,"command");t&&t({originalEvent:e,item:this.item.item}),this.$emit("item-click",{originalEvent:e,item:this.item,id:this.id})},containerClass(){return["p-menuitem",this.item.class,{"p-focus":this.id===this.focusedOptionId,"p-disabled":this.disabled()}]},linkClass(e){return["p-menuitem-link",{"router-link-active":e&&e.isActive,"router-link-active-exact":this.exact&&e&&e.isExactActive}]},visible(){return"function"==typeof this.item.visible?this.item.visible():!1!==this.item.visible},disabled(){return"function"==typeof this.item.disabled?this.item.disabled():this.item.disabled},label(){return"function"==typeof this.item.label?this.item.label():this.item.label}},directives:{ripple:a}};const S=["id","aria-label","aria-disabled"],K=["href","onClick"],z={class:"p-menuitem-text"},$=["href","target"],D={class:"p-menuitem-text"};A.render=function(e,t,i,n,s,l){const o=r("router-link"),a=d("ripple");return l.visible()?(c(),u("li",{key:0,id:i.id,class:p(l.containerClass()),role:"menuitem",style:h(i.item.style),"aria-label":l.label(),"aria-disabled":l.disabled()},[m("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>l.onItemClick(e))},[i.template?(c(),f(g(i.template),{key:1,item:i.item},null,8,["item"])):(c(),u(b,{key:0},[i.item.to&&!l.disabled()?(c(),f(o,{key:0,to:i.item.to,custom:""},{default:v((({navigate:e,href:t,isActive:n,isExactActive:s})=>[y((c(),u("a",{href:t,class:p(l.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:t=>l.onItemActionClick(t,e)},[i.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",i.item.icon])},null,2)):k("",!0),m("span",z,x(l.label()),1)],10,K)),[[a]])])),_:1},8,["to"])):y((c(),u("a",{key:1,href:i.item.url,class:p(l.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",i.item.icon])},null,2)):k("",!0),m("span",D,x(l.label()),1)],10,$)),[[a]])],64))])],14,S)):k("",!0)};var V={name:"Menu",inheritAttrs:!1,emits:["show","hide","focus","blur"],props:{popup:{type:Boolean,default:!1},model:{type:Array,default:null},appendTo:{type:String,default:"body"},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:0},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},data:()=>({overlayVisible:!1,focused:!1,focusedOptionIndex:-1,selectedOptionIndex:-1}),target:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,list:null,mounted(){this.popup||(this.bindResizeListener(),this.bindOutsideClickListener())},beforeUnmount(){this.unbindResizeListener(),this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.target=null,this.container&&this.autoZIndex&&n.clear(this.container),this.container=null},methods:{itemClick(e){const t=e.item;this.disabled(t)||(t.command&&t.command(e),t.to&&e.navigate&&e.navigate(e.originalEvent),this.overlayVisible&&this.hide(),this.popup||this.focusedOptionIndex===e.id||(this.focusedOptionIndex=e.id))},onListFocus(e){this.focused=!0,this.popup||(-1!==this.selectedOptionIndex?(this.changeFocusedOptionIndex(this.selectedOptionIndex),this.selectedOptionIndex=-1):this.changeFocusedOptionIndex(0)),this.$emit("focus",e)},onListBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onListKeyDown(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Enter":this.onEnterKey(e);break;case"Space":this.onSpaceKey(e);break;case"Escape":this.popup&&(s.focus(this.target),this.hide());case"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const t=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)s.focus(this.target),this.hide(),e.preventDefault();else{const t=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()}},onHomeKey(e){this.changeFocusedOptionIndex(0),e.preventDefault()},onEndKey(e){this.changeFocusedOptionIndex(s.find(this.container,"li.p-menuitem:not(.p-disabled)").length-1),e.preventDefault()},onEnterKey(e){const t=s.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),i=t&&s.findSingle(t,".p-menuitem-link");this.popup&&s.focus(this.target),i?i.click():t&&t.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const t=[...s.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t+1:0},findPrevOptionIndex(e){const t=[...s.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t-1:0},changeFocusedOptionIndex(e){const t=s.find(this.container,"li.p-menuitem:not(.p-disabled)");let i=e>=t.length?t.length-1:e<0?0:e;i>-1&&(this.focusedOptionIndex=t[i].getAttribute("id"))},toggle(e){this.overlayVisible?this.hide():this.show(e)},show(e){this.overlayVisible=!0,this.target=e.currentTarget},hide(){this.overlayVisible=!1,this.target=null},onEnter(e){this.alignOverlay(),this.bindOutsideClickListener(),this.bindResizeListener(),this.bindScrollListener(),this.autoZIndex&&n.set("menu",e,this.baseZIndex+this.$primevue.config.zIndex.menu),this.popup&&(s.focus(this.list),this.changeFocusedOptionIndex(0)),this.$emit("show")},onLeave(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.unbindScrollListener(),this.$emit("hide")},onAfterLeave(e){this.autoZIndex&&n.clear(e)},alignOverlay(){s.absolutePosition(this.container,this.target),this.container.style.minWidth=s.getOuterWidth(this.target)+"px"},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.container&&!this.container.contains(e.target),i=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&t&&i?this.hide():!this.popup&&t&&i&&(this.focusedOptionIndex=-1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new l(this.target,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!s.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},visible:e=>"function"==typeof e.visible?e.visible():!1!==e.visible,disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled,label:e=>"function"==typeof e.label?e.label():e.label,separatorClass:e=>["p-menuitem-separator",e.class],onOverlayClick(t){e.emit("overlay-click",{originalEvent:t,target:this.target})},containerRef(e){this.container=e},listRef(e){this.list=e}},computed:{containerClass(){return["p-menu p-component",{"p-menu-overlay":this.popup,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},id(){return this.$attrs.id||o()},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null}},components:{PVMenuitem:A,Portal:t}};const F=["id"],H=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],R=["id"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-menu-overlay {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-menu ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menu .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menu .p-menuitem-text {\n line-height: 1;\n}\n"),V.render=function(e,t,i,n,s,l){const o=r("PVMenuitem"),a=r("Portal");return c(),f(a,{appendTo:i.appendTo,disabled:!i.popup},{default:v((()=>[I(L,{name:"p-connected-overlay",onEnter:l.onEnter,onLeave:l.onLeave,onAfterLeave:l.onAfterLeave},{default:v((()=>[!i.popup||s.overlayVisible?(c(),u("div",O({key:0,ref:l.containerRef,id:l.id,class:l.containerClass},e.$attrs,{onClick:t[3]||(t[3]=(...e)=>l.onOverlayClick&&l.onOverlayClick(...e))}),[m("ul",{ref:l.listRef,id:l.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":s.focused?l.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:t[0]||(t[0]=(...e)=>l.onListFocus&&l.onListFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>l.onListBlur&&l.onListBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>l.onListKeyDown&&l.onListKeyDown(...e))},[(c(!0),u(b,null,C(i.model,((t,n)=>(c(),u(b,{key:l.label(t)+n.toString()},[t.items&&l.visible(t)&&!t.separator?(c(),u(b,{key:0},[t.items?(c(),u("li",{key:0,id:l.id+"_"+n,class:"p-submenu-header",role:"none"},[E(e.$slots,"item",{item:t},(()=>[w(x(l.label(t)),1)]))],8,R)):k("",!0),(c(!0),u(b,null,C(t.items,((s,a)=>(c(),u(b,{key:s.label+n+"_"+a},[l.visible(s)&&!s.separator?(c(),f(o,{key:0,id:l.id+"_"+n+"_"+a,item:s,template:e.$slots.item,exact:i.exact,focusedOptionId:l.focusedOptionId,onItemClick:l.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):l.visible(s)&&s.separator?(c(),u("li",{key:"separator"+n+a,class:p(l.separatorClass(t)),style:h(s.style),role:"separator"},null,6)):k("",!0)],64)))),128))],64)):l.visible(t)&&t.separator?(c(),u("li",{key:"separator"+n.toString(),class:p(l.separatorClass(t)),style:h(t.style),role:"separator"},null,6)):(c(),f(o,{key:l.label(t)+n.toString(),id:l.id+"_"+n,item:t,template:e.$slots.item,exact:i.exact,focusedOptionId:l.focusedOptionId,onItemClick:l.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,H)],16,F)):k("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])};export{V as default};
|
|
1
|
+
import e from"primevue/overlayeventbus";import t from"primevue/portal";import{ObjectUtils as i,UniqueComponentId as n,ZIndexUtils as s,DomHandler as l,ConnectedOverlayScrollHandler as o}from"primevue/utils";import a from"primevue/ripple";import{resolveComponent as r,resolveDirective as d,openBlock as c,createElementBlock as u,normalizeClass as p,normalizeStyle as h,createElementVNode as m,Fragment as b,createBlock as f,withCtx as v,withDirectives as y,createCommentVNode as k,toDisplayString as x,resolveDynamicComponent as g,createVNode as I,Transition as L,mergeProps as O,renderList as C,renderSlot as w,createTextVNode as E}from"vue";var A={name:"Menuitem",inheritAttrs:!1,emits:["item-click"],props:{item:null,template:null,exact:null,id:null,focusedOptionId:null},methods:{getItemProp:(e,t)=>e&&e.item?i.getItemValue(e.item[t]):void 0,onItemActionClick(e,t){t&&t(e)},onItemClick(e){const t=this.getItemProp(this.item,"command");t&&t({originalEvent:e,item:this.item.item}),this.$emit("item-click",{originalEvent:e,item:this.item,id:this.id})},containerClass(){return["p-menuitem",this.item.class,{"p-focus":this.id===this.focusedOptionId,"p-disabled":this.disabled()}]},linkClass(e){return["p-menuitem-link",{"router-link-active":e&&e.isActive,"router-link-active-exact":this.exact&&e&&e.isExactActive}]},visible(){return"function"==typeof this.item.visible?this.item.visible():!1!==this.item.visible},disabled(){return"function"==typeof this.item.disabled?this.item.disabled():this.item.disabled},label(){return"function"==typeof this.item.label?this.item.label():this.item.label}},directives:{ripple:a}};const S=["id","aria-label","aria-disabled"],K=["href","onClick"],z={class:"p-menuitem-text"},$=["href","target"],D={class:"p-menuitem-text"};A.render=function(e,t,i,n,s,l){const o=r("router-link"),a=d("ripple");return l.visible()?(c(),u("li",{key:0,id:i.id,class:p(l.containerClass()),role:"menuitem",style:h(i.item.style),"aria-label":l.label(),"aria-disabled":l.disabled()},[m("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>l.onItemClick(e))},[i.template?(c(),f(g(i.template),{key:1,item:i.item},null,8,["item"])):(c(),u(b,{key:0},[i.item.to&&!l.disabled()?(c(),f(o,{key:0,to:i.item.to,custom:""},{default:v((({navigate:e,href:t,isActive:n,isExactActive:s})=>[y((c(),u("a",{href:t,class:p(l.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:t=>l.onItemActionClick(t,e)},[i.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",i.item.icon])},null,2)):k("",!0),m("span",z,x(l.label()),1)],10,K)),[[a]])])),_:1},8,["to"])):y((c(),u("a",{key:1,href:i.item.url,class:p(l.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",i.item.icon])},null,2)):k("",!0),m("span",D,x(l.label()),1)],10,$)),[[a]])],64))])],14,S)):k("",!0)};var V={name:"Menu",inheritAttrs:!1,emits:["show","hide","focus","blur"],props:{popup:{type:Boolean,default:!1},model:{type:Array,default:null},appendTo:{type:String,default:"body"},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:0},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},data(){return{id:this.$attrs.id,overlayVisible:!1,focused:!1,focusedOptionIndex:-1,selectedOptionIndex:-1}},watch:{"$attrs.id":function(e){this.id=e||n()}},target:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,list:null,mounted(){this.id=this.id||n(),this.popup||(this.bindResizeListener(),this.bindOutsideClickListener())},beforeUnmount(){this.unbindResizeListener(),this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.target=null,this.container&&this.autoZIndex&&s.clear(this.container),this.container=null},methods:{itemClick(e){const t=e.item;this.disabled(t)||(t.command&&t.command(e),t.to&&e.navigate&&e.navigate(e.originalEvent),this.overlayVisible&&this.hide(),this.popup||this.focusedOptionIndex===e.id||(this.focusedOptionIndex=e.id))},onListFocus(e){this.focused=!0,this.popup||(-1!==this.selectedOptionIndex?(this.changeFocusedOptionIndex(this.selectedOptionIndex),this.selectedOptionIndex=-1):this.changeFocusedOptionIndex(0)),this.$emit("focus",e)},onListBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onListKeyDown(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Enter":this.onEnterKey(e);break;case"Space":this.onSpaceKey(e);break;case"Escape":this.popup&&(l.focus(this.target),this.hide());case"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const t=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)l.focus(this.target),this.hide(),e.preventDefault();else{const t=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()}},onHomeKey(e){this.changeFocusedOptionIndex(0),e.preventDefault()},onEndKey(e){this.changeFocusedOptionIndex(l.find(this.container,"li.p-menuitem:not(.p-disabled)").length-1),e.preventDefault()},onEnterKey(e){const t=l.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),i=t&&l.findSingle(t,".p-menuitem-link");this.popup&&l.focus(this.target),i?i.click():t&&t.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const t=[...l.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t+1:0},findPrevOptionIndex(e){const t=[...l.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t-1:0},changeFocusedOptionIndex(e){const t=l.find(this.container,"li.p-menuitem:not(.p-disabled)");let i=e>=t.length?t.length-1:e<0?0:e;i>-1&&(this.focusedOptionIndex=t[i].getAttribute("id"))},toggle(e){this.overlayVisible?this.hide():this.show(e)},show(e){this.overlayVisible=!0,this.target=e.currentTarget},hide(){this.overlayVisible=!1,this.target=null},onEnter(e){this.alignOverlay(),this.bindOutsideClickListener(),this.bindResizeListener(),this.bindScrollListener(),this.autoZIndex&&s.set("menu",e,this.baseZIndex+this.$primevue.config.zIndex.menu),this.popup&&(l.focus(this.list),this.changeFocusedOptionIndex(0)),this.$emit("show")},onLeave(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.unbindScrollListener(),this.$emit("hide")},onAfterLeave(e){this.autoZIndex&&s.clear(e)},alignOverlay(){l.absolutePosition(this.container,this.target),this.container.style.minWidth=l.getOuterWidth(this.target)+"px"},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.container&&!this.container.contains(e.target),i=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&t&&i?this.hide():!this.popup&&t&&i&&(this.focusedOptionIndex=-1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new o(this.target,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!l.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},visible:e=>"function"==typeof e.visible?e.visible():!1!==e.visible,disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled,label:e=>"function"==typeof e.label?e.label():e.label,separatorClass:e=>["p-menuitem-separator",e.class],onOverlayClick(t){e.emit("overlay-click",{originalEvent:t,target:this.target})},containerRef(e){this.container=e},listRef(e){this.list=e}},computed:{containerClass(){return["p-menu p-component",{"p-menu-overlay":this.popup,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null}},components:{PVMenuitem:A,Portal:t}};const F=["id"],H=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],R=["id"];!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-menu-overlay {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-menu ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menu .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menu .p-menuitem-text {\n line-height: 1;\n}\n"),V.render=function(e,t,i,n,s,l){const o=r("PVMenuitem"),a=r("Portal");return c(),f(a,{appendTo:i.appendTo,disabled:!i.popup},{default:v((()=>[I(L,{name:"p-connected-overlay",onEnter:l.onEnter,onLeave:l.onLeave,onAfterLeave:l.onAfterLeave},{default:v((()=>[!i.popup||s.overlayVisible?(c(),u("div",O({key:0,ref:l.containerRef,id:s.id,class:l.containerClass},e.$attrs,{onClick:t[3]||(t[3]=(...e)=>l.onOverlayClick&&l.onOverlayClick(...e))}),[m("ul",{ref:l.listRef,id:s.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":s.focused?l.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:t[0]||(t[0]=(...e)=>l.onListFocus&&l.onListFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>l.onListBlur&&l.onListBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>l.onListKeyDown&&l.onListKeyDown(...e))},[(c(!0),u(b,null,C(i.model,((t,n)=>(c(),u(b,{key:l.label(t)+n.toString()},[t.items&&l.visible(t)&&!t.separator?(c(),u(b,{key:0},[t.items?(c(),u("li",{key:0,id:s.id+"_"+n,class:"p-submenu-header",role:"none"},[w(e.$slots,"item",{item:t},(()=>[E(x(l.label(t)),1)]))],8,R)):k("",!0),(c(!0),u(b,null,C(t.items,((a,r)=>(c(),u(b,{key:a.label+n+"_"+r},[l.visible(a)&&!a.separator?(c(),f(o,{key:0,id:s.id+"_"+n+"_"+r,item:a,template:e.$slots.item,exact:i.exact,focusedOptionId:l.focusedOptionId,onItemClick:l.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):l.visible(a)&&a.separator?(c(),u("li",{key:"separator"+n+r,class:p(l.separatorClass(t)),style:h(a.style),role:"separator"},null,6)):k("",!0)],64)))),128))],64)):l.visible(t)&&t.separator?(c(),u("li",{key:"separator"+n.toString(),class:p(l.separatorClass(t)),style:h(t.style),role:"separator"},null,6)):(c(),f(o,{key:l.label(t)+n.toString(),id:s.id+"_"+n,item:t,template:e.$slots.item,exact:i.exact,focusedOptionId:l.focusedOptionId,onItemClick:l.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,H)],16,F)):k("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])};export{V as default};
|
package/menu/menu.js
CHANGED
|
@@ -186,12 +186,18 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
186
186
|
},
|
|
187
187
|
data() {
|
|
188
188
|
return {
|
|
189
|
+
id: this.$attrs.id,
|
|
189
190
|
overlayVisible: false,
|
|
190
191
|
focused: false,
|
|
191
192
|
focusedOptionIndex: -1,
|
|
192
193
|
selectedOptionIndex: -1
|
|
193
194
|
};
|
|
194
195
|
},
|
|
196
|
+
watch: {
|
|
197
|
+
'$attrs.id': function (newValue) {
|
|
198
|
+
this.id = newValue || utils.UniqueComponentId();
|
|
199
|
+
}
|
|
200
|
+
},
|
|
195
201
|
target: null,
|
|
196
202
|
outsideClickListener: null,
|
|
197
203
|
scrollHandler: null,
|
|
@@ -199,6 +205,8 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
199
205
|
container: null,
|
|
200
206
|
list: null,
|
|
201
207
|
mounted() {
|
|
208
|
+
this.id = this.id || utils.UniqueComponentId();
|
|
209
|
+
|
|
202
210
|
if (!this.popup) {
|
|
203
211
|
this.bindResizeListener();
|
|
204
212
|
this.bindOutsideClickListener();
|
|
@@ -488,9 +496,6 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
488
496
|
}
|
|
489
497
|
];
|
|
490
498
|
},
|
|
491
|
-
id() {
|
|
492
|
-
return this.$attrs.id || utils.UniqueComponentId();
|
|
493
|
-
},
|
|
494
499
|
focusedOptionId() {
|
|
495
500
|
return this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : null;
|
|
496
501
|
}
|
|
@@ -525,14 +530,14 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
525
530
|
? (vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({
|
|
526
531
|
key: 0,
|
|
527
532
|
ref: $options.containerRef,
|
|
528
|
-
id: $
|
|
533
|
+
id: $data.id,
|
|
529
534
|
class: $options.containerClass
|
|
530
535
|
}, _ctx.$attrs, {
|
|
531
536
|
onClick: _cache[3] || (_cache[3] = (...args) => ($options.onOverlayClick && $options.onOverlayClick(...args)))
|
|
532
537
|
}), [
|
|
533
538
|
vue.createElementVNode("ul", {
|
|
534
539
|
ref: $options.listRef,
|
|
535
|
-
id: $
|
|
540
|
+
id: $data.id + '_list',
|
|
536
541
|
class: "p-menu-list p-reset",
|
|
537
542
|
role: "menu",
|
|
538
543
|
tabindex: $props.tabindex,
|
|
@@ -552,7 +557,7 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
552
557
|
(item.items)
|
|
553
558
|
? (vue.openBlock(), vue.createElementBlock("li", {
|
|
554
559
|
key: 0,
|
|
555
|
-
id: $
|
|
560
|
+
id: $data.id + '_' + i,
|
|
556
561
|
class: "p-submenu-header",
|
|
557
562
|
role: "none"
|
|
558
563
|
}, [
|
|
@@ -568,7 +573,7 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
568
573
|
($options.visible(child) && !child.separator)
|
|
569
574
|
? (vue.openBlock(), vue.createBlock(_component_PVMenuitem, {
|
|
570
575
|
key: 0,
|
|
571
|
-
id: $
|
|
576
|
+
id: $data.id + '_' + i + '_' + j,
|
|
572
577
|
item: child,
|
|
573
578
|
template: _ctx.$slots.item,
|
|
574
579
|
exact: $props.exact,
|
|
@@ -595,7 +600,7 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
595
600
|
}, null, 6))
|
|
596
601
|
: (vue.openBlock(), vue.createBlock(_component_PVMenuitem, {
|
|
597
602
|
key: $options.label(item) + i.toString(),
|
|
598
|
-
id: $
|
|
603
|
+
id: $data.id + '_' + i,
|
|
599
604
|
item: item,
|
|
600
605
|
template: _ctx.$slots.item,
|
|
601
606
|
exact: $props.exact,
|
package/menu/menu.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.menu=function(e,t,i,n,s){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(e),a=l(t),r={name:"Menuitem",inheritAttrs:!1,emits:["item-click"],props:{item:null,template:null,exact:null,id:null,focusedOptionId:null},methods:{getItemProp:(e,t)=>e&&e.item?i.ObjectUtils.getItemValue(e.item[t]):void 0,onItemActionClick(e,t){t&&t(e)},onItemClick(e){const t=this.getItemProp(this.item,"command");t&&t({originalEvent:e,item:this.item.item}),this.$emit("item-click",{originalEvent:e,item:this.item,id:this.id})},containerClass(){return["p-menuitem",this.item.class,{"p-focus":this.id===this.focusedOptionId,"p-disabled":this.disabled()}]},linkClass(e){return["p-menuitem-link",{"router-link-active":e&&e.isActive,"router-link-active-exact":this.exact&&e&&e.isExactActive}]},visible(){return"function"==typeof this.item.visible?this.item.visible():!1!==this.item.visible},disabled(){return"function"==typeof this.item.disabled?this.item.disabled():this.item.disabled},label(){return"function"==typeof this.item.label?this.item.label():this.item.label}},directives:{ripple:l(n).default}};const d=["id","aria-label","aria-disabled"],c=["href","onClick"],u={class:"p-menuitem-text"},p=["href","target"],m={class:"p-menuitem-text"};r.render=function(e,t,i,n,l,o){const a=s.resolveComponent("router-link"),r=s.resolveDirective("ripple");return o.visible()?(s.openBlock(),s.createElementBlock("li",{key:0,id:i.id,class:s.normalizeClass(o.containerClass()),role:"menuitem",style:s.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[s.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[i.item.to&&!o.disabled()?(s.openBlock(),s.createBlock(a,{key:0,to:i.item.to,custom:""},{default:s.withCtx((({navigate:e,href:t,isActive:n,isExactActive:l})=>[s.withDirectives((s.openBlock(),s.createElementBlock("a",{href:t,class:s.normalizeClass(o.linkClass({isActive:n,isExactActive:l})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",u,s.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):s.withDirectives((s.openBlock(),s.createElementBlock("a",{key:1,href:i.item.url,class:s.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",m,s.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):s.createCommentVNode("",!0)};var h={name:"Menu",inheritAttrs:!1,emits:["show","hide","focus","blur"],props:{popup:{type:Boolean,default:!1},model:{type:Array,default:null},appendTo:{type:String,default:"body"},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:0},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},data:()=>({overlayVisible:!1,focused:!1,focusedOptionIndex:-1,selectedOptionIndex:-1}),target:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,list:null,mounted(){this.popup||(this.bindResizeListener(),this.bindOutsideClickListener())},beforeUnmount(){this.unbindResizeListener(),this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.target=null,this.container&&this.autoZIndex&&i.ZIndexUtils.clear(this.container),this.container=null},methods:{itemClick(e){const t=e.item;this.disabled(t)||(t.command&&t.command(e),t.to&&e.navigate&&e.navigate(e.originalEvent),this.overlayVisible&&this.hide(),this.popup||this.focusedOptionIndex===e.id||(this.focusedOptionIndex=e.id))},onListFocus(e){this.focused=!0,this.popup||(-1!==this.selectedOptionIndex?(this.changeFocusedOptionIndex(this.selectedOptionIndex),this.selectedOptionIndex=-1):this.changeFocusedOptionIndex(0)),this.$emit("focus",e)},onListBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onListKeyDown(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Enter":this.onEnterKey(e);break;case"Space":this.onSpaceKey(e);break;case"Escape":this.popup&&(i.DomHandler.focus(this.target),this.hide());case"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const t=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)i.DomHandler.focus(this.target),this.hide(),e.preventDefault();else{const t=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()}},onHomeKey(e){this.changeFocusedOptionIndex(0),e.preventDefault()},onEndKey(e){this.changeFocusedOptionIndex(i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)").length-1),e.preventDefault()},onEnterKey(e){const t=i.DomHandler.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),n=t&&i.DomHandler.findSingle(t,".p-menuitem-link");this.popup&&i.DomHandler.focus(this.target),n?n.click():t&&t.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t+1:0},findPrevOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t-1:0},changeFocusedOptionIndex(e){const t=i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)");let n=e>=t.length?t.length-1:e<0?0:e;n>-1&&(this.focusedOptionIndex=t[n].getAttribute("id"))},toggle(e){this.overlayVisible?this.hide():this.show(e)},show(e){this.overlayVisible=!0,this.target=e.currentTarget},hide(){this.overlayVisible=!1,this.target=null},onEnter(e){this.alignOverlay(),this.bindOutsideClickListener(),this.bindResizeListener(),this.bindScrollListener(),this.autoZIndex&&i.ZIndexUtils.set("menu",e,this.baseZIndex+this.$primevue.config.zIndex.menu),this.popup&&(i.DomHandler.focus(this.list),this.changeFocusedOptionIndex(0)),this.$emit("show")},onLeave(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.unbindScrollListener(),this.$emit("hide")},onAfterLeave(e){this.autoZIndex&&i.ZIndexUtils.clear(e)},alignOverlay(){i.DomHandler.absolutePosition(this.container,this.target),this.container.style.minWidth=i.DomHandler.getOuterWidth(this.target)+"px"},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.container&&!this.container.contains(e.target),i=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&t&&i?this.hide():!this.popup&&t&&i&&(this.focusedOptionIndex=-1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new i.ConnectedOverlayScrollHandler(this.target,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!i.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},visible:e=>"function"==typeof e.visible?e.visible():!1!==e.visible,disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled,label:e=>"function"==typeof e.label?e.label():e.label,separatorClass:e=>["p-menuitem-separator",e.class],onOverlayClick(e){o.default.emit("overlay-click",{originalEvent:e,target:this.target})},containerRef(e){this.container=e},listRef(e){this.list=e}},computed:{containerClass(){return["p-menu p-component",{"p-menu-overlay":this.popup,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},id(){return this.$attrs.id||i.UniqueComponentId()},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null}},components:{PVMenuitem:r,Portal:a.default}};const b=["id"],f=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],k=["id"];return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-menu-overlay {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-menu ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menu .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menu .p-menuitem-text {\n line-height: 1;\n}\n"),h.render=function(e,t,i,n,l,o){const a=s.resolveComponent("PVMenuitem"),r=s.resolveComponent("Portal");return s.openBlock(),s.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:s.withCtx((()=>[s.createVNode(s.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:s.withCtx((()=>[!i.popup||l.overlayVisible?(s.openBlock(),s.createElementBlock("div",s.mergeProps({key:0,ref:o.containerRef,id:o.id,class:o.containerClass},e.$attrs,{onClick:t[3]||(t[3]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e))}),[s.createElementVNode("ul",{ref:o.listRef,id:o.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":l.focused?o.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:t[0]||(t[0]=(...e)=>o.onListFocus&&o.onListFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onListBlur&&o.onListBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onListKeyDown&&o.onListKeyDown(...e))},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.model,((t,n)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[t.items?(s.openBlock(),s.createElementBlock("li",{key:0,id:o.id+"_"+n,class:"p-submenu-header",role:"none"},[s.renderSlot(e.$slots,"item",{item:t},(()=>[s.createTextVNode(s.toDisplayString(o.label(t)),1)]))],8,k)):s.createCommentVNode("",!0),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.items,((l,r)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:l.label+n+"_"+r},[o.visible(l)&&!l.separator?(s.openBlock(),s.createBlock(a,{key:0,id:o.id+"_"+n+"_"+r,item:l,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(l)&&l.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n+r,class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(l.style),role:"separator"},null,6)):s.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n.toString(),class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(t.style),role:"separator"},null,6)):(s.openBlock(),s.createBlock(a,{key:o.label(t)+n.toString(),id:o.id+"_"+n,item:t,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,f)],16,b)):s.createCommentVNode("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])},h}(primevue.overlayeventbus,primevue.portal,primevue.utils,primevue.ripple,Vue);
|
|
1
|
+
this.primevue=this.primevue||{},this.primevue.menu=function(e,t,i,n,s){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(e),a=l(t),r={name:"Menuitem",inheritAttrs:!1,emits:["item-click"],props:{item:null,template:null,exact:null,id:null,focusedOptionId:null},methods:{getItemProp:(e,t)=>e&&e.item?i.ObjectUtils.getItemValue(e.item[t]):void 0,onItemActionClick(e,t){t&&t(e)},onItemClick(e){const t=this.getItemProp(this.item,"command");t&&t({originalEvent:e,item:this.item.item}),this.$emit("item-click",{originalEvent:e,item:this.item,id:this.id})},containerClass(){return["p-menuitem",this.item.class,{"p-focus":this.id===this.focusedOptionId,"p-disabled":this.disabled()}]},linkClass(e){return["p-menuitem-link",{"router-link-active":e&&e.isActive,"router-link-active-exact":this.exact&&e&&e.isExactActive}]},visible(){return"function"==typeof this.item.visible?this.item.visible():!1!==this.item.visible},disabled(){return"function"==typeof this.item.disabled?this.item.disabled():this.item.disabled},label(){return"function"==typeof this.item.label?this.item.label():this.item.label}},directives:{ripple:l(n).default}};const d=["id","aria-label","aria-disabled"],c=["href","onClick"],u={class:"p-menuitem-text"},p=["href","target"],m={class:"p-menuitem-text"};r.render=function(e,t,i,n,l,o){const a=s.resolveComponent("router-link"),r=s.resolveDirective("ripple");return o.visible()?(s.openBlock(),s.createElementBlock("li",{key:0,id:i.id,class:s.normalizeClass(o.containerClass()),role:"menuitem",style:s.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[s.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[i.item.to&&!o.disabled()?(s.openBlock(),s.createBlock(a,{key:0,to:i.item.to,custom:""},{default:s.withCtx((({navigate:e,href:t,isActive:n,isExactActive:l})=>[s.withDirectives((s.openBlock(),s.createElementBlock("a",{href:t,class:s.normalizeClass(o.linkClass({isActive:n,isExactActive:l})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",u,s.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):s.withDirectives((s.openBlock(),s.createElementBlock("a",{key:1,href:i.item.url,class:s.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",m,s.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):s.createCommentVNode("",!0)};var h={name:"Menu",inheritAttrs:!1,emits:["show","hide","focus","blur"],props:{popup:{type:Boolean,default:!1},model:{type:Array,default:null},appendTo:{type:String,default:"body"},autoZIndex:{type:Boolean,default:!0},baseZIndex:{type:Number,default:0},exact:{type:Boolean,default:!0},tabindex:{type:Number,default:0},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},data(){return{id:this.$attrs.id,overlayVisible:!1,focused:!1,focusedOptionIndex:-1,selectedOptionIndex:-1}},watch:{"$attrs.id":function(e){this.id=e||i.UniqueComponentId()}},target:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,list:null,mounted(){this.id=this.id||i.UniqueComponentId(),this.popup||(this.bindResizeListener(),this.bindOutsideClickListener())},beforeUnmount(){this.unbindResizeListener(),this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.target=null,this.container&&this.autoZIndex&&i.ZIndexUtils.clear(this.container),this.container=null},methods:{itemClick(e){const t=e.item;this.disabled(t)||(t.command&&t.command(e),t.to&&e.navigate&&e.navigate(e.originalEvent),this.overlayVisible&&this.hide(),this.popup||this.focusedOptionIndex===e.id||(this.focusedOptionIndex=e.id))},onListFocus(e){this.focused=!0,this.popup||(-1!==this.selectedOptionIndex?(this.changeFocusedOptionIndex(this.selectedOptionIndex),this.selectedOptionIndex=-1):this.changeFocusedOptionIndex(0)),this.$emit("focus",e)},onListBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onListKeyDown(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Enter":this.onEnterKey(e);break;case"Space":this.onSpaceKey(e);break;case"Escape":this.popup&&(i.DomHandler.focus(this.target),this.hide());case"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const t=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)i.DomHandler.focus(this.target),this.hide(),e.preventDefault();else{const t=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(t),e.preventDefault()}},onHomeKey(e){this.changeFocusedOptionIndex(0),e.preventDefault()},onEndKey(e){this.changeFocusedOptionIndex(i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)").length-1),e.preventDefault()},onEnterKey(e){const t=i.DomHandler.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),n=t&&i.DomHandler.findSingle(t,".p-menuitem-link");this.popup&&i.DomHandler.focus(this.target),n?n.click():t&&t.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t+1:0},findPrevOptionIndex(e){const t=[...i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((t=>t.id===e));return t>-1?t-1:0},changeFocusedOptionIndex(e){const t=i.DomHandler.find(this.container,"li.p-menuitem:not(.p-disabled)");let n=e>=t.length?t.length-1:e<0?0:e;n>-1&&(this.focusedOptionIndex=t[n].getAttribute("id"))},toggle(e){this.overlayVisible?this.hide():this.show(e)},show(e){this.overlayVisible=!0,this.target=e.currentTarget},hide(){this.overlayVisible=!1,this.target=null},onEnter(e){this.alignOverlay(),this.bindOutsideClickListener(),this.bindResizeListener(),this.bindScrollListener(),this.autoZIndex&&i.ZIndexUtils.set("menu",e,this.baseZIndex+this.$primevue.config.zIndex.menu),this.popup&&(i.DomHandler.focus(this.list),this.changeFocusedOptionIndex(0)),this.$emit("show")},onLeave(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.unbindScrollListener(),this.$emit("hide")},onAfterLeave(e){this.autoZIndex&&i.ZIndexUtils.clear(e)},alignOverlay(){i.DomHandler.absolutePosition(this.container,this.target),this.container.style.minWidth=i.DomHandler.getOuterWidth(this.target)+"px"},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.container&&!this.container.contains(e.target),i=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&t&&i?this.hide():!this.popup&&t&&i&&(this.focusedOptionIndex=-1)},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new i.ConnectedOverlayScrollHandler(this.target,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!i.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},visible:e=>"function"==typeof e.visible?e.visible():!1!==e.visible,disabled:e=>"function"==typeof e.disabled?e.disabled():e.disabled,label:e=>"function"==typeof e.label?e.label():e.label,separatorClass:e=>["p-menuitem-separator",e.class],onOverlayClick(e){o.default.emit("overlay-click",{originalEvent:e,target:this.target})},containerRef(e){this.container=e},listRef(e){this.list=e}},computed:{containerClass(){return["p-menu p-component",{"p-menu-overlay":this.popup,"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null}},components:{PVMenuitem:r,Portal:a.default}};const b=["id"],f=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],k=["id"];return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-menu-overlay {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-menu ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menu .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menu .p-menuitem-text {\n line-height: 1;\n}\n"),h.render=function(e,t,i,n,l,o){const a=s.resolveComponent("PVMenuitem"),r=s.resolveComponent("Portal");return s.openBlock(),s.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:s.withCtx((()=>[s.createVNode(s.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:s.withCtx((()=>[!i.popup||l.overlayVisible?(s.openBlock(),s.createElementBlock("div",s.mergeProps({key:0,ref:o.containerRef,id:l.id,class:o.containerClass},e.$attrs,{onClick:t[3]||(t[3]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e))}),[s.createElementVNode("ul",{ref:o.listRef,id:l.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":l.focused?o.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:t[0]||(t[0]=(...e)=>o.onListFocus&&o.onListFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onListBlur&&o.onListBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onListKeyDown&&o.onListKeyDown(...e))},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.model,((t,n)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[t.items?(s.openBlock(),s.createElementBlock("li",{key:0,id:l.id+"_"+n,class:"p-submenu-header",role:"none"},[s.renderSlot(e.$slots,"item",{item:t},(()=>[s.createTextVNode(s.toDisplayString(o.label(t)),1)]))],8,k)):s.createCommentVNode("",!0),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.items,((r,d)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:r.label+n+"_"+d},[o.visible(r)&&!r.separator?(s.openBlock(),s.createBlock(a,{key:0,id:l.id+"_"+n+"_"+d,item:r,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(r)&&r.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n+d,class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(r.style),role:"separator"},null,6)):s.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(s.openBlock(),s.createElementBlock("li",{key:"separator"+n.toString(),class:s.normalizeClass(o.separatorClass(t)),style:s.normalizeStyle(t.style),role:"separator"},null,6)):(s.openBlock(),s.createBlock(a,{key:o.label(t)+n.toString(),id:l.id+"_"+n,item:t,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,f)],16,b)):s.createCommentVNode("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])},h}(primevue.overlayeventbus,primevue.portal,primevue.utils,primevue.ripple,Vue);
|
package/menubar/Menubar.vue
CHANGED
|
@@ -80,6 +80,7 @@ export default {
|
|
|
80
80
|
},
|
|
81
81
|
data() {
|
|
82
82
|
return {
|
|
83
|
+
id: this.$attrs.id,
|
|
83
84
|
mobileActive: false,
|
|
84
85
|
focused: false,
|
|
85
86
|
focusedItemInfo: { index: -1, level: 0, parentKey: '' },
|
|
@@ -88,6 +89,9 @@ export default {
|
|
|
88
89
|
};
|
|
89
90
|
},
|
|
90
91
|
watch: {
|
|
92
|
+
'$attrs.id': function (newValue) {
|
|
93
|
+
this.id = newValue || UniqueComponentId();
|
|
94
|
+
},
|
|
91
95
|
activeItemPath(newPath) {
|
|
92
96
|
if (ObjectUtils.isNotEmpty(newPath)) {
|
|
93
97
|
this.bindOutsideClickListener();
|
|
@@ -101,6 +105,9 @@ export default {
|
|
|
101
105
|
outsideClickListener: null,
|
|
102
106
|
container: null,
|
|
103
107
|
menubar: null,
|
|
108
|
+
mounted() {
|
|
109
|
+
this.id = this.id || UniqueComponentId();
|
|
110
|
+
},
|
|
104
111
|
beforeUnmount() {
|
|
105
112
|
this.mobileActive = false;
|
|
106
113
|
this.unbindOutsideClickListener();
|
|
@@ -593,9 +600,6 @@ export default {
|
|
|
593
600
|
|
|
594
601
|
return processedItem ? processedItem.items : this.processedItems;
|
|
595
602
|
},
|
|
596
|
-
id() {
|
|
597
|
-
return this.$attrs.id || UniqueComponentId();
|
|
598
|
-
},
|
|
599
603
|
focusedItemId() {
|
|
600
604
|
return this.focusedItemInfo.index !== -1 ? `${this.id}${ObjectUtils.isNotEmpty(this.focusedItemInfo.parentKey) ? '_' + this.focusedItemInfo.parentKey : ''}_${this.focusedItemInfo.index}` : null;
|
|
601
605
|
}
|
package/menubar/menubar.cjs.js
CHANGED
|
@@ -297,6 +297,7 @@ var script = {
|
|
|
297
297
|
},
|
|
298
298
|
data() {
|
|
299
299
|
return {
|
|
300
|
+
id: this.$attrs.id,
|
|
300
301
|
mobileActive: false,
|
|
301
302
|
focused: false,
|
|
302
303
|
focusedItemInfo: { index: -1, level: 0, parentKey: '' },
|
|
@@ -305,6 +306,9 @@ var script = {
|
|
|
305
306
|
};
|
|
306
307
|
},
|
|
307
308
|
watch: {
|
|
309
|
+
'$attrs.id': function (newValue) {
|
|
310
|
+
this.id = newValue || utils.UniqueComponentId();
|
|
311
|
+
},
|
|
308
312
|
activeItemPath(newPath) {
|
|
309
313
|
if (utils.ObjectUtils.isNotEmpty(newPath)) {
|
|
310
314
|
this.bindOutsideClickListener();
|
|
@@ -318,6 +322,9 @@ var script = {
|
|
|
318
322
|
outsideClickListener: null,
|
|
319
323
|
container: null,
|
|
320
324
|
menubar: null,
|
|
325
|
+
mounted() {
|
|
326
|
+
this.id = this.id || utils.UniqueComponentId();
|
|
327
|
+
},
|
|
321
328
|
beforeUnmount() {
|
|
322
329
|
this.mobileActive = false;
|
|
323
330
|
this.unbindOutsideClickListener();
|
|
@@ -810,9 +817,6 @@ var script = {
|
|
|
810
817
|
|
|
811
818
|
return processedItem ? processedItem.items : this.processedItems;
|
|
812
819
|
},
|
|
813
|
-
id() {
|
|
814
|
-
return this.$attrs.id || utils.UniqueComponentId();
|
|
815
|
-
},
|
|
816
820
|
focusedItemId() {
|
|
817
821
|
return this.focusedItemInfo.index !== -1 ? `${this.id}${utils.ObjectUtils.isNotEmpty(this.focusedItemInfo.parentKey) ? '_' + this.focusedItemInfo.parentKey : ''}_${this.focusedItemInfo.index}` : null;
|
|
818
822
|
}
|
|
@@ -857,7 +861,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
857
861
|
class: "p-menubar-button",
|
|
858
862
|
"aria-haspopup": $props.model.length && $props.model.length > 0 ? true : false,
|
|
859
863
|
"aria-expanded": $data.mobileActive,
|
|
860
|
-
"aria-controls": $
|
|
864
|
+
"aria-controls": $data.id,
|
|
861
865
|
"aria-label": _ctx.$primevue.config.locale.aria.navigation,
|
|
862
866
|
onClick: _cache[0] || (_cache[0] = $event => ($options.menuButtonClick($event))),
|
|
863
867
|
onKeydown: _cache[1] || (_cache[1] = $event => ($options.menuButtonKeydown($event)))
|
|
@@ -865,7 +869,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
865
869
|
: vue.createCommentVNode("", true),
|
|
866
870
|
vue.createVNode(_component_MenubarSub, {
|
|
867
871
|
ref: $options.menubarRef,
|
|
868
|
-
id: $
|
|
872
|
+
id: $data.id,
|
|
869
873
|
class: "p-menubar-root-list",
|
|
870
874
|
role: "menubar",
|
|
871
875
|
items: $options.processedItems,
|
|
@@ -874,7 +878,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
874
878
|
mobileActive: $data.mobileActive,
|
|
875
879
|
tabindex: "0",
|
|
876
880
|
"aria-activedescendant": $data.focused ? $options.focusedItemId : undefined,
|
|
877
|
-
menuId: $
|
|
881
|
+
menuId: $data.id,
|
|
878
882
|
focusedItemId: $data.focused ? $options.focusedItemId : undefined,
|
|
879
883
|
activeItemPath: $data.activeItemPath,
|
|
880
884
|
exact: $props.exact,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("primevue/utils"),t=require("primevue/ripple"),i=require("vue");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n={name:"MenubarSub",emits:["item-mouseenter","item-click"],props:{items:{type:Array,default:null},root:{type:Boolean,default:!1},popup:{type:Boolean,default:!1},mobileActive:{type:Boolean,default:!1},template:{type:Function,default:null},exact:{type:Boolean,default:!0},level:{type:Number,default:0},menuId:{type:String,default:null},focusedItemId:{type:String,default:null},activeItemPath:{type:Object,default:null}},list:null,methods:{getItemId(e){return`${this.menuId}_${e.key}`},getItemKey(e){return this.getItemId(e)},getItemProp:(t,i,s)=>t&&t.item?e.ObjectUtils.getItemValue(t.item[i],s):void 0,getItemLabel(e){return this.getItemProp(e,"label")},isItemActive(e){return this.activeItemPath.some((t=>t.key===e.key))},isItemVisible(e){return!1!==this.getItemProp(e,"visible")},isItemDisabled(e){return this.getItemProp(e,"disabled")},isItemFocused(e){return this.focusedItemId===this.getItemId(e)},isItemGroup:t=>e.ObjectUtils.isNotEmpty(t.items),onItemClick(e,t){this.getItemProp(t,"command",{originalEvent:e,item:t.item}),this.$emit("item-click",{originalEvent:e,processedItem:t,isFocus:!0})},onItemMouseEnter(e,t){this.$emit("item-mouseenter",{originalEvent:e,processedItem:t})},onItemActionClick(e,t){t&&t(e)},getAriaSetSize(){return this.items.filter((e=>this.isItemVisible(e)&&!this.getItemProp(e,"separator"))).length},getAriaPosInset(e){return e-this.items.slice(0,e).filter((e=>this.isItemVisible(e)&&this.getItemProp(e,"separator"))).length+1},getItemClass(e){return["p-menuitem",this.getItemProp(e,"class"),{"p-menuitem-active p-highlight":this.isItemActive(e),"p-focus":this.isItemFocused(e),"p-disabled":this.isItemDisabled(e)}]},getItemActionClass(e,t){return["p-menuitem-link",{"router-link-active":t&&t.isActive,"router-link-active-exact":this.exact&&t&&t.isExactActive}]},getItemIconClass(e){return["p-menuitem-icon",this.getItemProp(e,"icon")]},getSeparatorItemClass(e){return["p-menuitem-separator",this.getItemProp(e,"class")]},getSubmenuIcon(){return["p-submenu-icon pi",{"pi-angle-right":!this.root,"pi-angle-down":this.root}]}},computed:{containerClass(){return{"p-submenu-list":!this.root,"p-menubar-root-list":this.root}}},directives:{ripple:s(t).default}};const o=["id","aria-label","aria-disabled","aria-expanded","aria-haspopup","aria-level","aria-setsize","aria-posinset"],r=["onClick","onMouseenter"],a=["href","onClick"],l={class:"p-menuitem-text"},m=["href","target"],c={class:"p-menuitem-text"},d=["id"];n.render=function(e,t,s,n,u,I){const h=i.resolveComponent("router-link"),p=i.resolveComponent("MenubarSub",!0),f=i.resolveDirective("ripple");return i.openBlock(),i.createElementBlock("ul",null,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.items,((n,u)=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:I.getItemKey(n)},[I.isItemVisible(n)&&!I.getItemProp(n,"separator")?(i.openBlock(),i.createElementBlock("li",{key:0,id:I.getItemId(n),style:i.normalizeStyle(I.getItemProp(n,"style")),class:i.normalizeClass(I.getItemClass(n)),role:"menuitem","aria-label":I.getItemLabel(n),"aria-disabled":I.isItemDisabled(n)||void 0,"aria-expanded":I.isItemGroup(n)?I.isItemActive(n):void 0,"aria-haspopup":I.isItemGroup(n)&&!I.getItemProp(n,"to")?"menu":void 0,"aria-level":s.level+1,"aria-setsize":I.getAriaSetSize(),"aria-posinset":I.getAriaPosInset(u)},[i.createElementVNode("div",{class:"p-menuitem-content",onClick:e=>I.onItemClick(e,n),onMouseenter:e=>I.onItemMouseEnter(e,n)},[s.template?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.template),{key:1,item:n.item},null,8,["item"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:0},[I.getItemProp(n,"to")&&!I.isItemDisabled(n)?(i.openBlock(),i.createBlock(h,{key:0,to:I.getItemProp(n,"to"),custom:""},{default:i.withCtx((({navigate:e,href:t,isActive:s,isExactActive:o})=>[i.withDirectives((i.openBlock(),i.createElementBlock("a",{href:t,class:i.normalizeClass(I.getItemActionClass(n,{isActive:s,isExactActive:o})),tabindex:"-1","aria-hidden":"true",onClick:t=>I.onItemActionClick(t,e)},[I.getItemProp(n,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(n))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",l,i.toDisplayString(I.getItemLabel(n)),1)],10,a)),[[f]])])),_:2},1032,["to"])):i.withDirectives((i.openBlock(),i.createElementBlock("a",{key:1,href:I.getItemProp(n,"url"),class:i.normalizeClass(I.getItemActionClass(n)),target:I.getItemProp(n,"target"),tabindex:"-1","aria-hidden":"true"},[I.getItemProp(n,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(n))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",c,i.toDisplayString(I.getItemLabel(n)),1),I.getItemProp(n,"items")?(i.openBlock(),i.createElementBlock("span",{key:1,class:i.normalizeClass(I.getSubmenuIcon())},null,2)):i.createCommentVNode("",!0)],10,m)),[[f]])],64))],40,r),I.isItemVisible(n)&&I.isItemGroup(n)?(i.openBlock(),i.createBlock(p,{key:0,menuId:s.menuId,role:"menu",class:"p-submenu-list",focusedItemId:s.focusedItemId,items:n.items,mobileActive:s.mobileActive,activeItemPath:s.activeItemPath,template:s.template,exact:s.exact,level:s.level+1,onItemClick:t[0]||(t[0]=t=>e.$emit("item-click",t)),onItemMouseenter:t[1]||(t[1]=t=>e.$emit("item-mouseenter",t))},null,8,["menuId","focusedItemId","items","mobileActive","activeItemPath","template","exact","level"])):i.createCommentVNode("",!0)],14,o)):i.createCommentVNode("",!0),I.isItemVisible(n)&&I.getItemProp(n,"separator")?(i.openBlock(),i.createElementBlock("li",{key:1,id:I.getItemId(n),style:i.normalizeStyle(I.getItemProp(n,"style")),class:i.normalizeClass(I.getSeparatorItemClass(n)),role:"separator"},null,14,d)):i.createCommentVNode("",!0)],64)))),128))])};var u={name:"Menubar",emits:["focus","blur"],props:{model:{type:Array,default:null},exact:{type:Boolean,default:!0},buttonProps:{type:null,default:null},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},data:()=>({mobileActive:!1,focused:!1,focusedItemInfo:{index:-1,level:0,parentKey:""},activeItemPath:[],dirty:!1}),watch:{activeItemPath(t){e.ObjectUtils.isNotEmpty(t)?(this.bindOutsideClickListener(),this.bindResizeListener()):(this.unbindOutsideClickListener(),this.unbindResizeListener())}},outsideClickListener:null,container:null,menubar:null,beforeUnmount(){this.mobileActive=!1,this.unbindOutsideClickListener(),this.unbindResizeListener(),this.container&&e.ZIndexUtils.clear(this.container),this.container=null},methods:{getItemProp:(t,i)=>t?e.ObjectUtils.getItemValue(t[i]):void 0,getItemLabel(e){return this.getItemProp(e,"label")},isItemDisabled(e){return this.getItemProp(e,"disabled")},isItemGroup(t){return e.ObjectUtils.isNotEmpty(this.getItemProp(t,"items"))},isItemSeparator(e){return this.getItemProp(e,"separator")},getProccessedItemLabel(e){return e?this.getItemLabel(e.item):void 0},isProccessedItemGroup:t=>t&&e.ObjectUtils.isNotEmpty(t.items),toggle(t){this.mobileActive?(this.mobileActive=!1,e.ZIndexUtils.clear(this.menubar),this.hide()):(this.mobileActive=!0,e.ZIndexUtils.set("menu",this.menubar,this.$primevue.config.zIndex.menu),setTimeout((()=>{this.show()}),0)),this.bindOutsideClickListener(),t.preventDefault()},show(){this.focusedItemInfo={index:this.findFirstFocusedItemIndex(),level:0,parentKey:""},e.DomHandler.focus(this.menubar)},hide(t,i){this.mobileActive&&setTimeout((()=>{e.DomHandler.focus(this.$refs.menubutton)}),0),this.activeItemPath=[],this.focusedItemInfo={index:-1,level:0,parentKey:""},i&&e.DomHandler.focus(this.menubar),this.dirty=!1},onFocus(e){this.focused=!0,this.focusedItemInfo=-1!==this.focusedItemInfo.index?this.focusedItemInfo:{index:this.findFirstFocusedItemIndex(),level:0,parentKey:""},this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedItemInfo={index:-1,level:0,parentKey:""},this.searchValue="",this.dirty=!1,this.$emit("blur",e)},onKeyDown(t){const i=t.metaKey||t.ctrlKey;switch(t.code){case"ArrowDown":this.onArrowDownKey(t);break;case"ArrowUp":this.onArrowUpKey(t);break;case"ArrowLeft":this.onArrowLeftKey(t);break;case"ArrowRight":this.onArrowRightKey(t);break;case"Home":this.onHomeKey(t);break;case"End":this.onEndKey(t);break;case"Space":this.onSpaceKey(t);break;case"Enter":this.onEnterKey(t);break;case"Escape":this.onEscapeKey(t);break;case"Tab":this.onTabKey(t);break;case"PageDown":case"PageUp":case"Backspace":case"ShiftLeft":case"ShiftRight":break;default:!i&&e.ObjectUtils.isPrintableCharacter(t.key)&&this.searchItems(t,t.key)}},onItemChange(t){const{processedItem:i,isFocus:s}=t;if(e.ObjectUtils.isEmpty(i))return;const{index:n,key:o,level:r,parentKey:a,items:l}=i,m=e.ObjectUtils.isNotEmpty(l),c=this.activeItemPath.filter((e=>e.parentKey!==a&&e.parentKey!==o));m&&c.push(i),this.focusedItemInfo={index:n,level:r,parentKey:a},this.activeItemPath=c,m&&(this.dirty=!0),s&&e.DomHandler.focus(this.menubar)},onItemClick(t){const{originalEvent:i,processedItem:s}=t,n=this.isProccessedItemGroup(s),o=e.ObjectUtils.isEmpty(s.parent);if(this.isSelected(s)){const{index:t,key:i,level:n,parentKey:r}=s;this.activeItemPath=this.activeItemPath.filter((e=>i!==e.key&&i.startsWith(e.key))),this.focusedItemInfo={index:t,level:n,parentKey:r},this.dirty=!o,e.DomHandler.focus(this.menubar)}else if(n)this.onItemChange(t);else{const t=o?s:this.activeItemPath.find((e=>""===e.parentKey));this.hide(i),this.changeFocusedItemIndex(i,t?t.index:-1),this.mobileActive=!1,e.DomHandler.focus(this.menubar)}},onItemMouseEnter(e){!this.mobileActive&&this.dirty&&this.onItemChange(e)},menuButtonClick(e){this.toggle(e)},menuButtonKeydown(e){("Enter"===e.code||"Space"===e.code)&&this.menuButtonClick(e)},onArrowDownKey(t){const i=this.visibleItems[this.focusedItemInfo.index];if(i?e.ObjectUtils.isEmpty(i.parent):null){this.isProccessedItemGroup(i)&&(this.onItemChange({originalEvent:t,processedItem:i}),this.focusedItemInfo={index:-1,parentKey:i.key},this.onArrowRightKey(t))}else{const e=-1!==this.focusedItemInfo.index?this.findNextItemIndex(this.focusedItemInfo.index):this.findFirstFocusedItemIndex();this.changeFocusedItemIndex(t,e),t.preventDefault()}},onArrowUpKey(t){const i=this.visibleItems[this.focusedItemInfo.index];if(e.ObjectUtils.isEmpty(i.parent)){if(this.isProccessedItemGroup(i)){this.onItemChange({originalEvent:t,processedItem:i}),this.focusedItemInfo={index:-1,parentKey:i.key};const e=this.findLastItemIndex();this.changeFocusedItemIndex(t,e)}}else{const e=this.activeItemPath.find((e=>e.key===i.parentKey));if(0===this.focusedItemInfo.index)this.focusedItemInfo={index:-1,parentKey:e?e.parentKey:""},this.searchValue="",this.onArrowLeftKey(t),this.activeItemPath=this.activeItemPath.filter((e=>e.parentKey!==this.focusedItemInfo.parentKey));else{const e=-1!==this.focusedItemInfo.index?this.findPrevItemIndex(this.focusedItemInfo.index):this.findLastFocusedItemIndex();this.changeFocusedItemIndex(t,e)}}t.preventDefault()},onArrowLeftKey(e){const t=this.visibleItems[this.focusedItemInfo.index],i=t?this.activeItemPath.find((e=>e.key===t.parentKey)):null;if(i)this.onItemChange({originalEvent:e,processedItem:i}),this.activeItemPath=this.activeItemPath.filter((e=>e.parentKey!==this.focusedItemInfo.parentKey)),e.preventDefault();else{const t=-1!==this.focusedItemInfo.index?this.findPrevItemIndex(this.focusedItemInfo.index):this.findLastFocusedItemIndex();this.changeFocusedItemIndex(e,t),e.preventDefault()}},onArrowRightKey(e){const t=this.visibleItems[this.focusedItemInfo.index];if(t?this.activeItemPath.find((e=>e.key===t.parentKey)):null){this.isProccessedItemGroup(t)&&(this.onItemChange({originalEvent:e,processedItem:t}),this.focusedItemInfo={index:-1,parentKey:t.key},this.onArrowDownKey(e))}else{const t=-1!==this.focusedItemInfo.index?this.findNextItemIndex(this.focusedItemInfo.index):this.findFirstFocusedItemIndex();this.changeFocusedItemIndex(e,t),e.preventDefault()}},onHomeKey(e){this.changeFocusedItemIndex(e,this.findFirstItemIndex()),e.preventDefault()},onEndKey(e){this.changeFocusedItemIndex(e,this.findLastItemIndex()),e.preventDefault()},onEnterKey(t){if(-1!==this.focusedItemInfo.index){const t=e.DomHandler.findSingle(this.menubar,`li[id="${this.focusedItemId}"]`),i=t&&e.DomHandler.findSingle(t,".p-menuitem-link");i?i.click():t&&t.click();const s=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(s)&&(this.focusedItemInfo.index=this.findFirstFocusedItemIndex())}t.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},onEscapeKey(e){this.hide(e,!0),this.focusedItemInfo.index=this.findFirstFocusedItemIndex(),e.preventDefault()},onTabKey(e){if(-1!==this.focusedItemInfo.index){const t=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(t)&&this.onItemChange({originalEvent:e,processedItem:t})}this.hide()},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.menubar!==e.target&&!this.menubar.contains(e.target),i=this.mobileActive&&this.$refs.menubutton!==e.target&&!this.$refs.menubutton.contains(e.target);t&&(i?this.mobileActive=!1:this.hide())},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindResizeListener(){this.resizeListener||(this.resizeListener=t=>{e.DomHandler.isTouchDevice()||this.hide(t,!0),this.mobileActive=!1},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},isItemMatched(e){return this.isValidItem(e)&&this.getProccessedItemLabel(e).toLocaleLowerCase().startsWith(this.searchValue.toLocaleLowerCase())},isValidItem(e){return!!e&&!this.isItemDisabled(e.item)&&!this.isItemSeparator(e.item)},isValidSelectedItem(e){return this.isValidItem(e)&&this.isSelected(e)},isSelected(e){return this.activeItemPath.some((t=>t.key===e.key))},findFirstItemIndex(){return this.visibleItems.findIndex((e=>this.isValidItem(e)))},findLastItemIndex(){return e.ObjectUtils.findLastIndex(this.visibleItems,(e=>this.isValidItem(e)))},findNextItemIndex(e){const t=e<this.visibleItems.length-1?this.visibleItems.slice(e+1).findIndex((e=>this.isValidItem(e))):-1;return t>-1?t+e+1:e},findPrevItemIndex(t){const i=t>0?e.ObjectUtils.findLastIndex(this.visibleItems.slice(0,t),(e=>this.isValidItem(e))):-1;return i>-1?i:t},findSelectedItemIndex(){return this.visibleItems.findIndex((e=>this.isValidSelectedItem(e)))},findFirstFocusedItemIndex(){const e=this.findSelectedItemIndex();return e<0?this.findFirstItemIndex():e},findLastFocusedItemIndex(){const e=this.findSelectedItemIndex();return e<0?this.findLastItemIndex():e},searchItems(e,t){this.searchValue=(this.searchValue||"")+t;let i=-1,s=!1;return-1!==this.focusedItemInfo.index?(i=this.visibleItems.slice(this.focusedItemInfo.index).findIndex((e=>this.isItemMatched(e))),i=-1===i?this.visibleItems.slice(0,this.focusedItemInfo.index).findIndex((e=>this.isItemMatched(e))):i+this.focusedItemInfo.index):i=this.visibleItems.findIndex((e=>this.isItemMatched(e))),-1!==i&&(s=!0),-1===i&&-1===this.focusedItemInfo.index&&(i=this.findFirstFocusedItemIndex()),-1!==i&&this.changeFocusedItemIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),s},changeFocusedItemIndex(e,t){this.focusedItemInfo.index!==t&&(this.focusedItemInfo.index=t,this.scrollInView())},scrollInView(t=-1){const i=-1!==t?`${this.id}_${t}`:this.focusedItemId,s=e.DomHandler.findSingle(this.menubar,`li[id="${i}"]`);s&&s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"start"})},createProcessedItems(e,t=0,i={},s=""){const n=[];return e&&e.forEach(((e,o)=>{const r=(""!==s?s+"_":"")+o,a={item:e,index:o,level:t,key:r,parent:i,parentKey:s};a.items=this.createProcessedItems(e.items,t+1,a,r),n.push(a)})),n},containerRef(e){this.container=e},menubarRef(e){this.menubar=e?e.$el:void 0}},computed:{containerClass(){return["p-menubar p-component",{"p-menubar-mobile-active":this.mobileActive}]},processedItems(){return this.createProcessedItems(this.model||[])},visibleItems(){const e=this.activeItemPath.find((e=>e.key===this.focusedItemInfo.parentKey));return e?e.items:this.processedItems},id(){return this.$attrs.id||e.UniqueComponentId()},focusedItemId(){return-1!==this.focusedItemInfo.index?`${this.id}${e.ObjectUtils.isNotEmpty(this.focusedItemInfo.parentKey)?"_"+this.focusedItemInfo.parentKey:""}_${this.focusedItemInfo.index}`:null}},components:{MenubarSub:n}};const I={key:0,class:"p-menubar-start"},h=["aria-haspopup","aria-expanded","aria-controls","aria-label"],p=[i.createElementVNode("i",{class:"pi pi-bars"},null,-1)],f={key:2,class:"p-menubar-end"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-menubar {\n display: flex;\n align-items: center;\n}\n.p-menubar ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menubar .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menubar .p-menuitem-text {\n line-height: 1;\n}\n.p-menubar .p-menuitem {\n position: relative;\n}\n.p-menubar-root-list {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n}\n.p-menubar-root-list > li ul {\n display: none;\n z-index: 1;\n}\n.p-menubar-root-list > .p-menuitem-active > .p-submenu-list {\n display: block;\n}\n.p-menubar .p-submenu-list {\n display: none;\n position: absolute;\n z-index: 1;\n}\n.p-menubar .p-submenu-list > .p-menuitem-active > .p-submenu-list {\n display: block;\n left: 100%;\n top: 0;\n}\n.p-menubar .p-submenu-list .p-menuitem .p-menuitem-content .p-menuitem-link .p-submenu-icon {\n margin-left: auto;\n}\n.p-menubar .p-menubar-end {\n margin-left: auto;\n align-self: center;\n}\n.p-menubar-button {\n display: none;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n text-decoration: none;\n}\n"),u.render=function(e,t,s,n,o,r){const a=i.resolveComponent("MenubarSub");return i.openBlock(),i.createElementBlock("div",{ref:r.containerRef,class:i.normalizeClass(r.containerClass)},[e.$slots.start?(i.openBlock(),i.createElementBlock("div",I,[i.renderSlot(e.$slots,"start")])):i.createCommentVNode("",!0),s.model&&s.model.length>0?(i.openBlock(),i.createElementBlock("a",i.mergeProps({key:1,ref:"menubutton",role:"button",tabindex:"0",class:"p-menubar-button","aria-haspopup":!!(s.model.length&&s.model.length>0),"aria-expanded":o.mobileActive,"aria-controls":r.id,"aria-label":e.$primevue.config.locale.aria.navigation,onClick:t[0]||(t[0]=e=>r.menuButtonClick(e)),onKeydown:t[1]||(t[1]=e=>r.menuButtonKeydown(e))},s.buttonProps),p,16,h)):i.createCommentVNode("",!0),i.createVNode(a,{ref:r.menubarRef,id:r.id,class:"p-menubar-root-list",role:"menubar",items:r.processedItems,template:e.$slots.item,root:!0,mobileActive:o.mobileActive,tabindex:"0","aria-activedescendant":o.focused?r.focusedItemId:void 0,menuId:r.id,focusedItemId:o.focused?r.focusedItemId:void 0,activeItemPath:o.activeItemPath,exact:s.exact,level:0,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onFocus:r.onFocus,onBlur:r.onBlur,onKeydown:r.onKeyDown,onItemClick:r.onItemClick,onItemMouseenter:r.onItemMouseEnter},null,8,["id","items","template","mobileActive","aria-activedescendant","menuId","focusedItemId","activeItemPath","exact","aria-labelledby","aria-label","onFocus","onBlur","onKeydown","onItemClick","onItemMouseenter"]),e.$slots.end?(i.openBlock(),i.createElementBlock("div",f,[i.renderSlot(e.$slots,"end")])):i.createCommentVNode("",!0)],2)},module.exports=u;
|
|
1
|
+
"use strict";var e=require("primevue/utils"),t=require("primevue/ripple"),i=require("vue");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n={name:"MenubarSub",emits:["item-mouseenter","item-click"],props:{items:{type:Array,default:null},root:{type:Boolean,default:!1},popup:{type:Boolean,default:!1},mobileActive:{type:Boolean,default:!1},template:{type:Function,default:null},exact:{type:Boolean,default:!0},level:{type:Number,default:0},menuId:{type:String,default:null},focusedItemId:{type:String,default:null},activeItemPath:{type:Object,default:null}},list:null,methods:{getItemId(e){return`${this.menuId}_${e.key}`},getItemKey(e){return this.getItemId(e)},getItemProp:(t,i,s)=>t&&t.item?e.ObjectUtils.getItemValue(t.item[i],s):void 0,getItemLabel(e){return this.getItemProp(e,"label")},isItemActive(e){return this.activeItemPath.some((t=>t.key===e.key))},isItemVisible(e){return!1!==this.getItemProp(e,"visible")},isItemDisabled(e){return this.getItemProp(e,"disabled")},isItemFocused(e){return this.focusedItemId===this.getItemId(e)},isItemGroup:t=>e.ObjectUtils.isNotEmpty(t.items),onItemClick(e,t){this.getItemProp(t,"command",{originalEvent:e,item:t.item}),this.$emit("item-click",{originalEvent:e,processedItem:t,isFocus:!0})},onItemMouseEnter(e,t){this.$emit("item-mouseenter",{originalEvent:e,processedItem:t})},onItemActionClick(e,t){t&&t(e)},getAriaSetSize(){return this.items.filter((e=>this.isItemVisible(e)&&!this.getItemProp(e,"separator"))).length},getAriaPosInset(e){return e-this.items.slice(0,e).filter((e=>this.isItemVisible(e)&&this.getItemProp(e,"separator"))).length+1},getItemClass(e){return["p-menuitem",this.getItemProp(e,"class"),{"p-menuitem-active p-highlight":this.isItemActive(e),"p-focus":this.isItemFocused(e),"p-disabled":this.isItemDisabled(e)}]},getItemActionClass(e,t){return["p-menuitem-link",{"router-link-active":t&&t.isActive,"router-link-active-exact":this.exact&&t&&t.isExactActive}]},getItemIconClass(e){return["p-menuitem-icon",this.getItemProp(e,"icon")]},getSeparatorItemClass(e){return["p-menuitem-separator",this.getItemProp(e,"class")]},getSubmenuIcon(){return["p-submenu-icon pi",{"pi-angle-right":!this.root,"pi-angle-down":this.root}]}},computed:{containerClass(){return{"p-submenu-list":!this.root,"p-menubar-root-list":this.root}}},directives:{ripple:s(t).default}};const o=["id","aria-label","aria-disabled","aria-expanded","aria-haspopup","aria-level","aria-setsize","aria-posinset"],r=["onClick","onMouseenter"],a=["href","onClick"],l={class:"p-menuitem-text"},m=["href","target"],c={class:"p-menuitem-text"},d=["id"];n.render=function(e,t,s,n,u,I){const h=i.resolveComponent("router-link"),p=i.resolveComponent("MenubarSub",!0),f=i.resolveDirective("ripple");return i.openBlock(),i.createElementBlock("ul",null,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.items,((n,u)=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:I.getItemKey(n)},[I.isItemVisible(n)&&!I.getItemProp(n,"separator")?(i.openBlock(),i.createElementBlock("li",{key:0,id:I.getItemId(n),style:i.normalizeStyle(I.getItemProp(n,"style")),class:i.normalizeClass(I.getItemClass(n)),role:"menuitem","aria-label":I.getItemLabel(n),"aria-disabled":I.isItemDisabled(n)||void 0,"aria-expanded":I.isItemGroup(n)?I.isItemActive(n):void 0,"aria-haspopup":I.isItemGroup(n)&&!I.getItemProp(n,"to")?"menu":void 0,"aria-level":s.level+1,"aria-setsize":I.getAriaSetSize(),"aria-posinset":I.getAriaPosInset(u)},[i.createElementVNode("div",{class:"p-menuitem-content",onClick:e=>I.onItemClick(e,n),onMouseenter:e=>I.onItemMouseEnter(e,n)},[s.template?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.template),{key:1,item:n.item},null,8,["item"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:0},[I.getItemProp(n,"to")&&!I.isItemDisabled(n)?(i.openBlock(),i.createBlock(h,{key:0,to:I.getItemProp(n,"to"),custom:""},{default:i.withCtx((({navigate:e,href:t,isActive:s,isExactActive:o})=>[i.withDirectives((i.openBlock(),i.createElementBlock("a",{href:t,class:i.normalizeClass(I.getItemActionClass(n,{isActive:s,isExactActive:o})),tabindex:"-1","aria-hidden":"true",onClick:t=>I.onItemActionClick(t,e)},[I.getItemProp(n,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(n))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",l,i.toDisplayString(I.getItemLabel(n)),1)],10,a)),[[f]])])),_:2},1032,["to"])):i.withDirectives((i.openBlock(),i.createElementBlock("a",{key:1,href:I.getItemProp(n,"url"),class:i.normalizeClass(I.getItemActionClass(n)),target:I.getItemProp(n,"target"),tabindex:"-1","aria-hidden":"true"},[I.getItemProp(n,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(n))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",c,i.toDisplayString(I.getItemLabel(n)),1),I.getItemProp(n,"items")?(i.openBlock(),i.createElementBlock("span",{key:1,class:i.normalizeClass(I.getSubmenuIcon())},null,2)):i.createCommentVNode("",!0)],10,m)),[[f]])],64))],40,r),I.isItemVisible(n)&&I.isItemGroup(n)?(i.openBlock(),i.createBlock(p,{key:0,menuId:s.menuId,role:"menu",class:"p-submenu-list",focusedItemId:s.focusedItemId,items:n.items,mobileActive:s.mobileActive,activeItemPath:s.activeItemPath,template:s.template,exact:s.exact,level:s.level+1,onItemClick:t[0]||(t[0]=t=>e.$emit("item-click",t)),onItemMouseenter:t[1]||(t[1]=t=>e.$emit("item-mouseenter",t))},null,8,["menuId","focusedItemId","items","mobileActive","activeItemPath","template","exact","level"])):i.createCommentVNode("",!0)],14,o)):i.createCommentVNode("",!0),I.isItemVisible(n)&&I.getItemProp(n,"separator")?(i.openBlock(),i.createElementBlock("li",{key:1,id:I.getItemId(n),style:i.normalizeStyle(I.getItemProp(n,"style")),class:i.normalizeClass(I.getSeparatorItemClass(n)),role:"separator"},null,14,d)):i.createCommentVNode("",!0)],64)))),128))])};var u={name:"Menubar",emits:["focus","blur"],props:{model:{type:Array,default:null},exact:{type:Boolean,default:!0},buttonProps:{type:null,default:null},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},data(){return{id:this.$attrs.id,mobileActive:!1,focused:!1,focusedItemInfo:{index:-1,level:0,parentKey:""},activeItemPath:[],dirty:!1}},watch:{"$attrs.id":function(t){this.id=t||e.UniqueComponentId()},activeItemPath(t){e.ObjectUtils.isNotEmpty(t)?(this.bindOutsideClickListener(),this.bindResizeListener()):(this.unbindOutsideClickListener(),this.unbindResizeListener())}},outsideClickListener:null,container:null,menubar:null,mounted(){this.id=this.id||e.UniqueComponentId()},beforeUnmount(){this.mobileActive=!1,this.unbindOutsideClickListener(),this.unbindResizeListener(),this.container&&e.ZIndexUtils.clear(this.container),this.container=null},methods:{getItemProp:(t,i)=>t?e.ObjectUtils.getItemValue(t[i]):void 0,getItemLabel(e){return this.getItemProp(e,"label")},isItemDisabled(e){return this.getItemProp(e,"disabled")},isItemGroup(t){return e.ObjectUtils.isNotEmpty(this.getItemProp(t,"items"))},isItemSeparator(e){return this.getItemProp(e,"separator")},getProccessedItemLabel(e){return e?this.getItemLabel(e.item):void 0},isProccessedItemGroup:t=>t&&e.ObjectUtils.isNotEmpty(t.items),toggle(t){this.mobileActive?(this.mobileActive=!1,e.ZIndexUtils.clear(this.menubar),this.hide()):(this.mobileActive=!0,e.ZIndexUtils.set("menu",this.menubar,this.$primevue.config.zIndex.menu),setTimeout((()=>{this.show()}),0)),this.bindOutsideClickListener(),t.preventDefault()},show(){this.focusedItemInfo={index:this.findFirstFocusedItemIndex(),level:0,parentKey:""},e.DomHandler.focus(this.menubar)},hide(t,i){this.mobileActive&&setTimeout((()=>{e.DomHandler.focus(this.$refs.menubutton)}),0),this.activeItemPath=[],this.focusedItemInfo={index:-1,level:0,parentKey:""},i&&e.DomHandler.focus(this.menubar),this.dirty=!1},onFocus(e){this.focused=!0,this.focusedItemInfo=-1!==this.focusedItemInfo.index?this.focusedItemInfo:{index:this.findFirstFocusedItemIndex(),level:0,parentKey:""},this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedItemInfo={index:-1,level:0,parentKey:""},this.searchValue="",this.dirty=!1,this.$emit("blur",e)},onKeyDown(t){const i=t.metaKey||t.ctrlKey;switch(t.code){case"ArrowDown":this.onArrowDownKey(t);break;case"ArrowUp":this.onArrowUpKey(t);break;case"ArrowLeft":this.onArrowLeftKey(t);break;case"ArrowRight":this.onArrowRightKey(t);break;case"Home":this.onHomeKey(t);break;case"End":this.onEndKey(t);break;case"Space":this.onSpaceKey(t);break;case"Enter":this.onEnterKey(t);break;case"Escape":this.onEscapeKey(t);break;case"Tab":this.onTabKey(t);break;case"PageDown":case"PageUp":case"Backspace":case"ShiftLeft":case"ShiftRight":break;default:!i&&e.ObjectUtils.isPrintableCharacter(t.key)&&this.searchItems(t,t.key)}},onItemChange(t){const{processedItem:i,isFocus:s}=t;if(e.ObjectUtils.isEmpty(i))return;const{index:n,key:o,level:r,parentKey:a,items:l}=i,m=e.ObjectUtils.isNotEmpty(l),c=this.activeItemPath.filter((e=>e.parentKey!==a&&e.parentKey!==o));m&&c.push(i),this.focusedItemInfo={index:n,level:r,parentKey:a},this.activeItemPath=c,m&&(this.dirty=!0),s&&e.DomHandler.focus(this.menubar)},onItemClick(t){const{originalEvent:i,processedItem:s}=t,n=this.isProccessedItemGroup(s),o=e.ObjectUtils.isEmpty(s.parent);if(this.isSelected(s)){const{index:t,key:i,level:n,parentKey:r}=s;this.activeItemPath=this.activeItemPath.filter((e=>i!==e.key&&i.startsWith(e.key))),this.focusedItemInfo={index:t,level:n,parentKey:r},this.dirty=!o,e.DomHandler.focus(this.menubar)}else if(n)this.onItemChange(t);else{const t=o?s:this.activeItemPath.find((e=>""===e.parentKey));this.hide(i),this.changeFocusedItemIndex(i,t?t.index:-1),this.mobileActive=!1,e.DomHandler.focus(this.menubar)}},onItemMouseEnter(e){!this.mobileActive&&this.dirty&&this.onItemChange(e)},menuButtonClick(e){this.toggle(e)},menuButtonKeydown(e){("Enter"===e.code||"Space"===e.code)&&this.menuButtonClick(e)},onArrowDownKey(t){const i=this.visibleItems[this.focusedItemInfo.index];if(i?e.ObjectUtils.isEmpty(i.parent):null){this.isProccessedItemGroup(i)&&(this.onItemChange({originalEvent:t,processedItem:i}),this.focusedItemInfo={index:-1,parentKey:i.key},this.onArrowRightKey(t))}else{const e=-1!==this.focusedItemInfo.index?this.findNextItemIndex(this.focusedItemInfo.index):this.findFirstFocusedItemIndex();this.changeFocusedItemIndex(t,e),t.preventDefault()}},onArrowUpKey(t){const i=this.visibleItems[this.focusedItemInfo.index];if(e.ObjectUtils.isEmpty(i.parent)){if(this.isProccessedItemGroup(i)){this.onItemChange({originalEvent:t,processedItem:i}),this.focusedItemInfo={index:-1,parentKey:i.key};const e=this.findLastItemIndex();this.changeFocusedItemIndex(t,e)}}else{const e=this.activeItemPath.find((e=>e.key===i.parentKey));if(0===this.focusedItemInfo.index)this.focusedItemInfo={index:-1,parentKey:e?e.parentKey:""},this.searchValue="",this.onArrowLeftKey(t),this.activeItemPath=this.activeItemPath.filter((e=>e.parentKey!==this.focusedItemInfo.parentKey));else{const e=-1!==this.focusedItemInfo.index?this.findPrevItemIndex(this.focusedItemInfo.index):this.findLastFocusedItemIndex();this.changeFocusedItemIndex(t,e)}}t.preventDefault()},onArrowLeftKey(e){const t=this.visibleItems[this.focusedItemInfo.index],i=t?this.activeItemPath.find((e=>e.key===t.parentKey)):null;if(i)this.onItemChange({originalEvent:e,processedItem:i}),this.activeItemPath=this.activeItemPath.filter((e=>e.parentKey!==this.focusedItemInfo.parentKey)),e.preventDefault();else{const t=-1!==this.focusedItemInfo.index?this.findPrevItemIndex(this.focusedItemInfo.index):this.findLastFocusedItemIndex();this.changeFocusedItemIndex(e,t),e.preventDefault()}},onArrowRightKey(e){const t=this.visibleItems[this.focusedItemInfo.index];if(t?this.activeItemPath.find((e=>e.key===t.parentKey)):null){this.isProccessedItemGroup(t)&&(this.onItemChange({originalEvent:e,processedItem:t}),this.focusedItemInfo={index:-1,parentKey:t.key},this.onArrowDownKey(e))}else{const t=-1!==this.focusedItemInfo.index?this.findNextItemIndex(this.focusedItemInfo.index):this.findFirstFocusedItemIndex();this.changeFocusedItemIndex(e,t),e.preventDefault()}},onHomeKey(e){this.changeFocusedItemIndex(e,this.findFirstItemIndex()),e.preventDefault()},onEndKey(e){this.changeFocusedItemIndex(e,this.findLastItemIndex()),e.preventDefault()},onEnterKey(t){if(-1!==this.focusedItemInfo.index){const t=e.DomHandler.findSingle(this.menubar,`li[id="${this.focusedItemId}"]`),i=t&&e.DomHandler.findSingle(t,".p-menuitem-link");i?i.click():t&&t.click();const s=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(s)&&(this.focusedItemInfo.index=this.findFirstFocusedItemIndex())}t.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},onEscapeKey(e){this.hide(e,!0),this.focusedItemInfo.index=this.findFirstFocusedItemIndex(),e.preventDefault()},onTabKey(e){if(-1!==this.focusedItemInfo.index){const t=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(t)&&this.onItemChange({originalEvent:e,processedItem:t})}this.hide()},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.menubar!==e.target&&!this.menubar.contains(e.target),i=this.mobileActive&&this.$refs.menubutton!==e.target&&!this.$refs.menubutton.contains(e.target);t&&(i?this.mobileActive=!1:this.hide())},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindResizeListener(){this.resizeListener||(this.resizeListener=t=>{e.DomHandler.isTouchDevice()||this.hide(t,!0),this.mobileActive=!1},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},isItemMatched(e){return this.isValidItem(e)&&this.getProccessedItemLabel(e).toLocaleLowerCase().startsWith(this.searchValue.toLocaleLowerCase())},isValidItem(e){return!!e&&!this.isItemDisabled(e.item)&&!this.isItemSeparator(e.item)},isValidSelectedItem(e){return this.isValidItem(e)&&this.isSelected(e)},isSelected(e){return this.activeItemPath.some((t=>t.key===e.key))},findFirstItemIndex(){return this.visibleItems.findIndex((e=>this.isValidItem(e)))},findLastItemIndex(){return e.ObjectUtils.findLastIndex(this.visibleItems,(e=>this.isValidItem(e)))},findNextItemIndex(e){const t=e<this.visibleItems.length-1?this.visibleItems.slice(e+1).findIndex((e=>this.isValidItem(e))):-1;return t>-1?t+e+1:e},findPrevItemIndex(t){const i=t>0?e.ObjectUtils.findLastIndex(this.visibleItems.slice(0,t),(e=>this.isValidItem(e))):-1;return i>-1?i:t},findSelectedItemIndex(){return this.visibleItems.findIndex((e=>this.isValidSelectedItem(e)))},findFirstFocusedItemIndex(){const e=this.findSelectedItemIndex();return e<0?this.findFirstItemIndex():e},findLastFocusedItemIndex(){const e=this.findSelectedItemIndex();return e<0?this.findLastItemIndex():e},searchItems(e,t){this.searchValue=(this.searchValue||"")+t;let i=-1,s=!1;return-1!==this.focusedItemInfo.index?(i=this.visibleItems.slice(this.focusedItemInfo.index).findIndex((e=>this.isItemMatched(e))),i=-1===i?this.visibleItems.slice(0,this.focusedItemInfo.index).findIndex((e=>this.isItemMatched(e))):i+this.focusedItemInfo.index):i=this.visibleItems.findIndex((e=>this.isItemMatched(e))),-1!==i&&(s=!0),-1===i&&-1===this.focusedItemInfo.index&&(i=this.findFirstFocusedItemIndex()),-1!==i&&this.changeFocusedItemIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),s},changeFocusedItemIndex(e,t){this.focusedItemInfo.index!==t&&(this.focusedItemInfo.index=t,this.scrollInView())},scrollInView(t=-1){const i=-1!==t?`${this.id}_${t}`:this.focusedItemId,s=e.DomHandler.findSingle(this.menubar,`li[id="${i}"]`);s&&s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"start"})},createProcessedItems(e,t=0,i={},s=""){const n=[];return e&&e.forEach(((e,o)=>{const r=(""!==s?s+"_":"")+o,a={item:e,index:o,level:t,key:r,parent:i,parentKey:s};a.items=this.createProcessedItems(e.items,t+1,a,r),n.push(a)})),n},containerRef(e){this.container=e},menubarRef(e){this.menubar=e?e.$el:void 0}},computed:{containerClass(){return["p-menubar p-component",{"p-menubar-mobile-active":this.mobileActive}]},processedItems(){return this.createProcessedItems(this.model||[])},visibleItems(){const e=this.activeItemPath.find((e=>e.key===this.focusedItemInfo.parentKey));return e?e.items:this.processedItems},focusedItemId(){return-1!==this.focusedItemInfo.index?`${this.id}${e.ObjectUtils.isNotEmpty(this.focusedItemInfo.parentKey)?"_"+this.focusedItemInfo.parentKey:""}_${this.focusedItemInfo.index}`:null}},components:{MenubarSub:n}};const I={key:0,class:"p-menubar-start"},h=["aria-haspopup","aria-expanded","aria-controls","aria-label"],p=[i.createElementVNode("i",{class:"pi pi-bars"},null,-1)],f={key:2,class:"p-menubar-end"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-menubar {\n display: flex;\n align-items: center;\n}\n.p-menubar ul {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.p-menubar .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n}\n.p-menubar .p-menuitem-text {\n line-height: 1;\n}\n.p-menubar .p-menuitem {\n position: relative;\n}\n.p-menubar-root-list {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n}\n.p-menubar-root-list > li ul {\n display: none;\n z-index: 1;\n}\n.p-menubar-root-list > .p-menuitem-active > .p-submenu-list {\n display: block;\n}\n.p-menubar .p-submenu-list {\n display: none;\n position: absolute;\n z-index: 1;\n}\n.p-menubar .p-submenu-list > .p-menuitem-active > .p-submenu-list {\n display: block;\n left: 100%;\n top: 0;\n}\n.p-menubar .p-submenu-list .p-menuitem .p-menuitem-content .p-menuitem-link .p-submenu-icon {\n margin-left: auto;\n}\n.p-menubar .p-menubar-end {\n margin-left: auto;\n align-self: center;\n}\n.p-menubar-button {\n display: none;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n text-decoration: none;\n}\n"),u.render=function(e,t,s,n,o,r){const a=i.resolveComponent("MenubarSub");return i.openBlock(),i.createElementBlock("div",{ref:r.containerRef,class:i.normalizeClass(r.containerClass)},[e.$slots.start?(i.openBlock(),i.createElementBlock("div",I,[i.renderSlot(e.$slots,"start")])):i.createCommentVNode("",!0),s.model&&s.model.length>0?(i.openBlock(),i.createElementBlock("a",i.mergeProps({key:1,ref:"menubutton",role:"button",tabindex:"0",class:"p-menubar-button","aria-haspopup":!!(s.model.length&&s.model.length>0),"aria-expanded":o.mobileActive,"aria-controls":o.id,"aria-label":e.$primevue.config.locale.aria.navigation,onClick:t[0]||(t[0]=e=>r.menuButtonClick(e)),onKeydown:t[1]||(t[1]=e=>r.menuButtonKeydown(e))},s.buttonProps),p,16,h)):i.createCommentVNode("",!0),i.createVNode(a,{ref:r.menubarRef,id:o.id,class:"p-menubar-root-list",role:"menubar",items:r.processedItems,template:e.$slots.item,root:!0,mobileActive:o.mobileActive,tabindex:"0","aria-activedescendant":o.focused?r.focusedItemId:void 0,menuId:o.id,focusedItemId:o.focused?r.focusedItemId:void 0,activeItemPath:o.activeItemPath,exact:s.exact,level:0,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onFocus:r.onFocus,onBlur:r.onBlur,onKeydown:r.onKeyDown,onItemClick:r.onItemClick,onItemMouseenter:r.onItemMouseEnter},null,8,["id","items","template","mobileActive","aria-activedescendant","menuId","focusedItemId","activeItemPath","exact","aria-labelledby","aria-label","onFocus","onBlur","onKeydown","onItemClick","onItemMouseenter"]),e.$slots.end?(i.openBlock(),i.createElementBlock("div",f,[i.renderSlot(e.$slots,"end")])):i.createCommentVNode("",!0)],2)},module.exports=u;
|