WordPress/wp-includes/blocks/query/view.min.js

1 line
1.8 KiB
JavaScript
Raw Normal View History

import*as e from"@wordpress/interactivity";var t={978:e=>{e.exports=import("@wordpress/interactivity-router")}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const t=(e=>{var t={};return n.d(t,e),t})({getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store}),r=e=>e&&e instanceof window.HTMLAnchorElement&&e.href&&(!e.target||"_self"===e.target)&&e.origin===window.location.origin;(0,t.store)("core/query",{state:{get startAnimation(){return"start"===(0,t.getContext)().animation},get finishAnimation(){return"finish"===(0,t.getContext)().animation}},actions:{*navigate(e){const o=(0,t.getContext)(),{ref:i}=(0,t.getElement)(),{queryRef:a}=o,s=a?.dataset.wpNavigationDisabled;if(r(i)&&(e=>!(0!==e.button||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.defaultPrevented))(e)&&!s){e.preventDefault();const t=setTimeout((()=>{o.message=o.loadingText,o.animation="start"}),400),{actions:r}=yield Promise.resolve().then(n.bind(n,978));yield r.navigate(i.href),clearTimeout(t),o.message=o.loadedText+(o.message===o.loadedText?" ":""),o.animation="finish",o.url=i.href;const s=".wp-block-post-template a[href]";a.querySelector(s)?.focus()}},*prefetch(){const{queryRef:e}=(0,t.getContext)(),{ref:o}=(0,t.getElement)(),i=e?.dataset.wpNavigationDisabled;if(r(o)&&!i){const{actions:e}=yield Promise.resolve().then(n.bind(n,978));yield e.prefetch(o.href)}}},callbacks:{*prefetch(){const{url:e}=(0,t.getContext)(),{ref:o}=(0,t.getElement)();if(e&&r(o)){const{actions:e}=yield Promise.resolve().then(n.bind(n,978));yield e.prefetch(o.href)}},setQueryRef(){const e=(0,t.getContext)(),{ref:r}=(0,t.getElement)();e.queryRef=r}}})})();