@wordpress/notices 5.32.0 → 5.32.1-next.b8c8708f3.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/build/index.js CHANGED
@@ -1,13 +1,29 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "store", {
7
- enumerable: true,
8
- get: function () {
9
- return _store.store;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
+ store: () => import_store.store
22
+ });
23
+ module.exports = __toCommonJS(index_exports);
24
+ var import_store = require("./store");
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ store
11
28
  });
12
- var _store = require("./store");
13
- //# sourceMappingURL=index.js.map
29
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_store","require"],"sources":["@wordpress/notices/src/index.js"],"sourcesContent":["export { store } from './store';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.js"],
4
+ "sourcesContent": ["export { store } from './store';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;",
6
+ "names": []
7
+ }
@@ -1,104 +1,51 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var actions_exports = {};
20
+ __export(actions_exports, {
21
+ createErrorNotice: () => createErrorNotice,
22
+ createInfoNotice: () => createInfoNotice,
23
+ createNotice: () => createNotice,
24
+ createSuccessNotice: () => createSuccessNotice,
25
+ createWarningNotice: () => createWarningNotice,
26
+ removeAllNotices: () => removeAllNotices,
27
+ removeNotice: () => removeNotice,
28
+ removeNotices: () => removeNotices
5
29
  });
6
- exports.createErrorNotice = createErrorNotice;
7
- exports.createInfoNotice = createInfoNotice;
8
- exports.createNotice = createNotice;
9
- exports.createSuccessNotice = createSuccessNotice;
10
- exports.createWarningNotice = createWarningNotice;
11
- exports.removeAllNotices = removeAllNotices;
12
- exports.removeNotice = removeNotice;
13
- exports.removeNotices = removeNotices;
14
- var _constants = require("./constants");
15
- /**
16
- * Internal dependencies
17
- */
18
-
19
- /**
20
- * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
21
- *
22
- * @property {string} label Message to use as action label.
23
- * @property {?string} url Optional URL of resource if action incurs
24
- * browser navigation.
25
- * @property {?Function} onClick Optional function to invoke when action is
26
- * triggered by user.
27
- */
28
-
30
+ module.exports = __toCommonJS(actions_exports);
31
+ var import_constants = require("./constants");
29
32
  let uniqueId = 0;
30
-
31
- /**
32
- * Returns an action object used in signalling that a notice is to be created.
33
- *
34
- * @param {string|undefined} status Notice status ("info" if undefined is passed).
35
- * @param {string} content Notice message.
36
- * @param {Object} [options] Notice options.
37
- * @param {string} [options.context='global'] Context under which to
38
- * group notice.
39
- * @param {string} [options.id] Identifier for notice.
40
- * Automatically assigned
41
- * if not specified.
42
- * @param {boolean} [options.isDismissible=true] Whether the notice can
43
- * be dismissed by user.
44
- * @param {string} [options.type='default'] Type of notice, one of
45
- * `default`, or `snackbar`.
46
- * @param {boolean} [options.speak=true] Whether the notice
47
- * content should be
48
- * announced to screen
49
- * readers.
50
- * @param {Array<WPNoticeAction>} [options.actions] User actions to be
51
- * presented with notice.
52
- * @param {string} [options.icon] An icon displayed with the notice.
53
- * Only used when type is set to `snackbar`.
54
- * @param {boolean} [options.explicitDismiss] Whether the notice includes
55
- * an explicit dismiss button and
56
- * can't be dismissed by clicking
57
- * the body of the notice. Only applies
58
- * when type is set to `snackbar`.
59
- * @param {Function} [options.onDismiss] Called when the notice is dismissed.
60
- *
61
- * @example
62
- * ```js
63
- * import { __ } from '@wordpress/i18n';
64
- * import { useDispatch } from '@wordpress/data';
65
- * import { store as noticesStore } from '@wordpress/notices';
66
- * import { Button } from '@wordpress/components';
67
- *
68
- * const ExampleComponent = () => {
69
- * const { createNotice } = useDispatch( noticesStore );
70
- * return (
71
- * <Button
72
- * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }
73
- * >
74
- * { __( 'Generate a success notice!' ) }
75
- * </Button>
76
- * );
77
- * };
78
- * ```
79
- *
80
- * @return {Object} Action object.
81
- */
82
- function createNotice(status = _constants.DEFAULT_STATUS, content, options = {}) {
33
+ function createNotice(status = import_constants.DEFAULT_STATUS, content, options = {}) {
83
34
  const {
84
35
  speak = true,
85
36
  isDismissible = true,
86
- context = _constants.DEFAULT_CONTEXT,
37
+ context = import_constants.DEFAULT_CONTEXT,
87
38
  id = `${context}${++uniqueId}`,
88
39
  actions = [],
89
- type = 'default',
40
+ type = "default",
90
41
  __unstableHTML,
91
42
  icon = null,
92
43
  explicitDismiss = false,
93
44
  onDismiss
94
45
  } = options;
95
-
96
- // The supported value shape of content is currently limited to plain text
97
- // strings. To avoid setting expectation that e.g. a React Element could be
98
- // supported, cast to a string.
99
46
  content = String(content);
100
47
  return {
101
- type: 'CREATE_NOTICE',
48
+ type: "CREATE_NOTICE",
102
49
  context,
103
50
  notice: {
104
51
  id,
@@ -115,313 +62,48 @@ function createNotice(status = _constants.DEFAULT_STATUS, content, options = {})
115
62
  }
116
63
  };
117
64
  }
118
-
119
- /**
120
- * Returns an action object used in signalling that a success notice is to be
121
- * created. Refer to `createNotice` for options documentation.
122
- *
123
- * @see createNotice
124
- *
125
- * @param {string} content Notice message.
126
- * @param {Object} [options] Optional notice options.
127
- *
128
- * @example
129
- * ```js
130
- * import { __ } from '@wordpress/i18n';
131
- * import { useDispatch } from '@wordpress/data';
132
- * import { store as noticesStore } from '@wordpress/notices';
133
- * import { Button } from '@wordpress/components';
134
- *
135
- * const ExampleComponent = () => {
136
- * const { createSuccessNotice } = useDispatch( noticesStore );
137
- * return (
138
- * <Button
139
- * onClick={ () =>
140
- * createSuccessNotice( __( 'Success!' ), {
141
- * type: 'snackbar',
142
- * icon: '🔥',
143
- * } )
144
- * }
145
- * >
146
- * { __( 'Generate a snackbar success notice!' ) }
147
- * </Button>
148
- * );
149
- * };
150
- * ```
151
- *
152
- * @return {Object} Action object.
153
- */
154
65
  function createSuccessNotice(content, options) {
155
- return createNotice('success', content, options);
66
+ return createNotice("success", content, options);
156
67
  }
157
-
158
- /**
159
- * Returns an action object used in signalling that an info notice is to be
160
- * created. Refer to `createNotice` for options documentation.
161
- *
162
- * @see createNotice
163
- *
164
- * @param {string} content Notice message.
165
- * @param {Object} [options] Optional notice options.
166
- *
167
- * @example
168
- * ```js
169
- * import { __ } from '@wordpress/i18n';
170
- * import { useDispatch } from '@wordpress/data';
171
- * import { store as noticesStore } from '@wordpress/notices';
172
- * import { Button } from '@wordpress/components';
173
- *
174
- * const ExampleComponent = () => {
175
- * const { createInfoNotice } = useDispatch( noticesStore );
176
- * return (
177
- * <Button
178
- * onClick={ () =>
179
- * createInfoNotice( __( 'Something happened!' ), {
180
- * isDismissible: false,
181
- * } )
182
- * }
183
- * >
184
- * { __( 'Generate a notice that cannot be dismissed.' ) }
185
- * </Button>
186
- * );
187
- * };
188
- *```
189
- *
190
- * @return {Object} Action object.
191
- */
192
68
  function createInfoNotice(content, options) {
193
- return createNotice('info', content, options);
69
+ return createNotice("info", content, options);
194
70
  }
195
-
196
- /**
197
- * Returns an action object used in signalling that an error notice is to be
198
- * created. Refer to `createNotice` for options documentation.
199
- *
200
- * @see createNotice
201
- *
202
- * @param {string} content Notice message.
203
- * @param {Object} [options] Optional notice options.
204
- *
205
- * @example
206
- * ```js
207
- * import { __ } from '@wordpress/i18n';
208
- * import { useDispatch } from '@wordpress/data';
209
- * import { store as noticesStore } from '@wordpress/notices';
210
- * import { Button } from '@wordpress/components';
211
- *
212
- * const ExampleComponent = () => {
213
- * const { createErrorNotice } = useDispatch( noticesStore );
214
- * return (
215
- * <Button
216
- * onClick={ () =>
217
- * createErrorNotice( __( 'An error occurred!' ), {
218
- * type: 'snackbar',
219
- * explicitDismiss: true,
220
- * } )
221
- * }
222
- * >
223
- * { __(
224
- * 'Generate a snackbar error notice with explicit dismiss button.'
225
- * ) }
226
- * </Button>
227
- * );
228
- * };
229
- * ```
230
- *
231
- * @return {Object} Action object.
232
- */
233
71
  function createErrorNotice(content, options) {
234
- return createNotice('error', content, options);
72
+ return createNotice("error", content, options);
235
73
  }
236
-
237
- /**
238
- * Returns an action object used in signalling that a warning notice is to be
239
- * created. Refer to `createNotice` for options documentation.
240
- *
241
- * @see createNotice
242
- *
243
- * @param {string} content Notice message.
244
- * @param {Object} [options] Optional notice options.
245
- *
246
- * @example
247
- * ```js
248
- * import { __ } from '@wordpress/i18n';
249
- * import { useDispatch } from '@wordpress/data';
250
- * import { store as noticesStore } from '@wordpress/notices';
251
- * import { Button } from '@wordpress/components';
252
- *
253
- * const ExampleComponent = () => {
254
- * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );
255
- * return (
256
- * <Button
257
- * onClick={ () =>
258
- * createWarningNotice( __( 'Warning!' ), {
259
- * onDismiss: () => {
260
- * createInfoNotice(
261
- * __( 'The warning has been dismissed!' )
262
- * );
263
- * },
264
- * } )
265
- * }
266
- * >
267
- * { __( 'Generates a warning notice with onDismiss callback' ) }
268
- * </Button>
269
- * );
270
- * };
271
- * ```
272
- *
273
- * @return {Object} Action object.
274
- */
275
74
  function createWarningNotice(content, options) {
276
- return createNotice('warning', content, options);
75
+ return createNotice("warning", content, options);
277
76
  }
278
-
279
- /**
280
- * Returns an action object used in signalling that a notice is to be removed.
281
- *
282
- * @param {string} id Notice unique identifier.
283
- * @param {string} [context='global'] Optional context (grouping) in which the notice is
284
- * intended to appear. Defaults to default context.
285
- *
286
- * @example
287
- * ```js
288
- * import { __ } from '@wordpress/i18n';
289
- * import { useDispatch } from '@wordpress/data';
290
- * import { store as noticesStore } from '@wordpress/notices';
291
- * import { Button } from '@wordpress/components';
292
- *
293
- * const ExampleComponent = () => {
294
- * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );
295
- * const { createWarningNotice, removeNotice } = useDispatch( noticesStore );
296
- *
297
- * return (
298
- * <>
299
- * <Button
300
- * onClick={ () =>
301
- * createWarningNotice( __( 'Warning!' ), {
302
- * isDismissible: false,
303
- * } )
304
- * }
305
- * >
306
- * { __( 'Generate a notice' ) }
307
- * </Button>
308
- * { notices.length > 0 && (
309
- * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>
310
- * { __( 'Remove the notice' ) }
311
- * </Button>
312
- * ) }
313
- * </>
314
- * );
315
- *};
316
- * ```
317
- *
318
- * @return {Object} Action object.
319
- */
320
- function removeNotice(id, context = _constants.DEFAULT_CONTEXT) {
77
+ function removeNotice(id, context = import_constants.DEFAULT_CONTEXT) {
321
78
  return {
322
- type: 'REMOVE_NOTICE',
79
+ type: "REMOVE_NOTICE",
323
80
  id,
324
81
  context
325
82
  };
326
83
  }
327
-
328
- /**
329
- * Removes all notices from a given context. Defaults to the default context.
330
- *
331
- * @param {string} noticeType The context to remove all notices from.
332
- * @param {string} context The context to remove all notices from.
333
- *
334
- * @example
335
- * ```js
336
- * import { __ } from '@wordpress/i18n';
337
- * import { useDispatch, useSelect } from '@wordpress/data';
338
- * import { store as noticesStore } from '@wordpress/notices';
339
- * import { Button } from '@wordpress/components';
340
- *
341
- * export const ExampleComponent = () => {
342
- * const notices = useSelect( ( select ) =>
343
- * select( noticesStore ).getNotices()
344
- * );
345
- * const { removeAllNotices } = useDispatch( noticesStore );
346
- * return (
347
- * <>
348
- * <ul>
349
- * { notices.map( ( notice ) => (
350
- * <li key={ notice.id }>{ notice.content }</li>
351
- * ) ) }
352
- * </ul>
353
- * <Button
354
- * onClick={ () =>
355
- * removeAllNotices()
356
- * }
357
- * >
358
- * { __( 'Clear all notices', 'woo-gutenberg-products-block' ) }
359
- * </Button>
360
- * <Button
361
- * onClick={ () =>
362
- * removeAllNotices( 'snackbar' )
363
- * }
364
- * >
365
- * { __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }
366
- * </Button>
367
- * </>
368
- * );
369
- * };
370
- * ```
371
- *
372
- * @return {Object} Action object.
373
- */
374
- function removeAllNotices(noticeType = 'default', context = _constants.DEFAULT_CONTEXT) {
84
+ function removeAllNotices(noticeType = "default", context = import_constants.DEFAULT_CONTEXT) {
375
85
  return {
376
- type: 'REMOVE_ALL_NOTICES',
86
+ type: "REMOVE_ALL_NOTICES",
377
87
  noticeType,
378
88
  context
379
89
  };
380
90
  }
381
-
382
- /**
383
- * Returns an action object used in signalling that several notices are to be removed.
384
- *
385
- * @param {string[]} ids List of unique notice identifiers.
386
- * @param {string} [context='global'] Optional context (grouping) in which the notices are
387
- * intended to appear. Defaults to default context.
388
- * @example
389
- * ```js
390
- * import { __ } from '@wordpress/i18n';
391
- * import { useDispatch, useSelect } from '@wordpress/data';
392
- * import { store as noticesStore } from '@wordpress/notices';
393
- * import { Button } from '@wordpress/components';
394
- *
395
- * const ExampleComponent = () => {
396
- * const notices = useSelect( ( select ) =>
397
- * select( noticesStore ).getNotices()
398
- * );
399
- * const { removeNotices } = useDispatch( noticesStore );
400
- * return (
401
- * <>
402
- * <ul>
403
- * { notices.map( ( notice ) => (
404
- * <li key={ notice.id }>{ notice.content }</li>
405
- * ) ) }
406
- * </ul>
407
- * <Button
408
- * onClick={ () =>
409
- * removeNotices( notices.map( ( { id } ) => id ) )
410
- * }
411
- * >
412
- * { __( 'Clear all notices' ) }
413
- * </Button>
414
- * </>
415
- * );
416
- * };
417
- * ```
418
- * @return {Object} Action object.
419
- */
420
- function removeNotices(ids, context = _constants.DEFAULT_CONTEXT) {
91
+ function removeNotices(ids, context = import_constants.DEFAULT_CONTEXT) {
421
92
  return {
422
- type: 'REMOVE_NOTICES',
93
+ type: "REMOVE_NOTICES",
423
94
  ids,
424
95
  context
425
96
  };
426
97
  }
427
- //# sourceMappingURL=actions.js.map
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ createErrorNotice,
101
+ createInfoNotice,
102
+ createNotice,
103
+ createSuccessNotice,
104
+ createWarningNotice,
105
+ removeAllNotices,
106
+ removeNotice,
107
+ removeNotices
108
+ });
109
+ //# sourceMappingURL=actions.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_constants","require","uniqueId","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","removeAllNotices","noticeType","removeNotices","ids"],"sources":["@wordpress/notices/src/store/actions.js"],"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: '🔥',\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"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAIC,QAAQ,GAAG,CAAC;;AAEhB;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAEC,MAAM,GAAGC,yBAAc,EAAEC,OAAO,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAG;EAC9E,MAAM;IACLC,KAAK,GAAG,IAAI;IACZC,aAAa,GAAG,IAAI;IACpBC,OAAO,GAAGC,0BAAe;IACzBC,EAAE,GAAG,GAAIF,OAAO,GAAK,EAAER,QAAQ,EAAG;IAClCW,OAAO,GAAG,EAAE;IACZC,IAAI,GAAG,SAAS;IAChBC,cAAc;IACdC,IAAI,GAAG,IAAI;IACXC,eAAe,GAAG,KAAK;IACvBC;EACD,CAAC,GAAGX,OAAO;;EAEX;EACA;EACA;EACAD,OAAO,GAAGa,MAAM,CAAEb,OAAQ,CAAC;EAE3B,OAAO;IACNQ,IAAI,EAAE,eAAe;IACrBJ,OAAO;IACPU,MAAM,EAAE;MACPR,EAAE;MACFR,MAAM;MACNE,OAAO;MACPe,aAAa,EAAEb,KAAK,GAAGF,OAAO,GAAG,IAAI;MACrCS,cAAc;MACdN,aAAa;MACbI,OAAO;MACPC,IAAI;MACJE,IAAI;MACJC,eAAe;MACfC;IACD;EACD,CAAC;AACF;;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;AACA;AACA;AACA;AACA;AACO,SAASI,mBAAmBA,CAAEhB,OAAO,EAAEC,OAAO,EAAG;EACvD,OAAOJ,YAAY,CAAE,SAAS,EAAEG,OAAO,EAAEC,OAAQ,CAAC;AACnD;;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;AACA;AACA;AACA;AACO,SAASgB,gBAAgBA,CAAEjB,OAAO,EAAEC,OAAO,EAAG;EACpD,OAAOJ,YAAY,CAAE,MAAM,EAAEG,OAAO,EAAEC,OAAQ,CAAC;AAChD;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiB,iBAAiBA,CAAElB,OAAO,EAAEC,OAAO,EAAG;EACrD,OAAOJ,YAAY,CAAE,OAAO,EAAEG,OAAO,EAAEC,OAAQ,CAAC;AACjD;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASkB,mBAAmBA,CAAEnB,OAAO,EAAEC,OAAO,EAAG;EACvD,OAAOJ,YAAY,CAAE,SAAS,EAAEG,OAAO,EAAEC,OAAQ,CAAC;AACnD;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASmB,YAAYA,CAAEd,EAAE,EAAEF,OAAO,GAAGC,0BAAe,EAAG;EAC7D,OAAO;IACNG,IAAI,EAAE,eAAe;IACrBF,EAAE;IACFF;EACD,CAAC;AACF;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiB,gBAAgBA,CAC/BC,UAAU,GAAG,SAAS,EACtBlB,OAAO,GAAGC,0BAAe,EACxB;EACD,OAAO;IACNG,IAAI,EAAE,oBAAoB;IAC1Bc,UAAU;IACVlB;EACD,CAAC;AACF;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASmB,aAAaA,CAAEC,GAAG,EAAEpB,OAAO,GAAGC,0BAAe,EAAG;EAC/D,OAAO;IACNG,IAAI,EAAE,gBAAgB;IACtBgB,GAAG;IACHpB;EACD,CAAC;AACF","ignoreList":[]}
1
+ {
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;",
6
+ "names": []
7
+ }
@@ -1,22 +1,32 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var constants_exports = {};
20
+ __export(constants_exports, {
21
+ DEFAULT_CONTEXT: () => DEFAULT_CONTEXT,
22
+ DEFAULT_STATUS: () => DEFAULT_STATUS
5
23
  });
6
- exports.DEFAULT_STATUS = exports.DEFAULT_CONTEXT = void 0;
7
- /**
8
- * Default context to use for notice grouping when not otherwise specified. Its
9
- * specific value doesn't hold much meaning, but it must be reasonably unique
10
- * and, more importantly, referenced consistently in the store implementation.
11
- *
12
- * @type {string}
13
- */
14
- const DEFAULT_CONTEXT = exports.DEFAULT_CONTEXT = 'global';
15
-
16
- /**
17
- * Default notice status.
18
- *
19
- * @type {string}
20
- */
21
- const DEFAULT_STATUS = exports.DEFAULT_STATUS = 'info';
22
- //# sourceMappingURL=constants.js.map
24
+ module.exports = __toCommonJS(constants_exports);
25
+ const DEFAULT_CONTEXT = "global";
26
+ const DEFAULT_STATUS = "info";
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ DEFAULT_CONTEXT,
30
+ DEFAULT_STATUS
31
+ });
32
+ //# sourceMappingURL=constants.js.map