You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

673 lines
22 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ "use strict";
  3. /******/ // The require scope
  4. /******/ var __webpack_require__ = {};
  5. /******/
  6. /************************************************************************/
  7. /******/ /* webpack/runtime/define property getters */
  8. /******/ !function() {
  9. /******/ // define getter functions for harmony exports
  10. /******/ __webpack_require__.d = function(exports, definition) {
  11. /******/ for(var key in definition) {
  12. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14. /******/ }
  15. /******/ }
  16. /******/ };
  17. /******/ }();
  18. /******/
  19. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  20. /******/ !function() {
  21. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  22. /******/ }();
  23. /******/
  24. /******/ /* webpack/runtime/make namespace object */
  25. /******/ !function() {
  26. /******/ // define __esModule on exports
  27. /******/ __webpack_require__.r = function(exports) {
  28. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30. /******/ }
  31. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  32. /******/ };
  33. /******/ }();
  34. /******/
  35. /************************************************************************/
  36. var __webpack_exports__ = {};
  37. // ESM COMPAT FLAG
  38. __webpack_require__.r(__webpack_exports__);
  39. // EXPORTS
  40. __webpack_require__.d(__webpack_exports__, {
  41. store: function() { return /* reexport */ store; }
  42. });
  43. // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
  44. var actions_namespaceObject = {};
  45. __webpack_require__.r(actions_namespaceObject);
  46. __webpack_require__.d(actions_namespaceObject, {
  47. createErrorNotice: function() { return createErrorNotice; },
  48. createInfoNotice: function() { return createInfoNotice; },
  49. createNotice: function() { return createNotice; },
  50. createSuccessNotice: function() { return createSuccessNotice; },
  51. createWarningNotice: function() { return createWarningNotice; },
  52. removeAllNotices: function() { return removeAllNotices; },
  53. removeNotice: function() { return removeNotice; },
  54. removeNotices: function() { return removeNotices; }
  55. });
  56. // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
  57. var selectors_namespaceObject = {};
  58. __webpack_require__.r(selectors_namespaceObject);
  59. __webpack_require__.d(selectors_namespaceObject, {
  60. getNotices: function() { return getNotices; }
  61. });
  62. ;// CONCATENATED MODULE: external ["wp","data"]
  63. var external_wp_data_namespaceObject = window["wp"]["data"];
  64. ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
  65. /**
  66. * Higher-order reducer creator which creates a combined reducer object, keyed
  67. * by a property on the action object.
  68. *
  69. * @param {string} actionProperty Action property by which to key object.
  70. *
  71. * @return {Function} Higher-order reducer.
  72. */
  73. const onSubKey = actionProperty => reducer => (state = {}, action) => {
  74. // Retrieve subkey from action. Do not track if undefined; useful for cases
  75. // where reducer is scoped by action shape.
  76. const key = action[actionProperty];
  77. if (key === undefined) {
  78. return state;
  79. }
  80. // Avoid updating state if unchanged. Note that this also accounts for a
  81. // reducer which returns undefined on a key which is not yet tracked.
  82. const nextKeyState = reducer(state[key], action);
  83. if (nextKeyState === state[key]) {
  84. return state;
  85. }
  86. return {
  87. ...state,
  88. [key]: nextKeyState
  89. };
  90. };
  91. /* harmony default export */ var on_sub_key = (onSubKey);
  92. ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
  93. /**
  94. * Internal dependencies
  95. */
  96. /**
  97. * Reducer returning the next notices state. The notices state is an object
  98. * where each key is a context, its value an array of notice objects.
  99. *
  100. * @param {Object} state Current state.
  101. * @param {Object} action Dispatched action.
  102. *
  103. * @return {Object} Updated state.
  104. */
  105. const notices = on_sub_key('context')((state = [], action) => {
  106. switch (action.type) {
  107. case 'CREATE_NOTICE':
  108. // Avoid duplicates on ID.
  109. return [...state.filter(({
  110. id
  111. }) => id !== action.notice.id), action.notice];
  112. case 'REMOVE_NOTICE':
  113. return state.filter(({
  114. id
  115. }) => id !== action.id);
  116. case 'REMOVE_NOTICES':
  117. return state.filter(({
  118. id
  119. }) => !action.ids.includes(id));
  120. case 'REMOVE_ALL_NOTICES':
  121. return state.filter(({
  122. type
  123. }) => type !== action.noticeType);
  124. }
  125. return state;
  126. });
  127. /* harmony default export */ var reducer = (notices);
  128. ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
  129. /**
  130. * Default context to use for notice grouping when not otherwise specified. Its
  131. * specific value doesn't hold much meaning, but it must be reasonably unique
  132. * and, more importantly, referenced consistently in the store implementation.
  133. *
  134. * @type {string}
  135. */
  136. const DEFAULT_CONTEXT = 'global';
  137. /**
  138. * Default notice status.
  139. *
  140. * @type {string}
  141. */
  142. const DEFAULT_STATUS = 'info';
  143. ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
  144. /**
  145. * Internal dependencies
  146. */
  147. /**
  148. * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
  149. *
  150. * @property {string} label Message to use as action label.
  151. * @property {?string} url Optional URL of resource if action incurs
  152. * browser navigation.
  153. * @property {?Function} onClick Optional function to invoke when action is
  154. * triggered by user.
  155. */
  156. let uniqueId = 0;
  157. /**
  158. * Returns an action object used in signalling that a notice is to be created.
  159. *
  160. * @param {string|undefined} status Notice status ("info" if undefined is passed).
  161. * @param {string} content Notice message.
  162. * @param {Object} [options] Notice options.
  163. * @param {string} [options.context='global'] Context under which to
  164. * group notice.
  165. * @param {string} [options.id] Identifier for notice.
  166. * Automatically assigned
  167. * if not specified.
  168. * @param {boolean} [options.isDismissible=true] Whether the notice can
  169. * be dismissed by user.
  170. * @param {string} [options.type='default'] Type of notice, one of
  171. * `default`, or `snackbar`.
  172. * @param {boolean} [options.speak=true] Whether the notice
  173. * content should be
  174. * announced to screen
  175. * readers.
  176. * @param {Array<WPNoticeAction>} [options.actions] User actions to be
  177. * presented with notice.
  178. * @param {string} [options.icon] An icon displayed with the notice.
  179. * Only used when type is set to `snackbar`.
  180. * @param {boolean} [options.explicitDismiss] Whether the notice includes
  181. * an explicit dismiss button and
  182. * can't be dismissed by clicking
  183. * the body of the notice. Only applies
  184. * when type is set to `snackbar`.
  185. * @param {Function} [options.onDismiss] Called when the notice is dismissed.
  186. *
  187. * @example
  188. * ```js
  189. * import { __ } from '@wordpress/i18n';
  190. * import { useDispatch } from '@wordpress/data';
  191. * import { store as noticesStore } from '@wordpress/notices';
  192. * import { Button } from '@wordpress/components';
  193. *
  194. * const ExampleComponent = () => {
  195. * const { createNotice } = useDispatch( noticesStore );
  196. * return (
  197. * <Button
  198. * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }
  199. * >
  200. * { __( 'Generate a success notice!' ) }
  201. * </Button>
  202. * );
  203. * };
  204. * ```
  205. *
  206. * @return {Object} Action object.
  207. */
  208. function createNotice(status = DEFAULT_STATUS, content, options = {}) {
  209. const {
  210. speak = true,
  211. isDismissible = true,
  212. context = DEFAULT_CONTEXT,
  213. id = `${context}${++uniqueId}`,
  214. actions = [],
  215. type = 'default',
  216. __unstableHTML,
  217. icon = null,
  218. explicitDismiss = false,
  219. onDismiss
  220. } = options;
  221. // The supported value shape of content is currently limited to plain text
  222. // strings. To avoid setting expectation that e.g. a WPElement could be
  223. // supported, cast to a string.
  224. content = String(content);
  225. return {
  226. type: 'CREATE_NOTICE',
  227. context,
  228. notice: {
  229. id,
  230. status,
  231. content,
  232. spokenMessage: speak ? content : null,
  233. __unstableHTML,
  234. isDismissible,
  235. actions,
  236. type,
  237. icon,
  238. explicitDismiss,
  239. onDismiss
  240. }
  241. };
  242. }
  243. /**
  244. * Returns an action object used in signalling that a success notice is to be
  245. * created. Refer to `createNotice` for options documentation.
  246. *
  247. * @see createNotice
  248. *
  249. * @param {string} content Notice message.
  250. * @param {Object} [options] Optional notice options.
  251. *
  252. * @example
  253. * ```js
  254. * import { __ } from '@wordpress/i18n';
  255. * import { useDispatch } from '@wordpress/data';
  256. * import { store as noticesStore } from '@wordpress/notices';
  257. * import { Button } from '@wordpress/components';
  258. *
  259. * const ExampleComponent = () => {
  260. * const { createSuccessNotice } = useDispatch( noticesStore );
  261. * return (
  262. * <Button
  263. * onClick={ () =>
  264. * createSuccessNotice( __( 'Success!' ), {
  265. * type: 'snackbar',
  266. * icon: '🔥',
  267. * } )
  268. * }
  269. * >
  270. * { __( 'Generate a snackbar success notice!' ) }
  271. * </Button>
  272. * );
  273. * };
  274. * ```
  275. *
  276. * @return {Object} Action object.
  277. */
  278. function createSuccessNotice(content, options) {
  279. return createNotice('success', content, options);
  280. }
  281. /**
  282. * Returns an action object used in signalling that an info notice is to be
  283. * created. Refer to `createNotice` for options documentation.
  284. *
  285. * @see createNotice
  286. *
  287. * @param {string} content Notice message.
  288. * @param {Object} [options] Optional notice options.
  289. *
  290. * @example
  291. * ```js
  292. * import { __ } from '@wordpress/i18n';
  293. * import { useDispatch } from '@wordpress/data';
  294. * import { store as noticesStore } from '@wordpress/notices';
  295. * import { Button } from '@wordpress/components';
  296. *
  297. * const ExampleComponent = () => {
  298. * const { createInfoNotice } = useDispatch( noticesStore );
  299. * return (
  300. * <Button
  301. * onClick={ () =>
  302. * createInfoNotice( __( 'Something happened!' ), {
  303. * isDismissible: false,
  304. * } )
  305. * }
  306. * >
  307. * { __( 'Generate a notice that cannot be dismissed.' ) }
  308. * </Button>
  309. * );
  310. * };
  311. *```
  312. *
  313. * @return {Object} Action object.
  314. */
  315. function createInfoNotice(content, options) {
  316. return createNotice('info', content, options);
  317. }
  318. /**
  319. * Returns an action object used in signalling that an error notice is to be
  320. * created. Refer to `createNotice` for options documentation.
  321. *
  322. * @see createNotice
  323. *
  324. * @param {string} content Notice message.
  325. * @param {Object} [options] Optional notice options.
  326. *
  327. * @example
  328. * ```js
  329. * import { __ } from '@wordpress/i18n';
  330. * import { useDispatch } from '@wordpress/data';
  331. * import { store as noticesStore } from '@wordpress/notices';
  332. * import { Button } from '@wordpress/components';
  333. *
  334. * const ExampleComponent = () => {
  335. * const { createErrorNotice } = useDispatch( noticesStore );
  336. * return (
  337. * <Button
  338. * onClick={ () =>
  339. * createErrorNotice( __( 'An error occurred!' ), {
  340. * type: 'snackbar',
  341. * explicitDismiss: true,
  342. * } )
  343. * }
  344. * >
  345. * { __(
  346. * 'Generate an snackbar error notice with explicit dismiss button.'
  347. * ) }
  348. * </Button>
  349. * );
  350. * };
  351. * ```
  352. *
  353. * @return {Object} Action object.
  354. */
  355. function createErrorNotice(content, options) {
  356. return createNotice('error', content, options);
  357. }
  358. /**
  359. * Returns an action object used in signalling that a warning notice is to be
  360. * created. Refer to `createNotice` for options documentation.
  361. *
  362. * @see createNotice
  363. *
  364. * @param {string} content Notice message.
  365. * @param {Object} [options] Optional notice options.
  366. *
  367. * @example
  368. * ```js
  369. * import { __ } from '@wordpress/i18n';
  370. * import { useDispatch } from '@wordpress/data';
  371. * import { store as noticesStore } from '@wordpress/notices';
  372. * import { Button } from '@wordpress/components';
  373. *
  374. * const ExampleComponent = () => {
  375. * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );
  376. * return (
  377. * <Button
  378. * onClick={ () =>
  379. * createWarningNotice( __( 'Warning!' ), {
  380. * onDismiss: () => {
  381. * createInfoNotice(
  382. * __( 'The warning has been dismissed!' )
  383. * );
  384. * },
  385. * } )
  386. * }
  387. * >
  388. * { __( 'Generates a warning notice with onDismiss callback' ) }
  389. * </Button>
  390. * );
  391. * };
  392. * ```
  393. *
  394. * @return {Object} Action object.
  395. */
  396. function createWarningNotice(content, options) {
  397. return createNotice('warning', content, options);
  398. }
  399. /**
  400. * Returns an action object used in signalling that a notice is to be removed.
  401. *
  402. * @param {string} id Notice unique identifier.
  403. * @param {string} [context='global'] Optional context (grouping) in which the notice is
  404. * intended to appear. Defaults to default context.
  405. *
  406. * @example
  407. * ```js
  408. * import { __ } from '@wordpress/i18n';
  409. * import { useDispatch } from '@wordpress/data';
  410. * import { store as noticesStore } from '@wordpress/notices';
  411. * import { Button } from '@wordpress/components';
  412. *
  413. * const ExampleComponent = () => {
  414. * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );
  415. * const { createWarningNotice, removeNotice } = useDispatch( noticesStore );
  416. *
  417. * return (
  418. * <>
  419. * <Button
  420. * onClick={ () =>
  421. * createWarningNotice( __( 'Warning!' ), {
  422. * isDismissible: false,
  423. * } )
  424. * }
  425. * >
  426. * { __( 'Generate a notice' ) }
  427. * </Button>
  428. * { notices.length > 0 && (
  429. * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>
  430. * { __( 'Remove the notice' ) }
  431. * </Button>
  432. * ) }
  433. * </>
  434. * );
  435. *};
  436. * ```
  437. *
  438. * @return {Object} Action object.
  439. */
  440. function removeNotice(id, context = DEFAULT_CONTEXT) {
  441. return {
  442. type: 'REMOVE_NOTICE',
  443. id,
  444. context
  445. };
  446. }
  447. /**
  448. * Removes all notices from a given context. Defaults to the default context.
  449. *
  450. * @param {string} noticeType The context to remove all notices from.
  451. * @param {string} context The context to remove all notices from.
  452. *
  453. * @example
  454. * ```js
  455. * import { __ } from '@wordpress/i18n';
  456. * import { useDispatch, useSelect } from '@wordpress/data';
  457. * import { store as noticesStore } from '@wordpress/notices';
  458. * import { Button } from '@wordpress/components';
  459. *
  460. * export const ExampleComponent = () => {
  461. * const notices = useSelect( ( select ) =>
  462. * select( noticesStore ).getNotices()
  463. * );
  464. * const { removeNotices } = useDispatch( noticesStore );
  465. * return (
  466. * <>
  467. * <ul>
  468. * { notices.map( ( notice ) => (
  469. * <li key={ notice.id }>{ notice.content }</li>
  470. * ) ) }
  471. * </ul>
  472. * <Button
  473. * onClick={ () =>
  474. * removeAllNotices()
  475. * }
  476. * >
  477. * { __( 'Clear all notices', 'woo-gutenberg-products-block' ) }
  478. * </Button>
  479. * <Button
  480. * onClick={ () =>
  481. * removeAllNotices( 'snackbar' )
  482. * }
  483. * >
  484. * { __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }
  485. * </Button>
  486. * </>
  487. * );
  488. * };
  489. * ```
  490. *
  491. * @return {Object} Action object.
  492. */
  493. function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) {
  494. return {
  495. type: 'REMOVE_ALL_NOTICES',
  496. noticeType,
  497. context
  498. };
  499. }
  500. /**
  501. * Returns an action object used in signalling that several notices are to be removed.
  502. *
  503. * @param {string[]} ids List of unique notice identifiers.
  504. * @param {string} [context='global'] Optional context (grouping) in which the notices are
  505. * intended to appear. Defaults to default context.
  506. * @example
  507. * ```js
  508. * import { __ } from '@wordpress/i18n';
  509. * import { useDispatch, useSelect } from '@wordpress/data';
  510. * import { store as noticesStore } from '@wordpress/notices';
  511. * import { Button } from '@wordpress/components';
  512. *
  513. * const ExampleComponent = () => {
  514. * const notices = useSelect( ( select ) =>
  515. * select( noticesStore ).getNotices()
  516. * );
  517. * const { removeNotices } = useDispatch( noticesStore );
  518. * return (
  519. * <>
  520. * <ul>
  521. * { notices.map( ( notice ) => (
  522. * <li key={ notice.id }>{ notice.content }</li>
  523. * ) ) }
  524. * </ul>
  525. * <Button
  526. * onClick={ () =>
  527. * removeNotices( notices.map( ( { id } ) => id ) )
  528. * }
  529. * >
  530. * { __( 'Clear all notices' ) }
  531. * </Button>
  532. * </>
  533. * );
  534. * };
  535. * ```
  536. * @return {Object} Action object.
  537. */
  538. function removeNotices(ids, context = DEFAULT_CONTEXT) {
  539. return {
  540. type: 'REMOVE_NOTICES',
  541. ids,
  542. context
  543. };
  544. }
  545. ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
  546. /**
  547. * Internal dependencies
  548. */
  549. /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
  550. /**
  551. * The default empty set of notices to return when there are no notices
  552. * assigned for a given notices context. This can occur if the getNotices
  553. * selector is called without a notice ever having been created for the
  554. * context. A shared value is used to ensure referential equality between
  555. * sequential selector calls, since otherwise `[] !== []`.
  556. *
  557. * @type {Array}
  558. */
  559. const DEFAULT_NOTICES = [];
  560. /**
  561. * @typedef {Object} WPNotice Notice object.
  562. *
  563. * @property {string} id Unique identifier of notice.
  564. * @property {string} status Status of notice, one of `success`,
  565. * `info`, `error`, or `warning`. Defaults
  566. * to `info`.
  567. * @property {string} content Notice message.
  568. * @property {string} spokenMessage Audibly announced message text used by
  569. * assistive technologies.
  570. * @property {string} __unstableHTML Notice message as raw HTML. Intended to
  571. * serve primarily for compatibility of
  572. * server-rendered notices, and SHOULD NOT
  573. * be used for notices. It is subject to
  574. * removal without notice.
  575. * @property {boolean} isDismissible Whether the notice can be dismissed by
  576. * user. Defaults to `true`.
  577. * @property {string} type Type of notice, one of `default`,
  578. * or `snackbar`. Defaults to `default`.
  579. * @property {boolean} speak Whether the notice content should be
  580. * announced to screen readers. Defaults to
  581. * `true`.
  582. * @property {WPNoticeAction[]} actions User actions to present with notice.
  583. */
  584. /**
  585. * Returns all notices as an array, optionally for a given context. Defaults to
  586. * the global context.
  587. *
  588. * @param {Object} state Notices state.
  589. * @param {?string} context Optional grouping context.
  590. *
  591. * @example
  592. *
  593. *```js
  594. * import { useSelect } from '@wordpress/data';
  595. * import { store as noticesStore } from '@wordpress/notices';
  596. *
  597. * const ExampleComponent = () => {
  598. * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );
  599. * return (
  600. * <ul>
  601. * { notices.map( ( notice ) => (
  602. * <li key={ notice.ID }>{ notice.content }</li>
  603. * ) ) }
  604. * </ul>
  605. * )
  606. * };
  607. *```
  608. *
  609. * @return {WPNotice[]} Array of notices.
  610. */
  611. function getNotices(state, context = DEFAULT_CONTEXT) {
  612. return state[context] || DEFAULT_NOTICES;
  613. }
  614. ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
  615. /**
  616. * WordPress dependencies
  617. */
  618. /**
  619. * Internal dependencies
  620. */
  621. /**
  622. * Store definition for the notices namespace.
  623. *
  624. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  625. */
  626. const store = (0,external_wp_data_namespaceObject.createReduxStore)('core/notices', {
  627. reducer: reducer,
  628. actions: actions_namespaceObject,
  629. selectors: selectors_namespaceObject
  630. });
  631. (0,external_wp_data_namespaceObject.register)(store);
  632. ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
  633. (window.wp = window.wp || {}).notices = __webpack_exports__;
  634. /******/ })()
  635. ;