@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
1 lines • 1.81 kB
Source Map (JSON)
{"version":3,"file":"Toc.mjs","names":[],"sources":["../../src/Toc/Toc.tsx"],"sourcesContent":["'use client';\n\nimport { Anchor } from 'antd';\nimport { cx } from 'antd-style';\nimport { memo, useMemo } from 'react';\n\nimport { styles } from './style';\nimport { default as TocMobile } from './TocMobile';\nimport { type TocProps } from './type';\nimport { mapItems } from './utils';\n\nconst Toc = memo<TocProps>(\n ({ activeKey, items, getContainer, isMobile, headerHeight = 64, tocWidth = 176 }) => {\n // Convert props to CSS variables\n const cssVariables = useMemo<Record<string, string>>(\n () => ({\n '--toc-header-height': `${headerHeight}px`,\n '--toc-width': `${tocWidth}px`,\n }),\n [headerHeight, tocWidth],\n );\n\n if (isMobile)\n return (\n <TocMobile\n activeKey={activeKey}\n getContainer={getContainer}\n headerHeight={headerHeight}\n items={items}\n />\n );\n\n return (\n <section className={cx(styles.container, styles.anchor)} style={cssVariables}>\n <h4>Table of Contents</h4>\n <Anchor\n getContainer={getContainer}\n items={mapItems(items)}\n targetOffset={headerHeight + 12}\n />\n </section>\n );\n },\n);\n\nToc.displayName = 'Toc';\n\nexport default Toc;\n"],"mappings":";;;;;;;;;AAWA,MAAM,MAAM,MACT,EAAE,WAAW,OAAO,cAAc,UAAU,eAAe,IAAI,WAAW,UAAU;CAEnF,MAAM,eAAe,eACZ;EACL,uBAAuB,GAAG,aAAa;EACvC,eAAe,GAAG,SAAS;CAC7B,IACA,CAAC,cAAc,QAAQ,CACzB;CAEA,IAAI,UACF,OACE,oBAAC,WAAD;EACa;EACG;EACA;EACP;CACR,CAAA;CAGL,OACE,qBAAC,WAAD;EAAS,WAAW,GAAG,OAAO,WAAW,OAAO,MAAM;EAAG,OAAO;YAAhE,CACE,oBAAC,MAAD,EAAA,UAAI,oBAAqB,CAAA,GACzB,oBAAC,QAAD;GACgB;GACd,OAAO,SAAS,KAAK;GACrB,cAAc,eAAe;EAC9B,CAAA,CACM;;AAEb,CACF;AAEA,IAAI,cAAc"}