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


Generated: Sun Jan 19 01:00:03 2020 Cross-referenced by PHPXref 0.7.1