//#region src/lib/tree.d.ts type Compare = (current: T, next: T) => boolean; //#endregion //#region src/lib/toc-item.d.ts type TocItem = { level: number; text: string; id: string; href: string; source: TSource; children: TocItem[]; }; //#endregion //#region src/lib/dom-list.d.ts type DomListOptions = { type?: "ol" | "ul"; render?: (items: TocItem[], context: DomListRenderContext) => Element; }; type DomListRenderContext = { document: Document; createLink: (item: TocItem) => HTMLAnchorElement; renderList: (items: TocItem[]) => HTMLOListElement | HTMLUListElement; }; /** * Given TOC items extracted from DOM headings, creates a new list of anchors * that point to those headings. * * @param items Array of nested TOC items. * @param options Options object. * @param options.type Type of DOM element to use. * @param options.render Custom renderer for the full TOC output. * @returns A new list element. * @example * * const items = [ * { * level: 1, * text: 'First', * id: '1', * href: '#1', * source: document.createElement('h1'), * children: [ * { * level: 2, * text: 'Second', * id: '2', * href: '#2', * source: document.createElement('h2'), * children: [], * }, * ], * }, * { * level: 1, * text: 'Third', * id: '3', * href: '#3', * source: document.createElement('h1'), * children: [], * }, * ] * * domList(items) * // =>
    * //
  1. First * //
      * //
    1. Second
    2. * //
    * //
  2. * //
  3. Third
  4. * //
*/ declare function domList(items: TocItem[], options?: DomListOptions): Element; //#endregion //#region src/lib/dom-toc.d.ts type DomRoot = string | Element; type DomTarget = string | Element; type DomHeadingsInput = string | Iterable; type DomItemsOptions = { compare?: Compare; root?: DomRoot; headings?: DomHeadingsInput; text?: (element: Element) => string; id?: (text: string, element: Element) => string; }; type DomTocOptions = DomItemsOptions & DomListOptions & { target?: DomTarget; }; /** * Extract TOC items from headings in the DOM. * * @param options Options object. * @param options.compare Function used to compare hierarchy of heading * elements. * @param options.root Root element or selector used to query headings. * @param options.headings Heading selector or iterable of heading elements. * @param options.text Function used to generate the visible heading text. * @param options.id Function used to generate the heading id. * @returns TOC items generated from the headings. */ declare function domItems(options?: DomItemsOptions): TocItem[]; /** * Handy function to automagically generate a table of contents based on the * document and optional heading inputs, and attach it somewhere in the DOM. * * @param options Options object. * @param options.root Root element or selector used to query headings. * @param options.headings Heading selector or iterable of heading elements. * @param options.target Target element or selector where the TOC will be * attached. * @param options.render Custom renderer forwarded to `domList`. * @returns The generated list element attached to the target. * @example * * domToc() * // =>
    * //
  1. First * //
      * //
    1. Second
    2. * //
    * //
  2. * //
  3. Third
  4. * //
*/ declare function domToc(options?: DomTocOptions): Element; //#endregion export { type DomHeadingsInput, type DomItemsOptions, type DomListOptions, type DomListRenderContext, type DomRoot, type DomTarget, type DomTocOptions, type TocItem, domItems, domList, domToc }; //# sourceMappingURL=dom.d.ts.map