[ 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 = "Ko7W");
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  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
 102  __webpack_require__.r(__webpack_exports__);
 103  
 104  // EXPORTS
 105  __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
 106  
 107  // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
 108  var actions_namespaceObject = {};
 109  __webpack_require__.r(actions_namespaceObject);
 110  __webpack_require__.d(actions_namespaceObject, "createNotice", function() { return createNotice; });
 111  __webpack_require__.d(actions_namespaceObject, "createSuccessNotice", function() { return createSuccessNotice; });
 112  __webpack_require__.d(actions_namespaceObject, "createInfoNotice", function() { return createInfoNotice; });
 113  __webpack_require__.d(actions_namespaceObject, "createErrorNotice", function() { return createErrorNotice; });
 114  __webpack_require__.d(actions_namespaceObject, "createWarningNotice", function() { return createWarningNotice; });
 115  __webpack_require__.d(actions_namespaceObject, "removeNotice", function() { return removeNotice; });
 116  
 117  // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
 118  var selectors_namespaceObject = {};
 119  __webpack_require__.r(selectors_namespaceObject);
 120  __webpack_require__.d(selectors_namespaceObject, "getNotices", function() { return getNotices; });
 121  
 122  // EXTERNAL MODULE: external ["wp","data"]
 123  var external_wp_data_ = __webpack_require__("1ZqX");
 124  
 125  // EXTERNAL MODULE: external "lodash"
 126  var external_lodash_ = __webpack_require__("YLtl");
 127  
 128  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
 129  /**
 130   * Higher-order reducer creator which creates a combined reducer object, keyed
 131   * by a property on the action object.
 132   *
 133   * @param {string} actionProperty Action property by which to key object.
 134   *
 135   * @return {Function} Higher-order reducer.
 136   */
 137  const onSubKey = actionProperty => reducer => (state = {}, action) => {
 138    // Retrieve subkey from action. Do not track if undefined; useful for cases
 139    // where reducer is scoped by action shape.
 140    const key = action[actionProperty];
 141  
 142    if (key === undefined) {
 143      return state;
 144    } // Avoid updating state if unchanged. Note that this also accounts for a
 145    // reducer which returns undefined on a key which is not yet tracked.
 146  
 147  
 148    const nextKeyState = reducer(state[key], action);
 149  
 150    if (nextKeyState === state[key]) {
 151      return state;
 152    }
 153  
 154    return { ...state,
 155      [key]: nextKeyState
 156    };
 157  };
 158  /* harmony default export */ var on_sub_key = (onSubKey);
 159  
 160  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/reducer.js
 161  /**
 162   * External dependencies
 163   */
 164  
 165  /**
 166   * Internal dependencies
 167   */
 168  
 169  
 170  /**
 171   * Reducer returning the next notices state. The notices state is an object
 172   * where each key is a context, its value an array of notice objects.
 173   *
 174   * @param {Object} state  Current state.
 175   * @param {Object} action Dispatched action.
 176   *
 177   * @return {Object} Updated state.
 178   */
 179  
 180  const notices = on_sub_key('context')((state = [], action) => {
 181    switch (action.type) {
 182      case 'CREATE_NOTICE':
 183        // Avoid duplicates on ID.
 184        return [...Object(external_lodash_["reject"])(state, {
 185          id: action.notice.id
 186        }), action.notice];
 187  
 188      case 'REMOVE_NOTICE':
 189        return Object(external_lodash_["reject"])(state, {
 190          id: action.id
 191        });
 192    }
 193  
 194    return state;
 195  });
 196  /* harmony default export */ var reducer = (notices);
 197  
 198  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/constants.js
 199  /**
 200   * 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
 202   * and, more importantly, referenced consistently in the store implementation.
 203   *
 204   * @type {string}
 205   */
 206  const DEFAULT_CONTEXT = 'global';
 207  /**
 208   * Default notice status.
 209   *
 210   * @type {string}
 211   */
 212  
 213  const DEFAULT_STATUS = 'info';
 214  
 215  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/actions.js
 216  /**
 217   * External dependencies
 218   */
 219  
 220  /**
 221   * Internal dependencies
 222   */
 223  
 224  
 225  /**
 226   * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
 227   *
 228   * @property {string}    label    Message to use as action label.
 229   * @property {?string}   url      Optional URL of resource if action incurs
 230   *                                browser navigation.
 231   * @property {?Function} onClick  Optional function to invoke when action is
 232   *                                triggered by user.
 233   *
 234   */
 235  
 236  /**
 237   * Returns an action object used in signalling that a notice is to be created.
 238   *
 239   * @param {string}                [status='info']              Notice status.
 240   * @param {string}                content                      Notice message.
 241   * @param {Object}                [options]                    Notice options.
 242   * @param {string}                [options.context='global']   Context under which to
 243   *                                                             group notice.
 244   * @param {string}                [options.id]                 Identifier for notice.
 245   *                                                             Automatically assigned
 246   *                                                             if not specified.
 247   * @param {boolean}               [options.isDismissible=true] Whether the notice can
 248   *                                                             be dismissed by user.
 249   * @param {string}                [options.type='default']     Type of notice, one of
 250   *                                                             `default`, or `snackbar`.
 251   * @param {boolean}               [options.speak=true]         Whether the notice
 252   *                                                             content should be
 253   *                                                             announced to screen
 254   *                                                             readers.
 255   * @param {Array<WPNoticeAction>} [options.actions]            User actions to be
 256   *                                                             presented with notice.
 257   * @param {Object}                [options.icon]               An icon displayed with the notice.
 258   * @param {boolean}               [options.explicitDismiss]    Whether the notice includes
 259   *                                                             an explict dismiss button and
 260   *                                                             can't be dismissed by clicking
 261   *                                                             the body of the notice.
 262   * @param {Function}              [options.onDismiss]          Called when the notice is dismissed.
 263   *
 264   * @return {Object} Action object.
 265   */
 266  
 267  function createNotice(status = DEFAULT_STATUS, content, options = {}) {
 268    const {
 269      speak = true,
 270      isDismissible = true,
 271      context = DEFAULT_CONTEXT,
 272      id = Object(external_lodash_["uniqueId"])(context),
 273      actions = [],
 274      type = 'default',
 275      __unstableHTML,
 276      icon = null,
 277      explicitDismiss = false,
 278      onDismiss = null
 279    } = 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
 281    // supported, cast to a string.
 282  
 283    content = String(content);
 284    return {
 285      type: 'CREATE_NOTICE',
 286      context,
 287      notice: {
 288        id,
 289        status,
 290        content,
 291        spokenMessage: speak ? content : null,
 292        __unstableHTML,
 293        isDismissible,
 294        actions,
 295        type,
 296        icon,
 297        explicitDismiss,
 298        onDismiss
 299      }
 300    };
 301  }
 302  /**
 303   * Returns an action object used in signalling that a success notice is to be
 304   * created. Refer to `createNotice` for options documentation.
 305   *
 306   * @see createNotice
 307   *
 308   * @param {string} content   Notice message.
 309   * @param {Object} [options] Optional notice options.
 310   *
 311   * @return {Object} Action object.
 312   */
 313  
 314  function createSuccessNotice(content, options) {
 315    return createNotice('success', content, options);
 316  }
 317  /**
 318   * Returns an action object used in signalling that an info notice is to be
 319   * created. Refer to `createNotice` for options documentation.
 320   *
 321   * @see createNotice
 322   *
 323   * @param {string} content   Notice message.
 324   * @param {Object} [options] Optional notice options.
 325   *
 326   * @return {Object} Action object.
 327   */
 328  
 329  function createInfoNotice(content, options) {
 330    return createNotice('info', content, options);
 331  }
 332  /**
 333   * Returns an action object used in signalling that an error notice is to be
 334   * created. Refer to `createNotice` for options documentation.
 335   *
 336   * @see createNotice
 337   *
 338   * @param {string} content   Notice message.
 339   * @param {Object} [options] Optional notice options.
 340   *
 341   * @return {Object} Action object.
 342   */
 343  
 344  function createErrorNotice(content, options) {
 345    return createNotice('error', content, options);
 346  }
 347  /**
 348   * Returns an action object used in signalling that a warning notice is to be
 349   * created. Refer to `createNotice` for options documentation.
 350   *
 351   * @see createNotice
 352   *
 353   * @param {string} content   Notice message.
 354   * @param {Object} [options] Optional notice options.
 355   *
 356   * @return {Object} Action object.
 357   */
 358  
 359  function createWarningNotice(content, options) {
 360    return createNotice('warning', content, options);
 361  }
 362  /**
 363   * Returns an action object used in signalling that a notice is to be removed.
 364   *
 365   * @param {string} id                 Notice unique identifier.
 366   * @param {string} [context='global'] Optional context (grouping) in which the notice is
 367   *                                    intended to appear. Defaults to default context.
 368   *
 369   * @return {Object} Action object.
 370   */
 371  
 372  function removeNotice(id, context = DEFAULT_CONTEXT) {
 373    return {
 374      type: 'REMOVE_NOTICE',
 375      id,
 376      context
 377    };
 378  }
 379  
 380  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/selectors.js
 381  /**
 382   * Internal dependencies
 383   */
 384  
 385  /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
 386  
 387  /**
 388   * The default empty set of notices to return when there are no notices
 389   * assigned for a given notices context. This can occur if the getNotices
 390   * selector is called without a notice ever having been created for the
 391   * context. A shared value is used to ensure referential equality between
 392   * sequential selector calls, since otherwise `[] !== []`.
 393   *
 394   * @type {Array}
 395   */
 396  
 397  const DEFAULT_NOTICES = [];
 398  /**
 399   * @typedef {Object} WPNotice Notice object.
 400   *
 401   * @property {string}  id               Unique identifier of notice.
 402   * @property {string}  status           Status of notice, one of `success`,
 403   *                                      `info`, `error`, or `warning`. Defaults
 404   *                                      to `info`.
 405   * @property {string}  content          Notice message.
 406   * @property {string}  spokenMessage    Audibly announced message text used by
 407   *                                      assistive technologies.
 408   * @property {string}  __unstableHTML   Notice message as raw HTML. Intended to
 409   *                                      serve primarily for compatibility of
 410   *                                      server-rendered notices, and SHOULD NOT
 411   *                                      be used for notices. It is subject to
 412   *                                      removal without notice.
 413   * @property {boolean} isDismissible    Whether the notice can be dismissed by
 414   *                                      user. Defaults to `true`.
 415   * @property {string}  type             Type of notice, one of `default`,
 416   *                                      or `snackbar`. Defaults to `default`.
 417   * @property {boolean} speak            Whether the notice content should be
 418   *                                      announced to screen readers. Defaults to
 419   *                                      `true`.
 420   * @property {WPNoticeAction[]} actions User actions to present with notice.
 421   *
 422   */
 423  
 424  /**
 425   * Returns all notices as an array, optionally for a given context. Defaults to
 426   * the global context.
 427   *
 428   * @param {Object}  state   Notices state.
 429   * @param {?string} context Optional grouping context.
 430   *
 431   * @return {WPNotice[]} Array of notices.
 432   */
 433  
 434  function getNotices(state, context = DEFAULT_CONTEXT) {
 435    return state[context] || DEFAULT_NOTICES;
 436  }
 437  
 438  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/store/index.js
 439  /**
 440   * WordPress dependencies
 441   */
 442  
 443  /**
 444   * Internal dependencies
 445   */
 446  
 447  
 448  
 449  
 450  /**
 451   * Store definition for the notices namespace.
 452   *
 453   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 454   *
 455   * @type {Object}
 456   */
 457  
 458  const store = Object(external_wp_data_["createReduxStore"])('core/notices', {
 459    reducer: reducer,
 460    actions: actions_namespaceObject,
 461    selectors: selectors_namespaceObject
 462  });
 463  Object(external_wp_data_["register"])(store);
 464  
 465  // CONCATENATED MODULE: ./node_modules/@wordpress/notices/build-module/index.js
 466  
 467  
 468  
 469  /***/ }),
 470  
 471  /***/ "YLtl":
 472  /***/ (function(module, exports) {
 473  
 474  (function() { module.exports = window["lodash"]; }());
 475  
 476  /***/ })
 477  
 478  /******/ });


Generated: Mon Jun 21 01:00:04 2021 Cross-referenced by PHPXref 0.7.1