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) • 23.7 kB
JavaScript
import*as e from"react";import t from"react";import n,{PrimeReactContext as r,ariaLabel as o}from"primereact/api";import{ComponentBase as i,useHandleStyle as a}from"primereact/componentbase";import{CSSTransition as l}from"primereact/csstransition";import{useStyle as c,useMountEffect as s,useMergeProps as u,useDisplayOrder as p,useGlobalOnEscapeKey as d,ESC_KEY_HANDLING_PRIORITIES as m,useEventListener as f,useUpdateEffect as g,useUnmountEffect as b}from"primereact/hooks";import{ObjectUtils as h,DomHandler as y,classNames as v,UniqueComponentId as x,ZIndexUtils as w,IconUtils as O}from"primereact/utils";import{TimesIcon as S}from"primereact/icons/times";import{WindowMaximizeIcon as E}from"primereact/icons/windowmaximize";import{WindowMinimizeIcon as P}from"primereact/icons/windowminimize";import{Portal as z}from"primereact/portal";import{Ripple as k}from"primereact/ripple";function j(){return j=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},j.apply(this,arguments)}function I(e){return I="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},I(e)}function D(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 R(e){if(Array.isArray(e))return D(e)}function C(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _(e,t){if(e){if("string"==typeof e)return D(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)?D(e,t):void 0}}function N(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e,t){if("object"!==I(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==I(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function M(e){var t=T(e,"string");return"symbol"===I(t)?t:String(t)}function F(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B(e){if(Array.isArray(e))return e}function X(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return l}}function A(){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 H(e,t){return B(e)||X(e,t)||_(e,t)||A()}var Y=i.extend({defaultProps:{__TYPE:"FocusTrap",children:void 0},css:{styles:""},getProps:function(e){return h.getMergedProps(e,Y.defaultProps)},getOtherProps:function(e){return h.getDiffProps(e,Y.defaultProps)}});function $(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 L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$(Object(n),!0).forEach((function(t){F(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var V=t.memo(t.forwardRef((function(e,n){var o=t.useRef(null),i=t.useRef(null),a=t.useRef(null),l=t.useContext(r),u=Y.getProps(e,l),p={props:u};c(Y.css.styles,{name:"focustrap"});Y.setMetaData(L({},p));t.useImperativeHandle(n,(function(){return{props:u,getInk:function(){return i.current},getTarget:function(){return o.current}}})),s((function(){u.disabled||(o.current=h(),v(o.current))}));var d,m,f,g,b,h=function(){return i.current&&i.current.parentElement},v=function(e){var t=u||{},n=t.autoFocusSelector,r=t.firstFocusableSelector,o=void 0===r?"":r,i=t.autoFocus,a=void 0!==i&&i,l="".concat(x(void 0===n?"":n)),c="[autofocus]".concat(l,", [data-pc-autofocus='true']").concat(l),s=y.getFirstFocusableElement(e,c);a&&!s&&(s=y.getFirstFocusableElement(e,x(o))),y.focus(s)},x=function(e){return':not(.p-hidden-focusable):not([data-p-hidden-focusable="true"])'.concat(null!=e?e:"")},w=function(e){var t,n=e.currentTarget,r=e.relatedTarget,i=r!==n.$_pfocustrap_firsthiddenfocusableelement&&null!==(t=o.current)&&void 0!==t&&t.contains(r)?n.$_pfocustrap_firsthiddenfocusableelement:y.getLastFocusableElement(n.parentElement,x(n.$_pfocustrap_focusableselector));y.focus(i)};return m=void 0===(d=(u||{}).tabIndex)?0:d,g=(f=function(e,n){return t.createElement("span",{ref:"firstfocusableelement"===n?i:a,className:"p-hidden-accessible p-hidden-focusable",tabIndex:m,role:"presentation","aria-hidden":!0,"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0,onFocus:e,"data-pc-section":n})})((function(e){var t,n=e.currentTarget,r=e.relatedTarget,i=r!==n.$_pfocustrap_lasthiddenfocusableelement&&null!==(t=o.current)&&void 0!==t&&t.contains(r)?n.$_pfocustrap_lasthiddenfocusableelement:y.getFirstFocusableElement(n.parentElement,x(n.$_pfocustrap_focusableselector));y.focus(i)}),"firstfocusableelement"),b=f(w,"lastfocusableelement"),g.ref.current&&b.ref.current&&(g.ref.current.$_pfocustrap_lasthiddenfocusableelement=b.ref.current,b.ref.current.$_pfocustrap_firsthiddenfocusableelement=g.ref.current),t.createElement(t.Fragment,null,g,u.children,b)})));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 Z(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){F(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 U=i.extend({defaultProps:{__TYPE:"Dialog",__parentMetadata:null,appendTo:null,ariaCloseIconLabel:null,baseZIndex:0,blockScroll:!1,breakpoints:null,className:null,closable:!0,closeIcon:null,closeOnEscape:!0,content:null,contentClassName:null,contentStyle:null,dismissableMask:!1,draggable:!0,focusOnShow:!0,footer:null,footerClassName:null,header:null,headerClassName:null,headerStyle:null,icons:null,id:null,keepInViewport:!0,maskClassName:null,maskStyle:null,maximizable:!1,maximizeIcon:null,maximized:!1,minX:0,minY:0,minimizeIcon:null,modal:!0,onClick:null,onDrag:null,onDragEnd:null,onDragStart:null,onHide:null,onMaskClick:null,onMaximize:null,onResize:null,onResizeEnd:null,onResizeStart:null,onShow:null,position:"center",resizable:!0,rtl:!1,showHeader:!0,style:null,transitionOptions:null,visible:!1,children:void 0},css:{classes:{closeButtonIcon:"p-dialog-header-close-icon",closeButton:"p-dialog-header-icon p-dialog-header-close p-link",maximizableIcon:"p-dialog-header-maximize-icon",maximizableButton:"p-dialog-header-icon p-dialog-header-maximize p-link",header:function(e){return v("p-dialog-header",e.props.headerClassName)},headerTitle:"p-dialog-title",headerIcons:"p-dialog-header-icons",content:function(e){return v("p-dialog-content",e.props.contentClassName)},footer:function(e){return v("p-dialog-footer",e.props.footerClassName)},mask:function(e){var t=e.props,n=e.maskVisibleState,r=["center","left","right","top","top-left","top-right","bottom","bottom-left","bottom-right"].find((function(e){return e===t.position||e.replace("-","")===t.position}));return v("p-dialog-mask",r?"p-dialog-".concat(r):"",{"p-component-overlay p-component-overlay-enter":t.modal,"p-dialog-visible":n,"p-dialog-draggable":t.draggable,"p-dialog-resizable":t.resizable},t.maskClassName)},root:function(e){var t=e.maximized,r=e.context;return v("p-dialog p-component",{"p-dialog-rtl":e.props.rtl,"p-dialog-maximized":t,"p-dialog-default":!t,"p-input-filled":r&&"filled"===r.inputStyle||"filled"===n.inputStyle,"p-ripple-disabled":r&&!1===r.ripple||!1===n.ripple})},transition:"p-dialog"},styles:"\n@layer primereact {\n .p-dialog-mask {\n background-color: transparent;\n transition-property: background-color;\n }\n\n .p-dialog-visible {\n display: flex;\n }\n\n .p-dialog-mask.p-component-overlay {\n pointer-events: auto;\n }\n\n .p-dialog {\n display: flex;\n flex-direction: column;\n pointer-events: auto;\n max-height: 90%;\n transform: scale(1);\n position: relative;\n }\n\n .p-dialog-content {\n overflow-y: auto;\n flex-grow: 1;\n }\n\n .p-dialog-header {\n display: flex;\n align-items: center;\n flex-shrink: 0;\n }\n\n .p-dialog-footer {\n flex-shrink: 0;\n }\n\n .p-dialog .p-dialog-header-icons {\n display: flex;\n align-items: center;\n align-self: flex-start;\n flex-shrink: 0;\n }\n\n .p-dialog .p-dialog-header-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n position: relative;\n }\n\n .p-dialog .p-dialog-title {\n flex-grow: 1;\n }\n\n /* Fluid */\n .p-fluid .p-dialog-footer .p-button {\n width: auto;\n }\n\n /* Animation */\n /* Center */\n .p-dialog-enter {\n opacity: 0;\n transform: scale(0.7);\n }\n\n .p-dialog-enter-active {\n opacity: 1;\n transform: scale(1);\n transition: all 150ms cubic-bezier(0, 0, 0.2, 1);\n }\n\n .p-dialog-enter-done {\n transform: none;\n }\n\n .p-dialog-exit-active {\n opacity: 0;\n transform: scale(0.7);\n transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);\n }\n\n /* Top, Bottom, Left, Right, Top* and Bottom* */\n .p-dialog-top .p-dialog,\n .p-dialog-bottom .p-dialog,\n .p-dialog-left .p-dialog,\n .p-dialog-right .p-dialog,\n .p-dialog-top-left .p-dialog,\n .p-dialog-top-right .p-dialog,\n .p-dialog-bottom-left .p-dialog,\n .p-dialog-bottom-right .p-dialog {\n margin: 0.75em;\n }\n\n .p-dialog-top .p-dialog-enter,\n .p-dialog-top .p-dialog-exit-active {\n transform: translate3d(0px, -100%, 0px);\n }\n\n .p-dialog-bottom .p-dialog-enter,\n .p-dialog-bottom .p-dialog-exit-active {\n transform: translate3d(0px, 100%, 0px);\n }\n\n .p-dialog-left .p-dialog-enter,\n .p-dialog-left .p-dialog-exit-active,\n .p-dialog-top-left .p-dialog-enter,\n .p-dialog-top-left .p-dialog-exit-active,\n .p-dialog-bottom-left .p-dialog-enter,\n .p-dialog-bottom-left .p-dialog-exit-active {\n transform: translate3d(-100%, 0px, 0px);\n }\n\n .p-dialog-right .p-dialog-enter,\n .p-dialog-right .p-dialog-exit-active,\n .p-dialog-top-right .p-dialog-enter,\n .p-dialog-top-right .p-dialog-exit-active,\n .p-dialog-bottom-right .p-dialog-enter,\n .p-dialog-bottom-right .p-dialog-exit-active {\n transform: translate3d(100%, 0px, 0px);\n }\n\n .p-dialog-top .p-dialog-enter-active,\n .p-dialog-bottom .p-dialog-enter-active,\n .p-dialog-left .p-dialog-enter-active,\n .p-dialog-top-left .p-dialog-enter-active,\n .p-dialog-bottom-left .p-dialog-enter-active,\n .p-dialog-right .p-dialog-enter-active,\n .p-dialog-top-right .p-dialog-enter-active,\n .p-dialog-bottom-right .p-dialog-enter-active {\n transform: translate3d(0px, 0px, 0px);\n transition: all 0.3s ease-out;\n }\n\n .p-dialog-top .p-dialog-exit-active,\n .p-dialog-bottom .p-dialog-exit-active,\n .p-dialog-left .p-dialog-exit-active,\n .p-dialog-top-left .p-dialog-exit-active,\n .p-dialog-bottom-left .p-dialog-exit-active,\n .p-dialog-right .p-dialog-exit-active,\n .p-dialog-top-right .p-dialog-exit-active,\n .p-dialog-bottom-right .p-dialog-exit-active {\n transition: all 0.3s ease-out;\n }\n\n /* Maximize */\n .p-dialog-maximized {\n transition: none;\n transform: none;\n margin: 0;\n width: 100vw !important;\n height: 100vh !important;\n max-height: 100%;\n top: 0px !important;\n left: 0px !important;\n }\n\n .p-dialog-maximized .p-dialog-content {\n flex-grow: 1;\n }\n\n .p-confirm-dialog .p-dialog-content {\n display: flex;\n align-items: center;\n }\n\n /* Resizable */\n .p-dialog .p-resizable-handle {\n position: absolute;\n font-size: 0.1px;\n display: block;\n cursor: se-resize;\n width: 12px;\n height: 12px;\n right: 1px;\n bottom: 1px;\n }\n\n .p-dialog-draggable .p-dialog-header {\n cursor: move;\n }\n}\n",inlineStyles:{mask:function(e){var t=e.props;return Z({position:"fixed",height:"100%",width:"100%",left:0,top:0,display:"flex",justifyContent:"left"===t.position||"top-left"===t.position||"bottom-left"===t.position?"flex-start":"right"===t.position||"top-right"===t.position||"bottom-right"===t.position?"flex-end":"center",alignItems:"top"===t.position||"top-left"===t.position||"top-right"===t.position?"flex-start":"bottom"===t.position||"bottom-left"===t.position||"bottom-right"===t.position?"flex-end":"center",pointerEvents:!t.modal&&"none"},t.maskStyle)}}}});function W(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 G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?W(Object(n),!0).forEach((function(t){F(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var K=e.forwardRef((function(t,i){var c=u(),I=e.useContext(r),D=U.getProps(t,I),T=D.id?D.id:x(),M=H(e.useState(T),2),F=M[0],B=H(e.useState(!1),2),X=B[0],A=B[1],Y=H(e.useState(!1),2),$=Y[0],L=Y[1],J=H(e.useState(D.maximized),2),Z=J[0],W=J[1],K=e.useRef(null),q=e.useRef(null),Q=e.useRef(null),ee=e.useRef(null),te=e.useRef(null),ne=e.useRef(null),re=e.useRef(null),oe=e.useRef(!1),ie=e.useRef(!1),ae=e.useRef(null),le=e.useRef(null),ce=e.useRef(null),se=e.useRef(T),ue=e.useRef(null),pe=D.onMaximize?D.maximized:Z,de=$&&(D.blockScroll||D.maximizable&&pe),me=D.closable&&D.closeOnEscape&&$,fe=p("dialog",me),ge=U.setMetaData(G(G({props:D},D.__parentMetadata),{},{state:{id:F,maximized:pe,containerVisible:X}})),be=ge.ptm,he=ge.cx,ye=ge.sx,ve=ge.isUnstyled;a(U.css.styles,ve,{name:"dialog"}),d({callback:function(e){Ce(e)},when:me&&fe,priority:[m.DIALOG,fe]});var xe=H(f({type:"mousemove",target:function(){return window.document},listener:function(e){return He(e)}}),2),we=xe[0],Oe=xe[1],Se=H(f({type:"mouseup",target:function(){return window.document},listener:function(e){return Ye(e)}}),2),Ee=Se[0],Pe=Se[1],ze=H(f({type:"mousemove",target:function(){return window.document},listener:function(e){return Fe(e)}}),2),ke=ze[0],je=ze[1],Ie=H(f({type:"mouseup",target:function(){return window.document},listener:function(e){return Be(e)}}),2),De=Ie[0],Re=Ie[1],Ce=function(e){D.onHide(),e.preventDefault()},_e=function(e){Q.current=e.target,D.onPointerDown&&D.onPointerDown(e)},Ne=function(e){D.dismissableMask&&D.modal&&q.current===e.target&&!Q.current&&Ce(e),D.onMaskClick&&D.onMaskClick(e),Q.current=null},Te=function(e){D.onMaximize?D.onMaximize({originalEvent:e,maximized:!pe}):W((function(e){return!e})),e.preventDefault()},Me=function(e){y.hasClass(e.target,"p-dialog-header-icon")||y.hasClass(e.target.parentElement,"p-dialog-header-icon")||D.draggable&&(oe.current=!0,ae.current=e.pageX,le.current=e.pageY,K.current.style.margin="0",y.addClass(document.body,"p-unselectable-text"),D.onDragStart&&D.onDragStart(e))},Fe=function(e){if(oe.current){var t=y.getOuterWidth(K.current),n=y.getOuterHeight(K.current),r=e.pageX-ae.current,o=e.pageY-le.current,i=K.current.getBoundingClientRect(),a=i.left+r,l=i.top+o,c=y.getViewport(),s=getComputedStyle(K.current),u=parseFloat(s.marginLeft),p=parseFloat(s.marginTop);K.current.style.position="fixed",D.keepInViewport?(a>=D.minX&&a+t<c.width&&(ae.current=e.pageX,K.current.style.left=a-u+"px"),l>=D.minY&&l+n<c.height&&(le.current=e.pageY,K.current.style.top=l-p+"px")):(ae.current=e.pageX,K.current.style.left=a-u+"px",le.current=e.pageY,K.current.style.top=l-p+"px"),D.onDrag&&D.onDrag(e)}},Be=function(e){oe.current&&(oe.current=!1,y.removeClass(document.body,"p-unselectable-text"),D.onDragEnd&&D.onDragEnd(e))},Xe=function(e){D.resizable&&(ie.current=!0,ae.current=e.pageX,le.current=e.pageY,y.addClass(document.body,"p-unselectable-text"),D.onResizeStart&&D.onResizeStart(e))},Ae=function(e,t,n){!n&&(n=y.getViewport());var r=parseInt(e);return/^(\d+|(\.\d+))(\.\d+)?%$/.test(e)?r*(n[t]/100):r},He=function(e){if(ie.current){var t=e.pageX-ae.current,n=e.pageY-le.current,r=y.getOuterWidth(K.current),o=y.getOuterHeight(K.current),i=K.current.getBoundingClientRect(),a=y.getViewport(),l=!parseInt(K.current.style.top)||!parseInt(K.current.style.left),c=Ae(K.current.style.minWidth,"width",a),s=Ae(K.current.style.minHeight,"height",a),u=r+t,p=o+n;l&&(u+=t,p+=n),(!c||u>c)&&i.left+u<a.width&&(K.current.style.width=u+"px"),(!s||p>s)&&i.top+p<a.height&&(K.current.style.height=p+"px"),ae.current=e.pageX,le.current=e.pageY,D.onResize&&D.onResize(e)}},Ye=function(e){ie.current&&(ie.current=!1,y.removeClass(document.body,"p-unselectable-text"),D.onResizeEnd&&D.onResizeEnd(e))},$e=function(){K.current.style.position="",K.current.style.left="",K.current.style.top="",K.current.style.margin=""},Le=function(){K.current.setAttribute(se.current,"")},Ve=function(){var e;D.onShow&&D.onShow(),D.focusOnShow&&!((e=document.activeElement)&&K.current&&K.current.contains(e))&&D.closable&&D.showHeader&&re.current&&re.current.focus(),Ue()},Je=function(){D.modal&&!ve()&&y.addClass(q.current,"p-component-overlay-leave")},Ze=function(){oe.current=!1,w.clear(q.current),A(!1),We(),y.focus(ue.current),ue.current=null},Ue=function(){Ke()},We=function(){qe()},Ge=function(e){if(e&&$){var t={id:F,hasBlockScroll:de};document.primeDialogParams||(document.primeDialogParams=[]);var n=document.primeDialogParams.findIndex((function(e){return e.id===F}));document.primeDialogParams=-1===n?[].concat(R(r=document.primeDialogParams)||C(r)||_(r)||N(),[t]):document.primeDialogParams.toSpliced(n,1,t)}else document.primeDialogParams=document.primeDialogParams&&document.primeDialogParams.filter((function(e){return e.id!==F}));var r;document.primeDialogParams&&document.primeDialogParams.some((function(e){return e.hasBlockScroll}))?y.blockBodyScroll():y.unblockBodyScroll()},Ke=function(){D.draggable&&(ke(),De()),D.resizable&&(we(),Ee())},qe=function(){je(),Re(),Oe(),Pe()},Qe=function(){ce.current=y.createInlineStyle(I&&I.nonce||n.nonce,I&&I.styleContainer);var e="";for(var t in D.breakpoints)e+="\n @media screen and (max-width: ".concat(t,') {\n [data-pc-name="dialog"][').concat(se.current,"] {\n width: ").concat(D.breakpoints[t]," !important;\n }\n }\n ");ce.current.innerHTML=e};s((function(){Ge(!0),D.visible&&A(!0)})),e.useEffect((function(){return D.breakpoints&&Qe(),function(){ce.current=y.removeInlineStyle(ce.current)}}),[D.breakpoints]),g((function(){D.visible&&!X&&A(!0),D.visible!==$&&X&&L(D.visible),D.visible&&(ue.current=document.activeElement)}),[D.visible,X]),g((function(){X&&(w.set("modal",q.current,I&&I.autoZIndex||n.autoZIndex,D.baseZIndex||I&&I.zIndex.modal||n.zIndex.modal),L(!0))}),[X]),g((function(){Ge(!0)}),[de,$]),b((function(){We(),Ge(!1),y.removeInlineStyle(ce.current),w.clear(q.current)})),e.useImperativeHandle(i,(function(){return{props:D,resetPosition:$e,getElement:function(){return K.current},getMask:function(){return q.current},getContent:function(){return ee.current},getHeader:function(){return te.current},getFooter:function(){return ne.current},getCloseButton:function(){return re.current}}}));var et=function(){if(D.closable){var t=D.ariaCloseIconLabel||o("close"),n=c({className:he("closeButtonIcon"),"aria-hidden":!0},be("closeButtonIcon")),r=O.getJSXIcon(D.closeIcon||e.createElement(S,n),G({},n),{props:D}),i=c({ref:re,type:"button",className:he("closeButton"),"aria-label":t,onClick:Ce,onKeyDown:function(e){"Escape"!==e.key&&e.stopPropagation()}},be("closeButton"));return e.createElement("button",i,r,e.createElement(k,null))}return null},tt=function(){var t=c({className:he("maximizableIcon")},be("maximizableIcon")),n=O.getJSXIcon(pe?D.minimizeIcon||e.createElement(P,t):D.maximizeIcon||e.createElement(E,t),t,{props:D});if(D.maximizable){var r=c({type:"button",className:he("maximizableButton"),onClick:Te},be("maximizableButton"));return e.createElement("button",r,n,e.createElement(k,null))}return null},nt=function(){if(D.showHeader){var t=et(),n=tt(),r=h.getJSXElement(D.icons,D),o=h.getJSXElement(D.header,D),i=F+"_header",a=c({ref:te,style:D.headerStyle,className:he("header"),onMouseDown:Me},be("header")),l=c({id:i,className:he("headerTitle")},be("headerTitle")),s=c({className:he("headerIcons")},be("headerIcons"));return e.createElement("div",a,e.createElement("div",l,o),e.createElement("div",s,r,n,t))}return null},rt=function(){var t=h.getJSXElement(D.footer,D),n=c({ref:ne,className:he("footer")},be("footer"));return t&&e.createElement("div",n,t)};return X&&function(){var n,r,o,i,a,s,u=F+"_header",p=F+"_content",d={enter:"center"===D.position?150:300,exit:"center"===D.position?150:300},m=c({ref:q,style:ye("mask"),className:he("mask"),onPointerUp:Ne},be("mask")),f=c({ref:K,id:F,className:v(D.className,he("root",{props:D,maximized:pe,context:I})),style:D.style,onClick:D.onClick,role:"dialog","aria-labelledby":u,"aria-describedby":p,"aria-modal":D.modal,onPointerDown:_e},U.getOtherProps(D),be("root")),g=c({classNames:he("transition"),timeout:d,in:$,options:D.transitionOptions,unmountOnExit:!0,onEnter:Le,onEntered:Ve,onExiting:Je,onExited:Ze},be("transition")),b=null;null!=t&&t.content?(s={header:D.header,content:D.message,message:null==D||null===(a=D.children)||void 0===a||null===(a=a[1])||void 0===a||null===(a=a.props)||void 0===a?void 0:a.children},b=h.getJSXElement(t.content,{headerRef:te,contentRef:ee,footerRef:ne,closeRef:re,hide:Ce,message:s})):(r=nt(),n=c({id:F+"_content",ref:ee,style:D.contentStyle,className:he("content")},be("content")),o=e.createElement("div",n,D.children),i=rt(),b=e.createElement(e.Fragment,null,r,o,i,D.resizable?e.createElement("span",{className:"p-resizable-handle",style:{zIndex:90},onMouseDown:Xe}):null));var y=e.createElement("div",m,e.createElement(l,j({nodeRef:K},g),e.createElement("div",f,e.createElement(V,{autoFocus:D.focusOnShow},b))));return e.createElement(z,{element:y,appendTo:D.appendTo,visible:!0})}()}));K.displayName="Dialog";export{K as Dialog};