UNPKG

@wordpress/block-library

Version:
1,209 lines (1,208 loc) • 37.4 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); // \0rolldown/runtime.js var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); let clsx = require("clsx"); clsx = __toESM(clsx); let _wordpress_block_editor = require("@wordpress/block-editor"); let _wordpress_compose = require("@wordpress/compose"); let ___utils_migrate_font_family_js = require("../utils/migrate-font-family.cjs"); ___utils_migrate_font_family_js = __toESM(___utils_migrate_font_family_js); let ___utils_migrate_text_align_js = require("../utils/migrate-text-align.cjs"); ___utils_migrate_text_align_js = __toESM(___utils_migrate_text_align_js); let react_jsx_runtime = require("react/jsx-runtime"); // packages/block-library/src/button/deprecated.jsx const migrateWidth = (attributes) => { const { width, ...otherAttributes } = attributes; if (!width) return otherAttributes; return { ...otherAttributes, style: { ...otherAttributes.style, dimensions: { ...otherAttributes.style?.dimensions, width: `${width}%` } } }; }; const migrateBorderRadius = (attributes) => { const { borderRadius, ...newAttributes } = attributes; const oldBorderRadius = [borderRadius, newAttributes.style?.border?.radius].find((possibleBorderRadius) => { return typeof possibleBorderRadius === "number" && possibleBorderRadius !== 0; }); if (!oldBorderRadius) return newAttributes; return { ...newAttributes, style: { ...newAttributes.style, border: { ...newAttributes.style?.border, radius: `${oldBorderRadius}px` } } }; }; function migrateAlign(attributes) { if (!attributes.align) return attributes; const { align, ...otherAttributes } = attributes; return { ...otherAttributes, className: (0, clsx.default)(otherAttributes.className, `align${attributes.align}`) }; } const migrateCustomColorsAndGradients = (attributes) => { if (!attributes.customTextColor && !attributes.customBackgroundColor && !attributes.customGradient) return attributes; const style = { color: {} }; if (attributes.customTextColor) style.color.text = attributes.customTextColor; if (attributes.customBackgroundColor) style.color.background = attributes.customBackgroundColor; if (attributes.customGradient) style.color.gradient = attributes.customGradient; const { customTextColor, customBackgroundColor, customGradient, ...restAttributes } = attributes; return { ...restAttributes, style }; }; const oldColorsMigration = (attributes) => { const { color, textColor, ...restAttributes } = { ...attributes, customTextColor: attributes.textColor && "#" === attributes.textColor[0] ? attributes.textColor : void 0, customBackgroundColor: attributes.color && "#" === attributes.color[0] ? attributes.color : void 0 }; return migrateCustomColorsAndGradients(restAttributes); }; const blockAttributes = { url: { type: "string", source: "attribute", selector: "a", attribute: "href" }, title: { type: "string", source: "attribute", selector: "a", attribute: "title" }, text: { type: "string", source: "html", selector: "a" } }; const deprecated = [ { attributes: { tagName: { type: "string", enum: ["a", "button"], default: "a" }, type: { type: "string", default: "button" }, url: { type: "string", source: "attribute", selector: "a", attribute: "href", role: "content" }, title: { type: "string", source: "attribute", selector: "a,button", attribute: "title", role: "content" }, text: { type: "rich-text", source: "rich-text", selector: "a,button", role: "content" }, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target", role: "content" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel", role: "content" }, placeholder: { type: "string" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, width: { type: "number" } }, supports: { anchor: true, splitting: true, align: false, alignWide: false, color: { __experimentalSkipSerialization: true, gradients: true, __experimentalDefaultControls: { background: true, text: true } }, typography: { __experimentalSkipSerialization: [ "fontSize", "lineHeight", "textAlign", "fontFamily", "fontWeight", "fontStyle", "textTransform", "textDecoration", "letterSpacing" ], fontSize: true, lineHeight: true, textAlign: true, __experimentalFontFamily: true, __experimentalFontWeight: true, __experimentalFontStyle: true, __experimentalTextTransform: true, __experimentalTextDecoration: true, __experimentalLetterSpacing: true, __experimentalWritingMode: true, __experimentalDefaultControls: { fontSize: true } }, reusable: false, shadow: { __experimentalSkipSerialization: true }, spacing: { __experimentalSkipSerialization: true, padding: ["horizontal", "vertical"], __experimentalDefaultControls: { padding: true } }, __experimentalBorder: { color: true, radius: true, style: true, width: true, __experimentalSkipSerialization: true, __experimentalDefaultControls: { color: true, radius: true, style: true, width: true } }, interactivity: { clientNavigation: true } }, selectors: { root: ".wp-block-button .wp-block-button__link", typography: { writingMode: ".wp-block-button" } }, save({ attributes, className }) { const { tagName, type, fontSize, linkTarget, rel, style, text, title, url, width } = attributes; const TagName = tagName || "a"; const isButtonTag = "button" === TagName; const buttonType = type || "button"; const borderProps = (0, _wordpress_block_editor.__experimentalGetBorderClassesAndStyles)(attributes); const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const spacingProps = (0, _wordpress_block_editor.__experimentalGetSpacingClassesAndStyles)(attributes); const shadowProps = (0, _wordpress_block_editor.__experimentalGetShadowClassesAndStyles)(attributes); const typographyProps = (0, _wordpress_block_editor.getTypographyClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, borderProps.className, typographyProps.className, { "no-border-radius": style?.border?.radius === 0, [`has-custom-font-size`]: fontSize || style?.typography?.fontSize }, (0, _wordpress_block_editor.__experimentalGetElementClassName)("button")); const buttonStyle = { ...borderProps.style, ...colorProps.style, ...spacingProps.style, ...shadowProps.style, ...typographyProps.style, writingMode: void 0 }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: TagName, type: isButtonTag ? buttonType : null, className: buttonClasses, href: isButtonTag ? null : url, title, style: buttonStyle, value: text, target: isButtonTag ? null : linkTarget, rel: isButtonTag ? null : rel }) }); }, isEligible(attributes) { return typeof attributes.width === "number"; }, migrate: migrateWidth }, { attributes: { tagName: { type: "string", enum: ["a", "button"], default: "a" }, type: { type: "string", default: "button" }, textAlign: { type: "string" }, url: { type: "string", source: "attribute", selector: "a", attribute: "href", role: "content" }, title: { type: "string", source: "attribute", selector: "a,button", attribute: "title", role: "content" }, text: { type: "rich-text", source: "rich-text", selector: "a,button", role: "content" }, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target", role: "content" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel", role: "content" }, placeholder: { type: "string" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, width: { type: "number" } }, supports: { anchor: true, align: true, alignWide: false, color: { __experimentalSkipSerialization: true, gradients: true, __experimentalDefaultControls: { background: true, text: true } }, typography: { __experimentalSkipSerialization: [ "fontSize", "lineHeight", "fontFamily", "fontWeight", "fontStyle", "textTransform", "textDecoration", "letterSpacing" ], fontSize: true, lineHeight: true, __experimentalFontFamily: true, __experimentalFontWeight: true, __experimentalFontStyle: true, __experimentalTextTransform: true, __experimentalTextDecoration: true, __experimentalLetterSpacing: true, __experimentalWritingMode: true, __experimentalDefaultControls: { fontSize: true } }, reusable: false, shadow: { __experimentalSkipSerialization: true }, spacing: { __experimentalSkipSerialization: true, padding: ["horizontal", "vertical"], __experimentalDefaultControls: { padding: true } }, __experimentalBorder: { color: true, radius: true, style: true, width: true, __experimentalSkipSerialization: true, __experimentalDefaultControls: { color: true, radius: true, style: true, width: true } }, interactivity: { clientNavigation: true } }, selectors: { root: ".wp-block-button .wp-block-button__link", typography: { writingMode: ".wp-block-button" } }, save({ attributes, className }) { const { tagName, type, textAlign, fontSize, linkTarget, rel, style, text, title, url, width } = attributes; const TagName = tagName || "a"; const isButtonTag = "button" === TagName; const buttonType = type || "button"; const borderProps = (0, _wordpress_block_editor.__experimentalGetBorderClassesAndStyles)(attributes); const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const spacingProps = (0, _wordpress_block_editor.__experimentalGetSpacingClassesAndStyles)(attributes); const shadowProps = (0, _wordpress_block_editor.__experimentalGetShadowClassesAndStyles)(attributes); const typographyProps = (0, _wordpress_block_editor.getTypographyClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, borderProps.className, typographyProps.className, { [`has-text-align-${textAlign}`]: textAlign, "no-border-radius": style?.border?.radius === 0, [`has-custom-font-size`]: fontSize || style?.typography?.fontSize }, (0, _wordpress_block_editor.__experimentalGetElementClassName)("button")); const buttonStyle = { ...borderProps.style, ...colorProps.style, ...spacingProps.style, ...shadowProps.style, ...typographyProps.style, writingMode: void 0 }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: TagName, type: isButtonTag ? buttonType : null, className: buttonClasses, href: isButtonTag ? null : url, title, style: buttonStyle, value: text, target: isButtonTag ? null : linkTarget, rel: isButtonTag ? null : rel }) }); }, isEligible(attributes) { return !!attributes.textAlign || typeof attributes.width === "number"; }, migrate: (0, _wordpress_compose.compose)(migrateWidth, ___utils_migrate_text_align_js.default) }, { attributes: { tagName: { type: "string", enum: ["a", "button"], default: "a" }, type: { type: "string", default: "button" }, textAlign: { type: "string" }, url: { type: "string", source: "attribute", selector: "a", attribute: "href" }, title: { type: "string", source: "attribute", selector: "a,button", attribute: "title", role: "content" }, text: { type: "rich-text", source: "rich-text", selector: "a,button", role: "content" }, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target", role: "content" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel", role: "content" }, placeholder: { type: "string" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, width: { type: "number" } }, supports: { anchor: true, align: true, alignWide: false, color: { __experimentalSkipSerialization: true, gradients: true, __experimentalDefaultControls: { background: true, text: true } }, typography: { fontSize: true, lineHeight: true, __experimentalFontFamily: true, __experimentalFontWeight: true, __experimentalFontStyle: true, __experimentalTextTransform: true, __experimentalTextDecoration: true, __experimentalLetterSpacing: true, __experimentalWritingMode: true, __experimentalDefaultControls: { fontSize: true } }, reusable: false, shadow: { __experimentalSkipSerialization: true }, spacing: { __experimentalSkipSerialization: true, padding: ["horizontal", "vertical"], __experimentalDefaultControls: { padding: true } }, __experimentalBorder: { color: true, radius: true, style: true, width: true, __experimentalSkipSerialization: true, __experimentalDefaultControls: { color: true, radius: true, style: true, width: true } }, __experimentalSelector: ".wp-block-button__link", interactivity: { clientNavigation: true } }, save({ attributes, className }) { const { tagName, type, textAlign, fontSize, linkTarget, rel, style, text, title, url, width } = attributes; const TagName = tagName || "a"; const isButtonTag = "button" === TagName; const buttonType = type || "button"; const borderProps = (0, _wordpress_block_editor.__experimentalGetBorderClassesAndStyles)(attributes); const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const spacingProps = (0, _wordpress_block_editor.__experimentalGetSpacingClassesAndStyles)(attributes); const shadowProps = (0, _wordpress_block_editor.__experimentalGetShadowClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, borderProps.className, { [`has-text-align-${textAlign}`]: textAlign, "no-border-radius": style?.border?.radius === 0 }, (0, _wordpress_block_editor.__experimentalGetElementClassName)("button")); const buttonStyle = { ...borderProps.style, ...colorProps.style, ...spacingProps.style, ...shadowProps.style }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width, [`has-custom-font-size`]: fontSize || style?.typography?.fontSize }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: TagName, type: isButtonTag ? buttonType : null, className: buttonClasses, href: isButtonTag ? null : url, title, style: buttonStyle, value: text, target: isButtonTag ? null : linkTarget, rel: isButtonTag ? null : rel }) }); }, isEligible(attributes) { return typeof attributes.width === "number"; }, migrate: migrateWidth }, { attributes: { url: { type: "string", source: "attribute", selector: "a", attribute: "href" }, title: { type: "string", source: "attribute", selector: "a", attribute: "title" }, text: { type: "string", source: "html", selector: "a" }, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, width: { type: "number" } }, supports: { anchor: true, align: true, alignWide: false, color: { __experimentalSkipSerialization: true, gradients: true, __experimentalDefaultControls: { background: true, text: true } }, typography: { fontSize: true, __experimentalFontFamily: true, __experimentalDefaultControls: { fontSize: true } }, reusable: false, spacing: { __experimentalSkipSerialization: true, padding: ["horizontal", "vertical"], __experimentalDefaultControls: { padding: true } }, __experimentalBorder: { radius: true, __experimentalSkipSerialization: true, __experimentalDefaultControls: { radius: true } }, __experimentalSelector: ".wp-block-button__link" }, save({ attributes, className }) { const { fontSize, linkTarget, rel, style, text, title, url, width } = attributes; if (!text) return null; const borderProps = (0, _wordpress_block_editor.__experimentalGetBorderClassesAndStyles)(attributes); const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const spacingProps = (0, _wordpress_block_editor.__experimentalGetSpacingClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, borderProps.className, { "no-border-radius": style?.border?.radius === 0 }); const buttonStyle = { ...borderProps.style, ...colorProps.style, ...spacingProps.style }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width, [`has-custom-font-size`]: fontSize || style?.typography?.fontSize }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }) }); } }, { attributes: { url: { type: "string", source: "attribute", selector: "a", attribute: "href" }, title: { type: "string", source: "attribute", selector: "a", attribute: "title" }, text: { type: "string", source: "html", selector: "a" }, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, width: { type: "number" } }, supports: { anchor: true, align: true, alignWide: false, color: { __experimentalSkipSerialization: true, gradients: true }, typography: { fontSize: true, __experimentalFontFamily: true }, reusable: false, spacing: { __experimentalSkipSerialization: true, padding: ["horizontal", "vertical"], __experimentalDefaultControls: { padding: true } }, __experimentalBorder: { radius: true, __experimentalSkipSerialization: true }, __experimentalSelector: ".wp-block-button__link" }, save({ attributes, className }) { const { fontSize, linkTarget, rel, style, text, title, url, width } = attributes; if (!text) return null; const borderProps = (0, _wordpress_block_editor.__experimentalGetBorderClassesAndStyles)(attributes); const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const spacingProps = (0, _wordpress_block_editor.__experimentalGetSpacingClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, borderProps.className, { "no-border-radius": style?.border?.radius === 0 }); const buttonStyle = { ...borderProps.style, ...colorProps.style, ...spacingProps.style }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width, [`has-custom-font-size`]: fontSize || style?.typography?.fontSize }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }) }); }, migrate: (0, _wordpress_compose.compose)(migrateWidth, ___utils_migrate_font_family_js.default), isEligible({ style, width }) { return style?.typography?.fontFamily || typeof width === "number"; } }, { supports: { anchor: true, align: true, alignWide: false, color: { __experimentalSkipSerialization: true, gradients: true }, typography: { fontSize: true, __experimentalFontFamily: true }, reusable: false, __experimentalSelector: ".wp-block-button__link" }, attributes: { ...blockAttributes, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, width: { type: "number" } }, isEligible({ style }) { return typeof style?.border?.radius === "number"; }, save({ attributes, className }) { const { fontSize, linkTarget, rel, style, text, title, url, width } = attributes; if (!text) return null; const borderRadius = style?.border?.radius; const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, { "no-border-radius": style?.border?.radius === 0 }); const buttonStyle = { borderRadius: borderRadius ? borderRadius : void 0, ...colorProps.style }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width, [`has-custom-font-size`]: fontSize || style?.typography?.fontSize }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }) }); }, migrate: (0, _wordpress_compose.compose)(migrateWidth, ___utils_migrate_font_family_js.default, migrateBorderRadius) }, { supports: { anchor: true, align: true, alignWide: false, color: { __experimentalSkipSerialization: true }, reusable: false, __experimentalSelector: ".wp-block-button__link" }, attributes: { ...blockAttributes, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" }, borderRadius: { type: "number" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, style: { type: "object" }, width: { type: "number" } }, save({ attributes, className }) { const { borderRadius, linkTarget, rel, text, title, url, width } = attributes; const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, { "no-border-radius": borderRadius === 0 }); const buttonStyle = { borderRadius: borderRadius ? borderRadius + "px" : void 0, ...colorProps.style }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }) }); }, migrate: (0, _wordpress_compose.compose)(migrateWidth, ___utils_migrate_font_family_js.default, migrateBorderRadius) }, { supports: { anchor: true, align: true, alignWide: false, color: { __experimentalSkipSerialization: true }, reusable: false, __experimentalSelector: ".wp-block-button__link" }, attributes: { ...blockAttributes, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" }, borderRadius: { type: "number" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, style: { type: "object" }, width: { type: "number" } }, save({ attributes, className }) { const { borderRadius, linkTarget, rel, text, title, url, width } = attributes; const colorProps = (0, _wordpress_block_editor.__experimentalGetColorClassesAndStyles)(attributes); const buttonClasses = (0, clsx.default)("wp-block-button__link", colorProps.className, { "no-border-radius": borderRadius === 0 }); const buttonStyle = { borderRadius: borderRadius ? borderRadius + "px" : void 0, ...colorProps.style }; const wrapperClasses = (0, clsx.default)(className, { [`has-custom-width wp-block-button__width-${width}`]: width }); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ..._wordpress_block_editor.useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }) }); }, migrate: (0, _wordpress_compose.compose)(migrateWidth, ___utils_migrate_font_family_js.default, migrateBorderRadius) }, { supports: { align: true, alignWide: false, color: { gradients: true } }, attributes: { ...blockAttributes, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" }, borderRadius: { type: "number" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, gradient: { type: "string" }, style: { type: "object" } }, save({ attributes }) { const { borderRadius, linkTarget, rel, text, title, url } = attributes; const buttonClasses = (0, clsx.default)("wp-block-button__link", { "no-border-radius": borderRadius === 0 }); const buttonStyle = { borderRadius: borderRadius ? borderRadius + "px" : void 0 }; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }); }, migrate: (0, _wordpress_compose.compose)(migrateWidth, migrateBorderRadius) }, { supports: { align: true, alignWide: false }, attributes: { ...blockAttributes, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" }, borderRadius: { type: "number" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, customBackgroundColor: { type: "string" }, customTextColor: { type: "string" }, customGradient: { type: "string" }, gradient: { type: "string" } }, isEligible: (attributes) => !!attributes.customTextColor || !!attributes.customBackgroundColor || !!attributes.customGradient || !!attributes.align, migrate: (0, _wordpress_compose.compose)(migrateWidth, migrateBorderRadius, migrateCustomColorsAndGradients, migrateAlign), save({ attributes }) { const { backgroundColor, borderRadius, customBackgroundColor, customTextColor, customGradient, linkTarget, gradient, rel, text, textColor, title, url } = attributes; const textClass = (0, _wordpress_block_editor.getColorClassName)("color", textColor); const backgroundClass = !customGradient && (0, _wordpress_block_editor.getColorClassName)("background-color", backgroundColor); const gradientClass = (0, _wordpress_block_editor.__experimentalGetGradientClass)(gradient); const buttonClasses = (0, clsx.default)("wp-block-button__link", { "has-text-color": textColor || customTextColor, [textClass]: textClass, "has-background": backgroundColor || customBackgroundColor || customGradient || gradient, [backgroundClass]: backgroundClass, "no-border-radius": borderRadius === 0, [gradientClass]: gradientClass }); const buttonStyle = { background: customGradient ? customGradient : void 0, backgroundColor: backgroundClass || customGradient || gradient ? void 0 : customBackgroundColor, color: textClass ? void 0 : customTextColor, borderRadius: borderRadius ? borderRadius + "px" : void 0 }; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }) }); } }, { attributes: { ...blockAttributes, align: { type: "string", default: "none" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, customBackgroundColor: { type: "string" }, customTextColor: { type: "string" }, linkTarget: { type: "string", source: "attribute", selector: "a", attribute: "target" }, rel: { type: "string", source: "attribute", selector: "a", attribute: "rel" }, placeholder: { type: "string" } }, isEligible(attribute) { return attribute.className && attribute.className.includes("is-style-squared"); }, migrate(attributes) { let newClassName = attributes.className; if (newClassName) newClassName = newClassName.replace(/is-style-squared[\s]?/, "").trim(); return migrateBorderRadius(migrateCustomColorsAndGradients({ ...attributes, className: newClassName ? newClassName : void 0, borderRadius: 0 })); }, save({ attributes }) { const { backgroundColor, customBackgroundColor, customTextColor, linkTarget, rel, text, textColor, title, url } = attributes; const textClass = (0, _wordpress_block_editor.getColorClassName)("color", textColor); const backgroundClass = (0, _wordpress_block_editor.getColorClassName)("background-color", backgroundColor); const buttonClasses = (0, clsx.default)("wp-block-button__link", { "has-text-color": textColor || customTextColor, [textClass]: textClass, "has-background": backgroundColor || customBackgroundColor, [backgroundClass]: backgroundClass }); const buttonStyle = { backgroundColor: backgroundClass ? void 0 : customBackgroundColor, color: textClass ? void 0 : customTextColor }; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text, target: linkTarget, rel }) }); } }, { attributes: { ...blockAttributes, align: { type: "string", default: "none" }, backgroundColor: { type: "string" }, textColor: { type: "string" }, customBackgroundColor: { type: "string" }, customTextColor: { type: "string" } }, migrate: (0, _wordpress_compose.compose)(migrateWidth, oldColorsMigration), save({ attributes }) { const { url, text, title, backgroundColor, textColor, customBackgroundColor, customTextColor } = attributes; const textClass = (0, _wordpress_block_editor.getColorClassName)("color", textColor); const backgroundClass = (0, _wordpress_block_editor.getColorClassName)("background-color", backgroundColor); const buttonClasses = (0, clsx.default)("wp-block-button__link", { "has-text-color": textColor || customTextColor, [textClass]: textClass, "has-background": backgroundColor || customBackgroundColor, [backgroundClass]: backgroundClass }); const buttonStyle = { backgroundColor: backgroundClass ? void 0 : customBackgroundColor, color: textClass ? void 0 : customTextColor }; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: buttonClasses, href: url, title, style: buttonStyle, value: text }) }); } }, { attributes: { ...blockAttributes, color: { type: "string" }, textColor: { type: "string" }, align: { type: "string", default: "none" } }, save({ attributes }) { const { url, text, title, align, color, textColor } = attributes; const buttonStyle = { backgroundColor: color, color: textColor }; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `align${align}`, children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", className: "wp-block-button__link", href: url, title, style: buttonStyle, value: text }) }); }, migrate: (0, _wordpress_compose.compose)(migrateWidth, oldColorsMigration) }, { attributes: { ...blockAttributes, color: { type: "string" }, textColor: { type: "string" }, align: { type: "string", default: "none" } }, save({ attributes }) { const { url, text, title, align, color, textColor } = attributes; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `align${align}`, style: { backgroundColor: color }, children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText.Content, { tagName: "a", href: url, title, style: { color: textColor }, value: text }) }); }, migrate: (0, _wordpress_compose.compose)(migrateWidth, oldColorsMigration) } ]; exports.default = deprecated; //# sourceMappingURL=deprecated.cjs.map