~canonical-sysadmins/wordpress/5.0.2

« back to all changes in this revision

Viewing changes to wp-includes/js/dist/viewport.js

  • Committer: Barry Price
  • Date: 2018-12-12 05:08:33 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: barry.price@canonical.com-20181212050833-y090hmrbmlxy37aa
Merge WP5.0 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 = 316);
 
86
/******/ })
 
87
/************************************************************************/
 
88
/******/ ({
 
89
 
 
90
/***/ 19:
 
91
/***/ (function(module, __webpack_exports__, __webpack_require__) {
 
92
 
 
93
"use strict";
 
94
 
 
95
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
 
96
function _arrayWithoutHoles(arr) {
 
97
  if (Array.isArray(arr)) {
 
98
    for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
 
99
      arr2[i] = arr[i];
 
100
    }
 
101
 
 
102
    return arr2;
 
103
  }
 
104
}
 
105
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
 
106
var iterableToArray = __webpack_require__(32);
 
107
 
 
108
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
 
109
function _nonIterableSpread() {
 
110
  throw new TypeError("Invalid attempt to spread non-iterable instance");
 
111
}
 
112
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
 
113
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; });
 
114
 
 
115
 
 
116
 
 
117
function _toConsumableArray(arr) {
 
118
  return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread();
 
119
}
 
120
 
 
121
/***/ }),
 
122
 
 
123
/***/ 2:
 
124
/***/ (function(module, exports) {
 
125
 
 
126
(function() { module.exports = this["lodash"]; }());
 
127
 
 
128
/***/ }),
 
129
 
 
130
/***/ 316:
 
131
/***/ (function(module, __webpack_exports__, __webpack_require__) {
 
132
 
 
133
"use strict";
 
134
__webpack_require__.r(__webpack_exports__);
 
135
var actions_namespaceObject = {};
 
136
__webpack_require__.r(actions_namespaceObject);
 
137
__webpack_require__.d(actions_namespaceObject, "setIsMatching", function() { return setIsMatching; });
 
138
var selectors_namespaceObject = {};
 
139
__webpack_require__.r(selectors_namespaceObject);
 
140
__webpack_require__.d(selectors_namespaceObject, "isViewportMatch", function() { return isViewportMatch; });
 
141
 
 
142
// EXTERNAL MODULE: external "lodash"
 
143
var external_lodash_ = __webpack_require__(2);
 
144
 
 
145
// EXTERNAL MODULE: external {"this":["wp","data"]}
 
146
var external_this_wp_data_ = __webpack_require__(5);
 
147
 
 
148
// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/reducer.js
 
149
/**
 
150
 * Reducer returning the viewport state, as keys of breakpoint queries with
 
151
 * boolean value representing whether query is matched.
 
152
 *
 
153
 * @param {Object} state  Current state.
 
154
 * @param {Object} action Dispatched action.
 
155
 *
 
156
 * @return {Object} Updated state.
 
157
 */
 
158
function reducer() {
 
159
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 
160
  var action = arguments.length > 1 ? arguments[1] : undefined;
 
161
 
 
162
  switch (action.type) {
 
163
    case 'SET_IS_MATCHING':
 
164
      return action.values;
 
165
  }
 
166
 
 
167
  return state;
 
168
}
 
169
 
 
170
/* harmony default export */ var store_reducer = (reducer);
 
171
 
 
172
// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/actions.js
 
173
/**
 
174
 * Returns an action object used in signalling that viewport queries have been
 
175
 * updated. Values are specified as an object of breakpoint query keys where
 
176
 * value represents whether query matches.
 
177
 *
 
178
 * @param {Object} values Breakpoint query matches.
 
179
 *
 
180
 * @return {Object} Action object.
 
181
 */
 
182
function setIsMatching(values) {
 
183
  return {
 
184
    type: 'SET_IS_MATCHING',
 
185
    values: values
 
186
  };
 
187
}
 
188
 
 
189
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 
190
var toConsumableArray = __webpack_require__(19);
 
191
 
 
192
// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/selectors.js
 
193
 
 
194
 
 
195
/**
 
196
 * External dependencies
 
197
 */
 
198
 
 
199
/**
 
200
 * Returns true if the viewport matches the given query, or false otherwise.
 
201
 *
 
202
 * @param {Object} state Viewport state object.
 
203
 * @param {string} query Query string. Includes operator and breakpoint name,
 
204
 *                       space separated. Operator defaults to >=.
 
205
 *
 
206
 * @example
 
207
 *
 
208
 * ```js
 
209
 * isViewportMatch( state, '< huge' );
 
210
 * isViewPortMatch( state, 'medium' );
 
211
 * ```
 
212
 *
 
213
 * @return {boolean} Whether viewport matches query.
 
214
 */
 
215
 
 
216
function isViewportMatch(state, query) {
 
217
  // Pad to _at least_ two elements to take from the right, effectively
 
218
  // defaulting the left-most value.
 
219
  var key = Object(external_lodash_["takeRight"])(['>='].concat(Object(toConsumableArray["a" /* default */])(query.split(' '))), 2).join(' ');
 
220
  return !!state[key];
 
221
}
 
222
 
 
223
// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/index.js
 
224
/**
 
225
 * WordPress dependencies
 
226
 */
 
227
 
 
228
/**
 
229
 * Internal dependencies
 
230
 */
 
231
 
 
232
 
 
233
 
 
234
 
 
235
/* harmony default export */ var store = (Object(external_this_wp_data_["registerStore"])('core/viewport', {
 
236
  reducer: store_reducer,
 
237
  actions: actions_namespaceObject,
 
238
  selectors: selectors_namespaceObject
 
239
}));
 
240
 
 
241
// EXTERNAL MODULE: external {"this":["wp","compose"]}
 
242
var external_this_wp_compose_ = __webpack_require__(7);
 
243
 
 
244
// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/with-viewport-match.js
 
245
/**
 
246
 * External dependencies
 
247
 */
 
248
 
 
249
/**
 
250
 * WordPress dependencies
 
251
 */
 
252
 
 
253
 
 
254
 
 
255
/**
 
256
 * Higher-order component creator, creating a new component which renders with
 
257
 * the given prop names, where the value passed to the underlying component is
 
258
 * the result of the query assigned as the object's value.
 
259
 *
 
260
 * @param {Object} queries  Object of prop name to viewport query.
 
261
 *
 
262
 * @see isViewportMatch
 
263
 *
 
264
 * @return {Function} Higher-order component.
 
265
 */
 
266
 
 
267
var with_viewport_match_withViewportMatch = function withViewportMatch(queries) {
 
268
  return Object(external_this_wp_compose_["createHigherOrderComponent"])(Object(external_this_wp_data_["withSelect"])(function (select) {
 
269
    return Object(external_lodash_["mapValues"])(queries, function (query) {
 
270
      return select('core/viewport').isViewportMatch(query);
 
271
    });
 
272
  }), 'withViewportMatch');
 
273
};
 
274
 
 
275
/* harmony default export */ var with_viewport_match = (with_viewport_match_withViewportMatch);
 
276
 
 
277
// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/if-viewport-matches.js
 
278
/**
 
279
 * WordPress dependencies
 
280
 */
 
281
 
 
282
/**
 
283
 * Internal dependencies
 
284
 */
 
285
 
 
286
 
 
287
/**
 
288
 * Higher-order component creator, creating a new component which renders if
 
289
 * the viewport query is satisfied.
 
290
 *
 
291
 * @param {string} query Viewport query.
 
292
 *
 
293
 * @see withViewportMatches
 
294
 *
 
295
 * @return {Function} Higher-order component.
 
296
 */
 
297
 
 
298
var if_viewport_matches_ifViewportMatches = function ifViewportMatches(query) {
 
299
  return Object(external_this_wp_compose_["createHigherOrderComponent"])(Object(external_this_wp_compose_["compose"])([with_viewport_match({
 
300
    isViewportMatch: query
 
301
  }), Object(external_this_wp_compose_["ifCondition"])(function (props) {
 
302
    return props.isViewportMatch;
 
303
  })]), 'ifViewportMatches');
 
304
};
 
305
 
 
306
/* harmony default export */ var if_viewport_matches = (if_viewport_matches_ifViewportMatches);
 
307
 
 
308
// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/index.js
 
309
/* concated harmony reexport ifViewportMatches */__webpack_require__.d(__webpack_exports__, "ifViewportMatches", function() { return if_viewport_matches; });
 
310
/* concated harmony reexport withViewportMatch */__webpack_require__.d(__webpack_exports__, "withViewportMatch", function() { return with_viewport_match; });
 
311
/**
 
312
 * External dependencies
 
313
 */
 
314
 
 
315
/**
 
316
 * WordPress dependencies
 
317
 */
 
318
 
 
319
 
 
320
/**
 
321
 * Internal dependencies
 
322
 */
 
323
 
 
324
 
 
325
 
 
326
 
 
327
/**
 
328
 * Hash of breakpoint names with pixel width at which it becomes effective.
 
329
 *
 
330
 * @see _breakpoints.scss
 
331
 *
 
332
 * @type {Object}
 
333
 */
 
334
 
 
335
var BREAKPOINTS = {
 
336
  huge: 1440,
 
337
  wide: 1280,
 
338
  large: 960,
 
339
  medium: 782,
 
340
  small: 600,
 
341
  mobile: 480
 
342
};
 
343
/**
 
344
 * Hash of query operators with corresponding condition for media query.
 
345
 *
 
346
 * @type {Object}
 
347
 */
 
348
 
 
349
var OPERATORS = {
 
350
  '<': 'max-width',
 
351
  '>=': 'min-width'
 
352
};
 
353
/**
 
354
 * Callback invoked when media query state should be updated. Is invoked a
 
355
 * maximum of one time per call stack.
 
356
 */
 
357
 
 
358
var build_module_setIsMatching = Object(external_lodash_["debounce"])(function () {
 
359
  var values = Object(external_lodash_["mapValues"])(build_module_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 build_module_queries = Object(external_lodash_["reduce"])(BREAKPOINTS, function (result, width, name) {
 
377
  Object(external_lodash_["forEach"])(OPERATORS, function (condition, operator) {
 
378
    var list = window.matchMedia("(".concat(condition, ": ").concat(width, "px)"));
 
379
    list.addListener(build_module_setIsMatching);
 
380
    var key = [operator, name].join(' ');
 
381
    result[key] = list;
 
382
  });
 
383
  return result;
 
384
}, {});
 
385
window.addEventListener('orientationchange', build_module_setIsMatching); // Set initial values
 
386
 
 
387
build_module_setIsMatching();
 
388
 
 
389
 
 
390
/***/ }),
 
391
 
 
392
/***/ 32:
 
393
/***/ (function(module, __webpack_exports__, __webpack_require__) {
 
394
 
 
395
"use strict";
 
396
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 
397
function _iterableToArray(iter) {
 
398
  if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
 
399
}
 
400
 
 
401
/***/ }),
 
402
 
 
403
/***/ 5:
 
404
/***/ (function(module, exports) {
 
405
 
 
406
(function() { module.exports = this["wp"]["data"]; }());
 
407
 
 
408
/***/ }),
 
409
 
 
410
/***/ 7:
 
411
/***/ (function(module, exports) {
 
412
 
 
413
(function() { module.exports = this["wp"]["compose"]; }());
 
414
 
 
415
/***/ })
 
416
 
 
417
/******/ });
 
 
b'\\ No newline at end of file'