UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines 1.79 kB
{"version":3,"file":"Toc.mjs","names":["TocMobile"],"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 { default as TocMobile } from './TocMobile';\nimport { styles } from './style';\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;EAC5B,GACD,CAAC,cAAc,SAAS,CACzB;AAED,KAAI,SACF,QACE,oBAACA;EACY;EACG;EACA;EACP;GACP;AAGN,QACE,qBAAC;EAAQ,WAAW,GAAG,OAAO,WAAW,OAAO,OAAO;EAAE,OAAO;aAC9D,oBAAC,kBAAG,sBAAsB,EAC1B,oBAAC;GACe;GACd,OAAO,SAAS,MAAM;GACtB,cAAc,eAAe;IAC7B;GACM;EAGf;AAED,IAAI,cAAc;AAElB,kBAAe"}