WordPress/wp-includes/js/dist/viewport.min.js

2 lines
2.3 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
!function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ifViewportMatches:function(){return f},store:function(){return s},withViewportMatch:function(){return l}});var r={};e.r(r),e.d(r,{setIsMatching:function(){return c}});var n={};e.r(n),e.d(n,{isViewportMatch:function(){return u}});var o=window.wp.compose,i=window.wp.data;var a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return"SET_IS_MATCHING"===t.type?t.values:e};function c(e){return{type:"SET_IS_MATCHING",values:e}}function u(e,t){return-1===t.indexOf(" ")&&(t=">= "+t),!!e[t]}const s=(0,i.createReduxStore)("core/viewport",{reducer:a,actions:r,selectors:n});(0,i.register)(s);var d=(e,t)=>{const r=(0,o.debounce)((()=>{const e=Object.fromEntries(a.map((e=>{let[t,r]=e;return[t,r.matches]})));(0,i.dispatch)(s).setIsMatching(e)}),0,{leading:!0}),n=Object.entries(t),a=Object.entries(e).flatMap((e=>{let[t,o]=e;return n.map((e=>{let[n,i]=e;const a=window.matchMedia(`(${i}: ${o}px)`);return a.addEventListener("change",r),[`${n} ${t}`,a]}))}));window.addEventListener("orientationchange",r),r(),r.flush()};function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},p.apply(this,arguments)}var w=window.wp.element;var l=e=>{const t=Object.entries(e);return(0,o.createHigherOrderComponent)((e=>(0,o.pure)((r=>{const n=Object.fromEntries(t.map((e=>{let[t,r]=e,[n,i]=r.split(" ");return void 0===i&&(i=n,n=">="),[t,(0,o.useViewportMatch)(i,n)]})));return(0,w.createElement)(e,p({},r,n))}))),"withViewportMatch")};var f=e=>(0,o.createHigherOrderComponent)((0,o.compose)([l({isViewportMatch:e}),(0,o.ifCondition)((e=>e.isViewportMatch))]),"ifViewportMatches");d({huge:1440,wide:1280,large:960,medium:782,small:600,mobile:480},{"<":"max-width",">=":"min-width"}),(window.wp=window.wp||{}).viewport=t}();