UNPKG

@wordpress/block-library

Version:
28 lines (27 loc) • 1.25 kB
import { Fragment, jsx, jsxs } from "react/jsx-runtime"; // packages/block-library/src/table-of-contents/list.tsx const 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.mjs.map