2023-09-21 09:26:32 -04:00
|
|
|
/******/ (function() { // webpackBootstrap
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ "use strict";
|
2023-02-07 02:04:52 -05:00
|
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
|
|
|
|
/***/ 5619:
|
2023-09-21 09:26:32 -04:00
|
|
|
/***/ (function(module) {
|
2023-02-07 02:04:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// do not edit .js files directly - edit src/index.jst
|
|
|
|
|
|
|
|
|
|
|
|
var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function equal(a, b) {
|
|
|
|
if (a === b) return true;
|
|
|
|
|
|
|
|
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
|
|
|
if (a.constructor !== b.constructor) return false;
|
|
|
|
|
|
|
|
var length, i, keys;
|
|
|
|
if (Array.isArray(a)) {
|
|
|
|
length = a.length;
|
|
|
|
if (length != b.length) return false;
|
|
|
|
for (i = length; i-- !== 0;)
|
|
|
|
if (!equal(a[i], b[i])) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((a instanceof Map) && (b instanceof Map)) {
|
|
|
|
if (a.size !== b.size) return false;
|
|
|
|
for (i of a.entries())
|
|
|
|
if (!b.has(i[0])) return false;
|
|
|
|
for (i of a.entries())
|
|
|
|
if (!equal(i[1], b.get(i[0]))) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((a instanceof Set) && (b instanceof Set)) {
|
|
|
|
if (a.size !== b.size) return false;
|
|
|
|
for (i of a.entries())
|
|
|
|
if (!b.has(i[0])) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
|
|
length = a.length;
|
|
|
|
if (length != b.length) return false;
|
|
|
|
for (i = length; i-- !== 0;)
|
|
|
|
if (a[i] !== b[i]) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
|
|
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
|
|
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
|
|
|
|
|
|
keys = Object.keys(a);
|
|
|
|
length = keys.length;
|
|
|
|
if (length !== Object.keys(b).length) return false;
|
|
|
|
|
|
|
|
for (i = length; i-- !== 0;)
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
|
|
|
|
|
|
for (i = length; i-- !== 0;) {
|
|
|
|
var key = keys[i];
|
|
|
|
|
|
|
|
if (!equal(a[key], b[key])) return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// true if both NaN, false otherwise
|
|
|
|
return a!==a && b!==b;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
|
|
/******/ });
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ // The module cache
|
|
|
|
/******/ var __webpack_module_cache__ = {};
|
|
|
|
/******/
|
|
|
|
/******/ // The require function
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
/******/ // Check if module is in cache
|
|
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
|
|
/******/ if (cachedModule !== undefined) {
|
|
|
|
/******/ return cachedModule.exports;
|
|
|
|
/******/ }
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
|
|
/******/ // no module.id needed
|
|
|
|
/******/ // no module.loaded needed
|
|
|
|
/******/ exports: {}
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // Execute the module function
|
|
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
|
|
/******/
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ }
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ /* webpack/runtime/compat get default export */
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ !function() {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ __webpack_require__.n = function(module) {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ var getter = module && module.__esModule ?
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ function() { return module['default']; } :
|
|
|
|
/******/ function() { return module; };
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ __webpack_require__.d(getter, { a: getter });
|
|
|
|
/******/ return getter;
|
|
|
|
/******/ };
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ }();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/define property getters */
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ !function() {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ // define getter functions for harmony exports
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ __webpack_require__.d = function(exports, definition) {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ for(var key in definition) {
|
|
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
|
|
/******/ }
|
|
|
|
/******/ }
|
2019-09-19 11:19:18 -04:00
|
|
|
/******/ };
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ }();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
2023-09-21 09:26:32 -04:00
|
|
|
/******/ !function() {
|
|
|
|
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
|
|
/******/ }();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
2019-09-19 11:19:18 -04:00
|
|
|
/************************************************************************/
|
2022-04-11 08:04:30 -04:00
|
|
|
var __webpack_exports__ = {};
|
2023-02-07 02:04:52 -05:00
|
|
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
2023-09-21 09:26:32 -04:00
|
|
|
!function() {
|
2019-09-19 11:19:18 -04:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
// EXPORTS
|
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
2023-09-21 09:26:32 -04:00
|
|
|
"default": function() { return /* binding */ build_module; }
|
2022-04-11 08:04:30 -04:00
|
|
|
});
|
2019-09-19 11:19:18 -04:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","element"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_element_namespaceObject = window["wp"]["element"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","data"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_data_namespaceObject = window["wp"]["data"];
|
2023-02-07 02:04:52 -05:00
|
|
|
// EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
|
|
|
|
var es6 = __webpack_require__(5619);
|
|
|
|
var es6_default = /*#__PURE__*/__webpack_require__.n(es6);
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","compose"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_compose_namespaceObject = window["wp"]["compose"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","i18n"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","apiFetch"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
|
2022-04-11 08:04:30 -04:00
|
|
|
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
|
|
|
|
;// CONCATENATED MODULE: external ["wp","url"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_url_namespaceObject = window["wp"]["url"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","components"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_components_namespaceObject = window["wp"]["components"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","blocks"]
|
2023-09-21 09:26:32 -04:00
|
|
|
var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/server-side-render.js
|
2019-09-19 11:19:18 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2019-09-19 11:19:18 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-15 11:19:43 -04:00
|
|
|
|
2023-02-07 02:04:52 -05:00
|
|
|
const EMPTY_OBJECT = {};
|
2023-06-27 10:24:19 -04:00
|
|
|
function rendererPath(block, attributes = null, urlQueryArgs = {}) {
|
2022-04-11 08:04:30 -04:00
|
|
|
return (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/block-renderer/${block}`, {
|
2021-05-19 11:09:27 -04:00
|
|
|
context: 'edit',
|
|
|
|
...(null !== attributes ? {
|
|
|
|
attributes
|
|
|
|
} : {}),
|
|
|
|
...urlQueryArgs
|
|
|
|
});
|
2019-09-19 11:19:18 -04:00
|
|
|
}
|
2023-02-07 02:04:52 -05:00
|
|
|
function removeBlockSupportAttributes(attributes) {
|
|
|
|
const {
|
|
|
|
backgroundColor,
|
|
|
|
borderColor,
|
|
|
|
fontFamily,
|
|
|
|
fontSize,
|
|
|
|
gradient,
|
|
|
|
textColor,
|
|
|
|
className,
|
|
|
|
...restAttributes
|
|
|
|
} = attributes;
|
|
|
|
const {
|
|
|
|
border,
|
|
|
|
color,
|
|
|
|
elements,
|
|
|
|
spacing,
|
|
|
|
typography,
|
|
|
|
...restStyles
|
2023-06-27 10:24:19 -04:00
|
|
|
} = attributes?.style || EMPTY_OBJECT;
|
2023-09-26 10:23:26 -04:00
|
|
|
return {
|
|
|
|
...restAttributes,
|
2023-02-07 02:04:52 -05:00
|
|
|
style: restStyles
|
|
|
|
};
|
|
|
|
}
|
2023-06-27 10:24:19 -04:00
|
|
|
function DefaultEmptyResponsePlaceholder({
|
|
|
|
className
|
|
|
|
}) {
|
2022-04-11 08:04:30 -04:00
|
|
|
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
|
2021-04-15 11:19:43 -04:00
|
|
|
className: className
|
2022-04-11 08:04:30 -04:00
|
|
|
}, (0,external_wp_i18n_namespaceObject.__)('Block rendered as empty.'));
|
2021-04-15 11:19:43 -04:00
|
|
|
}
|
2023-06-27 10:24:19 -04:00
|
|
|
function DefaultErrorResponsePlaceholder({
|
|
|
|
response,
|
|
|
|
className
|
|
|
|
}) {
|
2023-09-26 10:23:26 -04:00
|
|
|
const errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
|
|
|
|
// translators: %s: error message describing the problem
|
2022-04-11 08:04:30 -04:00
|
|
|
(0,external_wp_i18n_namespaceObject.__)('Error loading block: %s'), response.errorMsg);
|
|
|
|
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
|
2021-04-15 11:19:43 -04:00
|
|
|
className: className
|
|
|
|
}, errorMessage);
|
|
|
|
}
|
2023-06-27 10:24:19 -04:00
|
|
|
function DefaultLoadingResponsePlaceholder({
|
|
|
|
children,
|
|
|
|
showLoader
|
|
|
|
}) {
|
2022-04-11 08:04:30 -04:00
|
|
|
return (0,external_wp_element_namespaceObject.createElement)("div", {
|
2021-11-08 09:29:21 -05:00
|
|
|
style: {
|
|
|
|
position: 'relative'
|
|
|
|
}
|
2022-04-11 08:04:30 -04:00
|
|
|
}, showLoader && (0,external_wp_element_namespaceObject.createElement)("div", {
|
2021-11-08 09:29:21 -05:00
|
|
|
style: {
|
|
|
|
position: 'absolute',
|
|
|
|
top: '50%',
|
|
|
|
left: '50%',
|
|
|
|
marginTop: '-9px',
|
|
|
|
marginLeft: '-9px'
|
|
|
|
}
|
2022-04-11 08:04:30 -04:00
|
|
|
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
|
2021-11-08 09:29:21 -05:00
|
|
|
style: {
|
|
|
|
opacity: showLoader ? '0.3' : 1
|
|
|
|
}
|
|
|
|
}, children));
|
2021-04-15 11:19:43 -04:00
|
|
|
}
|
|
|
|
function ServerSideRender(props) {
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
|
|
|
attributes,
|
|
|
|
block,
|
|
|
|
className,
|
|
|
|
httpMethod = 'GET',
|
|
|
|
urlQueryArgs,
|
2023-02-07 02:04:52 -05:00
|
|
|
skipBlockSupportAttributes = false,
|
2021-05-19 11:09:27 -04:00
|
|
|
EmptyResponsePlaceholder = DefaultEmptyResponsePlaceholder,
|
|
|
|
ErrorResponsePlaceholder = DefaultErrorResponsePlaceholder,
|
|
|
|
LoadingResponsePlaceholder = DefaultLoadingResponsePlaceholder
|
|
|
|
} = props;
|
2022-04-11 08:04:30 -04:00
|
|
|
const isMountedRef = (0,external_wp_element_namespaceObject.useRef)(true);
|
|
|
|
const [showLoader, setShowLoader] = (0,external_wp_element_namespaceObject.useState)(false);
|
|
|
|
const fetchRequestRef = (0,external_wp_element_namespaceObject.useRef)();
|
|
|
|
const [response, setResponse] = (0,external_wp_element_namespaceObject.useState)(null);
|
|
|
|
const prevProps = (0,external_wp_compose_namespaceObject.usePrevious)(props);
|
|
|
|
const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
|
2021-04-15 11:19:43 -04:00
|
|
|
function fetchData() {
|
2023-02-07 02:04:52 -05:00
|
|
|
var _sanitizedAttributes, _sanitizedAttributes2;
|
2021-04-15 11:19:43 -04:00
|
|
|
if (!isMountedRef.current) {
|
|
|
|
return;
|
2019-09-19 11:19:18 -04:00
|
|
|
}
|
2021-11-08 09:29:21 -05:00
|
|
|
setIsLoading(true);
|
2023-02-07 02:04:52 -05:00
|
|
|
let sanitizedAttributes = attributes && (0,external_wp_blocks_namespaceObject.__experimentalSanitizeBlockAttributes)(block, attributes);
|
|
|
|
if (skipBlockSupportAttributes) {
|
|
|
|
sanitizedAttributes = removeBlockSupportAttributes(sanitizedAttributes);
|
2023-09-26 10:23:26 -04:00
|
|
|
}
|
2021-04-15 11:19:43 -04:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// If httpMethod is 'POST', send the attributes in the request body instead of the URL.
|
|
|
|
// This allows sending a larger attributes object than in a GET request, where the attributes are in the URL.
|
2021-05-19 11:09:27 -04:00
|
|
|
const isPostRequest = 'POST' === httpMethod;
|
2023-02-07 02:04:52 -05:00
|
|
|
const urlAttributes = isPostRequest ? null : (_sanitizedAttributes = sanitizedAttributes) !== null && _sanitizedAttributes !== void 0 ? _sanitizedAttributes : null;
|
2021-05-19 11:09:27 -04:00
|
|
|
const path = rendererPath(block, urlAttributes, urlQueryArgs);
|
|
|
|
const data = isPostRequest ? {
|
2023-02-07 02:04:52 -05:00
|
|
|
attributes: (_sanitizedAttributes2 = sanitizedAttributes) !== null && _sanitizedAttributes2 !== void 0 ? _sanitizedAttributes2 : null
|
2023-09-26 10:23:26 -04:00
|
|
|
} : null;
|
2021-04-15 11:19:43 -04:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// Store the latest fetch request so that when we process it, we can
|
|
|
|
// check if it is the current request, to avoid race conditions on slow networks.
|
2021-05-19 11:09:27 -04:00
|
|
|
const fetchRequest = fetchRequestRef.current = external_wp_apiFetch_default()({
|
|
|
|
path,
|
|
|
|
data,
|
2021-04-15 11:19:43 -04:00
|
|
|
method: isPostRequest ? 'POST' : 'GET'
|
2021-05-19 11:09:27 -04:00
|
|
|
}).then(fetchResponse => {
|
2021-04-15 11:19:43 -04:00
|
|
|
if (isMountedRef.current && fetchRequest === fetchRequestRef.current && fetchResponse) {
|
|
|
|
setResponse(fetchResponse.rendered);
|
2019-09-19 11:19:18 -04:00
|
|
|
}
|
2021-05-19 11:09:27 -04:00
|
|
|
}).catch(error => {
|
2021-04-15 11:19:43 -04:00
|
|
|
if (isMountedRef.current && fetchRequest === fetchRequestRef.current) {
|
|
|
|
setResponse({
|
|
|
|
error: true,
|
|
|
|
errorMsg: error.message
|
2019-09-19 11:19:18 -04:00
|
|
|
});
|
|
|
|
}
|
2021-11-08 09:29:21 -05:00
|
|
|
}).finally(() => {
|
|
|
|
if (isMountedRef.current && fetchRequest === fetchRequestRef.current) {
|
|
|
|
setIsLoading(false);
|
|
|
|
}
|
2021-04-15 11:19:43 -04:00
|
|
|
});
|
|
|
|
return fetchRequest;
|
|
|
|
}
|
2023-09-26 10:23:26 -04:00
|
|
|
const debouncedFetchData = (0,external_wp_compose_namespaceObject.useDebounce)(fetchData, 500);
|
2019-09-19 11:19:18 -04:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// When the component unmounts, set isMountedRef to false. This will
|
2021-04-15 11:19:43 -04:00
|
|
|
// let the async fetch callbacks know when to stop.
|
2022-04-11 08:04:30 -04:00
|
|
|
(0,external_wp_element_namespaceObject.useEffect)(() => () => {
|
2021-05-19 11:09:27 -04:00
|
|
|
isMountedRef.current = false;
|
2021-04-15 11:19:43 -04:00
|
|
|
}, []);
|
2022-04-11 08:04:30 -04:00
|
|
|
(0,external_wp_element_namespaceObject.useEffect)(() => {
|
2021-04-15 11:19:43 -04:00
|
|
|
// Don't debounce the first fetch. This ensures that the first render
|
2022-04-12 11:12:47 -04:00
|
|
|
// shows data as soon as possible.
|
2021-04-15 11:19:43 -04:00
|
|
|
if (prevProps === undefined) {
|
|
|
|
fetchData();
|
2023-02-07 02:04:52 -05:00
|
|
|
} else if (!es6_default()(prevProps, props)) {
|
2021-04-15 11:19:43 -04:00
|
|
|
debouncedFetchData();
|
2019-09-19 11:19:18 -04:00
|
|
|
}
|
2021-04-15 11:19:43 -04:00
|
|
|
});
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-11-08 09:29:21 -05:00
|
|
|
/**
|
|
|
|
* Effect to handle showing the loading placeholder.
|
|
|
|
* Show it only if there is no previous response or
|
|
|
|
* the request takes more than one second.
|
|
|
|
*/
|
2022-04-11 08:04:30 -04:00
|
|
|
(0,external_wp_element_namespaceObject.useEffect)(() => {
|
2021-11-08 09:29:21 -05:00
|
|
|
if (!isLoading) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const timeout = setTimeout(() => {
|
|
|
|
setShowLoader(true);
|
|
|
|
}, 1000);
|
|
|
|
return () => clearTimeout(timeout);
|
|
|
|
}, [isLoading]);
|
|
|
|
const hasResponse = !!response;
|
|
|
|
const hasEmptyResponse = response === '';
|
2023-06-27 10:24:19 -04:00
|
|
|
const hasError = response?.error;
|
2022-01-04 00:39:28 -05:00
|
|
|
if (isLoading) {
|
2023-09-26 10:23:26 -04:00
|
|
|
return (0,external_wp_element_namespaceObject.createElement)(LoadingResponsePlaceholder, {
|
|
|
|
...props,
|
2022-01-04 00:39:28 -05:00
|
|
|
showLoader: showLoader
|
2023-06-27 10:24:19 -04:00
|
|
|
}, hasResponse && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, {
|
2022-01-04 00:39:28 -05:00
|
|
|
className: className
|
|
|
|
}, response));
|
|
|
|
}
|
2021-11-08 09:29:21 -05:00
|
|
|
if (hasEmptyResponse || !hasResponse) {
|
2023-09-26 10:23:26 -04:00
|
|
|
return (0,external_wp_element_namespaceObject.createElement)(EmptyResponsePlaceholder, {
|
|
|
|
...props
|
2023-06-27 10:24:19 -04:00
|
|
|
});
|
2021-11-08 09:29:21 -05:00
|
|
|
}
|
|
|
|
if (hasError) {
|
2023-06-27 10:24:19 -04:00
|
|
|
return (0,external_wp_element_namespaceObject.createElement)(ErrorResponsePlaceholder, {
|
|
|
|
response: response,
|
|
|
|
...props
|
|
|
|
});
|
2019-09-19 11:19:18 -04:00
|
|
|
}
|
2022-04-11 08:04:30 -04:00
|
|
|
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, {
|
2021-04-15 11:19:43 -04:00
|
|
|
className: className
|
|
|
|
}, response);
|
|
|
|
}
|
2019-09-19 11:19:18 -04:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/server-side-render/build-module/index.js
|
2019-09-19 11:19:18 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2019-09-19 11:19:18 -04:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
2023-02-07 02:04:52 -05:00
|
|
|
const build_module_EMPTY_OBJECT = {};
|
2022-04-11 08:04:30 -04:00
|
|
|
const ExportedServerSideRender = (0,external_wp_data_namespaceObject.withSelect)(select => {
|
2021-11-08 09:29:21 -05:00
|
|
|
// FIXME: @wordpress/server-side-render should not depend on @wordpress/editor.
|
|
|
|
// It is used by blocks that can be loaded into a *non-post* block editor.
|
|
|
|
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
2021-05-19 11:09:27 -04:00
|
|
|
const coreEditorSelect = select('core/editor');
|
2019-09-19 11:19:18 -04:00
|
|
|
if (coreEditorSelect) {
|
2023-09-26 10:23:26 -04:00
|
|
|
const currentPostId = coreEditorSelect.getCurrentPostId();
|
|
|
|
// For templates and template parts we use a custom ID format.
|
2021-04-15 11:19:43 -04:00
|
|
|
// Since they aren't real posts, we don't want to use their ID
|
|
|
|
// for server-side rendering. Since they use a string based ID,
|
|
|
|
// we can assume real post IDs are numbers.
|
2021-05-21 06:14:23 -04:00
|
|
|
if (currentPostId && typeof currentPostId === 'number') {
|
2019-09-19 11:19:18 -04:00
|
|
|
return {
|
2021-05-19 11:09:27 -04:00
|
|
|
currentPostId
|
2019-09-19 11:19:18 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2023-02-07 02:04:52 -05:00
|
|
|
return build_module_EMPTY_OBJECT;
|
2023-06-27 10:24:19 -04:00
|
|
|
})(({
|
|
|
|
urlQueryArgs = build_module_EMPTY_OBJECT,
|
|
|
|
currentPostId,
|
|
|
|
...props
|
|
|
|
}) => {
|
2022-04-11 08:04:30 -04:00
|
|
|
const newUrlQueryArgs = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
2019-09-19 11:19:18 -04:00
|
|
|
if (!currentPostId) {
|
|
|
|
return urlQueryArgs;
|
|
|
|
}
|
2021-05-19 11:09:27 -04:00
|
|
|
return {
|
|
|
|
post_id: currentPostId,
|
|
|
|
...urlQueryArgs
|
|
|
|
};
|
2019-09-19 11:19:18 -04:00
|
|
|
}, [currentPostId, urlQueryArgs]);
|
2023-06-27 10:24:19 -04:00
|
|
|
return (0,external_wp_element_namespaceObject.createElement)(ServerSideRender, {
|
|
|
|
urlQueryArgs: newUrlQueryArgs,
|
|
|
|
...props
|
|
|
|
});
|
2019-09-19 11:19:18 -04:00
|
|
|
});
|
2023-09-21 09:26:32 -04:00
|
|
|
/* harmony default export */ var build_module = (ExportedServerSideRender);
|
2019-09-19 11:19:18 -04:00
|
|
|
|
2023-09-21 09:26:32 -04:00
|
|
|
}();
|
2022-04-11 08:04:30 -04:00
|
|
|
(window.wp = window.wp || {}).serverSideRender = __webpack_exports__["default"];
|
|
|
|
/******/ })()
|
|
|
|
;
|