[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> notices.js (source)

   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 = 438);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 18:
  91  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92  
  93  "use strict";
  94  
  95  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
  96  var arrayLikeToArray = __webpack_require__(25);
  97  
  98  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
  99  
 100  function _arrayWithoutHoles(arr) {
 101    if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
 102  }
 103  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
 104  var iterableToArray = __webpack_require__(35);
 105  
 106  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 107  var unsupportedIterableToArray = __webpack_require__(27);
 108  
 109  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
 110  function _nonIterableSpread() {
 111    throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 112  }
 113  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
 114  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; });
 115  
 116  
 117  
 118  
 119  function _toConsumableArray(arr) {
 120    return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
 121  }
 122  
 123  /***/ }),
 124  
 125  /***/ 2:
 126  /***/ (function(module, exports) {
 127  
 128  (function() { module.exports = this["lodash"]; }());
 129  
 130  /***/ }),
 131  
 132  /***/ 25:
 133  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 134  
 135  "use strict";
 136  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
 137  function _arrayLikeToArray(arr, len) {
 138    if (len == null || len > arr.length) len = arr.length;
 139  
 140    for (var i = 0, arr2 = new Array(len); i < len; i++) {
 141      arr2[i] = arr[i];
 142    }
 143  
 144    return arr2;
 145  }
 146  
 147  /***/ }),
 148  
 149  /***/ 27:
 150  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 151  
 152  "use strict";
 153  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 154  /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25);
 155  
 156  function _unsupportedIterableToArray(o, minLen) {
 157    if (!o) return;
 158    if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 159    var n = Object.prototype.toString.call(o).slice(8, -1);
 160    if (n === "Object" && o.constructor) n = o.constructor.name;
 161    if (n === "Map" || n === "Set") return Array.from(n);
 162    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 163  }
 164  
 165  /***/ }),
 166  
 167  /***/ 35:
 168  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 169  
 170  "use strict";
 171  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 172  function _iterableToArray(iter) {
 173    if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
 174  }
 175  
 176  /***/ }),
 177  
 178  /***/ 4:
 179  /***/ (function(module, exports) {
 180  
 181  (function() { module.exports = this["wp"]["data"]; }());
 182  
 183  /***/ }),
 184  
 185  /***/ 438:
 186  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 187  
 188  "use strict";
 189  __webpack_require__.r(__webpack_exports__);
 190  var actions_namespaceObject = {};
 191  __webpack_require__.r(actions_namespaceObject);
 192  __webpack_require__.d(actions_namespaceObject, "createNotice", function() { return createNotice; });
 193  __webpack_require__.d(actions_namespaceObject, "createSuccessNotice", function() { return createSuccessNotice; });
 194  __webpack_require__.d(actions_namespaceObject, "createInfoNotice", function() { return createInfoNotice; });
 195  __webpack_require__.d(actions_namespaceObject, "createErrorNotice", function() { return createErrorNotice; });
 196  __webpack_require__.d(actions_namespaceObject, "createWarningNotice", function() { return createWarningNotice; });
 197  __webpack_require__.d(actions_namespaceObject, "removeNotice", function() { return removeNotice; });
 198  var selectors_namespaceObject = {};
 199  __webpack_require__.r(selectors_namespaceObject);
 200  __webpack_require__.d(selectors_namespaceObject, "getNotices", function() { return getNotices; });
 201  
 202  // EXTERNAL MODULE: external {"this":["wp","data"]}
 203  var external_this_wp_data_ = __webpack_require__(4);
 204  
 205  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 206  var toConsumableArray = __webpack_require__(18);
 207  
 208  // EXTERNAL MODULE: external {"this":"lodash"}
 209  var external_this_lodash_ = __webpack_require__(2);
 210  
 211  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
 212  var defineProperty = __webpack_require__(5);
 213  
 214  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
 215  
 216  
 217  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; }
 218  
 219  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; }
 220  
 221  /**
 222   * Higher-order reducer creator which creates a combined reducer object, keyed
 223   * by a property on the action object.
 224   *
 225   * @param {string} actionProperty Action property by which to key object.
 226   *
 227   * @return {Function} Higher-order reducer.
 228   */
 229  var on_sub_key_onSubKey = function onSubKey(actionProperty) {
 230    return function (reducer) {
 231      return function () {
 232        var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 233        var action = arguments.length > 1 ? arguments[1] : undefined;
 234        // Retrieve subkey from action. Do not track if undefined; useful for cases
 235        // where reducer is scoped by action shape.
 236        var key = action[actionProperty];
 237  
 238        if (key === undefined) {
 239          return state;
 240        } // Avoid updating state if unchanged. Note that this also accounts for a
 241        // reducer which returns undefined on a key which is not yet tracked.
 242  
 243  
 244        var nextKeyState = reducer(state[key], action);
 245  
 246        if (nextKeyState === state[key]) {
 247          return state;
 248        }
 249  
 250        return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState));
 251      };
 252    };
 253  };
 254  /* harmony default export */ var on_sub_key = (on_sub_key_onSubKey);
 255  
 256  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
 257  
 258  
 259  /**
 260   * External dependencies
 261   */
 262  
 263  /**
 264   * Internal dependencies
 265   */
 266  
 267  
 268  /**
 269   * Reducer returning the next notices state. The notices state is an object
 270   * where each key is a context, its value an array of notice objects.
 271   *
 272   * @param {Object} state  Current state.
 273   * @param {Object} action Dispatched action.
 274   *
 275   * @return {Object} Updated state.
 276   */
 277  
 278  var notices = on_sub_key('context')(function () {
 279    var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
 280    var action = arguments.length > 1 ? arguments[1] : undefined;
 281  
 282    switch (action.type) {
 283      case 'CREATE_NOTICE':
 284        // Avoid duplicates on ID.
 285        return [].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["reject"])(state, {
 286          id: action.notice.id
 287        })), [action.notice]);
 288  
 289      case 'REMOVE_NOTICE':
 290        return Object(external_this_lodash_["reject"])(state, {
 291          id: action.id
 292        });
 293    }
 294  
 295    return state;
 296  });
 297  /* harmony default export */ var store_reducer = (notices);
 298  
 299  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
 300  /**
 301   * Default context to use for notice grouping when not otherwise specified. Its
 302   * specific value doesn't hold much meaning, but it must be reasonably unique
 303   * and, more importantly, referenced consistently in the store implementation.
 304   *
 305   * @type {string}
 306   */
 307  var DEFAULT_CONTEXT = 'global';
 308  /**
 309   * Default notice status.
 310   *
 311   * @type {string}
 312   */
 313  
 314  var DEFAULT_STATUS = 'info';
 315  
 316  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
 317  /**
 318   * External dependencies
 319   */
 320  
 321  /**
 322   * Internal dependencies
 323   */
 324  
 325  
 326  /**
 327   * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
 328   *
 329   * @property {string}    label    Message to use as action label.
 330   * @property {?string}   url      Optional URL of resource if action incurs
 331   *                                browser navigation.
 332   * @property {?Function} onClick  Optional function to invoke when action is
 333   *                                triggered by user.
 334   *
 335   */
 336  
 337  /**
 338   * Returns an action object used in signalling that a notice is to be created.
 339   *
 340   * @param {string}                [status='info']              Notice status.
 341   * @param {string}                content                      Notice message.
 342   * @param {Object}                [options]                    Notice options.
 343   * @param {string}                [options.context='global']   Context under which to
 344   *                                                             group notice.
 345   * @param {string}                [options.id]                 Identifier for notice.
 346   *                                                             Automatically assigned
 347   *                                                             if not specified.
 348   * @param {boolean}               [options.isDismissible=true] Whether the notice can
 349   *                                                             be dismissed by user.
 350   * @param {string}                [options.type='default']     Type of notice, one of
 351   *                                                             `default`, or `snackbar`.
 352   * @param {boolean}               [options.speak=true]         Whether the notice
 353   *                                                             content should be
 354   *                                                             announced to screen
 355   *                                                             readers.
 356   * @param {Array<WPNoticeAction>} [options.actions]            User actions to be
 357   *                                                             presented with notice.
 358   *
 359   * @return {Object} Action object.
 360   */
 361  
 362  function createNotice() {
 363    var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATUS;
 364    var content = arguments.length > 1 ? arguments[1] : undefined;
 365    var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
 366    var _options$speak = options.speak,
 367        speak = _options$speak === void 0 ? true : _options$speak,
 368        _options$isDismissibl = options.isDismissible,
 369        isDismissible = _options$isDismissibl === void 0 ? true : _options$isDismissibl,
 370        _options$context = options.context,
 371        context = _options$context === void 0 ? DEFAULT_CONTEXT : _options$context,
 372        _options$id = options.id,
 373        id = _options$id === void 0 ? Object(external_this_lodash_["uniqueId"])(context) : _options$id,
 374        _options$actions = options.actions,
 375        actions = _options$actions === void 0 ? [] : _options$actions,
 376        _options$type = options.type,
 377        type = _options$type === void 0 ? 'default' : _options$type,
 378        __unstableHTML = options.__unstableHTML; // The supported value shape of content is currently limited to plain text
 379    // strings. To avoid setting expectation that e.g. a WPElement could be
 380    // supported, cast to a string.
 381  
 382    content = String(content);
 383    return {
 384      type: 'CREATE_NOTICE',
 385      context: context,
 386      notice: {
 387        id: id,
 388        status: status,
 389        content: content,
 390        spokenMessage: speak ? content : null,
 391        __unstableHTML: __unstableHTML,
 392        isDismissible: isDismissible,
 393        actions: actions,
 394        type: type
 395      }
 396    };
 397  }
 398  /**
 399   * Returns an action object used in signalling that a success notice is to be
 400   * created. Refer to `createNotice` for options documentation.
 401   *
 402   * @see createNotice
 403   *
 404   * @param {string} content   Notice message.
 405   * @param {Object} [options] Optional notice options.
 406   *
 407   * @return {Object} Action object.
 408   */
 409  
 410  function createSuccessNotice(content, options) {
 411    return createNotice('success', content, options);
 412  }
 413  /**
 414   * Returns an action object used in signalling that an info notice is to be
 415   * created. Refer to `createNotice` for options documentation.
 416   *
 417   * @see createNotice
 418   *
 419   * @param {string} content   Notice message.
 420   * @param {Object} [options] Optional notice options.
 421   *
 422   * @return {Object} Action object.
 423   */
 424  
 425  function createInfoNotice(content, options) {
 426    return createNotice('info', content, options);
 427  }
 428  /**
 429   * Returns an action object used in signalling that an error notice is to be
 430   * created. Refer to `createNotice` for options documentation.
 431   *
 432   * @see createNotice
 433   *
 434   * @param {string} content   Notice message.
 435   * @param {Object} [options] Optional notice options.
 436   *
 437   * @return {Object} Action object.
 438   */
 439  
 440  function createErrorNotice(content, options) {
 441    return createNotice('error', content, options);
 442  }
 443  /**
 444   * Returns an action object used in signalling that a warning notice is to be
 445   * created. Refer to `createNotice` for options documentation.
 446   *
 447   * @see createNotice
 448   *
 449   * @param {string} content   Notice message.
 450   * @param {Object} [options] Optional notice options.
 451   *
 452   * @return {Object} Action object.
 453   */
 454  
 455  function createWarningNotice(content, options) {
 456    return createNotice('warning', content, options);
 457  }
 458  /**
 459   * Returns an action object used in signalling that a notice is to be removed.
 460   *
 461   * @param {string} id                 Notice unique identifier.
 462   * @param {string} [context='global'] Optional context (grouping) in which the notice is
 463   *                                    intended to appear. Defaults to default context.
 464   *
 465   * @return {Object} Action object.
 466   */
 467  
 468  function removeNotice(id) {
 469    var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
 470    return {
 471      type: 'REMOVE_NOTICE',
 472      id: id,
 473      context: context
 474    };
 475  }
 476  
 477  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
 478  /**
 479   * Internal dependencies
 480   */
 481  
 482  /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
 483  
 484  /**
 485   * The default empty set of notices to return when there are no notices
 486   * assigned for a given notices context. This can occur if the getNotices
 487   * selector is called without a notice ever having been created for the
 488   * context. A shared value is used to ensure referential equality between
 489   * sequential selector calls, since otherwise `[] !== []`.
 490   *
 491   * @type {Array}
 492   */
 493  
 494  var DEFAULT_NOTICES = [];
 495  /**
 496   * @typedef {Object} WPNotice Notice object.
 497   *
 498   * @property {string}  id               Unique identifier of notice.
 499   * @property {string}  status           Status of notice, one of `success`,
 500   *                                      `info`, `error`, or `warning`. Defaults
 501   *                                      to `info`.
 502   * @property {string}  content          Notice message.
 503   * @property {string}  spokenMessage    Audibly announced message text used by
 504   *                                      assistive technologies.
 505   * @property {string}  __unstableHTML   Notice message as raw HTML. Intended to
 506   *                                      serve primarily for compatibility of
 507   *                                      server-rendered notices, and SHOULD NOT
 508   *                                      be used for notices. It is subject to
 509   *                                      removal without notice.
 510   * @property {boolean} isDismissible    Whether the notice can be dismissed by
 511   *                                      user. Defaults to `true`.
 512   * @property {string}  type             Type of notice, one of `default`,
 513   *                                      or `snackbar`. Defaults to `default`.
 514   * @property {boolean} speak            Whether the notice content should be
 515   *                                      announced to screen readers. Defaults to
 516   *                                      `true`.
 517   * @property {WPNoticeAction[]} actions User actions to present with notice.
 518   *
 519   */
 520  
 521  /**
 522   * Returns all notices as an array, optionally for a given context. Defaults to
 523   * the global context.
 524   *
 525   * @param {Object}  state   Notices state.
 526   * @param {?string} context Optional grouping context.
 527   *
 528   * @return {WPNotice[]} Array of notices.
 529   */
 530  
 531  function getNotices(state) {
 532    var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
 533    return state[context] || DEFAULT_NOTICES;
 534  }
 535  
 536  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
 537  /**
 538   * WordPress dependencies
 539   */
 540  
 541  /**
 542   * Internal dependencies
 543   */
 544  
 545  
 546  
 547  
 548  /* harmony default export */ var store = (Object(external_this_wp_data_["registerStore"])('core/notices', {
 549    reducer: store_reducer,
 550    actions: actions_namespaceObject,
 551    selectors: selectors_namespaceObject
 552  }));
 553  
 554  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
 555  /**
 556   * Internal dependencies
 557   */
 558  
 559  
 560  
 561  /***/ }),
 562  
 563  /***/ 5:
 564  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 565  
 566  "use strict";
 567  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
 568  function _defineProperty(obj, key, value) {
 569    if (key in obj) {
 570      Object.defineProperty(obj, key, {
 571        value: value,
 572        enumerable: true,
 573        configurable: true,
 574        writable: true
 575      });
 576    } else {
 577      obj[key] = value;
 578    }
 579  
 580    return obj;
 581  }
 582  
 583  /***/ })
 584  
 585  /******/ });


Generated: Thu Apr 2 01:00:03 2020 Cross-referenced by PHPXref 0.7.1