[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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


Generated : Sun May 24 08:20:01 2020 Cross-referenced by PHPXref