[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> viewport.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["viewport"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = 474);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 0:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["wp"]["element"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 11:
  98  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99  
 100  "use strict";
 101  
 102  // EXPORTS
 103  __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
 104  
 105  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
 106  var arrayWithHoles = __webpack_require__(38);
 107  
 108  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
 109  function _iterableToArrayLimit(arr, i) {
 110    if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
 111    var _arr = [];
 112    var _n = true;
 113    var _d = false;
 114    var _e = undefined;
 115  
 116    try {
 117      for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
 118        _arr.push(_s.value);
 119  
 120        if (i && _arr.length === i) break;
 121      }
 122    } catch (err) {
 123      _d = true;
 124      _e = err;
 125    } finally {
 126      try {
 127        if (!_n && _i["return"] != null) _i["return"]();
 128      } finally {
 129        if (_d) throw _e;
 130      }
 131    }
 132  
 133    return _arr;
 134  }
 135  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 136  var unsupportedIterableToArray = __webpack_require__(31);
 137  
 138  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
 139  var nonIterableRest = __webpack_require__(39);
 140  
 141  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
 142  
 143  
 144  
 145  
 146  function _slicedToArray(arr, i) {
 147    return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
 148  }
 149  
 150  /***/ }),
 151  
 152  /***/ 12:
 153  /***/ (function(module, exports) {
 154  
 155  (function() { module.exports = window["wp"]["compose"]; }());
 156  
 157  /***/ }),
 158  
 159  /***/ 2:
 160  /***/ (function(module, exports) {
 161  
 162  (function() { module.exports = window["lodash"]; }());
 163  
 164  /***/ }),
 165  
 166  /***/ 24:
 167  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 168  
 169  "use strict";
 170  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
 171  function _arrayLikeToArray(arr, len) {
 172    if (len == null || len > arr.length) len = arr.length;
 173  
 174    for (var i = 0, arr2 = new Array(len); i < len; i++) {
 175      arr2[i] = arr[i];
 176    }
 177  
 178    return arr2;
 179  }
 180  
 181  /***/ }),
 182  
 183  /***/ 31:
 184  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 185  
 186  "use strict";
 187  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 188  /* harmony import */ var _babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
 189  
 190  function _unsupportedIterableToArray(o, minLen) {
 191    if (!o) return;
 192    if (typeof o === "string") return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 193    var n = Object.prototype.toString.call(o).slice(8, -1);
 194    if (n === "Object" && o.constructor) n = o.constructor.name;
 195    if (n === "Map" || n === "Set") return Array.from(o);
 196    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 197  }
 198  
 199  /***/ }),
 200  
 201  /***/ 38:
 202  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 203  
 204  "use strict";
 205  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
 206  function _arrayWithHoles(arr) {
 207    if (Array.isArray(arr)) return arr;
 208  }
 209  
 210  /***/ }),
 211  
 212  /***/ 39:
 213  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 214  
 215  "use strict";
 216  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
 217  function _nonIterableRest() {
 218    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 219  }
 220  
 221  /***/ }),
 222  
 223  /***/ 4:
 224  /***/ (function(module, exports) {
 225  
 226  (function() { module.exports = window["wp"]["data"]; }());
 227  
 228  /***/ }),
 229  
 230  /***/ 474:
 231  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 232  
 233  "use strict";
 234  // ESM COMPAT FLAG
 235  __webpack_require__.r(__webpack_exports__);
 236  
 237  // EXPORTS
 238  __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
 239  __webpack_require__.d(__webpack_exports__, "ifViewportMatches", function() { return /* reexport */ if_viewport_matches; });
 240  __webpack_require__.d(__webpack_exports__, "withViewportMatch", function() { return /* reexport */ with_viewport_match; });
 241  
 242  // NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/actions.js
 243  var actions_namespaceObject = {};
 244  __webpack_require__.r(actions_namespaceObject);
 245  __webpack_require__.d(actions_namespaceObject, "setIsMatching", function() { return actions_setIsMatching; });
 246  
 247  // NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/selectors.js
 248  var selectors_namespaceObject = {};
 249  __webpack_require__.r(selectors_namespaceObject);
 250  __webpack_require__.d(selectors_namespaceObject, "isViewportMatch", function() { return isViewportMatch; });
 251  
 252  // EXTERNAL MODULE: external "lodash"
 253  var external_lodash_ = __webpack_require__(2);
 254  
 255  // EXTERNAL MODULE: external ["wp","data"]
 256  var external_wp_data_ = __webpack_require__(4);
 257  
 258  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/reducer.js
 259  /**
 260   * Reducer returning the viewport state, as keys of breakpoint queries with
 261   * boolean value representing whether query is matched.
 262   *
 263   * @param {Object} state  Current state.
 264   * @param {Object} action Dispatched action.
 265   *
 266   * @return {Object} Updated state.
 267   */
 268  function reducer() {
 269    var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 270    var action = arguments.length > 1 ? arguments[1] : undefined;
 271  
 272    switch (action.type) {
 273      case 'SET_IS_MATCHING':
 274        return action.values;
 275    }
 276  
 277    return state;
 278  }
 279  
 280  /* harmony default export */ var store_reducer = (reducer);
 281  
 282  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/actions.js
 283  /**
 284   * Returns an action object used in signalling that viewport queries have been
 285   * updated. Values are specified as an object of breakpoint query keys where
 286   * value represents whether query matches.
 287   *
 288   * @param {Object} values Breakpoint query matches.
 289   *
 290   * @return {Object} Action object.
 291   */
 292  function actions_setIsMatching(values) {
 293    return {
 294      type: 'SET_IS_MATCHING',
 295      values: values
 296    };
 297  }
 298  
 299  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/selectors.js
 300  /**
 301   * Returns true if the viewport matches the given query, or false otherwise.
 302   *
 303   * @param {Object} state Viewport state object.
 304   * @param {string} query Query string. Includes operator and breakpoint name,
 305   *                       space separated. Operator defaults to >=.
 306   *
 307   * @example
 308   *
 309   * ```js
 310   * isViewportMatch( state, '< huge' );
 311   * isViewPortMatch( state, 'medium' );
 312   * ```
 313   *
 314   * @return {boolean} Whether viewport matches query.
 315   */
 316  function isViewportMatch(state, query) {
 317    // Default to `>=` if no operator is present.
 318    if (query.indexOf(' ') === -1) {
 319      query = '>= ' + query;
 320    }
 321  
 322    return !!state[query];
 323  }
 324  
 325  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/index.js
 326  /**
 327   * WordPress dependencies
 328   */
 329  
 330  /**
 331   * Internal dependencies
 332   */
 333  
 334  
 335  
 336  
 337  var STORE_NAME = 'core/viewport';
 338  /**
 339   * Store definition for the viewport namespace.
 340   *
 341   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 342   *
 343   * @type {Object}
 344   */
 345  
 346  var store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, {
 347    reducer: store_reducer,
 348    actions: actions_namespaceObject,
 349    selectors: selectors_namespaceObject
 350  });
 351  Object(external_wp_data_["register"])(store);
 352  
 353  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/listener.js
 354  /**
 355   * External dependencies
 356   */
 357  
 358  /**
 359   * WordPress dependencies
 360   */
 361  
 362  
 363  /**
 364   * Internal dependencies
 365   */
 366  
 367  
 368  
 369  var listener_addDimensionsEventListener = function addDimensionsEventListener(breakpoints, operators) {
 370    /**
 371     * Callback invoked when media query state should be updated. Is invoked a
 372     * maximum of one time per call stack.
 373     */
 374    var setIsMatching = Object(external_lodash_["debounce"])(function () {
 375      var values = Object(external_lodash_["mapValues"])(queries, function (query) {
 376        return query.matches;
 377      });
 378      Object(external_wp_data_["dispatch"])(store).setIsMatching(values);
 379    }, {
 380      leading: true
 381    });
 382    /**
 383     * Hash of breakpoint names with generated MediaQueryList for corresponding
 384     * media query.
 385     *
 386     * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
 387     * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList
 388     *
 389     * @type {Object<string,MediaQueryList>}
 390     */
 391  
 392    var queries = Object(external_lodash_["reduce"])(breakpoints, function (result, width, name) {
 393      Object(external_lodash_["forEach"])(operators, function (condition, operator) {
 394        var list = window.matchMedia("(".concat(condition, ": ").concat(width, "px)"));
 395        list.addListener(setIsMatching);
 396        var key = [operator, name].join(' ');
 397        result[key] = list;
 398      });
 399      return result;
 400    }, {});
 401    window.addEventListener('orientationchange', setIsMatching); // Set initial values
 402  
 403    setIsMatching();
 404    setIsMatching.flush();
 405  };
 406  
 407  /* harmony default export */ var listener = (listener_addDimensionsEventListener);
 408  
 409  // EXTERNAL MODULE: external ["wp","compose"]
 410  var external_wp_compose_ = __webpack_require__(12);
 411  
 412  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
 413  var esm_extends = __webpack_require__(8);
 414  
 415  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
 416  var slicedToArray = __webpack_require__(11);
 417  
 418  // EXTERNAL MODULE: external ["wp","element"]
 419  var external_wp_element_ = __webpack_require__(0);
 420  
 421  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/with-viewport-match.js
 422  
 423  
 424  
 425  
 426  /**
 427   * External dependencies
 428   */
 429  
 430  /**
 431   * WordPress dependencies
 432   */
 433  
 434  
 435  /**
 436   * Higher-order component creator, creating a new component which renders with
 437   * the given prop names, where the value passed to the underlying component is
 438   * the result of the query assigned as the object's value.
 439   *
 440   * @see isViewportMatch
 441   *
 442   * @param {Object} queries  Object of prop name to viewport query.
 443   *
 444   * @example
 445   *
 446   * ```jsx
 447   * function MyComponent( { isMobile } ) {
 448   *     return (
 449   *         <div>Currently: { isMobile ? 'Mobile' : 'Not Mobile' }</div>
 450   *     );
 451   * }
 452   *
 453   * MyComponent = withViewportMatch( { isMobile: '< small' } )( MyComponent );
 454   * ```
 455   *
 456   * @return {Function} Higher-order component.
 457   */
 458  
 459  var with_viewport_match_withViewportMatch = function withViewportMatch(queries) {
 460    var useViewPortQueriesResult = function useViewPortQueriesResult() {
 461      return Object(external_lodash_["mapValues"])(queries, function (query) {
 462        var _query$split = query.split(' '),
 463            _query$split2 = Object(slicedToArray["a" /* default */])(_query$split, 2),
 464            operator = _query$split2[0],
 465            breakpointName = _query$split2[1];
 466  
 467        if (breakpointName === undefined) {
 468          breakpointName = operator;
 469          operator = '>=';
 470        } // Hooks should unconditionally execute in the same order,
 471        // we are respecting that as from the static query of the HOC we generate
 472        // a hook that calls other hooks always in the same order (because the query never changes).
 473        // eslint-disable-next-line react-hooks/rules-of-hooks
 474  
 475  
 476        return Object(external_wp_compose_["useViewportMatch"])(breakpointName, operator);
 477      });
 478    };
 479  
 480    return Object(external_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
 481      return Object(external_wp_compose_["pure"])(function (props) {
 482        var queriesResult = useViewPortQueriesResult();
 483        return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, queriesResult));
 484      });
 485    }, 'withViewportMatch');
 486  };
 487  
 488  /* harmony default export */ var with_viewport_match = (with_viewport_match_withViewportMatch);
 489  
 490  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/if-viewport-matches.js
 491  /**
 492   * WordPress dependencies
 493   */
 494  
 495  /**
 496   * Internal dependencies
 497   */
 498  
 499  
 500  /**
 501   * Higher-order component creator, creating a new component which renders if
 502   * the viewport query is satisfied.
 503   *
 504   * @see withViewportMatches
 505   *
 506   * @param {string} query Viewport query.
 507   *
 508   * @example
 509   *
 510   * ```jsx
 511   * function MyMobileComponent() {
 512   *     return <div>I'm only rendered on mobile viewports!</div>;
 513   * }
 514   *
 515   * MyMobileComponent = ifViewportMatches( '< small' )( MyMobileComponent );
 516   * ```
 517   *
 518   * @return {Function} Higher-order component.
 519   */
 520  
 521  var if_viewport_matches_ifViewportMatches = function ifViewportMatches(query) {
 522    return Object(external_wp_compose_["createHigherOrderComponent"])(Object(external_wp_compose_["compose"])([with_viewport_match({
 523      isViewportMatch: query
 524    }), Object(external_wp_compose_["ifCondition"])(function (props) {
 525      return props.isViewportMatch;
 526    })]), 'ifViewportMatches');
 527  };
 528  
 529  /* harmony default export */ var if_viewport_matches = (if_viewport_matches_ifViewportMatches);
 530  
 531  // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/index.js
 532  /**
 533   * Internal dependencies
 534   */
 535  
 536  
 537  
 538  
 539  /**
 540   * Hash of breakpoint names with pixel width at which it becomes effective.
 541   *
 542   * @see _breakpoints.scss
 543   *
 544   * @type {Object}
 545   */
 546  
 547  var BREAKPOINTS = {
 548    huge: 1440,
 549    wide: 1280,
 550    large: 960,
 551    medium: 782,
 552    small: 600,
 553    mobile: 480
 554  };
 555  /**
 556   * Hash of query operators with corresponding condition for media query.
 557   *
 558   * @type {Object}
 559   */
 560  
 561  var OPERATORS = {
 562    '<': 'max-width',
 563    '>=': 'min-width'
 564  };
 565  listener(BREAKPOINTS, OPERATORS);
 566  
 567  
 568  /***/ }),
 569  
 570  /***/ 8:
 571  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 572  
 573  "use strict";
 574  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
 575  function _extends() {
 576    _extends = Object.assign || function (target) {
 577      for (var i = 1; i < arguments.length; i++) {
 578        var source = arguments[i];
 579  
 580        for (var key in source) {
 581          if (Object.prototype.hasOwnProperty.call(source, key)) {
 582            target[key] = source[key];
 583          }
 584        }
 585      }
 586  
 587      return target;
 588    };
 589  
 590    return _extends.apply(this, arguments);
 591  }
 592  
 593  /***/ })
 594  
 595  /******/ });


Generated: Mon Mar 8 01:00:04 2021 Cross-referenced by PHPXref 0.7.1