rumine-web/static/wagtailadmin/js/sidebar.js

2 lines
45 KiB
JavaScript
Raw Normal View History

2024-03-13 07:49:06 +01:00
/*! For license information please see sidebar.js.LICENSE.txt */
(()=>{"use strict";var e,t={2975:(e,t,n)=>{n(7647),n(6526)},3665:(e,t,n)=>{var a=n(7647),r=n.n(a),i=n(3416),s=n.n(i);function o(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)e[a]=n[a]}return e}var l=function e(t,n){function a(e,a,r){if("undefined"!=typeof document){"number"==typeof(r=o({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=e+"="+t.write(a,e)+i}}return Object.create({set:a,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],a={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var o=decodeURIComponent(i[0]);if(a[o]=t.read(s,o),e===o)break}catch(e){}}return e?a[e]:a}},remove:function(e,t){a(e,"",o({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,o({},this.attributes,t))},withConverter:function(t){return e(o({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),c=n(9408),u=n(1302);const m=150,d=({modules:e,currentPath:t,collapsedOnLoad:n=!1,navigate:r,onExpandCollapse:i})=>{const[s,o]=a.useState(n),l=a.useRef(null);a.useEffect((()=>{s&&i&&i(!0)}),[]);const[d,p]=a.useState(!1),[h,f]=a.useState(!0),g=()=>window.innerWidth<800,[v,b]=a.useState(g());a.useEffect((()=>{function e(){return g()?(b(!0),null):(b(!1),p(!1),setTimeout((()=>{f(!0)}),m))}window.addEventListener("resize",e);const t=e();return()=>{window.removeEventListener("resize",e),t&&clearTimeout(t)}}),[]);const E=s&&!v,[w,y]=a.useState(!1);a.useEffect((()=>{y(!0);const e=setTimeout((()=>{y(!1)}),m);return()=>{clearTimeout(e)}}),[E]);const N=()=>{o(!s),i&&i(!s)},[_,P]=a.useState(!1),C=()=>{E&&N()};a.useEffect((()=>{const e=setTimeout((()=>{d||f(!0)}),m);return()=>{clearTimeout(e)}}),[d]);const S=()=>{p(!1),l&&l.current?.focus()},x=e.map(((e,n)=>e.render({key:n,slim:E,expandingOrCollapsing:w,onHideMobile:S,onSearchClick:C,currentPath:t,navigate:r})));return a.createElement(a.Fragment,null,a.createElement("button",{onClick:()=>{p(!d),y(!0);const e=setTimeout((()=>{y(!1),f(!h)}),m);return()=>{clearTimeout(e)}},"aria-label":(0,c.ih)("Toggle sidebar"),"aria-expanded":d?"true":"false",className:"button sidebar-nav-toggle"+(v?" sidebar-nav-toggle--mobile":"")+(d?" sidebar-nav-toggle--open":""),type:"button",ref:l},d?a.createElement(u.Z,{name:"cross"}):a.createElement(u.Z,{name:"bars"})),a.createElement("div",{className:"sidebar"+(E?" sidebar--slim":"")+(v?" sidebar--mobile":"")+(v&&!d?" sidebar--hidden":"")+(v&&!d&&h?" sidebar--closed":"")},a.createElement("div",{className:"sidebar__inner",onFocus:()=>{_&&(o(!1),P(!0))},onBlur:()=>{_&&(P(!1),o(!0))}},a.createElement("div",{className:`sm:w-mt-2 ${E?"w-justify-center":"w-justify-end"} w-flex w-items-center`},a.createElement("button",{onClick:N,"aria-label":(0,c.ih)("Toggle sidebar"),"aria-expanded":E?"false":"true",type:"button",className:(E?"":"w-mr-4")+"\n button\n sidebar__collapse-toggle\n w-flex\n w-justify-center\n w-items-center\n hover:w-bg-surface-menu-item-active\n hover:text-white\n hover:opacity-100"},a.createElement(u.Z,{name:"expand-right",className:s?"":"-w-rotate-180"}))),x)))};var p=n(4676);const h="wagtail_sidebar_collapsed";var f=n(1736);const g=({item:e,slim:t,path:n,state:r,dispatch:i,navigate:s})=>{const o=r.activePath===n,l=r.activePath.startsWith(n),m=n.split(".").length>2,d="sidebar-menu-item"+(l?" sidebar-menu-item--active":"")+(m?" sidebar-menu-item--in-sub-menu":"");ret