Merged in feature/81-dev-dev01 (pull request #5)
auto-patch 81-dev-dev01-2023-12-05T22_45_26 * auto-patch 81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
48
wp/wp-includes/js/dist/viewport.js
vendored
48
wp/wp-includes/js/dist/viewport.js
vendored
@@ -39,23 +39,23 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"ifViewportMatches": function() { return /* reexport */ if_viewport_matches; },
|
||||
"store": function() { return /* reexport */ store; },
|
||||
"withViewportMatch": function() { return /* reexport */ with_viewport_match; }
|
||||
ifViewportMatches: function() { return /* reexport */ if_viewport_matches; },
|
||||
store: function() { return /* reexport */ store; },
|
||||
withViewportMatch: function() { return /* reexport */ with_viewport_match; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
"setIsMatching": function() { return setIsMatching; }
|
||||
setIsMatching: function() { return setIsMatching; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/viewport/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
"isViewportMatch": function() { return isViewportMatch; }
|
||||
isViewportMatch: function() { return isViewportMatch; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","compose"]
|
||||
@@ -77,10 +77,8 @@ function reducer(state = {}, action) {
|
||||
case 'SET_IS_MATCHING':
|
||||
return action.values;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/* harmony default export */ var store_reducer = (reducer);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/store/actions.js
|
||||
@@ -138,7 +136,6 @@ function isViewportMatch(state, query) {
|
||||
if (query.indexOf(' ') === -1) {
|
||||
query = '>= ' + query;
|
||||
}
|
||||
|
||||
return !!state[query];
|
||||
}
|
||||
|
||||
@@ -147,14 +144,15 @@ function isViewportMatch(state, query) {
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
const STORE_NAME = 'core/viewport';
|
||||
|
||||
/**
|
||||
* Store definition for the viewport namespace.
|
||||
*
|
||||
@@ -162,7 +160,6 @@ const STORE_NAME = 'core/viewport';
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
reducer: store_reducer,
|
||||
actions: actions_namespaceObject,
|
||||
@@ -176,12 +173,11 @@ const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME,
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const addDimensionsEventListener = (breakpoints, operators) => {
|
||||
/**
|
||||
* Callback invoked when media query state should be updated. Is invoked a
|
||||
@@ -193,6 +189,7 @@ const addDimensionsEventListener = (breakpoints, operators) => {
|
||||
}, 0, {
|
||||
leading: true
|
||||
});
|
||||
|
||||
/**
|
||||
* Hash of breakpoint names with generated MediaQueryList for corresponding
|
||||
* media query.
|
||||
@@ -202,7 +199,6 @@ const addDimensionsEventListener = (breakpoints, operators) => {
|
||||
*
|
||||
* @type {Object<string,MediaQueryList>}
|
||||
*/
|
||||
|
||||
const operatorEntries = Object.entries(operators);
|
||||
const queries = Object.entries(breakpoints).flatMap(([name, width]) => {
|
||||
return operatorEntries.map(([operator, condition]) => {
|
||||
@@ -211,23 +207,23 @@ const addDimensionsEventListener = (breakpoints, operators) => {
|
||||
return [`${operator} ${name}`, list];
|
||||
});
|
||||
});
|
||||
window.addEventListener('orientationchange', setIsMatching); // Set initial values.
|
||||
window.addEventListener('orientationchange', setIsMatching);
|
||||
|
||||
// Set initial values.
|
||||
setIsMatching();
|
||||
setIsMatching.flush();
|
||||
};
|
||||
|
||||
/* harmony default export */ var listener = (addDimensionsEventListener);
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","element"]
|
||||
var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/with-viewport-match.js
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Higher-order component creator, creating a new component which renders with
|
||||
* the given prop names, where the value passed to the underlying component is
|
||||
@@ -251,35 +247,30 @@ var external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
*
|
||||
* @return {Function} Higher-order component.
|
||||
*/
|
||||
|
||||
const withViewportMatch = queries => {
|
||||
const queryEntries = Object.entries(queries);
|
||||
|
||||
const useViewPortQueriesResult = () => Object.fromEntries(queryEntries.map(([key, query]) => {
|
||||
let [operator, breakpointName] = query.split(' ');
|
||||
|
||||
if (breakpointName === undefined) {
|
||||
breakpointName = operator;
|
||||
operator = '>=';
|
||||
} // Hooks should unconditionally execute in the same order,
|
||||
}
|
||||
// Hooks should unconditionally execute in the same order,
|
||||
// we are respecting that as from the static query of the HOC we generate
|
||||
// a hook that calls other hooks always in the same order (because the query never changes).
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
|
||||
|
||||
return [key, (0,external_wp_compose_namespaceObject.useViewportMatch)(breakpointName, operator)];
|
||||
}));
|
||||
|
||||
return (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => {
|
||||
return (0,external_wp_compose_namespaceObject.pure)(props => {
|
||||
const queriesResult = useViewPortQueriesResult();
|
||||
return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, { ...props,
|
||||
return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, {
|
||||
...props,
|
||||
...queriesResult
|
||||
});
|
||||
});
|
||||
}, 'withViewportMatch');
|
||||
};
|
||||
|
||||
/* harmony default export */ var with_viewport_match = (withViewportMatch);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/if-viewport-matches.js
|
||||
@@ -287,6 +278,7 @@ const withViewportMatch = queries => {
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
@@ -312,11 +304,9 @@ const withViewportMatch = queries => {
|
||||
*
|
||||
* @return {Function} Higher-order component.
|
||||
*/
|
||||
|
||||
const ifViewportMatches = query => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((0,external_wp_compose_namespaceObject.compose)([with_viewport_match({
|
||||
isViewportMatch: query
|
||||
}), (0,external_wp_compose_namespaceObject.ifCondition)(props => props.isViewportMatch)]), 'ifViewportMatches');
|
||||
|
||||
/* harmony default export */ var if_viewport_matches = (ifViewportMatches);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/viewport/build-module/index.js
|
||||
@@ -327,6 +317,7 @@ const ifViewportMatches = query => (0,external_wp_compose_namespaceObject.create
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Hash of breakpoint names with pixel width at which it becomes effective.
|
||||
*
|
||||
@@ -334,7 +325,6 @@ const ifViewportMatches = query => (0,external_wp_compose_namespaceObject.create
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
const BREAKPOINTS = {
|
||||
huge: 1440,
|
||||
wide: 1280,
|
||||
@@ -343,12 +333,12 @@ const BREAKPOINTS = {
|
||||
small: 600,
|
||||
mobile: 480
|
||||
};
|
||||
|
||||
/**
|
||||
* Hash of query operators with corresponding condition for media query.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
const OPERATORS = {
|
||||
'<': 'max-width',
|
||||
'>=': 'min-width'
|
||||
|
||||
Reference in New Issue
Block a user