wp/wp-includes/js/dist/notices.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    80 /******/ 	// __webpack_public_path__
    80 /******/ 	// __webpack_public_path__
    81 /******/ 	__webpack_require__.p = "";
    81 /******/ 	__webpack_require__.p = "";
    82 /******/
    82 /******/
    83 /******/
    83 /******/
    84 /******/ 	// Load entry module and return exports
    84 /******/ 	// Load entry module and return exports
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 455);
    85 /******/ 	return __webpack_require__(__webpack_require__.s = "Ko7W");
    86 /******/ })
    86 /******/ })
    87 /************************************************************************/
    87 /************************************************************************/
    88 /******/ ({
    88 /******/ ({
    89 
    89 
    90 /***/ 18:
    90 /***/ "1ZqX":
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    91 /***/ (function(module, exports) {
    92 
    92 
    93 "use strict";
    93 (function() { module.exports = window["wp"]["data"]; }());
    94 
       
    95 // EXPORTS
       
    96 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; });
       
    97 
       
    98 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
       
    99 var arrayLikeToArray = __webpack_require__(26);
       
   100 
       
   101 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
       
   102 
       
   103 function _arrayWithoutHoles(arr) {
       
   104   if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
       
   105 }
       
   106 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
       
   107 var iterableToArray = __webpack_require__(35);
       
   108 
       
   109 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
       
   110 var unsupportedIterableToArray = __webpack_require__(29);
       
   111 
       
   112 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
       
   113 function _nonIterableSpread() {
       
   114   throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
       
   115 }
       
   116 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
       
   117 
       
   118 
       
   119 
       
   120 
       
   121 function _toConsumableArray(arr) {
       
   122   return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
       
   123 }
       
   124 
    94 
   125 /***/ }),
    95 /***/ }),
   126 
    96 
   127 /***/ 2:
    97 /***/ "Ko7W":
   128 /***/ (function(module, exports) {
       
   129 
       
   130 (function() { module.exports = this["lodash"]; }());
       
   131 
       
   132 /***/ }),
       
   133 
       
   134 /***/ 26:
       
   135 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   136 
       
   137 "use strict";
       
   138 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
       
   139 function _arrayLikeToArray(arr, len) {
       
   140   if (len == null || len > arr.length) len = arr.length;
       
   141 
       
   142   for (var i = 0, arr2 = new Array(len); i < len; i++) {
       
   143     arr2[i] = arr[i];
       
   144   }
       
   145 
       
   146   return arr2;
       
   147 }
       
   148 
       
   149 /***/ }),
       
   150 
       
   151 /***/ 29:
       
   152 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   153 
       
   154 "use strict";
       
   155 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
       
   156 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26);
       
   157 
       
   158 function _unsupportedIterableToArray(o, minLen) {
       
   159   if (!o) return;
       
   160   if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
       
   161   var n = Object.prototype.toString.call(o).slice(8, -1);
       
   162   if (n === "Object" && o.constructor) n = o.constructor.name;
       
   163   if (n === "Map" || n === "Set") return Array.from(o);
       
   164   if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
       
   165 }
       
   166 
       
   167 /***/ }),
       
   168 
       
   169 /***/ 35:
       
   170 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   171 
       
   172 "use strict";
       
   173 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
       
   174 function _iterableToArray(iter) {
       
   175   if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
       
   176 }
       
   177 
       
   178 /***/ }),
       
   179 
       
   180 /***/ 4:
       
   181 /***/ (function(module, exports) {
       
   182 
       
   183 (function() { module.exports = this["wp"]["data"]; }());
       
   184 
       
   185 /***/ }),
       
   186 
       
   187 /***/ 455:
       
   188 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    98 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   189 
    99 
   190 "use strict";
   100 "use strict";
   191 // ESM COMPAT FLAG
   101 // ESM COMPAT FLAG
   192 __webpack_require__.r(__webpack_exports__);
   102 __webpack_require__.r(__webpack_exports__);
       
   103 
       
   104 // EXPORTS
       
   105 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
   193 
   106 
   194 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
   107 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
   195 var actions_namespaceObject = {};
   108 var actions_namespaceObject = {};
   196 __webpack_require__.r(actions_namespaceObject);
   109 __webpack_require__.r(actions_namespaceObject);
   197 __webpack_require__.d(actions_namespaceObject, "createNotice", function() { return createNotice; });
   110 __webpack_require__.d(actions_namespaceObject, "createNotice", function() { return createNotice; });
   204 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
   117 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
   205 var selectors_namespaceObject = {};
   118 var selectors_namespaceObject = {};
   206 __webpack_require__.r(selectors_namespaceObject);
   119 __webpack_require__.r(selectors_namespaceObject);
   207 __webpack_require__.d(selectors_namespaceObject, "getNotices", function() { return getNotices; });
   120 __webpack_require__.d(selectors_namespaceObject, "getNotices", function() { return getNotices; });
   208 
   121 
   209 // EXTERNAL MODULE: external {"this":["wp","data"]}
   122 // EXTERNAL MODULE: external ["wp","data"]
   210 var external_this_wp_data_ = __webpack_require__(4);
   123 var external_wp_data_ = __webpack_require__("1ZqX");
   211 
   124 
   212 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
   125 // EXTERNAL MODULE: external "lodash"
   213 var toConsumableArray = __webpack_require__(18);
   126 var external_lodash_ = __webpack_require__("YLtl");
   214 
       
   215 // EXTERNAL MODULE: external {"this":"lodash"}
       
   216 var external_this_lodash_ = __webpack_require__(2);
       
   217 
       
   218 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
       
   219 var defineProperty = __webpack_require__(5);
       
   220 
   127 
   221 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
   128 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
   222 
       
   223 
       
   224 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
       
   225 
       
   226 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
       
   227 
       
   228 /**
   129 /**
   229  * Higher-order reducer creator which creates a combined reducer object, keyed
   130  * Higher-order reducer creator which creates a combined reducer object, keyed
   230  * by a property on the action object.
   131  * by a property on the action object.
   231  *
   132  *
   232  * @param {string} actionProperty Action property by which to key object.
   133  * @param {string} actionProperty Action property by which to key object.
   233  *
   134  *
   234  * @return {Function} Higher-order reducer.
   135  * @return {Function} Higher-order reducer.
   235  */
   136  */
   236 var on_sub_key_onSubKey = function onSubKey(actionProperty) {
   137 const onSubKey = actionProperty => reducer => (state = {}, action) => {
   237   return function (reducer) {
   138   // Retrieve subkey from action. Do not track if undefined; useful for cases
   238     return function () {
   139   // where reducer is scoped by action shape.
   239       var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
   140   const key = action[actionProperty];
   240       var action = arguments.length > 1 ? arguments[1] : undefined;
   141 
   241       // Retrieve subkey from action. Do not track if undefined; useful for cases
   142   if (key === undefined) {
   242       // where reducer is scoped by action shape.
   143     return state;
   243       var key = action[actionProperty];
   144   } // Avoid updating state if unchanged. Note that this also accounts for a
   244 
   145   // reducer which returns undefined on a key which is not yet tracked.
   245       if (key === undefined) {
   146 
   246         return state;
   147 
   247       } // Avoid updating state if unchanged. Note that this also accounts for a
   148   const nextKeyState = reducer(state[key], action);
   248       // reducer which returns undefined on a key which is not yet tracked.
   149 
   249 
   150   if (nextKeyState === state[key]) {
   250 
   151     return state;
   251       var nextKeyState = reducer(state[key], action);
   152   }
   252 
   153 
   253       if (nextKeyState === state[key]) {
   154   return { ...state,
   254         return state;
   155     [key]: nextKeyState
   255       }
       
   256 
       
   257       return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState));
       
   258     };
       
   259   };
   156   };
   260 };
   157 };
   261 /* harmony default export */ var on_sub_key = (on_sub_key_onSubKey);
   158 /* harmony default export */ var on_sub_key = (onSubKey);
   262 
   159 
   263 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
   160 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
   264 
       
   265 
       
   266 /**
   161 /**
   267  * External dependencies
   162  * External dependencies
   268  */
   163  */
   269 
   164 
   270 /**
   165 /**
   280  * @param {Object} action Dispatched action.
   175  * @param {Object} action Dispatched action.
   281  *
   176  *
   282  * @return {Object} Updated state.
   177  * @return {Object} Updated state.
   283  */
   178  */
   284 
   179 
   285 var notices = on_sub_key('context')(function () {
   180 const notices = on_sub_key('context')((state = [], action) => {
   286   var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
       
   287   var action = arguments.length > 1 ? arguments[1] : undefined;
       
   288 
       
   289   switch (action.type) {
   181   switch (action.type) {
   290     case 'CREATE_NOTICE':
   182     case 'CREATE_NOTICE':
   291       // Avoid duplicates on ID.
   183       // Avoid duplicates on ID.
   292       return [].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["reject"])(state, {
   184       return [...Object(external_lodash_["reject"])(state, {
   293         id: action.notice.id
   185         id: action.notice.id
   294       })), [action.notice]);
   186       }), action.notice];
   295 
   187 
   296     case 'REMOVE_NOTICE':
   188     case 'REMOVE_NOTICE':
   297       return Object(external_this_lodash_["reject"])(state, {
   189       return Object(external_lodash_["reject"])(state, {
   298         id: action.id
   190         id: action.id
   299       });
   191       });
   300   }
   192   }
   301 
   193 
   302   return state;
   194   return state;
   303 });
   195 });
   304 /* harmony default export */ var store_reducer = (notices);
   196 /* harmony default export */ var reducer = (notices);
   305 
   197 
   306 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
   198 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
   307 /**
   199 /**
   308  * Default context to use for notice grouping when not otherwise specified. Its
   200  * Default context to use for notice grouping when not otherwise specified. Its
   309  * specific value doesn't hold much meaning, but it must be reasonably unique
   201  * specific value doesn't hold much meaning, but it must be reasonably unique
   310  * and, more importantly, referenced consistently in the store implementation.
   202  * and, more importantly, referenced consistently in the store implementation.
   311  *
   203  *
   312  * @type {string}
   204  * @type {string}
   313  */
   205  */
   314 var DEFAULT_CONTEXT = 'global';
   206 const DEFAULT_CONTEXT = 'global';
   315 /**
   207 /**
   316  * Default notice status.
   208  * Default notice status.
   317  *
   209  *
   318  * @type {string}
   210  * @type {string}
   319  */
   211  */
   320 
   212 
   321 var DEFAULT_STATUS = 'info';
   213 const DEFAULT_STATUS = 'info';
   322 
   214 
   323 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
   215 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
   324 /**
   216 /**
   325  * External dependencies
   217  * External dependencies
   326  */
   218  */
   360  *                                                             content should be
   252  *                                                             content should be
   361  *                                                             announced to screen
   253  *                                                             announced to screen
   362  *                                                             readers.
   254  *                                                             readers.
   363  * @param {Array<WPNoticeAction>} [options.actions]            User actions to be
   255  * @param {Array<WPNoticeAction>} [options.actions]            User actions to be
   364  *                                                             presented with notice.
   256  *                                                             presented with notice.
   365  *
   257  * @param {Object}                [options.icon]               An icon displayed with the notice.
   366  * @return {Object} Action object.
   258  * @param {boolean}               [options.explicitDismiss]    Whether the notice includes
   367  */
   259  *                                                             an explict dismiss button and
   368 
   260  *                                                             can't be dismissed by clicking
   369 function createNotice() {
   261  *                                                             the body of the notice.
   370   var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATUS;
   262  * @param {Function}              [options.onDismiss]          Called when the notice is dismissed.
   371   var content = arguments.length > 1 ? arguments[1] : undefined;
   263  *
   372   var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
   264  * @return {Object} Action object.
   373   var _options$speak = options.speak,
   265  */
   374       speak = _options$speak === void 0 ? true : _options$speak,
   266 
   375       _options$isDismissibl = options.isDismissible,
   267 function createNotice(status = DEFAULT_STATUS, content, options = {}) {
   376       isDismissible = _options$isDismissibl === void 0 ? true : _options$isDismissibl,
   268   const {
   377       _options$context = options.context,
   269     speak = true,
   378       context = _options$context === void 0 ? DEFAULT_CONTEXT : _options$context,
   270     isDismissible = true,
   379       _options$id = options.id,
   271     context = DEFAULT_CONTEXT,
   380       id = _options$id === void 0 ? Object(external_this_lodash_["uniqueId"])(context) : _options$id,
   272     id = Object(external_lodash_["uniqueId"])(context),
   381       _options$actions = options.actions,
   273     actions = [],
   382       actions = _options$actions === void 0 ? [] : _options$actions,
   274     type = 'default',
   383       _options$type = options.type,
   275     __unstableHTML,
   384       type = _options$type === void 0 ? 'default' : _options$type,
   276     icon = null,
   385       __unstableHTML = options.__unstableHTML; // The supported value shape of content is currently limited to plain text
   277     explicitDismiss = false,
       
   278     onDismiss = null
       
   279   } = options; // The supported value shape of content is currently limited to plain text
   386   // strings. To avoid setting expectation that e.g. a WPElement could be
   280   // strings. To avoid setting expectation that e.g. a WPElement could be
   387   // supported, cast to a string.
   281   // supported, cast to a string.
   388 
   282 
   389   content = String(content);
   283   content = String(content);
   390   return {
   284   return {
   391     type: 'CREATE_NOTICE',
   285     type: 'CREATE_NOTICE',
   392     context: context,
   286     context,
   393     notice: {
   287     notice: {
   394       id: id,
   288       id,
   395       status: status,
   289       status,
   396       content: content,
   290       content,
   397       spokenMessage: speak ? content : null,
   291       spokenMessage: speak ? content : null,
   398       __unstableHTML: __unstableHTML,
   292       __unstableHTML,
   399       isDismissible: isDismissible,
   293       isDismissible,
   400       actions: actions,
   294       actions,
   401       type: type
   295       type,
       
   296       icon,
       
   297       explicitDismiss,
       
   298       onDismiss
   402     }
   299     }
   403   };
   300   };
   404 }
   301 }
   405 /**
   302 /**
   406  * Returns an action object used in signalling that a success notice is to be
   303  * Returns an action object used in signalling that a success notice is to be
   470  *                                    intended to appear. Defaults to default context.
   367  *                                    intended to appear. Defaults to default context.
   471  *
   368  *
   472  * @return {Object} Action object.
   369  * @return {Object} Action object.
   473  */
   370  */
   474 
   371 
   475 function removeNotice(id) {
   372 function removeNotice(id, context = DEFAULT_CONTEXT) {
   476   var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
       
   477   return {
   373   return {
   478     type: 'REMOVE_NOTICE',
   374     type: 'REMOVE_NOTICE',
   479     id: id,
   375     id,
   480     context: context
   376     context
   481   };
   377   };
   482 }
   378 }
   483 
   379 
   484 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
   380 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
   485 /**
   381 /**
   496  * sequential selector calls, since otherwise `[] !== []`.
   392  * sequential selector calls, since otherwise `[] !== []`.
   497  *
   393  *
   498  * @type {Array}
   394  * @type {Array}
   499  */
   395  */
   500 
   396 
   501 var DEFAULT_NOTICES = [];
   397 const DEFAULT_NOTICES = [];
   502 /**
   398 /**
   503  * @typedef {Object} WPNotice Notice object.
   399  * @typedef {Object} WPNotice Notice object.
   504  *
   400  *
   505  * @property {string}  id               Unique identifier of notice.
   401  * @property {string}  id               Unique identifier of notice.
   506  * @property {string}  status           Status of notice, one of `success`,
   402  * @property {string}  status           Status of notice, one of `success`,
   533  * @param {?string} context Optional grouping context.
   429  * @param {?string} context Optional grouping context.
   534  *
   430  *
   535  * @return {WPNotice[]} Array of notices.
   431  * @return {WPNotice[]} Array of notices.
   536  */
   432  */
   537 
   433 
   538 function getNotices(state) {
   434 function getNotices(state, context = DEFAULT_CONTEXT) {
   539   var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
       
   540   return state[context] || DEFAULT_NOTICES;
   435   return state[context] || DEFAULT_NOTICES;
   541 }
   436 }
   542 
   437 
   543 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
   438 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
   544 /**
   439 /**
   550  */
   445  */
   551 
   446 
   552 
   447 
   553 
   448 
   554 
   449 
   555 /* harmony default export */ var store = (Object(external_this_wp_data_["registerStore"])('core/notices', {
   450 /**
   556   reducer: store_reducer,
   451  * Store definition for the notices namespace.
       
   452  *
       
   453  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
       
   454  *
       
   455  * @type {Object}
       
   456  */
       
   457 
       
   458 const store = Object(external_wp_data_["createReduxStore"])('core/notices', {
       
   459   reducer: reducer,
   557   actions: actions_namespaceObject,
   460   actions: actions_namespaceObject,
   558   selectors: selectors_namespaceObject
   461   selectors: selectors_namespaceObject
   559 }));
   462 });
       
   463 Object(external_wp_data_["register"])(store);
   560 
   464 
   561 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
   465 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
   562 /**
       
   563  * Internal dependencies
       
   564  */
       
   565 
   466 
   566 
   467 
   567 
   468 
   568 /***/ }),
   469 /***/ }),
   569 
   470 
   570 /***/ 5:
   471 /***/ "YLtl":
   571 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   472 /***/ (function(module, exports) {
   572 
   473 
   573 "use strict";
   474 (function() { module.exports = window["lodash"]; }());
   574 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
       
   575 function _defineProperty(obj, key, value) {
       
   576   if (key in obj) {
       
   577     Object.defineProperty(obj, key, {
       
   578       value: value,
       
   579       enumerable: true,
       
   580       configurable: true,
       
   581       writable: true
       
   582     });
       
   583   } else {
       
   584     obj[key] = value;
       
   585   }
       
   586 
       
   587   return obj;
       
   588 }
       
   589 
   475 
   590 /***/ })
   476 /***/ })
   591 
   477 
   592 /******/ });
   478 /******/ });