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


Generated: Thu Jul 2 01:00:04 2020 Cross-referenced by PHPXref 0.7.1