primevue 3.18.0 → 3.19.0
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 +13 -2
- package/autocomplete/AutoComplete.vue +15 -2
- package/autocomplete/autocomplete.cjs.js +15 -2
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +15 -2
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +15 -2
- package/autocomplete/autocomplete.min.js +1 -1
- package/breadcrumb/BreadcrumbItem.vue +6 -6
- package/breadcrumb/breadcrumb.cjs.js +6 -6
- package/breadcrumb/breadcrumb.cjs.min.js +1 -1
- package/breadcrumb/breadcrumb.esm.js +6 -6
- package/breadcrumb/breadcrumb.esm.min.js +1 -1
- package/breadcrumb/breadcrumb.js +6 -6
- package/breadcrumb/breadcrumb.min.js +1 -1
- package/calendar/Calendar.d.ts +20 -0
- package/calendar/Calendar.vue +32 -14
- package/calendar/calendar.cjs.js +139 -121
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +139 -121
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +139 -121
- package/calendar/calendar.min.js +1 -1
- package/chips/Chips.d.ts +7 -2
- package/chips/Chips.vue +11 -3
- package/chips/chips.cjs.js +12 -4
- package/chips/chips.cjs.min.js +1 -1
- package/chips/chips.esm.js +12 -4
- package/chips/chips.esm.min.js +1 -1
- package/chips/chips.js +12 -4
- package/chips/chips.min.js +1 -1
- package/confirmdialog/ConfirmDialog.vue +6 -1
- package/confirmdialog/confirmdialog.cjs.js +7 -1
- package/confirmdialog/confirmdialog.cjs.min.js +1 -1
- package/confirmdialog/confirmdialog.esm.js +7 -1
- package/confirmdialog/confirmdialog.esm.min.js +1 -1
- package/confirmdialog/confirmdialog.js +7 -1
- package/confirmdialog/confirmdialog.min.js +1 -1
- package/confirmpopup/ConfirmPopup.vue +59 -5
- package/confirmpopup/confirmpopup.cjs.js +83 -19
- package/confirmpopup/confirmpopup.cjs.min.js +1 -1
- package/confirmpopup/confirmpopup.esm.js +82 -19
- package/confirmpopup/confirmpopup.esm.min.js +1 -1
- package/confirmpopup/confirmpopup.js +82 -19
- package/confirmpopup/confirmpopup.min.js +1 -1
- package/contextmenu/ContextMenu.vue +14 -16
- package/contextmenu/contextmenu.cjs.js +14 -16
- package/contextmenu/contextmenu.cjs.min.js +1 -1
- package/contextmenu/contextmenu.esm.js +14 -16
- package/contextmenu/contextmenu.esm.min.js +1 -1
- package/contextmenu/contextmenu.js +14 -16
- package/contextmenu/contextmenu.min.js +1 -1
- package/core/core.js +374 -94
- package/core/core.min.js +13 -9
- package/datatable/DataTable.d.ts +1 -1
- package/datatable/DataTable.vue +1 -1
- package/datatable/HeaderCell.vue +1 -1
- package/datatable/TableBody.vue +1 -1
- package/datatable/TableHeader.vue +1 -1
- package/datatable/datatable.cjs.js +4 -4
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +4 -4
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +4 -4
- package/datatable/datatable.min.js +1 -1
- package/dialog/Dialog.d.ts +19 -5
- package/dialog/Dialog.vue +114 -51
- package/dialog/dialog.cjs.js +145 -72
- package/dialog/dialog.cjs.min.js +1 -1
- package/dialog/dialog.esm.js +143 -71
- package/dialog/dialog.esm.min.js +1 -1
- package/dialog/dialog.js +143 -71
- package/dialog/dialog.min.js +1 -1
- package/dropdown/Dropdown.vue +20 -1
- package/dropdown/dropdown.cjs.js +20 -1
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +20 -1
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +20 -1
- package/dropdown/dropdown.min.js +1 -1
- package/fileupload/FileContent.vue +9 -2
- package/fileupload/fileupload.cjs.js +10 -4
- package/fileupload/fileupload.cjs.min.js +1 -1
- package/fileupload/fileupload.esm.js +9 -4
- package/fileupload/fileupload.esm.min.js +1 -1
- package/fileupload/fileupload.js +11 -6
- package/fileupload/fileupload.min.js +1 -1
- package/focustrap/FocusTrap.d.ts +5 -0
- package/focustrap/focustrap.cjs.js +94 -0
- package/focustrap/focustrap.cjs.min.js +1 -0
- package/focustrap/focustrap.esm.js +92 -0
- package/focustrap/focustrap.esm.min.js +1 -0
- package/focustrap/focustrap.js +96 -0
- package/focustrap/focustrap.min.js +1 -0
- package/focustrap/package.json +6 -0
- package/inplace/Inplace.d.ts +5 -0
- package/inplace/Inplace.vue +5 -1
- package/inplace/inplace.cjs.js +6 -2
- package/inplace/inplace.cjs.min.js +1 -1
- package/inplace/inplace.esm.js +6 -2
- package/inplace/inplace.esm.min.js +1 -1
- package/inplace/inplace.js +6 -2
- package/inplace/inplace.min.js +1 -1
- package/inputnumber/InputNumber.d.ts +5 -0
- package/inputnumber/InputNumber.vue +9 -0
- package/inputnumber/inputnumber.cjs.js +9 -0
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +9 -0
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +9 -0
- package/inputnumber/inputnumber.min.js +1 -1
- package/megamenu/MegaMenu.vue +3 -2
- package/megamenu/megamenu.cjs.js +3 -2
- package/megamenu/megamenu.cjs.min.js +1 -1
- package/megamenu/megamenu.esm.js +3 -2
- package/megamenu/megamenu.esm.min.js +1 -1
- package/megamenu/megamenu.js +3 -2
- package/megamenu/megamenu.min.js +1 -1
- package/menu/Menu.vue +7 -7
- package/menu/menu.cjs.js +7 -7
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.esm.js +7 -7
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +7 -7
- package/menu/menu.min.js +1 -1
- package/menubar/Menubar.vue +5 -3
- package/menubar/MenubarSub.vue +1 -1
- package/menubar/menubar.cjs.js +22 -18
- package/menubar/menubar.cjs.min.js +1 -1
- package/menubar/menubar.esm.js +22 -18
- package/menubar/menubar.esm.min.js +1 -1
- package/menubar/menubar.js +22 -18
- package/menubar/menubar.min.js +1 -1
- package/message/Message.d.ts +5 -0
- package/message/Message.vue +5 -1
- package/message/message.cjs.js +9 -5
- package/message/message.cjs.min.js +1 -1
- package/message/message.esm.js +9 -5
- package/message/message.esm.min.js +1 -1
- package/message/message.js +9 -5
- package/message/message.min.js +1 -1
- package/multiselect/MultiSelect.vue +24 -3
- package/multiselect/multiselect.cjs.js +24 -3
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +24 -3
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +24 -3
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/OverlayPanel.d.ts +2 -1
- package/overlaypanel/OverlayPanel.vue +31 -5
- package/overlaypanel/overlaypanel.cjs.js +49 -17
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.esm.js +48 -17
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +48 -17
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +1 -1
- package/paginator/Paginator.vue +5 -3
- package/paginator/paginator.cjs.js +5 -3
- package/paginator/paginator.cjs.min.js +1 -1
- package/paginator/paginator.esm.js +5 -3
- package/paginator/paginator.esm.min.js +1 -1
- package/paginator/paginator.js +5 -3
- package/paginator/paginator.min.js +1 -1
- package/panelmenu/PanelMenuList.vue +1 -2
- package/panelmenu/panelmenu.cjs.js +4 -622
- package/panelmenu/panelmenu.cjs.min.js +1 -1
- package/panelmenu/panelmenu.esm.js +13 -631
- package/panelmenu/panelmenu.esm.min.js +1 -1
- package/panelmenu/panelmenu.js +4 -622
- package/panelmenu/panelmenu.min.js +1 -1
- package/resources/primevue.css +4 -2
- package/resources/primevue.min.css +1 -1
- package/scrollpanel/ScrollPanel.vue +5 -0
- package/scrollpanel/scrollpanel.cjs.js +1 -1
- package/scrollpanel/scrollpanel.cjs.min.js +1 -1
- package/scrollpanel/scrollpanel.esm.js +1 -1
- package/scrollpanel/scrollpanel.esm.min.js +1 -1
- package/scrollpanel/scrollpanel.js +1 -1
- package/scrollpanel/scrollpanel.min.js +1 -1
- package/sidebar/Sidebar.d.ts +5 -5
- package/sidebar/Sidebar.vue +46 -14
- package/sidebar/sidebar.cjs.js +73 -30
- package/sidebar/sidebar.cjs.min.js +1 -1
- package/sidebar/sidebar.esm.js +72 -30
- package/sidebar/sidebar.esm.min.js +1 -1
- package/sidebar/sidebar.js +72 -30
- package/sidebar/sidebar.min.js +1 -1
- package/slider/Slider.vue +21 -12
- package/slider/slider.cjs.js +21 -12
- package/slider/slider.cjs.min.js +1 -1
- package/slider/slider.esm.js +21 -12
- package/slider/slider.esm.min.js +1 -1
- package/slider/slider.js +21 -12
- package/slider/slider.min.js +1 -1
- package/splitter/Splitter.d.ts +16 -0
- package/splitter/Splitter.vue +2 -1
- package/splitter/splitter.cjs.js +2 -1
- package/splitter/splitter.cjs.min.js +1 -1
- package/splitter/splitter.esm.js +2 -1
- package/splitter/splitter.esm.min.js +1 -1
- package/splitter/splitter.js +2 -1
- package/splitter/splitter.min.js +1 -1
- package/tieredmenu/TieredMenu.vue +1 -2
- package/tieredmenu/tieredmenu.cjs.js +1 -2
- package/tieredmenu/tieredmenu.cjs.min.js +1 -1
- package/tieredmenu/tieredmenu.esm.js +1 -2
- package/tieredmenu/tieredmenu.esm.min.js +1 -1
- package/tieredmenu/tieredmenu.js +1 -2
- package/tieredmenu/tieredmenu.min.js +1 -1
- package/toast/Toast.d.ts +25 -0
- package/toast/Toast.vue +32 -1
- package/toast/ToastMessage.vue +12 -7
- package/toast/toast.cjs.js +44 -14
- package/toast/toast.cjs.min.js +1 -1
- package/toast/toast.esm.js +44 -14
- package/toast/toast.esm.min.js +1 -1
- package/toast/toast.js +44 -14
- package/toast/toast.min.js +1 -1
- package/tooltip/tooltip.cjs.js +28 -5
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +28 -5
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +28 -5
- package/tooltip/tooltip.min.js +1 -1
- package/utils/Utils.d.ts +1 -0
- package/utils/utils.cjs.js +6 -0
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +6 -0
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +6 -0
- package/utils/utils.min.js +1 -1
- package/vetur-attributes.json +75 -11
- package/vetur-tags.json +25 -8
- package/web-types.json +233 -21
package/menu/menu.cjs.js
CHANGED
|
@@ -347,9 +347,9 @@ var script = {
|
|
|
347
347
|
},
|
|
348
348
|
changeFocusedOptionIndex(index) {
|
|
349
349
|
const links = utils.DomHandler.find(this.container, 'li.p-menuitem:not(.p-disabled)');
|
|
350
|
-
let order = index
|
|
350
|
+
let order = index > links.length ? links.length - 1 : index < 0 ? 0 : index;
|
|
351
351
|
|
|
352
|
-
this.focusedOptionIndex = links[order].getAttribute('id');
|
|
352
|
+
order > -1 && links.length > 0 && (this.focusedOptionIndex = links[order].getAttribute('id'));
|
|
353
353
|
},
|
|
354
354
|
toggle(event) {
|
|
355
355
|
if (this.overlayVisible) this.hide();
|
|
@@ -459,8 +459,8 @@ var script = {
|
|
|
459
459
|
label(item) {
|
|
460
460
|
return typeof item.label === 'function' ? item.label() : item.label;
|
|
461
461
|
},
|
|
462
|
-
|
|
463
|
-
|
|
462
|
+
separatorClass(item) {
|
|
463
|
+
return ['p-menuitem-separator', item.class];
|
|
464
464
|
},
|
|
465
465
|
onOverlayClick(event) {
|
|
466
466
|
OverlayEventBus__default["default"].emit('overlay-click', {
|
|
@@ -468,6 +468,9 @@ var script = {
|
|
|
468
468
|
target: this.target
|
|
469
469
|
});
|
|
470
470
|
},
|
|
471
|
+
containerRef(el) {
|
|
472
|
+
this.container = el;
|
|
473
|
+
},
|
|
471
474
|
listRef(el) {
|
|
472
475
|
this.list = el;
|
|
473
476
|
}
|
|
@@ -483,9 +486,6 @@ var script = {
|
|
|
483
486
|
}
|
|
484
487
|
];
|
|
485
488
|
},
|
|
486
|
-
separatorClass(item) {
|
|
487
|
-
return ['p-menu-separator p-menuitem-separator', item.class]; // TODO: the 'p-menu-separator' class is deprecated since v3.18.0.
|
|
488
|
-
},
|
|
489
489
|
id() {
|
|
490
490
|
return this.$attrs.id || utils.UniqueComponentId();
|
|
491
491
|
},
|
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"),l=require("vue");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e),a=s(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:s(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,s,o){const a=l.resolveComponent("router-link"),r=l.resolveDirective("ripple");return o.visible()?(l.openBlock(),l.createElementBlock("li",{key:0,id:i.id,class:l.normalizeClass(o.containerClass()),role:"menuitem",style:l.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[l.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(l.openBlock(),l.createBlock(l.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[i.item.to&&!o.disabled()?(l.openBlock(),l.createBlock(a,{key:0,to:i.item.to,custom:""},{default:l.withCtx((({navigate:e,href:t,isActive:n,isExactActive:s})=>[l.withDirectives((l.openBlock(),l.createElementBlock("a",{href:t,class:l.normalizeClass(o.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",u,l.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):l.withDirectives((l.openBlock(),l.createElementBlock("a",{key:1,href:i.item.url,class:l.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",m,l.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):l.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"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;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,containerRef(e){this.container=e},onOverlayClick(e){o.default.emit("overlay-click",{originalEvent:e,target:this.target})},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}]},separatorClass:e=>["p-menu-separator p-menuitem-separator",e.class],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],l=document.createElement("style");l.type="text/css","top"===i&&n.firstChild?n.insertBefore(l,n.firstChild):n.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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,s,o){const a=l.resolveComponent("PVMenuitem"),r=l.resolveComponent("Portal");return l.openBlock(),l.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:l.withCtx((()=>[!i.popup||s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.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))}),[l.createElementVNode("ul",{ref:o.listRef,id:o.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":s.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))},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(i.model,((t,n)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[t.items?(l.openBlock(),l.createElementBlock("li",{key:0,id:o.id+"_"+n,class:"p-submenu-header",role:"none"},[l.renderSlot(e.$slots,"item",{item:t},(()=>[l.createTextVNode(l.toDisplayString(o.label(t)),1)]))],8,k)):l.createCommentVNode("",!0),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(t.items,((s,r)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:s.label+n+"_"+r},[o.visible(s)&&!s.separator?(l.openBlock(),l.createBlock(a,{key:0,id:o.id+"_"+n+"_"+r,item:s,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(s)&&s.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n+r,class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(s.style),role:"separator"},null,6)):l.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n.toString(),class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(t.style),role:"separator"},null,6)):(l.openBlock(),l.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)):l.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"),l=require("vue");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e),a=s(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:s(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,s,o){const a=l.resolveComponent("router-link"),r=l.resolveDirective("ripple");return o.visible()?(l.openBlock(),l.createElementBlock("li",{key:0,id:i.id,class:l.normalizeClass(o.containerClass()),role:"menuitem",style:l.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[l.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(l.openBlock(),l.createBlock(l.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[i.item.to&&!o.disabled()?(l.openBlock(),l.createBlock(a,{key:0,to:i.item.to,custom:""},{default:l.withCtx((({navigate:e,href:t,isActive:n,isExactActive:s})=>[l.withDirectives((l.openBlock(),l.createElementBlock("a",{href:t,class:l.normalizeClass(o.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",u,l.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):l.withDirectives((l.openBlock(),l.createElementBlock("a",{key:1,href:i.item.url,class:l.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",m,l.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):l.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"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&&t.length>0&&(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],l=document.createElement("style");l.type="text/css","top"===i&&n.firstChild?n.insertBefore(l,n.firstChild):n.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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,s,o){const a=l.resolveComponent("PVMenuitem"),r=l.resolveComponent("Portal");return l.openBlock(),l.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:l.withCtx((()=>[!i.popup||s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.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))}),[l.createElementVNode("ul",{ref:o.listRef,id:o.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":s.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))},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(i.model,((t,n)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[t.items?(l.openBlock(),l.createElementBlock("li",{key:0,id:o.id+"_"+n,class:"p-submenu-header",role:"none"},[l.renderSlot(e.$slots,"item",{item:t},(()=>[l.createTextVNode(l.toDisplayString(o.label(t)),1)]))],8,k)):l.createCommentVNode("",!0),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(t.items,((s,r)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:s.label+n+"_"+r},[o.visible(s)&&!s.separator?(l.openBlock(),l.createBlock(a,{key:0,id:o.id+"_"+n+"_"+r,item:s,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(s)&&s.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n+r,class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(s.style),role:"separator"},null,6)):l.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n.toString(),class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(t.style),role:"separator"},null,6)):(l.openBlock(),l.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)):l.createCommentVNode("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])},module.exports=h;
|
package/menu/menu.esm.js
CHANGED
|
@@ -339,9 +339,9 @@ var script = {
|
|
|
339
339
|
},
|
|
340
340
|
changeFocusedOptionIndex(index) {
|
|
341
341
|
const links = DomHandler.find(this.container, 'li.p-menuitem:not(.p-disabled)');
|
|
342
|
-
let order = index
|
|
342
|
+
let order = index > links.length ? links.length - 1 : index < 0 ? 0 : index;
|
|
343
343
|
|
|
344
|
-
this.focusedOptionIndex = links[order].getAttribute('id');
|
|
344
|
+
order > -1 && links.length > 0 && (this.focusedOptionIndex = links[order].getAttribute('id'));
|
|
345
345
|
},
|
|
346
346
|
toggle(event) {
|
|
347
347
|
if (this.overlayVisible) this.hide();
|
|
@@ -451,8 +451,8 @@ var script = {
|
|
|
451
451
|
label(item) {
|
|
452
452
|
return typeof item.label === 'function' ? item.label() : item.label;
|
|
453
453
|
},
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
separatorClass(item) {
|
|
455
|
+
return ['p-menuitem-separator', item.class];
|
|
456
456
|
},
|
|
457
457
|
onOverlayClick(event) {
|
|
458
458
|
OverlayEventBus.emit('overlay-click', {
|
|
@@ -460,6 +460,9 @@ var script = {
|
|
|
460
460
|
target: this.target
|
|
461
461
|
});
|
|
462
462
|
},
|
|
463
|
+
containerRef(el) {
|
|
464
|
+
this.container = el;
|
|
465
|
+
},
|
|
463
466
|
listRef(el) {
|
|
464
467
|
this.list = el;
|
|
465
468
|
}
|
|
@@ -475,9 +478,6 @@ var script = {
|
|
|
475
478
|
}
|
|
476
479
|
];
|
|
477
480
|
},
|
|
478
|
-
separatorClass(item) {
|
|
479
|
-
return ['p-menu-separator p-menuitem-separator', item.class]; // TODO: the 'p-menu-separator' class is deprecated since v3.18.0.
|
|
480
|
-
},
|
|
481
481
|
id() {
|
|
482
482
|
return this.$attrs.id || UniqueComponentId();
|
|
483
483
|
},
|
package/menu/menu.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"primevue/overlayeventbus";import i from"primevue/portal";import{ObjectUtils as t,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 x,toDisplayString as k,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,i)=>e&&e.item?t.getItemValue(e.item[i]):void 0,onItemActionClick(e,i){i&&i(e)},onItemClick(e){const i=this.getItemProp(this.item,"command");i&&i({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,i,t,n,s,l){const o=r("router-link"),a=d("ripple");return l.visible()?(c(),u("li",{key:0,id:t.id,class:p(l.containerClass()),role:"menuitem",style:h(t.item.style),"aria-label":l.label(),"aria-disabled":l.disabled()},[m("div",{class:"p-menuitem-content",onClick:i[0]||(i[0]=e=>l.onItemClick(e))},[t.template?(c(),f(g(t.template),{key:1,item:t.item},null,8,["item"])):(c(),u(b,{key:0},[t.item.to&&!l.disabled()?(c(),f(o,{key:0,to:t.item.to,custom:""},{default:v((({navigate:e,href:i,isActive:n,isExactActive:s})=>[y((c(),u("a",{href:i,class:p(l.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:i=>l.onItemActionClick(i,e)},[t.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",t.item.icon])},null,2)):x("",!0),m("span",z,k(l.label()),1)],10,K)),[[a]])])),_:1},8,["to"])):y((c(),u("a",{key:1,href:t.item.url,class:p(l.linkClass()),target:t.item.target,tabindex:"-1","aria-hidden":"true"},[t.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",t.item.icon])},null,2)):x("",!0),m("span",D,k(l.label()),1)],10,$)),[[a]])],64))])],14,S)):x("",!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 i=e.item;this.disabled(i)||(i.command&&i.command(e),i.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"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const i=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(i),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)s.focus(this.target),this.hide(),e.preventDefault();else{const i=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(i),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 i=s.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),t=i&&s.findSingle(i,".p-menuitem-link");this.popup&&s.focus(this.target),t?t.click():i&&i.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const i=[...s.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((i=>i.id===e));return i>-1?i+1:0},findPrevOptionIndex(e){const i=[...s.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((i=>i.id===e));return i>-1?i-1:0},changeFocusedOptionIndex(e){const i=s.find(this.container,"li.p-menuitem:not(.p-disabled)");let t=e>=i.length?i.length-1:e<0?0:e;this.focusedOptionIndex=i[t].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 i=this.container&&!this.container.contains(e.target),t=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&i&&t?this.hide():!this.popup&&i&&t&&(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,containerRef(e){this.container=e},onOverlayClick(i){e.emit("overlay-click",{originalEvent:i,target:this.target})},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}]},separatorClass:e=>["p-menu-separator p-menuitem-separator",e.class],id(){return this.$attrs.id||o()},focusedOptionId(){return-1!==this.focusedOptionIndex?this.focusedOptionIndex:null}},components:{PVMenuitem:A,Portal:i}};const F=["id"],H=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],R=["id"];!function(e,i){void 0===i&&(i={});var t=i.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===t&&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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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,i,t,n,s,l){const o=r("PVMenuitem"),a=r("Portal");return c(),f(a,{appendTo:t.appendTo,disabled:!t.popup},{default:v((()=>[I(L,{name:"p-connected-overlay",onEnter:l.onEnter,onLeave:l.onLeave,onAfterLeave:l.onAfterLeave},{default:v((()=>[!t.popup||s.overlayVisible?(c(),u("div",O({key:0,ref:l.containerRef,id:l.id,class:l.containerClass},e.$attrs,{onClick:i[3]||(i[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:t.tabindex,"aria-activedescendant":s.focused?l.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:i[0]||(i[0]=(...e)=>l.onListFocus&&l.onListFocus(...e)),onBlur:i[1]||(i[1]=(...e)=>l.onListBlur&&l.onListBlur(...e)),onKeydown:i[2]||(i[2]=(...e)=>l.onListKeyDown&&l.onListKeyDown(...e))},[(c(!0),u(b,null,C(t.model,((i,n)=>(c(),u(b,{key:l.label(i)+n.toString()},[i.items&&l.visible(i)&&!i.separator?(c(),u(b,{key:0},[i.items?(c(),u("li",{key:0,id:l.id+"_"+n,class:"p-submenu-header",role:"none"},[w(e.$slots,"item",{item:i},(()=>[E(k(l.label(i)),1)]))],8,R)):x("",!0),(c(!0),u(b,null,C(i.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:t.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(i)),style:h(s.style),role:"separator"},null,6)):x("",!0)],64)))),128))],64)):l.visible(i)&&i.separator?(c(),u("li",{key:"separator"+n.toString(),class:p(l.separatorClass(i)),style:h(i.style),role:"separator"},null,6)):(c(),f(o,{key:l.label(i)+n.toString(),id:l.id+"_"+n,item:i,template:e.$slots.item,exact:t.exact,focusedOptionId:l.focusedOptionId,onItemClick:l.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,H)],16,F)):x("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])};export{V as default};
|
|
1
|
+
import e from"primevue/overlayeventbus";import i from"primevue/portal";import{ObjectUtils as t,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 x,toDisplayString as k,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,i)=>e&&e.item?t.getItemValue(e.item[i]):void 0,onItemActionClick(e,i){i&&i(e)},onItemClick(e){const i=this.getItemProp(this.item,"command");i&&i({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,i,t,n,s,l){const o=r("router-link"),a=d("ripple");return l.visible()?(c(),u("li",{key:0,id:t.id,class:p(l.containerClass()),role:"menuitem",style:h(t.item.style),"aria-label":l.label(),"aria-disabled":l.disabled()},[m("div",{class:"p-menuitem-content",onClick:i[0]||(i[0]=e=>l.onItemClick(e))},[t.template?(c(),f(g(t.template),{key:1,item:t.item},null,8,["item"])):(c(),u(b,{key:0},[t.item.to&&!l.disabled()?(c(),f(o,{key:0,to:t.item.to,custom:""},{default:v((({navigate:e,href:i,isActive:n,isExactActive:s})=>[y((c(),u("a",{href:i,class:p(l.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:i=>l.onItemActionClick(i,e)},[t.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",t.item.icon])},null,2)):x("",!0),m("span",z,k(l.label()),1)],10,K)),[[a]])])),_:1},8,["to"])):y((c(),u("a",{key:1,href:t.item.url,class:p(l.linkClass()),target:t.item.target,tabindex:"-1","aria-hidden":"true"},[t.item.icon?(c(),u("span",{key:0,class:p(["p-menuitem-icon",t.item.icon])},null,2)):x("",!0),m("span",D,k(l.label()),1)],10,$)),[[a]])],64))])],14,S)):x("",!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 i=e.item;this.disabled(i)||(i.command&&i.command(e),i.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"Tab":this.overlayVisible&&this.hide()}},onArrowDownKey(e){const i=this.findNextOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(i),e.preventDefault()},onArrowUpKey(e){if(e.altKey&&this.popup)s.focus(this.target),this.hide(),e.preventDefault();else{const i=this.findPrevOptionIndex(this.focusedOptionIndex);this.changeFocusedOptionIndex(i),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 i=s.findSingle(this.list,`li[id="${this.focusedOptionIndex}"]`),t=i&&s.findSingle(i,".p-menuitem-link");this.popup&&s.focus(this.target),t?t.click():i&&i.click(),e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},findNextOptionIndex(e){const i=[...s.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((i=>i.id===e));return i>-1?i+1:0},findPrevOptionIndex(e){const i=[...s.find(this.container,"li.p-menuitem:not(.p-disabled)")].findIndex((i=>i.id===e));return i>-1?i-1:0},changeFocusedOptionIndex(e){const i=s.find(this.container,"li.p-menuitem:not(.p-disabled)");let t=e>i.length?i.length-1:e<0?0:e;t>-1&&i.length>0&&(this.focusedOptionIndex=i[t].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 i=this.container&&!this.container.contains(e.target),t=!(this.target&&(this.target===e.target||this.target.contains(e.target)));this.overlayVisible&&i&&t?this.hide():!this.popup&&i&&t&&(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(i){e.emit("overlay-click",{originalEvent:i,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:i}};const F=["id"],H=["id","tabindex","aria-activedescendant","aria-label","aria-labelledby"],R=["id"];!function(e,i){void 0===i&&(i={});var t=i.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===t&&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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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,i,t,n,s,l){const o=r("PVMenuitem"),a=r("Portal");return c(),f(a,{appendTo:t.appendTo,disabled:!t.popup},{default:v((()=>[I(L,{name:"p-connected-overlay",onEnter:l.onEnter,onLeave:l.onLeave,onAfterLeave:l.onAfterLeave},{default:v((()=>[!t.popup||s.overlayVisible?(c(),u("div",O({key:0,ref:l.containerRef,id:l.id,class:l.containerClass},e.$attrs,{onClick:i[3]||(i[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:t.tabindex,"aria-activedescendant":s.focused?l.focusedOptionId:void 0,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,onFocus:i[0]||(i[0]=(...e)=>l.onListFocus&&l.onListFocus(...e)),onBlur:i[1]||(i[1]=(...e)=>l.onListBlur&&l.onListBlur(...e)),onKeydown:i[2]||(i[2]=(...e)=>l.onListKeyDown&&l.onListKeyDown(...e))},[(c(!0),u(b,null,C(t.model,((i,n)=>(c(),u(b,{key:l.label(i)+n.toString()},[i.items&&l.visible(i)&&!i.separator?(c(),u(b,{key:0},[i.items?(c(),u("li",{key:0,id:l.id+"_"+n,class:"p-submenu-header",role:"none"},[w(e.$slots,"item",{item:i},(()=>[E(k(l.label(i)),1)]))],8,R)):x("",!0),(c(!0),u(b,null,C(i.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:t.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(i)),style:h(s.style),role:"separator"},null,6)):x("",!0)],64)))),128))],64)):l.visible(i)&&i.separator?(c(),u("li",{key:"separator"+n.toString(),class:p(l.separatorClass(i)),style:h(i.style),role:"separator"},null,6)):(c(),f(o,{key:l.label(i)+n.toString(),id:l.id+"_"+n,item:i,template:e.$slots.item,exact:t.exact,focusedOptionId:l.focusedOptionId,onItemClick:l.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"]))],64)))),128))],40,H)],16,F)):x("",!0)])),_:3},8,["onEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo","disabled"])};export{V as default};
|
package/menu/menu.js
CHANGED
|
@@ -343,9 +343,9 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
343
343
|
},
|
|
344
344
|
changeFocusedOptionIndex(index) {
|
|
345
345
|
const links = utils.DomHandler.find(this.container, 'li.p-menuitem:not(.p-disabled)');
|
|
346
|
-
let order = index
|
|
346
|
+
let order = index > links.length ? links.length - 1 : index < 0 ? 0 : index;
|
|
347
347
|
|
|
348
|
-
this.focusedOptionIndex = links[order].getAttribute('id');
|
|
348
|
+
order > -1 && links.length > 0 && (this.focusedOptionIndex = links[order].getAttribute('id'));
|
|
349
349
|
},
|
|
350
350
|
toggle(event) {
|
|
351
351
|
if (this.overlayVisible) this.hide();
|
|
@@ -455,8 +455,8 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
455
455
|
label(item) {
|
|
456
456
|
return typeof item.label === 'function' ? item.label() : item.label;
|
|
457
457
|
},
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
separatorClass(item) {
|
|
459
|
+
return ['p-menuitem-separator', item.class];
|
|
460
460
|
},
|
|
461
461
|
onOverlayClick(event) {
|
|
462
462
|
OverlayEventBus__default["default"].emit('overlay-click', {
|
|
@@ -464,6 +464,9 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
464
464
|
target: this.target
|
|
465
465
|
});
|
|
466
466
|
},
|
|
467
|
+
containerRef(el) {
|
|
468
|
+
this.container = el;
|
|
469
|
+
},
|
|
467
470
|
listRef(el) {
|
|
468
471
|
this.list = el;
|
|
469
472
|
}
|
|
@@ -479,9 +482,6 @@ this.primevue.menu = (function (OverlayEventBus, Portal, utils, Ripple, vue) {
|
|
|
479
482
|
}
|
|
480
483
|
];
|
|
481
484
|
},
|
|
482
|
-
separatorClass(item) {
|
|
483
|
-
return ['p-menu-separator p-menuitem-separator', item.class]; // TODO: the 'p-menu-separator' class is deprecated since v3.18.0.
|
|
484
|
-
},
|
|
485
485
|
id() {
|
|
486
486
|
return this.$attrs.id || utils.UniqueComponentId();
|
|
487
487
|
},
|
package/menu/menu.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.menu=function(e,t,i,n,l){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e),a=s(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:s(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,s,o){const a=l.resolveComponent("router-link"),r=l.resolveDirective("ripple");return o.visible()?(l.openBlock(),l.createElementBlock("li",{key:0,id:i.id,class:l.normalizeClass(o.containerClass()),role:"menuitem",style:l.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[l.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(l.openBlock(),l.createBlock(l.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[i.item.to&&!o.disabled()?(l.openBlock(),l.createBlock(a,{key:0,to:i.item.to,custom:""},{default:l.withCtx((({navigate:e,href:t,isActive:n,isExactActive:s})=>[l.withDirectives((l.openBlock(),l.createElementBlock("a",{href:t,class:l.normalizeClass(o.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",u,l.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):l.withDirectives((l.openBlock(),l.createElementBlock("a",{key:1,href:i.item.url,class:l.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",m,l.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):l.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"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;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,containerRef(e){this.container=e},onOverlayClick(e){o.default.emit("overlay-click",{originalEvent:e,target:this.target})},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}]},separatorClass:e=>["p-menu-separator p-menuitem-separator",e.class],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],l=document.createElement("style");l.type="text/css","top"===i&&n.firstChild?n.insertBefore(l,n.firstChild):n.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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,s,o){const a=l.resolveComponent("PVMenuitem"),r=l.resolveComponent("Portal");return l.openBlock(),l.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:l.withCtx((()=>[!i.popup||s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.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))}),[l.createElementVNode("ul",{ref:o.listRef,id:o.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":s.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))},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(i.model,((t,n)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[t.items?(l.openBlock(),l.createElementBlock("li",{key:0,id:o.id+"_"+n,class:"p-submenu-header",role:"none"},[l.renderSlot(e.$slots,"item",{item:t},(()=>[l.createTextVNode(l.toDisplayString(o.label(t)),1)]))],8,k)):l.createCommentVNode("",!0),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(t.items,((s,r)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:s.label+n+"_"+r},[o.visible(s)&&!s.separator?(l.openBlock(),l.createBlock(a,{key:0,id:o.id+"_"+n+"_"+r,item:s,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(s)&&s.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n+r,class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(s.style),role:"separator"},null,6)):l.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n.toString(),class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(t.style),role:"separator"},null,6)):(l.openBlock(),l.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)):l.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,l){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e),a=s(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:s(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,s,o){const a=l.resolveComponent("router-link"),r=l.resolveDirective("ripple");return o.visible()?(l.openBlock(),l.createElementBlock("li",{key:0,id:i.id,class:l.normalizeClass(o.containerClass()),role:"menuitem",style:l.normalizeStyle(i.item.style),"aria-label":o.label(),"aria-disabled":o.disabled()},[l.createElementVNode("div",{class:"p-menuitem-content",onClick:t[0]||(t[0]=e=>o.onItemClick(e))},[i.template?(l.openBlock(),l.createBlock(l.resolveDynamicComponent(i.template),{key:1,item:i.item},null,8,["item"])):(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[i.item.to&&!o.disabled()?(l.openBlock(),l.createBlock(a,{key:0,to:i.item.to,custom:""},{default:l.withCtx((({navigate:e,href:t,isActive:n,isExactActive:s})=>[l.withDirectives((l.openBlock(),l.createElementBlock("a",{href:t,class:l.normalizeClass(o.linkClass({isActive:n,isExactActive:s})),tabindex:"-1","aria-hidden":"true",onClick:t=>o.onItemActionClick(t,e)},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",u,l.toDisplayString(o.label()),1)],10,c)),[[r]])])),_:1},8,["to"])):l.withDirectives((l.openBlock(),l.createElementBlock("a",{key:1,href:i.item.url,class:l.normalizeClass(o.linkClass()),target:i.item.target,tabindex:"-1","aria-hidden":"true"},[i.item.icon?(l.openBlock(),l.createElementBlock("span",{key:0,class:l.normalizeClass(["p-menuitem-icon",i.item.icon])},null,2)):l.createCommentVNode("",!0),l.createElementVNode("span",m,l.toDisplayString(o.label()),1)],10,p)),[[r]])],64))])],14,d)):l.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"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&&t.length>0&&(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],l=document.createElement("style");l.type="text/css","top"===i&&n.firstChild?n.insertBefore(l,n.firstChild):n.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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,s,o){const a=l.resolveComponent("PVMenuitem"),r=l.resolveComponent("Portal");return l.openBlock(),l.createBlock(r,{appendTo:i.appendTo,disabled:!i.popup},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onEnter,onLeave:o.onLeave,onAfterLeave:o.onAfterLeave},{default:l.withCtx((()=>[!i.popup||s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.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))}),[l.createElementVNode("ul",{ref:o.listRef,id:o.id+"_list",class:"p-menu-list p-reset",role:"menu",tabindex:i.tabindex,"aria-activedescendant":s.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))},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(i.model,((t,n)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.label(t)+n.toString()},[t.items&&o.visible(t)&&!t.separator?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[t.items?(l.openBlock(),l.createElementBlock("li",{key:0,id:o.id+"_"+n,class:"p-submenu-header",role:"none"},[l.renderSlot(e.$slots,"item",{item:t},(()=>[l.createTextVNode(l.toDisplayString(o.label(t)),1)]))],8,k)):l.createCommentVNode("",!0),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(t.items,((s,r)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:s.label+n+"_"+r},[o.visible(s)&&!s.separator?(l.openBlock(),l.createBlock(a,{key:0,id:o.id+"_"+n+"_"+r,item:s,template:e.$slots.item,exact:i.exact,focusedOptionId:o.focusedOptionId,onItemClick:o.itemClick},null,8,["id","item","template","exact","focusedOptionId","onItemClick"])):o.visible(s)&&s.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n+r,class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(s.style),role:"separator"},null,6)):l.createCommentVNode("",!0)],64)))),128))],64)):o.visible(t)&&t.separator?(l.openBlock(),l.createElementBlock("li",{key:"separator"+n.toString(),class:l.normalizeClass(o.separatorClass(t)),style:l.normalizeStyle(t.style),role:"separator"},null,6)):(l.openBlock(),l.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)):l.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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<slot name="start"></slot>
|
|
5
5
|
</div>
|
|
6
6
|
<a
|
|
7
|
+
v-if="model.length > 0"
|
|
7
8
|
ref="menubutton"
|
|
8
9
|
role="button"
|
|
9
10
|
tabindex="0"
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
class="p-menubar-root-list"
|
|
25
26
|
role="menubar"
|
|
26
27
|
:items="processedItems"
|
|
28
|
+
:template="$slots.item"
|
|
27
29
|
:root="true"
|
|
28
30
|
:mobileActive="mobileActive"
|
|
29
31
|
tabindex="0"
|
|
@@ -76,9 +78,6 @@ export default {
|
|
|
76
78
|
default: null
|
|
77
79
|
}
|
|
78
80
|
},
|
|
79
|
-
outsideClickListener: null,
|
|
80
|
-
container: null,
|
|
81
|
-
menubar: null,
|
|
82
81
|
data() {
|
|
83
82
|
return {
|
|
84
83
|
mobileActive: false,
|
|
@@ -99,6 +98,9 @@ export default {
|
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
},
|
|
101
|
+
outsideClickListener: null,
|
|
102
|
+
container: null,
|
|
103
|
+
menubar: null,
|
|
102
104
|
beforeUnmount() {
|
|
103
105
|
this.mobileActive = false;
|
|
104
106
|
this.unbindOutsideClickListener();
|
package/menubar/MenubarSub.vue
CHANGED
|
@@ -172,7 +172,7 @@ export default {
|
|
|
172
172
|
return ['p-menuitem-icon', this.getItemProp(processedItem, 'icon')];
|
|
173
173
|
},
|
|
174
174
|
getSeparatorItemClass(processedItem) {
|
|
175
|
-
return ['p-
|
|
175
|
+
return ['p-menuitem-separator', this.getItemProp(processedItem, 'class')];
|
|
176
176
|
},
|
|
177
177
|
getSubmenuIcon() {
|
|
178
178
|
return ['p-submenu-icon pi', { 'pi-angle-right': !this.root, 'pi-angle-down': this.root }];
|
package/menubar/menubar.cjs.js
CHANGED
|
@@ -124,7 +124,7 @@ var script$1 = {
|
|
|
124
124
|
return ['p-menuitem-icon', this.getItemProp(processedItem, 'icon')];
|
|
125
125
|
},
|
|
126
126
|
getSeparatorItemClass(processedItem) {
|
|
127
|
-
return ['p-
|
|
127
|
+
return ['p-menuitem-separator', this.getItemProp(processedItem, 'class')];
|
|
128
128
|
},
|
|
129
129
|
getSubmenuIcon() {
|
|
130
130
|
return ['p-submenu-icon pi', { 'pi-angle-right': !this.root, 'pi-angle-down': this.root }];
|
|
@@ -297,9 +297,6 @@ var script = {
|
|
|
297
297
|
default: null
|
|
298
298
|
}
|
|
299
299
|
},
|
|
300
|
-
outsideClickListener: null,
|
|
301
|
-
container: null,
|
|
302
|
-
menubar: null,
|
|
303
300
|
data() {
|
|
304
301
|
return {
|
|
305
302
|
mobileActive: false,
|
|
@@ -320,6 +317,9 @@ var script = {
|
|
|
320
317
|
}
|
|
321
318
|
}
|
|
322
319
|
},
|
|
320
|
+
outsideClickListener: null,
|
|
321
|
+
container: null,
|
|
322
|
+
menubar: null,
|
|
323
323
|
beforeUnmount() {
|
|
324
324
|
this.mobileActive = false;
|
|
325
325
|
this.unbindOutsideClickListener();
|
|
@@ -829,7 +829,7 @@ const _hoisted_4 = [
|
|
|
829
829
|
_hoisted_3
|
|
830
830
|
];
|
|
831
831
|
const _hoisted_5 = {
|
|
832
|
-
key:
|
|
832
|
+
key: 2,
|
|
833
833
|
class: "p-menubar-end"
|
|
834
834
|
};
|
|
835
835
|
|
|
@@ -845,24 +845,28 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
845
845
|
vue.renderSlot(_ctx.$slots, "start")
|
|
846
846
|
]))
|
|
847
847
|
: vue.createCommentVNode("", true),
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
848
|
+
($props.model.length > 0)
|
|
849
|
+
? (vue.openBlock(), vue.createElementBlock("a", vue.mergeProps({
|
|
850
|
+
key: 1,
|
|
851
|
+
ref: "menubutton",
|
|
852
|
+
role: "button",
|
|
853
|
+
tabindex: "0",
|
|
854
|
+
class: "p-menubar-button",
|
|
855
|
+
"aria-haspopup": $props.model.length && $props.model.length > 0 ? true : false,
|
|
856
|
+
"aria-expanded": $data.mobileActive,
|
|
857
|
+
"aria-controls": $options.id,
|
|
858
|
+
"aria-label": _ctx.$primevue.config.locale.aria.navigation,
|
|
859
|
+
onClick: _cache[0] || (_cache[0] = $event => ($options.menuButtonClick($event))),
|
|
860
|
+
onKeydown: _cache[1] || (_cache[1] = $event => ($options.menuButtonKeydown($event)))
|
|
861
|
+
}, $props.buttonProps), _hoisted_4, 16, _hoisted_2))
|
|
862
|
+
: vue.createCommentVNode("", true),
|
|
860
863
|
vue.createVNode(_component_MenubarSub, {
|
|
861
864
|
ref: $options.menubarRef,
|
|
862
865
|
id: $options.id,
|
|
863
866
|
class: "p-menubar-root-list",
|
|
864
867
|
role: "menubar",
|
|
865
868
|
items: $options.processedItems,
|
|
869
|
+
template: _ctx.$slots.item,
|
|
866
870
|
root: true,
|
|
867
871
|
mobileActive: $data.mobileActive,
|
|
868
872
|
tabindex: "0",
|
|
@@ -879,7 +883,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
879
883
|
onKeydown: $options.onKeyDown,
|
|
880
884
|
onItemClick: $options.onItemClick,
|
|
881
885
|
onItemMouseenter: $options.onItemMouseEnter
|
|
882
|
-
}, null, 8, ["id", "items", "mobileActive", "aria-activedescendant", "menuId", "focusedItemId", "activeItemPath", "exact", "aria-labelledby", "aria-label", "onFocus", "onBlur", "onKeydown", "onItemClick", "onItemMouseenter"]),
|
|
886
|
+
}, null, 8, ["id", "items", "template", "mobileActive", "aria-activedescendant", "menuId", "focusedItemId", "activeItemPath", "exact", "aria-labelledby", "aria-label", "onFocus", "onBlur", "onKeydown", "onItemClick", "onItemMouseenter"]),
|
|
883
887
|
(_ctx.$slots.end)
|
|
884
888
|
? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
|
|
885
889
|
vue.renderSlot(_ctx.$slots, "end")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("primevue/utils"),t=require("primevue/ripple"),i=require("vue");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s={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)=>t&&t.item?e.ObjectUtils.getItemValue(t.item[i]):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){const i=this.getItemProp(t,"command");i&&i({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-menu-separator 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:n(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"];s.render=function(e,t,n,s,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(n.items,((s,u)=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:I.getItemKey(s)},[I.isItemVisible(s)&&!I.getItemProp(s,"separator")?(i.openBlock(),i.createElementBlock("li",{key:0,id:I.getItemId(s),style:i.normalizeStyle(I.getItemProp(s,"style")),class:i.normalizeClass(I.getItemClass(s)),role:"menuitem","aria-label":I.getItemLabel(s),"aria-disabled":I.isItemDisabled(s)||void 0,"aria-expanded":I.isItemGroup(s)?I.isItemActive(s):void 0,"aria-haspopup":I.isItemGroup(s)&&!I.getItemProp(s,"to")?"menu":void 0,"aria-level":n.level+1,"aria-setsize":I.getAriaSetSize(),"aria-posinset":I.getAriaPosInset(u)},[i.createElementVNode("div",{class:"p-menuitem-content",onClick:e=>I.onItemClick(e,s),onMouseenter:e=>I.onItemMouseEnter(e,s)},[n.template?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(n.template),{key:1,item:s.item},null,8,["item"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:0},[I.getItemProp(s,"to")&&!I.isItemDisabled(s)?(i.openBlock(),i.createBlock(h,{key:0,to:I.getItemProp(s,"to"),custom:""},{default:i.withCtx((({navigate:e,href:t,isActive:n,isExactActive:o})=>[i.withDirectives((i.openBlock(),i.createElementBlock("a",{href:t,class:i.normalizeClass(I.getItemActionClass(s,{isActive:n,isExactActive:o})),tabindex:"-1","aria-hidden":"true",onClick:t=>I.onItemActionClick(t,e)},[I.getItemProp(s,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(s))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",l,i.toDisplayString(I.getItemLabel(s)),1)],10,a)),[[f]])])),_:2},1032,["to"])):i.withDirectives((i.openBlock(),i.createElementBlock("a",{key:1,href:I.getItemProp(s,"url"),class:i.normalizeClass(I.getItemActionClass(s)),target:I.getItemProp(s,"target"),tabindex:"-1","aria-hidden":"true"},[I.getItemProp(s,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(s))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",c,i.toDisplayString(I.getItemLabel(s)),1),I.getItemProp(s,"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(s)&&I.isItemGroup(s)?(i.openBlock(),i.createBlock(p,{key:0,menuId:n.menuId,role:"menu",class:"p-submenu-list",focusedItemId:n.focusedItemId,items:s.items,mobileActive:n.mobileActive,activeItemPath:n.activeItemPath,template:n.template,exact:n.exact,level:n.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(s)&&I.getItemProp(s,"separator")?(i.openBlock(),i.createElementBlock("li",{key:1,id:I.getItemId(s),style:i.normalizeStyle(I.getItemProp(s,"style")),class:i.normalizeClass(I.getSeparatorItemClass(s)),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}},outsideClickListener:null,container:null,menubar: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())}},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:n}=t;if(e.ObjectUtils.isEmpty(i))return;const{index:s,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:s,level:r,parentKey:a},this.activeItemPath=c,m&&(this.dirty=!0),n&&e.DomHandler.focus(this.menubar)},onItemClick(t){const{originalEvent:i,processedItem:n}=t,s=this.isProccessedItemGroup(n),o=e.ObjectUtils.isEmpty(n.parent);if(this.isSelected(n)){const{index:t,key:i,level:s,parentKey:r}=n;this.activeItemPath=this.activeItemPath.filter((e=>i!==e.key&&i.startsWith(e.key))),this.focusedItemInfo={index:t,level:s,parentKey:r},this.dirty=!o,e.DomHandler.focus(this.menubar)}else s?this.onItemChange(t):(this.hide(i,!0),this.mobileActive=!1)},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 n=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(n)&&(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,n=!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&&(n=!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),n},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,n=e.DomHandler.findSingle(this.menubar,`li[id="${i}"]`);n&&n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"})},createProcessedItems(e,t=0,i={},n=""){const s=[];return e&&e.forEach(((e,o)=>{const r=(""!==n?n+"_":"")+o,a={item:e,index:o,level:t,key:r,parent:i,parentKey:n};a.items=this.createProcessedItems(e.items,t+1,a,r),s.push(a)})),s},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:s}};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:1,class:"p-menubar-end"};!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-menubar {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n}\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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -ms-flex-wrap: wrap;\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 -ms-flex-item-align: center;\n align-self: center;\n}\n.p-menubar-button {\n display: none;\n cursor: pointer;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n text-decoration: none;\n}\n"),u.render=function(e,t,n,s,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),i.createElementVNode("a",i.mergeProps({ref:"menubutton",role:"button",tabindex:"0",class:"p-menubar-button","aria-haspopup":!!(n.model.length&&n.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))},n.buttonProps),p,16,h),i.createVNode(a,{ref:r.menubarRef,id:r.id,class:"p-menubar-root-list",role:"menubar",items:r.processedItems,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:n.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","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 n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s={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)=>t&&t.item?e.ObjectUtils.getItemValue(t.item[i]):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){const i=this.getItemProp(t,"command");i&&i({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:n(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"];s.render=function(e,t,n,s,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(n.items,((s,u)=>(i.openBlock(),i.createElementBlock(i.Fragment,{key:I.getItemKey(s)},[I.isItemVisible(s)&&!I.getItemProp(s,"separator")?(i.openBlock(),i.createElementBlock("li",{key:0,id:I.getItemId(s),style:i.normalizeStyle(I.getItemProp(s,"style")),class:i.normalizeClass(I.getItemClass(s)),role:"menuitem","aria-label":I.getItemLabel(s),"aria-disabled":I.isItemDisabled(s)||void 0,"aria-expanded":I.isItemGroup(s)?I.isItemActive(s):void 0,"aria-haspopup":I.isItemGroup(s)&&!I.getItemProp(s,"to")?"menu":void 0,"aria-level":n.level+1,"aria-setsize":I.getAriaSetSize(),"aria-posinset":I.getAriaPosInset(u)},[i.createElementVNode("div",{class:"p-menuitem-content",onClick:e=>I.onItemClick(e,s),onMouseenter:e=>I.onItemMouseEnter(e,s)},[n.template?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(n.template),{key:1,item:s.item},null,8,["item"])):(i.openBlock(),i.createElementBlock(i.Fragment,{key:0},[I.getItemProp(s,"to")&&!I.isItemDisabled(s)?(i.openBlock(),i.createBlock(h,{key:0,to:I.getItemProp(s,"to"),custom:""},{default:i.withCtx((({navigate:e,href:t,isActive:n,isExactActive:o})=>[i.withDirectives((i.openBlock(),i.createElementBlock("a",{href:t,class:i.normalizeClass(I.getItemActionClass(s,{isActive:n,isExactActive:o})),tabindex:"-1","aria-hidden":"true",onClick:t=>I.onItemActionClick(t,e)},[I.getItemProp(s,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(s))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",l,i.toDisplayString(I.getItemLabel(s)),1)],10,a)),[[f]])])),_:2},1032,["to"])):i.withDirectives((i.openBlock(),i.createElementBlock("a",{key:1,href:I.getItemProp(s,"url"),class:i.normalizeClass(I.getItemActionClass(s)),target:I.getItemProp(s,"target"),tabindex:"-1","aria-hidden":"true"},[I.getItemProp(s,"icon")?(i.openBlock(),i.createElementBlock("span",{key:0,class:i.normalizeClass(I.getItemIconClass(s))},null,2)):i.createCommentVNode("",!0),i.createElementVNode("span",c,i.toDisplayString(I.getItemLabel(s)),1),I.getItemProp(s,"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(s)&&I.isItemGroup(s)?(i.openBlock(),i.createBlock(p,{key:0,menuId:n.menuId,role:"menu",class:"p-submenu-list",focusedItemId:n.focusedItemId,items:s.items,mobileActive:n.mobileActive,activeItemPath:n.activeItemPath,template:n.template,exact:n.exact,level:n.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(s)&&I.getItemProp(s,"separator")?(i.openBlock(),i.createElementBlock("li",{key:1,id:I.getItemId(s),style:i.normalizeStyle(I.getItemProp(s,"style")),class:i.normalizeClass(I.getSeparatorItemClass(s)),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:n}=t;if(e.ObjectUtils.isEmpty(i))return;const{index:s,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:s,level:r,parentKey:a},this.activeItemPath=c,m&&(this.dirty=!0),n&&e.DomHandler.focus(this.menubar)},onItemClick(t){const{originalEvent:i,processedItem:n}=t,s=this.isProccessedItemGroup(n),o=e.ObjectUtils.isEmpty(n.parent);if(this.isSelected(n)){const{index:t,key:i,level:s,parentKey:r}=n;this.activeItemPath=this.activeItemPath.filter((e=>i!==e.key&&i.startsWith(e.key))),this.focusedItemInfo={index:t,level:s,parentKey:r},this.dirty=!o,e.DomHandler.focus(this.menubar)}else s?this.onItemChange(t):(this.hide(i,!0),this.mobileActive=!1)},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 n=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(n)&&(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,n=!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&&(n=!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),n},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,n=e.DomHandler.findSingle(this.menubar,`li[id="${i}"]`);n&&n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"})},createProcessedItems(e,t=0,i={},n=""){const s=[];return e&&e.forEach(((e,o)=>{const r=(""!==n?n+"_":"")+o,a={item:e,index:o,level:t,key:r,parent:i,parentKey:n};a.items=this.createProcessedItems(e.items,t+1,a,r),s.push(a)})),s},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:s}};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 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-menubar {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n}\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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\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: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -ms-flex-wrap: wrap;\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 -ms-flex-item-align: center;\n align-self: center;\n}\n.p-menubar-button {\n display: none;\n cursor: pointer;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n text-decoration: none;\n}\n"),u.render=function(e,t,n,s,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),n.model.length>0?(i.openBlock(),i.createElementBlock("a",i.mergeProps({key:1,ref:"menubutton",role:"button",tabindex:"0",class:"p-menubar-button","aria-haspopup":!!(n.model.length&&n.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))},n.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:n.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;
|