wp/wp-includes/js/dist/viewport.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    80 /******/ 	// __webpack_public_path__
    80 /******/ 	// __webpack_public_path__
    81 /******/ 	__webpack_require__.p = "";
    81 /******/ 	__webpack_require__.p = "";
    82 /******/
    82 /******/
    83 /******/
    83 /******/
    84 /******/ 	// Load entry module and return exports
    84 /******/ 	// Load entry module and return exports
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 372);
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 454);
    86 /******/ })
    86 /******/ })
    87 /************************************************************************/
    87 /************************************************************************/
    88 /******/ ({
    88 /******/ ({
    89 
    89 
       
    90 /***/ 0:
       
    91 /***/ (function(module, exports) {
       
    92 
       
    93 (function() { module.exports = this["wp"]["element"]; }());
       
    94 
       
    95 /***/ }),
       
    96 
       
    97 /***/ 14:
       
    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__(29);
       
   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 
    90 /***/ 2:
   152 /***/ 2:
    91 /***/ (function(module, exports) {
   153 /***/ (function(module, exports) {
    92 
   154 
    93 (function() { module.exports = this["lodash"]; }());
   155 (function() { module.exports = this["lodash"]; }());
    94 
   156 
    95 /***/ }),
   157 /***/ }),
    96 
   158 
    97 /***/ 372:
   159 /***/ 26:
    98 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   160 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    99 
   161 
   100 "use strict";
   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 /***/ 29:
       
   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 /***/ 454:
       
   224 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   225 
       
   226 "use strict";
       
   227 // ESM COMPAT FLAG
   101 __webpack_require__.r(__webpack_exports__);
   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
   102 var actions_namespaceObject = {};
   235 var actions_namespaceObject = {};
   103 __webpack_require__.r(actions_namespaceObject);
   236 __webpack_require__.r(actions_namespaceObject);
   104 __webpack_require__.d(actions_namespaceObject, "setIsMatching", function() { return setIsMatching; });
   237 __webpack_require__.d(actions_namespaceObject, "setIsMatching", function() { return actions_setIsMatching; });
       
   238 
       
   239 // NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/selectors.js
   105 var selectors_namespaceObject = {};
   240 var selectors_namespaceObject = {};
   106 __webpack_require__.r(selectors_namespaceObject);
   241 __webpack_require__.r(selectors_namespaceObject);
   107 __webpack_require__.d(selectors_namespaceObject, "isViewportMatch", function() { return isViewportMatch; });
   242 __webpack_require__.d(selectors_namespaceObject, "isViewportMatch", function() { return isViewportMatch; });
   108 
   243 
   109 // EXTERNAL MODULE: external "lodash"
       
   110 var external_lodash_ = __webpack_require__(2);
       
   111 
       
   112 // EXTERNAL MODULE: external {"this":["wp","data"]}
   244 // EXTERNAL MODULE: external {"this":["wp","data"]}
   113 var external_this_wp_data_ = __webpack_require__(5);
   245 var external_this_wp_data_ = __webpack_require__(4);
   114 
   246 
   115 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/reducer.js
   247 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/reducer.js
   116 /**
   248 /**
   117  * Reducer returning the viewport state, as keys of breakpoint queries with
   249  * Reducer returning the viewport state, as keys of breakpoint queries with
   118  * boolean value representing whether query is matched.
   250  * boolean value representing whether query is matched.
   144  *
   276  *
   145  * @param {Object} values Breakpoint query matches.
   277  * @param {Object} values Breakpoint query matches.
   146  *
   278  *
   147  * @return {Object} Action object.
   279  * @return {Object} Action object.
   148  */
   280  */
   149 function setIsMatching(values) {
   281 function actions_setIsMatching(values) {
   150   return {
   282   return {
   151     type: 'SET_IS_MATCHING',
   283     type: 'SET_IS_MATCHING',
   152     values: values
   284     values: values
   153   };
   285   };
   154 }
   286 }
   195   reducer: store_reducer,
   327   reducer: store_reducer,
   196   actions: actions_namespaceObject,
   328   actions: actions_namespaceObject,
   197   selectors: selectors_namespaceObject
   329   selectors: selectors_namespaceObject
   198 }));
   330 }));
   199 
   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 
   200 // EXTERNAL MODULE: external {"this":["wp","compose"]}
   386 // EXTERNAL MODULE: external {"this":["wp","compose"]}
   201 var external_this_wp_compose_ = __webpack_require__(6);
   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__(14);
       
   394 
       
   395 // EXTERNAL MODULE: external {"this":["wp","element"]}
       
   396 var external_this_wp_element_ = __webpack_require__(0);
   202 
   397 
   203 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/with-viewport-match.js
   398 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/with-viewport-match.js
       
   399 
       
   400 
       
   401 
       
   402 
   204 /**
   403 /**
   205  * External dependencies
   404  * External dependencies
   206  */
   405  */
   207 
   406 
   208 /**
   407 /**
   209  * WordPress dependencies
   408  * WordPress dependencies
   210  */
   409  */
   211 
       
   212 
   410 
   213 
   411 
   214 /**
   412 /**
   215  * Higher-order component creator, creating a new component which renders with
   413  * Higher-order component creator, creating a new component which renders with
   216  * the given prop names, where the value passed to the underlying component is
   414  * the given prop names, where the value passed to the underlying component is
   234  *
   432  *
   235  * @return {Function} Higher-order component.
   433  * @return {Function} Higher-order component.
   236  */
   434  */
   237 
   435 
   238 var with_viewport_match_withViewportMatch = function withViewportMatch(queries) {
   436 var with_viewport_match_withViewportMatch = function withViewportMatch(queries) {
   239   return Object(external_this_wp_compose_["createHigherOrderComponent"])(Object(external_this_wp_data_["withSelect"])(function (select) {
   437   var useViewPortQueriesResult = function useViewPortQueriesResult() {
   240     return Object(external_lodash_["mapValues"])(queries, function (query) {
   438     return Object(external_this_lodash_["mapValues"])(queries, function (query) {
   241       return select('core/viewport').isViewportMatch(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);
   242     });
   454     });
   243   }), 'withViewportMatch');
   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');
   244 };
   463 };
   245 
   464 
   246 /* harmony default export */ var with_viewport_match = (with_viewport_match_withViewportMatch);
   465 /* harmony default export */ var with_viewport_match = (with_viewport_match_withViewportMatch);
   247 
   466 
   248 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/if-viewport-matches.js
   467 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/if-viewport-matches.js
   285 };
   504 };
   286 
   505 
   287 /* harmony default export */ var if_viewport_matches = (if_viewport_matches_ifViewportMatches);
   506 /* harmony default export */ var if_viewport_matches = (if_viewport_matches_ifViewportMatches);
   288 
   507 
   289 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/index.js
   508 // CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/index.js
   290 /* concated harmony reexport ifViewportMatches */__webpack_require__.d(__webpack_exports__, "ifViewportMatches", function() { return if_viewport_matches; });
       
   291 /* concated harmony reexport withViewportMatch */__webpack_require__.d(__webpack_exports__, "withViewportMatch", function() { return with_viewport_match; });
       
   292 /**
       
   293  * External dependencies
       
   294  */
       
   295 
       
   296 /**
       
   297  * WordPress dependencies
       
   298  */
       
   299 
       
   300 
       
   301 /**
   509 /**
   302  * Internal dependencies
   510  * Internal dependencies
   303  */
   511  */
   304 
   512 
   305 
   513 
   329 
   537 
   330 var OPERATORS = {
   538 var OPERATORS = {
   331   '<': 'max-width',
   539   '<': 'max-width',
   332   '>=': 'min-width'
   540   '>=': 'min-width'
   333 };
   541 };
   334 /**
   542 listener(BREAKPOINTS, OPERATORS);
   335  * Callback invoked when media query state should be updated. Is invoked a
   543 
   336  * maximum of one time per call stack.
   544 
   337  */
   545 /***/ }),
   338 
   546 
   339 var build_module_setIsMatching = Object(external_lodash_["debounce"])(function () {
   547 /***/ 8:
   340   var values = Object(external_lodash_["mapValues"])(build_module_queries, function (query) {
   548 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   341     return query.matches;
   549 
   342   });
   550 "use strict";
   343   Object(external_this_wp_data_["dispatch"])('core/viewport').setIsMatching(values);
   551 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
   344 }, {
   552 function _extends() {
   345   leading: true
   553   _extends = Object.assign || function (target) {
   346 });
   554     for (var i = 1; i < arguments.length; i++) {
   347 /**
   555       var source = arguments[i];
   348  * Hash of breakpoint names with generated MediaQueryList for corresponding
   556 
   349  * media query.
   557       for (var key in source) {
   350  *
   558         if (Object.prototype.hasOwnProperty.call(source, key)) {
   351  * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
   559           target[key] = source[key];
   352  * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList
   560         }
   353  *
   561       }
   354  * @type {Object<string,MediaQueryList>}
   562     }
   355  */
   563 
   356 
   564     return target;
   357 var build_module_queries = Object(external_lodash_["reduce"])(BREAKPOINTS, function (result, width, name) {
   565   };
   358   Object(external_lodash_["forEach"])(OPERATORS, function (condition, operator) {
   566 
   359     var list = window.matchMedia("(".concat(condition, ": ").concat(width, "px)"));
   567   return _extends.apply(this, arguments);
   360     list.addListener(build_module_setIsMatching);
   568 }
   361     var key = [operator, name].join(' ');
   569 
   362     result[key] = list;
   570 /***/ }),
   363   });
   571 
   364   return result;
   572 /***/ 9:
   365 }, {});
       
   366 window.addEventListener('orientationchange', build_module_setIsMatching); // Set initial values
       
   367 
       
   368 build_module_setIsMatching();
       
   369 build_module_setIsMatching.flush();
       
   370 
       
   371 
       
   372 /***/ }),
       
   373 
       
   374 /***/ 5:
       
   375 /***/ (function(module, exports) {
   573 /***/ (function(module, exports) {
   376 
   574 
   377 (function() { module.exports = this["wp"]["data"]; }());
       
   378 
       
   379 /***/ }),
       
   380 
       
   381 /***/ 6:
       
   382 /***/ (function(module, exports) {
       
   383 
       
   384 (function() { module.exports = this["wp"]["compose"]; }());
   575 (function() { module.exports = this["wp"]["compose"]; }());
   385 
   576 
   386 /***/ })
   577 /***/ })
   387 
   578 
   388 /******/ });
   579 /******/ });