You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
10 KiB

1 year ago
  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. /******/ }
  16. /******/ };
  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. /******/
  35. /************************************************************************/
  36. var __webpack_exports__ = {};
  37. // ESM COMPAT FLAG
  38. __webpack_require__.r(__webpack_exports__);
  39. // EXPORTS
  40. __webpack_require__.d(__webpack_exports__, {
  41. ifViewportMatches: function() { return /* reexport */ if_viewport_matches; },
  42. store: function() { return /* reexport */ store; },
  43. withViewportMatch: function() { return /* reexport */ with_viewport_match; }
  44. });
  45. // NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/actions.js
  46. var actions_namespaceObject = {};
  47. __webpack_require__.r(actions_namespaceObject);
  48. __webpack_require__.d(actions_namespaceObject, {
  49. setIsMatching: function() { return setIsMatching; }
  50. });
  51. // NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/selectors.js
  52. var selectors_namespaceObject = {};
  53. __webpack_require__.r(selectors_namespaceObject);
  54. __webpack_require__.d(selectors_namespaceObject, {
  55. isViewportMatch: function() { return isViewportMatch; }
  56. });
  57. ;// CONCATENATED MODULE: external ["wp","compose"]
  58. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  59. ;// CONCATENATED MODULE: external ["wp","data"]
  60. var external_wp_data_namespaceObject = window["wp"]["data"];
  61. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/reducer.js
  62. /**
  63. * Reducer returning the viewport state, as keys of breakpoint queries with
  64. * boolean value representing whether query is matched.
  65. *
  66. * @param {Object} state Current state.
  67. * @param {Object} action Dispatched action.
  68. *
  69. * @return {Object} Updated state.
  70. */
  71. function reducer(state = {}, action) {
  72. switch (action.type) {
  73. case 'SET_IS_MATCHING':
  74. return action.values;
  75. }
  76. return state;
  77. }
  78. /* harmony default export */ var store_reducer = (reducer);
  79. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/actions.js
  80. /**
  81. * Returns an action object used in signalling that viewport queries have been
  82. * updated. Values are specified as an object of breakpoint query keys where
  83. * value represents whether query matches.
  84. * Ignored from documentation as it is for internal use only.
  85. *
  86. * @ignore
  87. *
  88. * @param {Object} values Breakpoint query matches.
  89. *
  90. * @return {Object} Action object.
  91. */
  92. function setIsMatching(values) {
  93. return {
  94. type: 'SET_IS_MATCHING',
  95. values
  96. };
  97. }
  98. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/selectors.js
  99. /**
  100. * Returns true if the viewport matches the given query, or false otherwise.
  101. *
  102. * @param {Object} state Viewport state object.
  103. * @param {string} query Query string. Includes operator and breakpoint name,
  104. * space separated. Operator defaults to >=.
  105. *
  106. * @example
  107. *
  108. * ```js
  109. * import { store as viewportStore } from '@wordpress/viewport';
  110. * import { useSelect } from '@wordpress/data';
  111. * import { __ } from '@wordpress/i18n';
  112. * const ExampleComponent = () => {
  113. * const isMobile = useSelect(
  114. * ( select ) => select( viewportStore ).isViewportMatch( '< small' ),
  115. * []
  116. * );
  117. *
  118. * return isMobile ? (
  119. * <div>{ __( 'Mobile' ) }</div>
  120. * ) : (
  121. * <div>{ __( 'Not Mobile' ) }</div>
  122. * );
  123. * };
  124. * ```
  125. *
  126. * @return {boolean} Whether viewport matches query.
  127. */
  128. function isViewportMatch(state, query) {
  129. // Default to `>=` if no operator is present.
  130. if (query.indexOf(' ') === -1) {
  131. query = '>= ' + query;
  132. }
  133. return !!state[query];
  134. }
  135. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/index.js
  136. /**
  137. * WordPress dependencies
  138. */
  139. /**
  140. * Internal dependencies
  141. */
  142. const STORE_NAME = 'core/viewport';
  143. /**
  144. * Store definition for the viewport namespace.
  145. *
  146. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  147. *
  148. * @type {Object}
  149. */
  150. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
  151. reducer: store_reducer,
  152. actions: actions_namespaceObject,
  153. selectors: selectors_namespaceObject
  154. });
  155. (0,external_wp_data_namespaceObject.register)(store);
  156. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/listener.js
  157. /**
  158. * WordPress dependencies
  159. */
  160. /**
  161. * Internal dependencies
  162. */
  163. const addDimensionsEventListener = (breakpoints, operators) => {
  164. /**
  165. * Callback invoked when media query state should be updated. Is invoked a
  166. * maximum of one time per call stack.
  167. */
  168. const setIsMatching = (0,external_wp_compose_namespaceObject.debounce)(() => {
  169. const values = Object.fromEntries(queries.map(([key, query]) => [key, query.matches]));
  170. (0,external_wp_data_namespaceObject.dispatch)(store).setIsMatching(values);
  171. }, 0, {
  172. leading: true
  173. });
  174. /**
  175. * Hash of breakpoint names with generated MediaQueryList for corresponding
  176. * media query.
  177. *
  178. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
  179. * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList
  180. *
  181. * @type {Object<string,MediaQueryList>}
  182. */
  183. const operatorEntries = Object.entries(operators);
  184. const queries = Object.entries(breakpoints).flatMap(([name, width]) => {
  185. return operatorEntries.map(([operator, condition]) => {
  186. const list = window.matchMedia(`(${condition}: ${width}px)`);
  187. list.addEventListener('change', setIsMatching);
  188. return [`${operator} ${name}`, list];
  189. });
  190. });
  191. window.addEventListener('orientationchange', setIsMatching);
  192. // Set initial values.
  193. setIsMatching();
  194. setIsMatching.flush();
  195. };
  196. /* harmony default export */ var listener = (addDimensionsEventListener);
  197. ;// CONCATENATED MODULE: external ["wp","element"]
  198. var external_wp_element_namespaceObject = window["wp"]["element"];
  199. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/with-viewport-match.js
  200. /**
  201. * WordPress dependencies
  202. */
  203. /**
  204. * Higher-order component creator, creating a new component which renders with
  205. * the given prop names, where the value passed to the underlying component is
  206. * the result of the query assigned as the object's value.
  207. *
  208. * @see isViewportMatch
  209. *
  210. * @param {Object} queries Object of prop name to viewport query.
  211. *
  212. * @example
  213. *
  214. * ```jsx
  215. * function MyComponent( { isMobile } ) {
  216. * return (
  217. * <div>Currently: { isMobile ? 'Mobile' : 'Not Mobile' }</div>
  218. * );
  219. * }
  220. *
  221. * MyComponent = withViewportMatch( { isMobile: '< small' } )( MyComponent );
  222. * ```
  223. *
  224. * @return {Function} Higher-order component.
  225. */
  226. const withViewportMatch = queries => {
  227. const queryEntries = Object.entries(queries);
  228. const useViewPortQueriesResult = () => Object.fromEntries(queryEntries.map(([key, query]) => {
  229. let [operator, breakpointName] = query.split(' ');
  230. if (breakpointName === undefined) {
  231. breakpointName = operator;
  232. operator = '>=';
  233. }
  234. // Hooks should unconditionally execute in the same order,
  235. // we are respecting that as from the static query of the HOC we generate
  236. // a hook that calls other hooks always in the same order (because the query never changes).
  237. // eslint-disable-next-line react-hooks/rules-of-hooks
  238. return [key, (0,external_wp_compose_namespaceObject.useViewportMatch)(breakpointName, operator)];
  239. }));
  240. return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
  241. return (0,external_wp_compose_namespaceObject.pure)(props => {
  242. const queriesResult = useViewPortQueriesResult();
  243. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, {
  244. ...props,
  245. ...queriesResult
  246. });
  247. });
  248. }, 'withViewportMatch');
  249. };
  250. /* harmony default export */ var with_viewport_match = (withViewportMatch);
  251. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/if-viewport-matches.js
  252. /**
  253. * WordPress dependencies
  254. */
  255. /**
  256. * Internal dependencies
  257. */
  258. /**
  259. * Higher-order component creator, creating a new component which renders if
  260. * the viewport query is satisfied.
  261. *
  262. * @see withViewportMatches
  263. *
  264. * @param {string} query Viewport query.
  265. *
  266. * @example
  267. *
  268. * ```jsx
  269. * function MyMobileComponent() {
  270. * return <div>I'm only rendered on mobile viewports!</div>;
  271. * }
  272. *
  273. * MyMobileComponent = ifViewportMatches( '< small' )( MyMobileComponent );
  274. * ```
  275. *
  276. * @return {Function} Higher-order component.
  277. */
  278. const ifViewportMatches = query => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([with_viewport_match({
  279. isViewportMatch: query
  280. }), (0,external_wp_compose_namespaceObject.ifCondition)(props => props.isViewportMatch)]), 'ifViewportMatches');
  281. /* harmony default export */ var if_viewport_matches = (ifViewportMatches);
  282. ;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/index.js
  283. /**
  284. * Internal dependencies
  285. */
  286. /**
  287. * Hash of breakpoint names with pixel width at which it becomes effective.
  288. *
  289. * @see _breakpoints.scss
  290. *
  291. * @type {Object}
  292. */
  293. const BREAKPOINTS = {
  294. huge: 1440,
  295. wide: 1280,
  296. large: 960,
  297. medium: 782,
  298. small: 600,
  299. mobile: 480
  300. };
  301. /**
  302. * Hash of query operators with corresponding condition for media query.
  303. *
  304. * @type {Object}
  305. */
  306. const OPERATORS = {
  307. '<': 'max-width',
  308. '>=': 'min-width'
  309. };
  310. listener(BREAKPOINTS, OPERATORS);
  311. (window.wp = window.wp || {}).viewport = __webpack_exports__;
  312. /******/ })()
  313. ;