1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
(()=>{"use strict";var e,t={4174:(e,t,n)=>{var a=n(5781),r=n(9408);const l=(e,t=!("true"===e.getAttribute("aria-expanded")))=>{const n=document.querySelector(`#${e.getAttribute("aria-controls")}`);n&&(e.setAttribute("aria-expanded",`${t}`),t?n.removeAttribute("hidden"):"onbeforematch"in document.body?n.setAttribute("hidden","until-found"):n.setAttribute("hidden",""),e.dispatchEvent(new CustomEvent("commentAnchorVisibilityChange",{bubbles:!0})),e.dispatchEvent(new CustomEvent("wagtail:panel-toggle",{bubbles:!0,cancelable:!1,detail:{expanded:t}})))};function i(e){const t=e.closest("[data-panel]"),n=document.querySelector(`#${e.getAttribute("aria-controls")}`);if(!n||!t||t.collapsibleInitialised)return;t.collapsibleInitialised=!0;const a=l.bind(null,e),r=t.classList.contains("collapsed"),i=n.querySelector('[aria-invalid="true"], .error, .w-field--error'),o=r&&!i;o&&a(!1),e.addEventListener("click",a.bind(null,void 0));const s=t.querySelector("[data-panel-heading]");s&&s.addEventListener("click",a.bind(null,void 0)),n.addEventListener("beforematch",a.bind(null,!0)),e.dispatchEvent(new CustomEvent("wagtail:panel-init",{bubbles:!0,cancelable:!1,detail:{expanded:!o}}))}var o=n(7647),s=n.n(o),c=n(3416),d=n.n(c),u=n(9437),m=n(1302);const p=({expanded:e,floating:t,insideMinimap:n,onClick:a})=>s().createElement("button",{type:"button","aria-expanded":e,onClick:a,className:`button button-small button-secondary w-minimap__collapse-all ${t?"w-minimap__collapse-all--floating":""} ${n?"w-minimap__collapse-all--inside":""}`},s().createElement(m.Z,{name:e?"collapse-up":"collapse-down"}),e?(0,r.ih)("Collapse all"):(0,r.ih)("Expand all")),g=s().createElement("span",{className:"w-required-mark"},"*"),h=({item:e,intersects:t,expanded:n,onClick:a})=>{const{href:l,label:i,icon:o,required:c,errorCount:d,level:u}=e,p=d>0,h=(0,r.qP)("%(num)s error","%(num)s errors",d).replace("%(num)s",`${d}`),f=i.length>22?`${i.substring(0,22)}…`:i;return s().createElement("a",{href:l,className:`w-minimap-item w-minimap-item--${u} ${t?"w-minimap-item--active":""} ${p?"w-minimap-item--error":""}`,onClick:a.bind(null,e),"aria-current":t,tabIndex:n?void 0:-1,"aria-describedby":n?void 0:"w-minimap-toggle"},p?s().createElement("div",{className:"w-minimap-item__errors","aria-label":h},d):null,s().createElement(m.Z,{name:"minus",className:"w-minimap-item__placeholder"}),"h1"!==u&&"h2"!==u?s().createElement(m.Z,{name:o,className:"w-minimap-item__icon"}):null,s().createElement("span",{className:"w-minimap-item__label"},s().createElement("span",{className:"w-minimap-item__text"},f),c?g:null))},f={root:null,rootMargin:"-50px 0px -70px 0px",threshold:.1},b=(e,{target:t,isIntersecting:n})=>(e[`#${t.closest("[data-panel]")?.id}`||""]=n,e),v=({container:e,anchorsContainer:t,links:n,onUpdate:a,toggleAllPanels:i})=>{const c=(0,o.useMemo)((()=>(()=>{let e="false";try{e=localStorage.getItem("wagtail:minimap-expanded")||e}catch{}return"true"===e})()),[]),[d,g]=(0,o.useState)(c),v=(0,o.useCallback)(((e=!d)=>{g(e),document.body.classList.toggle("minimap-open",e);try{localStorage.setItem("wagtail:minimap-expanded",e?"true":"false")}catch{}}),[d,g]),[y,E]=(0,o.useState)(!0),[w,S]=(0,o.useState)({}),x=(0,o.useRef)(null),q=(0,o.useRef)({}),L=(0,o.useRef)(null),A=(0,o.useRef)(null),_=(e,t)=>{d||t.preventDefault(),l(e.toggle,!0),v(!0)};return(0,o.useEffect)((()=>{v(c)}),[]),(0,o.useEffect)((()=>{x.current||(x.current=new IntersectionObserver((t=>{q.current=t.reduce(b,{...q.current}),L.current||(L.current=(0,u.D)((e=>{S(e),(e=>{const t=e.querySelectorAll('a[aria-current="true"]');if(0===t.length||e.scrollHeight===e.clientHeight)return;const n=t[0],a=t[t.length-1];let r=e.scrollTop;n&&n.offsetTop<e.scrollTop&&(r=n.offsetTop),a&&a.offsetTop>e.scrollTop+e.offsetHeight&&(r=a.offsetTop-e.offsetHeight+a.offsetHeight),e.scrollTop=r})(A.current)}),100)),L.current(q.current),t.forEach((({target:t})=>{t.closest(".deleted")&&a(e)}))}),f));const t=x.current;return t.disconnect(),n.forEach((({panel:e,toggle:n})=>{const a=e.matches(".w-panel--nested")&&null===e.closest("[data-field]");t.observe(a?n:e)}
|