@fumadocs/base-ui 16.17.7 → 16.17.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/flux.css +1 -1
- package/css/generated/glass.css +1 -1
- package/css/generated/shared.css +1 -1
- package/css/generated/spacious.css +1 -1
- package/dist/.translations/index.d.ts +1 -3
- package/dist/.translations/keys.js +1 -2
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/components/accordion.d.ts +1 -3
- package/dist/components/accordion.js +1 -2
- package/dist/components/banner.d.ts +1 -2
- package/dist/components/banner.js +1 -2
- package/dist/components/callout.d.ts +1 -3
- package/dist/components/callout.js +1 -2
- package/dist/components/card.d.ts +1 -3
- package/dist/components/card.js +1 -2
- package/dist/components/codeblock.d.ts +1 -3
- package/dist/components/codeblock.js +1 -2
- package/dist/components/codeblock.rsc.d.ts +7 -3
- package/dist/components/codeblock.rsc.js +21 -9
- package/dist/components/dialog/search-algolia.d.ts +1 -3
- package/dist/components/dialog/search-algolia.js +1 -2
- package/dist/components/dialog/search-default.d.ts +1 -3
- package/dist/components/dialog/search-default.js +1 -2
- package/dist/components/dialog/search-orama.d.ts +1 -3
- package/dist/components/dialog/search-orama.js +1 -2
- package/dist/components/dialog/search.d.ts +13 -16
- package/dist/components/dialog/search.js +19 -31
- package/dist/components/dynamic-codeblock.core.d.ts +9 -6
- package/dist/components/dynamic-codeblock.core.js +55 -18
- package/dist/components/dynamic-codeblock.d.ts +2 -4
- package/dist/components/dynamic-codeblock.js +1 -2
- package/dist/components/files.d.ts +1 -3
- package/dist/components/files.js +1 -2
- package/dist/components/github-info.d.ts +1 -3
- package/dist/components/github-info.js +1 -2
- package/dist/components/heading.d.ts +1 -2
- package/dist/components/heading.js +1 -2
- package/dist/components/image-zoom.d.ts +3 -5
- package/dist/components/image-zoom.js +2 -3
- package/dist/components/inline-toc.d.ts +1 -3
- package/dist/components/inline-toc.js +1 -2
- package/dist/components/sidebar/base.d.ts +0 -1
- package/dist/components/sidebar/base.js +1 -2
- package/dist/components/sidebar/link-item.d.ts +1 -2
- package/dist/components/sidebar/link-item.js +1 -2
- package/dist/components/sidebar/page-tree.d.ts +1 -2
- package/dist/components/sidebar/page-tree.js +1 -2
- package/dist/components/sidebar/tabs/dropdown.d.ts +1 -3
- package/dist/components/sidebar/tabs/dropdown.js +1 -2
- package/dist/components/sidebar/tabs/index.d.ts +1 -3
- package/dist/components/sidebar/tabs/index.js +1 -2
- package/dist/components/steps.d.ts +1 -3
- package/dist/components/steps.js +1 -2
- package/dist/components/tabs.d.ts +2 -4
- package/dist/components/tabs.js +1 -2
- package/dist/components/toc/block.d.ts +2 -6
- package/dist/components/toc/block.js +6 -13
- package/dist/components/toc/clerk.d.ts +2 -7
- package/dist/components/toc/clerk.js +85 -120
- package/dist/components/toc/default.d.ts +2 -7
- package/dist/components/toc/default.js +112 -149
- package/dist/components/toc/index.d.ts +1 -6
- package/dist/components/toc/index.js +1 -2
- package/dist/components/type-table.d.ts +1 -3
- package/dist/components/type-table.js +1 -2
- package/dist/components/ui/accordion.d.ts +1 -3
- package/dist/components/ui/accordion.js +1 -2
- package/dist/components/ui/button.d.ts +1 -3
- package/dist/components/ui/button.js +1 -2
- package/dist/components/ui/collapsible.d.ts +1 -3
- package/dist/components/ui/collapsible.js +1 -2
- package/dist/components/ui/popover.d.ts +1 -3
- package/dist/components/ui/popover.js +1 -2
- package/dist/components/ui/tabs.d.ts +1 -6
- package/dist/components/ui/tabs.js +1 -2
- package/dist/contexts/i18n.d.ts +1 -2
- package/dist/contexts/i18n.js +1 -2
- package/dist/contexts/search.d.ts +1 -2
- package/dist/contexts/search.js +1 -2
- package/dist/contexts/tree.d.ts +1 -2
- package/dist/contexts/tree.js +1 -2
- package/dist/i18n.d.ts +0 -2
- package/dist/i18n.js +1 -2
- package/dist/layouts/docs/client.d.ts +1 -2
- package/dist/layouts/docs/client.js +1 -2
- package/dist/layouts/docs/index.d.ts +0 -2
- package/dist/layouts/docs/index.js +1 -2
- package/dist/layouts/docs/page/index.d.ts +0 -2
- package/dist/layouts/docs/page/index.js +1 -2
- package/dist/layouts/docs/page/slots/breadcrumb.d.ts +1 -3
- package/dist/layouts/docs/page/slots/breadcrumb.js +1 -2
- package/dist/layouts/docs/page/slots/container.d.ts +1 -3
- package/dist/layouts/docs/page/slots/container.js +1 -2
- package/dist/layouts/docs/page/slots/footer.d.ts +1 -2
- package/dist/layouts/docs/page/slots/footer.js +1 -2
- package/dist/layouts/docs/page/slots/toc.d.ts +5 -7
- package/dist/layouts/docs/page/slots/toc.js +1 -2
- package/dist/layouts/docs/slots/container.d.ts +1 -3
- package/dist/layouts/docs/slots/container.js +1 -2
- package/dist/layouts/docs/slots/header.d.ts +1 -3
- package/dist/layouts/docs/slots/header.js +1 -2
- package/dist/layouts/docs/slots/sidebar.d.ts +2 -4
- package/dist/layouts/docs/slots/sidebar.js +1 -2
- package/dist/layouts/flux/index.d.ts +1 -2
- package/dist/layouts/flux/index.js +1 -2
- package/dist/layouts/flux/page/index.d.ts +0 -2
- package/dist/layouts/flux/page/index.js +1 -2
- package/dist/layouts/flux/page/slots/breadcrumb.d.ts +1 -3
- package/dist/layouts/flux/page/slots/breadcrumb.js +1 -2
- package/dist/layouts/flux/page/slots/container.d.ts +1 -3
- package/dist/layouts/flux/page/slots/container.js +1 -2
- package/dist/layouts/flux/page/slots/footer.d.ts +1 -2
- package/dist/layouts/flux/page/slots/footer.js +1 -2
- package/dist/layouts/flux/page/slots/toc.d.ts +5 -7
- package/dist/layouts/flux/page/slots/toc.js +1 -2
- package/dist/layouts/flux/slots/container.d.ts +1 -3
- package/dist/layouts/flux/slots/container.js +1 -2
- package/dist/layouts/flux/slots/sidebar.d.ts +2 -4
- package/dist/layouts/flux/slots/sidebar.js +1 -2
- package/dist/layouts/flux/slots/tab-dropdown.d.ts +1 -3
- package/dist/layouts/flux/slots/tab-dropdown.js +1 -2
- package/dist/layouts/glass/index.d.ts +0 -2
- package/dist/layouts/glass/index.js +1 -2
- package/dist/layouts/glass/layout-tabs.js +1 -2
- package/dist/layouts/glass/page/index.d.ts +0 -2
- package/dist/layouts/glass/page/index.js +1 -2
- package/dist/layouts/glass/page/slots/breadcrumb.d.ts +1 -3
- package/dist/layouts/glass/page/slots/breadcrumb.js +1 -2
- package/dist/layouts/glass/page/slots/footer.d.ts +1 -2
- package/dist/layouts/glass/page/slots/footer.js +1 -2
- package/dist/layouts/glass/page/slots/toc.d.ts +2 -4
- package/dist/layouts/glass/page/slots/toc.js +1 -2
- package/dist/layouts/glass/slots/header.d.ts +1 -3
- package/dist/layouts/glass/slots/header.js +1 -2
- package/dist/layouts/glass/slots/sidebar.d.ts +1 -3
- package/dist/layouts/glass/slots/sidebar.js +1 -2
- package/dist/layouts/home/index.d.ts +1 -2
- package/dist/layouts/home/index.js +1 -2
- package/dist/layouts/home/navbar.d.ts +1 -3
- package/dist/layouts/home/navbar.js +1 -2
- package/dist/layouts/home/not-found.d.ts +1 -3
- package/dist/layouts/home/not-found.js +1 -2
- package/dist/layouts/home/slots/container.d.ts +1 -3
- package/dist/layouts/home/slots/container.js +1 -2
- package/dist/layouts/home/slots/header.d.ts +1 -3
- package/dist/layouts/home/slots/header.js +1 -2
- package/dist/layouts/notebook/client.d.ts +1 -2
- package/dist/layouts/notebook/client.js +1 -2
- package/dist/layouts/notebook/index.d.ts +0 -2
- package/dist/layouts/notebook/index.js +1 -2
- package/dist/layouts/notebook/page/index.d.ts +0 -2
- package/dist/layouts/notebook/page/index.js +1 -2
- package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +1 -3
- package/dist/layouts/notebook/page/slots/breadcrumb.js +1 -2
- package/dist/layouts/notebook/page/slots/container.d.ts +1 -3
- package/dist/layouts/notebook/page/slots/container.js +1 -2
- package/dist/layouts/notebook/page/slots/footer.d.ts +1 -2
- package/dist/layouts/notebook/page/slots/footer.js +1 -2
- package/dist/layouts/notebook/page/slots/toc.d.ts +5 -7
- package/dist/layouts/notebook/page/slots/toc.js +1 -2
- package/dist/layouts/notebook/slots/container.d.ts +1 -3
- package/dist/layouts/notebook/slots/container.js +1 -2
- package/dist/layouts/notebook/slots/header.d.ts +1 -3
- package/dist/layouts/notebook/slots/header.js +1 -2
- package/dist/layouts/notebook/slots/sidebar.d.ts +1 -3
- package/dist/layouts/notebook/slots/sidebar.js +1 -2
- package/dist/layouts/shared/client.d.ts +1 -3
- package/dist/layouts/shared/client.js +1 -2
- package/dist/layouts/shared/index.d.ts +0 -2
- package/dist/layouts/shared/index.js +1 -2
- package/dist/layouts/shared/page-actions.d.ts +1 -3
- package/dist/layouts/shared/page-actions.js +1 -2
- package/dist/layouts/shared/slots/language-select.d.ts +1 -3
- package/dist/layouts/shared/slots/language-select.js +1 -2
- package/dist/layouts/shared/slots/search-trigger.d.ts +1 -3
- package/dist/layouts/shared/slots/search-trigger.js +1 -2
- package/dist/layouts/shared/slots/theme-switch.d.ts +1 -3
- package/dist/layouts/shared/slots/theme-switch.js +1 -2
- package/dist/layouts/spacious/index.d.ts +1 -2
- package/dist/layouts/spacious/index.js +1 -2
- package/dist/layouts/spacious/page/index.d.ts +0 -2
- package/dist/layouts/spacious/page/index.js +1 -2
- package/dist/layouts/spacious/page/slots/breadcrumb.d.ts +1 -3
- package/dist/layouts/spacious/page/slots/breadcrumb.js +1 -2
- package/dist/layouts/spacious/page/slots/footer.d.ts +1 -2
- package/dist/layouts/spacious/page/slots/footer.js +1 -2
- package/dist/layouts/spacious/page/slots/toc.d.ts +5 -6
- package/dist/layouts/spacious/page/slots/toc.js +1 -2
- package/dist/layouts/spacious/slots/actions.d.ts +1 -3
- package/dist/layouts/spacious/slots/actions.js +1 -2
- package/dist/layouts/spacious/slots/header.d.ts +1 -3
- package/dist/layouts/spacious/slots/header.js +1 -2
- package/dist/layouts/spacious/slots/sidebar.d.ts +2 -4
- package/dist/layouts/spacious/slots/sidebar.js +1 -2
- package/dist/mdx.d.ts +0 -2
- package/dist/mdx.js +1 -2
- package/dist/mdx.server.d.ts +0 -2
- package/dist/mdx.server.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/controlled.d.ts +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/controlled.js +1 -2
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1/node_modules/react-medium-image-zoom/dist/uncontrolled.d.ts +3 -0
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/uncontrolled.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/adjust-svg-ids.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/compute-positioned-style.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/element-tests.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-div-img-style.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-img-alt.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-img-object-fit-style.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-img-regular-style.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-img-src.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-modal-img-transform.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-scale.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-style-ghost.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/get-style-modal-img.js +1 -2
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1/node_modules/react-medium-image-zoom/dist/utils/get-target-dimension.js +3 -0
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/parse-position.js +1 -2
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/utils/test-has-scalable-src.js +1 -2
- package/dist/og/takumi.d.ts +1 -3
- package/dist/og/takumi.js +1 -2
- package/dist/og.d.ts +1 -2
- package/dist/og.js +1 -2
- package/dist/page.d.ts +0 -2
- package/dist/page.js +1 -2
- package/dist/provider/astro.d.ts +1 -3
- package/dist/provider/astro.js +17 -2
- package/dist/provider/base.d.ts +0 -2
- package/dist/provider/base.js +1 -2
- package/dist/provider/next.d.ts +1 -3
- package/dist/provider/next.js +1 -2
- package/dist/provider/react-router.d.ts +1 -3
- package/dist/provider/react-router.js +1 -2
- package/dist/provider/tanstack.d.ts +1 -3
- package/dist/provider/tanstack.js +1 -2
- package/dist/provider/waku.d.ts +1 -3
- package/dist/provider/waku.js +1 -2
- package/dist/style.css +3 -6
- package/dist/tailwind/typography.js +1 -2
- package/dist/utils/cn.js +1 -2
- package/dist/utils/hotkey.js +1 -2
- package/dist/utils/merge-refs.js +1 -2
- package/dist/utils/urls.js +1 -2
- package/dist/utils/use-copy-button.d.ts +1 -3
- package/dist/utils/use-copy-button.js +1 -2
- package/dist/utils/use-footer-items.d.ts +1 -3
- package/dist/utils/use-footer-items.js +1 -2
- package/dist/utils/use-is-scroll-top.d.ts +1 -3
- package/dist/utils/use-is-scroll-top.js +1 -2
- package/package.json +11 -12
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/react-medium-image-zoom/dist/uncontrolled.d.ts +0 -5
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/react-medium-image-zoom/dist/utils/get-target-dimension.js +0 -4
- /package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.9_react-dom@19.3.0_react@19.3.0__react@19.3.0 → react-medium-image-zoom@5.4.9_react-dom@19.3.1_react@19.3.1__react@19.3.1}/node_modules/react-medium-image-zoom/dist/index.d.ts +0 -0
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
5
4
|
import { TOCEmpty } from "./default.js";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
6
|
+
import { useCallback } from "react";
|
|
8
7
|
import * as Primitive from "fumadocs-core/toc";
|
|
9
|
-
|
|
8
|
+
// src/components/toc/block.tsx
|
|
10
9
|
var block_exports = /* @__PURE__ */ __exportAll({
|
|
11
10
|
TOCEmpty: () => TOCEmpty,
|
|
12
11
|
TOCItem: () => TOCItem,
|
|
13
12
|
TOCItems: () => TOCItems
|
|
14
13
|
});
|
|
15
|
-
function TOCItems({
|
|
16
|
-
const containerRef = useRef(null);
|
|
17
|
-
const blockRef = useRef(null);
|
|
14
|
+
function TOCItems({ className, children, ...props }) {
|
|
18
15
|
const tocInfo = Primitive.useTOC();
|
|
19
|
-
|
|
20
|
-
const container =
|
|
21
|
-
const block = blockRef.current;
|
|
22
|
-
if (!container || !block) return;
|
|
16
|
+
const ref = useCallback((block) => {
|
|
17
|
+
const container = block.parentElement;
|
|
23
18
|
const positions = /* @__PURE__ */ new Map();
|
|
24
19
|
let height = 0;
|
|
25
20
|
const update = (items) => {
|
|
@@ -53,11 +48,10 @@ function TOCItems({ ref, className, children, ...props }) {
|
|
|
53
48
|
};
|
|
54
49
|
}, [tocInfo]);
|
|
55
50
|
return /* @__PURE__ */ jsxs("div", {
|
|
56
|
-
ref: mergeRefs(containerRef, ref),
|
|
57
51
|
className: cn("relative flex flex-col", className),
|
|
58
52
|
...props,
|
|
59
53
|
children: [/* @__PURE__ */ jsx("div", {
|
|
60
|
-
ref
|
|
54
|
+
ref,
|
|
61
55
|
className: "absolute inset-0 bg-linear-to-r from-fd-primary/10 [clip-path:inset(0_0_100%)] data-ready:transition-[clip-path] duration-300 ease-out"
|
|
62
56
|
}), children]
|
|
63
57
|
});
|
|
@@ -82,5 +76,4 @@ function TOCItem({ item, ...props }) {
|
|
|
82
76
|
}), item.title]
|
|
83
77
|
});
|
|
84
78
|
}
|
|
85
|
-
//#endregion
|
|
86
79
|
export { TOCEmpty, TOCItem, TOCItems, block_exports };
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import * as Primitive from "fumadocs-core/toc";
|
|
3
|
-
declare namespace clerk_d_exports {
|
|
4
|
-
export { TOCEmpty, TOCItem, TOCItems, TOCItemsProps };
|
|
5
|
-
}
|
|
6
3
|
export type TOCItemsProps = ComponentProps<'div'>;
|
|
7
|
-
export declare function TOCItems({
|
|
4
|
+
export declare function TOCItems({ className, children, ...props }: TOCItemsProps): import("react").JSX.Element;
|
|
8
5
|
export declare function TOCEmpty(): import("react").JSX.Element;
|
|
9
6
|
export declare function TOCItem({ item, ...props }: Primitive.TOCItemProps & {
|
|
10
7
|
item: Primitive.TOCItemType;
|
|
11
|
-
}): import("react").JSX.Element;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { clerk_d_exports };
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -1,106 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
5
4
|
import { useTOCItems } from "./index.js";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { useCallback,
|
|
6
|
+
import { useCallback, useMemo } from "react";
|
|
8
7
|
import { useTranslations } from "@fuma-translate/react";
|
|
9
8
|
import * as Primitive from "fumadocs-core/toc";
|
|
10
|
-
|
|
9
|
+
// src/components/toc/clerk.tsx
|
|
11
10
|
var clerk_exports = /* @__PURE__ */ __exportAll({
|
|
12
11
|
TOCEmpty: () => TOCEmpty,
|
|
13
12
|
TOCItem: () => TOCItem,
|
|
14
13
|
TOCItems: () => TOCItems
|
|
15
14
|
});
|
|
16
|
-
function TOCItems({
|
|
17
|
-
const containerRef = useRef(null);
|
|
15
|
+
function TOCItems({ className, children, ...props }) {
|
|
18
16
|
const items = useTOCItems();
|
|
19
|
-
const [svg, setSvg] = useState(null);
|
|
20
|
-
const onPrint = useCallback(() => {
|
|
21
|
-
const container = containerRef.current;
|
|
22
|
-
if (!container || container.clientHeight === 0) return;
|
|
23
|
-
if (items.length === 0) {
|
|
24
|
-
setSvg(null);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let w = 0;
|
|
28
|
-
let h = 0;
|
|
29
|
-
let d = "";
|
|
30
|
-
const positions = [];
|
|
31
|
-
const output = [];
|
|
32
|
-
for (let i = 0; i < items.length; i++) {
|
|
33
|
-
const item = items[i];
|
|
34
|
-
const element = container.querySelector(`a[href="${item.url}"]`);
|
|
35
|
-
if (!element) continue;
|
|
36
|
-
const styles = getComputedStyle(element);
|
|
37
|
-
const x = getLineOffset(item.depth) + .5;
|
|
38
|
-
const top = element.offsetTop + parseFloat(styles.paddingTop);
|
|
39
|
-
const bottom = element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom);
|
|
40
|
-
w = Math.max(x + 8, w);
|
|
41
|
-
h = Math.max(h, bottom);
|
|
42
|
-
if (i === 0) d += ` M${x} ${top} L${x} ${bottom}`;
|
|
43
|
-
else {
|
|
44
|
-
const [, upperBottom, upperX] = i > 0 ? positions[i - 1] : [
|
|
45
|
-
0,
|
|
46
|
-
0,
|
|
47
|
-
0
|
|
48
|
-
];
|
|
49
|
-
d += ` L ${upperX} ${upperBottom} ${x} ${top} L${x} ${bottom}`;
|
|
50
|
-
}
|
|
51
|
-
if (item._step !== void 0) output.push(/* @__PURE__ */ jsxs("g", {
|
|
52
|
-
transform: `translate(${x}, ${(top + bottom) / 2})`,
|
|
53
|
-
children: [/* @__PURE__ */ jsx("circle", {
|
|
54
|
-
cx: "0",
|
|
55
|
-
cy: "0",
|
|
56
|
-
r: "8",
|
|
57
|
-
className: "fill-fd-primary"
|
|
58
|
-
}), /* @__PURE__ */ jsx("text", {
|
|
59
|
-
cx: "0",
|
|
60
|
-
cy: "0",
|
|
61
|
-
textAnchor: "middle",
|
|
62
|
-
alignmentBaseline: "central",
|
|
63
|
-
dominantBaseline: "middle",
|
|
64
|
-
className: "fill-fd-primary-foreground font-medium text-xs leading-none font-mono rtl:-scale-x-100",
|
|
65
|
-
children: item._step
|
|
66
|
-
})]
|
|
67
|
-
}, i));
|
|
68
|
-
positions.push([
|
|
69
|
-
top,
|
|
70
|
-
bottom,
|
|
71
|
-
x
|
|
72
|
-
]);
|
|
73
|
-
}
|
|
74
|
-
output.unshift(/* @__PURE__ */ jsx("path", {
|
|
75
|
-
d,
|
|
76
|
-
className: "stroke-fd-primary",
|
|
77
|
-
strokeWidth: "1",
|
|
78
|
-
fill: "none"
|
|
79
|
-
}, "path"));
|
|
80
|
-
setSvg({
|
|
81
|
-
content: output,
|
|
82
|
-
width: w,
|
|
83
|
-
height: h,
|
|
84
|
-
d,
|
|
85
|
-
itemLineLengths: [],
|
|
86
|
-
positions
|
|
87
|
-
});
|
|
88
|
-
}, [items]);
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
const container = containerRef.current;
|
|
91
|
-
if (!container) return;
|
|
92
|
-
const observer = new ResizeObserver(onPrint);
|
|
93
|
-
observer.observe(container);
|
|
94
|
-
onPrint();
|
|
95
|
-
return () => {
|
|
96
|
-
observer.unobserve(container);
|
|
97
|
-
};
|
|
98
|
-
}, [onPrint]);
|
|
99
17
|
return /* @__PURE__ */ jsxs("div", {
|
|
100
|
-
ref: mergeRefs(containerRef, ref),
|
|
101
18
|
className: cn("relative flex flex-col", className),
|
|
102
19
|
...props,
|
|
103
|
-
children: [
|
|
20
|
+
children: [items.length > 0 && /* @__PURE__ */ jsx(ThumbTrack, { items }), children]
|
|
104
21
|
});
|
|
105
22
|
}
|
|
106
23
|
function TOCEmpty() {
|
|
@@ -110,41 +27,90 @@ function TOCEmpty() {
|
|
|
110
27
|
children: t("No Headings")
|
|
111
28
|
});
|
|
112
29
|
}
|
|
113
|
-
function ThumbTrack({
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
30
|
+
function ThumbTrack({ items }) {
|
|
31
|
+
const toc = Primitive.useTOC();
|
|
32
|
+
const ref = useCallback((track) => {
|
|
33
|
+
const container = track.parentElement;
|
|
34
|
+
const svg = track.querySelector("svg");
|
|
35
|
+
const path = svg.querySelector("path");
|
|
36
|
+
const steps = svg.getElementsByTagName("g");
|
|
37
|
+
const positions = /* @__PURE__ */ new Map();
|
|
38
|
+
const update = (infos) => {
|
|
39
|
+
let top = -1;
|
|
40
|
+
let bottom = -1;
|
|
41
|
+
for (const info of infos) {
|
|
42
|
+
const position = info.active ? positions.get(info.original.url) : void 0;
|
|
43
|
+
if (!position) continue;
|
|
44
|
+
if (top === -1) top = position.top;
|
|
45
|
+
bottom = position.bottom;
|
|
46
|
+
}
|
|
47
|
+
if (top !== -1) svg.style.clipPath = `polygon(0 ${top}px, 100% ${top}px, 100% ${bottom}px, 0 ${bottom}px)`;
|
|
48
|
+
};
|
|
49
|
+
const observer = new ResizeObserver(() => {
|
|
50
|
+
if (container.clientHeight === 0) return;
|
|
51
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
52
|
+
for (const anchor of container.getElementsByTagName("a")) anchors.set(anchor.getAttribute("href"), anchor);
|
|
53
|
+
let d = "";
|
|
54
|
+
let width = 0;
|
|
55
|
+
let height = 0;
|
|
56
|
+
let last;
|
|
57
|
+
positions.clear();
|
|
58
|
+
for (const item of items) {
|
|
59
|
+
const anchor = anchors.get(item.url);
|
|
60
|
+
if (!anchor) continue;
|
|
61
|
+
const styles = getComputedStyle(anchor);
|
|
62
|
+
const x = getLineOffset(item.depth) + .5;
|
|
63
|
+
const top = anchor.offsetTop + parseFloat(styles.paddingTop);
|
|
64
|
+
const bottom = anchor.offsetTop + anchor.clientHeight - parseFloat(styles.paddingBottom);
|
|
65
|
+
d += last ? ` L ${last.x} ${last.bottom} ${x} ${top}` : `M${x} ${top}`;
|
|
66
|
+
d += ` L${x} ${bottom}`;
|
|
67
|
+
last = {
|
|
68
|
+
x,
|
|
69
|
+
top,
|
|
70
|
+
bottom
|
|
71
|
+
};
|
|
72
|
+
positions.set(item.url, last);
|
|
73
|
+
width = Math.max(width, x + 8);
|
|
74
|
+
height = Math.max(height, bottom);
|
|
75
|
+
}
|
|
76
|
+
let step = 0;
|
|
77
|
+
for (const item of items) {
|
|
78
|
+
if (item._step === void 0) continue;
|
|
79
|
+
const position = positions.get(item.url);
|
|
80
|
+
const g = steps[step++];
|
|
81
|
+
if (position) g.setAttribute("transform", `translate(${position.x}, ${(position.top + position.bottom) / 2})`);
|
|
82
|
+
}
|
|
83
|
+
path.setAttribute("d", d);
|
|
84
|
+
track.style.width = `${width}px`;
|
|
85
|
+
track.style.height = `${height}px`;
|
|
86
|
+
update(toc.get());
|
|
87
|
+
});
|
|
88
|
+
observer.observe(container);
|
|
89
|
+
toc.listen(update);
|
|
90
|
+
return () => {
|
|
91
|
+
observer.disconnect();
|
|
92
|
+
toc.unlisten(update);
|
|
93
|
+
};
|
|
94
|
+
}, [items, toc]);
|
|
130
95
|
return /* @__PURE__ */ jsx("div", {
|
|
131
96
|
ref,
|
|
132
97
|
className: "absolute top-0 inset-s-0 origin-center rtl:-scale-x-100",
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
98
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
99
|
+
className: "absolute size-full [clip-path:polygon(0_0,100%_0,100%_0,0_0)] transition-[clip-path]",
|
|
100
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
101
|
+
className: "stroke-fd-primary",
|
|
102
|
+
strokeWidth: "1",
|
|
103
|
+
fill: "none"
|
|
104
|
+
}), items.map((item) => item._step !== void 0 && /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("circle", {
|
|
105
|
+
r: "8",
|
|
106
|
+
className: "fill-fd-primary"
|
|
107
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
108
|
+
textAnchor: "middle",
|
|
109
|
+
alignmentBaseline: "central",
|
|
110
|
+
dominantBaseline: "middle",
|
|
111
|
+
className: "fill-fd-primary-foreground font-medium text-xs leading-none font-mono rtl:-scale-x-100",
|
|
112
|
+
children: item._step
|
|
113
|
+
})] }, item.url))]
|
|
148
114
|
})
|
|
149
115
|
});
|
|
150
116
|
}
|
|
@@ -223,5 +189,4 @@ function TOCItem({ item, ...props }) {
|
|
|
223
189
|
children: [svg, item.title]
|
|
224
190
|
});
|
|
225
191
|
}
|
|
226
|
-
//#endregion
|
|
227
192
|
export { TOCEmpty, TOCItem, TOCItems, clerk_exports };
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import * as Primitive from "fumadocs-core/toc";
|
|
3
|
-
declare namespace default_d_exports {
|
|
4
|
-
export { TOCEmpty, TOCItem, TOCItems, TOCItemsProps };
|
|
5
|
-
}
|
|
6
3
|
export interface TOCItemsProps extends ComponentProps<'div'> {
|
|
7
4
|
thumbBox?: boolean;
|
|
8
5
|
}
|
|
9
|
-
export declare function TOCItems({
|
|
6
|
+
export declare function TOCItems({ className, thumbBox, children, ...props }: TOCItemsProps): import("react").JSX.Element;
|
|
10
7
|
export declare function TOCEmpty(): import("react").JSX.Element;
|
|
11
8
|
export declare function TOCItem({ item, ...props }: Primitive.TOCItemProps & {
|
|
12
9
|
item: Primitive.TOCItemType;
|
|
13
|
-
}): import("react").JSX.Element;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { default_d_exports };
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -1,119 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
5
4
|
import { useTOCItems } from "./index.js";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { useCallback,
|
|
6
|
+
import { useCallback, useMemo } from "react";
|
|
8
7
|
import { useTranslations } from "@fuma-translate/react";
|
|
9
8
|
import * as Primitive from "fumadocs-core/toc";
|
|
10
|
-
|
|
9
|
+
// src/components/toc/default.tsx
|
|
11
10
|
var default_exports = /* @__PURE__ */ __exportAll({
|
|
12
11
|
TOCEmpty: () => TOCEmpty,
|
|
13
12
|
TOCItem: () => TOCItem,
|
|
14
13
|
TOCItems: () => TOCItems
|
|
15
14
|
});
|
|
16
|
-
function TOCItems({
|
|
17
|
-
const containerRef = useRef(null);
|
|
15
|
+
function TOCItems({ className, thumbBox = true, children, ...props }) {
|
|
18
16
|
const items = useTOCItems();
|
|
19
|
-
const [svg, setSvg] = useState(null);
|
|
20
|
-
const onPrint = useCallback(() => {
|
|
21
|
-
const container = containerRef.current;
|
|
22
|
-
if (!container || container.clientHeight === 0) return;
|
|
23
|
-
if (items.length === 0) {
|
|
24
|
-
setSvg(null);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let w = 0;
|
|
28
|
-
let h = 0;
|
|
29
|
-
let d = "";
|
|
30
|
-
const positions = [];
|
|
31
|
-
const output = [];
|
|
32
|
-
for (let i = 0; i < items.length; i++) {
|
|
33
|
-
const item = items[i];
|
|
34
|
-
const element = container.querySelector(`a[href="${item.url}"]`);
|
|
35
|
-
if (!element) continue;
|
|
36
|
-
const styles = getComputedStyle(element);
|
|
37
|
-
const x = getLineOffset(item.depth) + .5;
|
|
38
|
-
const top = element.offsetTop + parseFloat(styles.paddingTop);
|
|
39
|
-
const bottom = element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom);
|
|
40
|
-
w = Math.max(x + 8, w);
|
|
41
|
-
h = Math.max(h, bottom);
|
|
42
|
-
if (i === 0) d += ` M${x} ${top} L${x} ${bottom}`;
|
|
43
|
-
else {
|
|
44
|
-
const [, upperBottom, upperX] = i > 0 ? positions[i - 1] : [
|
|
45
|
-
0,
|
|
46
|
-
0,
|
|
47
|
-
0
|
|
48
|
-
];
|
|
49
|
-
d += ` C ${upperX} ${top - 4} ${x} ${upperBottom + 4} ${x} ${top} L${x} ${bottom}`;
|
|
50
|
-
}
|
|
51
|
-
if (item._step !== void 0) output.push(/* @__PURE__ */ jsxs("g", {
|
|
52
|
-
transform: `translate(${x}, ${(top + bottom) / 2})`,
|
|
53
|
-
children: [/* @__PURE__ */ jsx("circle", {
|
|
54
|
-
cx: "0",
|
|
55
|
-
cy: "0",
|
|
56
|
-
r: "8",
|
|
57
|
-
className: "fill-fd-primary"
|
|
58
|
-
}), /* @__PURE__ */ jsx("text", {
|
|
59
|
-
cx: "0",
|
|
60
|
-
cy: "0",
|
|
61
|
-
textAnchor: "middle",
|
|
62
|
-
alignmentBaseline: "central",
|
|
63
|
-
dominantBaseline: "middle",
|
|
64
|
-
className: "fill-fd-primary-foreground font-medium text-xs leading-none font-mono rtl:-scale-x-100",
|
|
65
|
-
children: item._step
|
|
66
|
-
})]
|
|
67
|
-
}, i));
|
|
68
|
-
positions.push([
|
|
69
|
-
top,
|
|
70
|
-
bottom,
|
|
71
|
-
x
|
|
72
|
-
]);
|
|
73
|
-
}
|
|
74
|
-
output.unshift(/* @__PURE__ */ jsx("path", {
|
|
75
|
-
d,
|
|
76
|
-
className: "stroke-fd-primary",
|
|
77
|
-
strokeWidth: "1",
|
|
78
|
-
fill: "none"
|
|
79
|
-
}, "path"));
|
|
80
|
-
const itemLineLengths = [];
|
|
81
|
-
if (thumbBox) {
|
|
82
|
-
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
83
|
-
path.setAttribute("d", d);
|
|
84
|
-
const n = path.getTotalLength();
|
|
85
|
-
for (let i = 0; i < positions.length; i++) {
|
|
86
|
-
const [top, bottom] = positions[i];
|
|
87
|
-
let l = i > 0 ? itemLineLengths[i - 1][1] + (top - positions[i - 1][1]) : top;
|
|
88
|
-
while (l < n && path.getPointAtLength(l).y < top) l++;
|
|
89
|
-
itemLineLengths.push([l, l + bottom - top]);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
setSvg({
|
|
93
|
-
content: output,
|
|
94
|
-
width: w,
|
|
95
|
-
height: h,
|
|
96
|
-
d,
|
|
97
|
-
itemLineLengths,
|
|
98
|
-
positions
|
|
99
|
-
});
|
|
100
|
-
}, [items, thumbBox]);
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
const container = containerRef.current;
|
|
103
|
-
if (!container) return;
|
|
104
|
-
const observer = new ResizeObserver(onPrint);
|
|
105
|
-
observer.observe(container);
|
|
106
|
-
onPrint();
|
|
107
|
-
return () => {
|
|
108
|
-
observer.unobserve(container);
|
|
109
|
-
};
|
|
110
|
-
}, [onPrint]);
|
|
111
17
|
return /* @__PURE__ */ jsxs("div", {
|
|
112
|
-
ref: mergeRefs(containerRef, ref),
|
|
113
18
|
className: cn("relative flex flex-col", className),
|
|
114
19
|
...props,
|
|
115
|
-
children: [
|
|
116
|
-
|
|
20
|
+
children: [items.length > 0 && /* @__PURE__ */ jsx(ThumbTrack, {
|
|
21
|
+
items,
|
|
117
22
|
thumbBox
|
|
118
23
|
}), children]
|
|
119
24
|
});
|
|
@@ -125,60 +30,119 @@ function TOCEmpty() {
|
|
|
125
30
|
children: t("No Headings")
|
|
126
31
|
});
|
|
127
32
|
}
|
|
128
|
-
function ThumbTrack({
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
let
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
33
|
+
function ThumbTrack({ items, thumbBox }) {
|
|
34
|
+
const toc = Primitive.useTOC();
|
|
35
|
+
const ref = useCallback((track) => {
|
|
36
|
+
const container = track.parentElement;
|
|
37
|
+
const svg = track.querySelector("svg");
|
|
38
|
+
const path = svg.querySelector("path");
|
|
39
|
+
const steps = svg.getElementsByTagName("g");
|
|
40
|
+
const thumb = thumbBox ? track.querySelector("div") : null;
|
|
41
|
+
const segment = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
42
|
+
const positions = /* @__PURE__ */ new Map();
|
|
43
|
+
let previous;
|
|
44
|
+
const update = (infos) => {
|
|
45
|
+
let start = -1;
|
|
46
|
+
let end = -1;
|
|
47
|
+
for (let i = 0; i < infos.length; i++) {
|
|
48
|
+
if (!infos[i].active || !positions.has(infos[i].original.url)) continue;
|
|
49
|
+
if (start === -1) start = i;
|
|
50
|
+
end = i;
|
|
144
51
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
52
|
+
if (start === -1) return;
|
|
53
|
+
const first = positions.get(infos[start].original.url);
|
|
54
|
+
const last = positions.get(infos[end].original.url);
|
|
55
|
+
svg.style.clipPath = `polygon(0 ${first.top}px, 100% ${first.top}px, 100% ${last.bottom}px, 0 ${last.bottom}px)`;
|
|
56
|
+
if (!thumb) return;
|
|
57
|
+
const isUp = previous !== void 0 && (previous.start > start || previous.end > end || previous.start === start && previous.end === end && previous.isUp);
|
|
58
|
+
previous = {
|
|
59
|
+
start,
|
|
60
|
+
end,
|
|
148
61
|
isUp
|
|
149
62
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
63
|
+
thumb.style.offsetDistance = `${isUp ? first.offset : last.offset + last.bottom - last.top}px`;
|
|
64
|
+
thumb.style.opacity = infos[isUp ? start : end].original._step === void 0 ? "1" : "0";
|
|
65
|
+
};
|
|
66
|
+
const observer = new ResizeObserver(() => {
|
|
67
|
+
if (container.clientHeight === 0) return;
|
|
68
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
69
|
+
for (const anchor of container.getElementsByTagName("a")) anchors.set(anchor.getAttribute("href"), anchor);
|
|
70
|
+
let d = "";
|
|
71
|
+
let width = 0;
|
|
72
|
+
let height = 0;
|
|
73
|
+
let length = 0;
|
|
74
|
+
let last;
|
|
75
|
+
positions.clear();
|
|
76
|
+
for (const item of items) {
|
|
77
|
+
const anchor = anchors.get(item.url);
|
|
78
|
+
if (!anchor) continue;
|
|
79
|
+
const styles = getComputedStyle(anchor);
|
|
80
|
+
const x = getLineOffset(item.depth) + .5;
|
|
81
|
+
const top = anchor.offsetTop + parseFloat(styles.paddingTop);
|
|
82
|
+
const bottom = anchor.offsetTop + anchor.clientHeight - parseFloat(styles.paddingBottom);
|
|
83
|
+
if (last) {
|
|
84
|
+
const curve = `C ${last.x} ${top - 4} ${x} ${last.bottom + 4} ${x} ${top}`;
|
|
85
|
+
d += ` ${curve} L${x} ${bottom}`;
|
|
86
|
+
if (thumb) {
|
|
87
|
+
segment.setAttribute("d", `M${last.x} ${last.bottom} ${curve}`);
|
|
88
|
+
length += segment.getTotalLength();
|
|
89
|
+
}
|
|
90
|
+
} else d += `M${x} ${top} L${x} ${bottom}`;
|
|
91
|
+
last = {
|
|
92
|
+
x,
|
|
93
|
+
top,
|
|
94
|
+
bottom,
|
|
95
|
+
offset: length
|
|
96
|
+
};
|
|
97
|
+
positions.set(item.url, last);
|
|
98
|
+
length += bottom - top;
|
|
99
|
+
width = Math.max(width, x + 8);
|
|
100
|
+
height = Math.max(height, bottom);
|
|
101
|
+
}
|
|
102
|
+
let step = 0;
|
|
103
|
+
for (const item of items) {
|
|
104
|
+
if (item._step === void 0) continue;
|
|
105
|
+
const position = positions.get(item.url);
|
|
106
|
+
const g = steps[step++];
|
|
107
|
+
if (position) g.setAttribute("transform", `translate(${position.x}, ${(position.top + position.bottom) / 2})`);
|
|
108
|
+
}
|
|
109
|
+
path.setAttribute("d", d);
|
|
110
|
+
track.style.width = `${width}px`;
|
|
111
|
+
track.style.height = `${height}px`;
|
|
112
|
+
if (thumb) thumb.style.offsetPath = `path("${d}")`;
|
|
113
|
+
update(toc.get());
|
|
114
|
+
});
|
|
115
|
+
observer.observe(container);
|
|
116
|
+
toc.listen(update);
|
|
117
|
+
return () => {
|
|
118
|
+
observer.disconnect();
|
|
119
|
+
toc.unlisten(update);
|
|
120
|
+
};
|
|
121
|
+
}, [
|
|
122
|
+
items,
|
|
123
|
+
thumbBox,
|
|
124
|
+
toc
|
|
125
|
+
]);
|
|
160
126
|
return /* @__PURE__ */ jsxs("div", {
|
|
161
127
|
ref,
|
|
162
128
|
className: "absolute top-0 inset-s-0 origin-center rtl:-scale-x-100",
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
style: { offsetPath: `path("${computed.d}")` }
|
|
181
|
-
})]
|
|
129
|
+
children: [/* @__PURE__ */ jsxs("svg", {
|
|
130
|
+
className: "absolute size-full [clip-path:polygon(0_0,100%_0,100%_0,0_0)] transition-[clip-path]",
|
|
131
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
132
|
+
className: "stroke-fd-primary",
|
|
133
|
+
strokeWidth: "1",
|
|
134
|
+
fill: "none"
|
|
135
|
+
}), items.map((item) => item._step !== void 0 && /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("circle", {
|
|
136
|
+
r: "8",
|
|
137
|
+
className: "fill-fd-primary"
|
|
138
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
139
|
+
textAnchor: "middle",
|
|
140
|
+
alignmentBaseline: "central",
|
|
141
|
+
dominantBaseline: "middle",
|
|
142
|
+
className: "fill-fd-primary-foreground font-medium text-xs leading-none font-mono rtl:-scale-x-100",
|
|
143
|
+
children: item._step
|
|
144
|
+
})] }, item.url))]
|
|
145
|
+
}), thumbBox && /* @__PURE__ */ jsx("div", { className: "absolute left-0 size-1 bg-fd-primary rounded-full opacity-0 transition-[opacity,offset-distance]" })]
|
|
182
146
|
});
|
|
183
147
|
}
|
|
184
148
|
const BASE = 8;
|
|
@@ -256,5 +220,4 @@ function TOCItem({ item, ...props }) {
|
|
|
256
220
|
children: [svg, item.title]
|
|
257
221
|
});
|
|
258
222
|
}
|
|
259
|
-
//#endregion
|
|
260
223
|
export { TOCEmpty, TOCItem, TOCItems, default_exports };
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
import * as Primitive from "fumadocs-core/toc";
|
|
3
|
-
declare namespace index_d_exports {
|
|
4
|
-
export { TOCProvider, TOCProviderProps, TOCScrollArea, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
|
|
5
|
-
}
|
|
6
3
|
export declare function useTOCItems(): Primitive.TOCItemType[];
|
|
7
4
|
export type TOCProviderProps = Primitive.AnchorProviderProps;
|
|
8
5
|
export declare const useActiveAnchor: typeof Primitive.useActiveAnchor, useActiveAnchors: typeof Primitive.useActiveAnchors, useItems: typeof Primitive.useItems;
|
|
9
6
|
export declare function TOCProvider({ toc, children, ...props }: TOCProviderProps): import("react").JSX.Element;
|
|
10
|
-
export declare function TOCScrollArea({ ref, className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { index_d_exports };
|
|
7
|
+
export declare function TOCScrollArea({ ref, className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { mergeRefs } from "../../utils/merge-refs.js";
|
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { createContext, use, useRef } from "react";
|
|
7
7
|
import * as Primitive from "fumadocs-core/toc";
|
|
8
|
-
|
|
8
|
+
// src/components/toc/index.tsx
|
|
9
9
|
var toc_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
TOCProvider: () => TOCProvider,
|
|
11
11
|
TOCScrollArea: () => TOCScrollArea,
|
|
@@ -41,5 +41,4 @@ function TOCScrollArea({ ref, className, ...props }) {
|
|
|
41
41
|
})
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
//#endregion
|
|
45
44
|
export { TOCProvider, TOCScrollArea, toc_exports, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode } from "react";
|
|
2
|
-
//#region src/components/type-table.d.ts
|
|
3
2
|
export interface ParameterNode {
|
|
4
3
|
name: string;
|
|
5
4
|
description: ReactNode;
|
|
@@ -32,5 +31,4 @@ export interface TypeNode {
|
|
|
32
31
|
}
|
|
33
32
|
export declare function TypeTable({ id, type, className, ...props }: {
|
|
34
33
|
type: Record<string, TypeNode>;
|
|
35
|
-
} & ComponentProps<'div'>): import("react").JSX.Element;
|
|
36
|
-
//#endregion
|
|
34
|
+
} & ComponentProps<'div'>): import("react").JSX.Element;
|