@wordpress/notices 5.37.1-next.79a2f3cdd.0 → 5.38.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/index.cjs +1 -1
  3. package/build/index.cjs.map +1 -1
  4. package/build/store/actions.cjs +1 -1
  5. package/build/store/actions.cjs.map +3 -3
  6. package/build/store/constants.cjs +1 -1
  7. package/build/store/constants.cjs.map +3 -3
  8. package/build/store/controls.cjs +1 -1
  9. package/build/store/controls.cjs.map +3 -3
  10. package/build/store/index.cjs +1 -1
  11. package/build/store/index.cjs.map +1 -1
  12. package/build/store/reducer.cjs +3 -2
  13. package/build/store/reducer.cjs.map +3 -3
  14. package/build/store/selectors.cjs +1 -1
  15. package/build/store/selectors.cjs.map +3 -3
  16. package/build/store/types.cjs +19 -0
  17. package/build/store/types.cjs.map +7 -0
  18. package/build/store/utils/on-sub-key.cjs +1 -1
  19. package/build/store/utils/on-sub-key.cjs.map +3 -3
  20. package/build-module/index.mjs +1 -1
  21. package/build-module/index.mjs.map +1 -1
  22. package/build-module/store/actions.mjs +1 -1
  23. package/build-module/store/actions.mjs.map +3 -3
  24. package/build-module/store/constants.mjs +1 -1
  25. package/build-module/store/constants.mjs.map +3 -3
  26. package/build-module/store/controls.mjs +1 -1
  27. package/build-module/store/controls.mjs.map +3 -3
  28. package/build-module/store/index.mjs +1 -1
  29. package/build-module/store/index.mjs.map +1 -1
  30. package/build-module/store/reducer.mjs +3 -2
  31. package/build-module/store/reducer.mjs.map +3 -3
  32. package/build-module/store/selectors.mjs +1 -1
  33. package/build-module/store/selectors.mjs.map +3 -3
  34. package/build-module/store/types.mjs +1 -0
  35. package/build-module/store/types.mjs.map +7 -0
  36. package/build-module/store/utils/on-sub-key.mjs +1 -1
  37. package/build-module/store/utils/on-sub-key.mjs.map +3 -3
  38. package/build-types/index.d.ts +1 -1
  39. package/build-types/index.d.ts.map +1 -1
  40. package/build-types/store/actions.d.ts +60 -87
  41. package/build-types/store/actions.d.ts.map +1 -1
  42. package/build-types/store/constants.d.ts +6 -6
  43. package/build-types/store/constants.d.ts.map +1 -1
  44. package/build-types/store/controls.d.ts +6 -3
  45. package/build-types/store/controls.d.ts.map +1 -1
  46. package/build-types/store/index.d.ts +3 -3
  47. package/build-types/store/index.d.ts.map +1 -1
  48. package/build-types/store/reducer.d.ts +9 -5
  49. package/build-types/store/reducer.d.ts.map +1 -1
  50. package/build-types/store/selectors.d.ts +5 -81
  51. package/build-types/store/selectors.d.ts.map +1 -1
  52. package/build-types/store/types.d.ts +141 -0
  53. package/build-types/store/types.d.ts.map +1 -0
  54. package/build-types/store/utils/on-sub-key.d.ts +13 -1
  55. package/build-types/store/utils/on-sub-key.d.ts.map +1 -1
  56. package/package.json +4 -4
  57. package/src/store/{actions.js → actions.ts} +53 -69
  58. package/src/store/{constants.js → constants.ts} +6 -5
  59. package/src/store/{controls.js → controls.ts} +1 -1
  60. package/src/store/{reducer.js → reducer.ts} +11 -6
  61. package/src/store/selectors.ts +49 -0
  62. package/src/store/test/{actions.js → actions.ts} +2 -2
  63. package/src/store/test/{reducer.js → reducer.ts} +1 -1
  64. package/src/store/test/{selectors.js → selectors.ts} +13 -4
  65. package/src/store/types.ts +169 -0
  66. package/src/store/utils/{on-sub-key.js → on-sub-key.ts} +12 -5
  67. package/src/store/selectors.js +0 -73
  68. /package/src/{index.js → index.ts} +0 -0
  69. /package/src/store/{index.js → index.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.38.0 (2026-01-16)
6
+
7
+ ### Enhancements
8
+
9
+ - Improved TypeScript definitions ([#67565](https://github.com/WordPress/gutenberg/pull/67565)).
10
+
5
11
  ## 5.36.0 (2025-11-26)
6
12
 
7
13
  ## 5.35.0 (2025-11-12)
package/build/index.cjs CHANGED
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/notices/src/index.js
20
+ // packages/notices/src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  store: () => import_store.store
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.js"],
3
+ "sources": ["../src/index.ts"],
4
4
  "sourcesContent": ["export { store } from './store';\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;",
6
6
  "names": []
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/notices/src/store/actions.js
20
+ // packages/notices/src/store/actions.ts
21
21
  var actions_exports = {};
22
22
  __export(actions_exports, {
23
23
  createErrorNotice: () => createErrorNotice,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/actions.js"],
4
- "sourcesContent": ["/**\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\nlet uniqueId = 0;\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param {string|undefined} status Notice status (\"info\" if undefined is passed).\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 {string} [options.icon] An icon displayed with the notice.\n * Only used when type is set to `snackbar`.\n * @param {boolean} [options.explicitDismiss] Whether the notice includes\n * an explicit dismiss button and\n * can't be dismissed by clicking\n * the body of the notice. Only applies\n * when type is set to `snackbar`.\n * @param {Function} [options.onDismiss] Called when the notice is dismissed.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }\n * >\n * { __( 'Generate a success notice!' ) }\n * </Button>\n * );\n * };\n * ```\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 = `${ context }${ ++uniqueId }`,\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 React Element 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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createSuccessNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createSuccessNotice( __( 'Success!' ), {\n * type: 'snackbar',\n * icon: '\uD83D\uDD25',\n * } )\n * }\n * >\n * { __( 'Generate a snackbar success notice!' ) }\n * </Button>\n * );\n * };\n * ```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createInfoNotice( __( 'Something happened!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice that cannot be dismissed.' ) }\n * </Button>\n * );\n * };\n *```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createErrorNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createErrorNotice( __( 'An error occurred!' ), {\n * type: 'snackbar',\n * explicitDismiss: true,\n * } )\n * }\n * >\n * { __(\n * 'Generate a snackbar error notice with explicit dismiss button.'\n * ) }\n * </Button>\n * );\n * };\n * ```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * onDismiss: () => {\n * createInfoNotice(\n * __( 'The warning has been dismissed!' )\n * );\n * },\n * } )\n * }\n * >\n * { __( 'Generates a warning notice with onDismiss callback' ) }\n * </Button>\n * );\n * };\n * ```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * const { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n *\n * return (\n * <>\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice' ) }\n * </Button>\n * { notices.length > 0 && (\n * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>\n * { __( 'Remove the notice' ) }\n * </Button>\n * ) }\n * </>\n * );\n *};\n * ```\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\n/**\n * Removes all notices from a given context. Defaults to the default context.\n *\n * @param {string} noticeType The context to remove all notices from.\n * @param {string} context The context to remove all notices from.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * export const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeAllNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices()\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices( 'snackbar' )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n *\n * @return {Object} \t Action object.\n */\nexport function removeAllNotices(\n\tnoticeType = 'default',\n\tcontext = DEFAULT_CONTEXT\n) {\n\treturn {\n\t\ttype: 'REMOVE_ALL_NOTICES',\n\t\tnoticeType,\n\t\tcontext,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that several notices are to be removed.\n *\n * @param {string[]} ids List of unique notice identifiers.\n * @param {string} [context='global'] Optional context (grouping) in which the notices are\n * intended to appear. Defaults to default context.\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveNotices( notices.map( ( { id } ) => id ) )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n * @return {Object} Action object.\n */\nexport function removeNotices( ids, context = DEFAULT_CONTEXT ) {\n\treturn {\n\t\ttype: 'REMOVE_NOTICES',\n\t\tids,\n\t\tcontext,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAgD;AAYhD,IAAI,WAAW;AAqDR,SAAS,aAAc,SAAS,iCAAgB,SAAS,UAAU,CAAC,GAAI;AAC9E,QAAM;AAAA,IACL,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK,GAAI,OAAQ,GAAI,EAAE,QAAS;AAAA,IAChC,UAAU,CAAC;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB;AAAA,EACD,IAAI;AAKJ,YAAU,OAAQ,OAAQ;AAE1B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,QAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,QAAQ,UAAU;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;AAqCO,SAAS,oBAAqB,SAAS,SAAU;AACvD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AAoCO,SAAS,iBAAkB,SAAS,SAAU;AACpD,SAAO,aAAc,QAAQ,SAAS,OAAQ;AAC/C;AAuCO,SAAS,kBAAmB,SAAS,SAAU;AACrD,SAAO,aAAc,SAAS,SAAS,OAAQ;AAChD;AAwCO,SAAS,oBAAqB,SAAS,SAAU;AACvD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AA2CO,SAAS,aAAc,IAAI,UAAU,kCAAkB;AAC7D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAgDO,SAAS,iBACf,aAAa,WACb,UAAU,kCACT;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAwCO,SAAS,cAAe,KAAK,UAAU,kCAAkB;AAC/D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
3
+ "sources": ["../../src/store/actions.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';\nimport type { NoticeOptions, ReducerAction } from './types';\n\nlet uniqueId = 0;\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param status Notice status (\"info\" if undefined is passed).\n * @param content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }\n * >\n * { __( 'Generate a success notice!' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createNotice(\n\tstatus = DEFAULT_STATUS,\n\tcontent: string,\n\toptions: NoticeOptions = {}\n): Extract< ReducerAction, { type: 'CREATE_NOTICE' } > {\n\tconst {\n\t\tspeak = true,\n\t\tisDismissible = true,\n\t\tcontext = DEFAULT_CONTEXT,\n\t\tid = `${ context }${ ++uniqueId }`,\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 React Element 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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createSuccessNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createSuccessNotice( __( 'Success!' ), {\n * type: 'snackbar',\n * icon: '\uD83D\uDD25',\n * } )\n * }\n * >\n * { __( 'Generate a snackbar success notice!' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createSuccessNotice(\n\tcontent: string,\n\toptions?: NoticeOptions\n) {\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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createInfoNotice( __( 'Something happened!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice that cannot be dismissed.' ) }\n * </Button>\n * );\n * };\n *```\n *\n * @return Action object.\n */\nexport function createInfoNotice( content: string, options?: NoticeOptions ) {\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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createErrorNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createErrorNotice( __( 'An error occurred!' ), {\n * type: 'snackbar',\n * explicitDismiss: true,\n * } )\n * }\n * >\n * { __(\n * 'Generate a snackbar error notice with explicit dismiss button.'\n * ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createErrorNotice( content: string, options?: NoticeOptions ) {\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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * onDismiss: () => {\n * createInfoNotice(\n * __( 'The warning has been dismissed!' )\n * );\n * },\n * } )\n * }\n * >\n * { __( 'Generates a warning notice with onDismiss callback' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createWarningNotice(\n\tcontent: string,\n\toptions?: NoticeOptions\n) {\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 id Notice unique identifier.\n * @param context Optional context (grouping) in which the notice is\n * intended to appear. Defaults to 'default' context.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * const { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n *\n * return (\n * <>\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice' ) }\n * </Button>\n * { notices.length > 0 && (\n * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>\n * { __( 'Remove the notice' ) }\n * </Button>\n * ) }\n * </>\n * );\n *};\n * ```\n *\n * @return Action object.\n */\nexport function removeNotice(\n\tid: string,\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_NOTICE' } > {\n\treturn {\n\t\ttype: 'REMOVE_NOTICE',\n\t\tid,\n\t\tcontext,\n\t};\n}\n\n/**\n * Removes all notices from a given context. Defaults to the default context.\n *\n * @param noticeType The context to remove all notices from.\n * @param context The optional context to remove all notices from.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * export const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeAllNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices()\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices( 'snackbar' )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n *\n * @return \t Action object.\n */\nexport function removeAllNotices(\n\tnoticeType = 'default',\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_ALL_NOTICES' } > {\n\treturn {\n\t\ttype: 'REMOVE_ALL_NOTICES',\n\t\tnoticeType,\n\t\tcontext,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that several notices are to be removed.\n *\n * @param ids List of unique notice identifiers.\n * @param context Optional context (grouping) in which the notices are\n * intended to appear. Defaults to 'default' context.\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveNotices( notices.map( ( { id } ) => id ) )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n * @return Action object.\n */\nexport function removeNotices(\n\tids: Array< string >,\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_NOTICES' } > {\n\treturn {\n\t\ttype: 'REMOVE_NOTICES',\n\t\tids,\n\t\tcontext,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAgD;AAGhD,IAAI,WAAW;AA8BR,SAAS,aACf,SAAS,iCACT,SACA,UAAyB,CAAC,GAC4B;AACtD,QAAM;AAAA,IACL,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK,GAAI,OAAQ,GAAI,EAAE,QAAS;AAAA,IAChC,UAAU,CAAC;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB;AAAA,EACD,IAAI;AAKJ,YAAU,OAAQ,OAAQ;AAE1B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,QAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,QAAQ,UAAU;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;AAqCO,SAAS,oBACf,SACA,SACC;AACD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AAoCO,SAAS,iBAAkB,SAAiB,SAA0B;AAC5E,SAAO,aAAc,QAAQ,SAAS,OAAQ;AAC/C;AAuCO,SAAS,kBAAmB,SAAiB,SAA0B;AAC7E,SAAO,aAAc,SAAS,SAAS,OAAQ;AAChD;AAwCO,SAAS,oBACf,SACA,SACC;AACD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AA2CO,SAAS,aACf,IACA,UAAkB,kCACoC;AACtD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAgDO,SAAS,iBACf,aAAa,WACb,UAAkB,kCACyC;AAC3D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAwCO,SAAS,cACf,KACA,UAAkB,kCACqC;AACvD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/notices/src/store/constants.js
20
+ // packages/notices/src/store/constants.ts
21
21
  var constants_exports = {};
22
22
  __export(constants_exports, {
23
23
  DEFAULT_CONTEXT: () => DEFAULT_CONTEXT,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/constants.js"],
4
- "sourcesContent": ["/**\n * Default context to use for notice grouping when not otherwise specified. Its\n * specific value doesn't hold much meaning, but it must be reasonably unique\n * and, more importantly, referenced consistently in the store implementation.\n *\n * @type {string}\n */\nexport const DEFAULT_CONTEXT = 'global';\n\n/**\n * Default notice status.\n *\n * @type {string}\n */\nexport const DEFAULT_STATUS = 'info';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,IAAM,kBAAkB;AAOxB,IAAM,iBAAiB;",
3
+ "sources": ["../../src/store/constants.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Notice } from './types';\n\n/**\n * Default context to use for notice grouping when not otherwise specified. Its\n * specific value doesn't hold much meaning, but it must be reasonably unique\n * and, more importantly, referenced consistently in the store implementation.\n */\nexport const DEFAULT_CONTEXT = 'global';\n\n/**\n * Default notice status.\n */\nexport const DEFAULT_STATUS: Notice[ 'status' ] = 'info';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,IAAM,kBAAkB;AAKxB,IAAM,iBAAqC;",
6
6
  "names": []
7
7
  }
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/notices/src/store/controls.js
20
+ // packages/notices/src/store/controls.ts
21
21
  var controls_exports = {};
22
22
  __export(controls_exports, {
23
23
  default: () => controls_default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/controls.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\n\nexport default {\n\tSPEAK( action ) {\n\t\tspeak( action.message, action.ariaLive || 'assertive' );\n\t},\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAsB;AAEtB,IAAO,mBAAQ;AAAA,EACd,MAAO,QAAS;AACf,2BAAO,OAAO,SAAS,OAAO,YAAY,WAAY;AAAA,EACvD;AACD;",
3
+ "sources": ["../../src/store/controls.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\n\nexport default {\n\tSPEAK( action: { message: string; ariaLive?: 'polite' | 'assertive' } ) {\n\t\tspeak( action.message, action.ariaLive || 'assertive' );\n\t},\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAsB;AAEtB,IAAO,mBAAQ;AAAA,EACd,MAAO,QAAiE;AACvE,2BAAO,OAAO,SAAS,OAAO,YAAY,WAAY;AAAA,EACvD;AACD;",
6
6
  "names": []
7
7
  }
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/notices/src/store/index.js
30
+ // packages/notices/src/store/index.ts
31
31
  var store_exports = {};
32
32
  __export(store_exports, {
33
33
  store: () => store
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/index.js"],
3
+ "sources": ["../../src/store/index.ts"],
4
4
  "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 */\nexport const store = createReduxStore( 'core/notices', {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA2C;AAK3C,qBAAoB;AACpB,cAAyB;AACzB,gBAA2B;AAOpB,IAAM,YAAQ,8BAAkB,gBAAgB;AAAA,EACtD,wBAAAA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAAA,IAEF,sBAAU,KAAM;",
6
6
  "names": ["reducer"]
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // packages/notices/src/store/reducer.js
30
+ // packages/notices/src/store/reducer.ts
31
31
  var reducer_exports = {};
32
32
  __export(reducer_exports, {
33
33
  default: () => reducer_default
@@ -47,8 +47,9 @@ var notices = (0, import_on_sub_key.default)("context")((state = [], action) =>
47
47
  return state.filter(({ id }) => !action.ids.includes(id));
48
48
  case "REMOVE_ALL_NOTICES":
49
49
  return state.filter(({ type }) => type !== action.noticeType);
50
+ default:
51
+ return state;
50
52
  }
51
- return state;
52
53
  });
53
54
  var reducer_default = notices;
54
55
  //# sourceMappingURL=reducer.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["/**\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...state.filter( ( { id } ) => id !== action.notice.id ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn state.filter( ( { id } ) => id !== action.id );\n\n\t\tcase 'REMOVE_NOTICES':\n\t\t\treturn state.filter( ( { id } ) => ! action.ids.includes( id ) );\n\n\t\tcase 'REMOVE_ALL_NOTICES':\n\t\t\treturn state.filter( ( { type } ) => type !== action.noticeType );\n\t}\n\n\treturn state;\n} );\n\nexport default notices;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAqB;AAWrB,IAAM,cAAU,kBAAAA,SAAU,SAAU,EAAG,CAAE,QAAQ,CAAC,GAAG,WAAY;AAChE,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AAEJ,aAAO;AAAA,QACN,GAAG,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,OAAO,EAAG;AAAA,QACvD,OAAO;AAAA,MACR;AAAA,IAED,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,EAAG;AAAA,IAErD,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,CAAE,OAAO,IAAI,SAAU,EAAG,CAAE;AAAA,IAEhE,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,KAAK,MAAO,SAAS,OAAO,UAAW;AAAA,EAClE;AAEA,SAAO;AACR,CAAE;AAEF,IAAO,kBAAQ;",
3
+ "sources": ["../../src/store/reducer.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Notice, ReducerAction } from './types';\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 state Current state.\n * @param action Dispatched action.\n *\n * @return Updated state.\n */\nconst notices = onSubKey( 'context' )< Array< Notice >, ReducerAction >( (\n\tstate = [],\n\taction\n) => {\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...state.filter( ( { id } ) => id !== action.notice.id ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn state.filter( ( { id } ) => id !== action.id );\n\n\t\tcase 'REMOVE_NOTICES':\n\t\t\treturn state.filter( ( { id } ) => ! action.ids.includes( id ) );\n\n\t\tcase 'REMOVE_ALL_NOTICES':\n\t\t\treturn state.filter( ( { type } ) => type !== action.noticeType );\n\n\t\tdefault:\n\t\t\treturn state;\n\t}\n} );\n\nexport default notices;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,wBAAqB;AAWrB,IAAM,cAAU,kBAAAA,SAAU,SAAU,EAAqC,CACxE,QAAQ,CAAC,GACT,WACI;AACJ,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AAEJ,aAAO;AAAA,QACN,GAAG,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,OAAO,EAAG;AAAA,QACvD,OAAO;AAAA,MACR;AAAA,IAED,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,EAAG;AAAA,IAErD,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,CAAE,OAAO,IAAI,SAAU,EAAG,CAAE;AAAA,IAEhE,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,KAAK,MAAO,SAAS,OAAO,UAAW;AAAA,IAEjE;AACC,aAAO;AAAA,EACT;AACD,CAAE;AAEF,IAAO,kBAAQ;",
6
6
  "names": ["onSubKey"]
7
7
  }
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/notices/src/store/selectors.js
20
+ // packages/notices/src/store/selectors.ts
21
21
  var selectors_exports = {};
22
22
  __export(selectors_exports, {
23
23
  getNotices: () => getNotices
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/selectors.js"],
4
- "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 * 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 * @example\n *\n *```js\n * import { useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * return (\n * <ul>\n * { notices.map( ( notice ) => (\n * <li key={ notice.ID }>{ notice.content }</li>\n * ) ) }\n * </ul>\n * )\n * };\n *```\n *\n * @return {WPNotice[]} Array of notices.\n */\nexport function getNotices( state, context = DEFAULT_CONTEXT ) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAgC;AAahC,IAAM,kBAAkB,CAAC;AAsDlB,SAAS,WAAY,OAAO,UAAU,kCAAkB;AAC9D,SAAO,MAAO,OAAQ,KAAK;AAC5B;",
3
+ "sources": ["../../src/store/selectors.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT } from './constants';\nimport type { Notice } from './types';\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 */\nconst DEFAULT_NOTICES: Array< Notice > = [];\n\n/**\n * Returns all notices as an array, optionally for a given context. Defaults to\n * the global context.\n *\n * @param state Notices state.\n * @param context Optional grouping context.\n *\n * @example\n *\n *```js\n * import { useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * return (\n * <ul>\n * { notices.map( ( notice ) => (\n * <li key={ notice.ID }>{ notice.content }</li>\n * ) ) }\n * </ul>\n * )\n * };\n *```\n *\n * @return Array of notices.\n */\nexport function getNotices(\n\tstate: Record< string, Array< Notice > >,\n\tcontext: string = DEFAULT_CONTEXT\n) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAgC;AAWhC,IAAM,kBAAmC,CAAC;AA6BnC,SAAS,WACf,OACA,UAAkB,kCACjB;AACD,SAAO,MAAO,OAAQ,KAAK;AAC5B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // packages/notices/src/store/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
19
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/types.ts"],
4
+ "sourcesContent": ["/**\n * Object describing a user action option associated with a notice.\n */\nexport type NoticeAction = {\n\t/**\n\t * Message to use as action label.\n\t */\n\tlabel: string;\n\n\t/**\n\t * Optional URL of resource if action incurs browser navigation.\n\t */\n\turl?: string;\n\n\t/**\n\t * Optional function to invoke when action is triggered by user.\n\t */\n\tonClick?: VoidFunction;\n};\n\n/**\n * Notice object.\n */\nexport type Notice = {\n\t/**\n\t * Unique identifier of notice.\n\t */\n\tid: string;\n\n\t/**\n\t * Status of notice, one of `success`, `info`, `error`, or `warning`. Defaults to `info`.\n\t */\n\tstatus: 'success' | 'info' | 'error' | 'warning';\n\n\t/**\n\t * Notice message.\n\t */\n\tcontent: string;\n\n\t/**\n\t * Audibly announced message text used by assistive technologies.\n\t */\n\tspokenMessage: string | null;\n\n\t/**\n\t * Notice message as raw HTML. Intended to serve primarily for compatibility of server-rendered notices,\n\t * and SHOULD NOT be used for notices. It is subject to removal without notice.\n\t */\n\t__unstableHTML?: boolean;\n\n\t/**\n\t * Whether the notice can be dismissed by user. Defaults to `true`.\n\t */\n\tisDismissible: boolean;\n\n\t/**\n\t * Whether the notice includes an explicit dismiss button and can't be dismissed by clicking the body of the notice. Only applies when type is `snackbar`.\n\t */\n\texplicitDismiss?: boolean;\n\n\t/**\n\t * Called when the notice is dismissed.\n\t */\n\tonDismiss?: VoidFunction;\n\n\t/**\n\t * Type of notice, one of `default`, or `snackbar`.\n\t *\n\t * @default 'default'\n\t */\n\ttype: 'default' | 'snackbar' | ( string & {} );\n\n\t/**\n\t * User actions to present with notice.\n\t */\n\tactions: NoticeAction[];\n\n\t/**\n\t * An icon displayed with the notice. Only used when type is `snackbar`.\n\t */\n\ticon?: string | null;\n};\n\nexport type NoticeOptions = {\n\t/**\n\t * Context under which to group notice.\n\t * @default 'global'\n\t */\n\tcontext?: string;\n\n\t/**\n\t * Identifier for notice. Automatically assigned if not specified.\n\t */\n\tid?: string;\n\n\t/**\n\t * Whether the notice can be dismissed by user.\n\t * @default true\n\t */\n\tisDismissible?: boolean;\n\n\t/**\n\t * Type of notice, one of `default`, or `snackbar`.\n\t * @default 'default'\n\t */\n\ttype?: 'default' | 'snackbar' | ( string & {} );\n\n\t/**\n\t * Whether the notice content should be announced to screen readers.\n\t * @default true\n\t */\n\tspeak?: boolean;\n\n\t/**\n\t * User actions to be presented with notice.\n\t */\n\tactions?: NoticeAction[];\n\n\t/**\n\t * An icon displayed with the notice. Only used when type is set to `snackbar`.\n\t */\n\ticon?: string | null;\n\n\t/**\n\t * Whether the notice includes an explicit dismiss button and can't be dismissed by clicking the body of the notice. Only applies when type is set to `snackbar`.\n\t */\n\texplicitDismiss?: boolean;\n\n\t/**\n\t * Called when the notice is dismissed.\n\t */\n\tonDismiss?: VoidFunction;\n\n\t/**\n\t * Notice message as raw HTML. Intended to serve primarily for compatibility of server-rendered notices,\n\t * and SHOULD NOT be used for notices. It is subject to removal without notice.\n\t */\n\t__unstableHTML?: boolean;\n};\n\nexport type ReducerAction =\n\t| {\n\t\t\ttype: 'CREATE_NOTICE';\n\t\t\tcontext: string;\n\t\t\tnotice: Notice;\n\t }\n\t| {\n\t\t\ttype: 'REMOVE_NOTICE';\n\t\t\tcontext: string;\n\t\t\tid: string;\n\t }\n\t| {\n\t\t\ttype: 'REMOVE_NOTICES';\n\t\t\tcontext: string;\n\t\t\tids: Array< string >;\n\t }\n\t| {\n\t\t\ttype: 'REMOVE_ALL_NOTICES';\n\t\t\tcontext: string;\n\t\t\tnoticeType: string;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Represents any action not explicitly handled by this reducer,\n\t\t\t * allowing TypeScript's discriminated union narrowing to work correctly.\n\t\t\t */\n\t\t\ttype: '@@UNKNOWN_ACTION';\n\t\t\tcontext?: string;\n\t };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/notices/src/store/utils/on-sub-key.js
20
+ // packages/notices/src/store/utils/on-sub-key.ts
21
21
  var on_sub_key_exports = {};
22
22
  __export(on_sub_key_exports, {
23
23
  default: () => on_sub_key_default,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/store/utils/on-sub-key.js"],
4
- "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 =\n\t( actionProperty ) =>\n\t( reducer ) =>\n\t( state = {}, action ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\nexport default onSubKey;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,IAAM,WACZ,CAAE,mBACF,CAAE,YACF,CAAE,QAAQ,CAAC,GAAG,WAAY;AAGzB,QAAM,MAAM,OAAQ,cAAe;AACnC,MAAK,QAAQ,QAAY;AACxB,WAAO;AAAA,EACR;AAIA,QAAM,eAAe,QAAS,MAAO,GAAI,GAAG,MAAO;AACnD,MAAK,iBAAiB,MAAO,GAAI,GAAI;AACpC,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAE,GAAI,GAAG;AAAA,EACV;AACD;AAED,IAAO,qBAAQ;",
3
+ "sources": ["../../../src/store/utils/on-sub-key.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { Reducer, Action } from 'redux';\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param actionProperty Action property by which to key object.\n *\n * @return Higher-order reducer.\n */\nexport const onSubKey =\n\t( actionProperty: string ) =>\n\t< S, A extends Action & Record< string, any > >(\n\t\treducer: Reducer< S, A >\n\t) =>\n\t( state: Record< string, S > = {}, action: A ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\nexport default onSubKey;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,IAAM,WACZ,CAAE,mBACF,CACC,YAED,CAAE,QAA6B,CAAC,GAAG,WAAe;AAGjD,QAAM,MAAM,OAAQ,cAAe;AACnC,MAAK,QAAQ,QAAY;AACxB,WAAO;AAAA,EACR;AAIA,QAAM,eAAe,QAAS,MAAO,GAAI,GAAG,MAAO;AACnD,MAAK,iBAAiB,MAAO,GAAI,GAAI;AACpC,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAE,GAAI,GAAG;AAAA,EACV;AACD;AAED,IAAO,qBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/notices/src/index.js
1
+ // packages/notices/src/index.ts
2
2
  import { store } from "./store/index.mjs";
3
3
  export {
4
4
  store
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.js"],
3
+ "sources": ["../src/index.ts"],
4
4
  "sourcesContent": ["export { store } from './store';\n"],
5
5
  "mappings": ";AAAA,SAAS,aAAa;",
6
6
  "names": []
@@ -1,4 +1,4 @@
1
- // packages/notices/src/store/actions.js
1
+ // packages/notices/src/store/actions.ts
2
2
  import { DEFAULT_CONTEXT, DEFAULT_STATUS } from "./constants.mjs";
3
3
  var uniqueId = 0;
4
4
  function createNotice(status = DEFAULT_STATUS, content, options = {}) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/actions.js"],
4
- "sourcesContent": ["/**\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\nlet uniqueId = 0;\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param {string|undefined} status Notice status (\"info\" if undefined is passed).\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 {string} [options.icon] An icon displayed with the notice.\n * Only used when type is set to `snackbar`.\n * @param {boolean} [options.explicitDismiss] Whether the notice includes\n * an explicit dismiss button and\n * can't be dismissed by clicking\n * the body of the notice. Only applies\n * when type is set to `snackbar`.\n * @param {Function} [options.onDismiss] Called when the notice is dismissed.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }\n * >\n * { __( 'Generate a success notice!' ) }\n * </Button>\n * );\n * };\n * ```\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 = `${ context }${ ++uniqueId }`,\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 React Element 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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createSuccessNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createSuccessNotice( __( 'Success!' ), {\n * type: 'snackbar',\n * icon: '\uD83D\uDD25',\n * } )\n * }\n * >\n * { __( 'Generate a snackbar success notice!' ) }\n * </Button>\n * );\n * };\n * ```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createInfoNotice( __( 'Something happened!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice that cannot be dismissed.' ) }\n * </Button>\n * );\n * };\n *```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createErrorNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createErrorNotice( __( 'An error occurred!' ), {\n * type: 'snackbar',\n * explicitDismiss: true,\n * } )\n * }\n * >\n * { __(\n * 'Generate a snackbar error notice with explicit dismiss button.'\n * ) }\n * </Button>\n * );\n * };\n * ```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * onDismiss: () => {\n * createInfoNotice(\n * __( 'The warning has been dismissed!' )\n * );\n * },\n * } )\n * }\n * >\n * { __( 'Generates a warning notice with onDismiss callback' ) }\n * </Button>\n * );\n * };\n * ```\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 * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * const { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n *\n * return (\n * <>\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice' ) }\n * </Button>\n * { notices.length > 0 && (\n * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>\n * { __( 'Remove the notice' ) }\n * </Button>\n * ) }\n * </>\n * );\n *};\n * ```\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\n/**\n * Removes all notices from a given context. Defaults to the default context.\n *\n * @param {string} noticeType The context to remove all notices from.\n * @param {string} context The context to remove all notices from.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * export const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeAllNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices()\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices( 'snackbar' )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n *\n * @return {Object} \t Action object.\n */\nexport function removeAllNotices(\n\tnoticeType = 'default',\n\tcontext = DEFAULT_CONTEXT\n) {\n\treturn {\n\t\ttype: 'REMOVE_ALL_NOTICES',\n\t\tnoticeType,\n\t\tcontext,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that several notices are to be removed.\n *\n * @param {string[]} ids List of unique notice identifiers.\n * @param {string} [context='global'] Optional context (grouping) in which the notices are\n * intended to appear. Defaults to default context.\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveNotices( notices.map( ( { id } ) => id ) )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n * @return {Object} Action object.\n */\nexport function removeNotices( ids, context = DEFAULT_CONTEXT ) {\n\treturn {\n\t\ttype: 'REMOVE_NOTICES',\n\t\tids,\n\t\tcontext,\n\t};\n}\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB,sBAAsB;AAYhD,IAAI,WAAW;AAqDR,SAAS,aAAc,SAAS,gBAAgB,SAAS,UAAU,CAAC,GAAI;AAC9E,QAAM;AAAA,IACL,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK,GAAI,OAAQ,GAAI,EAAE,QAAS;AAAA,IAChC,UAAU,CAAC;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB;AAAA,EACD,IAAI;AAKJ,YAAU,OAAQ,OAAQ;AAE1B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,QAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,QAAQ,UAAU;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;AAqCO,SAAS,oBAAqB,SAAS,SAAU;AACvD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AAoCO,SAAS,iBAAkB,SAAS,SAAU;AACpD,SAAO,aAAc,QAAQ,SAAS,OAAQ;AAC/C;AAuCO,SAAS,kBAAmB,SAAS,SAAU;AACrD,SAAO,aAAc,SAAS,SAAS,OAAQ;AAChD;AAwCO,SAAS,oBAAqB,SAAS,SAAU;AACvD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AA2CO,SAAS,aAAc,IAAI,UAAU,iBAAkB;AAC7D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAgDO,SAAS,iBACf,aAAa,WACb,UAAU,iBACT;AACD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAwCO,SAAS,cAAe,KAAK,UAAU,iBAAkB;AAC/D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
3
+ "sources": ["../../src/store/actions.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';\nimport type { NoticeOptions, ReducerAction } from './types';\n\nlet uniqueId = 0;\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param status Notice status (\"info\" if undefined is passed).\n * @param content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }\n * >\n * { __( 'Generate a success notice!' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createNotice(\n\tstatus = DEFAULT_STATUS,\n\tcontent: string,\n\toptions: NoticeOptions = {}\n): Extract< ReducerAction, { type: 'CREATE_NOTICE' } > {\n\tconst {\n\t\tspeak = true,\n\t\tisDismissible = true,\n\t\tcontext = DEFAULT_CONTEXT,\n\t\tid = `${ context }${ ++uniqueId }`,\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 React Element 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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createSuccessNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createSuccessNotice( __( 'Success!' ), {\n * type: 'snackbar',\n * icon: '\uD83D\uDD25',\n * } )\n * }\n * >\n * { __( 'Generate a snackbar success notice!' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createSuccessNotice(\n\tcontent: string,\n\toptions?: NoticeOptions\n) {\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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createInfoNotice( __( 'Something happened!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice that cannot be dismissed.' ) }\n * </Button>\n * );\n * };\n *```\n *\n * @return Action object.\n */\nexport function createInfoNotice( content: string, options?: NoticeOptions ) {\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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createErrorNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createErrorNotice( __( 'An error occurred!' ), {\n * type: 'snackbar',\n * explicitDismiss: true,\n * } )\n * }\n * >\n * { __(\n * 'Generate a snackbar error notice with explicit dismiss button.'\n * ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createErrorNotice( content: string, options?: NoticeOptions ) {\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 content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * onDismiss: () => {\n * createInfoNotice(\n * __( 'The warning has been dismissed!' )\n * );\n * },\n * } )\n * }\n * >\n * { __( 'Generates a warning notice with onDismiss callback' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createWarningNotice(\n\tcontent: string,\n\toptions?: NoticeOptions\n) {\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 id Notice unique identifier.\n * @param context Optional context (grouping) in which the notice is\n * intended to appear. Defaults to 'default' context.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * const { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n *\n * return (\n * <>\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice' ) }\n * </Button>\n * { notices.length > 0 && (\n * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>\n * { __( 'Remove the notice' ) }\n * </Button>\n * ) }\n * </>\n * );\n *};\n * ```\n *\n * @return Action object.\n */\nexport function removeNotice(\n\tid: string,\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_NOTICE' } > {\n\treturn {\n\t\ttype: 'REMOVE_NOTICE',\n\t\tid,\n\t\tcontext,\n\t};\n}\n\n/**\n * Removes all notices from a given context. Defaults to the default context.\n *\n * @param noticeType The context to remove all notices from.\n * @param context The optional context to remove all notices from.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * export const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeAllNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices()\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices( 'snackbar' )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n *\n * @return \t Action object.\n */\nexport function removeAllNotices(\n\tnoticeType = 'default',\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_ALL_NOTICES' } > {\n\treturn {\n\t\ttype: 'REMOVE_ALL_NOTICES',\n\t\tnoticeType,\n\t\tcontext,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that several notices are to be removed.\n *\n * @param ids List of unique notice identifiers.\n * @param context Optional context (grouping) in which the notices are\n * intended to appear. Defaults to 'default' context.\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveNotices( notices.map( ( { id } ) => id ) )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n * @return Action object.\n */\nexport function removeNotices(\n\tids: Array< string >,\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_NOTICES' } > {\n\treturn {\n\t\ttype: 'REMOVE_NOTICES',\n\t\tids,\n\t\tcontext,\n\t};\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB,sBAAsB;AAGhD,IAAI,WAAW;AA8BR,SAAS,aACf,SAAS,gBACT,SACA,UAAyB,CAAC,GAC4B;AACtD,QAAM;AAAA,IACL,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK,GAAI,OAAQ,GAAI,EAAE,QAAS;AAAA,IAChC,UAAU,CAAC;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB;AAAA,EACD,IAAI;AAKJ,YAAU,OAAQ,OAAQ;AAE1B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,QAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,QAAQ,UAAU;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;AAqCO,SAAS,oBACf,SACA,SACC;AACD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AAoCO,SAAS,iBAAkB,SAAiB,SAA0B;AAC5E,SAAO,aAAc,QAAQ,SAAS,OAAQ;AAC/C;AAuCO,SAAS,kBAAmB,SAAiB,SAA0B;AAC7E,SAAO,aAAc,SAAS,SAAS,OAAQ;AAChD;AAwCO,SAAS,oBACf,SACA,SACC;AACD,SAAO,aAAc,WAAW,SAAS,OAAQ;AAClD;AA2CO,SAAS,aACf,IACA,UAAkB,iBACoC;AACtD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAgDO,SAAS,iBACf,aAAa,WACb,UAAkB,iBACyC;AAC3D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAwCO,SAAS,cACf,KACA,UAAkB,iBACqC;AACvD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/notices/src/store/constants.js
1
+ // packages/notices/src/store/constants.ts
2
2
  var DEFAULT_CONTEXT = "global";
3
3
  var DEFAULT_STATUS = "info";
4
4
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/constants.js"],
4
- "sourcesContent": ["/**\n * Default context to use for notice grouping when not otherwise specified. Its\n * specific value doesn't hold much meaning, but it must be reasonably unique\n * and, more importantly, referenced consistently in the store implementation.\n *\n * @type {string}\n */\nexport const DEFAULT_CONTEXT = 'global';\n\n/**\n * Default notice status.\n *\n * @type {string}\n */\nexport const DEFAULT_STATUS = 'info';\n"],
5
- "mappings": ";AAOO,IAAM,kBAAkB;AAOxB,IAAM,iBAAiB;",
3
+ "sources": ["../../src/store/constants.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Notice } from './types';\n\n/**\n * Default context to use for notice grouping when not otherwise specified. Its\n * specific value doesn't hold much meaning, but it must be reasonably unique\n * and, more importantly, referenced consistently in the store implementation.\n */\nexport const DEFAULT_CONTEXT = 'global';\n\n/**\n * Default notice status.\n */\nexport const DEFAULT_STATUS: Notice[ 'status' ] = 'info';\n"],
5
+ "mappings": ";AAUO,IAAM,kBAAkB;AAKxB,IAAM,iBAAqC;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/notices/src/store/controls.js
1
+ // packages/notices/src/store/controls.ts
2
2
  import { speak } from "@wordpress/a11y";
3
3
  var controls_default = {
4
4
  SPEAK(action) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/controls.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\n\nexport default {\n\tSPEAK( action ) {\n\t\tspeak( action.message, action.ariaLive || 'assertive' );\n\t},\n};\n"],
5
- "mappings": ";AAGA,SAAS,aAAa;AAEtB,IAAO,mBAAQ;AAAA,EACd,MAAO,QAAS;AACf,UAAO,OAAO,SAAS,OAAO,YAAY,WAAY;AAAA,EACvD;AACD;",
3
+ "sources": ["../../src/store/controls.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\n\nexport default {\n\tSPEAK( action: { message: string; ariaLive?: 'polite' | 'assertive' } ) {\n\t\tspeak( action.message, action.ariaLive || 'assertive' );\n\t},\n};\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa;AAEtB,IAAO,mBAAQ;AAAA,EACd,MAAO,QAAiE;AACvE,UAAO,OAAO,SAAS,OAAO,YAAY,WAAY;AAAA,EACvD;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/notices/src/store/index.js
1
+ // packages/notices/src/store/index.ts
2
2
  import { createReduxStore, register } from "@wordpress/data";
3
3
  import reducer from "./reducer.mjs";
4
4
  import * as actions from "./actions.mjs";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/index.js"],
3
+ "sources": ["../../src/store/index.ts"],
4
4
  "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 */\nexport const store = createReduxStore( 'core/notices', {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],
5
5
  "mappings": ";AAGA,SAAS,kBAAkB,gBAAgB;AAK3C,OAAO,aAAa;AACpB,YAAY,aAAa;AACzB,YAAY,eAAe;AAOpB,IAAM,QAAQ,iBAAkB,gBAAgB;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAEF,SAAU,KAAM;",
6
6
  "names": []
@@ -1,4 +1,4 @@
1
- // packages/notices/src/store/reducer.js
1
+ // packages/notices/src/store/reducer.ts
2
2
  import onSubKey from "./utils/on-sub-key.mjs";
3
3
  var notices = onSubKey("context")((state = [], action) => {
4
4
  switch (action.type) {
@@ -13,8 +13,9 @@ var notices = onSubKey("context")((state = [], action) => {
13
13
  return state.filter(({ id }) => !action.ids.includes(id));
14
14
  case "REMOVE_ALL_NOTICES":
15
15
  return state.filter(({ type }) => type !== action.noticeType);
16
+ default:
17
+ return state;
16
18
  }
17
- return state;
18
19
  });
19
20
  var reducer_default = notices;
20
21
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["/**\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...state.filter( ( { id } ) => id !== action.notice.id ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn state.filter( ( { id } ) => id !== action.id );\n\n\t\tcase 'REMOVE_NOTICES':\n\t\t\treturn state.filter( ( { id } ) => ! action.ids.includes( id ) );\n\n\t\tcase 'REMOVE_ALL_NOTICES':\n\t\t\treturn state.filter( ( { type } ) => type !== action.noticeType );\n\t}\n\n\treturn state;\n} );\n\nexport default notices;\n"],
5
- "mappings": ";AAGA,OAAO,cAAc;AAWrB,IAAM,UAAU,SAAU,SAAU,EAAG,CAAE,QAAQ,CAAC,GAAG,WAAY;AAChE,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AAEJ,aAAO;AAAA,QACN,GAAG,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,OAAO,EAAG;AAAA,QACvD,OAAO;AAAA,MACR;AAAA,IAED,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,EAAG;AAAA,IAErD,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,CAAE,OAAO,IAAI,SAAU,EAAG,CAAE;AAAA,IAEhE,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,KAAK,MAAO,SAAS,OAAO,UAAW;AAAA,EAClE;AAEA,SAAO;AACR,CAAE;AAEF,IAAO,kBAAQ;",
3
+ "sources": ["../../src/store/reducer.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Notice, ReducerAction } from './types';\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 state Current state.\n * @param action Dispatched action.\n *\n * @return Updated state.\n */\nconst notices = onSubKey( 'context' )< Array< Notice >, ReducerAction >( (\n\tstate = [],\n\taction\n) => {\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...state.filter( ( { id } ) => id !== action.notice.id ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn state.filter( ( { id } ) => id !== action.id );\n\n\t\tcase 'REMOVE_NOTICES':\n\t\t\treturn state.filter( ( { id } ) => ! action.ids.includes( id ) );\n\n\t\tcase 'REMOVE_ALL_NOTICES':\n\t\t\treturn state.filter( ( { type } ) => type !== action.noticeType );\n\n\t\tdefault:\n\t\t\treturn state;\n\t}\n} );\n\nexport default notices;\n"],
5
+ "mappings": ";AAIA,OAAO,cAAc;AAWrB,IAAM,UAAU,SAAU,SAAU,EAAqC,CACxE,QAAQ,CAAC,GACT,WACI;AACJ,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AAEJ,aAAO;AAAA,QACN,GAAG,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,OAAO,EAAG;AAAA,QACvD,OAAO;AAAA,MACR;AAAA,IAED,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,OAAO,OAAO,EAAG;AAAA,IAErD,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,GAAG,MAAO,CAAE,OAAO,IAAI,SAAU,EAAG,CAAE;AAAA,IAEhE,KAAK;AACJ,aAAO,MAAM,OAAQ,CAAE,EAAE,KAAK,MAAO,SAAS,OAAO,UAAW;AAAA,IAEjE;AACC,aAAO;AAAA,EACT;AACD,CAAE;AAEF,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/notices/src/store/selectors.js
1
+ // packages/notices/src/store/selectors.ts
2
2
  import { DEFAULT_CONTEXT } from "./constants.mjs";
3
3
  var DEFAULT_NOTICES = [];
4
4
  function getNotices(state, context = DEFAULT_CONTEXT) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/store/selectors.js"],
4
- "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 * 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 * @example\n *\n *```js\n * import { useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * return (\n * <ul>\n * { notices.map( ( notice ) => (\n * <li key={ notice.ID }>{ notice.content }</li>\n * ) ) }\n * </ul>\n * )\n * };\n *```\n *\n * @return {WPNotice[]} Array of notices.\n */\nexport function getNotices( state, context = DEFAULT_CONTEXT ) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"],
5
- "mappings": ";AAGA,SAAS,uBAAuB;AAahC,IAAM,kBAAkB,CAAC;AAsDlB,SAAS,WAAY,OAAO,UAAU,iBAAkB;AAC9D,SAAO,MAAO,OAAQ,KAAK;AAC5B;",
3
+ "sources": ["../../src/store/selectors.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT } from './constants';\nimport type { Notice } from './types';\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 */\nconst DEFAULT_NOTICES: Array< Notice > = [];\n\n/**\n * Returns all notices as an array, optionally for a given context. Defaults to\n * the global context.\n *\n * @param state Notices state.\n * @param context Optional grouping context.\n *\n * @example\n *\n *```js\n * import { useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * return (\n * <ul>\n * { notices.map( ( notice ) => (\n * <li key={ notice.ID }>{ notice.content }</li>\n * ) ) }\n * </ul>\n * )\n * };\n *```\n *\n * @return Array of notices.\n */\nexport function getNotices(\n\tstate: Record< string, Array< Notice > >,\n\tcontext: string = DEFAULT_CONTEXT\n) {\n\treturn state[ context ] || DEFAULT_NOTICES;\n}\n"],
5
+ "mappings": ";AAGA,SAAS,uBAAuB;AAWhC,IAAM,kBAAmC,CAAC;AA6BnC,SAAS,WACf,OACA,UAAkB,iBACjB;AACD,SAAO,MAAO,OAAQ,KAAK;AAC5B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- // packages/notices/src/store/utils/on-sub-key.js
1
+ // packages/notices/src/store/utils/on-sub-key.ts
2
2
  var onSubKey = (actionProperty) => (reducer) => (state = {}, action) => {
3
3
  const key = action[actionProperty];
4
4
  if (key === void 0) {