@wordpress/notices
Advanced tools
Comparing version 4.7.0 to 4.8.0
@@ -5,2 +5,3 @@ /** | ||
import { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants'; | ||
/** | ||
@@ -14,6 +15,6 @@ * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice. | ||
* triggered by user. | ||
* | ||
*/ | ||
let uniqueId = 0; | ||
/** | ||
@@ -70,3 +71,2 @@ * Returns an action object used in signalling that a notice is to be created. | ||
*/ | ||
export function createNotice(status = DEFAULT_STATUS, content, options = {}) { | ||
@@ -84,6 +84,7 @@ const { | ||
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); | ||
@@ -108,2 +109,3 @@ return { | ||
} | ||
/** | ||
@@ -144,6 +146,6 @@ * Returns an action object used in signalling that a success notice is to be | ||
*/ | ||
export function createSuccessNotice(content, options) { | ||
return createNotice('success', content, options); | ||
} | ||
/** | ||
@@ -183,6 +185,6 @@ * Returns an action object used in signalling that an info notice is to be | ||
*/ | ||
export function createInfoNotice(content, options) { | ||
return createNotice('info', content, options); | ||
} | ||
/** | ||
@@ -225,6 +227,6 @@ * Returns an action object used in signalling that an error notice is to be | ||
*/ | ||
export function createErrorNotice(content, options) { | ||
return createNotice('error', content, options); | ||
} | ||
/** | ||
@@ -268,6 +270,6 @@ * Returns an action object used in signalling that a warning notice is to be | ||
*/ | ||
export function createWarningNotice(content, options) { | ||
return createNotice('warning', content, options); | ||
} | ||
/** | ||
@@ -314,3 +316,2 @@ * Returns an action object used in signalling that a notice is to be removed. | ||
*/ | ||
export function removeNotice(id, context = DEFAULT_CONTEXT) { | ||
@@ -323,2 +324,3 @@ return { | ||
} | ||
/** | ||
@@ -370,3 +372,2 @@ * Removes all notices from a given context. Defaults to the default context. | ||
*/ | ||
export function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) { | ||
@@ -379,2 +380,3 @@ return { | ||
} | ||
/** | ||
@@ -418,3 +420,2 @@ * Returns an action object used in signalling that several notices are to be removed. | ||
*/ | ||
export function removeNotices(ids, context = DEFAULT_CONTEXT) { | ||
@@ -421,0 +422,0 @@ return { |
@@ -9,2 +9,3 @@ /** | ||
export const DEFAULT_CONTEXT = 'global'; | ||
/** | ||
@@ -15,4 +16,3 @@ * Default notice status. | ||
*/ | ||
export const DEFAULT_STATUS = 'info'; | ||
//# sourceMappingURL=constants.js.map |
@@ -9,4 +9,3 @@ /** | ||
} | ||
}; | ||
//# sourceMappingURL=controls.js.map |
@@ -5,9 +5,10 @@ /** | ||
import { createReduxStore, register } from '@wordpress/data'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import reducer from './reducer'; | ||
import * as actions from './actions'; | ||
import * as selectors from './selectors'; | ||
/** | ||
@@ -18,3 +19,2 @@ * Store definition for the notices namespace. | ||
*/ | ||
export const store = createReduxStore('core/notices', { | ||
@@ -21,0 +21,0 @@ reducer, |
@@ -5,2 +5,3 @@ /** | ||
import onSubKey from './utils/on-sub-key'; | ||
/** | ||
@@ -15,3 +16,2 @@ * Reducer returning the next notices state. The notices state is an object | ||
*/ | ||
const notices = onSubKey('context')((state = [], action) => { | ||
@@ -24,3 +24,2 @@ switch (action.type) { | ||
}) => id !== action.notice.id), action.notice]; | ||
case 'REMOVE_NOTICE': | ||
@@ -30,3 +29,2 @@ return state.filter(({ | ||
}) => id !== action.id); | ||
case 'REMOVE_NOTICES': | ||
@@ -36,3 +34,2 @@ return state.filter(({ | ||
}) => !action.ids.includes(id)); | ||
case 'REMOVE_ALL_NOTICES': | ||
@@ -43,3 +40,2 @@ return state.filter(({ | ||
} | ||
return state; | ||
@@ -46,0 +42,0 @@ }); |
@@ -5,2 +5,3 @@ /** | ||
import { DEFAULT_CONTEXT } from './constants'; | ||
/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */ | ||
@@ -17,4 +18,4 @@ | ||
*/ | ||
const DEFAULT_NOTICES = []; | ||
const DEFAULT_NOTICES = []; | ||
/** | ||
@@ -43,3 +44,2 @@ * @typedef {Object} WPNotice Notice object. | ||
* @property {WPNoticeAction[]} actions User actions to present with notice. | ||
* | ||
*/ | ||
@@ -74,3 +74,2 @@ | ||
*/ | ||
export function getNotices(state, context = DEFAULT_CONTEXT) { | ||
@@ -77,0 +76,0 @@ return state[context] || DEFAULT_NOTICES; |
@@ -13,16 +13,14 @@ /** | ||
const key = action[actionProperty]; | ||
if (key === undefined) { | ||
return state; | ||
} // Avoid updating state if unchanged. Note that this also accounts for a | ||
} | ||
// 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, | ||
return { | ||
...state, | ||
[key]: nextKeyState | ||
@@ -29,0 +27,0 @@ }; |
@@ -7,4 +7,4 @@ /** | ||
export const store: import("@wordpress/data/build-types/types").StoreDescriptor<import("@wordpress/data/build-types/types").ReduxStoreConfig<any, typeof actions, typeof selectors>>; | ||
import * as actions from "./actions"; | ||
import * as selectors from "./selectors"; | ||
import * as actions from './actions'; | ||
import * as selectors from './selectors'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -24,3 +24,2 @@ /** | ||
* @property {WPNoticeAction[]} actions User actions to present with notice. | ||
* | ||
*/ | ||
@@ -27,0 +26,0 @@ /** |
@@ -12,4 +12,3 @@ "use strict"; | ||
}); | ||
var _store = require("./store"); | ||
//# sourceMappingURL=index.js.map |
@@ -14,5 +14,3 @@ "use strict"; | ||
exports.removeNotices = removeNotices; | ||
var _constants = require("./constants"); | ||
/** | ||
@@ -30,5 +28,6 @@ * Internal dependencies | ||
* triggered by user. | ||
* | ||
*/ | ||
let uniqueId = 0; | ||
/** | ||
@@ -85,3 +84,2 @@ * Returns an action object used in signalling that a notice is to be created. | ||
*/ | ||
function createNotice(status = _constants.DEFAULT_STATUS, content, options = {}) { | ||
@@ -99,6 +97,7 @@ const { | ||
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); | ||
@@ -123,2 +122,3 @@ return { | ||
} | ||
/** | ||
@@ -159,7 +159,6 @@ * Returns an action object used in signalling that a success notice is to be | ||
*/ | ||
function createSuccessNotice(content, options) { | ||
return createNotice('success', content, options); | ||
} | ||
/** | ||
@@ -199,7 +198,6 @@ * Returns an action object used in signalling that an info notice is to be | ||
*/ | ||
function createInfoNotice(content, options) { | ||
return createNotice('info', content, options); | ||
} | ||
/** | ||
@@ -242,7 +240,6 @@ * Returns an action object used in signalling that an error notice is to be | ||
*/ | ||
function createErrorNotice(content, options) { | ||
return createNotice('error', content, options); | ||
} | ||
/** | ||
@@ -286,7 +283,6 @@ * Returns an action object used in signalling that a warning notice is to be | ||
*/ | ||
function createWarningNotice(content, options) { | ||
return createNotice('warning', content, options); | ||
} | ||
/** | ||
@@ -333,4 +329,2 @@ * Returns an action object used in signalling that a notice is to be removed. | ||
*/ | ||
function removeNotice(id, context = _constants.DEFAULT_CONTEXT) { | ||
@@ -343,2 +337,3 @@ return { | ||
} | ||
/** | ||
@@ -390,4 +385,2 @@ * Removes all notices from a given context. Defaults to the default context. | ||
*/ | ||
function removeAllNotices(noticeType = 'default', context = _constants.DEFAULT_CONTEXT) { | ||
@@ -400,2 +393,3 @@ return { | ||
} | ||
/** | ||
@@ -439,4 +433,2 @@ * Returns an action object used in signalling that several notices are to be removed. | ||
*/ | ||
function removeNotices(ids, context = _constants.DEFAULT_CONTEXT) { | ||
@@ -443,0 +435,0 @@ return { |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.DEFAULT_STATUS = exports.DEFAULT_CONTEXT = void 0; | ||
/** | ||
@@ -17,2 +16,3 @@ * Default context to use for notice grouping when not otherwise specified. Its | ||
const DEFAULT_CONTEXT = 'global'; | ||
/** | ||
@@ -23,3 +23,2 @@ * Default notice status. | ||
*/ | ||
exports.DEFAULT_CONTEXT = DEFAULT_CONTEXT; | ||
@@ -26,0 +25,0 @@ const DEFAULT_STATUS = 'info'; |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var _a11y = require("@wordpress/a11y"); | ||
/** | ||
@@ -18,5 +16,4 @@ * WordPress dependencies | ||
} | ||
}; | ||
exports.default = _default; | ||
//# sourceMappingURL=controls.js.map |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,15 +8,8 @@ value: true | ||
exports.store = void 0; | ||
var _data = require("@wordpress/data"); | ||
var _reducer = _interopRequireDefault(require("./reducer")); | ||
var actions = _interopRequireWildcard(require("./actions")); | ||
var selectors = _interopRequireWildcard(require("./selectors")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
/** | ||
@@ -24,0 +16,0 @@ * WordPress dependencies |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,5 +8,3 @@ value: true | ||
exports.default = void 0; | ||
var _onSubKey = _interopRequireDefault(require("./utils/on-sub-key")); | ||
/** | ||
@@ -33,3 +30,2 @@ * Internal dependencies | ||
}) => id !== action.notice.id), action.notice]; | ||
case 'REMOVE_NOTICE': | ||
@@ -39,3 +35,2 @@ return state.filter(({ | ||
}) => id !== action.id); | ||
case 'REMOVE_NOTICES': | ||
@@ -45,3 +40,2 @@ return state.filter(({ | ||
}) => !action.ids.includes(id)); | ||
case 'REMOVE_ALL_NOTICES': | ||
@@ -52,3 +46,2 @@ return state.filter(({ | ||
} | ||
return state; | ||
@@ -55,0 +48,0 @@ }); |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.getNotices = getNotices; | ||
var _constants = require("./constants"); | ||
/** | ||
@@ -27,2 +25,3 @@ * Internal dependencies | ||
const DEFAULT_NOTICES = []; | ||
/** | ||
@@ -51,3 +50,2 @@ * @typedef {Object} WPNotice Notice object. | ||
* @property {WPNoticeAction[]} actions User actions to present with notice. | ||
* | ||
*/ | ||
@@ -82,3 +80,2 @@ | ||
*/ | ||
function getNotices(state, context = _constants.DEFAULT_CONTEXT) { | ||
@@ -85,0 +82,0 @@ return state[context] || DEFAULT_NOTICES; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.onSubKey = exports.default = void 0; | ||
/** | ||
@@ -21,20 +20,17 @@ * Higher-order reducer creator which creates a combined reducer object, keyed | ||
const key = action[actionProperty]; | ||
if (key === undefined) { | ||
return state; | ||
} // Avoid updating state if unchanged. Note that this also accounts for a | ||
} | ||
// 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, | ||
return { | ||
...state, | ||
[key]: nextKeyState | ||
}; | ||
}; | ||
exports.onSubKey = onSubKey; | ||
@@ -41,0 +37,0 @@ var _default = onSubKey; |
@@ -5,2 +5,4 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. --> | ||
## 4.8.0 (2023-08-16) | ||
## 4.7.0 (2023-08-10) | ||
@@ -7,0 +9,0 @@ |
{ | ||
"name": "@wordpress/notices", | ||
"version": "4.7.0", | ||
"version": "4.8.0", | ||
"description": "State management for notices.", | ||
@@ -30,9 +30,12 @@ "author": "The WordPress Contributors", | ||
"@babel/runtime": "^7.16.0", | ||
"@wordpress/a11y": "^3.39.0", | ||
"@wordpress/data": "^9.9.0" | ||
"@wordpress/a11y": "^3.40.0", | ||
"@wordpress/data": "^9.10.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "b898cf1dc8e70841d1647ea0994ac6278acc18a7" | ||
"gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6" | ||
} |
@@ -14,3 +14,2 @@ /** | ||
* triggered by user. | ||
* | ||
*/ | ||
@@ -17,0 +16,0 @@ |
@@ -42,3 +42,2 @@ /** | ||
* @property {WPNoticeAction[]} actions User actions to present with notice. | ||
* | ||
*/ | ||
@@ -45,0 +44,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212081
4
2845
Updated@wordpress/a11y@^3.40.0
Updated@wordpress/data@^9.10.0