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