UNPKG

@wordpress/global-styles-ui

Version:
58 lines (57 loc) • 2.12 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let _wordpress_components = require("@wordpress/components"); let _wordpress_i18n = require("@wordpress/i18n"); let _wordpress_element = require("@wordpress/element"); let _wordpress_ui = require("@wordpress/ui"); let react_jsx_runtime = require("react/jsx-runtime"); // packages/global-styles-ui/src/presets/dialogs/rename-dialog.tsx function RenameDialog({ initialName, placeholder, toggleOpen, onRename }) { const [newName, setNewName] = (0, _wordpress_element.useState)(initialName); const handleConfirm = () => { if (newName && newName.trim()) onRename(newName); toggleOpen(); }; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Modal, { onRequestClose: toggleOpen, focusOnMount: "firstContentElement", title: (0, _wordpress_i18n.__)("Rename"), size: "small", children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", { onSubmit: (event) => { event.preventDefault(); handleConfirm(); }, children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, { gap: "sm", direction: "column", children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalInputControl, { autoComplete: "off", value: newName, onChange: setNewName, label: (0, _wordpress_i18n.__)("Name"), placeholder }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, { justify: "end", direction: "row", children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, { __next40pxDefaultSize: true, variant: "tertiary", onClick: toggleOpen, children: (0, _wordpress_i18n.__)("Cancel") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, { __next40pxDefaultSize: true, variant: "primary", type: "submit", children: (0, _wordpress_i18n.__)("Save") })] })] }) }) }); } exports.default = RenameDialog; //# sourceMappingURL=rename-dialog.cjs.map