@wordpress/block-library
Version:
Block library for the WordPress editor.
64 lines (63 loc) • 2.16 kB
JavaScript
// packages/block-library/src/query/edit/enhanced-pagination-modal.js
import {
Button,
Modal,
__experimentalVStack as VStack
} from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import { useState, useEffect } from "@wordpress/element";
import { useUnsupportedBlocks } from "../utils";
import { jsx, jsxs } from "react/jsx-runtime";
var modalDescriptionId = "wp-block-query-enhanced-pagination-modal__description";
function EnhancedPaginationModal({
clientId,
attributes: { enhancedPagination },
setAttributes
}) {
const [isOpen, setOpen] = useState(false);
const hasUnsupportedBlocks = useUnsupportedBlocks(clientId);
useEffect(() => {
if (enhancedPagination && hasUnsupportedBlocks) {
setAttributes({ enhancedPagination: false });
setOpen(true);
}
}, [enhancedPagination, hasUnsupportedBlocks, setAttributes]);
const closeModal = () => {
setOpen(false);
};
const notice = __(
"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."
) + " " + __(
'If you still want to prevent full page reloads, remove that block, then disable "Reload full page" again in the Query Block settings.'
);
return isOpen && /* @__PURE__ */ jsx(
Modal,
{
title: __("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__ */ jsxs(VStack, { alignment: "right", spacing: 5, children: [
/* @__PURE__ */ jsx("span", { id: modalDescriptionId, children: notice }),
/* @__PURE__ */ jsx(
Button,
{
__next40pxDefaultSize: true,
variant: "primary",
onClick: closeModal,
children: __("OK")
}
)
] })
}
);
}
export {
EnhancedPaginationModal as default
};
//# sourceMappingURL=enhanced-pagination-modal.js.map