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) • 13.5 kB
JavaScript
this.primereact=this.primereact||{},this.primereact.sidebar=function(e,n,t,r,i,a,s,o,l,c){"use strict";function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var b=d(n),u=p(t);function f(){return f=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},f.apply(null,arguments)}function m(e){return m="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},m(e)}function h(e,n){if("object"!=m(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}function v(e){var n=h(e,"string");return"symbol"==m(n)?n:n+""}function y(e,n,t){return(n=v(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function g(e){if(Array.isArray(e))return e}function x(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,i,a,s,o=[],l=!0,c=!1;try{if(a=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=a.call(t)).done)&&(o.push(r.value),o.length!==n);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=t.return&&(s=t.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}function S(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function w(e,n){if(e){if("string"==typeof e)return S(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?S(e,n):void 0}}function O(){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 E(e,n){return g(e)||x(e,n)||w(e,n)||O()}var j=r.ComponentBase.extend({defaultProps:{__TYPE:"Sidebar",appendTo:null,ariaCloseLabel:null,baseZIndex:0,blockScroll:!1,children:void 0,className:null,closeIcon:null,closeOnEscape:!0,content:null,dismissable:!0,fullScreen:!1,header:null,icons:null,id:null,maskClassName:null,maskStyle:null,modal:!0,onHide:null,onShow:null,position:"left",showCloseIcon:!0,style:null,transitionOptions:null,visible:!1},css:{classes:{closeButton:"p-sidebar-close p-sidebar-icon p-link",closeIcon:"p-sidebar-close-icon",mask:function(e){var n=e.props,t=e.maskVisibleState,r=["left","right","top","bottom"].find((function(e){return e===n.position}));return c.classNames("p-sidebar-mask",r&&!n.fullScreen?"p-sidebar-".concat(r):"",{"p-component-overlay p-component-overlay-enter":n.modal,"p-sidebar-mask-scrollblocker":n.blockScroll,"p-sidebar-visible":t,"p-sidebar-full":n.fullScreen},n.maskClassName)},header:function(e){return c.classNames("p-sidebar-header",{"p-sidebar-custom-header":e.props.header})},content:"p-sidebar-content",icons:"p-sidebar-icons",root:function(e){var n=e.context;return c.classNames("p-sidebar p-component",{"p-input-filled":n&&"filled"===n.inputStyle||"filled"===u.default.inputStyle,"p-ripple-disabled":n&&!1===n.ripple||!1===u.default.ripple})},transition:"p-sidebar"},styles:"\n@layer primereact {\n .p-sidebar-mask {\n display: none;\n justify-content: center;\n align-items: center;\n pointer-events: none;\n background-color: transparent;\n transition-property: background-color;\n }\n \n .p-sidebar-visible {\n display: flex;\n }\n \n .p-sidebar-mask.p-component-overlay {\n pointer-events: auto;\n }\n \n .p-sidebar {\n display: flex;\n flex-direction: column;\n pointer-events: auto;\n transform: translate3d(0px, 0px, 0px);\n position: relative;\n }\n \n .p-sidebar-content {\n overflow-y: auto;\n flex-grow: 1;\n }\n \n .p-sidebar-header {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n }\n \n .p-sidebar-custom-header {\n justify-content: space-between;\n }\n \n .p-sidebar-icons {\n display: flex;\n align-items: center;\n flex-shrink: 0;\n }\n \n .p-sidebar-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n position: relative;\n }\n \n .p-sidebar-full .p-sidebar {\n transition: none;\n transform: none;\n width: 100vw;\n height: 100vh;\n max-height: 100%;\n top: 0px;\n left: 0px;\n }\n \n /* Animation */\n /* Top, Bottom, Left and Right */\n .p-sidebar-top .p-sidebar-enter,\n .p-sidebar-top .p-sidebar-exit-active {\n transform: translate3d(0px, -100%, 0px);\n }\n \n .p-sidebar-bottom .p-sidebar-enter,\n .p-sidebar-bottom .p-sidebar-exit-active {\n transform: translate3d(0px, 100%, 0px);\n }\n \n .p-sidebar-left .p-sidebar-enter,\n .p-sidebar-left .p-sidebar-exit-active {\n transform: translate3d(-100%, 0px, 0px);\n }\n \n .p-sidebar-right .p-sidebar-enter,\n .p-sidebar-right .p-sidebar-exit-active {\n transform: translate3d(100%, 0px, 0px);\n }\n \n .p-sidebar-top .p-sidebar-enter-active,\n .p-sidebar-bottom .p-sidebar-enter-active,\n .p-sidebar-left .p-sidebar-enter-active,\n .p-sidebar-right .p-sidebar-enter-active {\n transform: translate3d(0px, 0px, 0px);\n transition: all 0.3s;\n }\n \n .p-sidebar-top .p-sidebar-enter-done,\n .p-sidebar-bottom .p-sidebar-enter-done,\n .p-sidebar-left .p-sidebar-enter-done,\n .p-sidebar-right .p-sidebar-enter-done {\n transform: none;\n }\n \n .p-sidebar-top .p-sidebar-exit-active,\n .p-sidebar-bottom .p-sidebar-exit-active,\n .p-sidebar-left .p-sidebar-exit-active,\n .p-sidebar-right .p-sidebar-exit-active {\n transition: all 0.3s;\n }\n \n /* Full */\n .p-sidebar-full .p-sidebar-enter {\n opacity: 0;\n transform: scale(0.5);\n }\n \n .p-sidebar-full .p-sidebar-enter-active {\n opacity: 1;\n transform: scale(1);\n transition: all 0.15s cubic-bezier(0, 0, 0.2, 1);\n }\n \n .p-sidebar-full .p-sidebar-enter-done {\n transform: none;\n }\n \n .p-sidebar-full .p-sidebar-exit-active {\n opacity: 0;\n transform: scale(0.5);\n transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);\n }\n \n /* Size */\n .p-sidebar-left .p-sidebar {\n width: 20rem;\n height: 100%;\n }\n \n .p-sidebar-right .p-sidebar {\n width: 20rem;\n height: 100%;\n }\n \n .p-sidebar-top .p-sidebar {\n height: 10rem;\n width: 100%;\n }\n \n .p-sidebar-bottom .p-sidebar {\n height: 10rem;\n width: 100%;\n }\n \n .p-sidebar-left .p-sidebar-sm,\n .p-sidebar-right .p-sidebar-sm {\n width: 20rem;\n }\n \n .p-sidebar-left .p-sidebar-md,\n .p-sidebar-right .p-sidebar-md {\n width: 40rem;\n }\n \n .p-sidebar-left .p-sidebar-lg,\n .p-sidebar-right .p-sidebar-lg {\n width: 60rem;\n }\n \n .p-sidebar-top .p-sidebar-sm,\n .p-sidebar-bottom .p-sidebar-sm {\n height: 10rem;\n }\n \n .p-sidebar-top .p-sidebar-md,\n .p-sidebar-bottom .p-sidebar-md {\n height: 20rem;\n }\n \n .p-sidebar-top .p-sidebar-lg,\n .p-sidebar-bottom .p-sidebar-lg {\n height: 30rem;\n }\n \n .p-sidebar-left .p-sidebar-view,\n .p-sidebar-right .p-sidebar-view,\n .p-sidebar-top .p-sidebar-view,\n .p-sidebar-bottom .p-sidebar-view {\n width: 100%;\n height: 100%;\n }\n \n .p-sidebar-left .p-sidebar-content,\n .p-sidebar-right .p-sidebar-content,\n .p-sidebar-top .p-sidebar-content,\n .p-sidebar-bottom .p-sidebar-content {\n width: 100%;\n height: 100%;\n }\n \n @media screen and (max-width: 64em) {\n .p-sidebar-left .p-sidebar-lg,\n .p-sidebar-left .p-sidebar-md,\n .p-sidebar-right .p-sidebar-lg,\n .p-sidebar-right .p-sidebar-md {\n width: 20rem;\n }\n } \n}\n",inlineStyles:{mask:function(e){var n=e.props;return{position:"fixed",height:"100%",width:"100%",left:0,top:0,display:"flex",justifyContent:"left"===n.position?"flex-start":"right"===n.position?"flex-end":"center",alignItems:"top"===n.position?"flex-start":"bottom"===n.position?"flex-end":"center"}}}}});function k(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function I(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?k(Object(t),!0).forEach((function(n){y(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):k(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var P=b.forwardRef((function(e,n){var p=a.useMergeProps(),d=b.useContext(t.PrimeReactContext),m=j.getProps(e,d),h=E(b.useState(!1),2),v=h[0],y=h[1],g=E(b.useState(!1),2),x=g[0],S=g[1],w=j.setMetaData({props:m,state:{containerVisible:v}}),O=w.ptm,k=w.cx,P=w.sx,N=w.isUnstyled;r.useHandleStyle(j.css.styles,N,{name:"sidebar"});var C=b.useRef(null),D=b.useRef(null),R=b.useRef(null),U=x&&m.closeOnEscape,T=a.useDisplayOrder("sidebar",U);a.useGlobalOnEscapeKey({callback:function(e){M(e)},when:U&&T,priority:[a.ESC_KEY_HANDLING_PRIORITIES.SIDEBAR,T]});var A=E(a.useEventListener({type:"click",listener:function(e){0===e.button&&H(e)&&M(e)}}),2),_=A[0],B=A[1],H=function(e){return C&&C.current&&!C.current.contains(e.target)},M=function(e){m.onHide(),e.preventDefault()},Z=function(){m.dismissable&&!m.modal&&_(),m.blockScroll&&c.DomHandler.blockBodyScroll()},z=function(){B(),m.blockScroll&&c.DomHandler.unblockBodyScroll()};b.useImperativeHandle(n,(function(){return{props:m,getElement:function(){return C.current},getMask:function(){return D.current},getCloseIcon:function(){return R.current}}})),a.useMountEffect((function(){m.visible&&y(!0)})),a.useUpdateEffect((function(){m.visible&&!v&&y(!0),m.visible!==x&&v&&S(m.visible)}),[m.visible,v,x]),a.useUpdateEffect((function(){v&&(c.ZIndexUtils.set("modal",D.current,d&&d.autoZIndex||u.default.autoZIndex,m.baseZIndex||d&&d.zIndex.modal||u.default.zIndex.modal),S(!0))}),[v]),a.useUpdateEffect((function(){x&&(B(),m.dismissable&&!m.modal&&_())}),[m.dismissable,m.modal,x]),a.useUnmountEffect((function(){z(),D.current&&c.ZIndexUtils.clear(D.current)}));var L,J,X,V,G,K=function(){var e=p({type:"button",ref:R,className:k("closeButton"),onClick:function(e){return M(e)},"aria-label":m.ariaCloseLabel||t.ariaLabel("close")},O("closeButton")),n=p({className:k("closeIcon")},O("closeIcon")),r=c.IconUtils.getJSXIcon(m.closeIcon||b.createElement(s.TimesIcon,n),I({},n),{props:m});return m.showCloseIcon?b.createElement("button",e,r,b.createElement(l.Ripple,null)):null},Y=p({ref:D,style:P("mask"),className:k("mask",{maskVisibleState:v}),onMouseDown:function(e){return n=e,void(m.dismissable&&m.modal&&D.current===n.target&&M(n));var n}},O("mask")),F=p({id:m.id,className:c.classNames(m.className,k("root",{context:d})),style:m.style,role:"complementary"},j.getOtherProps(m),O("root")),$=p({className:k("header")},O("header")),q=p({className:k("content")},O("content")),Q=p({className:k("icons")},O("icons")),W={enter:m.fullScreen?150:300,exit:m.fullScreen?150:300},ee=p({classNames:k("transition"),in:x,timeout:W,options:m.transitionOptions,unmountOnExit:!0,onEntered:function(){var e;m.onShow&&m.onShow(),!((e=document.activeElement)&&C&&C.current.contains(e))&&m.showCloseIcon&&R.current&&R.current.focus(),Z()},onExiting:function(){m.modal&&!N()&&c.DomHandler.addClass(D.current,"p-component-overlay-leave")},onExited:function(){c.ZIndexUtils.clear(D.current),y(!1),z()}},O("transition"));return v&&(G=null!=e&&e.content?(V={closeIconRef:R,hide:M},b.createElement("div",Y,b.createElement(i.CSSTransition,f({nodeRef:C},ee),b.createElement("div",f({ref:C},F),c.ObjectUtils.getJSXElement(e.content,V))))):(L=K(),J=m.icons?c.ObjectUtils.getJSXElement(m.icons,m):null,X=m.header?c.ObjectUtils.getJSXElement(m.header,m):null,b.createElement("div",Y,b.createElement(i.CSSTransition,f({nodeRef:C},ee),b.createElement("div",f({ref:C},F),b.createElement("div",$,X,b.createElement("div",Q,J,L)),b.createElement("div",q,m.children))))),b.createElement(o.Portal,{element:G,appendTo:m.appendTo,visible:!0}))}));return P.displayName="Sidebar",e.Sidebar=P,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.api,primereact.componentbase,primereact.csstransition,primereact.hooks,primereact.icons.times,primereact.portal,primereact.ripple,primereact.utils);