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


Generated : Thu Dec 3 08:20:02 2020 Cross-referenced by PHPXref