@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,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as react_jsx_runtime117 from "react/jsx-runtime";
|
|
1
|
+
import { SharedProps } from "../../contexts/search.js";
|
|
3
2
|
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { Dialog } from "@base-ui/react/dialog";
|
|
5
5
|
import { HighlightedText, ReactSortedResult } from "@hanzo/docs-core/search";
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ type SearchItemType = (ReactSortedResult & {
|
|
|
13
13
|
node: ReactNode;
|
|
14
14
|
onSelect: () => void;
|
|
15
15
|
};
|
|
16
|
-
interface SearchDialogProps extends
|
|
16
|
+
interface SearchDialogProps extends SharedProps {
|
|
17
17
|
search: string;
|
|
18
18
|
onSearchChange: (v: string) => void;
|
|
19
19
|
onSelect?: (item: SearchItemType) => void;
|
|
@@ -28,24 +28,24 @@ declare function SearchDialog({
|
|
|
28
28
|
isLoading,
|
|
29
29
|
onSelect: onSelectProp,
|
|
30
30
|
children
|
|
31
|
-
}: SearchDialogProps):
|
|
32
|
-
declare function SearchDialogHeader(props: ComponentProps<'div'>):
|
|
33
|
-
declare function SearchDialogInput(props: ComponentProps<'input'>):
|
|
31
|
+
}: SearchDialogProps): react_jsx_runtime0.JSX.Element;
|
|
32
|
+
declare function SearchDialogHeader(props: ComponentProps<'div'>): react_jsx_runtime0.JSX.Element;
|
|
33
|
+
declare function SearchDialogInput(props: ComponentProps<'input'>): react_jsx_runtime0.JSX.Element;
|
|
34
34
|
declare function SearchDialogClose({
|
|
35
35
|
children,
|
|
36
36
|
className,
|
|
37
37
|
...props
|
|
38
|
-
}: ComponentProps<'button'>):
|
|
39
|
-
declare function SearchDialogFooter(props: ComponentProps<'div'>):
|
|
38
|
+
}: ComponentProps<'button'>): react_jsx_runtime0.JSX.Element;
|
|
39
|
+
declare function SearchDialogFooter(props: ComponentProps<'div'>): react_jsx_runtime0.JSX.Element;
|
|
40
40
|
declare function SearchDialogOverlay({
|
|
41
41
|
className,
|
|
42
42
|
...props
|
|
43
|
-
}: ComponentProps<typeof Dialog.Backdrop>):
|
|
43
|
+
}: ComponentProps<typeof Dialog.Backdrop>): react_jsx_runtime0.JSX.Element;
|
|
44
44
|
declare function SearchDialogContent({
|
|
45
45
|
children,
|
|
46
46
|
className,
|
|
47
47
|
...props
|
|
48
|
-
}: ComponentProps<typeof Dialog.Popup>):
|
|
48
|
+
}: ComponentProps<typeof Dialog.Popup>): react_jsx_runtime0.JSX.Element;
|
|
49
49
|
declare function SearchDialogList({
|
|
50
50
|
items,
|
|
51
51
|
Empty,
|
|
@@ -64,18 +64,20 @@ declare function SearchDialogList({
|
|
|
64
64
|
item: SearchItemType;
|
|
65
65
|
onClick: () => void;
|
|
66
66
|
}) => ReactNode;
|
|
67
|
-
}):
|
|
67
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
68
68
|
declare function SearchDialogListItem({
|
|
69
69
|
item,
|
|
70
70
|
className,
|
|
71
71
|
children,
|
|
72
|
-
|
|
72
|
+
renderMarkdown,
|
|
73
|
+
renderHighlights: _,
|
|
73
74
|
...props
|
|
74
75
|
}: ComponentProps<'button'> & {
|
|
75
|
-
|
|
76
|
+
renderMarkdown?: (v: string) => ReactNode; /** @deprecated highlight blocks is now wrapped in `<mark />`, use `renderMarkdown` to handle instead. */
|
|
77
|
+
renderHighlights?: (blocks: HighlightedText<ReactNode>[]) => ReactNode;
|
|
76
78
|
item: SearchItemType;
|
|
77
|
-
}):
|
|
78
|
-
declare function SearchDialogIcon(props: ComponentProps<'svg'>):
|
|
79
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
80
|
+
declare function SearchDialogIcon(props: ComponentProps<'svg'>): react_jsx_runtime0.JSX.Element;
|
|
79
81
|
interface TagsListProps extends ComponentProps<'div'> {
|
|
80
82
|
tag?: string;
|
|
81
83
|
onTagChange: (tag: string | undefined) => void;
|
|
@@ -86,15 +88,14 @@ declare function TagsList({
|
|
|
86
88
|
onTagChange,
|
|
87
89
|
allowClear,
|
|
88
90
|
...props
|
|
89
|
-
}: TagsListProps):
|
|
91
|
+
}: TagsListProps): react_jsx_runtime0.JSX.Element;
|
|
90
92
|
declare function TagsListItem({
|
|
91
93
|
value,
|
|
92
94
|
className,
|
|
93
95
|
...props
|
|
94
96
|
}: ComponentProps<'button'> & {
|
|
95
97
|
value: string;
|
|
96
|
-
}):
|
|
97
|
-
declare function renderHighlights(highlights: HighlightedText<ReactNode>[]): ReactNode;
|
|
98
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
98
99
|
declare function useSearch(): {
|
|
99
100
|
open: boolean;
|
|
100
101
|
onOpenChange: (open: boolean) => void;
|
|
@@ -112,6 +113,5 @@ declare function useSearchList(): {
|
|
|
112
113
|
active: string | null;
|
|
113
114
|
setActive: (v: string | null) => void;
|
|
114
115
|
};
|
|
115
|
-
|
|
116
|
-
export { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, SearchDialogProps, SearchItemType, type SharedProps, TagsList, TagsListItem, TagsListProps, useSearch, useSearchList, useTagsList };
|
|
117
|
-
//# sourceMappingURL=search.d.ts.map
|
|
116
|
+
//#endregion
|
|
117
|
+
export { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, SearchDialogProps, SearchItemType, type SharedProps, TagsList, TagsListItem, TagsListProps, useSearch, useSearchList, useTagsList };
|
|
@@ -1,45 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { I18nLabel, useI18n } from "../../contexts/i18n.js";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
3
4
|
import { buttonVariants } from "../ui/button.js";
|
|
4
|
-
import {
|
|
5
|
+
import { Fragment, createContext, use, useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
5
6
|
import { useRouter } from "@hanzo/docs-core/framework";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ChevronRight, Hash, Search } from "lucide-react";
|
|
9
|
-
import { Fragment as Fragment$1, createContext, use, useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
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
|
]),
|
|
@@ -54,7 +140,7 @@ function SearchDialogHeader(props) {
|
|
|
54
140
|
});
|
|
55
141
|
}
|
|
56
142
|
function SearchDialogInput(props) {
|
|
57
|
-
const { text } =
|
|
143
|
+
const { text } = useI18n();
|
|
58
144
|
const { search, onSearchChange } = useSearch();
|
|
59
145
|
return /* @__PURE__ */ jsx("input", {
|
|
60
146
|
...props,
|
|
@@ -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
|
-
const { text } =
|
|
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
|
|
@@ -104,8 +191,8 @@ function SearchDialogContent({ children, className, ...props }) {
|
|
|
104
191
|
}
|
|
105
192
|
function SearchDialogList({ items = null, Empty = () => /* @__PURE__ */ jsx("div", {
|
|
106
193
|
className: "py-12 text-center text-sm text-fd-muted-foreground",
|
|
107
|
-
children: /* @__PURE__ */ jsx(
|
|
108
|
-
}), Item = (props
|
|
194
|
+
children: /* @__PURE__ */ jsx(I18nLabel, { label: "searchNoResult" })
|
|
195
|
+
}), Item = (props) => /* @__PURE__ */ jsx(SearchDialogListItem, { ...props }), ...props }) {
|
|
109
196
|
const ref = useRef(null);
|
|
110
197
|
const { onSelect } = useSearch();
|
|
111
198
|
const [active, setActive] = useState(() => items && items.length > 0 ? items[0].id : null);
|
|
@@ -129,15 +216,16 @@ function SearchDialogList({ items = null, Empty = () => /* @__PURE__ */ jsx("div
|
|
|
129
216
|
const element = ref.current;
|
|
130
217
|
if (!element) return;
|
|
131
218
|
const observer = new ResizeObserver(() => {
|
|
132
|
-
const viewport
|
|
133
|
-
element.style.setProperty("--fd-animated-height", `${viewport
|
|
219
|
+
const viewport = element.firstElementChild;
|
|
220
|
+
element.style.setProperty("--fd-animated-height", `${viewport.clientHeight}px`);
|
|
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,12 +238,12 @@ 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
|
|
157
245
|
}), [active]),
|
|
158
|
-
children: [items?.length === 0 && Empty(), items?.map((item) => /* @__PURE__ */ jsx(Fragment
|
|
246
|
+
children: [items?.length === 0 && Empty(), items?.map((item) => /* @__PURE__ */ jsx(Fragment, { children: Item({
|
|
159
247
|
item,
|
|
160
248
|
onClick: () => onSelect(item)
|
|
161
249
|
}) }, item.id))]
|
|
@@ -163,22 +251,26 @@ 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;
|
|
170
|
-
else children ??= /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
261
|
+
else children ??= /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
171
262
|
/* @__PURE__ */ jsx("div", {
|
|
172
263
|
className: "inline-flex items-center text-fd-muted-foreground text-xs empty:hidden",
|
|
173
|
-
children: item.breadcrumbs?.map((item
|
|
264
|
+
children: item.breadcrumbs?.map((item, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx(ChevronRight, { className: "size-4 rtl:rotate-180" }), item] }, i))
|
|
174
265
|
}),
|
|
175
266
|
item.type !== "page" && /* @__PURE__ */ jsx("div", {
|
|
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$1, { 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
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CodeBlockProps } from "./codeblock.js";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { UseShikiOptions } from "@hanzo/docs-core/highlight/shiki/react";
|
|
4
|
+
import { HighlighterCore } from "shiki";
|
|
5
|
+
|
|
6
|
+
//#region src/components/dynamic-codeblock.core.d.ts
|
|
7
|
+
interface DynamicCodeblockProps {
|
|
8
|
+
highlighter: HighlighterCore | (() => HighlighterCore | PromiseLike<HighlighterCore>);
|
|
9
|
+
lang: string;
|
|
10
|
+
code: string;
|
|
11
|
+
/**
|
|
12
|
+
* Extra props for the underlying `<CodeBlock />` component.
|
|
13
|
+
*
|
|
14
|
+
* Ignored if you defined your own `pre` component in `options.components`.
|
|
15
|
+
*/
|
|
16
|
+
codeblock?: CodeBlockProps;
|
|
17
|
+
/**
|
|
18
|
+
* Wrap in React `<Suspense />` and provide a fallback.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue true
|
|
21
|
+
*/
|
|
22
|
+
wrapInSuspense?: boolean;
|
|
23
|
+
options: DistributiveOmit<UseShikiOptions, 'lang'>;
|
|
24
|
+
}
|
|
25
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
26
|
+
declare function DynamicCodeBlock({
|
|
27
|
+
lang,
|
|
28
|
+
code,
|
|
29
|
+
codeblock,
|
|
30
|
+
options,
|
|
31
|
+
wrapInSuspense,
|
|
32
|
+
highlighter
|
|
33
|
+
}: DynamicCodeblockProps): react_jsx_runtime0.JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { DynamicCodeBlock, DynamicCodeblockProps };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { CodeBlock, Pre } from "./codeblock.js";
|
|
4
|
+
import { createContext, use, useId } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useShikiDynamic } from "@hanzo/docs-core/highlight/shiki/react";
|
|
7
|
+
//#region src/components/dynamic-codeblock.core.tsx
|
|
8
|
+
const PropsContext = createContext(void 0);
|
|
9
|
+
function DefaultPre(props) {
|
|
10
|
+
const extraProps = use(PropsContext);
|
|
11
|
+
return /* @__PURE__ */ jsx(CodeBlock, {
|
|
12
|
+
...props,
|
|
13
|
+
...extraProps,
|
|
14
|
+
className: cn("my-0", props.className, extraProps?.className),
|
|
15
|
+
children: /* @__PURE__ */ jsx(Pre, { children: props.children })
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function DynamicCodeBlock({ lang, code, codeblock, options, wrapInSuspense = true, highlighter }) {
|
|
19
|
+
const id = useId();
|
|
20
|
+
const shikiOptions = {
|
|
21
|
+
lang,
|
|
22
|
+
defaultColor: false,
|
|
23
|
+
...options,
|
|
24
|
+
components: {
|
|
25
|
+
pre: DefaultPre,
|
|
26
|
+
...options.components
|
|
27
|
+
}
|
|
28
|
+
};
|
|
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
|
|
37
|
+
});
|
|
38
|
+
return /* @__PURE__ */ jsx(PropsContext, {
|
|
39
|
+
value: codeblock,
|
|
40
|
+
children: node
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function Placeholder({ code, components = {} }) {
|
|
44
|
+
const { pre: Pre = "pre", code: Code = "code" } = components;
|
|
45
|
+
return /* @__PURE__ */ jsx(Pre, { children: /* @__PURE__ */ jsx(Code, { children: code.split("\n").map((line, i) => /* @__PURE__ */ jsx("span", {
|
|
46
|
+
className: "line",
|
|
47
|
+
children: line
|
|
48
|
+
}, i)) }) });
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { DynamicCodeBlock };
|
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import { HighlightOptionsCommon, HighlightOptionsThemes } from "@hanzo/docs-core/highlight";
|
|
1
|
+
import { DynamicCodeblockProps as DynamicCodeblockProps$1 } from "./dynamic-codeblock.core.js";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
3
|
|
|
5
4
|
//#region src/components/dynamic-codeblock.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Extra props for the underlying `<CodeBlock />` component.
|
|
11
|
-
*
|
|
12
|
-
* Ignored if you defined your own `pre` component in `options.components`.
|
|
13
|
-
*/
|
|
14
|
-
codeblock?: CodeBlockProps;
|
|
15
|
-
/**
|
|
16
|
-
* Wrap in React `<Suspense />` and provide a fallback.
|
|
17
|
-
*
|
|
18
|
-
* @defaultValue true
|
|
19
|
-
*/
|
|
20
|
-
wrapInSuspense?: boolean;
|
|
21
|
-
options?: Omit<HighlightOptionsCommon, 'lang'> & HighlightOptionsThemes;
|
|
22
|
-
}
|
|
23
|
-
declare function DynamicCodeBlock({
|
|
24
|
-
lang,
|
|
25
|
-
code,
|
|
26
|
-
codeblock,
|
|
27
|
-
options,
|
|
28
|
-
wrapInSuspense
|
|
29
|
-
}: DynamicCodeblockProps): react_jsx_runtime98.JSX.Element;
|
|
5
|
+
type DynamicCodeblockProps = Omit<DynamicCodeblockProps$1, 'highlighter' | 'options'> & {
|
|
6
|
+
options?: DynamicCodeblockProps$1['options'];
|
|
7
|
+
};
|
|
8
|
+
declare function DynamicCodeBlock(props: DynamicCodeblockProps): react_jsx_runtime0.JSX.Element;
|
|
30
9
|
//#endregion
|
|
31
|
-
export { DynamicCodeBlock, DynamicCodeblockProps };
|
|
32
|
-
//# sourceMappingURL=dynamic-codeblock.d.ts.map
|
|
10
|
+
export { DynamicCodeBlock, DynamicCodeblockProps };
|
|
@@ -1,66 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { CodeBlock, Pre } from "./codeblock.js";
|
|
4
|
-
import { cn } from "@hanzo/docs-ui/cn";
|
|
1
|
+
"use client";
|
|
2
|
+
import { DynamicCodeBlock as DynamicCodeBlock$1 } from "./dynamic-codeblock.core.js";
|
|
5
3
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
7
|
-
import { useShiki } from "@hanzo/docs-core/highlight/client";
|
|
8
|
-
|
|
4
|
+
import { defaultShikiFactory } from "@hanzo/docs-core/highlight/shiki/full";
|
|
9
5
|
//#region src/components/dynamic-codeblock.tsx
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
function DynamicCodeBlock(props) {
|
|
7
|
+
return /* @__PURE__ */ jsx(DynamicCodeBlock$1, {
|
|
8
|
+
highlighter: () => defaultShikiFactory.getOrInit(),
|
|
9
|
+
options: { themes: {
|
|
10
|
+
light: "github-light",
|
|
11
|
+
dark: "github-dark"
|
|
12
|
+
} },
|
|
13
|
+
...props
|
|
18
14
|
});
|
|
19
15
|
}
|
|
20
|
-
function DynamicCodeBlock({ lang, code, codeblock, options, wrapInSuspense = true }) {
|
|
21
|
-
const id = useId();
|
|
22
|
-
const shikiOptions = {
|
|
23
|
-
lang,
|
|
24
|
-
...options,
|
|
25
|
-
components: {
|
|
26
|
-
pre: DefaultPre,
|
|
27
|
-
...options?.components
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const children = /* @__PURE__ */ jsx(PropsContext, {
|
|
31
|
-
value: codeblock,
|
|
32
|
-
children: /* @__PURE__ */ jsx(Internal, {
|
|
33
|
-
id,
|
|
34
|
-
...useDeferredValue({
|
|
35
|
-
code,
|
|
36
|
-
options: shikiOptions
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
if (wrapInSuspense) return /* @__PURE__ */ jsx(Suspense, {
|
|
41
|
-
fallback: /* @__PURE__ */ jsx(Placeholder, {
|
|
42
|
-
code,
|
|
43
|
-
components: shikiOptions.components
|
|
44
|
-
}),
|
|
45
|
-
children
|
|
46
|
-
});
|
|
47
|
-
return children;
|
|
48
|
-
}
|
|
49
|
-
function Placeholder({ code, components = {} }) {
|
|
50
|
-
const { pre: Pre$1 = "pre", code: Code = "code" } = components;
|
|
51
|
-
return /* @__PURE__ */ jsx(Pre$1, { children: /* @__PURE__ */ jsx(Code, { children: code.split("\n").map((line, i) => /* @__PURE__ */ jsx("span", {
|
|
52
|
-
className: "line",
|
|
53
|
-
children: line
|
|
54
|
-
}, i)) }) });
|
|
55
|
-
}
|
|
56
|
-
function Internal({ id, code, options }) {
|
|
57
|
-
return useShiki(code, options, [
|
|
58
|
-
id,
|
|
59
|
-
options.lang,
|
|
60
|
-
code
|
|
61
|
-
]);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
16
|
//#endregion
|
|
65
17
|
export { DynamicCodeBlock };
|
|
66
|
-
//# sourceMappingURL=dynamic-codeblock.js.map
|