[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/define property getters */
   8  /******/     (() => {
   9  /******/         // define getter functions for harmony exports
  10  /******/         __webpack_require__.d = (exports, definition) => {
  11  /******/             for(var key in definition) {
  12  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14  /******/                 }
  15  /******/             }
  16  /******/         };
  17  /******/     })();
  18  /******/     
  19  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  20  /******/     (() => {
  21  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  22  /******/     })();
  23  /******/     
  24  /******/     /* webpack/runtime/make namespace object */
  25  /******/     (() => {
  26  /******/         // define __esModule on exports
  27  /******/         __webpack_require__.r = (exports) => {
  28  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30  /******/             }
  31  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  32  /******/         };
  33  /******/     })();
  34  /******/     
  35  /************************************************************************/
  36  var __webpack_exports__ = {};
  37  // ESM COMPAT FLAG
  38  __webpack_require__.r(__webpack_exports__);
  39  
  40  // EXPORTS
  41  __webpack_require__.d(__webpack_exports__, {
  42    store: () => (/* reexport */ store)
  43  });
  44  
  45  // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js
  46  var actions_namespaceObject = {};
  47  __webpack_require__.r(actions_namespaceObject);
  48  __webpack_require__.d(actions_namespaceObject, {
  49    createErrorNotice: () => (createErrorNotice),
  50    createInfoNotice: () => (createInfoNotice),
  51    createNotice: () => (createNotice),
  52    createSuccessNotice: () => (createSuccessNotice),
  53    createWarningNotice: () => (createWarningNotice),
  54    removeAllNotices: () => (removeAllNotices),
  55    removeNotice: () => (removeNotice),
  56    removeNotices: () => (removeNotices)
  57  });
  58  
  59  // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js
  60  var selectors_namespaceObject = {};
  61  __webpack_require__.r(selectors_namespaceObject);
  62  __webpack_require__.d(selectors_namespaceObject, {
  63    getNotices: () => (getNotices)
  64  });
  65  
  66  ;// external ["wp","data"]
  67  const external_wp_data_namespaceObject = window["wp"]["data"];
  68  ;// ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
  69  const onSubKey = (actionProperty) => (reducer) => (state = {}, action) => {
  70    const key = action[actionProperty];
  71    if (key === void 0) {
  72      return state;
  73    }
  74    const nextKeyState = reducer(state[key], action);
  75    if (nextKeyState === state[key]) {
  76      return state;
  77    }
  78    return {
  79      ...state,
  80      [key]: nextKeyState
  81    };
  82  };
  83  var on_sub_key_default = onSubKey;
  84  
  85  
  86  ;// ./node_modules/@wordpress/notices/build-module/store/reducer.js
  87  
  88  const notices = on_sub_key_default("context")((state = [], action) => {
  89    switch (action.type) {
  90      case "CREATE_NOTICE":
  91        return [
  92          ...state.filter(({ id }) => id !== action.notice.id),
  93          action.notice
  94        ];
  95      case "REMOVE_NOTICE":
  96        return state.filter(({ id }) => id !== action.id);
  97      case "REMOVE_NOTICES":
  98        return state.filter(({ id }) => !action.ids.includes(id));
  99      case "REMOVE_ALL_NOTICES":
 100        return state.filter(({ type }) => type !== action.noticeType);
 101    }
 102    return state;
 103  });
 104  var reducer_default = notices;
 105  
 106  
 107  ;// ./node_modules/@wordpress/notices/build-module/store/constants.js
 108  const DEFAULT_CONTEXT = "global";
 109  const DEFAULT_STATUS = "info";
 110  
 111  
 112  ;// ./node_modules/@wordpress/notices/build-module/store/actions.js
 113  
 114  let uniqueId = 0;
 115  function createNotice(status = DEFAULT_STATUS, content, options = {}) {
 116    const {
 117      speak = true,
 118      isDismissible = true,
 119      context = DEFAULT_CONTEXT,
 120      id = `$context}${++uniqueId}`,
 121      actions = [],
 122      type = "default",
 123      __unstableHTML,
 124      icon = null,
 125      explicitDismiss = false,
 126      onDismiss
 127    } = options;
 128    content = String(content);
 129    return {
 130      type: "CREATE_NOTICE",
 131      context,
 132      notice: {
 133        id,
 134        status,
 135        content,
 136        spokenMessage: speak ? content : null,
 137        __unstableHTML,
 138        isDismissible,
 139        actions,
 140        type,
 141        icon,
 142        explicitDismiss,
 143        onDismiss
 144      }
 145    };
 146  }
 147  function createSuccessNotice(content, options) {
 148    return createNotice("success", content, options);
 149  }
 150  function createInfoNotice(content, options) {
 151    return createNotice("info", content, options);
 152  }
 153  function createErrorNotice(content, options) {
 154    return createNotice("error", content, options);
 155  }
 156  function createWarningNotice(content, options) {
 157    return createNotice("warning", content, options);
 158  }
 159  function removeNotice(id, context = DEFAULT_CONTEXT) {
 160    return {
 161      type: "REMOVE_NOTICE",
 162      id,
 163      context
 164    };
 165  }
 166  function removeAllNotices(noticeType = "default", context = DEFAULT_CONTEXT) {
 167    return {
 168      type: "REMOVE_ALL_NOTICES",
 169      noticeType,
 170      context
 171    };
 172  }
 173  function removeNotices(ids, context = DEFAULT_CONTEXT) {
 174    return {
 175      type: "REMOVE_NOTICES",
 176      ids,
 177      context
 178    };
 179  }
 180  
 181  
 182  ;// ./node_modules/@wordpress/notices/build-module/store/selectors.js
 183  
 184  const DEFAULT_NOTICES = [];
 185  function getNotices(state, context = DEFAULT_CONTEXT) {
 186    return state[context] || DEFAULT_NOTICES;
 187  }
 188  
 189  
 190  ;// ./node_modules/@wordpress/notices/build-module/store/index.js
 191  
 192  
 193  
 194  
 195  const store = (0,external_wp_data_namespaceObject.createReduxStore)("core/notices", {
 196    reducer: reducer_default,
 197    actions: actions_namespaceObject,
 198    selectors: selectors_namespaceObject
 199  });
 200  (0,external_wp_data_namespaceObject.register)(store);
 201  
 202  
 203  ;// ./node_modules/@wordpress/notices/build-module/index.js
 204  
 205  
 206  
 207  (window.wp = window.wp || {}).notices = __webpack_exports__;
 208  /******/ })()
 209  ;


Generated : Wed Oct 29 08:20:06 2025 Cross-referenced by PHPXref