@hanzo/docs-base-ui 16.5.3 → 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/css/generated/docs.css +68 -33
- package/css/generated/flux.css +44 -34
- package/css/generated/home.css +88 -4
- package/css/generated/notebook.css +65 -31
- package/css/generated/shared.css +199 -59
- package/css/lib/base.css +1 -4
- package/css/lib/shiki.css +49 -41
- package/css/preset.css +3 -0
- package/dist/_virtual/_rolldown/runtime.js +6 -11
- package/dist/components/accordion.d.ts +1 -2
- package/dist/components/accordion.js +3 -7
- package/dist/components/banner.d.ts +1 -2
- package/dist/components/banner.js +1 -5
- package/dist/components/callout.d.ts +1 -2
- package/dist/components/callout.js +0 -3
- package/dist/components/card.d.ts +1 -2
- package/dist/components/card.js +0 -3
- package/dist/components/codeblock.d.ts +1 -2
- package/dist/components/codeblock.js +2 -6
- 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 +1 -3
- package/dist/components/dialog/search-algolia.js +1 -5
- package/dist/components/dialog/search-default.d.ts +1 -3
- package/dist/components/dialog/search-default.js +1 -5
- package/dist/components/dialog/search-orama.d.ts +1 -3
- package/dist/components/dialog/search-orama.js +1 -5
- package/dist/components/dialog/search.d.ts +5 -5
- package/dist/components/dialog/search.js +124 -47
- package/dist/components/dynamic-codeblock.core.d.ts +7 -5
- package/dist/components/dynamic-codeblock.core.js +17 -32
- package/dist/components/dynamic-codeblock.d.ts +5 -3
- package/dist/components/dynamic-codeblock.js +8 -13
- package/dist/components/files.d.ts +1 -2
- package/dist/components/files.js +4 -8
- package/dist/components/github-info.d.ts +22 -9
- package/dist/components/github-info.js +33 -28
- package/dist/components/heading.d.ts +1 -2
- package/dist/components/heading.js +2 -5
- package/dist/components/image-zoom.d.ts +1 -2
- package/dist/components/image-zoom.js +2 -5
- package/dist/components/inline-toc.d.ts +1 -2
- package/dist/components/inline-toc.js +1 -5
- package/dist/components/sidebar/base.d.ts +7 -3
- package/dist/components/sidebar/base.js +6 -16
- package/dist/components/sidebar/link-item.d.ts +2 -3
- package/dist/components/sidebar/link-item.js +6 -3
- package/dist/components/sidebar/page-tree.d.ts +1 -2
- package/dist/components/sidebar/page-tree.js +54 -43
- package/dist/components/sidebar/tabs/dropdown.d.ts +4 -7
- package/dist/components/sidebar/tabs/dropdown.js +4 -11
- 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 +1 -2
- package/dist/components/steps.js +0 -3
- package/dist/components/tabs.d.ts +11 -7
- package/dist/components/tabs.js +13 -18
- package/dist/components/toc/clerk.d.ts +9 -2
- package/dist/components/toc/clerk.js +117 -62
- package/dist/components/toc/default.d.ts +9 -2
- package/dist/components/toc/default.js +28 -21
- package/dist/components/toc/index.d.ts +8 -5
- package/dist/components/toc/index.js +50 -25
- package/dist/components/type-table.d.ts +10 -5
- package/dist/components/type-table.js +22 -17
- package/dist/components/ui/accordion.d.ts +1 -2
- package/dist/components/ui/accordion.js +1 -5
- package/dist/components/ui/button.d.ts +2 -3
- package/dist/components/ui/button.js +0 -3
- package/dist/components/ui/collapsible.d.ts +1 -2
- package/dist/components/ui/collapsible.js +2 -6
- package/dist/components/ui/navigation-menu.d.ts +26 -12
- package/dist/components/ui/navigation-menu.js +52 -30
- package/dist/components/ui/popover.d.ts +10 -5
- package/dist/components/ui/popover.js +14 -18
- package/dist/components/ui/scroll-area.d.ts +17 -7
- package/dist/components/ui/scroll-area.js +26 -30
- package/dist/components/ui/tabs.d.ts +1 -2
- package/dist/components/ui/tabs.js +1 -5
- package/dist/contexts/i18n.d.ts +7 -5
- package/dist/contexts/i18n.js +3 -8
- package/dist/contexts/search.d.ts +2 -2
- package/dist/contexts/search.js +4 -6
- package/dist/contexts/tree.d.ts +1 -2
- package/dist/contexts/tree.js +1 -5
- package/dist/i18n.d.ts +16 -9
- package/dist/i18n.js +14 -14
- package/dist/layouts/docs/client.d.ts +30 -29
- package/dist/layouts/docs/client.js +72 -48
- package/dist/layouts/docs/index.d.ts +19 -33
- package/dist/layouts/docs/index.js +16 -172
- package/dist/layouts/docs/page/index.d.ts +67 -55
- package/dist/layouts/docs/page/index.js +74 -54
- 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 +34 -39
- package/dist/layouts/flux/index.js +77 -99
- package/dist/layouts/flux/page/index.d.ts +56 -49
- package/dist/layouts/flux/page/index.js +63 -35
- 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/{sidebar.js → slots/sidebar.js} +74 -34
- package/dist/layouts/flux/slots/tab-dropdown.d.ts +17 -0
- package/dist/layouts/flux/{tab-dropdown.js → slots/tab-dropdown.js} +13 -24
- package/dist/layouts/home/index.d.ts +24 -7
- package/dist/layouts/home/index.js +39 -19
- package/dist/layouts/home/navbar.d.ts +5 -14
- package/dist/layouts/home/navbar.js +10 -12
- 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 +57 -147
- package/dist/layouts/notebook/index.d.ts +25 -24
- package/dist/layouts/notebook/index.js +16 -212
- package/dist/layouts/notebook/page/index.d.ts +67 -55
- package/dist/layouts/notebook/page/index.js +74 -54
- 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 +136 -34
- package/dist/layouts/shared/index.js +49 -17
- 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} +11 -15
- package/dist/layouts/shared/slots/search-trigger.d.ts +23 -0
- package/dist/layouts/shared/{search-toggle.js → slots/search-trigger.js} +9 -13
- package/dist/layouts/shared/slots/theme-switch.d.ts +14 -0
- package/dist/layouts/shared/{theme-toggle.js → slots/theme-switch.js} +5 -9
- package/dist/mdx.d.ts +13 -3
- package/dist/mdx.js +0 -4
- package/dist/mdx.server.d.ts +1 -2
- 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 +1 -2
- package/dist/og.js +6 -6
- package/dist/page.d.ts +3 -4
- package/dist/page.js +6 -11
- package/dist/provider/base.d.ts +1 -2
- package/dist/provider/base.js +2 -6
- package/dist/provider/next.d.ts +1 -2
- package/dist/provider/next.js +1 -5
- package/dist/provider/react-router.d.ts +1 -2
- package/dist/provider/react-router.js +1 -5
- package/dist/provider/tanstack.d.ts +1 -2
- package/dist/provider/tanstack.js +1 -5
- package/dist/provider/waku.d.ts +1 -2
- package/dist/provider/waku.js +1 -5
- package/dist/style.css +433 -166
- package/dist/tailwind/typography.d.ts +2 -0
- package/dist/tailwind/typography.js +2 -0
- package/dist/utils/cn.js +1 -2
- package/dist/utils/merge-refs.js +0 -2
- package/dist/utils/urls.js +1 -3
- package/dist/utils/use-copy-button.d.ts +1 -2
- package/dist/utils/use-copy-button.js +1 -5
- package/dist/utils/use-footer-items.d.ts +1 -2
- package/dist/utils/use-footer-items.js +4 -8
- package/dist/utils/use-is-scroll-top.d.ts +1 -2
- package/dist/utils/use-is-scroll-top.js +1 -5
- package/package.json +139 -103
- package/LICENSE +0 -21
- 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.core.d.ts.map +0 -1
- package/dist/components/dynamic-codeblock.core.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-DGvp66QF.css +0 -80
- package/dist/components/image-zoom-DGvp66QF.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.d.ts.map +0 -1
- package/dist/components/toc/clerk.js.map +0 -1
- package/dist/components/toc/default.d.ts.map +0 -1
- package/dist/components/toc/default.js.map +0 -1
- package/dist/components/toc/index.d.ts.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.d.ts.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.d.ts.map +0 -1
- package/dist/contexts/tree.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.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 -48
- 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 -64
- 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/flux/index.d.ts.map +0 -1
- package/dist/layouts/flux/index.js.map +0 -1
- package/dist/layouts/flux/page/client.d.ts +0 -45
- package/dist/layouts/flux/page/client.d.ts.map +0 -1
- package/dist/layouts/flux/page/client.js +0 -255
- package/dist/layouts/flux/page/client.js.map +0 -1
- package/dist/layouts/flux/page/index.d.ts.map +0 -1
- package/dist/layouts/flux/page/index.js.map +0 -1
- package/dist/layouts/flux/sidebar.d.ts +0 -59
- package/dist/layouts/flux/sidebar.d.ts.map +0 -1
- package/dist/layouts/flux/sidebar.js.map +0 -1
- package/dist/layouts/flux/tab-dropdown.d.ts +0 -21
- package/dist/layouts/flux/tab-dropdown.d.ts.map +0 -1
- package/dist/layouts/flux/tab-dropdown.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 -267
- 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 -48
- 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 -60
- 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/og.d.ts.map +0 -1
- package/dist/og.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
- package/dist/utils/link-item.d.ts +0 -86
- package/dist/utils/link-item.d.ts.map +0 -1
- package/dist/utils/link-item.js +0 -25
- package/dist/utils/link-item.js.map +0 -1
- package/dist/utils/merge-refs.js.map +0 -1
- package/dist/utils/urls.js.map +0 -1
- package/dist/utils/use-copy-button.d.ts.map +0 -1
- package/dist/utils/use-copy-button.js.map +0 -1
- package/dist/utils/use-footer-items.d.ts.map +0 -1
- package/dist/utils/use-footer-items.js.map +0 -1
- package/dist/utils/use-is-scroll-top.d.ts.map +0 -1
- package/dist/utils/use-is-scroll-top.js.map +0 -1
|
@@ -1,45 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { I18nLabel, useI18n } from "../../contexts/i18n.js";
|
|
4
3
|
import { cn } from "../../utils/cn.js";
|
|
5
4
|
import { buttonVariants } from "../ui/button.js";
|
|
6
5
|
import { Fragment, createContext, use, useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
7
6
|
import { useRouter } from "@hanzo/docs-core/framework";
|
|
8
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { ChevronRight, Hash,
|
|
8
|
+
import { ChevronRight, Hash, SearchIcon } from "lucide-react";
|
|
10
9
|
import { cva } from "class-variance-authority";
|
|
11
10
|
import { useOnChange } from "@hanzo/docs-core/utils/use-on-change";
|
|
12
11
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
13
12
|
import { Dialog } from "@base-ui/react/dialog";
|
|
14
|
-
|
|
13
|
+
import { createMarkdownRenderer } from "@hanzo/docs-core/content/md";
|
|
14
|
+
import rehypeRaw from "rehype-raw";
|
|
15
|
+
import { visit } from "unist-util-visit";
|
|
15
16
|
//#region src/components/dialog/search.tsx
|
|
16
|
-
const
|
|
17
|
+
const RootContext = createContext(null);
|
|
17
18
|
const ListContext = createContext(null);
|
|
18
19
|
const TagsListContext = createContext(null);
|
|
20
|
+
const PreContext = createContext(false);
|
|
21
|
+
const mdRenderer = createMarkdownRenderer({
|
|
22
|
+
remarkRehypeOptions: { allowDangerousHtml: true },
|
|
23
|
+
rehypePlugins: [rehypeRaw, rehypeCustomElements]
|
|
24
|
+
});
|
|
25
|
+
const mdComponents = {
|
|
26
|
+
mark(props) {
|
|
27
|
+
return /* @__PURE__ */ jsx("span", {
|
|
28
|
+
...props,
|
|
29
|
+
className: "text-fd-primary underline"
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
a: "span",
|
|
33
|
+
p(props) {
|
|
34
|
+
return /* @__PURE__ */ jsx("p", {
|
|
35
|
+
...props,
|
|
36
|
+
className: "min-w-0"
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
strong(props) {
|
|
40
|
+
return /* @__PURE__ */ jsx("strong", {
|
|
41
|
+
...props,
|
|
42
|
+
className: "text-fd-accent-foreground font-medium"
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
code(props) {
|
|
46
|
+
if (use(PreContext)) return /* @__PURE__ */ jsx("code", {
|
|
47
|
+
...props,
|
|
48
|
+
className: "mask-[linear-gradient(to_bottom,white,white_30px,transparent_80px)]"
|
|
49
|
+
});
|
|
50
|
+
return /* @__PURE__ */ jsx("code", {
|
|
51
|
+
...props,
|
|
52
|
+
className: "border rounded-md px-px bg-fd-secondary text-fd-secondary-foreground"
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
custom({ _tagName = "fragment", children, ...rest }) {
|
|
56
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
57
|
+
className: "inline-flex max-w-full items-center border p-0.5 rounded-md bg-fd-card text-fd-card-foreground divide-x divide-fd-border",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("code", {
|
|
60
|
+
className: "rounded-sm px-0.5 me-1 bg-fd-primary font-medium text-xs text-fd-primary-foreground border-none",
|
|
61
|
+
children: _tagName
|
|
62
|
+
}),
|
|
63
|
+
Object.entries(rest).map(([k, v]) => {
|
|
64
|
+
if (typeof v !== "string") return;
|
|
65
|
+
return /* @__PURE__ */ jsxs("code", {
|
|
66
|
+
className: "truncate text-xs text-fd-muted-foreground px-1",
|
|
67
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
68
|
+
className: "text-fd-card-foreground",
|
|
69
|
+
children: [k, ": "]
|
|
70
|
+
}), v]
|
|
71
|
+
}, k);
|
|
72
|
+
}),
|
|
73
|
+
children && /* @__PURE__ */ jsx("span", {
|
|
74
|
+
className: "ps-1",
|
|
75
|
+
children
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
pre(props) {
|
|
81
|
+
return /* @__PURE__ */ jsx("pre", {
|
|
82
|
+
...props,
|
|
83
|
+
className: cn("flex flex-col border rounded-md my-0.5 p-2 bg-fd-secondary text-fd-secondary-foreground max-h-20 overflow-hidden", props.className),
|
|
84
|
+
children: /* @__PURE__ */ jsx(PreContext, {
|
|
85
|
+
value: true,
|
|
86
|
+
children: props.children
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
function rehypeCustomElements() {
|
|
92
|
+
return (tree) => {
|
|
93
|
+
visit(tree, (node) => {
|
|
94
|
+
if (node.type === "element" && document.createElement(node.tagName) instanceof HTMLUnknownElement) {
|
|
95
|
+
node.properties._tagName = node.tagName;
|
|
96
|
+
node.tagName = "custom";
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
19
101
|
function SearchDialog({ open, onOpenChange, search, onSearchChange, isLoading = false, onSelect: onSelectProp, children }) {
|
|
20
102
|
const router = useRouter();
|
|
21
|
-
const
|
|
103
|
+
const onOpenChangeCallback = useRef(onOpenChange);
|
|
104
|
+
onOpenChangeCallback.current = onOpenChange;
|
|
105
|
+
const onSearchChangeCallback = useRef(onSearchChange);
|
|
106
|
+
onSearchChangeCallback.current = onSearchChange;
|
|
107
|
+
const onSelect = (item) => {
|
|
22
108
|
if (item.type === "action") item.onSelect();
|
|
23
109
|
else if (item.external) window.open(item.url, "_blank")?.focus();
|
|
24
110
|
else router.push(item.url);
|
|
25
111
|
onOpenChange(false);
|
|
26
112
|
onSelectProp?.(item);
|
|
27
|
-
}
|
|
113
|
+
};
|
|
114
|
+
const onSelectCallback = useRef(onSelect);
|
|
115
|
+
onSelectCallback.current = onSelect;
|
|
28
116
|
return /* @__PURE__ */ jsx(Dialog.Root, {
|
|
29
117
|
open,
|
|
30
118
|
onOpenChange,
|
|
31
|
-
children: /* @__PURE__ */ jsx(
|
|
119
|
+
children: /* @__PURE__ */ jsx(RootContext, {
|
|
32
120
|
value: useMemo(() => ({
|
|
33
121
|
open,
|
|
34
|
-
onOpenChange,
|
|
35
122
|
search,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
123
|
+
isLoading,
|
|
124
|
+
onOpenChange: (v) => onOpenChangeCallback.current(v),
|
|
125
|
+
onSearchChange: (v) => onSearchChangeCallback.current(v),
|
|
126
|
+
onSelect: (v) => onSelectCallback.current(v)
|
|
39
127
|
}), [
|
|
40
128
|
isLoading,
|
|
41
|
-
onOpenChange,
|
|
42
|
-
onSearchChange,
|
|
43
129
|
open,
|
|
44
130
|
search
|
|
45
131
|
]),
|
|
@@ -87,15 +173,16 @@ function SearchDialogFooter(props) {
|
|
|
87
173
|
function SearchDialogOverlay({ className, ...props }) {
|
|
88
174
|
return /* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
89
175
|
...props,
|
|
90
|
-
className: (s) => cn("fixed inset-0 z-50 backdrop-blur-xs bg-fd-overlay data-
|
|
176
|
+
className: (s) => cn("fixed inset-0 z-50 backdrop-blur-xs bg-fd-overlay data-open:animate-fd-fade-in data-closed:animate-fd-fade-out", typeof className === "function" ? className(s) : className)
|
|
91
177
|
});
|
|
92
178
|
}
|
|
93
179
|
function SearchDialogContent({ children, className, ...props }) {
|
|
94
180
|
const { text } = useI18n();
|
|
95
181
|
return /* @__PURE__ */ jsx(Dialog.Portal, { children: /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
182
|
+
id: "fd-search-dialog-content",
|
|
96
183
|
"aria-describedby": void 0,
|
|
97
184
|
...props,
|
|
98
|
-
className: (s) => cn("fixed left-1/2 top-4 md:top-[calc(50%-250px)] z-50 w-[calc(100%-1rem)] max-w-screen-sm -translate-x-1/2 rounded-xl border bg-fd-popover text-fd-popover-foreground shadow-2xl
|
|
185
|
+
className: (s) => cn("fixed left-1/2 top-4 md:top-[calc(50%-250px)] z-50 w-[calc(100%-1rem)] max-w-screen-sm -translate-x-1/2 rounded-xl border bg-fd-popover text-fd-popover-foreground shadow-2xl overflow-hidden data-closed:animate-fd-dialog-out data-open:animate-fd-dialog-in focus-visible:outline-none", "*:border-b *:has-[+:last-child[data-empty=true]]:border-b-0 *:data-[empty=true]:border-b-0 *:last:border-b-0", typeof className === "function" ? className(s) : className),
|
|
99
186
|
children: [/* @__PURE__ */ jsx(Dialog.Title, {
|
|
100
187
|
className: "hidden",
|
|
101
188
|
children: text.search
|
|
@@ -134,10 +221,11 @@ function SearchDialogList({ items = null, Empty = () => /* @__PURE__ */ jsx("div
|
|
|
134
221
|
});
|
|
135
222
|
const viewport = element.firstElementChild;
|
|
136
223
|
if (viewport) observer.observe(viewport);
|
|
137
|
-
|
|
224
|
+
const content = document.getElementById("fd-search-dialog-content") ?? window;
|
|
225
|
+
content.addEventListener("keydown", onKey);
|
|
138
226
|
return () => {
|
|
139
227
|
observer.disconnect();
|
|
140
|
-
|
|
228
|
+
content.removeEventListener("keydown", onKey);
|
|
141
229
|
};
|
|
142
230
|
}, []);
|
|
143
231
|
useOnChange(items, () => {
|
|
@@ -150,7 +238,7 @@ function SearchDialogList({ items = null, Empty = () => /* @__PURE__ */ jsx("div
|
|
|
150
238
|
className: cn("overflow-hidden h-(--fd-animated-height) transition-[height]", props.className),
|
|
151
239
|
children: /* @__PURE__ */ jsx("div", {
|
|
152
240
|
className: cn("w-full flex flex-col overflow-y-auto max-h-[460px] p-1", !items && "hidden"),
|
|
153
|
-
children: /* @__PURE__ */ jsxs(ListContext
|
|
241
|
+
children: /* @__PURE__ */ jsxs(ListContext, {
|
|
154
242
|
value: useMemo(() => ({
|
|
155
243
|
active,
|
|
156
244
|
setActive
|
|
@@ -163,7 +251,10 @@ function SearchDialogList({ items = null, Empty = () => /* @__PURE__ */ jsx("div
|
|
|
163
251
|
})
|
|
164
252
|
});
|
|
165
253
|
}
|
|
166
|
-
function SearchDialogListItem({ item, className, children,
|
|
254
|
+
function SearchDialogListItem({ item, className, children, renderMarkdown = (s) => /* @__PURE__ */ jsx(mdRenderer.Markdown, {
|
|
255
|
+
components: mdComponents,
|
|
256
|
+
children: s
|
|
257
|
+
}), renderHighlights: _, ...props }) {
|
|
167
258
|
const { active: activeId, setActive } = useSearchList();
|
|
168
259
|
const active = item.id === activeId;
|
|
169
260
|
if (item.type === "action") children ??= item.node;
|
|
@@ -176,9 +267,10 @@ function SearchDialogListItem({ item, className, children, renderHighlights: ren
|
|
|
176
267
|
role: "none",
|
|
177
268
|
className: "absolute start-3 inset-y-0 w-px bg-fd-border"
|
|
178
269
|
}),
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
|
|
181
|
-
|
|
270
|
+
item.type === "heading" && /* @__PURE__ */ jsx(Hash, { className: "absolute start-6 top-2.5 size-4 text-fd-muted-foreground" }),
|
|
271
|
+
/* @__PURE__ */ jsx("div", {
|
|
272
|
+
className: cn("min-w-0", item.type === "text" && "ps-4", item.type === "heading" && "ps-8", item.type === "page" || item.type === "heading" ? "font-medium" : "text-fd-popover-foreground/80"),
|
|
273
|
+
children: typeof item.content === "string" ? renderMarkdown(item.content) : item.content
|
|
182
274
|
})
|
|
183
275
|
] });
|
|
184
276
|
return /* @__PURE__ */ jsx("button", {
|
|
@@ -191,7 +283,7 @@ function SearchDialogListItem({ item, className, children, renderHighlights: ren
|
|
|
191
283
|
});
|
|
192
284
|
}, [active]),
|
|
193
285
|
"aria-selected": active,
|
|
194
|
-
className: cn("relative select-none px-2.5 py-2 text-start text-sm rounded-lg", active && "bg-fd-accent text-fd-accent-foreground", className),
|
|
286
|
+
className: cn("relative select-none shrink-0 px-2.5 py-2 text-start text-sm overflow-hidden rounded-lg", active && "bg-fd-accent text-fd-accent-foreground", className),
|
|
195
287
|
onPointerMove: () => setActive(item.id),
|
|
196
288
|
...props,
|
|
197
289
|
children
|
|
@@ -199,26 +291,24 @@ function SearchDialogListItem({ item, className, children, renderHighlights: ren
|
|
|
199
291
|
}
|
|
200
292
|
function SearchDialogIcon(props) {
|
|
201
293
|
const { isLoading } = useSearch();
|
|
202
|
-
return /* @__PURE__ */ jsx(
|
|
294
|
+
return /* @__PURE__ */ jsx(SearchIcon, {
|
|
203
295
|
...props,
|
|
204
296
|
className: cn("size-5 text-fd-muted-foreground", isLoading && "animate-pulse duration-400", props.className)
|
|
205
297
|
});
|
|
206
298
|
}
|
|
207
299
|
const itemVariants = cva("rounded-md border px-2 py-0.5 text-xs font-medium text-fd-muted-foreground transition-colors", { variants: { active: { true: "bg-fd-accent text-fd-accent-foreground" } } });
|
|
208
300
|
function TagsList({ tag, onTagChange, allowClear = false, ...props }) {
|
|
301
|
+
const onTagChangeCallback = useRef(onTagChange);
|
|
302
|
+
onTagChangeCallback.current = onTagChange;
|
|
209
303
|
return /* @__PURE__ */ jsx("div", {
|
|
210
304
|
...props,
|
|
211
305
|
className: cn("flex items-center gap-1 flex-wrap", props.className),
|
|
212
|
-
children: /* @__PURE__ */ jsx(TagsListContext
|
|
306
|
+
children: /* @__PURE__ */ jsx(TagsListContext, {
|
|
213
307
|
value: useMemo(() => ({
|
|
214
308
|
value: tag,
|
|
215
|
-
onValueChange:
|
|
309
|
+
onValueChange: (v) => onTagChangeCallback.current(v),
|
|
216
310
|
allowClear
|
|
217
|
-
}), [
|
|
218
|
-
allowClear,
|
|
219
|
-
onTagChange,
|
|
220
|
-
tag
|
|
221
|
-
]),
|
|
311
|
+
}), [allowClear, tag]),
|
|
222
312
|
children: props.children
|
|
223
313
|
})
|
|
224
314
|
});
|
|
@@ -233,25 +323,14 @@ function TagsListItem({ value, className, ...props }) {
|
|
|
233
323
|
active: selected,
|
|
234
324
|
className
|
|
235
325
|
})),
|
|
236
|
-
onClick: () =>
|
|
237
|
-
onValueChange(selected && allowClear ? void 0 : value);
|
|
238
|
-
},
|
|
326
|
+
onClick: () => onValueChange(selected && allowClear ? void 0 : value),
|
|
239
327
|
tabIndex: -1,
|
|
240
328
|
...props,
|
|
241
329
|
children: props.children
|
|
242
330
|
});
|
|
243
331
|
}
|
|
244
|
-
function renderHighlights(highlights) {
|
|
245
|
-
return highlights.map((node, i) => {
|
|
246
|
-
if (node.styles?.highlight) return /* @__PURE__ */ jsx("span", {
|
|
247
|
-
className: "text-fd-primary underline",
|
|
248
|
-
children: node.content
|
|
249
|
-
}, i);
|
|
250
|
-
return /* @__PURE__ */ jsx(Fragment, { children: node.content }, i);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
332
|
function useSearch() {
|
|
254
|
-
const ctx = use(
|
|
333
|
+
const ctx = use(RootContext);
|
|
255
334
|
if (!ctx) throw new Error("Missing <SearchDialog />");
|
|
256
335
|
return ctx;
|
|
257
336
|
}
|
|
@@ -265,7 +344,5 @@ function useSearchList() {
|
|
|
265
344
|
if (!ctx) throw new Error("Missing <SearchDialogList />");
|
|
266
345
|
return ctx;
|
|
267
346
|
}
|
|
268
|
-
|
|
269
347
|
//#endregion
|
|
270
348
|
export { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, TagsList, TagsListItem, useSearch, useSearchList, useTagsList };
|
|
271
|
-
//# sourceMappingURL=search.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CodeBlockProps } from "./codeblock.js";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
-
import { UseShikiOptions } from "@hanzo/docs-core/highlight/
|
|
3
|
+
import { UseShikiOptions } from "@hanzo/docs-core/highlight/shiki/react";
|
|
4
|
+
import { HighlighterCore } from "shiki";
|
|
4
5
|
|
|
5
6
|
//#region src/components/dynamic-codeblock.core.d.ts
|
|
6
7
|
interface DynamicCodeblockProps {
|
|
8
|
+
highlighter: HighlighterCore | (() => HighlighterCore | PromiseLike<HighlighterCore>);
|
|
7
9
|
lang: string;
|
|
8
10
|
code: string;
|
|
9
11
|
/**
|
|
@@ -18,7 +20,7 @@ interface DynamicCodeblockProps {
|
|
|
18
20
|
* @defaultValue true
|
|
19
21
|
*/
|
|
20
22
|
wrapInSuspense?: boolean;
|
|
21
|
-
options
|
|
23
|
+
options: DistributiveOmit<UseShikiOptions, 'lang'>;
|
|
22
24
|
}
|
|
23
25
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
24
26
|
declare function DynamicCodeBlock({
|
|
@@ -26,8 +28,8 @@ declare function DynamicCodeBlock({
|
|
|
26
28
|
code,
|
|
27
29
|
codeblock,
|
|
28
30
|
options,
|
|
29
|
-
wrapInSuspense
|
|
31
|
+
wrapInSuspense,
|
|
32
|
+
highlighter
|
|
30
33
|
}: DynamicCodeblockProps): react_jsx_runtime0.JSX.Element;
|
|
31
34
|
//#endregion
|
|
32
|
-
export { DynamicCodeBlock, DynamicCodeblockProps };
|
|
33
|
-
//# sourceMappingURL=dynamic-codeblock.core.d.ts.map
|
|
35
|
+
export { DynamicCodeBlock, DynamicCodeblockProps };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { cn } from "../utils/cn.js";
|
|
4
3
|
import { CodeBlock, Pre } from "./codeblock.js";
|
|
5
|
-
import {
|
|
4
|
+
import { createContext, use, useId } from "react";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import { useShikiDynamic } from "@hanzo/docs-core/highlight/shiki/react";
|
|
9
7
|
//#region src/components/dynamic-codeblock.core.tsx
|
|
10
8
|
const PropsContext = createContext(void 0);
|
|
11
9
|
function DefaultPre(props) {
|
|
@@ -17,34 +15,30 @@ function DefaultPre(props) {
|
|
|
17
15
|
children: /* @__PURE__ */ jsx(Pre, { children: props.children })
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
|
-
function DynamicCodeBlock({ lang, code, codeblock, options, wrapInSuspense = true }) {
|
|
18
|
+
function DynamicCodeBlock({ lang, code, codeblock, options, wrapInSuspense = true, highlighter }) {
|
|
21
19
|
const id = useId();
|
|
22
20
|
const shikiOptions = {
|
|
23
21
|
lang,
|
|
22
|
+
defaultColor: false,
|
|
24
23
|
...options,
|
|
25
24
|
components: {
|
|
26
25
|
pre: DefaultPre,
|
|
27
|
-
...options
|
|
26
|
+
...options.components
|
|
28
27
|
}
|
|
29
28
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
29
|
+
let node = useShikiDynamic(highlighter, code, shikiOptions, [
|
|
30
|
+
id,
|
|
31
|
+
lang,
|
|
32
|
+
code
|
|
33
|
+
]);
|
|
34
|
+
if (wrapInSuspense) node ??= /* @__PURE__ */ jsx(Placeholder, {
|
|
35
|
+
code,
|
|
36
|
+
components: shikiOptions.components
|
|
39
37
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
components: shikiOptions.components
|
|
44
|
-
}),
|
|
45
|
-
children
|
|
38
|
+
return /* @__PURE__ */ jsx(PropsContext, {
|
|
39
|
+
value: codeblock,
|
|
40
|
+
children: node
|
|
46
41
|
});
|
|
47
|
-
return children;
|
|
48
42
|
}
|
|
49
43
|
function Placeholder({ code, components = {} }) {
|
|
50
44
|
const { pre: Pre = "pre", code: Code = "code" } = components;
|
|
@@ -53,14 +47,5 @@ function Placeholder({ code, components = {} }) {
|
|
|
53
47
|
children: line
|
|
54
48
|
}, i)) }) });
|
|
55
49
|
}
|
|
56
|
-
function Internal({ id, code, options }) {
|
|
57
|
-
return useShiki(code, options, [
|
|
58
|
-
id,
|
|
59
|
-
options.lang,
|
|
60
|
-
code
|
|
61
|
-
]);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
50
|
//#endregion
|
|
65
51
|
export { DynamicCodeBlock };
|
|
66
|
-
//# sourceMappingURL=dynamic-codeblock.core.js.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { DynamicCodeblockProps } from "./dynamic-codeblock.core.js";
|
|
1
|
+
import { DynamicCodeblockProps as DynamicCodeblockProps$1 } from "./dynamic-codeblock.core.js";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/dynamic-codeblock.d.ts
|
|
5
|
+
type DynamicCodeblockProps = Omit<DynamicCodeblockProps$1, 'highlighter' | 'options'> & {
|
|
6
|
+
options?: DynamicCodeblockProps$1['options'];
|
|
7
|
+
};
|
|
5
8
|
declare function DynamicCodeBlock(props: DynamicCodeblockProps): react_jsx_runtime0.JSX.Element;
|
|
6
9
|
//#endregion
|
|
7
|
-
export { DynamicCodeBlock,
|
|
8
|
-
//# sourceMappingURL=dynamic-codeblock.d.ts.map
|
|
10
|
+
export { DynamicCodeBlock, DynamicCodeblockProps };
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { DynamicCodeBlock as DynamicCodeBlock$1 } from "./dynamic-codeblock.core.js";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import { configDefault } from "@hanzo/docs-core/highlight";
|
|
7
|
-
|
|
4
|
+
import { defaultShikiFactory } from "@hanzo/docs-core/highlight/shiki/full";
|
|
8
5
|
//#region src/components/dynamic-codeblock.tsx
|
|
9
6
|
function DynamicCodeBlock(props) {
|
|
10
|
-
const config = useShikiConfigOptional() ?? configDefault;
|
|
11
7
|
return /* @__PURE__ */ jsx(DynamicCodeBlock$1, {
|
|
12
|
-
|
|
13
|
-
options: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
8
|
+
highlighter: () => defaultShikiFactory.getOrInit(),
|
|
9
|
+
options: { themes: {
|
|
10
|
+
light: "github-light",
|
|
11
|
+
dark: "github-dark"
|
|
12
|
+
} },
|
|
13
|
+
...props
|
|
17
14
|
});
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
//#endregion
|
|
21
17
|
export { DynamicCodeBlock };
|
|
22
|
-
//# sourceMappingURL=dynamic-codeblock.js.map
|
package/dist/components/files.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { cn } from "../utils/cn.js";
|
|
4
3
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible.js";
|
|
5
4
|
import { useState } from "react";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
6
|
+
import { FileIcon, FolderIcon, FolderOpen } from "lucide-react";
|
|
8
7
|
import { cva } from "class-variance-authority";
|
|
9
|
-
|
|
10
8
|
//#region src/components/files.tsx
|
|
11
9
|
const itemVariants = cva("flex flex-row items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-fd-accent hover:text-fd-accent-foreground [&_svg]:size-4");
|
|
12
10
|
function Files({ className, ...props }) {
|
|
@@ -16,7 +14,7 @@ function Files({ className, ...props }) {
|
|
|
16
14
|
children: props.children
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
|
-
function File({ name, icon = /* @__PURE__ */ jsx(
|
|
17
|
+
function File({ name, icon = /* @__PURE__ */ jsx(FileIcon, {}), className, ...rest }) {
|
|
20
18
|
return /* @__PURE__ */ jsxs("div", {
|
|
21
19
|
className: cn(itemVariants({ className })),
|
|
22
20
|
...rest,
|
|
@@ -31,14 +29,12 @@ function Folder({ name, defaultOpen = false, ...props }) {
|
|
|
31
29
|
...props,
|
|
32
30
|
children: [/* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
33
31
|
className: cn(itemVariants({ className: "w-full" })),
|
|
34
|
-
children: [open ? /* @__PURE__ */ jsx(FolderOpen, {}) : /* @__PURE__ */ jsx(
|
|
32
|
+
children: [open ? /* @__PURE__ */ jsx(FolderOpen, {}) : /* @__PURE__ */ jsx(FolderIcon, {}), name]
|
|
35
33
|
}), /* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx("div", {
|
|
36
34
|
className: "ms-2 flex flex-col border-l ps-2",
|
|
37
35
|
children: props.children
|
|
38
36
|
}) })]
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
//#endregion
|
|
43
40
|
export { File, Files, Folder };
|
|
44
|
-
//# sourceMappingURL=files.js.map
|
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/github-info.d.ts
|
|
5
|
+
interface FetchRepositoryInfoOptions {
|
|
6
|
+
owner: string;
|
|
7
|
+
repo: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
token?: string;
|
|
10
|
+
fetchOptions?: RequestInit;
|
|
11
|
+
}
|
|
12
|
+
interface RepositoryInfo {
|
|
13
|
+
stars: number;
|
|
14
|
+
forks: number;
|
|
15
|
+
}
|
|
16
|
+
declare function fetchRepositoryInfo({
|
|
17
|
+
owner,
|
|
18
|
+
repo,
|
|
19
|
+
token,
|
|
20
|
+
baseUrl,
|
|
21
|
+
fetchOptions
|
|
22
|
+
}: FetchRepositoryInfoOptions): Promise<RepositoryInfo>;
|
|
5
23
|
declare function GithubInfo({
|
|
6
24
|
repo,
|
|
7
25
|
owner,
|
|
8
26
|
token,
|
|
9
27
|
baseUrl,
|
|
28
|
+
fetchOptions,
|
|
10
29
|
...props
|
|
11
|
-
}:
|
|
12
|
-
owner: string;
|
|
13
|
-
repo: string;
|
|
14
|
-
token?: string;
|
|
15
|
-
baseUrl?: string;
|
|
16
|
-
}): Promise<react_jsx_runtime0.JSX.Element>;
|
|
30
|
+
}: ComponentProps<'a'> & FetchRepositoryInfoOptions): react_jsx_runtime0.JSX.Element;
|
|
17
31
|
//#endregion
|
|
18
|
-
export { GithubInfo };
|
|
19
|
-
//# sourceMappingURL=github-info.d.ts.map
|
|
32
|
+
export { FetchRepositoryInfoOptions, GithubInfo, RepositoryInfo, fetchRepositoryInfo };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { cn } from "../utils/cn.js";
|
|
2
|
+
import { use } from "react";
|
|
2
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Star } from "lucide-react";
|
|
4
|
-
|
|
4
|
+
import { GitFork, Star } from "lucide-react";
|
|
5
5
|
//#region src/components/github-info.tsx
|
|
6
|
-
async function
|
|
6
|
+
async function fetchRepositoryInfo({ owner, repo, token, baseUrl = "https://api.github.com", fetchOptions = { next: { revalidate: 60 } } }) {
|
|
7
7
|
const endpoint = `${baseUrl}/repos/${owner}/${repo}`;
|
|
8
|
-
const headers = new Headers(
|
|
8
|
+
const headers = new Headers(fetchOptions.headers);
|
|
9
|
+
headers.set("Content-Type", "application/json");
|
|
9
10
|
if (token) headers.set("Authorization", `Bearer ${token}`);
|
|
10
11
|
const response = await fetch(endpoint, {
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
...fetchOptions,
|
|
13
|
+
headers
|
|
13
14
|
});
|
|
14
15
|
if (!response.ok) {
|
|
15
16
|
const message = await response.text();
|
|
@@ -21,15 +22,29 @@ async function getRepoStarsAndForks(owner, repo, token, baseUrl = "https://api.g
|
|
|
21
22
|
forks: data.forks_count
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Uses compact notation (e.g., 1.5K, 2.3M).
|
|
27
|
+
*/
|
|
28
|
+
const defaultFormatter = new Intl.NumberFormat("en", {
|
|
29
|
+
notation: "compact",
|
|
30
|
+
maximumFractionDigits: 1
|
|
31
|
+
});
|
|
32
|
+
const promises = {};
|
|
33
|
+
function GithubInfo({ repo, owner, token, baseUrl, fetchOptions, ...props }) {
|
|
34
|
+
const options = {
|
|
35
|
+
repo,
|
|
36
|
+
owner,
|
|
37
|
+
token,
|
|
38
|
+
baseUrl,
|
|
39
|
+
fetchOptions
|
|
40
|
+
};
|
|
41
|
+
const { stars, forks } = use(promises[JSON.stringify(options)] ??= fetchRepositoryInfo(options));
|
|
27
42
|
return /* @__PURE__ */ jsxs("a", {
|
|
28
43
|
href: `https://github.com/${owner}/${repo}`,
|
|
29
44
|
rel: "noreferrer noopener",
|
|
30
45
|
target: "_blank",
|
|
31
46
|
...props,
|
|
32
|
-
className: cn("flex flex-col gap-1.5 p-2 rounded-lg text-sm text-fd-foreground/80 transition-colors
|
|
47
|
+
className: cn("flex flex-col gap-1.5 p-2 rounded-lg text-sm text-fd-foreground/80 transition-colors hover:text-fd-accent-foreground hover:bg-fd-accent", props.className),
|
|
33
48
|
children: [/* @__PURE__ */ jsxs("p", {
|
|
34
49
|
className: "flex items-center gap-2 truncate",
|
|
35
50
|
children: [
|
|
@@ -43,26 +58,16 @@ async function GithubInfo({ repo, owner, token, baseUrl, ...props }) {
|
|
|
43
58
|
"/",
|
|
44
59
|
repo
|
|
45
60
|
]
|
|
46
|
-
}), /* @__PURE__ */ jsxs("
|
|
61
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
47
62
|
className: "flex text-xs items-center gap-1 text-fd-muted-foreground",
|
|
48
|
-
children: [
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsx(Star, { className: "size-3" }),
|
|
65
|
+
/* @__PURE__ */ jsx("span", { children: defaultFormatter.format(stars) }),
|
|
66
|
+
/* @__PURE__ */ jsx(GitFork, { className: "size-3 ms-2" }),
|
|
67
|
+
/* @__PURE__ */ jsx("span", { children: defaultFormatter.format(forks) })
|
|
68
|
+
]
|
|
49
69
|
})]
|
|
50
70
|
});
|
|
51
71
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Converts a number to a human-readable string with K suffix for thousands
|
|
54
|
-
* @example 1500 -> "1.5K", 1000000 -> "1000000"
|
|
55
|
-
*/
|
|
56
|
-
function humanizeNumber(num) {
|
|
57
|
-
if (num < 1e3) return num.toString();
|
|
58
|
-
if (num < 1e5) {
|
|
59
|
-
const value = (num / 1e3).toFixed(1);
|
|
60
|
-
return `${value.endsWith(".0") ? value.slice(0, -2) : value}K`;
|
|
61
|
-
}
|
|
62
|
-
if (num < 1e6) return `${Math.floor(num / 1e3)}K`;
|
|
63
|
-
return num.toString();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
72
|
//#endregion
|
|
67
|
-
export { GithubInfo };
|
|
68
|
-
//# sourceMappingURL=github-info.js.map
|
|
73
|
+
export { GithubInfo, fetchRepositoryInfo };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cn } from "../utils/cn.js";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { LinkIcon } from "lucide-react";
|
|
5
4
|
//#region src/components/heading.tsx
|
|
6
5
|
function Heading({ as, className, ...props }) {
|
|
7
6
|
const As = as ?? "h1";
|
|
@@ -17,13 +16,11 @@ function Heading({ as, className, ...props }) {
|
|
|
17
16
|
href: `#${props.id}`,
|
|
18
17
|
className: "peer",
|
|
19
18
|
children: props.children
|
|
20
|
-
}), /* @__PURE__ */ jsx(
|
|
19
|
+
}), /* @__PURE__ */ jsx(LinkIcon, {
|
|
21
20
|
"aria-hidden": true,
|
|
22
21
|
className: "size-3.5 shrink-0 text-fd-muted-foreground opacity-0 transition-opacity peer-hover:opacity-100"
|
|
23
22
|
})]
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
//#endregion
|
|
28
26
|
export { Heading };
|
|
29
|
-
//# sourceMappingURL=heading.js.map
|