19
|
1 |
/******/ (function() { // webpackBootstrap |
|
2 |
/******/ "use strict"; |
|
3 |
/******/ // The require scope |
|
4 |
/******/ var __webpack_require__ = {}; |
|
5 |
/******/ |
|
6 |
/************************************************************************/ |
|
7 |
/******/ /* webpack/runtime/define property getters */ |
|
8 |
/******/ !function() { |
|
9 |
/******/ // define getter functions for harmony exports |
|
10 |
/******/ __webpack_require__.d = function(exports, definition) { |
|
11 |
/******/ for(var key in definition) { |
|
12 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
13 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
14 |
/******/ } |
|
15 |
/******/ } |
9
|
16 |
/******/ }; |
19
|
17 |
/******/ }(); |
|
18 |
/******/ |
|
19 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
20 |
/******/ !function() { |
|
21 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
|
22 |
/******/ }(); |
|
23 |
/******/ |
|
24 |
/******/ /* webpack/runtime/make namespace object */ |
|
25 |
/******/ !function() { |
|
26 |
/******/ // define __esModule on exports |
|
27 |
/******/ __webpack_require__.r = function(exports) { |
|
28 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
29 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
30 |
/******/ } |
|
31 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
32 |
/******/ }; |
|
33 |
/******/ }(); |
|
34 |
/******/ |
9
|
35 |
/************************************************************************/ |
19
|
36 |
var __webpack_exports__ = {}; |
16
|
37 |
// ESM COMPAT FLAG |
9
|
38 |
__webpack_require__.r(__webpack_exports__); |
16
|
39 |
|
|
40 |
// EXPORTS |
19
|
41 |
__webpack_require__.d(__webpack_exports__, { |
|
42 |
"ifViewportMatches": function() { return /* reexport */ if_viewport_matches; }, |
|
43 |
"store": function() { return /* reexport */ store; }, |
|
44 |
"withViewportMatch": function() { return /* reexport */ with_viewport_match; } |
|
45 |
}); |
16
|
46 |
|
|
47 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/actions.js |
9
|
48 |
var actions_namespaceObject = {}; |
|
49 |
__webpack_require__.r(actions_namespaceObject); |
19
|
50 |
__webpack_require__.d(actions_namespaceObject, { |
|
51 |
"setIsMatching": function() { return setIsMatching; } |
|
52 |
}); |
16
|
53 |
|
|
54 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/selectors.js |
9
|
55 |
var selectors_namespaceObject = {}; |
|
56 |
__webpack_require__.r(selectors_namespaceObject); |
19
|
57 |
__webpack_require__.d(selectors_namespaceObject, { |
|
58 |
"isViewportMatch": function() { return isViewportMatch; } |
|
59 |
}); |
18
|
60 |
|
19
|
61 |
;// CONCATENATED MODULE: external "lodash" |
|
62 |
var external_lodash_namespaceObject = window["lodash"]; |
|
63 |
;// CONCATENATED MODULE: external ["wp","data"] |
|
64 |
var external_wp_data_namespaceObject = window["wp"]["data"]; |
|
65 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/reducer.js |
9
|
66 |
/** |
|
67 |
* Reducer returning the viewport state, as keys of breakpoint queries with |
|
68 |
* boolean value representing whether query is matched. |
|
69 |
* |
|
70 |
* @param {Object} state Current state. |
|
71 |
* @param {Object} action Dispatched action. |
|
72 |
* |
|
73 |
* @return {Object} Updated state. |
|
74 |
*/ |
19
|
75 |
function reducer() { |
|
76 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
77 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
|
78 |
|
9
|
79 |
switch (action.type) { |
|
80 |
case 'SET_IS_MATCHING': |
|
81 |
return action.values; |
|
82 |
} |
|
83 |
|
|
84 |
return state; |
|
85 |
} |
|
86 |
|
|
87 |
/* harmony default export */ var store_reducer = (reducer); |
|
88 |
|
19
|
89 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/actions.js |
9
|
90 |
/** |
|
91 |
* Returns an action object used in signalling that viewport queries have been |
|
92 |
* updated. Values are specified as an object of breakpoint query keys where |
|
93 |
* value represents whether query matches. |
|
94 |
* |
|
95 |
* @param {Object} values Breakpoint query matches. |
|
96 |
* |
|
97 |
* @return {Object} Action object. |
|
98 |
*/ |
19
|
99 |
function setIsMatching(values) { |
9
|
100 |
return { |
|
101 |
type: 'SET_IS_MATCHING', |
18
|
102 |
values |
9
|
103 |
}; |
|
104 |
} |
|
105 |
|
19
|
106 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/selectors.js |
9
|
107 |
/** |
|
108 |
* Returns true if the viewport matches the given query, or false otherwise. |
|
109 |
* |
|
110 |
* @param {Object} state Viewport state object. |
|
111 |
* @param {string} query Query string. Includes operator and breakpoint name, |
|
112 |
* space separated. Operator defaults to >=. |
|
113 |
* |
|
114 |
* @example |
|
115 |
* |
|
116 |
* ```js |
|
117 |
* isViewportMatch( state, '< huge' ); |
|
118 |
* isViewPortMatch( state, 'medium' ); |
|
119 |
* ``` |
|
120 |
* |
|
121 |
* @return {boolean} Whether viewport matches query. |
|
122 |
*/ |
|
123 |
function isViewportMatch(state, query) { |
|
124 |
// Default to `>=` if no operator is present. |
|
125 |
if (query.indexOf(' ') === -1) { |
|
126 |
query = '>= ' + query; |
|
127 |
} |
|
128 |
|
|
129 |
return !!state[query]; |
|
130 |
} |
|
131 |
|
19
|
132 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/index.js |
9
|
133 |
/** |
|
134 |
* WordPress dependencies |
|
135 |
*/ |
|
136 |
|
|
137 |
/** |
|
138 |
* Internal dependencies |
|
139 |
*/ |
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
18
|
144 |
const STORE_NAME = 'core/viewport'; |
|
145 |
/** |
|
146 |
* Store definition for the viewport namespace. |
|
147 |
* |
|
148 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
149 |
* |
|
150 |
* @type {Object} |
|
151 |
*/ |
|
152 |
|
19
|
153 |
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
9
|
154 |
reducer: store_reducer, |
|
155 |
actions: actions_namespaceObject, |
|
156 |
selectors: selectors_namespaceObject |
18
|
157 |
}); |
19
|
158 |
(0,external_wp_data_namespaceObject.register)(store); |
9
|
159 |
|
19
|
160 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/listener.js |
9
|
161 |
/** |
|
162 |
* External dependencies |
|
163 |
*/ |
|
164 |
|
|
165 |
/** |
|
166 |
* WordPress dependencies |
|
167 |
*/ |
|
168 |
|
|
169 |
|
18
|
170 |
/** |
|
171 |
* Internal dependencies |
|
172 |
*/ |
9
|
173 |
|
18
|
174 |
|
|
175 |
|
|
176 |
const addDimensionsEventListener = (breakpoints, operators) => { |
16
|
177 |
/** |
|
178 |
* Callback invoked when media query state should be updated. Is invoked a |
|
179 |
* maximum of one time per call stack. |
|
180 |
*/ |
19
|
181 |
const setIsMatching = (0,external_lodash_namespaceObject.debounce)(() => { |
|
182 |
const values = (0,external_lodash_namespaceObject.mapValues)(queries, query => query.matches); |
|
183 |
(0,external_wp_data_namespaceObject.dispatch)(store).setIsMatching(values); |
16
|
184 |
}, { |
|
185 |
leading: true |
|
186 |
}); |
|
187 |
/** |
|
188 |
* Hash of breakpoint names with generated MediaQueryList for corresponding |
|
189 |
* media query. |
|
190 |
* |
|
191 |
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia |
|
192 |
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList |
|
193 |
* |
|
194 |
* @type {Object<string,MediaQueryList>} |
|
195 |
*/ |
|
196 |
|
19
|
197 |
const queries = (0,external_lodash_namespaceObject.reduce)(breakpoints, (result, width, name) => { |
|
198 |
(0,external_lodash_namespaceObject.forEach)(operators, (condition, operator) => { |
18
|
199 |
const list = window.matchMedia(`(${condition}: ${width}px)`); |
16
|
200 |
list.addListener(setIsMatching); |
18
|
201 |
const key = [operator, name].join(' '); |
16
|
202 |
result[key] = list; |
|
203 |
}); |
|
204 |
return result; |
|
205 |
}, {}); |
19
|
206 |
window.addEventListener('orientationchange', setIsMatching); // Set initial values. |
16
|
207 |
|
|
208 |
setIsMatching(); |
|
209 |
setIsMatching.flush(); |
|
210 |
}; |
|
211 |
|
18
|
212 |
/* harmony default export */ var listener = (addDimensionsEventListener); |
16
|
213 |
|
19
|
214 |
;// CONCATENATED MODULE: external ["wp","compose"] |
|
215 |
var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
|
216 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
217 |
function _extends() { |
|
218 |
_extends = Object.assign ? Object.assign.bind() : function (target) { |
|
219 |
for (var i = 1; i < arguments.length; i++) { |
|
220 |
var source = arguments[i]; |
16
|
221 |
|
19
|
222 |
for (var key in source) { |
|
223 |
if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
224 |
target[key] = source[key]; |
|
225 |
} |
|
226 |
} |
|
227 |
} |
16
|
228 |
|
19
|
229 |
return target; |
|
230 |
}; |
|
231 |
return _extends.apply(this, arguments); |
|
232 |
} |
|
233 |
;// CONCATENATED MODULE: external ["wp","element"] |
|
234 |
var external_wp_element_namespaceObject = window["wp"]["element"]; |
|
235 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/with-viewport-match.js |
16
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
/** |
|
240 |
* External dependencies |
|
241 |
*/ |
|
242 |
|
|
243 |
/** |
|
244 |
* WordPress dependencies |
|
245 |
*/ |
|
246 |
|
|
247 |
|
9
|
248 |
/** |
|
249 |
* Higher-order component creator, creating a new component which renders with |
|
250 |
* the given prop names, where the value passed to the underlying component is |
|
251 |
* the result of the query assigned as the object's value. |
|
252 |
* |
|
253 |
* @see isViewportMatch |
|
254 |
* |
19
|
255 |
* @param {Object} queries Object of prop name to viewport query. |
9
|
256 |
* |
|
257 |
* @example |
|
258 |
* |
|
259 |
* ```jsx |
|
260 |
* function MyComponent( { isMobile } ) { |
|
261 |
* return ( |
|
262 |
* <div>Currently: { isMobile ? 'Mobile' : 'Not Mobile' }</div> |
|
263 |
* ); |
|
264 |
* } |
|
265 |
* |
|
266 |
* MyComponent = withViewportMatch( { isMobile: '< small' } )( MyComponent ); |
|
267 |
* ``` |
|
268 |
* |
|
269 |
* @return {Function} Higher-order component. |
|
270 |
*/ |
|
271 |
|
18
|
272 |
const withViewportMatch = queries => { |
19
|
273 |
const useViewPortQueriesResult = () => (0,external_lodash_namespaceObject.mapValues)(queries, query => { |
18
|
274 |
let [operator, breakpointName] = query.split(' '); |
16
|
275 |
|
18
|
276 |
if (breakpointName === undefined) { |
|
277 |
breakpointName = operator; |
|
278 |
operator = '>='; |
|
279 |
} // Hooks should unconditionally execute in the same order, |
|
280 |
// we are respecting that as from the static query of the HOC we generate |
|
281 |
// a hook that calls other hooks always in the same order (because the query never changes). |
|
282 |
// eslint-disable-next-line react-hooks/rules-of-hooks |
16
|
283 |
|
|
284 |
|
19
|
285 |
return (0,external_wp_compose_namespaceObject.useViewportMatch)(breakpointName, operator); |
18
|
286 |
}); |
16
|
287 |
|
19
|
288 |
return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => { |
|
289 |
return (0,external_wp_compose_namespaceObject.pure)(props => { |
18
|
290 |
const queriesResult = useViewPortQueriesResult(); |
19
|
291 |
return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, queriesResult)); |
16
|
292 |
}); |
|
293 |
}, 'withViewportMatch'); |
9
|
294 |
}; |
|
295 |
|
18
|
296 |
/* harmony default export */ var with_viewport_match = (withViewportMatch); |
9
|
297 |
|
19
|
298 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/if-viewport-matches.js |
9
|
299 |
/** |
|
300 |
* WordPress dependencies |
|
301 |
*/ |
|
302 |
|
|
303 |
/** |
|
304 |
* Internal dependencies |
|
305 |
*/ |
|
306 |
|
|
307 |
|
|
308 |
/** |
|
309 |
* Higher-order component creator, creating a new component which renders if |
|
310 |
* the viewport query is satisfied. |
|
311 |
* |
|
312 |
* @see withViewportMatches |
|
313 |
* |
|
314 |
* @param {string} query Viewport query. |
|
315 |
* |
|
316 |
* @example |
|
317 |
* |
|
318 |
* ```jsx |
|
319 |
* function MyMobileComponent() { |
|
320 |
* return <div>I'm only rendered on mobile viewports!</div>; |
|
321 |
* } |
|
322 |
* |
|
323 |
* MyMobileComponent = ifViewportMatches( '< small' )( MyMobileComponent ); |
|
324 |
* ``` |
|
325 |
* |
|
326 |
* @return {Function} Higher-order component. |
|
327 |
*/ |
|
328 |
|
19
|
329 |
const ifViewportMatches = query => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([with_viewport_match({ |
18
|
330 |
isViewportMatch: query |
19
|
331 |
}), (0,external_wp_compose_namespaceObject.ifCondition)(props => props.isViewportMatch)]), 'ifViewportMatches'); |
9
|
332 |
|
18
|
333 |
/* harmony default export */ var if_viewport_matches = (ifViewportMatches); |
9
|
334 |
|
19
|
335 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/index.js |
9
|
336 |
/** |
|
337 |
* Internal dependencies |
|
338 |
*/ |
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
/** |
|
344 |
* Hash of breakpoint names with pixel width at which it becomes effective. |
|
345 |
* |
|
346 |
* @see _breakpoints.scss |
|
347 |
* |
|
348 |
* @type {Object} |
|
349 |
*/ |
|
350 |
|
18
|
351 |
const BREAKPOINTS = { |
9
|
352 |
huge: 1440, |
|
353 |
wide: 1280, |
|
354 |
large: 960, |
|
355 |
medium: 782, |
|
356 |
small: 600, |
|
357 |
mobile: 480 |
|
358 |
}; |
|
359 |
/** |
|
360 |
* Hash of query operators with corresponding condition for media query. |
|
361 |
* |
|
362 |
* @type {Object} |
|
363 |
*/ |
|
364 |
|
18
|
365 |
const OPERATORS = { |
9
|
366 |
'<': 'max-width', |
|
367 |
'>=': 'min-width' |
|
368 |
}; |
16
|
369 |
listener(BREAKPOINTS, OPERATORS); |
9
|
370 |
|
19
|
371 |
(window.wp = window.wp || {}).viewport = __webpack_exports__; |
|
372 |
/******/ })() |
|
373 |
; |