Bez popisu

notices.js 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. this["wp"] = this["wp"] || {}; this["wp"]["notices"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = "Ko7W");
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ "1ZqX":
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = window["wp"]["data"]; }());
  92. /***/ }),
  93. /***/ "Ko7W":
  94. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95. "use strict";
  96. // ESM COMPAT FLAG
  97. __webpack_require__.r(__webpack_exports__);
  98. // EXPORTS
  99. __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
  100. // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
  101. var actions_namespaceObject = {};
  102. __webpack_require__.r(actions_namespaceObject);
  103. __webpack_require__.d(actions_namespaceObject, "createNotice", function() { return createNotice; });
  104. __webpack_require__.d(actions_namespaceObject, "createSuccessNotice", function() { return createSuccessNotice; });
  105. __webpack_require__.d(actions_namespaceObject, "createInfoNotice", function() { return createInfoNotice; });
  106. __webpack_require__.d(actions_namespaceObject, "createErrorNotice", function() { return createErrorNotice; });
  107. __webpack_require__.d(actions_namespaceObject, "createWarningNotice", function() { return createWarningNotice; });
  108. __webpack_require__.d(actions_namespaceObject, "removeNotice", function() { return removeNotice; });
  109. // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
  110. var selectors_namespaceObject = {};
  111. __webpack_require__.r(selectors_namespaceObject);
  112. __webpack_require__.d(selectors_namespaceObject, "getNotices", function() { return getNotices; });
  113. // EXTERNAL MODULE: external ["wp","data"]
  114. var external_wp_data_ = __webpack_require__("1ZqX");
  115. // EXTERNAL MODULE: external "lodash"
  116. var external_lodash_ = __webpack_require__("YLtl");
  117. // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
  118. /**
  119. * Higher-order reducer creator which creates a combined reducer object, keyed
  120. * by a property on the action object.
  121. *
  122. * @param {string} actionProperty Action property by which to key object.
  123. *
  124. * @return {Function} Higher-order reducer.
  125. */
  126. const onSubKey = actionProperty => reducer => (state = {}, action) => {
  127. // Retrieve subkey from action. Do not track if undefined; useful for cases
  128. // where reducer is scoped by action shape.
  129. const key = action[actionProperty];
  130. if (key === undefined) {
  131. return state;
  132. } // Avoid updating state if unchanged. Note that this also accounts for a
  133. // reducer which returns undefined on a key which is not yet tracked.
  134. const nextKeyState = reducer(state[key], action);
  135. if (nextKeyState === state[key]) {
  136. return state;
  137. }
  138. return { ...state,
  139. [key]: nextKeyState
  140. };
  141. };
  142. /* harmony default export */ var on_sub_key = (onSubKey);
  143. // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
  144. /**
  145. * External dependencies
  146. */
  147. /**
  148. * Internal dependencies
  149. */
  150. /**
  151. * Reducer returning the next notices state. The notices state is an object
  152. * where each key is a context, its value an array of notice objects.
  153. *
  154. * @param {Object} state Current state.
  155. * @param {Object} action Dispatched action.
  156. *
  157. * @return {Object} Updated state.
  158. */
  159. const notices = on_sub_key('context')((state = [], action) => {
  160. switch (action.type) {
  161. case 'CREATE_NOTICE':
  162. // Avoid duplicates on ID.
  163. return [...Object(external_lodash_["reject"])(state, {
  164. id: action.notice.id
  165. }), action.notice];
  166. case 'REMOVE_NOTICE':
  167. return Object(external_lodash_["reject"])(state, {
  168. id: action.id
  169. });
  170. }
  171. return state;
  172. });
  173. /* harmony default export */ var reducer = (notices);
  174. // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
  175. /**
  176. * Default context to use for notice grouping when not otherwise specified. Its
  177. * specific value doesn't hold much meaning, but it must be reasonably unique
  178. * and, more importantly, referenced consistently in the store implementation.
  179. *
  180. * @type {string}
  181. */
  182. const DEFAULT_CONTEXT = 'global';
  183. /**
  184. * Default notice status.
  185. *
  186. * @type {string}
  187. */
  188. const DEFAULT_STATUS = 'info';
  189. // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
  190. /**
  191. * External dependencies
  192. */
  193. /**
  194. * Internal dependencies
  195. */
  196. /**
  197. * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
  198. *
  199. * @property {string} label Message to use as action label.
  200. * @property {?string} url Optional URL of resource if action incurs
  201. * browser navigation.
  202. * @property {?Function} onClick Optional function to invoke when action is
  203. * triggered by user.
  204. *
  205. */
  206. /**
  207. * Returns an action object used in signalling that a notice is to be created.
  208. *
  209. * @param {string} [status='info'] Notice status.
  210. * @param {string} content Notice message.
  211. * @param {Object} [options] Notice options.
  212. * @param {string} [options.context='global'] Context under which to
  213. * group notice.
  214. * @param {string} [options.id] Identifier for notice.
  215. * Automatically assigned
  216. * if not specified.
  217. * @param {boolean} [options.isDismissible=true] Whether the notice can
  218. * be dismissed by user.
  219. * @param {string} [options.type='default'] Type of notice, one of
  220. * `default`, or `snackbar`.
  221. * @param {boolean} [options.speak=true] Whether the notice
  222. * content should be
  223. * announced to screen
  224. * readers.
  225. * @param {Array<WPNoticeAction>} [options.actions] User actions to be
  226. * presented with notice.
  227. * @param {Object} [options.icon] An icon displayed with the notice.
  228. * @param {boolean} [options.explicitDismiss] Whether the notice includes
  229. * an explict dismiss button and
  230. * can't be dismissed by clicking
  231. * the body of the notice.
  232. * @param {Function} [options.onDismiss] Called when the notice is dismissed.
  233. *
  234. * @return {Object} Action object.
  235. */
  236. function createNotice(status = DEFAULT_STATUS, content, options = {}) {
  237. const {
  238. speak = true,
  239. isDismissible = true,
  240. context = DEFAULT_CONTEXT,
  241. id = Object(external_lodash_["uniqueId"])(context),
  242. actions = [],
  243. type = 'default',
  244. __unstableHTML,
  245. icon = null,
  246. explicitDismiss = false,
  247. onDismiss = null
  248. } = options; // The supported value shape of content is currently limited to plain text
  249. // strings. To avoid setting expectation that e.g. a WPElement could be
  250. // supported, cast to a string.
  251. content = String(content);
  252. return {
  253. type: 'CREATE_NOTICE',
  254. context,
  255. notice: {
  256. id,
  257. status,
  258. content,
  259. spokenMessage: speak ? content : null,
  260. __unstableHTML,
  261. isDismissible,
  262. actions,
  263. type,
  264. icon,
  265. explicitDismiss,
  266. onDismiss
  267. }
  268. };
  269. }
  270. /**
  271. * Returns an action object used in signalling that a success notice is to be
  272. * created. Refer to `createNotice` for options documentation.
  273. *
  274. * @see createNotice
  275. *
  276. * @param {string} content Notice message.
  277. * @param {Object} [options] Optional notice options.
  278. *
  279. * @return {Object} Action object.
  280. */
  281. function createSuccessNotice(content, options) {
  282. return createNotice('success', content, options);
  283. }
  284. /**
  285. * Returns an action object used in signalling that an info notice is to be
  286. * created. Refer to `createNotice` for options documentation.
  287. *
  288. * @see createNotice
  289. *
  290. * @param {string} content Notice message.
  291. * @param {Object} [options] Optional notice options.
  292. *
  293. * @return {Object} Action object.
  294. */
  295. function createInfoNotice(content, options) {
  296. return createNotice('info', content, options);
  297. }
  298. /**
  299. * Returns an action object used in signalling that an error notice is to be
  300. * created. Refer to `createNotice` for options documentation.
  301. *
  302. * @see createNotice
  303. *
  304. * @param {string} content Notice message.
  305. * @param {Object} [options] Optional notice options.
  306. *
  307. * @return {Object} Action object.
  308. */
  309. function createErrorNotice(content, options) {
  310. return createNotice('error', content, options);
  311. }
  312. /**
  313. * Returns an action object used in signalling that a warning notice is to be
  314. * created. Refer to `createNotice` for options documentation.
  315. *
  316. * @see createNotice
  317. *
  318. * @param {string} content Notice message.
  319. * @param {Object} [options] Optional notice options.
  320. *
  321. * @return {Object} Action object.
  322. */
  323. function createWarningNotice(content, options) {
  324. return createNotice('warning', content, options);
  325. }
  326. /**
  327. * Returns an action object used in signalling that a notice is to be removed.
  328. *
  329. * @param {string} id Notice unique identifier.
  330. * @param {string} [context='global'] Optional context (grouping) in which the notice is
  331. * intended to appear. Defaults to default context.
  332. *
  333. * @return {Object} Action object.
  334. */
  335. function removeNotice(id, context = DEFAULT_CONTEXT) {
  336. return {
  337. type: 'REMOVE_NOTICE',
  338. id,
  339. context
  340. };
  341. }
  342. // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
  343. /**
  344. * Internal dependencies
  345. */
  346. /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
  347. /**
  348. * The default empty set of notices to return when there are no notices
  349. * assigned for a given notices context. This can occur if the getNotices
  350. * selector is called without a notice ever having been created for the
  351. * context. A shared value is used to ensure referential equality between
  352. * sequential selector calls, since otherwise `[] !== []`.
  353. *
  354. * @type {Array}
  355. */
  356. const DEFAULT_NOTICES = [];
  357. /**
  358. * @typedef {Object} WPNotice Notice object.
  359. *
  360. * @property {string} id Unique identifier of notice.
  361. * @property {string} status Status of notice, one of `success`,
  362. * `info`, `error`, or `warning`. Defaults
  363. * to `info`.
  364. * @property {string} content Notice message.
  365. * @property {string} spokenMessage Audibly announced message text used by
  366. * assistive technologies.
  367. * @property {string} __unstableHTML Notice message as raw HTML. Intended to
  368. * serve primarily for compatibility of
  369. * server-rendered notices, and SHOULD NOT
  370. * be used for notices. It is subject to
  371. * removal without notice.
  372. * @property {boolean} isDismissible Whether the notice can be dismissed by
  373. * user. Defaults to `true`.
  374. * @property {string} type Type of notice, one of `default`,
  375. * or `snackbar`. Defaults to `default`.
  376. * @property {boolean} speak Whether the notice content should be
  377. * announced to screen readers. Defaults to
  378. * `true`.
  379. * @property {WPNoticeAction[]} actions User actions to present with notice.
  380. *
  381. */
  382. /**
  383. * Returns all notices as an array, optionally for a given context. Defaults to
  384. * the global context.
  385. *
  386. * @param {Object} state Notices state.
  387. * @param {?string} context Optional grouping context.
  388. *
  389. * @return {WPNotice[]} Array of notices.
  390. */
  391. function getNotices(state, context = DEFAULT_CONTEXT) {
  392. return state[context] || DEFAULT_NOTICES;
  393. }
  394. // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
  395. /**
  396. * WordPress dependencies
  397. */
  398. /**
  399. * Internal dependencies
  400. */
  401. /**
  402. * Store definition for the notices namespace.
  403. *
  404. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  405. *
  406. * @type {Object}
  407. */
  408. const store = Object(external_wp_data_["createReduxStore"])('core/notices', {
  409. reducer: reducer,
  410. actions: actions_namespaceObject,
  411. selectors: selectors_namespaceObject
  412. });
  413. Object(external_wp_data_["register"])(store);
  414. // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
  415. /***/ }),
  416. /***/ "YLtl":
  417. /***/ (function(module, exports) {
  418. (function() { module.exports = window["lodash"]; }());
  419. /***/ })
  420. /******/ });