@hanzo/docs-base-ui 16.5.0 → 16.7.5
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/README.md +3 -3
- package/css/aspen.css +39 -0
- package/css/black.css +39 -1
- package/css/catppuccin.css +49 -1
- package/css/dusk.css +47 -1
- package/css/emerald.css +39 -0
- package/css/generated/docs.css +490 -0
- package/css/generated/flux.css +429 -0
- package/css/generated/home.css +285 -0
- package/css/generated/notebook.css +526 -0
- package/css/generated/shared.css +1173 -0
- package/css/lib/base.css +214 -0
- package/css/lib/default-colors.css +51 -0
- package/css/lib/shiki.css +98 -0
- package/css/neutral.css +7 -1
- package/css/ocean.css +44 -1
- package/css/preset.css +9 -7
- package/css/purple.css +39 -1
- package/css/ruby.css +39 -0
- package/css/shadcn.css +36 -1
- package/css/solar.css +75 -1
- package/css/vitepress.css +65 -1
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/accordion.d.ts +2 -3
- package/dist/components/accordion.js +9 -13
- package/dist/components/banner.d.ts +3 -4
- package/dist/components/banner.js +5 -9
- package/dist/components/callout.d.ts +6 -7
- package/dist/components/callout.js +1 -4
- package/dist/components/card.d.ts +4 -5
- package/dist/components/card.js +2 -5
- package/dist/components/codeblock.d.ts +8 -9
- package/dist/components/codeblock.js +9 -13
- package/dist/components/codeblock.rsc.d.ts +21 -0
- package/dist/components/codeblock.rsc.js +22 -0
- package/dist/components/dialog/search-algolia.d.ts +7 -9
- package/dist/components/dialog/search-algolia.js +8 -12
- package/dist/components/dialog/search-default.d.ts +7 -9
- package/dist/components/dialog/search-default.js +8 -12
- package/dist/components/dialog/search-orama.d.ts +7 -9
- package/dist/components/dialog/search-orama.js +8 -12
- package/dist/components/dialog/search.d.ts +21 -21
- package/dist/components/dialog/search.js +137 -60
- package/dist/components/dynamic-codeblock.core.d.ts +35 -0
- package/dist/components/dynamic-codeblock.core.js +51 -0
- package/dist/components/dynamic-codeblock.d.ts +7 -29
- package/dist/components/dynamic-codeblock.js +11 -60
- package/dist/components/files.d.ts +1 -2
- package/dist/components/files.js +6 -10
- package/dist/components/github-info.d.ts +23 -10
- package/dist/components/github-info.js +34 -29
- package/dist/components/heading.d.ts +1 -2
- package/dist/components/heading.js +3 -6
- package/dist/components/image-zoom.d.ts +4 -5
- package/dist/components/image-zoom.js +2 -5
- package/dist/components/inline-toc.d.ts +3 -4
- package/dist/components/inline-toc.js +2 -6
- package/dist/components/sidebar/base.d.ts +29 -23
- package/dist/components/sidebar/base.js +16 -22
- package/dist/components/sidebar/link-item.d.ts +3 -4
- package/dist/components/sidebar/link-item.js +6 -3
- package/dist/components/sidebar/page-tree.d.ts +3 -4
- package/dist/components/sidebar/page-tree.js +56 -45
- package/dist/components/sidebar/tabs/dropdown.d.ts +6 -9
- package/dist/components/sidebar/tabs/dropdown.js +22 -29
- package/dist/components/sidebar/tabs/index.d.ts +3 -17
- package/dist/components/sidebar/tabs/index.js +0 -3
- package/dist/components/steps.d.ts +4 -5
- package/dist/components/steps.js +0 -3
- package/dist/components/tabs.d.ts +15 -11
- package/dist/components/tabs.js +15 -20
- package/dist/components/toc/clerk.d.ts +19 -1
- package/dist/components/toc/clerk.js +165 -10
- package/dist/components/toc/default.d.ts +19 -1
- package/dist/components/toc/default.js +45 -10
- package/dist/components/toc/index.d.ts +29 -1
- package/dist/components/toc/index.js +105 -10
- package/dist/components/type-table.d.ts +11 -6
- package/dist/components/type-table.js +28 -23
- package/dist/components/ui/accordion.d.ts +7 -8
- package/dist/components/ui/accordion.js +2 -6
- package/dist/components/ui/button.d.ts +1 -2
- package/dist/components/ui/button.js +0 -3
- package/dist/components/ui/collapsible.d.ts +6 -7
- package/dist/components/ui/collapsible.js +3 -7
- package/dist/components/ui/navigation-menu.d.ts +27 -13
- package/dist/components/ui/navigation-menu.js +53 -31
- package/dist/components/ui/popover.d.ts +11 -6
- package/dist/components/ui/popover.js +15 -19
- package/dist/components/ui/scroll-area.d.ts +17 -7
- package/dist/components/ui/scroll-area.js +27 -31
- package/dist/components/ui/tabs.d.ts +8 -9
- package/dist/components/ui/tabs.js +5 -9
- package/dist/contexts/i18n.d.ts +62 -1
- package/dist/contexts/i18n.js +53 -10
- package/dist/contexts/search.d.ts +71 -5
- package/dist/contexts/search.js +64 -10
- package/dist/contexts/tree.d.ts +21 -1
- package/dist/contexts/tree.js +36 -10
- package/dist/i18n.d.ts +21 -1
- package/dist/i18n.js +20 -3
- package/dist/layouts/docs/client.d.ts +30 -29
- package/dist/layouts/docs/client.js +76 -52
- package/dist/layouts/docs/index.d.ts +21 -35
- package/dist/layouts/docs/index.js +16 -172
- package/dist/layouts/docs/page/index.d.ts +75 -52
- package/dist/layouts/docs/page/index.js +76 -56
- package/dist/layouts/docs/page/slots/breadcrumb.d.ts +14 -0
- package/dist/layouts/docs/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/docs/page/slots/container.d.ts +7 -0
- package/dist/layouts/docs/page/slots/container.js +17 -0
- package/dist/layouts/docs/page/slots/footer.d.ts +23 -0
- package/dist/layouts/docs/page/slots/footer.js +56 -0
- package/dist/layouts/docs/page/slots/toc.d.ts +55 -0
- package/dist/layouts/docs/page/slots/toc.js +166 -0
- package/dist/layouts/docs/slots/container.d.ts +7 -0
- package/dist/layouts/docs/slots/container.js +29 -0
- package/dist/layouts/docs/slots/header.d.ts +8 -0
- package/dist/layouts/docs/slots/header.js +38 -0
- package/dist/layouts/docs/slots/sidebar.d.ts +30 -0
- package/dist/layouts/docs/slots/sidebar.js +319 -0
- package/dist/layouts/flux/index.d.ts +74 -0
- package/dist/layouts/flux/index.js +146 -0
- package/dist/layouts/flux/page/index.d.ts +105 -0
- package/dist/layouts/flux/page/index.js +104 -0
- package/dist/layouts/flux/page/slots/breadcrumb.d.ts +14 -0
- package/dist/layouts/flux/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/flux/page/slots/container.d.ts +7 -0
- package/dist/layouts/flux/page/slots/container.js +17 -0
- package/dist/layouts/flux/page/slots/footer.d.ts +23 -0
- package/dist/layouts/flux/page/slots/footer.js +56 -0
- package/dist/layouts/flux/page/slots/toc.d.ts +34 -0
- package/dist/layouts/flux/page/slots/toc.js +172 -0
- package/dist/layouts/flux/slots/container.d.ts +7 -0
- package/dist/layouts/flux/slots/container.js +13 -0
- package/dist/layouts/flux/slots/sidebar.d.ts +23 -0
- package/dist/layouts/flux/slots/sidebar.js +237 -0
- package/dist/layouts/flux/slots/tab-dropdown.d.ts +17 -0
- package/dist/layouts/flux/slots/tab-dropdown.js +85 -0
- package/dist/layouts/home/index.d.ts +25 -8
- package/dist/layouts/home/index.js +39 -19
- package/dist/layouts/home/navbar.d.ts +7 -16
- package/dist/layouts/home/navbar.js +12 -14
- package/dist/layouts/home/not-found.d.ts +9 -0
- package/dist/layouts/home/not-found.js +38 -0
- package/dist/layouts/home/slots/container.d.ts +7 -0
- package/dist/layouts/home/slots/container.js +13 -0
- package/dist/layouts/home/slots/header.d.ts +11 -0
- package/dist/layouts/home/slots/header.js +242 -0
- package/dist/layouts/notebook/client.d.ts +32 -44
- package/dist/layouts/notebook/client.js +58 -148
- package/dist/layouts/notebook/index.d.ts +26 -25
- package/dist/layouts/notebook/index.js +16 -213
- package/dist/layouts/notebook/page/index.d.ts +75 -52
- package/dist/layouts/notebook/page/index.js +76 -56
- package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +14 -0
- package/dist/layouts/notebook/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/notebook/page/slots/container.d.ts +7 -0
- package/dist/layouts/notebook/page/slots/container.js +17 -0
- package/dist/layouts/notebook/page/slots/footer.d.ts +23 -0
- package/dist/layouts/notebook/page/slots/footer.js +56 -0
- package/dist/layouts/notebook/page/slots/toc.d.ts +55 -0
- package/dist/layouts/notebook/page/slots/toc.js +165 -0
- package/dist/layouts/notebook/slots/container.d.ts +7 -0
- package/dist/layouts/notebook/slots/container.js +31 -0
- package/dist/layouts/notebook/slots/header.d.ts +8 -0
- package/dist/layouts/notebook/slots/header.js +194 -0
- package/dist/layouts/notebook/slots/sidebar.d.ts +40 -0
- package/dist/layouts/notebook/slots/sidebar.js +297 -0
- package/dist/layouts/shared/client.d.ts +45 -0
- package/dist/layouts/shared/client.js +84 -0
- package/dist/layouts/shared/index.d.ts +144 -35
- package/dist/layouts/shared/index.js +74 -15
- package/dist/layouts/shared/page-actions.d.ts +36 -0
- package/dist/layouts/shared/page-actions.js +190 -0
- package/dist/layouts/shared/slots/language-select.d.ts +10 -0
- package/dist/layouts/shared/{language-toggle.js → slots/language-select.js} +12 -16
- package/dist/layouts/shared/slots/search-trigger.d.ts +23 -0
- package/dist/layouts/shared/{search-toggle.js → slots/search-trigger.js} +12 -16
- package/dist/layouts/shared/slots/theme-switch.d.ts +14 -0
- package/dist/layouts/shared/{theme-toggle.js → slots/theme-switch.js} +11 -15
- package/dist/mdx.d.ts +23 -13
- package/dist/mdx.js +2 -6
- package/dist/mdx.server.d.ts +1 -3
- package/dist/mdx.server.js +0 -3
- package/dist/og/takumi.d.ts +21 -0
- package/dist/og/takumi.js +70 -0
- package/dist/og.d.ts +22 -1
- package/dist/og.js +70 -3
- package/dist/page.d.ts +6 -7
- package/dist/page.js +9 -14
- package/dist/provider/base.d.ts +5 -6
- package/dist/provider/base.js +5 -9
- package/dist/provider/next.d.ts +4 -5
- package/dist/provider/next.js +1 -5
- package/dist/provider/react-router.d.ts +4 -5
- package/dist/provider/react-router.js +1 -5
- package/dist/provider/tanstack.d.ts +4 -5
- package/dist/provider/tanstack.js +1 -5
- package/dist/provider/waku.d.ts +4 -5
- package/dist/provider/waku.js +1 -5
- package/dist/style.css +594 -192
- package/dist/tailwind/typography.d.ts +2 -0
- package/dist/tailwind/typography.js +2 -0
- package/dist/utils/cn.js +2 -0
- package/dist/utils/merge-refs.js +11 -0
- package/dist/utils/urls.js +15 -0
- package/dist/utils/use-copy-button.d.ts +6 -1
- package/dist/utils/use-copy-button.js +26 -3
- package/dist/utils/use-footer-items.d.ts +9 -1
- package/dist/utils/use-footer-items.js +24 -3
- package/dist/utils/use-is-scroll-top.d.ts +8 -1
- package/dist/utils/use-is-scroll-top.js +20 -3
- package/package.json +133 -81
- package/css/layouts/docs.css +0 -1
- package/css/layouts/home.css +0 -1
- package/css/layouts/notebook.css +0 -1
- package/dist/_virtual/rolldown_runtime.js +0 -36
- package/dist/components/accordion.d.ts.map +0 -1
- package/dist/components/accordion.js.map +0 -1
- package/dist/components/banner.d.ts.map +0 -1
- package/dist/components/banner.js.map +0 -1
- package/dist/components/callout.d.ts.map +0 -1
- package/dist/components/callout.js.map +0 -1
- package/dist/components/card.d.ts.map +0 -1
- package/dist/components/card.js.map +0 -1
- package/dist/components/codeblock.d.ts.map +0 -1
- package/dist/components/codeblock.js.map +0 -1
- package/dist/components/dialog/search-algolia.d.ts.map +0 -1
- package/dist/components/dialog/search-algolia.js.map +0 -1
- package/dist/components/dialog/search-default.d.ts.map +0 -1
- package/dist/components/dialog/search-default.js.map +0 -1
- package/dist/components/dialog/search-orama.d.ts.map +0 -1
- package/dist/components/dialog/search-orama.js.map +0 -1
- package/dist/components/dialog/search.d.ts.map +0 -1
- package/dist/components/dialog/search.js.map +0 -1
- package/dist/components/dynamic-codeblock.d.ts.map +0 -1
- package/dist/components/dynamic-codeblock.js.map +0 -1
- package/dist/components/files.d.ts.map +0 -1
- package/dist/components/files.js.map +0 -1
- package/dist/components/github-info.d.ts.map +0 -1
- package/dist/components/github-info.js.map +0 -1
- package/dist/components/heading.d.ts.map +0 -1
- package/dist/components/heading.js.map +0 -1
- package/dist/components/image-zoom-CtfZieBH.css +0 -80
- package/dist/components/image-zoom-CtfZieBH.css.map +0 -1
- package/dist/components/image-zoom.d.ts.map +0 -1
- package/dist/components/image-zoom.js.map +0 -1
- package/dist/components/image-zoom2.js +0 -1
- package/dist/components/inline-toc.d.ts.map +0 -1
- package/dist/components/inline-toc.js.map +0 -1
- package/dist/components/sidebar/base.d.ts.map +0 -1
- package/dist/components/sidebar/base.js.map +0 -1
- package/dist/components/sidebar/link-item.d.ts.map +0 -1
- package/dist/components/sidebar/link-item.js.map +0 -1
- package/dist/components/sidebar/page-tree.d.ts.map +0 -1
- package/dist/components/sidebar/page-tree.js.map +0 -1
- package/dist/components/sidebar/tabs/dropdown.d.ts.map +0 -1
- package/dist/components/sidebar/tabs/dropdown.js.map +0 -1
- package/dist/components/sidebar/tabs/index.d.ts.map +0 -1
- package/dist/components/sidebar/tabs/index.js.map +0 -1
- package/dist/components/steps.d.ts.map +0 -1
- package/dist/components/steps.js.map +0 -1
- package/dist/components/tabs.d.ts.map +0 -1
- package/dist/components/tabs.js.map +0 -1
- package/dist/components/toc/clerk.js.map +0 -1
- package/dist/components/toc/default.js.map +0 -1
- package/dist/components/toc/index.js.map +0 -1
- package/dist/components/type-table.d.ts.map +0 -1
- package/dist/components/type-table.js.map +0 -1
- package/dist/components/ui/accordion.d.ts.map +0 -1
- package/dist/components/ui/accordion.js.map +0 -1
- package/dist/components/ui/button.d.ts.map +0 -1
- package/dist/components/ui/button.js.map +0 -1
- package/dist/components/ui/collapsible.d.ts.map +0 -1
- package/dist/components/ui/collapsible.js.map +0 -1
- package/dist/components/ui/navigation-menu.d.ts.map +0 -1
- package/dist/components/ui/navigation-menu.js.map +0 -1
- package/dist/components/ui/popover.d.ts.map +0 -1
- package/dist/components/ui/popover.js.map +0 -1
- package/dist/components/ui/scroll-area.d.ts.map +0 -1
- package/dist/components/ui/scroll-area.js.map +0 -1
- package/dist/components/ui/tabs.d.ts.map +0 -1
- package/dist/components/ui/tabs.js.map +0 -1
- package/dist/contexts/i18n.js.map +0 -1
- package/dist/contexts/search.d.ts.map +0 -1
- package/dist/contexts/search.js.map +0 -1
- package/dist/contexts/tree.js.map +0 -1
- package/dist/layouts/docs/client.d.ts.map +0 -1
- package/dist/layouts/docs/client.js.map +0 -1
- package/dist/layouts/docs/index.d.ts.map +0 -1
- package/dist/layouts/docs/index.js.map +0 -1
- package/dist/layouts/docs/page/client.d.ts +0 -46
- package/dist/layouts/docs/page/client.d.ts.map +0 -1
- package/dist/layouts/docs/page/client.js +0 -227
- package/dist/layouts/docs/page/client.js.map +0 -1
- package/dist/layouts/docs/page/index.d.ts.map +0 -1
- package/dist/layouts/docs/page/index.js.map +0 -1
- package/dist/layouts/docs/sidebar.d.ts +0 -63
- package/dist/layouts/docs/sidebar.d.ts.map +0 -1
- package/dist/layouts/docs/sidebar.js +0 -162
- package/dist/layouts/docs/sidebar.js.map +0 -1
- package/dist/layouts/home/client.d.ts +0 -19
- package/dist/layouts/home/client.d.ts.map +0 -1
- package/dist/layouts/home/client.js +0 -285
- package/dist/layouts/home/client.js.map +0 -1
- package/dist/layouts/home/index.d.ts.map +0 -1
- package/dist/layouts/home/index.js.map +0 -1
- package/dist/layouts/home/navbar.d.ts.map +0 -1
- package/dist/layouts/home/navbar.js.map +0 -1
- package/dist/layouts/notebook/client.d.ts.map +0 -1
- package/dist/layouts/notebook/client.js.map +0 -1
- package/dist/layouts/notebook/index.d.ts.map +0 -1
- package/dist/layouts/notebook/index.js.map +0 -1
- package/dist/layouts/notebook/page/client.d.ts +0 -46
- package/dist/layouts/notebook/page/client.d.ts.map +0 -1
- package/dist/layouts/notebook/page/client.js +0 -227
- package/dist/layouts/notebook/page/client.js.map +0 -1
- package/dist/layouts/notebook/page/index.d.ts.map +0 -1
- package/dist/layouts/notebook/page/index.js.map +0 -1
- package/dist/layouts/notebook/sidebar.d.ts +0 -59
- package/dist/layouts/notebook/sidebar.d.ts.map +0 -1
- package/dist/layouts/notebook/sidebar.js +0 -133
- package/dist/layouts/notebook/sidebar.js.map +0 -1
- package/dist/layouts/shared/index.d.ts.map +0 -1
- package/dist/layouts/shared/index.js.map +0 -1
- package/dist/layouts/shared/language-toggle.d.ts +0 -10
- package/dist/layouts/shared/language-toggle.d.ts.map +0 -1
- package/dist/layouts/shared/language-toggle.js.map +0 -1
- package/dist/layouts/shared/search-toggle.d.ts +0 -23
- package/dist/layouts/shared/search-toggle.d.ts.map +0 -1
- package/dist/layouts/shared/search-toggle.js.map +0 -1
- package/dist/layouts/shared/theme-toggle.d.ts +0 -14
- package/dist/layouts/shared/theme-toggle.d.ts.map +0 -1
- package/dist/layouts/shared/theme-toggle.js.map +0 -1
- package/dist/mdx.d.ts.map +0 -1
- package/dist/mdx.js.map +0 -1
- package/dist/mdx.server.d.ts.map +0 -1
- package/dist/mdx.server.js.map +0 -1
- package/dist/page.d.ts.map +0 -1
- package/dist/page.js.map +0 -1
- package/dist/provider/base.d.ts.map +0 -1
- package/dist/provider/base.js.map +0 -1
- package/dist/provider/next.d.ts.map +0 -1
- package/dist/provider/next.js.map +0 -1
- package/dist/provider/react-router.d.ts.map +0 -1
- package/dist/provider/react-router.js.map +0 -1
- package/dist/provider/tanstack.d.ts.map +0 -1
- package/dist/provider/tanstack.js.map +0 -1
- package/dist/provider/waku.d.ts.map +0 -1
- package/dist/provider/waku.js.map +0 -1
|
@@ -1,58 +1,69 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useTreeContext, useTreePath } from "../../contexts/tree.js";
|
|
2
|
+
import { isActive } from "../../utils/urls.js";
|
|
3
|
+
import { Fragment, createContext, use, useMemo } from "react";
|
|
4
|
+
import { usePathname } from "@hanzo/docs-core/framework";
|
|
2
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Fragment as Fragment$1, useMemo } from "react";
|
|
4
|
-
|
|
5
6
|
//#region src/components/sidebar/page-tree.tsx
|
|
7
|
+
const RendererContext = createContext(null);
|
|
6
8
|
function createPageTreeRenderer({ SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarSeparator, SidebarItem }) {
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
function renderList(nodes) {
|
|
10
|
+
return nodes.map((node, i) => /* @__PURE__ */ jsx(PageTreeNode, { node }, i));
|
|
11
|
+
}
|
|
12
|
+
function PageTreeNode({ node }) {
|
|
13
|
+
const { Separator, Item, Folder, pathname } = use(RendererContext);
|
|
14
|
+
if (node.type === "separator") {
|
|
15
|
+
if (Separator) return /* @__PURE__ */ jsx(Separator, { item: node });
|
|
16
|
+
return /* @__PURE__ */ jsxs(SidebarSeparator, { children: [node.icon, node.name] });
|
|
17
|
+
}
|
|
18
|
+
if (node.type === "folder") {
|
|
19
|
+
const path = useTreePath();
|
|
20
|
+
if (Folder) return /* @__PURE__ */ jsx(Folder, {
|
|
21
|
+
item: node,
|
|
22
|
+
children: renderList(node.children)
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsxs(SidebarFolder, {
|
|
25
|
+
collapsible: node.collapsible,
|
|
26
|
+
active: path.includes(node),
|
|
27
|
+
defaultOpen: node.defaultOpen,
|
|
28
|
+
children: [node.index ? /* @__PURE__ */ jsxs(SidebarFolderLink, {
|
|
29
|
+
href: node.index.url,
|
|
30
|
+
active: isActive(node.index.url, pathname),
|
|
31
|
+
external: node.index.external,
|
|
32
|
+
children: [node.icon, node.name]
|
|
33
|
+
}) : /* @__PURE__ */ jsxs(SidebarFolderTrigger, { children: [node.icon, node.name] }), /* @__PURE__ */ jsx(SidebarFolderContent, { children: renderList(node.children) })]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (Item) return /* @__PURE__ */ jsx(Item, { item: node });
|
|
37
|
+
return /* @__PURE__ */ jsx(SidebarItem, {
|
|
38
|
+
href: node.url,
|
|
39
|
+
external: node.external,
|
|
40
|
+
active: isActive(node.url, pathname),
|
|
41
|
+
icon: node.icon,
|
|
42
|
+
children: node.name
|
|
18
43
|
});
|
|
19
44
|
}
|
|
20
45
|
/**
|
|
21
46
|
* Render sidebar items from page tree
|
|
22
47
|
*/
|
|
23
48
|
return function SidebarPageTree(components) {
|
|
24
|
-
const {
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
icon: item.icon,
|
|
42
|
-
children: item.name
|
|
43
|
-
}, item.url);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: renderSidebarList(root.children) }, root.$id);
|
|
47
|
-
}, [
|
|
48
|
-
Folder,
|
|
49
|
-
Item,
|
|
50
|
-
Separator,
|
|
51
|
-
root
|
|
52
|
-
]);
|
|
49
|
+
const { Folder, Item, Separator } = components;
|
|
50
|
+
const { root } = useTreeContext();
|
|
51
|
+
const pathname = usePathname();
|
|
52
|
+
return /* @__PURE__ */ jsx(RendererContext, {
|
|
53
|
+
value: useMemo(() => ({
|
|
54
|
+
Folder,
|
|
55
|
+
Item,
|
|
56
|
+
Separator,
|
|
57
|
+
pathname
|
|
58
|
+
}), [
|
|
59
|
+
Folder,
|
|
60
|
+
Item,
|
|
61
|
+
Separator,
|
|
62
|
+
pathname
|
|
63
|
+
]),
|
|
64
|
+
children: /* @__PURE__ */ jsx(Fragment, { children: renderList(root.children) }, root.$id)
|
|
65
|
+
});
|
|
53
66
|
};
|
|
54
67
|
}
|
|
55
|
-
|
|
56
68
|
//#endregion
|
|
57
69
|
export { createPageTreeRenderer };
|
|
58
|
-
//# sourceMappingURL=page-tree.js.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as react_jsx_runtime17 from "react/jsx-runtime";
|
|
1
|
+
import { LayoutTab, isLayoutTabActive } from "../../../layouts/shared/index.js";
|
|
3
2
|
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/components/sidebar/tabs/dropdown.d.ts
|
|
6
|
-
|
|
7
|
-
props?: ComponentProps<'a'>;
|
|
8
|
-
}
|
|
6
|
+
type SidebarTabWithProps = LayoutTab;
|
|
9
7
|
declare function SidebarTabsDropdown({
|
|
10
8
|
options,
|
|
11
9
|
placeholder,
|
|
@@ -13,8 +11,7 @@ declare function SidebarTabsDropdown({
|
|
|
13
11
|
}: {
|
|
14
12
|
placeholder?: ReactNode;
|
|
15
13
|
options: SidebarTabWithProps[];
|
|
16
|
-
} & ComponentProps<'button'>):
|
|
17
|
-
declare
|
|
14
|
+
} & ComponentProps<'button'>): react_jsx_runtime0.JSX.Element;
|
|
15
|
+
declare const isTabActive: typeof isLayoutTabActive;
|
|
18
16
|
//#endregion
|
|
19
|
-
export { SidebarTabWithProps, SidebarTabsDropdown, isTabActive };
|
|
20
|
-
//# sourceMappingURL=dropdown.d.ts.map
|
|
17
|
+
export { SidebarTabWithProps, SidebarTabsDropdown, isTabActive };
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useSidebar } from "../base.js";
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
4
3
|
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
5
|
-
import
|
|
4
|
+
import { isLayoutTabActive } from "../../../layouts/shared/index.js";
|
|
5
|
+
import { useSidebar } from "../base.js";
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
6
7
|
import { usePathname } from "@hanzo/docs-core/framework";
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import Link from "@hanzo/docs-core/link";
|
|
9
10
|
import { Check, ChevronsUpDown } from "lucide-react";
|
|
10
|
-
import { useMemo, useState } from "react";
|
|
11
|
-
import { isActive, normalize } from "@hanzo/docs-ui/urls";
|
|
12
|
-
|
|
13
11
|
//#region src/components/sidebar/tabs/dropdown.tsx
|
|
14
12
|
function SidebarTabsDropdown({ options, placeholder, ...props }) {
|
|
15
13
|
const [open, setOpen] = useState(false);
|
|
16
14
|
const { closeOnRedirect } = useSidebar();
|
|
17
15
|
const pathname = usePathname();
|
|
18
16
|
const selected = useMemo(() => {
|
|
19
|
-
return options.findLast((item
|
|
17
|
+
return options.findLast((item) => isTabActive(item, pathname));
|
|
20
18
|
}, [options, pathname]);
|
|
21
19
|
const onClick = () => {
|
|
22
20
|
closeOnRedirect.current = false;
|
|
23
21
|
setOpen(false);
|
|
24
22
|
};
|
|
25
|
-
const item = selected ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
23
|
+
const item = selected ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
26
24
|
className: "size-9 shrink-0 empty:hidden md:size-5",
|
|
27
25
|
children: selected.icon
|
|
28
26
|
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
@@ -37,42 +35,37 @@ function SidebarTabsDropdown({ options, placeholder, ...props }) {
|
|
|
37
35
|
onOpenChange: setOpen,
|
|
38
36
|
children: [item && /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
39
37
|
...props,
|
|
40
|
-
className: cn("flex items-center gap-2 rounded-lg p-2 border bg-fd-secondary/50 text-start text-fd-secondary-foreground transition-colors hover:bg-fd-accent data-
|
|
38
|
+
className: cn("flex items-center gap-2 rounded-lg p-2 border bg-fd-secondary/50 text-start text-fd-secondary-foreground transition-colors hover:bg-fd-accent data-open:bg-fd-accent data-open:text-fd-accent-foreground", props.className),
|
|
41
39
|
children: [item, /* @__PURE__ */ jsx(ChevronsUpDown, { className: "shrink-0 ms-auto size-4 text-fd-muted-foreground" })]
|
|
42
40
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
43
41
|
className: "flex flex-col gap-1 w-(--anchor-width) p-1 fd-scroll-container",
|
|
44
|
-
children: options.map((item
|
|
45
|
-
const isActive
|
|
46
|
-
if (!isActive
|
|
42
|
+
children: options.map((item) => {
|
|
43
|
+
const isActive = selected && item.url === selected.url;
|
|
44
|
+
if (!isActive && item.unlisted) return;
|
|
47
45
|
return /* @__PURE__ */ jsxs(Link, {
|
|
48
|
-
href: item
|
|
46
|
+
href: item.url,
|
|
49
47
|
onClick,
|
|
50
|
-
...item
|
|
51
|
-
className: cn("flex items-center gap-2 rounded-lg p-1.5 hover:bg-fd-accent hover:text-fd-accent-foreground", item
|
|
48
|
+
...item.props,
|
|
49
|
+
className: cn("flex items-center gap-2 rounded-lg p-1.5 hover:bg-fd-accent hover:text-fd-accent-foreground", item.props?.className),
|
|
52
50
|
children: [
|
|
53
51
|
/* @__PURE__ */ jsx("div", {
|
|
54
52
|
className: "shrink-0 size-9 md:mb-auto md:size-5 empty:hidden",
|
|
55
|
-
children: item
|
|
53
|
+
children: item.icon
|
|
56
54
|
}),
|
|
57
55
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
58
56
|
className: "text-sm font-medium leading-none",
|
|
59
|
-
children: item
|
|
57
|
+
children: item.title
|
|
60
58
|
}), /* @__PURE__ */ jsx("p", {
|
|
61
59
|
className: "text-[0.8125rem] text-fd-muted-foreground mt-1 empty:hidden",
|
|
62
|
-
children: item
|
|
60
|
+
children: item.description
|
|
63
61
|
})] }),
|
|
64
|
-
/* @__PURE__ */ jsx(Check, { className: cn("shrink-0 ms-auto size-3.5 text-fd-primary", !isActive
|
|
62
|
+
/* @__PURE__ */ jsx(Check, { className: cn("shrink-0 ms-auto size-3.5 text-fd-primary", !isActive && "invisible") })
|
|
65
63
|
]
|
|
66
|
-
}, item
|
|
64
|
+
}, item.url);
|
|
67
65
|
})
|
|
68
66
|
})]
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
|
-
|
|
72
|
-
if (tab.urls) return tab.urls.has(normalize(pathname));
|
|
73
|
-
return isActive(tab.url, pathname, true);
|
|
74
|
-
}
|
|
75
|
-
|
|
69
|
+
const isTabActive = isLayoutTabActive;
|
|
76
70
|
//#endregion
|
|
77
71
|
export { SidebarTabsDropdown, isTabActive };
|
|
78
|
-
//# sourceMappingURL=dropdown.js.map
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LayoutTab } from "../../../layouts/shared/index.js";
|
|
2
2
|
import * as PageTree from "@hanzo/docs-core/page-tree";
|
|
3
3
|
|
|
4
4
|
//#region src/components/sidebar/tabs/index.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Redirect URL of the folder, usually the index page
|
|
8
|
-
*/
|
|
9
|
-
url: string;
|
|
10
|
-
icon?: ReactNode;
|
|
11
|
-
title: ReactNode;
|
|
12
|
-
description?: ReactNode;
|
|
13
|
-
/**
|
|
14
|
-
* Detect from a list of urls
|
|
15
|
-
*/
|
|
16
|
-
urls?: Set<string>;
|
|
17
|
-
unlisted?: boolean;
|
|
18
|
-
}
|
|
5
|
+
type SidebarTab = LayoutTab;
|
|
19
6
|
interface GetSidebarTabsOptions {
|
|
20
7
|
transform?: (option: SidebarTab, node: PageTree.Folder) => SidebarTab | null;
|
|
21
8
|
}
|
|
@@ -23,5 +10,4 @@ declare function getSidebarTabs(tree: PageTree.Root, {
|
|
|
23
10
|
transform
|
|
24
11
|
}?: GetSidebarTabsOptions): SidebarTab[];
|
|
25
12
|
//#endregion
|
|
26
|
-
export { GetSidebarTabsOptions, SidebarTab, getSidebarTabs };
|
|
27
|
-
//# sourceMappingURL=index.d.ts.map
|
|
13
|
+
export { GetSidebarTabsOptions, SidebarTab, getSidebarTabs };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
2
|
//#region src/components/sidebar/tabs/index.tsx
|
|
4
3
|
const defaultTransform = (option, node) => {
|
|
5
4
|
if (!node.icon) return option;
|
|
@@ -43,7 +42,5 @@ function getFolderUrls(folder, output = /* @__PURE__ */ new Set()) {
|
|
|
43
42
|
}
|
|
44
43
|
return output;
|
|
45
44
|
}
|
|
46
|
-
|
|
47
45
|
//#endregion
|
|
48
46
|
export { getSidebarTabs };
|
|
49
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import * as react_jsx_runtime80 from "react/jsx-runtime";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/steps.d.ts
|
|
5
5
|
declare function Steps({
|
|
6
6
|
children
|
|
7
7
|
}: {
|
|
8
8
|
children: ReactNode;
|
|
9
|
-
}):
|
|
9
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
10
10
|
declare function Step({
|
|
11
11
|
children
|
|
12
12
|
}: {
|
|
13
13
|
children: ReactNode;
|
|
14
|
-
}):
|
|
14
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
|
-
export { Step, Steps };
|
|
17
|
-
//# sourceMappingURL=steps.d.ts.map
|
|
16
|
+
export { Step, Steps };
|
package/dist/components/steps.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
2
|
//#region src/components/steps.tsx
|
|
4
3
|
function Steps({ children }) {
|
|
5
4
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -13,7 +12,5 @@ function Step({ children }) {
|
|
|
13
12
|
children
|
|
14
13
|
});
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
//#endregion
|
|
18
16
|
export { Step, Steps };
|
|
19
|
-
//# sourceMappingURL=steps.js.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Tabs as Tabs$1, TabsContent as TabsContent$1 } from "./ui/tabs.js";
|
|
2
|
-
import * as
|
|
3
|
-
import * as React from "react";
|
|
1
|
+
import { Tabs as Tabs$1, TabsContent as TabsContent$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1 } from "./ui/tabs.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
4
3
|
import { ComponentProps, ReactNode } from "react";
|
|
5
|
-
import * as
|
|
4
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
5
|
|
|
7
6
|
//#region src/components/tabs.d.ts
|
|
8
7
|
interface TabsProps extends Omit<ComponentProps<typeof Tabs$1>, 'value' | 'onValueChange'> {
|
|
@@ -21,8 +20,14 @@ interface TabsProps extends Omit<ComponentProps<typeof Tabs$1>, 'value' | 'onVal
|
|
|
21
20
|
*/
|
|
22
21
|
label?: ReactNode;
|
|
23
22
|
}
|
|
24
|
-
declare
|
|
25
|
-
|
|
23
|
+
declare function TabsList({
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: React$1.ComponentPropsWithRef<typeof TabsList$1>): react_jsx_runtime0.JSX.Element;
|
|
27
|
+
declare function TabsTrigger({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}: React$1.ComponentPropsWithRef<typeof TabsTrigger$1>): react_jsx_runtime0.JSX.Element;
|
|
26
31
|
declare function Tabs({
|
|
27
32
|
ref,
|
|
28
33
|
className,
|
|
@@ -31,7 +36,7 @@ declare function Tabs({
|
|
|
31
36
|
defaultIndex,
|
|
32
37
|
defaultValue,
|
|
33
38
|
...props
|
|
34
|
-
}: TabsProps):
|
|
39
|
+
}: TabsProps): react_jsx_runtime0.JSX.Element;
|
|
35
40
|
interface TabProps extends Omit<ComponentProps<typeof TabsContent$1>, 'value'> {
|
|
36
41
|
/**
|
|
37
42
|
* Value of tab, detect from index if unspecified.
|
|
@@ -41,12 +46,11 @@ interface TabProps extends Omit<ComponentProps<typeof TabsContent$1>, 'value'> {
|
|
|
41
46
|
declare function Tab({
|
|
42
47
|
value,
|
|
43
48
|
...props
|
|
44
|
-
}: TabProps):
|
|
49
|
+
}: TabProps): react_jsx_runtime0.JSX.Element;
|
|
45
50
|
declare function TabsContent({
|
|
46
51
|
value,
|
|
47
52
|
className,
|
|
48
53
|
...props
|
|
49
|
-
}: ComponentProps<typeof TabsContent$1>):
|
|
54
|
+
}: ComponentProps<typeof TabsContent$1>): react_jsx_runtime0.JSX.Element;
|
|
50
55
|
//#endregion
|
|
51
|
-
export { Tab, TabProps, Tabs, TabsContent, TabsList, TabsProps, TabsTrigger };
|
|
52
|
-
//# sourceMappingURL=tabs.d.ts.map
|
|
56
|
+
export { Tab, TabProps, Tabs, TabsContent, TabsList, TabsProps, TabsTrigger };
|
package/dist/components/tabs.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { Tabs as Tabs$1, TabsContent as TabsContent$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1 } from "./ui/tabs.js";
|
|
4
|
-
import { cn } from "@hanzo/docs-ui/cn";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import * as React from "react";
|
|
7
4
|
import { createContext, useContext, useEffect, useId, useMemo, useState } from "react";
|
|
8
|
-
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
6
|
//#region src/components/tabs.tsx
|
|
10
7
|
const TabsContext = createContext(null);
|
|
11
8
|
function useTabContext() {
|
|
@@ -13,18 +10,18 @@ function useTabContext() {
|
|
|
13
10
|
if (!ctx) throw new Error("You must wrap your component in <Tabs>");
|
|
14
11
|
return ctx;
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
|
|
13
|
+
function TabsList({ className, ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(TabsList$1, {
|
|
15
|
+
...props,
|
|
16
|
+
className: (s) => cn("flex gap-3.5 text-fd-secondary-foreground overflow-x-auto px-4 not-prose", typeof className === "function" ? className(s) : className)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function TabsTrigger({ className, ...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(TabsTrigger$1, {
|
|
21
|
+
...props,
|
|
22
|
+
className: (s) => cn("inline-flex items-center gap-2 whitespace-nowrap text-fd-muted-foreground border-b border-transparent py-2 text-sm font-medium transition-colors [&_svg]:size-4 hover:text-fd-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[active]:border-fd-primary data-[active]:text-fd-primary", typeof className === "function" ? className(s) : className)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
28
25
|
function Tabs({ ref, className, items, label, defaultIndex = 0, defaultValue = items ? escapeValue(items[defaultIndex]) : void 0, ...props }) {
|
|
29
26
|
const [value, setValue] = useState(defaultValue);
|
|
30
27
|
const collection = useMemo(() => [], []);
|
|
@@ -95,7 +92,5 @@ function useCollectionIndex() {
|
|
|
95
92
|
function escapeValue(v) {
|
|
96
93
|
return v.toLowerCase().replace(/\s/, "-");
|
|
97
94
|
}
|
|
98
|
-
|
|
99
95
|
//#endregion
|
|
100
96
|
export { Tab, Tabs, TabsContent, TabsList, TabsTrigger };
|
|
101
|
-
//# sourceMappingURL=tabs.js.map
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as Primitive from "@hanzo/docs-core/toc";
|
|
4
|
+
|
|
5
|
+
//#region src/components/toc/clerk.d.ts
|
|
6
|
+
declare function TOCItems({
|
|
7
|
+
ref,
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}: ComponentProps<'div'>): react_jsx_runtime0.JSX.Element;
|
|
11
|
+
declare function TOCEmpty(): react_jsx_runtime0.JSX.Element;
|
|
12
|
+
declare function TOCItem({
|
|
13
|
+
item,
|
|
14
|
+
...props
|
|
15
|
+
}: Primitive.TOCItemProps & {
|
|
16
|
+
item: Primitive.TOCItemType;
|
|
17
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TOCEmpty, TOCItem, TOCItems };
|
|
@@ -1,12 +1,167 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { useI18n } from "../../contexts/i18n.js";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
6
|
+
import { TocThumb, useTOCItems } from "./index.js";
|
|
7
|
+
import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import * as Primitive from "@hanzo/docs-core/toc";
|
|
5
10
|
//#region src/components/toc/clerk.tsx
|
|
6
|
-
var clerk_exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
var clerk_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
TOCEmpty: () => TOCEmpty,
|
|
13
|
+
TOCItem: () => TOCItem,
|
|
14
|
+
TOCItems: () => TOCItems
|
|
15
|
+
});
|
|
16
|
+
function TOCItems({ ref, className, ...props }) {
|
|
17
|
+
const containerRef = useRef(null);
|
|
18
|
+
const items = useTOCItems();
|
|
19
|
+
const [svg, setSvg] = useState();
|
|
20
|
+
const onResize = useEffectEvent(() => {
|
|
21
|
+
const container = containerRef.current;
|
|
22
|
+
if (!container || container.clientHeight === 0) return;
|
|
23
|
+
let w = 0;
|
|
24
|
+
let h = 0;
|
|
25
|
+
let b0 = 0;
|
|
26
|
+
let d = "";
|
|
27
|
+
for (let i = 0; i < items.length; i++) {
|
|
28
|
+
const element = container.querySelector(`a[href="#${items[i].url.slice(1)}"]`);
|
|
29
|
+
if (!element) continue;
|
|
30
|
+
const styles = getComputedStyle(element);
|
|
31
|
+
const offset = getLineOffset(items[i].depth) + 1, top = element.offsetTop + parseFloat(styles.paddingTop), bottom = element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom);
|
|
32
|
+
w = Math.max(offset, w);
|
|
33
|
+
h = Math.max(h, bottom);
|
|
34
|
+
if (i === 0) d += ` M${offset} ${top} L${offset} ${bottom}`;
|
|
35
|
+
else {
|
|
36
|
+
const pOffset = getLineOffset(items[i - 1].depth) + 1;
|
|
37
|
+
d += ` C ${pOffset} ${top - 4} ${offset} ${b0 + 4} ${offset} ${top} L${offset} ${bottom}`;
|
|
38
|
+
}
|
|
39
|
+
b0 = bottom;
|
|
40
|
+
}
|
|
41
|
+
setSvg({
|
|
42
|
+
d,
|
|
43
|
+
width: w + 1,
|
|
44
|
+
height: h
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!containerRef.current) return;
|
|
49
|
+
const observer = new ResizeObserver(onResize);
|
|
50
|
+
onResize();
|
|
51
|
+
observer.observe(containerRef.current);
|
|
52
|
+
return () => {
|
|
53
|
+
observer.disconnect();
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [svg && /* @__PURE__ */ jsxs(TocThumb, {
|
|
57
|
+
containerRef,
|
|
58
|
+
className: "absolute top-0 inset-s-0",
|
|
59
|
+
style: {
|
|
60
|
+
width: svg.width,
|
|
61
|
+
height: svg.height
|
|
62
|
+
},
|
|
63
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
64
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
65
|
+
viewBox: `0 0 ${svg.width} ${svg.height}`,
|
|
66
|
+
className: "absolute transition-[clip-path]",
|
|
67
|
+
style: {
|
|
68
|
+
width: svg.width,
|
|
69
|
+
height: svg.height,
|
|
70
|
+
clipPath: `polygon(0 var(--fd-top), 100% var(--fd-top), 100% calc(var(--fd-top) + var(--fd-height)), 0 calc(var(--fd-top) + var(--fd-height)))`
|
|
71
|
+
},
|
|
72
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
73
|
+
d: svg.d,
|
|
74
|
+
className: "stroke-fd-primary",
|
|
75
|
+
strokeWidth: "1",
|
|
76
|
+
fill: "none"
|
|
77
|
+
})
|
|
78
|
+
}), /* @__PURE__ */ jsx(ThumbBox, {})]
|
|
79
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
80
|
+
ref: mergeRefs(containerRef, ref),
|
|
81
|
+
className: cn("flex flex-col", className),
|
|
82
|
+
...props
|
|
83
|
+
})] });
|
|
84
|
+
}
|
|
85
|
+
function TOCEmpty() {
|
|
86
|
+
const { text } = useI18n();
|
|
87
|
+
return /* @__PURE__ */ jsx("div", {
|
|
88
|
+
className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground",
|
|
89
|
+
children: text.tocNoHeadings
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function ThumbBox() {
|
|
93
|
+
const items = Primitive.useItems();
|
|
94
|
+
let startIdx = -1;
|
|
95
|
+
let endIdx = -1;
|
|
96
|
+
let lastInactiveIdx = -1;
|
|
97
|
+
for (let i = 0; i < items.length; i++) {
|
|
98
|
+
const item = items[i];
|
|
99
|
+
if (item.active) {
|
|
100
|
+
if (startIdx === -1) startIdx = i;
|
|
101
|
+
endIdx = i;
|
|
102
|
+
} else if (lastInactiveIdx === -1 || items[lastInactiveIdx].t < item.t) lastInactiveIdx = i;
|
|
103
|
+
}
|
|
104
|
+
if (startIdx === -1) return;
|
|
105
|
+
const isStart = endIdx < lastInactiveIdx;
|
|
106
|
+
return /* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: "absolute size-1 bg-fd-primary rounded-full transition-transform",
|
|
108
|
+
style: { translate: `calc(${getLineOffset(items[isStart ? startIdx : endIdx].original.depth)}px - 1.25px) ${isStart ? "var(--fd-top)" : "calc(var(--fd-top) + var(--fd-height))"}` }
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function getItemOffset(depth) {
|
|
112
|
+
if (depth <= 2) return 14;
|
|
113
|
+
if (depth === 3) return 26;
|
|
114
|
+
return 36;
|
|
115
|
+
}
|
|
116
|
+
function getLineOffset(depth) {
|
|
117
|
+
if (depth <= 2) return 2;
|
|
118
|
+
if (depth === 3) return 10;
|
|
119
|
+
return 20;
|
|
120
|
+
}
|
|
121
|
+
function TOCItem({ item, ...props }) {
|
|
122
|
+
const items = useTOCItems();
|
|
123
|
+
const { lowerOffset, offset, upperOffset } = useMemo(() => {
|
|
124
|
+
const index = items.indexOf(item);
|
|
125
|
+
const offset = getLineOffset(item.depth);
|
|
126
|
+
return {
|
|
127
|
+
offset,
|
|
128
|
+
upperOffset: index > 0 ? getLineOffset(items[index - 1].depth) : offset,
|
|
129
|
+
lowerOffset: index + 1 < items.length ? getLineOffset(items[index + 1].depth) : offset
|
|
130
|
+
};
|
|
131
|
+
}, [items, item]);
|
|
132
|
+
return /* @__PURE__ */ jsxs(Primitive.TOCItem, {
|
|
133
|
+
href: item.url,
|
|
134
|
+
...props,
|
|
135
|
+
className: cn("prose relative py-1.5 text-sm scroll-m-4 text-fd-muted-foreground hover:text-fd-accent-foreground transition-colors wrap-anywhere first:pt-0 last:pb-0 data-[active=true]:text-fd-primary", props.className),
|
|
136
|
+
style: {
|
|
137
|
+
paddingInlineStart: getItemOffset(item.depth),
|
|
138
|
+
...props.style
|
|
139
|
+
},
|
|
140
|
+
children: [
|
|
141
|
+
offset !== upperOffset && /* @__PURE__ */ jsx("svg", {
|
|
142
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
143
|
+
viewBox: `${Math.min(offset, upperOffset)} 0 ${Math.abs(upperOffset - offset)} 12`,
|
|
144
|
+
className: "absolute -top-1.5",
|
|
145
|
+
style: {
|
|
146
|
+
width: Math.abs(upperOffset - offset) + 1,
|
|
147
|
+
height: 12,
|
|
148
|
+
insetInlineStart: Math.min(offset, upperOffset)
|
|
149
|
+
},
|
|
150
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
151
|
+
d: `M ${upperOffset} 0 C ${upperOffset} 8 ${offset} 4 ${offset} 12`,
|
|
152
|
+
stroke: "black",
|
|
153
|
+
strokeWidth: "1",
|
|
154
|
+
fill: "none",
|
|
155
|
+
className: "stroke-fd-foreground/10"
|
|
156
|
+
})
|
|
157
|
+
}),
|
|
158
|
+
/* @__PURE__ */ jsx("div", {
|
|
159
|
+
className: cn("absolute inset-y-0 w-px bg-fd-foreground/10", offset !== upperOffset && "top-1.5", offset !== lowerOffset && "bottom-1.5"),
|
|
160
|
+
style: { insetInlineStart: offset }
|
|
161
|
+
}),
|
|
162
|
+
item.title
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
10
166
|
//#endregion
|
|
11
|
-
export { clerk_exports };
|
|
12
|
-
//# sourceMappingURL=clerk.js.map
|
|
167
|
+
export { TOCEmpty, TOCItem, TOCItems, clerk_exports };
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as Primitive from "@hanzo/docs-core/toc";
|
|
4
|
+
|
|
5
|
+
//#region src/components/toc/default.d.ts
|
|
6
|
+
declare function TOCItems({
|
|
7
|
+
ref,
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}: ComponentProps<'div'>): react_jsx_runtime0.JSX.Element;
|
|
11
|
+
declare function TOCEmpty(): react_jsx_runtime0.JSX.Element;
|
|
12
|
+
declare function TOCItem({
|
|
13
|
+
item,
|
|
14
|
+
...props
|
|
15
|
+
}: Primitive.TOCItemProps & {
|
|
16
|
+
item: Primitive.TOCItemType;
|
|
17
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TOCEmpty, TOCItem, TOCItems };
|