[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> data-controls.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["dataControls"] =
   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 = 398);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 18:
  91  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92  
  93  "use strict";
  94  
  95  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
  96  var arrayLikeToArray = __webpack_require__(25);
  97  
  98  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
  99  
 100  function _arrayWithoutHoles(arr) {
 101    if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
 102  }
 103  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
 104  var iterableToArray = __webpack_require__(35);
 105  
 106  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 107  var unsupportedIterableToArray = __webpack_require__(27);
 108  
 109  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
 110  function _nonIterableSpread() {
 111    throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 112  }
 113  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
 114  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; });
 115  
 116  
 117  
 118  
 119  function _toConsumableArray(arr) {
 120    return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
 121  }
 122  
 123  /***/ }),
 124  
 125  /***/ 25:
 126  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 127  
 128  "use strict";
 129  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
 130  function _arrayLikeToArray(arr, len) {
 131    if (len == null || len > arr.length) len = arr.length;
 132  
 133    for (var i = 0, arr2 = new Array(len); i < len; i++) {
 134      arr2[i] = arr[i];
 135    }
 136  
 137    return arr2;
 138  }
 139  
 140  /***/ }),
 141  
 142  /***/ 27:
 143  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 144  
 145  "use strict";
 146  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 147  /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25);
 148  
 149  function _unsupportedIterableToArray(o, minLen) {
 150    if (!o) return;
 151    if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 152    var n = Object.prototype.toString.call(o).slice(8, -1);
 153    if (n === "Object" && o.constructor) n = o.constructor.name;
 154    if (n === "Map" || n === "Set") return Array.from(n);
 155    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 156  }
 157  
 158  /***/ }),
 159  
 160  /***/ 35:
 161  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 162  
 163  "use strict";
 164  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 165  function _iterableToArray(iter) {
 166    if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
 167  }
 168  
 169  /***/ }),
 170  
 171  /***/ 398:
 172  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 173  
 174  "use strict";
 175  __webpack_require__.r(__webpack_exports__);
 176  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "apiFetch", function() { return apiFetch; });
 177  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "select", function() { return select; });
 178  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dispatch", function() { return dispatch; });
 179  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "controls", function() { return controls; });
 180  /* harmony import */ var _babel_runtime_helpers_esm_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
 181  /* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(42);
 182  /* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__);
 183  /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
 184  /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__);
 185  
 186  
 187  /**
 188   * WordPress dependencies
 189   */
 190  
 191  
 192  /**
 193   * Dispatches a control action for triggering an api fetch call.
 194   *
 195   * @param {Object} request Arguments for the fetch request.
 196   *
 197   * @example
 198   * ```js
 199   * import { apiFetch } from '@wordpress/data-controls';
 200   *
 201   * // Action generator using apiFetch
 202   * export function* myAction() {
 203   *     const path = '/v2/my-api/items';
 204   *     const items = yield apiFetch( { path } );
 205   *     // do something with the items.
 206   * }
 207   * ```
 208   *
 209   * @return {Object} The control descriptor.
 210   */
 211  
 212  var apiFetch = function apiFetch(request) {
 213    return {
 214      type: 'API_FETCH',
 215      request: request
 216    };
 217  };
 218  /**
 219   * Dispatches a control action for triggering a registry select.
 220   *
 221   * Note: when this control action is handled, it automatically considers
 222   * selectors that may have a resolver. It will await and return the resolved
 223   * value when the selector has not been resolved yet.
 224   *
 225   * @param {string} storeKey      The key for the store the selector belongs to
 226   * @param {string} selectorName  The name of the selector
 227   * @param {Array}  args          Arguments for the select.
 228   *
 229   * @example
 230   * ```js
 231   * import { select } from '@wordpress/data-controls';
 232   *
 233   * // Action generator using select
 234   * export function* myAction() {
 235   *     const isSidebarOpened = yield select( 'core/edit-post', 'isEditorSideBarOpened' );
 236   *     // do stuff with the result from the select.
 237   * }
 238   * ```
 239   *
 240   * @return {Object} The control descriptor.
 241   */
 242  
 243  function select(storeKey, selectorName) {
 244    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
 245      args[_key - 2] = arguments[_key];
 246    }
 247  
 248    return {
 249      type: 'SELECT',
 250      storeKey: storeKey,
 251      selectorName: selectorName,
 252      args: args
 253    };
 254  }
 255  /**
 256   * Dispatches a control action for triggering a registry dispatch.
 257   *
 258   * @param {string} storeKey    The key for the store the action belongs to
 259   * @param {string} actionName  The name of the action to dispatch
 260   * @param {Array}  args        Arguments for the dispatch action.
 261   *
 262   * @example
 263   * ```js
 264   * import { dispatch } from '@wordpress/data-controls';
 265   *
 266   * // Action generator using dispatch
 267   * export function* myAction() {
 268   *     yield dispatch( 'core/edit-post', 'togglePublishSidebar' );
 269   *     // do some other things.
 270   * }
 271   * ```
 272   *
 273   * @return {Object}  The control descriptor.
 274   */
 275  
 276  function dispatch(storeKey, actionName) {
 277    for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
 278      args[_key2 - 2] = arguments[_key2];
 279    }
 280  
 281    return {
 282      type: 'DISPATCH',
 283      storeKey: storeKey,
 284      actionName: actionName,
 285      args: args
 286    };
 287  }
 288  /**
 289   * The default export is what you use to register the controls with your custom
 290   * store.
 291   *
 292   * @example
 293   * ```js
 294   * // WordPress dependencies
 295   * import { controls } from '@wordpress/data-controls';
 296   * import { registerStore } from '@wordpress/data';
 297   *
 298   * // Internal dependencies
 299   * import reducer from './reducer';
 300   * import * as selectors from './selectors';
 301   * import * as actions from './actions';
 302   * import * as resolvers from './resolvers';
 303   *
 304   * registerStore( 'my-custom-store', {
 305   *     reducer,
 306   *     controls,
 307   *     actions,
 308   *     selectors,
 309   *     resolvers,
 310   * } );
 311   * ```
 312   *
 313   * @return {Object} An object for registering the default controls with the
 314   *                  store.
 315   */
 316  
 317  var controls = {
 318    API_FETCH: function API_FETCH(_ref) {
 319      var request = _ref.request;
 320      return _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()(request);
 321    },
 322    SELECT: Object(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__["createRegistryControl"])(function (registry) {
 323      return function (_ref2) {
 324        var _registry;
 325  
 326        var storeKey = _ref2.storeKey,
 327            selectorName = _ref2.selectorName,
 328            args = _ref2.args;
 329        return (_registry = registry[registry.select(storeKey)[selectorName].hasResolver ? '__experimentalResolveSelect' : 'select'](storeKey))[selectorName].apply(_registry, Object(_babel_runtime_helpers_esm_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(args));
 330      };
 331    }),
 332    DISPATCH: Object(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__["createRegistryControl"])(function (registry) {
 333      return function (_ref3) {
 334        var _registry$dispatch;
 335  
 336        var storeKey = _ref3.storeKey,
 337            actionName = _ref3.actionName,
 338            args = _ref3.args;
 339        return (_registry$dispatch = registry.dispatch(storeKey))[actionName].apply(_registry$dispatch, Object(_babel_runtime_helpers_esm_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(args));
 340      };
 341    })
 342  };
 343  
 344  
 345  /***/ }),
 346  
 347  /***/ 4:
 348  /***/ (function(module, exports) {
 349  
 350  (function() { module.exports = this["wp"]["data"]; }());
 351  
 352  /***/ }),
 353  
 354  /***/ 42:
 355  /***/ (function(module, exports) {
 356  
 357  (function() { module.exports = this["wp"]["apiFetch"]; }());
 358  
 359  /***/ })
 360  
 361  /******/ });


Generated: Wed Apr 8 01:00:03 2020 Cross-referenced by PHPXref 0.7.1