[ 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 = 456);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 18:
  91  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92  
  93  "use strict";
  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  
 125  /***/ }),
 126  
 127  /***/ 2:
 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  /***/ 456:
 188  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 189  
 190  "use strict";
 191  // ESM COMPAT FLAG
 192  __webpack_require__.r(__webpack_exports__);
 193  
 194  // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
 195  var actions_namespaceObject = {};
 196  __webpack_require__.r(actions_namespaceObject);
 197  __webpack_require__.d(actions_namespaceObject, "createNotice", function() { return createNotice; });
 198  __webpack_require__.d(actions_namespaceObject, "createSuccessNotice", function() { return createSuccessNotice; });
 199  __webpack_require__.d(actions_namespaceObject, "createInfoNotice", function() { return createInfoNotice; });
 200  __webpack_require__.d(actions_namespaceObject, "createErrorNotice", function() { return createErrorNotice; });
 201  __webpack_require__.d(actions_namespaceObject, "createWarningNotice", function() { return createWarningNotice; });
 202  __webpack_require__.d(actions_namespaceObject, "removeNotice", function() { return removeNotice; });
 203  
 204  // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
 205  var selectors_namespaceObject = {};
 206  __webpack_require__.r(selectors_namespaceObject);
 207  __webpack_require__.d(selectors_namespaceObject, "getNotices", function() { return getNotices; });
 208  
 209  // EXTERNAL MODULE: external {"this":["wp","data"]}
 210  var external_this_wp_data_ = __webpack_require__(4);
 211  
 212  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 213  var toConsumableArray = __webpack_require__(18);
 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  
 221  // 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  /**
 229   * Higher-order reducer creator which creates a combined reducer object, keyed
 230   * by a property on the action object.
 231   *
 232   * @param {string} actionProperty Action property by which to key object.
 233   *
 234   * @return {Function} Higher-order reducer.
 235   */
 236  var on_sub_key_onSubKey = function onSubKey(actionProperty) {
 237    return function (reducer) {
 238      return function () {
 239        var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 240        var action = arguments.length > 1 ? arguments[1] : undefined;
 241        // Retrieve subkey from action. Do not track if undefined; useful for cases
 242        // where reducer is scoped by action shape.
 243        var key = action[actionProperty];
 244  
 245        if (key === undefined) {
 246          return state;
 247        } // Avoid updating state if unchanged. Note that this also accounts for a
 248        // reducer which returns undefined on a key which is not yet tracked.
 249  
 250  
 251        var nextKeyState = reducer(state[key], action);
 252  
 253        if (nextKeyState === state[key]) {
 254          return state;
 255        }
 256  
 257        return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, key, nextKeyState));
 258      };
 259    };
 260  };
 261  /* harmony default export */ var on_sub_key = (on_sub_key_onSubKey);
 262  
 263  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
 264  
 265  
 266  /**
 267   * External dependencies
 268   */
 269  
 270  /**
 271   * Internal dependencies
 272   */
 273  
 274  
 275  /**
 276   * Reducer returning the next notices state. The notices state is an object
 277   * where each key is a context, its value an array of notice objects.
 278   *
 279   * @param {Object} state  Current state.
 280   * @param {Object} action Dispatched action.
 281   *
 282   * @return {Object} Updated state.
 283   */
 284  
 285  var notices = on_sub_key('context')(function () {
 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) {
 290      case 'CREATE_NOTICE':
 291        // Avoid duplicates on ID.
 292        return [].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["reject"])(state, {
 293          id: action.notice.id
 294        })), [action.notice]);
 295  
 296      case 'REMOVE_NOTICE':
 297        return Object(external_this_lodash_["reject"])(state, {
 298          id: action.id
 299        });
 300    }
 301  
 302    return state;
 303  });
 304  /* harmony default export */ var store_reducer = (notices);
 305  
 306  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
 307  /**
 308   * 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
 310   * and, more importantly, referenced consistently in the store implementation.
 311   *
 312   * @type {string}
 313   */
 314  var DEFAULT_CONTEXT = 'global';
 315  /**
 316   * Default notice status.
 317   *
 318   * @type {string}
 319   */
 320  
 321  var DEFAULT_STATUS = 'info';
 322  
 323  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
 324  /**
 325   * External dependencies
 326   */
 327  
 328  /**
 329   * Internal dependencies
 330   */
 331  
 332  
 333  /**
 334   * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
 335   *
 336   * @property {string}    label    Message to use as action label.
 337   * @property {?string}   url      Optional URL of resource if action incurs
 338   *                                browser navigation.
 339   * @property {?Function} onClick  Optional function to invoke when action is
 340   *                                triggered by user.
 341   *
 342   */
 343  
 344  /**
 345   * Returns an action object used in signalling that a notice is to be created.
 346   *
 347   * @param {string}                [status='info']              Notice status.
 348   * @param {string}                content                      Notice message.
 349   * @param {Object}                [options]                    Notice options.
 350   * @param {string}                [options.context='global']   Context under which to
 351   *                                                             group notice.
 352   * @param {string}                [options.id]                 Identifier for notice.
 353   *                                                             Automatically assigned
 354   *                                                             if not specified.
 355   * @param {boolean}               [options.isDismissible=true] Whether the notice can
 356   *                                                             be dismissed by user.
 357   * @param {string}                [options.type='default']     Type of notice, one of
 358   *                                                             `default`, or `snackbar`.
 359   * @param {boolean}               [options.speak=true]         Whether the notice
 360   *                                                             content should be
 361   *                                                             announced to screen
 362   *                                                             readers.
 363   * @param {Array<WPNoticeAction>} [options.actions]            User actions to be
 364   *                                                             presented with notice.
 365   *
 366   * @return {Object} Action object.
 367   */
 368  
 369  function createNotice() {
 370    var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATUS;
 371    var content = arguments.length > 1 ? arguments[1] : undefined;
 372    var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
 373    var _options$speak = options.speak,
 374        speak = _options$speak === void 0 ? true : _options$speak,
 375        _options$isDismissibl = options.isDismissible,
 376        isDismissible = _options$isDismissibl === void 0 ? true : _options$isDismissibl,
 377        _options$context = options.context,
 378        context = _options$context === void 0 ? DEFAULT_CONTEXT : _options$context,
 379        _options$id = options.id,
 380        id = _options$id === void 0 ? Object(external_this_lodash_["uniqueId"])(context) : _options$id,
 381        _options$actions = options.actions,
 382        actions = _options$actions === void 0 ? [] : _options$actions,
 383        _options$type = options.type,
 384        type = _options$type === void 0 ? 'default' : _options$type,
 385        __unstableHTML = options.__unstableHTML; // 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
 387    // supported, cast to a string.
 388  
 389    content = String(content);
 390    return {
 391      type: 'CREATE_NOTICE',
 392      context: context,
 393      notice: {
 394        id: id,
 395        status: status,
 396        content: content,
 397        spokenMessage: speak ? content : null,
 398        __unstableHTML: __unstableHTML,
 399        isDismissible: isDismissible,
 400        actions: actions,
 401        type: type
 402      }
 403    };
 404  }
 405  /**
 406   * Returns an action object used in signalling that a success notice is to be
 407   * created. Refer to `createNotice` for options documentation.
 408   *
 409   * @see createNotice
 410   *
 411   * @param {string} content   Notice message.
 412   * @param {Object} [options] Optional notice options.
 413   *
 414   * @return {Object} Action object.
 415   */
 416  
 417  function createSuccessNotice(content, options) {
 418    return createNotice('success', content, options);
 419  }
 420  /**
 421   * Returns an action object used in signalling that an info notice is to be
 422   * created. Refer to `createNotice` for options documentation.
 423   *
 424   * @see createNotice
 425   *
 426   * @param {string} content   Notice message.
 427   * @param {Object} [options] Optional notice options.
 428   *
 429   * @return {Object} Action object.
 430   */
 431  
 432  function createInfoNotice(content, options) {
 433    return createNotice('info', content, options);
 434  }
 435  /**
 436   * Returns an action object used in signalling that an error notice is to be
 437   * created. Refer to `createNotice` for options documentation.
 438   *
 439   * @see createNotice
 440   *
 441   * @param {string} content   Notice message.
 442   * @param {Object} [options] Optional notice options.
 443   *
 444   * @return {Object} Action object.
 445   */
 446  
 447  function createErrorNotice(content, options) {
 448    return createNotice('error', content, options);
 449  }
 450  /**
 451   * Returns an action object used in signalling that a warning notice is to be
 452   * created. Refer to `createNotice` for options documentation.
 453   *
 454   * @see createNotice
 455   *
 456   * @param {string} content   Notice message.
 457   * @param {Object} [options] Optional notice options.
 458   *
 459   * @return {Object} Action object.
 460   */
 461  
 462  function createWarningNotice(content, options) {
 463    return createNotice('warning', content, options);
 464  }
 465  /**
 466   * Returns an action object used in signalling that a notice is to be removed.
 467   *
 468   * @param {string} id                 Notice unique identifier.
 469   * @param {string} [context='global'] Optional context (grouping) in which the notice is
 470   *                                    intended to appear. Defaults to default context.
 471   *
 472   * @return {Object} Action object.
 473   */
 474  
 475  function removeNotice(id) {
 476    var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
 477    return {
 478      type: 'REMOVE_NOTICE',
 479      id: id,
 480      context: context
 481    };
 482  }
 483  
 484  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
 485  /**
 486   * Internal dependencies
 487   */
 488  
 489  /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
 490  
 491  /**
 492   * The default empty set of notices to return when there are no notices
 493   * assigned for a given notices context. This can occur if the getNotices
 494   * selector is called without a notice ever having been created for the
 495   * context. A shared value is used to ensure referential equality between
 496   * sequential selector calls, since otherwise `[] !== []`.
 497   *
 498   * @type {Array}
 499   */
 500  
 501  var DEFAULT_NOTICES = [];
 502  /**
 503   * @typedef {Object} WPNotice Notice object.
 504   *
 505   * @property {string}  id               Unique identifier of notice.
 506   * @property {string}  status           Status of notice, one of `success`,
 507   *                                      `info`, `error`, or `warning`. Defaults
 508   *                                      to `info`.
 509   * @property {string}  content          Notice message.
 510   * @property {string}  spokenMessage    Audibly announced message text used by
 511   *                                      assistive technologies.
 512   * @property {string}  __unstableHTML   Notice message as raw HTML. Intended to
 513   *                                      serve primarily for compatibility of
 514   *                                      server-rendered notices, and SHOULD NOT
 515   *                                      be used for notices. It is subject to
 516   *                                      removal without notice.
 517   * @property {boolean} isDismissible    Whether the notice can be dismissed by
 518   *                                      user. Defaults to `true`.
 519   * @property {string}  type             Type of notice, one of `default`,
 520   *                                      or `snackbar`. Defaults to `default`.
 521   * @property {boolean} speak            Whether the notice content should be
 522   *                                      announced to screen readers. Defaults to
 523   *                                      `true`.
 524   * @property {WPNoticeAction[]} actions User actions to present with notice.
 525   *
 526   */
 527  
 528  /**
 529   * Returns all notices as an array, optionally for a given context. Defaults to
 530   * the global context.
 531   *
 532   * @param {Object}  state   Notices state.
 533   * @param {?string} context Optional grouping context.
 534   *
 535   * @return {WPNotice[]} Array of notices.
 536   */
 537  
 538  function getNotices(state) {
 539    var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CONTEXT;
 540    return state[context] || DEFAULT_NOTICES;
 541  }
 542  
 543  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
 544  /**
 545   * WordPress dependencies
 546   */
 547  
 548  /**
 549   * Internal dependencies
 550   */
 551  
 552  
 553  
 554  
 555  /* harmony default export */ var store = (Object(external_this_wp_data_["registerStore"])('core/notices', {
 556    reducer: store_reducer,
 557    actions: actions_namespaceObject,
 558    selectors: selectors_namespaceObject
 559  }));
 560  
 561  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
 562  /**
 563   * Internal dependencies
 564   */
 565  
 566  
 567  
 568  /***/ }),
 569  
 570  /***/ 5:
 571  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 572  
 573  "use strict";
 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  
 590  /***/ })
 591  
 592  /******/ });


Generated: Sun Sep 20 01:00:03 2020 Cross-referenced by PHPXref 0.7.1