@wordpress/block-library
Version:
Block library for the WordPress editor.
56 lines (55 loc) • 2.15 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_element = require("@wordpress/element");
let _wordpress_i18n = require("@wordpress/i18n");
let _wordpress_components = require("@wordpress/components");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/template-part/edit/title-modal.jsx
function TitleModal({ areaLabel, onClose, onSubmit }) {
const [title, setTitle] = (0, _wordpress_element.useState)("");
const submitForCreation = (event) => {
event.preventDefault();
onSubmit(title);
};
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Modal, {
title: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Create new %s"), areaLabel.toLowerCase()),
onRequestClose: onClose,
focusOnMount: "firstContentElement",
size: "small",
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
onSubmit: submitForCreation,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_components.__experimentalVStack, {
spacing: "5",
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.TextControl, {
label: (0, _wordpress_i18n.__)("Name"),
value: title,
onChange: setTitle,
placeholder: (0, _wordpress_i18n.__)("Custom Template Part")
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_components.__experimentalHStack, {
justify: "right",
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
__next40pxDefaultSize: true,
variant: "tertiary",
onClick: () => {
onClose();
setTitle("");
},
children: (0, _wordpress_i18n.__)("Cancel")
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
variant: "primary",
type: "submit",
accessibleWhenDisabled: true,
disabled: !title.length,
__next40pxDefaultSize: true,
children: (0, _wordpress_i18n.__)("Create")
})]
})]
})
})
});
}
exports.default = TitleModal;
//# sourceMappingURL=title-modal.cjs.map