@wordpress/block-library
Version:
Block library for the WordPress editor.
76 lines (73 loc) • 2.61 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = EnhancedPaginationModal;
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _element = require("@wordpress/element");
var _utils = require("../utils");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const modalDescriptionId = 'wp-block-query-enhanced-pagination-modal__description';
function EnhancedPaginationModal({
clientId,
attributes: {
enhancedPagination
},
setAttributes
}) {
const [isOpen, setOpen] = (0, _element.useState)(false);
const {
hasBlocksFromPlugins,
hasPostContentBlock,
hasUnsupportedBlocks
} = (0, _utils.useUnsupportedBlocks)(clientId);
(0, _element.useEffect)(() => {
if (enhancedPagination && hasUnsupportedBlocks) {
setAttributes({
enhancedPagination: false
});
setOpen(true);
}
}, [enhancedPagination, hasUnsupportedBlocks, setAttributes]);
const closeModal = () => {
setOpen(false);
};
let notice = (0, _i18n.__)('If you still want to prevent full page reloads, remove that block, then disable "Reload full page" again in the Query Block settings.');
if (hasBlocksFromPlugins) {
notice = (0, _i18n.__)('Currently, avoiding full page reloads is not possible when non-interactive or non-client Navigation compatible blocks from plugins are present inside the Query block.') + ' ' + notice;
} else if (hasPostContentBlock) {
notice = (0, _i18n.__)('Currently, avoiding full page reloads is not possible when a Content block is present inside the Query block.') + ' ' + notice;
}
return isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
title: (0, _i18n.__)('Query block: Reload full page enabled'),
className: "wp-block-query__enhanced-pagination-modal",
aria: {
describedby: modalDescriptionId
},
role: "alertdialog",
focusOnMount: "firstElement",
isDismissible: false,
onRequestClose: closeModal,
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
alignment: "right",
spacing: 5,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
id: modalDescriptionId,
children: notice
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
__next40pxDefaultSize: true,
variant: "primary",
onClick: closeModal,
children: (0, _i18n.__)('OK')
})]
})
});
}
//# sourceMappingURL=enhanced-pagination-modal.js.map
;