@wordpress/notices 3.2.6 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.3.0 (2022-01-27)
6
+
5
7
  ## 3.2.0 (2021-07-21)
6
8
 
7
9
  ## 3.1.0 (2021-05-20)
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2021 by the contributors
3
+ Copyright 2016-2022 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.createErrorNotice = createErrorNotice;
7
+ exports.createInfoNotice = createInfoNotice;
6
8
  exports.createNotice = createNotice;
7
9
  exports.createSuccessNotice = createSuccessNotice;
8
- exports.createInfoNotice = createInfoNotice;
9
- exports.createErrorNotice = createErrorNotice;
10
10
  exports.createWarningNotice = createWarningNotice;
11
11
  exports.removeNotice = removeNotice;
12
12
 
@@ -63,7 +63,10 @@ var _constants = require("./constants");
63
63
  *
64
64
  * @return {Object} Action object.
65
65
  */
66
- function createNotice(status = _constants.DEFAULT_STATUS, content, options = {}) {
66
+ function createNotice() {
67
+ let status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.DEFAULT_STATUS;
68
+ let content = arguments.length > 1 ? arguments[1] : undefined;
69
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
67
70
  const {
68
71
  speak = true,
69
72
  isDismissible = true,
@@ -173,7 +176,8 @@ function createWarningNotice(content, options) {
173
176
  */
174
177
 
175
178
 
176
- function removeNotice(id, context = _constants.DEFAULT_CONTEXT) {
179
+ function removeNotice(id) {
180
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.DEFAULT_CONTEXT;
177
181
  return {
178
182
  type: 'REMOVE_NOTICE',
179
183
  id,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/actions.js"],"names":["createNotice","status","DEFAULT_STATUS","content","options","speak","isDismissible","context","DEFAULT_CONTEXT","id","actions","type","__unstableHTML","icon","explicitDismiss","onDismiss","String","notice","spokenMessage","createSuccessNotice","createInfoNotice","createErrorNotice","createWarningNotice","removeNotice"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CAAuBC,MAAM,GAAGC,yBAAhC,EAAgDC,OAAhD,EAAyDC,OAAO,GAAG,EAAnE,EAAwE;AAC9E,QAAM;AACLC,IAAAA,KAAK,GAAG,IADH;AAELC,IAAAA,aAAa,GAAG,IAFX;AAGLC,IAAAA,OAAO,GAAGC,0BAHL;AAILC,IAAAA,EAAE,GAAG,sBAAUF,OAAV,CAJA;AAKLG,IAAAA,OAAO,GAAG,EALL;AAMLC,IAAAA,IAAI,GAAG,SANF;AAOLC,IAAAA,cAPK;AAQLC,IAAAA,IAAI,GAAG,IARF;AASLC,IAAAA,eAAe,GAAG,KATb;AAULC,IAAAA;AAVK,MAWFX,OAXJ,CAD8E,CAc9E;AACA;AACA;;AACAD,EAAAA,OAAO,GAAGa,MAAM,CAAEb,OAAF,CAAhB;AAEA,SAAO;AACNQ,IAAAA,IAAI,EAAE,eADA;AAENJ,IAAAA,OAFM;AAGNU,IAAAA,MAAM,EAAE;AACPR,MAAAA,EADO;AAEPR,MAAAA,MAFO;AAGPE,MAAAA,OAHO;AAIPe,MAAAA,aAAa,EAAEb,KAAK,GAAGF,OAAH,GAAa,IAJ1B;AAKPS,MAAAA,cALO;AAMPN,MAAAA,aANO;AAOPI,MAAAA,OAPO;AAQPC,MAAAA,IARO;AASPE,MAAAA,IATO;AAUPC,MAAAA,eAVO;AAWPC,MAAAA;AAXO;AAHF,GAAP;AAiBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,mBAAT,CAA8BhB,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOJ,YAAY,CAAE,SAAF,EAAaG,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASgB,gBAAT,CAA2BjB,OAA3B,EAAoCC,OAApC,EAA8C;AACpD,SAAOJ,YAAY,CAAE,MAAF,EAAUG,OAAV,EAAmBC,OAAnB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASiB,iBAAT,CAA4BlB,OAA5B,EAAqCC,OAArC,EAA+C;AACrD,SAAOJ,YAAY,CAAE,OAAF,EAAWG,OAAX,EAAoBC,OAApB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASkB,mBAAT,CAA8BnB,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOJ,YAAY,CAAE,SAAF,EAAaG,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASmB,YAAT,CAAuBd,EAAvB,EAA2BF,OAAO,GAAGC,0BAArC,EAAuD;AAC7D,SAAO;AACNG,IAAAA,IAAI,EAAE,eADA;AAENF,IAAAA,EAFM;AAGNF,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniqueId } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';\n\n/**\n * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.\n *\n * @property {string} label Message to use as action label.\n * @property {?string} url Optional URL of resource if action incurs\n * browser navigation.\n * @property {?Function} onClick Optional function to invoke when action is\n * triggered by user.\n *\n */\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param {string} [status='info'] Notice status.\n * @param {string} content Notice message.\n * @param {Object} [options] Notice options.\n * @param {string} [options.context='global'] Context under which to\n * group notice.\n * @param {string} [options.id] Identifier for notice.\n * Automatically assigned\n * if not specified.\n * @param {boolean} [options.isDismissible=true] Whether the notice can\n * be dismissed by user.\n * @param {string} [options.type='default'] Type of notice, one of\n * `default`, or `snackbar`.\n * @param {boolean} [options.speak=true] Whether the notice\n * content should be\n * announced to screen\n * readers.\n * @param {Array<WPNoticeAction>} [options.actions] User actions to be\n * presented with notice.\n * @param {Object} [options.icon] An icon displayed with the notice.\n * @param {boolean} [options.explicitDismiss] Whether the notice includes\n * an explict dismiss button and\n * can't be dismissed by clicking\n * the body of the notice.\n * @param {Function} [options.onDismiss] Called when the notice is dismissed.\n *\n * @return {Object} Action object.\n */\nexport function createNotice( status = DEFAULT_STATUS, content, options = {} ) {\n\tconst {\n\t\tspeak = true,\n\t\tisDismissible = true,\n\t\tcontext = DEFAULT_CONTEXT,\n\t\tid = uniqueId( context ),\n\t\tactions = [],\n\t\ttype = 'default',\n\t\t__unstableHTML,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\tonDismiss,\n\t} = options;\n\n\t// The supported value shape of content is currently limited to plain text\n\t// strings. To avoid setting expectation that e.g. a WPElement could be\n\t// supported, cast to a string.\n\tcontent = String( content );\n\n\treturn {\n\t\ttype: 'CREATE_NOTICE',\n\t\tcontext,\n\t\tnotice: {\n\t\t\tid,\n\t\t\tstatus,\n\t\t\tcontent,\n\t\t\tspokenMessage: speak ? content : null,\n\t\t\t__unstableHTML,\n\t\t\tisDismissible,\n\t\t\tactions,\n\t\t\ttype,\n\t\t\ticon,\n\t\t\texplicitDismiss,\n\t\t\tonDismiss,\n\t\t},\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a success notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createSuccessNotice( content, options ) {\n\treturn createNotice( 'success', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an info notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createInfoNotice( content, options ) {\n\treturn createNotice( 'info', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an error notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createErrorNotice( content, options ) {\n\treturn createNotice( 'error', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a warning notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createWarningNotice( content, options ) {\n\treturn createNotice( 'warning', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a notice is to be removed.\n *\n * @param {string} id Notice unique identifier.\n * @param {string} [context='global'] Optional context (grouping) in which the notice is\n * intended to appear. Defaults to default context.\n *\n * @return {Object} Action object.\n */\nexport function removeNotice( id, context = DEFAULT_CONTEXT ) {\n\treturn {\n\t\ttype: 'REMOVE_NOTICE',\n\t\tid,\n\t\tcontext,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/actions.js"],"names":["createNotice","status","DEFAULT_STATUS","content","options","speak","isDismissible","context","DEFAULT_CONTEXT","id","actions","type","__unstableHTML","icon","explicitDismiss","onDismiss","String","notice","spokenMessage","createSuccessNotice","createInfoNotice","createErrorNotice","createWarningNotice","removeNotice"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,GAAwE;AAAA,MAAjDC,MAAiD,uEAAxCC,yBAAwC;AAAA,MAAxBC,OAAwB;AAAA,MAAfC,OAAe,uEAAL,EAAK;AAC9E,QAAM;AACLC,IAAAA,KAAK,GAAG,IADH;AAELC,IAAAA,aAAa,GAAG,IAFX;AAGLC,IAAAA,OAAO,GAAGC,0BAHL;AAILC,IAAAA,EAAE,GAAG,sBAAUF,OAAV,CAJA;AAKLG,IAAAA,OAAO,GAAG,EALL;AAMLC,IAAAA,IAAI,GAAG,SANF;AAOLC,IAAAA,cAPK;AAQLC,IAAAA,IAAI,GAAG,IARF;AASLC,IAAAA,eAAe,GAAG,KATb;AAULC,IAAAA;AAVK,MAWFX,OAXJ,CAD8E,CAc9E;AACA;AACA;;AACAD,EAAAA,OAAO,GAAGa,MAAM,CAAEb,OAAF,CAAhB;AAEA,SAAO;AACNQ,IAAAA,IAAI,EAAE,eADA;AAENJ,IAAAA,OAFM;AAGNU,IAAAA,MAAM,EAAE;AACPR,MAAAA,EADO;AAEPR,MAAAA,MAFO;AAGPE,MAAAA,OAHO;AAIPe,MAAAA,aAAa,EAAEb,KAAK,GAAGF,OAAH,GAAa,IAJ1B;AAKPS,MAAAA,cALO;AAMPN,MAAAA,aANO;AAOPI,MAAAA,OAPO;AAQPC,MAAAA,IARO;AASPE,MAAAA,IATO;AAUPC,MAAAA,eAVO;AAWPC,MAAAA;AAXO;AAHF,GAAP;AAiBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,mBAAT,CAA8BhB,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOJ,YAAY,CAAE,SAAF,EAAaG,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASgB,gBAAT,CAA2BjB,OAA3B,EAAoCC,OAApC,EAA8C;AACpD,SAAOJ,YAAY,CAAE,MAAF,EAAUG,OAAV,EAAmBC,OAAnB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASiB,iBAAT,CAA4BlB,OAA5B,EAAqCC,OAArC,EAA+C;AACrD,SAAOJ,YAAY,CAAE,OAAF,EAAWG,OAAX,EAAoBC,OAApB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASkB,mBAAT,CAA8BnB,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOJ,YAAY,CAAE,SAAF,EAAaG,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASmB,YAAT,CAAuBd,EAAvB,EAAuD;AAAA,MAA5BF,OAA4B,uEAAlBC,0BAAkB;AAC7D,SAAO;AACNG,IAAAA,IAAI,EAAE,eADA;AAENF,IAAAA,EAFM;AAGNF,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniqueId } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';\n\n/**\n * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.\n *\n * @property {string} label Message to use as action label.\n * @property {?string} url Optional URL of resource if action incurs\n * browser navigation.\n * @property {?Function} onClick Optional function to invoke when action is\n * triggered by user.\n *\n */\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param {string} [status='info'] Notice status.\n * @param {string} content Notice message.\n * @param {Object} [options] Notice options.\n * @param {string} [options.context='global'] Context under which to\n * group notice.\n * @param {string} [options.id] Identifier for notice.\n * Automatically assigned\n * if not specified.\n * @param {boolean} [options.isDismissible=true] Whether the notice can\n * be dismissed by user.\n * @param {string} [options.type='default'] Type of notice, one of\n * `default`, or `snackbar`.\n * @param {boolean} [options.speak=true] Whether the notice\n * content should be\n * announced to screen\n * readers.\n * @param {Array<WPNoticeAction>} [options.actions] User actions to be\n * presented with notice.\n * @param {Object} [options.icon] An icon displayed with the notice.\n * @param {boolean} [options.explicitDismiss] Whether the notice includes\n * an explict dismiss button and\n * can't be dismissed by clicking\n * the body of the notice.\n * @param {Function} [options.onDismiss] Called when the notice is dismissed.\n *\n * @return {Object} Action object.\n */\nexport function createNotice( status = DEFAULT_STATUS, content, options = {} ) {\n\tconst {\n\t\tspeak = true,\n\t\tisDismissible = true,\n\t\tcontext = DEFAULT_CONTEXT,\n\t\tid = uniqueId( context ),\n\t\tactions = [],\n\t\ttype = 'default',\n\t\t__unstableHTML,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\tonDismiss,\n\t} = options;\n\n\t// The supported value shape of content is currently limited to plain text\n\t// strings. To avoid setting expectation that e.g. a WPElement could be\n\t// supported, cast to a string.\n\tcontent = String( content );\n\n\treturn {\n\t\ttype: 'CREATE_NOTICE',\n\t\tcontext,\n\t\tnotice: {\n\t\t\tid,\n\t\t\tstatus,\n\t\t\tcontent,\n\t\t\tspokenMessage: speak ? content : null,\n\t\t\t__unstableHTML,\n\t\t\tisDismissible,\n\t\t\tactions,\n\t\t\ttype,\n\t\t\ticon,\n\t\t\texplicitDismiss,\n\t\t\tonDismiss,\n\t\t},\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a success notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createSuccessNotice( content, options ) {\n\treturn createNotice( 'success', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an info notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createInfoNotice( content, options ) {\n\treturn createNotice( 'info', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an error notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createErrorNotice( content, options ) {\n\treturn createNotice( 'error', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a warning notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createWarningNotice( content, options ) {\n\treturn createNotice( 'warning', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a notice is to be removed.\n *\n * @param {string} id Notice unique identifier.\n * @param {string} [context='global'] Optional context (grouping) in which the notice is\n * intended to appear. Defaults to default context.\n *\n * @return {Object} Action object.\n */\nexport function removeNotice( id, context = DEFAULT_CONTEXT ) {\n\treturn {\n\t\ttype: 'REMOVE_NOTICE',\n\t\tid,\n\t\tcontext,\n\t};\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
@@ -17,6 +15,10 @@ var actions = _interopRequireWildcard(require("./actions"));
17
15
 
18
16
  var selectors = _interopRequireWildcard(require("./selectors"));
19
17
 
18
+ 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); }
19
+
20
+ 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; }
21
+
20
22
  /**
21
23
  * WordPress dependencies
22
24
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/index.js"],"names":["store","reducer","actions","selectors"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,4BAAkB,cAAlB,EAAkC;AACtDC,EAAAA,OAAO,EAAPA,gBADsD;AAEtDC,EAAAA,OAFsD;AAGtDC,EAAAA;AAHsD,CAAlC,CAAd;;AAMP,oBAAUH,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\n/**\n * Store definition for the notices namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( 'core/notices', {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/index.js"],"names":["store","reducer","actions","selectors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,4BAAkB,cAAlB,EAAkC;AACtDC,EAAAA,OAAO,EAAPA,gBADsD;AAEtDC,EAAAA,OAFsD;AAGtDC,EAAAA;AAHsD,CAAlC,CAAd;;AAMP,oBAAUH,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\n/**\n * Store definition for the notices namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( 'core/notices', {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"]}
@@ -28,7 +28,10 @@ var _onSubKey = _interopRequireDefault(require("./utils/on-sub-key"));
28
28
  *
29
29
  * @return {Object} Updated state.
30
30
  */
31
- const notices = (0, _onSubKey.default)('context')((state = [], action) => {
31
+ const notices = (0, _onSubKey.default)('context')(function () {
32
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
33
+ let action = arguments.length > 1 ? arguments[1] : undefined;
34
+
32
35
  switch (action.type) {
33
36
  case 'CREATE_NOTICE':
34
37
  // Avoid duplicates on ID.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/reducer.js"],"names":["notices","state","action","type","id","notice"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAO,GAAG,uBAAU,SAAV,EAAuB,CAAEC,KAAK,GAAG,EAAV,EAAcC,MAAd,KAA0B;AAChE,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC;AACA,aAAO,CACN,GAAG,oBAAQF,KAAR,EAAe;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACG,MAAP,CAAcD;AAApB,OAAf,CADG,EAENF,MAAM,CAACG,MAFD,CAAP;;AAKD,SAAK,eAAL;AACC,aAAO,oBAAQJ,KAAR,EAAe;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACE;AAAb,OAAf,CAAP;AATF;;AAYA,SAAOH,KAAP;AACA,CAde,CAAhB;eAgBeD,O","sourcesContent":["/**\n * External dependencies\n */\nimport { reject } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport onSubKey from './utils/on-sub-key';\n\n/**\n * Reducer returning the next notices state. The notices state is an object\n * where each key is a context, its value an array of notice objects.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nconst notices = onSubKey( 'context' )( ( state = [], action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'CREATE_NOTICE':\n\t\t\t// Avoid duplicates on ID.\n\t\t\treturn [\n\t\t\t\t...reject( state, { id: action.notice.id } ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn reject( state, { id: action.id } );\n\t}\n\n\treturn state;\n} );\n\nexport default notices;\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/reducer.js"],"names":["notices","state","action","type","id","notice"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAO,GAAG,uBAAU,SAAV,EAAuB,YAA0B;AAAA,MAAxBC,KAAwB,uEAAhB,EAAgB;AAAA,MAAZC,MAAY;;AAChE,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC;AACA,aAAO,CACN,GAAG,oBAAQF,KAAR,EAAe;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACG,MAAP,CAAcD;AAApB,OAAf,CADG,EAENF,MAAM,CAACG,MAFD,CAAP;;AAKD,SAAK,eAAL;AACC,aAAO,oBAAQJ,KAAR,EAAe;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACE;AAAb,OAAf,CAAP;AATF;;AAYA,SAAOH,KAAP;AACA,CAde,CAAhB;eAgBeD,O","sourcesContent":["/**\n * External dependencies\n */\nimport { reject } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport onSubKey from './utils/on-sub-key';\n\n/**\n * Reducer returning the next notices state. The notices state is an object\n * where each key is a context, its value an array of notice objects.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nconst notices = onSubKey( 'context' )( ( state = [], action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'CREATE_NOTICE':\n\t\t\t// Avoid duplicates on ID.\n\t\t\treturn [\n\t\t\t\t...reject( state, { id: action.notice.id } ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn reject( state, { id: action.id } );\n\t}\n\n\treturn state;\n} );\n\nexport default notices;\n"]}
@@ -59,7 +59,8 @@ const DEFAULT_NOTICES = [];
59
59
  * @return {WPNotice[]} Array of notices.
60
60
  */
61
61
 
62
- function getNotices(state, context = _constants.DEFAULT_CONTEXT) {
62
+ function getNotices(state) {
63
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.DEFAULT_CONTEXT;
63
64
  return state[context] || DEFAULT_NOTICES;
64
65
  }
65
66
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/selectors.js"],"names":["DEFAULT_NOTICES","getNotices","state","context","DEFAULT_CONTEXT"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,EAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,UAAT,CAAqBC,KAArB,EAA4BC,OAAO,GAAGC,0BAAtC,EAAwD;AAC9D,SAAOF,KAAK,CAAEC,OAAF,CAAL,IAAoBH,eAA3B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT } from './constants';\n\n/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */\n\n/**\n * The default empty set of notices to return when there are no notices\n * assigned for a given notices context. This can occur if the getNotices\n * selector is called without a notice ever having been created for the\n * context. A shared value is used to ensure referential equality between\n * sequential selector calls, since otherwise `[] !== []`.\n *\n * @type {Array}\n */\nconst DEFAULT_NOTICES = [];\n\n/**\n * @typedef {Object} WPNotice Notice object.\n *\n * @property {string} id Unique identifier of notice.\n * @property {string} status Status of notice, one of `success`,\n * `info`, `error`, or `warning`. Defaults\n * to `info`.\n * @property {string} content Notice message.\n * @property {string} spokenMessage Audibly announced message text used by\n * assistive technologies.\n * @property {string} __unstableHTML Notice message as raw HTML. Intended to\n * serve primarily for compatibility of\n * server-rendered notices, and SHOULD NOT\n * be used for notices. It is subject to\n * removal without notice.\n * @property {boolean} isDismissible Whether the notice can be dismissed by\n * user. Defaults to `true`.\n * @property {string} type Type of notice, one of `default`,\n * or `snackbar`. Defaults to `default`.\n * @property {boolean} speak Whether the notice content should be\n * announced to screen readers. Defaults to\n * `true`.\n * @property {WPNoticeAction[]} actions User actions to present with notice.\n *\n */\n\n/**\n * Returns all notices as an array, optionally for a given context. Defaults to\n * the global context.\n *\n * @param {Object} state Notices state.\n * @param {?string} context Optional grouping context.\n *\n * @return {WPNotice[]} Array of notices.\n */\nexport function getNotices( state, context = DEFAULT_CONTEXT ) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/selectors.js"],"names":["DEFAULT_NOTICES","getNotices","state","context","DEFAULT_CONTEXT"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,EAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,UAAT,CAAqBC,KAArB,EAAwD;AAAA,MAA5BC,OAA4B,uEAAlBC,0BAAkB;AAC9D,SAAOF,KAAK,CAAEC,OAAF,CAAL,IAAoBH,eAA3B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT } from './constants';\n\n/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */\n\n/**\n * The default empty set of notices to return when there are no notices\n * assigned for a given notices context. This can occur if the getNotices\n * selector is called without a notice ever having been created for the\n * context. A shared value is used to ensure referential equality between\n * sequential selector calls, since otherwise `[] !== []`.\n *\n * @type {Array}\n */\nconst DEFAULT_NOTICES = [];\n\n/**\n * @typedef {Object} WPNotice Notice object.\n *\n * @property {string} id Unique identifier of notice.\n * @property {string} status Status of notice, one of `success`,\n * `info`, `error`, or `warning`. Defaults\n * to `info`.\n * @property {string} content Notice message.\n * @property {string} spokenMessage Audibly announced message text used by\n * assistive technologies.\n * @property {string} __unstableHTML Notice message as raw HTML. Intended to\n * serve primarily for compatibility of\n * server-rendered notices, and SHOULD NOT\n * be used for notices. It is subject to\n * removal without notice.\n * @property {boolean} isDismissible Whether the notice can be dismissed by\n * user. Defaults to `true`.\n * @property {string} type Type of notice, one of `default`,\n * or `snackbar`. Defaults to `default`.\n * @property {boolean} speak Whether the notice content should be\n * announced to screen readers. Defaults to\n * `true`.\n * @property {WPNoticeAction[]} actions User actions to present with notice.\n *\n */\n\n/**\n * Returns all notices as an array, optionally for a given context. Defaults to\n * the global context.\n *\n * @param {Object} state Notices state.\n * @param {?string} context Optional grouping context.\n *\n * @return {WPNotice[]} Array of notices.\n */\nexport function getNotices( state, context = DEFAULT_CONTEXT ) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.onSubKey = void 0;
6
+ exports.onSubKey = exports.default = void 0;
7
7
 
8
8
  /**
9
9
  * Higher-order reducer creator which creates a combined reducer object, keyed
@@ -13,7 +13,9 @@ exports.default = exports.onSubKey = void 0;
13
13
  *
14
14
  * @return {Function} Higher-order reducer.
15
15
  */
16
- const onSubKey = actionProperty => reducer => (state = {}, action) => {
16
+ const onSubKey = actionProperty => reducer => function () {
17
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
+ let action = arguments.length > 1 ? arguments[1] : undefined;
17
19
  // Retrieve subkey from action. Do not track if undefined; useful for cases
18
20
  // where reducer is scoped by action shape.
19
21
  const key = action[actionProperty];
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/utils/on-sub-key.js"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAKC,cAAF,IAAwBC,OAAF,IAAe,CAC5DC,KAAK,GAAG,EADoD,EAE5DC,MAF4D,KAGxD;AACJ;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANG,CAQJ;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CAtBM;;;eAwBQP,Q","sourcesContent":["/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {Function} Higher-order reducer.\n */\nexport const onSubKey = ( actionProperty ) => ( reducer ) => (\n\tstate = {},\n\taction\n) => {\n\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t// where reducer is scoped by action shape.\n\tconst key = action[ actionProperty ];\n\tif ( key === undefined ) {\n\t\treturn state;\n\t}\n\n\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t// reducer which returns undefined on a key which is not yet tracked.\n\tconst nextKeyState = reducer( state[ key ], action );\n\tif ( nextKeyState === state[ key ] ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ key ]: nextKeyState,\n\t};\n};\n\nexport default onSubKey;\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/utils/on-sub-key.js"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAKC,cAAF,IAAwBC,OAAF,IAAe,YAGxD;AAAA,MAFJC,KAEI,uEAFI,EAEJ;AAAA,MADJC,MACI;AACJ;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANG,CAQJ;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CAtBM;;;eAwBQP,Q","sourcesContent":["/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {Function} Higher-order reducer.\n */\nexport const onSubKey = ( actionProperty ) => ( reducer ) => (\n\tstate = {},\n\taction\n) => {\n\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t// where reducer is scoped by action shape.\n\tconst key = action[ actionProperty ];\n\tif ( key === undefined ) {\n\t\treturn state;\n\t}\n\n\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t// reducer which returns undefined on a key which is not yet tracked.\n\tconst nextKeyState = reducer( state[ key ], action );\n\tif ( nextKeyState === state[ key ] ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ key ]: nextKeyState,\n\t};\n};\n\nexport default onSubKey;\n"]}
@@ -49,7 +49,10 @@ import { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';
49
49
  * @return {Object} Action object.
50
50
  */
51
51
 
52
- export function createNotice(status = DEFAULT_STATUS, content, options = {}) {
52
+ export function createNotice() {
53
+ let status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATUS;
54
+ let content = arguments.length > 1 ? arguments[1] : undefined;
55
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
53
56
  const {
54
57
  speak = true,
55
58
  isDismissible = true,
@@ -154,7 +157,8 @@ export function createWarningNotice(content, options) {
154
157
  * @return {Object} Action object.
155
158
  */
156
159
 
157
- export function removeNotice(id, context = DEFAULT_CONTEXT) {
160
+ export function removeNotice(id) {
161
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
158
162
  return {
159
163
  type: 'REMOVE_NOTICE',
160
164
  id,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/actions.js"],"names":["uniqueId","DEFAULT_CONTEXT","DEFAULT_STATUS","createNotice","status","content","options","speak","isDismissible","context","id","actions","type","__unstableHTML","icon","explicitDismiss","onDismiss","String","notice","spokenMessage","createSuccessNotice","createInfoNotice","createErrorNotice","createWarningNotice","removeNotice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,cAA1B,QAAgD,aAAhD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,MAAM,GAAGF,cAAhC,EAAgDG,OAAhD,EAAyDC,OAAO,GAAG,EAAnE,EAAwE;AAC9E,QAAM;AACLC,IAAAA,KAAK,GAAG,IADH;AAELC,IAAAA,aAAa,GAAG,IAFX;AAGLC,IAAAA,OAAO,GAAGR,eAHL;AAILS,IAAAA,EAAE,GAAGV,QAAQ,CAAES,OAAF,CAJR;AAKLE,IAAAA,OAAO,GAAG,EALL;AAMLC,IAAAA,IAAI,GAAG,SANF;AAOLC,IAAAA,cAPK;AAQLC,IAAAA,IAAI,GAAG,IARF;AASLC,IAAAA,eAAe,GAAG,KATb;AAULC,IAAAA;AAVK,MAWFV,OAXJ,CAD8E,CAc9E;AACA;AACA;;AACAD,EAAAA,OAAO,GAAGY,MAAM,CAAEZ,OAAF,CAAhB;AAEA,SAAO;AACNO,IAAAA,IAAI,EAAE,eADA;AAENH,IAAAA,OAFM;AAGNS,IAAAA,MAAM,EAAE;AACPR,MAAAA,EADO;AAEPN,MAAAA,MAFO;AAGPC,MAAAA,OAHO;AAIPc,MAAAA,aAAa,EAAEZ,KAAK,GAAGF,OAAH,GAAa,IAJ1B;AAKPQ,MAAAA,cALO;AAMPL,MAAAA,aANO;AAOPG,MAAAA,OAPO;AAQPC,MAAAA,IARO;AASPE,MAAAA,IATO;AAUPC,MAAAA,eAVO;AAWPC,MAAAA;AAXO;AAHF,GAAP;AAiBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,mBAAT,CAA8Bf,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOH,YAAY,CAAE,SAAF,EAAaE,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASe,gBAAT,CAA2BhB,OAA3B,EAAoCC,OAApC,EAA8C;AACpD,SAAOH,YAAY,CAAE,MAAF,EAAUE,OAAV,EAAmBC,OAAnB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASgB,iBAAT,CAA4BjB,OAA5B,EAAqCC,OAArC,EAA+C;AACrD,SAAOH,YAAY,CAAE,OAAF,EAAWE,OAAX,EAAoBC,OAApB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASiB,mBAAT,CAA8BlB,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOH,YAAY,CAAE,SAAF,EAAaE,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASkB,YAAT,CAAuBd,EAAvB,EAA2BD,OAAO,GAAGR,eAArC,EAAuD;AAC7D,SAAO;AACNW,IAAAA,IAAI,EAAE,eADA;AAENF,IAAAA,EAFM;AAGND,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniqueId } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';\n\n/**\n * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.\n *\n * @property {string} label Message to use as action label.\n * @property {?string} url Optional URL of resource if action incurs\n * browser navigation.\n * @property {?Function} onClick Optional function to invoke when action is\n * triggered by user.\n *\n */\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param {string} [status='info'] Notice status.\n * @param {string} content Notice message.\n * @param {Object} [options] Notice options.\n * @param {string} [options.context='global'] Context under which to\n * group notice.\n * @param {string} [options.id] Identifier for notice.\n * Automatically assigned\n * if not specified.\n * @param {boolean} [options.isDismissible=true] Whether the notice can\n * be dismissed by user.\n * @param {string} [options.type='default'] Type of notice, one of\n * `default`, or `snackbar`.\n * @param {boolean} [options.speak=true] Whether the notice\n * content should be\n * announced to screen\n * readers.\n * @param {Array<WPNoticeAction>} [options.actions] User actions to be\n * presented with notice.\n * @param {Object} [options.icon] An icon displayed with the notice.\n * @param {boolean} [options.explicitDismiss] Whether the notice includes\n * an explict dismiss button and\n * can't be dismissed by clicking\n * the body of the notice.\n * @param {Function} [options.onDismiss] Called when the notice is dismissed.\n *\n * @return {Object} Action object.\n */\nexport function createNotice( status = DEFAULT_STATUS, content, options = {} ) {\n\tconst {\n\t\tspeak = true,\n\t\tisDismissible = true,\n\t\tcontext = DEFAULT_CONTEXT,\n\t\tid = uniqueId( context ),\n\t\tactions = [],\n\t\ttype = 'default',\n\t\t__unstableHTML,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\tonDismiss,\n\t} = options;\n\n\t// The supported value shape of content is currently limited to plain text\n\t// strings. To avoid setting expectation that e.g. a WPElement could be\n\t// supported, cast to a string.\n\tcontent = String( content );\n\n\treturn {\n\t\ttype: 'CREATE_NOTICE',\n\t\tcontext,\n\t\tnotice: {\n\t\t\tid,\n\t\t\tstatus,\n\t\t\tcontent,\n\t\t\tspokenMessage: speak ? content : null,\n\t\t\t__unstableHTML,\n\t\t\tisDismissible,\n\t\t\tactions,\n\t\t\ttype,\n\t\t\ticon,\n\t\t\texplicitDismiss,\n\t\t\tonDismiss,\n\t\t},\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a success notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createSuccessNotice( content, options ) {\n\treturn createNotice( 'success', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an info notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createInfoNotice( content, options ) {\n\treturn createNotice( 'info', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an error notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createErrorNotice( content, options ) {\n\treturn createNotice( 'error', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a warning notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createWarningNotice( content, options ) {\n\treturn createNotice( 'warning', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a notice is to be removed.\n *\n * @param {string} id Notice unique identifier.\n * @param {string} [context='global'] Optional context (grouping) in which the notice is\n * intended to appear. Defaults to default context.\n *\n * @return {Object} Action object.\n */\nexport function removeNotice( id, context = DEFAULT_CONTEXT ) {\n\treturn {\n\t\ttype: 'REMOVE_NOTICE',\n\t\tid,\n\t\tcontext,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/actions.js"],"names":["uniqueId","DEFAULT_CONTEXT","DEFAULT_STATUS","createNotice","status","content","options","speak","isDismissible","context","id","actions","type","__unstableHTML","icon","explicitDismiss","onDismiss","String","notice","spokenMessage","createSuccessNotice","createInfoNotice","createErrorNotice","createWarningNotice","removeNotice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,cAA1B,QAAgD,aAAhD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,GAAwE;AAAA,MAAjDC,MAAiD,uEAAxCF,cAAwC;AAAA,MAAxBG,OAAwB;AAAA,MAAfC,OAAe,uEAAL,EAAK;AAC9E,QAAM;AACLC,IAAAA,KAAK,GAAG,IADH;AAELC,IAAAA,aAAa,GAAG,IAFX;AAGLC,IAAAA,OAAO,GAAGR,eAHL;AAILS,IAAAA,EAAE,GAAGV,QAAQ,CAAES,OAAF,CAJR;AAKLE,IAAAA,OAAO,GAAG,EALL;AAMLC,IAAAA,IAAI,GAAG,SANF;AAOLC,IAAAA,cAPK;AAQLC,IAAAA,IAAI,GAAG,IARF;AASLC,IAAAA,eAAe,GAAG,KATb;AAULC,IAAAA;AAVK,MAWFV,OAXJ,CAD8E,CAc9E;AACA;AACA;;AACAD,EAAAA,OAAO,GAAGY,MAAM,CAAEZ,OAAF,CAAhB;AAEA,SAAO;AACNO,IAAAA,IAAI,EAAE,eADA;AAENH,IAAAA,OAFM;AAGNS,IAAAA,MAAM,EAAE;AACPR,MAAAA,EADO;AAEPN,MAAAA,MAFO;AAGPC,MAAAA,OAHO;AAIPc,MAAAA,aAAa,EAAEZ,KAAK,GAAGF,OAAH,GAAa,IAJ1B;AAKPQ,MAAAA,cALO;AAMPL,MAAAA,aANO;AAOPG,MAAAA,OAPO;AAQPC,MAAAA,IARO;AASPE,MAAAA,IATO;AAUPC,MAAAA,eAVO;AAWPC,MAAAA;AAXO;AAHF,GAAP;AAiBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,mBAAT,CAA8Bf,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOH,YAAY,CAAE,SAAF,EAAaE,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASe,gBAAT,CAA2BhB,OAA3B,EAAoCC,OAApC,EAA8C;AACpD,SAAOH,YAAY,CAAE,MAAF,EAAUE,OAAV,EAAmBC,OAAnB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASgB,iBAAT,CAA4BjB,OAA5B,EAAqCC,OAArC,EAA+C;AACrD,SAAOH,YAAY,CAAE,OAAF,EAAWE,OAAX,EAAoBC,OAApB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASiB,mBAAT,CAA8BlB,OAA9B,EAAuCC,OAAvC,EAAiD;AACvD,SAAOH,YAAY,CAAE,SAAF,EAAaE,OAAb,EAAsBC,OAAtB,CAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASkB,YAAT,CAAuBd,EAAvB,EAAuD;AAAA,MAA5BD,OAA4B,uEAAlBR,eAAkB;AAC7D,SAAO;AACNW,IAAAA,IAAI,EAAE,eADA;AAENF,IAAAA,EAFM;AAGND,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniqueId } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';\n\n/**\n * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.\n *\n * @property {string} label Message to use as action label.\n * @property {?string} url Optional URL of resource if action incurs\n * browser navigation.\n * @property {?Function} onClick Optional function to invoke when action is\n * triggered by user.\n *\n */\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param {string} [status='info'] Notice status.\n * @param {string} content Notice message.\n * @param {Object} [options] Notice options.\n * @param {string} [options.context='global'] Context under which to\n * group notice.\n * @param {string} [options.id] Identifier for notice.\n * Automatically assigned\n * if not specified.\n * @param {boolean} [options.isDismissible=true] Whether the notice can\n * be dismissed by user.\n * @param {string} [options.type='default'] Type of notice, one of\n * `default`, or `snackbar`.\n * @param {boolean} [options.speak=true] Whether the notice\n * content should be\n * announced to screen\n * readers.\n * @param {Array<WPNoticeAction>} [options.actions] User actions to be\n * presented with notice.\n * @param {Object} [options.icon] An icon displayed with the notice.\n * @param {boolean} [options.explicitDismiss] Whether the notice includes\n * an explict dismiss button and\n * can't be dismissed by clicking\n * the body of the notice.\n * @param {Function} [options.onDismiss] Called when the notice is dismissed.\n *\n * @return {Object} Action object.\n */\nexport function createNotice( status = DEFAULT_STATUS, content, options = {} ) {\n\tconst {\n\t\tspeak = true,\n\t\tisDismissible = true,\n\t\tcontext = DEFAULT_CONTEXT,\n\t\tid = uniqueId( context ),\n\t\tactions = [],\n\t\ttype = 'default',\n\t\t__unstableHTML,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\tonDismiss,\n\t} = options;\n\n\t// The supported value shape of content is currently limited to plain text\n\t// strings. To avoid setting expectation that e.g. a WPElement could be\n\t// supported, cast to a string.\n\tcontent = String( content );\n\n\treturn {\n\t\ttype: 'CREATE_NOTICE',\n\t\tcontext,\n\t\tnotice: {\n\t\t\tid,\n\t\t\tstatus,\n\t\t\tcontent,\n\t\t\tspokenMessage: speak ? content : null,\n\t\t\t__unstableHTML,\n\t\t\tisDismissible,\n\t\t\tactions,\n\t\t\ttype,\n\t\t\ticon,\n\t\t\texplicitDismiss,\n\t\t\tonDismiss,\n\t\t},\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a success notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createSuccessNotice( content, options ) {\n\treturn createNotice( 'success', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an info notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createInfoNotice( content, options ) {\n\treturn createNotice( 'info', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an error notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createErrorNotice( content, options ) {\n\treturn createNotice( 'error', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a warning notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param {string} content Notice message.\n * @param {Object} [options] Optional notice options.\n *\n * @return {Object} Action object.\n */\nexport function createWarningNotice( content, options ) {\n\treturn createNotice( 'warning', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a notice is to be removed.\n *\n * @param {string} id Notice unique identifier.\n * @param {string} [context='global'] Optional context (grouping) in which the notice is\n * intended to appear. Defaults to default context.\n *\n * @return {Object} Action object.\n */\nexport function removeNotice( id, context = DEFAULT_CONTEXT ) {\n\treturn {\n\t\ttype: 'REMOVE_NOTICE',\n\t\tid,\n\t\tcontext,\n\t};\n}\n"]}
@@ -17,7 +17,10 @@ import onSubKey from './utils/on-sub-key';
17
17
  * @return {Object} Updated state.
18
18
  */
19
19
 
20
- const notices = onSubKey('context')((state = [], action) => {
20
+ const notices = onSubKey('context')(function () {
21
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
22
+ let action = arguments.length > 1 ? arguments[1] : undefined;
23
+
21
24
  switch (action.type) {
22
25
  case 'CREATE_NOTICE':
23
26
  // Avoid duplicates on ID.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/reducer.js"],"names":["reject","onSubKey","notices","state","action","type","id","notice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,QAAvB;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,oBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,OAAO,GAAGD,QAAQ,CAAE,SAAF,CAAR,CAAuB,CAAEE,KAAK,GAAG,EAAV,EAAcC,MAAd,KAA0B;AAChE,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC;AACA,aAAO,CACN,GAAGL,MAAM,CAAEG,KAAF,EAAS;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACG,MAAP,CAAcD;AAApB,OAAT,CADH,EAENF,MAAM,CAACG,MAFD,CAAP;;AAKD,SAAK,eAAL;AACC,aAAOP,MAAM,CAAEG,KAAF,EAAS;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACE;AAAb,OAAT,CAAb;AATF;;AAYA,SAAOH,KAAP;AACA,CAde,CAAhB;AAgBA,eAAeD,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { reject } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport onSubKey from './utils/on-sub-key';\n\n/**\n * Reducer returning the next notices state. The notices state is an object\n * where each key is a context, its value an array of notice objects.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nconst notices = onSubKey( 'context' )( ( state = [], action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'CREATE_NOTICE':\n\t\t\t// Avoid duplicates on ID.\n\t\t\treturn [\n\t\t\t\t...reject( state, { id: action.notice.id } ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn reject( state, { id: action.id } );\n\t}\n\n\treturn state;\n} );\n\nexport default notices;\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/reducer.js"],"names":["reject","onSubKey","notices","state","action","type","id","notice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,QAAvB;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,oBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,OAAO,GAAGD,QAAQ,CAAE,SAAF,CAAR,CAAuB,YAA0B;AAAA,MAAxBE,KAAwB,uEAAhB,EAAgB;AAAA,MAAZC,MAAY;;AAChE,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC;AACA,aAAO,CACN,GAAGL,MAAM,CAAEG,KAAF,EAAS;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACG,MAAP,CAAcD;AAApB,OAAT,CADH,EAENF,MAAM,CAACG,MAFD,CAAP;;AAKD,SAAK,eAAL;AACC,aAAOP,MAAM,CAAEG,KAAF,EAAS;AAAEG,QAAAA,EAAE,EAAEF,MAAM,CAACE;AAAb,OAAT,CAAb;AATF;;AAYA,SAAOH,KAAP;AACA,CAde,CAAhB;AAgBA,eAAeD,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { reject } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport onSubKey from './utils/on-sub-key';\n\n/**\n * Reducer returning the next notices state. The notices state is an object\n * where each key is a context, its value an array of notice objects.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nconst notices = onSubKey( 'context' )( ( state = [], action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'CREATE_NOTICE':\n\t\t\t// Avoid duplicates on ID.\n\t\t\treturn [\n\t\t\t\t...reject( state, { id: action.notice.id } ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn reject( state, { id: action.id } );\n\t}\n\n\treturn state;\n} );\n\nexport default notices;\n"]}
@@ -51,7 +51,8 @@ const DEFAULT_NOTICES = [];
51
51
  * @return {WPNotice[]} Array of notices.
52
52
  */
53
53
 
54
- export function getNotices(state, context = DEFAULT_CONTEXT) {
54
+ export function getNotices(state) {
55
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
55
56
  return state[context] || DEFAULT_NOTICES;
56
57
  }
57
58
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/selectors.js"],"names":["DEFAULT_CONTEXT","DEFAULT_NOTICES","getNotices","state","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,aAAhC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,eAAe,GAAG,EAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,UAAT,CAAqBC,KAArB,EAA4BC,OAAO,GAAGJ,eAAtC,EAAwD;AAC9D,SAAOG,KAAK,CAAEC,OAAF,CAAL,IAAoBH,eAA3B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT } from './constants';\n\n/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */\n\n/**\n * The default empty set of notices to return when there are no notices\n * assigned for a given notices context. This can occur if the getNotices\n * selector is called without a notice ever having been created for the\n * context. A shared value is used to ensure referential equality between\n * sequential selector calls, since otherwise `[] !== []`.\n *\n * @type {Array}\n */\nconst DEFAULT_NOTICES = [];\n\n/**\n * @typedef {Object} WPNotice Notice object.\n *\n * @property {string} id Unique identifier of notice.\n * @property {string} status Status of notice, one of `success`,\n * `info`, `error`, or `warning`. Defaults\n * to `info`.\n * @property {string} content Notice message.\n * @property {string} spokenMessage Audibly announced message text used by\n * assistive technologies.\n * @property {string} __unstableHTML Notice message as raw HTML. Intended to\n * serve primarily for compatibility of\n * server-rendered notices, and SHOULD NOT\n * be used for notices. It is subject to\n * removal without notice.\n * @property {boolean} isDismissible Whether the notice can be dismissed by\n * user. Defaults to `true`.\n * @property {string} type Type of notice, one of `default`,\n * or `snackbar`. Defaults to `default`.\n * @property {boolean} speak Whether the notice content should be\n * announced to screen readers. Defaults to\n * `true`.\n * @property {WPNoticeAction[]} actions User actions to present with notice.\n *\n */\n\n/**\n * Returns all notices as an array, optionally for a given context. Defaults to\n * the global context.\n *\n * @param {Object} state Notices state.\n * @param {?string} context Optional grouping context.\n *\n * @return {WPNotice[]} Array of notices.\n */\nexport function getNotices( state, context = DEFAULT_CONTEXT ) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/selectors.js"],"names":["DEFAULT_CONTEXT","DEFAULT_NOTICES","getNotices","state","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,aAAhC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,eAAe,GAAG,EAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,UAAT,CAAqBC,KAArB,EAAwD;AAAA,MAA5BC,OAA4B,uEAAlBJ,eAAkB;AAC9D,SAAOG,KAAK,CAAEC,OAAF,CAAL,IAAoBH,eAA3B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT } from './constants';\n\n/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */\n\n/**\n * The default empty set of notices to return when there are no notices\n * assigned for a given notices context. This can occur if the getNotices\n * selector is called without a notice ever having been created for the\n * context. A shared value is used to ensure referential equality between\n * sequential selector calls, since otherwise `[] !== []`.\n *\n * @type {Array}\n */\nconst DEFAULT_NOTICES = [];\n\n/**\n * @typedef {Object} WPNotice Notice object.\n *\n * @property {string} id Unique identifier of notice.\n * @property {string} status Status of notice, one of `success`,\n * `info`, `error`, or `warning`. Defaults\n * to `info`.\n * @property {string} content Notice message.\n * @property {string} spokenMessage Audibly announced message text used by\n * assistive technologies.\n * @property {string} __unstableHTML Notice message as raw HTML. Intended to\n * serve primarily for compatibility of\n * server-rendered notices, and SHOULD NOT\n * be used for notices. It is subject to\n * removal without notice.\n * @property {boolean} isDismissible Whether the notice can be dismissed by\n * user. Defaults to `true`.\n * @property {string} type Type of notice, one of `default`,\n * or `snackbar`. Defaults to `default`.\n * @property {boolean} speak Whether the notice content should be\n * announced to screen readers. Defaults to\n * `true`.\n * @property {WPNoticeAction[]} actions User actions to present with notice.\n *\n */\n\n/**\n * Returns all notices as an array, optionally for a given context. Defaults to\n * the global context.\n *\n * @param {Object} state Notices state.\n * @param {?string} context Optional grouping context.\n *\n * @return {WPNotice[]} Array of notices.\n */\nexport function getNotices( state, context = DEFAULT_CONTEXT ) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"]}
@@ -6,7 +6,9 @@
6
6
  *
7
7
  * @return {Function} Higher-order reducer.
8
8
  */
9
- export const onSubKey = actionProperty => reducer => (state = {}, action) => {
9
+ export const onSubKey = actionProperty => reducer => function () {
10
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11
+ let action = arguments.length > 1 ? arguments[1] : undefined;
10
12
  // Retrieve subkey from action. Do not track if undefined; useful for cases
11
13
  // where reducer is scoped by action shape.
12
14
  const key = action[actionProperty];
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/notices/src/store/utils/on-sub-key.js"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAKC,cAAF,IAAwBC,OAAF,IAAe,CAC5DC,KAAK,GAAG,EADoD,EAE5DC,MAF4D,KAGxD;AACJ;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANG,CAQJ;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CAtBM;AAwBP,eAAeP,QAAf","sourcesContent":["/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {Function} Higher-order reducer.\n */\nexport const onSubKey = ( actionProperty ) => ( reducer ) => (\n\tstate = {},\n\taction\n) => {\n\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t// where reducer is scoped by action shape.\n\tconst key = action[ actionProperty ];\n\tif ( key === undefined ) {\n\t\treturn state;\n\t}\n\n\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t// reducer which returns undefined on a key which is not yet tracked.\n\tconst nextKeyState = reducer( state[ key ], action );\n\tif ( nextKeyState === state[ key ] ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ key ]: nextKeyState,\n\t};\n};\n\nexport default onSubKey;\n"]}
1
+ {"version":3,"sources":["@wordpress/notices/src/store/utils/on-sub-key.js"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAKC,cAAF,IAAwBC,OAAF,IAAe,YAGxD;AAAA,MAFJC,KAEI,uEAFI,EAEJ;AAAA,MADJC,MACI;AACJ;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANG,CAQJ;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CAtBM;AAwBP,eAAeP,QAAf","sourcesContent":["/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {Function} Higher-order reducer.\n */\nexport const onSubKey = ( actionProperty ) => ( reducer ) => (\n\tstate = {},\n\taction\n) => {\n\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t// where reducer is scoped by action shape.\n\tconst key = action[ actionProperty ];\n\tif ( key === undefined ) {\n\t\treturn state;\n\t}\n\n\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t// reducer which returns undefined on a key which is not yet tracked.\n\tconst nextKeyState = reducer( state[ key ], action );\n\tif ( nextKeyState === state[ key ] ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ key ]: nextKeyState,\n\t};\n};\n\nexport default onSubKey;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/notices",
3
- "version": "3.2.6",
3
+ "version": "3.3.0",
4
4
  "description": "State management for notices.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -25,13 +25,13 @@
25
25
  "module": "build-module/index.js",
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.13.10",
29
- "@wordpress/a11y": "^3.2.3",
30
- "@wordpress/data": "^6.1.3",
28
+ "@babel/runtime": "^7.16.0",
29
+ "@wordpress/a11y": "^3.3.0",
30
+ "@wordpress/data": "^6.2.0",
31
31
  "lodash": "^4.17.21"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "393c2b5533837fd637e998d23f0124c081a10df0"
36
+ "gitHead": "d95ccb9366e249133cdb1d7b25c382446b9ee502"
37
37
  }