UNPKG

primereact

Version:

PrimeReact is an open source UI library for React featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime

2 lines (1 loc) 27.2 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/api"),n=require("primereact/button"),r=require("primereact/componentbase"),o=require("primereact/hooks"),i=require("primereact/icons/chevrondown"),u=require("primereact/overlayservice"),a=require("primereact/csstransition"),l=require("primereact/portal"),c=require("primereact/utils"),s=require("primereact/icons/angleright"),p=require("primereact/ripple"),d=require("primereact/tooltip");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var b=f(e),y=m(t);function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(this,arguments)}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function x(e,t){if("object"!==g(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==g(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function h(e){var t=x(e,"string");return"symbol"===g(t)?t:String(t)}function I(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e){if(Array.isArray(e))return e}function E(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,u,a=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(u=n.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function S(e,t){if(e){if("string"==typeof e)return w(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(e,t):void 0}}function k(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function N(e,t){return O(e)||E(e,t)||S(e,t)||k()}var P=r.ComponentBase.extend({defaultProps:{__TYPE:"TieredMenu",__parentMetadata:null,id:null,model:null,popup:!1,style:null,className:null,autoZIndex:!0,baseZIndex:0,breakpoint:void 0,scrollHeight:"400px",appendTo:null,transitionOptions:null,onShow:null,onFocus:null,onBlur:null,onHide:null,submenuIcon:null,children:void 0},css:{classes:{root:function(e){var t=e.context;return c.classNames("p-tieredmenu p-component",{"p-tieredmenu-overlay":e.props.popup,"p-input-filled":t&&"filled"===t.inputStyle||"filled"===y.default.inputStyle,"p-ripple-disabled":t&&!1===t.ripple||!1===y.default.ripple})},separator:"p-menuitem-separator",icon:function(e){return c.classNames("p-menuitem-icon",e._icon)},content:"p-menuitem-content",label:"p-menuitem-text",submenuIcon:"p-submenu-icon",action:"p-menuitem-link",menuitem:function(e){return c.classNames("p-menuitem",{"p-menuitem-active p-highlight":e.active,"p-focus":e.focused,"p-disabled":e.disabled},e.itemClassName)},menu:"p-tieredmenu-root-list",submenu:"p-submenu-list",transition:"p-connected-overlay"},styles:"\n@layer primereact {\n .p-tieredmenu-overlay {\n position: absolute;\n }\n\n .p-tieredmenu ul {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .p-tieredmenu .p-submenu-list {\n position: absolute;\n min-width: 100%;\n z-index: 1;\n display: none;\n }\n\n .p-tieredmenu .p-menuitem-link {\n cursor: pointer;\n display: flex;\n align-items: center;\n text-decoration: none;\n overflow: hidden;\n position: relative;\n }\n\n .p-tieredmenu .p-menuitem-text {\n line-height: 1;\n }\n\n .p-tieredmenu .p-menuitem {\n position: relative;\n }\n\n .p-tieredmenu .p-menuitem-link .p-submenu-icon {\n margin-left: auto;\n }\n\n .p-tieredmenu .p-menuitem-active > .p-submenu-list {\n display: block;\n left: 100%;\n top: 0;\n }\n\n .p-tieredmenu .p-menuitem-active > .p-submenu-list-flipped {\n left: -100%;\n }\n}\n",inlineStyles:{submenu:function(e){var t=e.subProps;return{display:!t.root&&t.parentActive?"block":"none"}}}}});function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var H=b.memo(b.forwardRef((function(e,t){var n=b.useRef(null),r=o.useMergeProps(),i=e.ptm,u=e.cx,a=e.sx,l=function(t,n){return i(n,{hostName:e.hostName,context:{active:v(t)}})},d=function(){if(n.current){var e=n.current.parentElement,t=c.DomHandler.getOffset(e),r=c.DomHandler.getViewport(),o=n.current.offsetParent?n.current.offsetWidth:c.DomHandler.getHiddenElementOuterWidth(n.current),i=c.DomHandler.getOuterWidth(e.children[0]),u=parseInt(t.top,10)+n.current.offsetHeight-c.DomHandler.getWindowScrollTop();n.current.style.top=u>r.height?r.height-u+"px":"0px",parseInt(t.left,10)+i+o>r.width-c.DomHandler.calculateScrollbarWidth()&&c.DomHandler.addClass(n.current,"p-submenu-list-flipped")}},m=function(t,n){var r=n.item;x(n)?t.preventDefault():(r.command&&r.command({originalEvent:t,item:r}),e.onItemClick&&e.onItemClick({originalEvent:t,processedItem:n}),r.url||(t.preventDefault(),t.stopPropagation()))},f=function(t){return"".concat(e.menuId,"_").concat(t.key)},y=function(e,t,n){return e&&e.item?c.ObjectUtils.getItemValue(e.item[t],n):void 0},v=function(t){return e.activeItemPath.some((function(e){return e.key===t.key}))},g=function(e){return!1!==y(e,"visible")},x=function(e){return y(e,"disabled")},h=function(t){return e.focusedItemId===f(t)},I=function(e){return c.ObjectUtils.isNotEmpty(e.items)},O=function(t,n){e.onItemMouseEnter&&e.onItemMouseEnter({originalEvent:t,processedItem:n})},E=function(t){return t-e.model.slice(0,t).filter((function(e){return g(e)&&y(e,"separator")})).length+1};o.useUpdateEffect((function(){e.root||!e.parentActive||e.isMobileMode||d()}),[e.parentActive]),b.useImperativeHandle(t,(function(){return{getElement:function(){return n.current}}}));var w=function(t){var n=r({key:"separator_"+t,className:u("separator"),role:"separator"},i("separator",{hostName:e.hostName}));return b.createElement("li",n)},S=function(t,n){return I(t)?b.createElement(H,{id:e.id+"_"+n,menuProps:e.menuProps,model:t.items,menuId:e.menuId,ariaLabelledby:f(t),focusedItemId:e.focusedItemId,activeItemPath:e.activeItemPath,level:e.level+1,onItemClick:e.onItemClick,popup:e.popup,onItemMouseEnter:e.onItemMouseEnter,parentActive:v(t),isMobileMode:e.isMobileMode,submenuIcon:e.submenuIcon,ptm:e.ptm,cx:u,sx:a}):null},k=function(t,n){if(!1===g(t))return null;var o=t.item,i=y(t,"style"),a=y(t,"className"),d=y(t,"icon"),w=y(t,"target"),k=y(t,"url"),N=f(t),P=h(t),j=v(t),H=x(t),C=I(t),M=c.classNames("p-menuitem-link"),U=c.classNames("p-menuitem-icon",d),T=r({className:c.classNames(o.icon,"p-menuitem-icon","icon")},l(t,"icon")),K=c.IconUtils.getJSXIcon(d,D({},T),{props:e.menuProps}),_=r({className:u("label")},l(t,"label")),R=o.label&&b.createElement("span",_,o.label),B=r({className:u("submenuIcon")},l(t,"submenuIcon")),L=C&&c.IconUtils.getJSXIcon(e.submenuIcon||b.createElement(s.AngleRightIcon,B),D({},B),{props:e.menuProps}),A=S(t,n),Z=r({href:k||"#","aria-hidden":!0,tabIndex:"-1",onFocus:function(e){return e.stopPropagation()},className:u("action"),target:w},l(t,"action")),q=b.createElement("a",Z,K,R,L,b.createElement(p.Ripple,null));o.template&&(q=c.ObjectUtils.getJSXElement(o.template,o,{className:M,labelClassName:"p-menuitem-text",iconClassName:U,submenuIconClassName:"p-submenu-icon",element:q,props:e,active:j,disabled:H}));var z=r({onClick:function(e){return m(e,t)},onMouseEnter:function(e){return O(e,t)},className:u("content")},l(t,"content")),F=r({key:N,id:N,"aria-label":o.label,"aria-disabled":H,"aria-expanded":C?j:void 0,"aria-haspopup":C&&!k?"menu":void 0,"aria-setsize":e.model.filter((function(e){return g(e)&&!y(e,"separator")})).length,"aria-posinset":E(n),"data-p-highlight":j,"data-p-disabled":H,"data-p-visited":P,className:u("menuitem",{itemClassName:a,active:j,focused:P,disabled:H}),style:i,onMouseEnter:function(e){return O(e,o)},role:"menuitem"},l(t,"menuitem"));return b.createElement("li",F,b.createElement("div",z,q),A)},N=e.model?e.model.map((function(e,t){return!1===e.visible?null:y(e,"separator")?w(t):k(e,t)})):null,P=e.root?"menu":"submenu",j=r({ref:n,id:e.id,tabIndex:e.tabIndex,onFocus:e.onFocus,onBlur:e.onBlur,onKeyDown:e.onKeyDown,className:u(P,{subProps:e}),style:a(P,{subProps:e}),role:e.root?"menubar":"menu","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-orientation":e.ariaOrientation,"aria-activedescendant":e.focusedItemId},i(P,{hostName:e.hostName}));return b.createElement("ul",j,N)})));function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?C(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}H.displayName="TieredMenuSub";var U=b.memo(b.forwardRef((function(e,n){var i=o.useMergeProps(),s=b.useContext(t.PrimeReactContext),p=P.getProps(e,s),d=N(b.useState(p.id),2),m=d[0],f=d[1],g=N(b.useState(!p.popup),2),x=g[0],h=g[1],I=N(b.useState([]),2),O=I[0],E=I[1],w=N(b.useState(!1),2),S=w[0],k=w[1],j=N(b.useState(null),2),D=j[0],C=j[1],U=N(b.useState({index:-1,level:0,parentKey:""}),2),T=U[0],K=U[1],_=N(b.useState(!1),2),R=_[0],B=_[1],L=N(b.useState([]),2),A=L[0],Z=L[1],q=N(b.useState([]),2),z=q[0],F=q[1],W=N(b.useState(!1),2),V=W[0],J=W[1],X=N(b.useState(null),2),Y=X[0],G=X[1],$=M(M({props:p},p.__parentMetadata),{},{state:{id:m,visible:x,attributeSelector:Y}}),Q=P.setMetaData($),ee=Q.ptm,te=Q.cx,ne=Q.sx;r.useHandleStyle(P.css.styles,Q.isUnstyled,{name:"tieredmenu"});var re=b.useRef(null),oe=b.useRef(null),ie=b.useRef(null),ue=b.useRef(null),ae=b.useRef(null),le=b.useRef(null),ce=b.useRef(null),se=o.useMatchMedia("screen and (max-width: ".concat(p.breakpoint,")"),!!p.breakpoint),pe=N(o.useEventListener({type:"click",listener:function(e){var t=re.current&&!re.current.contains(e.target),n=!p.popup||!(ie.current&&(ie.current===e.target||ie.current.contains(e.target)));t&&n&&he(e,!p.popup)}}),2),de=pe[0],me=pe[1],fe=N(o.useResizeListener({listener:function(){!se&&he(event,!0)}}),2),be=fe[0],ye=fe[1],ve=function(e){p.popup&&u.OverlayService.emit("overlay-click",{originalEvent:e,target:ie.current})},ge=function(e){p.popup&&(x?he(e):xe(e))},xe=function(e){p.popup&&(ie.current=e.currentTarget,h(!0),p.onShow&&p.onShow(e),ue.current=e.relatedTarget||null),K({index:Ge(),level:0,parentKey:""})},he=function(e,t){p.popup&&(h(!1),p.onHide&&p.onHide(e));var n=_e();E([]),K({index:-1,level:0,parentKey:""}),t&&c.DomHandler.focus(ue.current||ie.current||n),B(!1)},Ie=function(e){k(!0),K(-1!==T.index?T:{index:Ge(),level:0,parentKey:""}),p.onFocus&&p.onFocus(e)},Oe=function(e){k(!1),K({index:-1,level:0,parentKey:""}),le.current="",B(!1),p.onBlur&&p.onBlur(e)},Ee=function(e){var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":Ne(e);break;case"ArrowUp":Pe(e);break;case"ArrowLeft":je(e);break;case"ArrowRight":De(e);break;case"Home":He(e);break;case"End":Ce(e);break;case"Space":Ue(e);break;case"Enter":case"NumpadEnter":Me(e);break;case"Escape":p.popup&&c.DomHandler.focus(ie.current),Te(e);break;case"Tab":Ke(e);break;case"PageDown":case"PageUp":case"Backspace":case"ShiftLeft":case"ShiftRight":break;default:!t&&c.ObjectUtils.isPrintableCharacter(e.key)&&Qe(e.key)}},we=function(e){var t=e.processedItem,n=e.isFocus;if(!c.ObjectUtils.isEmpty(t)){var r=t.index,o=t.key,i=t.level,u=t.parentKey,a=c.ObjectUtils.isNotEmpty(t.items),l=O.filter((function(e){return e.parentKey!==u&&e.parentKey!==o}));a&&l.push(t),K({index:r,level:i,parentKey:u}),E(l),a&&B(!0),n&&c.DomHandler.focus(_e())}},Se=function(e){var t=e.originalEvent,n=e.processedItem;if(!Be(n)&&!p.isMobileMode){var r=Ae(n),o=c.ObjectUtils.isEmpty(n.parent),i=Fe(n),u=_e();if(i){var a=n.index,l=n.key,s=n.level,d=n.parentKey;E(O.filter((function(e){return l!==e.key&&l.startsWith(e.key)}))),K({index:a,level:s,parentKey:d}),r||B(!o),setTimeout((function(){c.DomHandler.focus(u),r&&B(!0)}),0)}else if(r)c.DomHandler.focus(u),we(e);else{var m=o?n:O.find((function(e){return""===e.parentKey})),f=m?m.index:-1;he(t,!0),K({index:f,parentKey:m?m.parentKey:""})}}},ke=function(e){var t=e.originalEvent;Be(e.processedItem)||p.isMobileMode?t.preventDefault():R&&!p.popup&&we(e)},Ne=function(e){var t=-1!==T.index?Je(T.index):Ge();et(t),e.preventDefault()},Pe=function(e){if(e.altKey){if(p.popup&&c.DomHandler.focus(ie.current),-1!==T.index){var t=z[T.index];!Ae(t)&&we({originalEvent:e,processedItem:t})}p.popup&&he(e,!0),e.preventDefault()}else{var n=-1!==T.index?Xe(T.index):$e();et(n),e.preventDefault()}},je=function(e){var t=z[T.index],n=O.find((function(e){return e.key===t.parentKey}));c.ObjectUtils.isEmpty(t.parent)||(K({index:-1,parentKey:n?n.parentKey:""}),le.current="",setTimeout((function(){return J(!0)}),0)),E(O.filter((function(e){return e.parentKey!==T.parentKey}))),e.preventDefault()},De=function(e){var t=z[T.index];Ae(t)&&(we({originalEvent:e,processedItem:t}),K({index:-1,parentKey:t.key}),le.current="",setTimeout((function(){return J(!0)}),0)),e.preventDefault()},He=function(e){et(We()),e.preventDefault()},Ce=function(e){et(Ve()),e.preventDefault()},Me=function(e){if(-1!==T.index){var t=c.DomHandler.findSingle(_e(),'li[id="'.concat("".concat(D),'"]')),n=t&&c.DomHandler.findSingle(t,'[data-pc-section="action"]');p.popup&&c.DomHandler.focus(ie.current),n?n.click():t&&t.click()}e.preventDefault()},Ue=function(e){Me(e)},Te=function(e){he(e,!0),!p.popup&&K(M(M({},T),{},{index:Ge()})),e.preventDefault()},Ke=function(e){if(-1!==T.index){var t=z[T.index];!Ae(t)&&we({originalEvent:e,processedItem:t})}he(e)},_e=function(){return oe.current.getElement()||null},Re=function(e,t){return e?c.ObjectUtils.getItemValue(e[t]):void 0},Be=function(e){return Re(e,"disabled")},Le=function(e){return e?Re(e.item,"label"):void 0},Ae=function(e){return e&&c.ObjectUtils.isNotEmpty(e.items)},Ze=function(e){return qe(e)&&Le(e).toLocaleLowerCase().startsWith(le.current.toLocaleLowerCase())},qe=function(e){return!!e&&!Be(e.item)&&!Re(e.item,"separator")},ze=function(e){return qe(e)&&Fe(e)},Fe=function(e){return O.some((function(t){return t.key===e.key}))},We=function(){return z.findIndex((function(e){return qe(e)}))},Ve=function(){return c.ObjectUtils.findLastIndex(z,(function(e){return qe(e)}))},Je=function(e){var t=e<z.length-1?z.slice(e+1).findIndex((function(e){return qe(e)})):-1;return t>-1?t+e+1:e},Xe=function(e){var t=e>0?c.ObjectUtils.findLastIndex(z.slice(0,e),(function(e){return qe(e)})):-1;return t>-1?t:e},Ye=function(){return z.findIndex((function(e){return ze(e)}))},Ge=function(){var e=Ye();return e<0?We():e},$e=function(){var e=Ye();return e<0?Ve():e},Qe=function(e){le.current=(le.current||"")+e;var t=-1,n=!1;return-1!==(t=-1!==T.index?-1===(t=z.slice(T.index).findIndex((function(e){return Ze(e)})))?z.slice(0,T.index).findIndex((function(e){return Ze(e)})):t+T.index:z.findIndex((function(e){return Ze(e)})))&&(n=!0),-1===t&&-1===T.index&&(t=Ge()),-1!==t&&et(t),ce.current&&clearTimeout(ce),ce.current=setTimeout((function(){le.current="",ce.current=null}),500),n},et=function(e){T.index!==e&&(K(M(M({},T),{},{index:e})),tt())},tt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=-1!==e?"".concat(m,"_").concat(e):D,n=c.DomHandler.findSingle(_e(),'li[id="'.concat(t,'"]'));n&&n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"})},nt=b.useCallback((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=[];return e&&e.forEach((function(e,i){var u=(""!==r?r+"_":"")+i,a={item:e,index:i,level:t,key:u,parent:n,parentKey:r};a.items=nt(e.items,t+1,a,u),o.push(a)})),o}),[]),rt=function(){if(!ae.current){ae.current=c.DomHandler.createInlineStyle(s&&s.nonce||y.default.nonce,s&&s.styleContainer);var e="".concat(Y),t="\n@media screen and (max-width: ".concat(p.breakpoint,") {\n .p-tieredmenu[").concat(e,"] > ul {\n max-height: ").concat(p.scrollHeight,";\n overflow: ").concat(p.scrollHeight?"auto":"",";\n }\n\n .p-tieredmenu[").concat(e,"] .p-submenu-list {\n position: relative;\n }\n\n .p-tieredmenu[").concat(e,"] .p-menuitem-active > .p-submenu-list {\n left: 0;\n box-shadow: none;\n border-radius: 0;\n padding: 0 0 0 calc(var(--inline-spacing) * 2); /* @todo */\n }\n\n .p-tieredmenu[").concat(e,"] .p-menuitem-active > .p-menuitem-link > .p-submenu-icon {\n transform: rotate(-180deg);\n }\n\n .p-tieredmenu[").concat(e,'] .p-submenu-icon:before {\n content: "\\e930";\n }\n\n ').concat(p.popup?"":".p-tieredmenu[".concat(e,"] { width: 100%; }"),"\n}\n");ae.current.innerHTML=t}},ot=function(){ae.current=c.DomHandler.removeInlineStyle(ae.current)},it=function(){var e;p.autoZIndex&&c.ZIndexUtils.set("menu",re.current,s&&s.autoZIndex||y.default.autoZIndex,p.baseZIndex||s&&s.zIndex.menu||y.default.zIndex.menu),c.DomHandler.addStyles(re.current,{position:"absolute",top:"0",left:"0"}),e=c.DomHandler.getOuterWidth(ie.current)>c.DomHandler.getOuterWidth(re.current),c.DomHandler.alignOverlay(re.current,ie.current,p.appendTo,e),c.DomHandler.focus(oe.current.getElement()),tt(),Y&&p.breakpoint&&(re.current.setAttribute(Y,""),rt())},ut=function(){de(),be()},at=function(){ie.current=null,me(),ye()},lt=function(){c.ZIndexUtils.clear(re.current),ot()};o.useMountEffect((function(){var e=c.UniqueComponentId();!m&&f(e),p.breakpoint&&!Y&&G(e)})),b.useEffect((function(){var e=nt(p.model||[]);Z(e)}),[p.model,nt]),o.useUpdateEffect((function(){var e=O.find((function(e){return e.key===T.parentKey}));F(e?e.items:A)}),[O,T,A]),o.useUpdateEffect((function(){var e=-1!==T.index?"".concat(m).concat(c.ObjectUtils.isNotEmpty(T.parentKey)?"_"+T.parentKey:"","_").concat(T.index):null;C(e)}),[T]),o.useUpdateEffect((function(){p.popup||(c.ObjectUtils.isNotEmpty(O)?(de(),be()):(me(),ye()))}),[O]),o.useUpdateEffect((function(){if(V){var e=-1!==T.index?Je(T.index):Ge();et(e),E(O.filter((function(e){return e.parentKey!==T.parentKey}))),J(!1)}}),[V]),o.useUpdateEffect((function(){return Y&&re.current&&(re.current.setAttribute(Y,""),rt()),function(){ot()}}),[Y,p.breakpoint]),o.useUnmountEffect((function(){c.ZIndexUtils.clear(re.current)})),b.useImperativeHandle(n,(function(){return{props:p,toggle:ge,show:xe,hide:he,getElement:function(){return re.current}}}));var ct,st,pt=(ct=i({ref:re,id:p.id,className:c.classNames(p.className,te("root")),style:p.style,onClick:ve},P.getOtherProps(p),ee("root")),st=i({classNames:te("transition"),in:x,timeout:{enter:120,exit:100},options:p.transitionOptions,unmountOnExit:!0,onEnter:it,onEntered:ut,onExit:at,onExited:lt},ee("transition")),b.createElement(a.CSSTransition,v({nodeRef:re},st),b.createElement("div",ct,b.createElement(H,{id:m+"_list",ref:oe,hostName:"TieredMenu",menuProps:p,tabIndex:0,model:A,ariaLabel:p.ariaLabel,ariaLabelledBy:p.ariaLabelledBy,ariaOrientation:"vertical",ariaActiveDescendant:S?D:void 0,menuId:m,level:0,focusedItemId:D,activeItemPath:O,onFocus:Ie,onBlur:Oe,onKeyDown:Ee,onItemClick:Se,onItemMouseEnter:ke,root:!0,popup:p.popup,onHide:he,isMobileMode:se,submenuIcon:p.submenuIcon,ptm:ee,cx:te,sx:ne}))));return p.popup?b.createElement(l.Portal,{element:pt,appendTo:p.appendTo}):pt})));U.displayName="TieredMenu";var T=r.ComponentBase.extend({defaultProps:{__TYPE:"SplitButton",id:null,label:null,icon:null,autoZIndex:!0,baseZIndex:0,loading:!1,loadingIcon:null,model:null,disabled:null,style:null,className:null,buttonClassName:null,menuStyle:null,menuClassName:null,menuButtonClassName:null,buttonProps:null,menuButtonProps:null,tabIndex:null,severity:null,rounded:!1,raised:!1,outlined:!1,text:!1,size:null,appendTo:null,tooltip:null,tooltipOptions:null,buttonTemplate:null,transitionOptions:null,dropdownIcon:null,onClick:null,onShow:null,onHide:null,children:void 0},css:{classes:{icon:"p-button-icon p-c",root:function(e){var t=e.props,n=e.size;return c.classNames("p-splitbutton p-component",I(I(I(I(I(I({"p-disabled":t.disabled,"p-button-loading-label-only":t.loading&&!t.icon&&t.label},"p-button-".concat(t.severity),t.severity),"p-button-raised",t.raised),"p-button-rounded",t.rounded),"p-button-text",t.text),"p-button-outlined",t.outlined),"p-button-".concat(n),n))},button:"p-splitbutton-defaultbutton",menuButton:"p-splitbutton-menubutton",menu:function(e){return c.classNames("p-menu p-menu-overlay p-component",e.props.menuClassName)},menuList:"p-menu-list p-reset",separator:"p-menu-separator",menuIcon:"p-menuitem-icon",menuLabel:"p-menuitem-text",anchor:function(e){return c.classNames("p-menuitem-link",e._className,{"p-disabled":e.disabled})},menuItem:"p-menuitem",transition:"p-connected-overlay"},styles:"\n@layer primereact {\n .p-splitbutton {\n display: inline-flex;\n position: relative;\n }\n\n .p-splitbutton .p-splitbutton-defaultbutton,\n .p-splitbutton.p-button-rounded > .p-splitbutton-defaultbutton.p-button,\n .p-splitbutton.p-button-outlined > .p-splitbutton-defaultbutton.p-button,\n .p-splitbutton.p-button-outlined > .p-splitbutton-defaultbutton.p-button-outlined.p-button:hover {\n flex: 1 1 auto;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n border-right: 0 none;\n }\n\n .p-splitbutton-menubutton,\n .p-splitbutton.p-button-rounded > .p-splitbutton-menubutton.p-button,\n .p-splitbutton.p-button-outlined > .p-splitbutton-menubutton.p-button {\n display: flex;\n align-items: center;\n justify-content: center;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n\n .p-splitbutton .p-menu {\n min-width: 100%;\n }\n\n .p-fluid .p-splitbutton {\n display: flex;\n }\n}\n"}});function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?K(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var R=b.memo(b.forwardRef((function(e,a){var l=o.useMergeProps(),s=b.useContext(t.PrimeReactContext),p=T.getProps(e,s),m=N(b.useState(p.id),2),f=m[0],g=m[1],x=N(b.useState(!1),2),h=x[0],I=x[1],O=b.useRef(null),E=b.useRef(null),w=b.useRef(null),S=b.useRef(null),k=o.useDisplayOrder("split-button-tooltip",h),P={props:p,state:{id:f,overlayVisible:h}},j=T.setMetaData(P),D=j.ptm,H=j.cx;r.useHandleStyle(T.css.styles,j.isUnstyled,{name:"splitbutton"}),o.useGlobalOnEscapeKey({callback:function(){K()},when:h&&k,priority:[o.ESC_KEY_HANDLING_PRIORITIES.SPLIT_BUTTON,k]});var C=function(e){h?K(e):M(e)},M=function(e){I(!0),E.current&&E.current.show(e)},K=function(e){I(!1),E.current&&E.current.hide(e)};if(o.useMountEffect((function(){f||g(c.UniqueComponentId()),c.DomHandler.alignOverlay(S.current,w.current.parentElement,p.appendTo||s&&s.appendTo||y.default.appendTo)})),o.useUnmountEffect((function(){c.ZIndexUtils.clear(S.current)})),b.useImperativeHandle(a,(function(){return{props:p,show:M,hide:K,getElement:function(){return O.current}}})),!1===p.visible)return null;var R=c.ObjectUtils.isNotEmpty(p.tooltip),B={large:"lg",small:"sm"}[p.size],L=p.buttonTemplate?c.ObjectUtils.getJSXElement(p.buttonTemplate,p):null,A=f+"_overlay",Z=l({ref:O,id:f,className:c.classNames(p.className,H("root",{size:B})),style:p.style},T.getOtherProps(p),D("root"));return b.createElement(b.Fragment,null,b.createElement("div",Z,b.createElement(n.Button,v({ref:w,type:"button",className:c.classNames(p.buttonClassName,H("button")),icon:p.icon,loading:p.loading,loadingIcon:p.loadingIcon,severity:p.severity,label:p.label,"aria-label":p.label,raised:p.raised,onClick:p.onClick,disabled:p.disabled,tabIndex:p.tabIndex,size:p.size,outlined:p.outlined,text:p.text},p.buttonProps,{pt:D("button"),__parentMetadata:{parent:P},unstyled:p.unstyled}),L),b.createElement(n.Button,v({type:"button",className:c.classNames(p.menuButtonClassName,H("menuButton")),icon:function(){var e=l({className:H("icon")},D("icon")),t=c.IconUtils.getJSXIcon(p.dropdownIcon||b.createElement(i.ChevronDownIcon,e),_({},e),{props:p});return t},onClick:C,disabled:p.disabled,"aria-expanded":h,"aria-haspopup":"true","aria-controls":A},p.menuButtonProps,{size:p.size,severity:p.severity,outlined:p.outlined,text:p.text,raised:p.raised,pt:D("menuButton"),__parentMetadata:{parent:P},onKeyDown:function(e){"ArrowDown"!==e.code&&"ArrowUp"!==e.code||(C(e),e.preventDefault())},unstyled:p.unstyled})),b.createElement(U,{ref:E,popup:!0,unstyled:p.unstyled,model:p.model,appendTo:p.appendTo,id:A,style:p.menuStyle,autoZIndex:p.autoZIndex,baseZIndex:p.baseZIndex,className:c.classNames(p.menuClassName,H("menu")),onClick:function(e){u.OverlayService.emit("overlay-click",{originalEvent:e,target:O.current})},onShow:function(){p.onShow&&p.onShow()},onHide:function(){I(!1),p.onHide&&p.onHide()},pt:D("menu"),__parentMetadata:{parent:P}})),R&&b.createElement(d.Tooltip,v({target:O,content:p.tooltip,pt:D("tooltip")},p.tooltipOptions)))})));R.displayName="SplitButton",exports.SplitButton=R;