@wordpress/block-library
Version:
Block library for the WordPress editor.
41 lines (40 loc) • 1.38 kB
JavaScript
// packages/block-library/src/table-of-contents/list.tsx
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var ENTRY_CLASS_NAME = "wp-block-table-of-contents__entry";
function TableOfContentsList({
nestedHeadingList,
disableLinkActivation,
onClick,
ordered = true
}) {
return /* @__PURE__ */ jsx(Fragment, { children: nestedHeadingList.map((node, index) => {
const { content, link } = node.heading;
const entry = link ? /* @__PURE__ */ jsx(
"a",
{
className: ENTRY_CLASS_NAME,
href: link,
"aria-disabled": disableLinkActivation || void 0,
onClick: disableLinkActivation && "function" === typeof onClick ? onClick : void 0,
children: content
}
) : /* @__PURE__ */ jsx("span", { className: ENTRY_CLASS_NAME, children: content });
const NestedListTag = ordered ? "ol" : "ul";
return /* @__PURE__ */ jsxs("li", { children: [
entry,
node.children ? /* @__PURE__ */ jsx(NestedListTag, { children: /* @__PURE__ */ jsx(
TableOfContentsList,
{
nestedHeadingList: node.children,
disableLinkActivation,
onClick: disableLinkActivation && "function" === typeof onClick ? onClick : void 0,
ordered
}
) }) : null
] }, index);
}) });
}
export {
TableOfContentsList as default
};
//# sourceMappingURL=list.js.map