@wordpress/block-library
Version:
Block library for the WordPress editor.
310 lines (309 loc) • 8.17 kB
JavaScript
import { RichText, __experimentalGetSpacingClassesAndStyles, getTypographyClassesAndStyles, useBlockProps } from "@wordpress/block-editor";
import { jsx, jsxs } from "react/jsx-runtime";
var deprecated_default = [
{
attributes: {
openByDefault: {
type: "boolean",
default: false
},
title: {
type: "rich-text",
source: "rich-text",
selector: ".wp-block-accordion-heading__toggle-title",
role: "content"
},
level: { type: "number" },
iconPosition: {
type: "string",
enum: ["left", "right"],
default: "right"
},
showIcon: {
type: "boolean",
default: true
}
},
supports: {
anchor: true,
color: {
background: true,
gradients: true
},
align: false,
interactivity: true,
spacing: {
padding: true,
__experimentalDefaultControls: { padding: true },
__experimentalSkipSerialization: true,
__experimentalSelector: ".wp-block-accordion-heading__toggle"
},
__experimentalBorder: {
color: true,
radius: true,
style: true,
width: true,
__experimentalDefaultControls: {
color: true,
radius: true,
style: true,
width: true
}
},
typography: {
__experimentalSkipSerialization: ["textDecoration", "letterSpacing"],
fontSize: true,
__experimentalFontFamily: true,
__experimentalFontWeight: true,
__experimentalFontStyle: true,
__experimentalTextTransform: true,
__experimentalTextDecoration: true,
__experimentalLetterSpacing: true,
__experimentalDefaultControls: {
fontSize: true,
fontFamily: true
}
},
shadow: true,
visibility: false,
lock: false
},
save({ attributes }) {
const { level, title, iconPosition, showIcon } = attributes;
const TagName = "h" + (level || 3);
const typographyProps = getTypographyClassesAndStyles(attributes);
const blockProps = useBlockProps.save();
const spacingProps = __experimentalGetSpacingClassesAndStyles(attributes);
return /* @__PURE__ */ jsx(TagName, {
...blockProps,
children: /* @__PURE__ */ jsxs("button", {
type: "button",
className: "wp-block-accordion-heading__toggle",
style: spacingProps.style,
children: [
showIcon && iconPosition === "left" && /* @__PURE__ */ jsx("span", {
className: "wp-block-accordion-heading__toggle-icon",
"aria-hidden": "true",
children: "+"
}),
/* @__PURE__ */ jsx(RichText.Content, {
className: "wp-block-accordion-heading__toggle-title",
tagName: "span",
value: title,
style: {
letterSpacing: typographyProps.style.letterSpacing,
textDecoration: typographyProps.style.textDecoration
}
}),
showIcon && iconPosition === "right" && /* @__PURE__ */ jsx("span", {
className: "wp-block-accordion-heading__toggle-icon",
"aria-hidden": "true",
children: "+"
})
]
})
});
}
},
{
attributes: {
openByDefault: {
type: "boolean",
default: false
},
title: {
type: "rich-text",
source: "rich-text",
selector: ".wp-block-accordion-heading__toggle-title",
role: "content"
},
level: { type: "number" },
iconPosition: {
type: "string",
enum: ["left", "right"],
default: "right"
},
showIcon: {
type: "boolean",
default: true
}
},
supports: {
anchor: true,
color: {
background: true,
gradients: true
},
align: false,
interactivity: true,
spacing: {
padding: true,
__experimentalDefaultControls: { padding: true },
__experimentalSkipSerialization: true,
__experimentalSelector: ".wp-block-accordion-heading__toggle"
},
__experimentalBorder: {
color: true,
radius: true,
style: true,
width: true,
__experimentalDefaultControls: {
color: true,
radius: true,
style: true,
width: true
}
},
typography: {
__experimentalSkipSerialization: ["textDecoration", "letterSpacing"],
fontSize: true,
__experimentalFontFamily: true,
__experimentalFontWeight: true,
__experimentalFontStyle: true,
__experimentalTextTransform: true,
__experimentalTextDecoration: true,
__experimentalLetterSpacing: true,
__experimentalDefaultControls: {
fontSize: true,
fontFamily: true
}
},
shadow: true,
visibility: false,
lock: false
},
save({ attributes }) {
const { level, title, iconPosition, showIcon } = attributes;
const TagName = "h" + (level || 3);
const typographyProps = getTypographyClassesAndStyles(attributes);
const blockProps = useBlockProps.save();
const spacingProps = __experimentalGetSpacingClassesAndStyles(attributes);
return /* @__PURE__ */ jsx(TagName, {
...blockProps,
children: /* @__PURE__ */ jsxs("button", {
className: "wp-block-accordion-heading__toggle",
style: spacingProps.style,
children: [
showIcon && iconPosition === "left" && /* @__PURE__ */ jsx("span", {
className: "wp-block-accordion-heading__toggle-icon",
"aria-hidden": "true",
children: "+"
}),
/* @__PURE__ */ jsx(RichText.Content, {
className: "wp-block-accordion-heading__toggle-title",
tagName: "span",
value: title,
style: {
letterSpacing: typographyProps.style.letterSpacing,
textDecoration: typographyProps.style.textDecoration
}
}),
showIcon && iconPosition === "right" && /* @__PURE__ */ jsx("span", {
className: "wp-block-accordion-heading__toggle-icon",
"aria-hidden": "true",
children: "+"
})
]
})
});
}
},
{
attributes: {
openByDefault: {
type: "boolean",
default: false
},
title: {
type: "rich-text",
source: "rich-text",
selector: ".wp-block-accordion-heading__toggle-title",
role: "content"
},
level: { type: "number" },
iconPosition: {
type: "string",
enum: ["left", "right"],
default: "right"
},
showIcon: {
type: "boolean",
default: true
}
},
supports: {
anchor: true,
color: {
background: true,
gradients: true
},
align: false,
interactivity: true,
spacing: {
padding: true,
__experimentalDefaultControls: { padding: true },
__experimentalSkipSerialization: true,
__experimentalSelector: ".wp-block-accordion-heading__toggle"
},
__experimentalBorder: {
color: true,
radius: true,
style: true,
width: true,
__experimentalDefaultControls: {
color: true,
radius: true,
style: true,
width: true
}
},
typography: {
fontSize: true,
__experimentalFontFamily: true,
__experimentalFontWeight: true,
__experimentalFontStyle: true,
__experimentalTextTransform: true,
__experimentalTextDecoration: true,
__experimentalLetterSpacing: true,
__experimentalDefaultControls: {
fontSize: true,
fontFamily: true
}
},
shadow: true,
visibility: false
},
save({ attributes }) {
const { level, title, iconPosition, showIcon } = attributes;
const TagName = "h" + (level || 3);
const blockProps = useBlockProps.save();
const spacingProps = __experimentalGetSpacingClassesAndStyles(attributes);
return /* @__PURE__ */ jsx(TagName, {
...blockProps,
children: /* @__PURE__ */ jsxs("button", {
className: "wp-block-accordion-heading__toggle",
style: spacingProps.style,
children: [
showIcon && iconPosition === "left" && /* @__PURE__ */ jsx("span", {
className: "wp-block-accordion-heading__toggle-icon",
"aria-hidden": "true",
children: "+"
}),
/* @__PURE__ */ jsx(RichText.Content, {
className: "wp-block-accordion-heading__toggle-title",
tagName: "span",
value: title
}),
showIcon && iconPosition === "right" && /* @__PURE__ */ jsx("span", {
className: "wp-block-accordion-heading__toggle-icon",
"aria-hidden": "true",
children: "+"
})
]
})
});
}
}
];
export { deprecated_default as default };
//# sourceMappingURL=deprecated.mjs.map