wp/wp-includes/js/dist/notices.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 this["wp"] = this["wp"] || {}; this["wp"]["notices"] =
     1 /******/ (function() { // webpackBootstrap
     2 /******/ (function(modules) { // webpackBootstrap
     2 /******/ 	"use strict";
     3 /******/ 	// The module cache
     3 /******/ 	// The require scope
     4 /******/ 	var installedModules = {};
     4 /******/ 	var __webpack_require__ = {};
     5 /******/
     5 /******/ 	
     6 /******/ 	// The require function
     6 /************************************************************************/
     7 /******/ 	function __webpack_require__(moduleId) {
     7 /******/ 	/* webpack/runtime/define property getters */
     8 /******/
     8 /******/ 	!function() {
     9 /******/ 		// Check if module is in cache
     9 /******/ 		// define getter functions for harmony exports
    10 /******/ 		if(installedModules[moduleId]) {
    10 /******/ 		__webpack_require__.d = function(exports, definition) {
    11 /******/ 			return installedModules[moduleId].exports;
    11 /******/ 			for(var key in definition) {
    12 /******/ 		}
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    13 /******/ 		// Create a new module (and put it into the cache)
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    14 /******/ 		var module = installedModules[moduleId] = {
    14 /******/ 				}
    15 /******/ 			i: moduleId,
    15 /******/ 			}
    16 /******/ 			l: false,
       
    17 /******/ 			exports: {}
       
    18 /******/ 		};
    16 /******/ 		};
    19 /******/
    17 /******/ 	}();
    20 /******/ 		// Execute the module function
    18 /******/ 	
    21 /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
    19 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
    22 /******/
    20 /******/ 	!function() {
    23 /******/ 		// Flag the module as loaded
    21 /******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
    24 /******/ 		module.l = true;
    22 /******/ 	}();
    25 /******/
    23 /******/ 	
    26 /******/ 		// Return the exports of the module
    24 /******/ 	/* webpack/runtime/make namespace object */
    27 /******/ 		return module.exports;
    25 /******/ 	!function() {
    28 /******/ 	}
    26 /******/ 		// define __esModule on exports
    29 /******/
    27 /******/ 		__webpack_require__.r = function(exports) {
    30 /******/
    28 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
    31 /******/ 	// expose the modules object (__webpack_modules__)
    29 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
    32 /******/ 	__webpack_require__.m = modules;
    30 /******/ 			}
    33 /******/
    31 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
    34 /******/ 	// expose the module cache
    32 /******/ 		};
    35 /******/ 	__webpack_require__.c = installedModules;
    33 /******/ 	}();
    36 /******/
    34 /******/ 	
    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 /************************************************************************/
    35 /************************************************************************/
    88 /******/ ({
    36 var __webpack_exports__ = {};
    89 
       
    90 /***/ "1ZqX":
       
    91 /***/ (function(module, exports) {
       
    92 
       
    93 (function() { module.exports = window["wp"]["data"]; }());
       
    94 
       
    95 /***/ }),
       
    96 
       
    97 /***/ "Ko7W":
       
    98 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
    99 
       
   100 "use strict";
       
   101 // ESM COMPAT FLAG
    37 // ESM COMPAT FLAG
   102 __webpack_require__.r(__webpack_exports__);
    38 __webpack_require__.r(__webpack_exports__);
   103 
    39 
   104 // EXPORTS
    40 // EXPORTS
   105 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
    41 __webpack_require__.d(__webpack_exports__, {
       
    42   "store": function() { return /* reexport */ store; }
       
    43 });
   106 
    44 
   107 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
    45 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
   108 var actions_namespaceObject = {};
    46 var actions_namespaceObject = {};
   109 __webpack_require__.r(actions_namespaceObject);
    47 __webpack_require__.r(actions_namespaceObject);
   110 __webpack_require__.d(actions_namespaceObject, "createNotice", function() { return createNotice; });
    48 __webpack_require__.d(actions_namespaceObject, {
   111 __webpack_require__.d(actions_namespaceObject, "createSuccessNotice", function() { return createSuccessNotice; });
    49   "createErrorNotice": function() { return createErrorNotice; },
   112 __webpack_require__.d(actions_namespaceObject, "createInfoNotice", function() { return createInfoNotice; });
    50   "createInfoNotice": function() { return createInfoNotice; },
   113 __webpack_require__.d(actions_namespaceObject, "createErrorNotice", function() { return createErrorNotice; });
    51   "createNotice": function() { return createNotice; },
   114 __webpack_require__.d(actions_namespaceObject, "createWarningNotice", function() { return createWarningNotice; });
    52   "createSuccessNotice": function() { return createSuccessNotice; },
   115 __webpack_require__.d(actions_namespaceObject, "removeNotice", function() { return removeNotice; });
    53   "createWarningNotice": function() { return createWarningNotice; },
       
    54   "removeNotice": function() { return removeNotice; }
       
    55 });
   116 
    56 
   117 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
    57 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
   118 var selectors_namespaceObject = {};
    58 var selectors_namespaceObject = {};
   119 __webpack_require__.r(selectors_namespaceObject);
    59 __webpack_require__.r(selectors_namespaceObject);
   120 __webpack_require__.d(selectors_namespaceObject, "getNotices", function() { return getNotices; });
    60 __webpack_require__.d(selectors_namespaceObject, {
   121 
    61   "getNotices": function() { return getNotices; }
   122 // EXTERNAL MODULE: external ["wp","data"]
    62 });
   123 var external_wp_data_ = __webpack_require__("1ZqX");
    63 
   124 
    64 ;// CONCATENATED MODULE: external ["wp","data"]
   125 // EXTERNAL MODULE: external "lodash"
    65 var external_wp_data_namespaceObject = window["wp"]["data"];
   126 var external_lodash_ = __webpack_require__("YLtl");
    66 ;// CONCATENATED MODULE: external "lodash"
   127 
    67 var external_lodash_namespaceObject = window["lodash"];
   128 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
    68 ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
   129 /**
    69 /**
   130  * Higher-order reducer creator which creates a combined reducer object, keyed
    70  * Higher-order reducer creator which creates a combined reducer object, keyed
   131  * by a property on the action object.
    71  * by a property on the action object.
   132  *
    72  *
   133  * @param {string} actionProperty Action property by which to key object.
    73  * @param {string} actionProperty Action property by which to key object.
   134  *
    74  *
   135  * @return {Function} Higher-order reducer.
    75  * @return {Function} Higher-order reducer.
   136  */
    76  */
   137 const onSubKey = actionProperty => reducer => (state = {}, action) => {
    77 const onSubKey = actionProperty => reducer => function () {
       
    78   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
    79   let action = arguments.length > 1 ? arguments[1] : undefined;
   138   // Retrieve subkey from action. Do not track if undefined; useful for cases
    80   // Retrieve subkey from action. Do not track if undefined; useful for cases
   139   // where reducer is scoped by action shape.
    81   // where reducer is scoped by action shape.
   140   const key = action[actionProperty];
    82   const key = action[actionProperty];
   141 
    83 
   142   if (key === undefined) {
    84   if (key === undefined) {
   155     [key]: nextKeyState
    97     [key]: nextKeyState
   156   };
    98   };
   157 };
    99 };
   158 /* harmony default export */ var on_sub_key = (onSubKey);
   100 /* harmony default export */ var on_sub_key = (onSubKey);
   159 
   101 
   160 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
   102 ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
   161 /**
   103 /**
   162  * External dependencies
   104  * External dependencies
   163  */
   105  */
   164 
   106 
   165 /**
   107 /**
   175  * @param {Object} action Dispatched action.
   117  * @param {Object} action Dispatched action.
   176  *
   118  *
   177  * @return {Object} Updated state.
   119  * @return {Object} Updated state.
   178  */
   120  */
   179 
   121 
   180 const notices = on_sub_key('context')((state = [], action) => {
   122 const notices = on_sub_key('context')(function () {
       
   123   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
       
   124   let action = arguments.length > 1 ? arguments[1] : undefined;
       
   125 
   181   switch (action.type) {
   126   switch (action.type) {
   182     case 'CREATE_NOTICE':
   127     case 'CREATE_NOTICE':
   183       // Avoid duplicates on ID.
   128       // Avoid duplicates on ID.
   184       return [...Object(external_lodash_["reject"])(state, {
   129       return [...(0,external_lodash_namespaceObject.reject)(state, {
   185         id: action.notice.id
   130         id: action.notice.id
   186       }), action.notice];
   131       }), action.notice];
   187 
   132 
   188     case 'REMOVE_NOTICE':
   133     case 'REMOVE_NOTICE':
   189       return Object(external_lodash_["reject"])(state, {
   134       return (0,external_lodash_namespaceObject.reject)(state, {
   190         id: action.id
   135         id: action.id
   191       });
   136       });
   192   }
   137   }
   193 
   138 
   194   return state;
   139   return state;
   195 });
   140 });
   196 /* harmony default export */ var reducer = (notices);
   141 /* harmony default export */ var reducer = (notices);
   197 
   142 
   198 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
   143 ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
   199 /**
   144 /**
   200  * Default context to use for notice grouping when not otherwise specified. Its
   145  * Default context to use for notice grouping when not otherwise specified. Its
   201  * specific value doesn't hold much meaning, but it must be reasonably unique
   146  * specific value doesn't hold much meaning, but it must be reasonably unique
   202  * and, more importantly, referenced consistently in the store implementation.
   147  * and, more importantly, referenced consistently in the store implementation.
   203  *
   148  *
   210  * @type {string}
   155  * @type {string}
   211  */
   156  */
   212 
   157 
   213 const DEFAULT_STATUS = 'info';
   158 const DEFAULT_STATUS = 'info';
   214 
   159 
   215 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
   160 ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
   216 /**
   161 /**
   217  * External dependencies
   162  * External dependencies
   218  */
   163  */
   219 
   164 
   220 /**
   165 /**
   223 
   168 
   224 
   169 
   225 /**
   170 /**
   226  * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
   171  * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
   227  *
   172  *
   228  * @property {string}    label    Message to use as action label.
   173  * @property {string}    label   Message to use as action label.
   229  * @property {?string}   url      Optional URL of resource if action incurs
   174  * @property {?string}   url     Optional URL of resource if action incurs
   230  *                                browser navigation.
   175  *                               browser navigation.
   231  * @property {?Function} onClick  Optional function to invoke when action is
   176  * @property {?Function} onClick Optional function to invoke when action is
   232  *                                triggered by user.
   177  *                               triggered by user.
   233  *
   178  *
   234  */
   179  */
   235 
   180 
   236 /**
   181 /**
   237  * Returns an action object used in signalling that a notice is to be created.
   182  * Returns an action object used in signalling that a notice is to be created.
   262  * @param {Function}              [options.onDismiss]          Called when the notice is dismissed.
   207  * @param {Function}              [options.onDismiss]          Called when the notice is dismissed.
   263  *
   208  *
   264  * @return {Object} Action object.
   209  * @return {Object} Action object.
   265  */
   210  */
   266 
   211 
   267 function createNotice(status = DEFAULT_STATUS, content, options = {}) {
   212 function createNotice() {
       
   213   let status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATUS;
       
   214   let content = arguments.length > 1 ? arguments[1] : undefined;
       
   215   let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
   268   const {
   216   const {
   269     speak = true,
   217     speak = true,
   270     isDismissible = true,
   218     isDismissible = true,
   271     context = DEFAULT_CONTEXT,
   219     context = DEFAULT_CONTEXT,
   272     id = Object(external_lodash_["uniqueId"])(context),
   220     id = (0,external_lodash_namespaceObject.uniqueId)(context),
   273     actions = [],
   221     actions = [],
   274     type = 'default',
   222     type = 'default',
   275     __unstableHTML,
   223     __unstableHTML,
   276     icon = null,
   224     icon = null,
   277     explicitDismiss = false,
   225     explicitDismiss = false,
   278     onDismiss = null
   226     onDismiss
   279   } = options; // The supported value shape of content is currently limited to plain text
   227   } = options; // The supported value shape of content is currently limited to plain text
   280   // strings. To avoid setting expectation that e.g. a WPElement could be
   228   // strings. To avoid setting expectation that e.g. a WPElement could be
   281   // supported, cast to a string.
   229   // supported, cast to a string.
   282 
   230 
   283   content = String(content);
   231   content = String(content);
   367  *                                    intended to appear. Defaults to default context.
   315  *                                    intended to appear. Defaults to default context.
   368  *
   316  *
   369  * @return {Object} Action object.
   317  * @return {Object} Action object.
   370  */
   318  */
   371 
   319 
   372 function removeNotice(id, context = DEFAULT_CONTEXT) {
   320 function removeNotice(id) {
       
   321   let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
   373   return {
   322   return {
   374     type: 'REMOVE_NOTICE',
   323     type: 'REMOVE_NOTICE',
   375     id,
   324     id,
   376     context
   325     context
   377   };
   326   };
   378 }
   327 }
   379 
   328 
   380 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
   329 ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
   381 /**
   330 /**
   382  * Internal dependencies
   331  * Internal dependencies
   383  */
   332  */
   384 
   333 
   385 /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
   334 /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
   396 
   345 
   397 const DEFAULT_NOTICES = [];
   346 const DEFAULT_NOTICES = [];
   398 /**
   347 /**
   399  * @typedef {Object} WPNotice Notice object.
   348  * @typedef {Object} WPNotice Notice object.
   400  *
   349  *
   401  * @property {string}  id               Unique identifier of notice.
   350  * @property {string}           id             Unique identifier of notice.
   402  * @property {string}  status           Status of notice, one of `success`,
   351  * @property {string}           status         Status of notice, one of `success`,
   403  *                                      `info`, `error`, or `warning`. Defaults
   352  *                                             `info`, `error`, or `warning`. Defaults
   404  *                                      to `info`.
   353  *                                             to `info`.
   405  * @property {string}  content          Notice message.
   354  * @property {string}           content        Notice message.
   406  * @property {string}  spokenMessage    Audibly announced message text used by
   355  * @property {string}           spokenMessage  Audibly announced message text used by
   407  *                                      assistive technologies.
   356  *                                             assistive technologies.
   408  * @property {string}  __unstableHTML   Notice message as raw HTML. Intended to
   357  * @property {string}           __unstableHTML Notice message as raw HTML. Intended to
   409  *                                      serve primarily for compatibility of
   358  *                                             serve primarily for compatibility of
   410  *                                      server-rendered notices, and SHOULD NOT
   359  *                                             server-rendered notices, and SHOULD NOT
   411  *                                      be used for notices. It is subject to
   360  *                                             be used for notices. It is subject to
   412  *                                      removal without notice.
   361  *                                             removal without notice.
   413  * @property {boolean} isDismissible    Whether the notice can be dismissed by
   362  * @property {boolean}          isDismissible  Whether the notice can be dismissed by
   414  *                                      user. Defaults to `true`.
   363  *                                             user. Defaults to `true`.
   415  * @property {string}  type             Type of notice, one of `default`,
   364  * @property {string}           type           Type of notice, one of `default`,
   416  *                                      or `snackbar`. Defaults to `default`.
   365  *                                             or `snackbar`. Defaults to `default`.
   417  * @property {boolean} speak            Whether the notice content should be
   366  * @property {boolean}          speak          Whether the notice content should be
   418  *                                      announced to screen readers. Defaults to
   367  *                                             announced to screen readers. Defaults to
   419  *                                      `true`.
   368  *                                             `true`.
   420  * @property {WPNoticeAction[]} actions User actions to present with notice.
   369  * @property {WPNoticeAction[]} actions        User actions to present with notice.
   421  *
   370  *
   422  */
   371  */
   423 
   372 
   424 /**
   373 /**
   425  * Returns all notices as an array, optionally for a given context. Defaults to
   374  * Returns all notices as an array, optionally for a given context. Defaults to
   429  * @param {?string} context Optional grouping context.
   378  * @param {?string} context Optional grouping context.
   430  *
   379  *
   431  * @return {WPNotice[]} Array of notices.
   380  * @return {WPNotice[]} Array of notices.
   432  */
   381  */
   433 
   382 
   434 function getNotices(state, context = DEFAULT_CONTEXT) {
   383 function getNotices(state) {
       
   384   let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
   435   return state[context] || DEFAULT_NOTICES;
   385   return state[context] || DEFAULT_NOTICES;
   436 }
   386 }
   437 
   387 
   438 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
   388 ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
   439 /**
   389 /**
   440  * WordPress dependencies
   390  * WordPress dependencies
   441  */
   391  */
   442 
   392 
   443 /**
   393 /**
   453  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
   403  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
   454  *
   404  *
   455  * @type {Object}
   405  * @type {Object}
   456  */
   406  */
   457 
   407 
   458 const store = Object(external_wp_data_["createReduxStore"])('core/notices', {
   408 const store = (0,external_wp_data_namespaceObject.createReduxStore)('core/notices', {
   459   reducer: reducer,
   409   reducer: reducer,
   460   actions: actions_namespaceObject,
   410   actions: actions_namespaceObject,
   461   selectors: selectors_namespaceObject
   411   selectors: selectors_namespaceObject
   462 });
   412 });
   463 Object(external_wp_data_["register"])(store);
   413 (0,external_wp_data_namespaceObject.register)(store);
   464 
   414 
   465 // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
   415 ;// CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
   466 
   416 
   467 
   417 
   468 
   418 (window.wp = window.wp || {}).notices = __webpack_exports__;
   469 /***/ }),
   419 /******/ })()
   470 
   420 ;
   471 /***/ "YLtl":
       
   472 /***/ (function(module, exports) {
       
   473 
       
   474 (function() { module.exports = window["lodash"]; }());
       
   475 
       
   476 /***/ })
       
   477 
       
   478 /******/ });