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
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=require("primereact/api"),t=require("primereact/componentbase"),r=require("primereact/csstransition"),i=require("primereact/hooks"),a=require("primereact/icons/times"),s=require("primereact/portal"),o=require("primereact/ripple"),l=require("primereact/utils");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function p(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 d=p(e),u=c(n);function b(){return b=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},b.apply(null,arguments)}function f(e){return f="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},f(e)}function m(e,n){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}function h(e){var n=m(e,"string");return"symbol"==f(n)?n:n+""}function v(e,n,t){return(n=h(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function y(e){if(Array.isArray(e))return e}function g(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 x(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 S(e,n){if(e){if("string"==typeof e)return x(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)?x(e,n):void 0}}function w(){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 O(e,n){return y(e)||g(e,n)||S(e,n)||w()}var E=t.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 l.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 l.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 l.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 j(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 k(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?j(Object(t),!0).forEach((function(n){v(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):j(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var I=d.forwardRef((function(e,c){var p=i.useMergeProps(),f=d.useContext(n.PrimeReactContext),m=E.getProps(e,f),h=O(d.useState(!1),2),v=h[0],y=h[1],g=O(d.useState(!1),2),x=g[0],S=g[1],w=E.setMetaData({props:m,state:{containerVisible:v}}),j=w.ptm,I=w.cx,P=w.sx,N=w.isUnstyled;t.useHandleStyle(E.css.styles,N,{name:"sidebar"});var C=d.useRef(null),D=d.useRef(null),R=d.useRef(null),U=x&&m.closeOnEscape,T=i.useDisplayOrder("sidebar",U);i.useGlobalOnEscapeKey({callback:function(e){H(e)},when:U&&T,priority:[i.ESC_KEY_HANDLING_PRIORITIES.SIDEBAR,T]});var q=O(i.useEventListener({type:"click",listener:function(e){0===e.button&&B(e)&&H(e)}}),2),A=q[0],_=q[1],B=function(e){return C&&C.current&&!C.current.contains(e.target)},H=function(e){m.onHide(),e.preventDefault()},M=function(){m.dismissable&&!m.modal&&A(),m.blockScroll&&l.DomHandler.blockBodyScroll()},Z=function(){_(),m.blockScroll&&l.DomHandler.unblockBodyScroll()};d.useImperativeHandle(c,(function(){return{props:m,getElement:function(){return C.current},getMask:function(){return D.current},getCloseIcon:function(){return R.current}}})),i.useMountEffect((function(){m.visible&&y(!0)})),i.useUpdateEffect((function(){m.visible&&!v&&y(!0),m.visible!==x&&v&&S(m.visible)}),[m.visible,v,x]),i.useUpdateEffect((function(){v&&(l.ZIndexUtils.set("modal",D.current,f&&f.autoZIndex||u.default.autoZIndex,m.baseZIndex||f&&f.zIndex.modal||u.default.zIndex.modal),S(!0))}),[v]),i.useUpdateEffect((function(){x&&(_(),m.dismissable&&!m.modal&&A())}),[m.dismissable,m.modal,x]),i.useUnmountEffect((function(){Z(),D.current&&l.ZIndexUtils.clear(D.current)}));var z,L,J,X,V,G=function(){var e=p({type:"button",ref:R,className:I("closeButton"),onClick:function(e){return H(e)},"aria-label":m.ariaCloseLabel||n.ariaLabel("close")},j("closeButton")),t=p({className:I("closeIcon")},j("closeIcon")),r=l.IconUtils.getJSXIcon(m.closeIcon||d.createElement(a.TimesIcon,t),k({},t),{props:m});return m.showCloseIcon?d.createElement("button",e,r,d.createElement(o.Ripple,null)):null},K=p({ref:D,style:P("mask"),className:I("mask",{maskVisibleState:v}),onMouseDown:function(e){return n=e,void(m.dismissable&&m.modal&&D.current===n.target&&H(n));var n}},j("mask")),Y=p({id:m.id,className:l.classNames(m.className,I("root",{context:f})),style:m.style,role:"complementary"},E.getOtherProps(m),j("root")),F=p({className:I("header")},j("header")),$=p({className:I("content")},j("content")),Q=p({className:I("icons")},j("icons")),W={enter:m.fullScreen?150:300,exit:m.fullScreen?150:300},ee=p({classNames:I("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(),M()},onExiting:function(){m.modal&&!N()&&l.DomHandler.addClass(D.current,"p-component-overlay-leave")},onExited:function(){l.ZIndexUtils.clear(D.current),y(!1),Z()}},j("transition"));return v&&(V=null!=e&&e.content?(X={closeIconRef:R,hide:H},d.createElement("div",K,d.createElement(r.CSSTransition,b({nodeRef:C},ee),d.createElement("div",b({ref:C},Y),l.ObjectUtils.getJSXElement(e.content,X))))):(z=G(),L=m.icons?l.ObjectUtils.getJSXElement(m.icons,m):null,J=m.header?l.ObjectUtils.getJSXElement(m.header,m):null,d.createElement("div",K,d.createElement(r.CSSTransition,b({nodeRef:C},ee),d.createElement("div",b({ref:C},Y),d.createElement("div",F,J,d.createElement("div",Q,L,z)),d.createElement("div",$,m.children))))),d.createElement(s.Portal,{element:V,appendTo:m.appendTo,visible:!0}))}));I.displayName="Sidebar",exports.Sidebar=I;
;