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


Generated: Sun Dec 5 01:00:03 2021 Cross-referenced by PHPXref 0.7.1