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:
76
wp/wp-includes/js/dist/notices.js
vendored
76
wp/wp-includes/js/dist/notices.js
vendored
@@ -39,28 +39,28 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"store": function() { return /* reexport */ store; }
|
||||
store: function() { return /* reexport */ store; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
|
||||
var actions_namespaceObject = {};
|
||||
__webpack_require__.r(actions_namespaceObject);
|
||||
__webpack_require__.d(actions_namespaceObject, {
|
||||
"createErrorNotice": function() { return createErrorNotice; },
|
||||
"createInfoNotice": function() { return createInfoNotice; },
|
||||
"createNotice": function() { return createNotice; },
|
||||
"createSuccessNotice": function() { return createSuccessNotice; },
|
||||
"createWarningNotice": function() { return createWarningNotice; },
|
||||
"removeAllNotices": function() { return removeAllNotices; },
|
||||
"removeNotice": function() { return removeNotice; },
|
||||
"removeNotices": function() { return removeNotices; }
|
||||
createErrorNotice: function() { return createErrorNotice; },
|
||||
createInfoNotice: function() { return createInfoNotice; },
|
||||
createNotice: function() { return createNotice; },
|
||||
createSuccessNotice: function() { return createSuccessNotice; },
|
||||
createWarningNotice: function() { return createWarningNotice; },
|
||||
removeAllNotices: function() { return removeAllNotices; },
|
||||
removeNotice: function() { return removeNotice; },
|
||||
removeNotices: function() { return removeNotices; }
|
||||
});
|
||||
|
||||
// NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
|
||||
var selectors_namespaceObject = {};
|
||||
__webpack_require__.r(selectors_namespaceObject);
|
||||
__webpack_require__.d(selectors_namespaceObject, {
|
||||
"getNotices": function() { return getNotices; }
|
||||
getNotices: function() { return getNotices; }
|
||||
});
|
||||
|
||||
;// CONCATENATED MODULE: external ["wp","data"]
|
||||
@@ -78,20 +78,18 @@ const onSubKey = actionProperty => reducer => (state = {}, action) => {
|
||||
// Retrieve subkey from action. Do not track if undefined; useful for cases
|
||||
// where reducer is scoped by action shape.
|
||||
const key = action[actionProperty];
|
||||
|
||||
if (key === undefined) {
|
||||
return state;
|
||||
} // Avoid updating state if unchanged. Note that this also accounts for a
|
||||
// reducer which returns undefined on a key which is not yet tracked.
|
||||
|
||||
|
||||
const nextKeyState = reducer(state[key], action);
|
||||
|
||||
if (nextKeyState === state[key]) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return { ...state,
|
||||
// Avoid updating state if unchanged. Note that this also accounts for a
|
||||
// reducer which returns undefined on a key which is not yet tracked.
|
||||
const nextKeyState = reducer(state[key], action);
|
||||
if (nextKeyState === state[key]) {
|
||||
return state;
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
[key]: nextKeyState
|
||||
};
|
||||
};
|
||||
@@ -102,6 +100,7 @@ const onSubKey = actionProperty => reducer => (state = {}, action) => {
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Reducer returning the next notices state. The notices state is an object
|
||||
* where each key is a context, its value an array of notice objects.
|
||||
@@ -111,7 +110,6 @@ const onSubKey = actionProperty => reducer => (state = {}, action) => {
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
|
||||
const notices = on_sub_key('context')((state = [], action) => {
|
||||
switch (action.type) {
|
||||
case 'CREATE_NOTICE':
|
||||
@@ -119,23 +117,19 @@ const notices = on_sub_key('context')((state = [], action) => {
|
||||
return [...state.filter(({
|
||||
id
|
||||
}) => id !== action.notice.id), action.notice];
|
||||
|
||||
case 'REMOVE_NOTICE':
|
||||
return state.filter(({
|
||||
id
|
||||
}) => id !== action.id);
|
||||
|
||||
case 'REMOVE_NOTICES':
|
||||
return state.filter(({
|
||||
id
|
||||
}) => !action.ids.includes(id));
|
||||
|
||||
case 'REMOVE_ALL_NOTICES':
|
||||
return state.filter(({
|
||||
type
|
||||
}) => type !== action.noticeType);
|
||||
}
|
||||
|
||||
return state;
|
||||
});
|
||||
/* harmony default export */ var reducer = (notices);
|
||||
@@ -149,12 +143,12 @@ const notices = on_sub_key('context')((state = [], action) => {
|
||||
* @type {string}
|
||||
*/
|
||||
const DEFAULT_CONTEXT = 'global';
|
||||
|
||||
/**
|
||||
* Default notice status.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
|
||||
const DEFAULT_STATUS = 'info';
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
|
||||
@@ -162,6 +156,7 @@ const DEFAULT_STATUS = 'info';
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
|
||||
*
|
||||
@@ -170,10 +165,10 @@ const DEFAULT_STATUS = 'info';
|
||||
* browser navigation.
|
||||
* @property {?Function} onClick Optional function to invoke when action is
|
||||
* triggered by user.
|
||||
*
|
||||
*/
|
||||
|
||||
let uniqueId = 0;
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a notice is to be created.
|
||||
*
|
||||
@@ -225,7 +220,6 @@ let uniqueId = 0;
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
const {
|
||||
speak = true,
|
||||
@@ -238,10 +232,11 @@ function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
icon = null,
|
||||
explicitDismiss = false,
|
||||
onDismiss
|
||||
} = options; // The supported value shape of content is currently limited to plain text
|
||||
} = options;
|
||||
|
||||
// The supported value shape of content is currently limited to plain text
|
||||
// strings. To avoid setting expectation that e.g. a WPElement could be
|
||||
// supported, cast to a string.
|
||||
|
||||
content = String(content);
|
||||
return {
|
||||
type: 'CREATE_NOTICE',
|
||||
@@ -261,6 +256,7 @@ function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a success notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
@@ -296,10 +292,10 @@ function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function createSuccessNotice(content, options) {
|
||||
return createNotice('success', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that an info notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
@@ -334,10 +330,10 @@ function createSuccessNotice(content, options) {
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function createInfoNotice(content, options) {
|
||||
return createNotice('info', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that an error notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
@@ -375,10 +371,10 @@ function createInfoNotice(content, options) {
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function createErrorNotice(content, options) {
|
||||
return createNotice('error', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a warning notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
@@ -417,10 +413,10 @@ function createErrorNotice(content, options) {
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function createWarningNotice(content, options) {
|
||||
return createNotice('warning', content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a notice is to be removed.
|
||||
*
|
||||
@@ -462,7 +458,6 @@ function createWarningNotice(content, options) {
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function removeNotice(id, context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_NOTICE',
|
||||
@@ -470,6 +465,7 @@ function removeNotice(id, context = DEFAULT_CONTEXT) {
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all notices from a given context. Defaults to the default context.
|
||||
*
|
||||
@@ -516,7 +512,6 @@ function removeNotice(id, context = DEFAULT_CONTEXT) {
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_ALL_NOTICES',
|
||||
@@ -524,6 +519,7 @@ function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) {
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that several notices are to be removed.
|
||||
*
|
||||
@@ -562,7 +558,6 @@ function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) {
|
||||
* ```
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
|
||||
function removeNotices(ids, context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_NOTICES',
|
||||
@@ -576,6 +571,7 @@ function removeNotices(ids, context = DEFAULT_CONTEXT) {
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
|
||||
|
||||
/**
|
||||
@@ -587,8 +583,8 @@ function removeNotices(ids, context = DEFAULT_CONTEXT) {
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
|
||||
const DEFAULT_NOTICES = [];
|
||||
|
||||
/**
|
||||
* @typedef {Object} WPNotice Notice object.
|
||||
*
|
||||
@@ -612,7 +608,6 @@ const DEFAULT_NOTICES = [];
|
||||
* announced to screen readers. Defaults to
|
||||
* `true`.
|
||||
* @property {WPNoticeAction[]} actions User actions to present with notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -642,7 +637,6 @@ const DEFAULT_NOTICES = [];
|
||||
*
|
||||
* @return {WPNotice[]} Array of notices.
|
||||
*/
|
||||
|
||||
function getNotices(state, context = DEFAULT_CONTEXT) {
|
||||
return state[context] || DEFAULT_NOTICES;
|
||||
}
|
||||
@@ -652,6 +646,7 @@ function getNotices(state, context = DEFAULT_CONTEXT) {
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
@@ -664,7 +659,6 @@ function getNotices(state, context = DEFAULT_CONTEXT) {
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*/
|
||||
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)('core/notices', {
|
||||
reducer: reducer,
|
||||
actions: actions_namespaceObject,
|
||||
|
||||
Reference in New Issue
Block a user