opin-ui 0.0.1
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 +5 -0
- package/css/aspen.css +39 -0
- package/css/black.css +39 -0
- package/css/catppuccin.css +49 -0
- package/css/dusk.css +47 -0
- package/css/emerald.css +39 -0
- package/css/generated/docs.css +1 -0
- package/css/generated/flux.css +1 -0
- package/css/generated/home.css +1 -0
- package/css/generated/notebook.css +1 -0
- package/css/generated/shared.css +1 -0
- package/css/lib/base.css +314 -0
- package/css/lib/default-colors.css +51 -0
- package/css/lib/shiki.css +108 -0
- package/css/neutral.css +7 -0
- package/css/ocean.css +44 -0
- package/css/preset-legacy.css +43 -0
- package/css/preset.css +11 -0
- package/css/purple.css +39 -0
- package/css/ruby.css +39 -0
- package/css/shadcn.css +36 -0
- package/css/solar.css +75 -0
- package/css/style.css +9 -0
- package/css/vitepress.css +65 -0
- package/dist/.translations/index.d.ts +49 -0
- package/dist/.translations/keys.js +49 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/accordion.d.ts +23 -0
- package/dist/components/accordion.js +68 -0
- package/dist/components/banner.d.ts +33 -0
- package/dist/components/banner.js +85 -0
- package/dist/components/callout.d.ts +41 -0
- package/dist/components/callout.js +53 -0
- package/dist/components/card.d.ts +19 -0
- package/dist/components/card.js +38 -0
- package/dist/components/codeblock.d.ts +61 -0
- package/dist/components/codeblock.js +173 -0
- package/dist/components/codeblock.rsc.d.ts +20 -0
- package/dist/components/codeblock.rsc.js +22 -0
- package/dist/components/dialog/search-algolia.d.ts +36 -0
- package/dist/components/dialog/search-algolia.js +64 -0
- package/dist/components/dialog/search-default.d.ts +36 -0
- package/dist/components/dialog/search-default.js +58 -0
- package/dist/components/dialog/search-orama.d.ts +43 -0
- package/dist/components/dialog/search-orama.js +69 -0
- package/dist/components/dialog/search.d.ts +112 -0
- package/dist/components/dialog/search.js +350 -0
- package/dist/components/dynamic-codeblock.core.d.ts +34 -0
- package/dist/components/dynamic-codeblock.core.js +51 -0
- package/dist/components/dynamic-codeblock.d.ts +9 -0
- package/dist/components/dynamic-codeblock.js +17 -0
- package/dist/components/files.d.ts +34 -0
- package/dist/components/files.js +40 -0
- package/dist/components/github-info.d.ts +35 -0
- package/dist/components/github-info.js +75 -0
- package/dist/components/heading.d.ts +13 -0
- package/dist/components/heading.js +38 -0
- package/dist/components/image-zoom.d.ts +23 -0
- package/dist/components/image-zoom.js +32 -0
- package/dist/components/image-zoom2.css +71 -0
- package/dist/components/inline-toc.d.ts +14 -0
- package/dist/components/inline-toc.js +28 -0
- package/dist/components/sidebar/base.d.ts +131 -0
- package/dist/components/sidebar/base.js +274 -0
- package/dist/components/sidebar/link-item.d.ts +22 -0
- package/dist/components/sidebar/link-item.js +38 -0
- package/dist/components/sidebar/page-tree.d.ts +28 -0
- package/dist/components/sidebar/page-tree.js +71 -0
- package/dist/components/sidebar/tabs/dropdown.d.ts +16 -0
- package/dist/components/sidebar/tabs/dropdown.js +71 -0
- package/dist/components/sidebar/tabs/index.d.ts +11 -0
- package/dist/components/sidebar/tabs/index.js +46 -0
- package/dist/components/steps.d.ts +15 -0
- package/dist/components/steps.js +16 -0
- package/dist/components/tabs.d.ts +49 -0
- package/dist/components/tabs.js +88 -0
- package/dist/components/toc/clerk.d.ts +20 -0
- package/dist/components/toc/clerk.js +226 -0
- package/dist/components/toc/default.d.ts +23 -0
- package/dist/components/toc/default.js +259 -0
- package/dist/components/toc/index.d.ts +19 -0
- package/dist/components/toc/index.js +45 -0
- package/dist/components/type-table.d.ts +43 -0
- package/dist/components/type-table.js +117 -0
- package/dist/components/ui/accordion.d.ts +30 -0
- package/dist/components/ui/accordion.js +42 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.js +20 -0
- package/dist/components/ui/collapsible.d.ts +15 -0
- package/dist/components/ui/collapsible.js +21 -0
- package/dist/components/ui/navigation-menu.d.ts +30 -0
- package/dist/components/ui/navigation-menu.js +41 -0
- package/dist/components/ui/popover.d.ts +15 -0
- package/dist/components/ui/popover.js +20 -0
- package/dist/components/ui/scroll-area.d.ts +22 -0
- package/dist/components/ui/scroll-area.js +34 -0
- package/dist/components/ui/tabs.d.ts +36 -0
- package/dist/components/ui/tabs.js +77 -0
- package/dist/contexts/i18n.d.ts +41 -0
- package/dist/contexts/i18n.js +37 -0
- package/dist/contexts/search.d.ts +73 -0
- package/dist/contexts/search.js +68 -0
- package/dist/contexts/tree.d.ts +20 -0
- package/dist/contexts/tree.js +38 -0
- package/dist/i18n.d.ts +16 -0
- package/dist/i18n.js +38 -0
- package/dist/layouts/docs/client.d.ts +34 -0
- package/dist/layouts/docs/client.js +92 -0
- package/dist/layouts/docs/index.d.ts +44 -0
- package/dist/layouts/docs/index.js +22 -0
- package/dist/layouts/docs/page/index.d.ts +115 -0
- package/dist/layouts/docs/page/index.js +124 -0
- package/dist/layouts/docs/page/slots/breadcrumb.d.ts +13 -0
- package/dist/layouts/docs/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/docs/page/slots/container.d.ts +6 -0
- package/dist/layouts/docs/page/slots/container.js +17 -0
- package/dist/layouts/docs/page/slots/footer.d.ts +22 -0
- package/dist/layouts/docs/page/slots/footer.js +56 -0
- package/dist/layouts/docs/page/slots/toc.d.ts +62 -0
- package/dist/layouts/docs/page/slots/toc.js +182 -0
- package/dist/layouts/docs/slots/container.d.ts +6 -0
- package/dist/layouts/docs/slots/container.js +36 -0
- package/dist/layouts/docs/slots/header.d.ts +6 -0
- package/dist/layouts/docs/slots/header.js +38 -0
- package/dist/layouts/docs/slots/sidebar.d.ts +29 -0
- package/dist/layouts/docs/slots/sidebar.js +326 -0
- package/dist/layouts/flux/index.d.ts +73 -0
- package/dist/layouts/flux/index.js +146 -0
- package/dist/layouts/flux/page/index.d.ts +102 -0
- package/dist/layouts/flux/page/index.js +104 -0
- package/dist/layouts/flux/page/slots/breadcrumb.d.ts +13 -0
- package/dist/layouts/flux/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/flux/page/slots/container.d.ts +6 -0
- package/dist/layouts/flux/page/slots/container.js +17 -0
- package/dist/layouts/flux/page/slots/footer.d.ts +22 -0
- package/dist/layouts/flux/page/slots/footer.js +56 -0
- package/dist/layouts/flux/page/slots/toc.d.ts +38 -0
- package/dist/layouts/flux/page/slots/toc.js +181 -0
- package/dist/layouts/flux/slots/container.d.ts +6 -0
- package/dist/layouts/flux/slots/container.js +13 -0
- package/dist/layouts/flux/slots/sidebar.d.ts +22 -0
- package/dist/layouts/flux/slots/sidebar.js +237 -0
- package/dist/layouts/flux/slots/tab-dropdown.d.ts +16 -0
- package/dist/layouts/flux/slots/tab-dropdown.js +85 -0
- package/dist/layouts/home/index.d.ts +28 -0
- package/dist/layouts/home/index.js +40 -0
- package/dist/layouts/home/navbar.d.ts +10 -0
- package/dist/layouts/home/navbar.js +34 -0
- package/dist/layouts/home/not-found.d.ts +7 -0
- package/dist/layouts/home/not-found.js +41 -0
- package/dist/layouts/home/slots/container.d.ts +6 -0
- package/dist/layouts/home/slots/container.js +13 -0
- package/dist/layouts/home/slots/header.d.ts +9 -0
- package/dist/layouts/home/slots/header.js +239 -0
- package/dist/layouts/notebook/client.d.ts +36 -0
- package/dist/layouts/notebook/client.js +69 -0
- package/dist/layouts/notebook/index.d.ts +37 -0
- package/dist/layouts/notebook/index.js +22 -0
- package/dist/layouts/notebook/page/index.d.ts +115 -0
- package/dist/layouts/notebook/page/index.js +124 -0
- package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +13 -0
- package/dist/layouts/notebook/page/slots/breadcrumb.js +44 -0
- package/dist/layouts/notebook/page/slots/container.d.ts +6 -0
- package/dist/layouts/notebook/page/slots/container.js +17 -0
- package/dist/layouts/notebook/page/slots/footer.d.ts +22 -0
- package/dist/layouts/notebook/page/slots/footer.js +56 -0
- package/dist/layouts/notebook/page/slots/toc.d.ts +62 -0
- package/dist/layouts/notebook/page/slots/toc.js +181 -0
- package/dist/layouts/notebook/slots/container.d.ts +6 -0
- package/dist/layouts/notebook/slots/container.js +38 -0
- package/dist/layouts/notebook/slots/header.d.ts +6 -0
- package/dist/layouts/notebook/slots/header.js +194 -0
- package/dist/layouts/notebook/slots/sidebar.d.ts +30 -0
- package/dist/layouts/notebook/slots/sidebar.js +298 -0
- package/dist/layouts/shared/client.d.ts +44 -0
- package/dist/layouts/shared/client.js +84 -0
- package/dist/layouts/shared/index.d.ts +178 -0
- package/dist/layouts/shared/index.js +98 -0
- package/dist/layouts/shared/page-actions.d.ts +35 -0
- package/dist/layouts/shared/page-actions.js +195 -0
- package/dist/layouts/shared/slots/language-select.d.ts +18 -0
- package/dist/layouts/shared/slots/language-select.js +43 -0
- package/dist/layouts/shared/slots/search-trigger.d.ts +22 -0
- package/dist/layouts/shared/slots/search-trigger.js +53 -0
- package/dist/layouts/shared/slots/theme-switch.d.ts +13 -0
- package/dist/layouts/shared/slots/theme-switch.js +65 -0
- package/dist/legacy/layout.d.ts +36 -0
- package/dist/legacy/layout.js +44 -0
- package/dist/legacy/sidebar.d.ts +17 -0
- package/dist/legacy/sidebar.js +33 -0
- package/dist/mdx.d.ts +45 -0
- package/dist/mdx.js +70 -0
- package/dist/mdx.server.d.ts +15 -0
- package/dist/mdx.server.js +20 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/controlled.d.ts +31 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/controlled.js +461 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/index.d.ts +2 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/uncontrolled.d.ts +7 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/uncontrolled.js +17 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/adjust-svg-ids.js +53 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/compute-positioned-style.js +25 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/element-tests.js +12 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-div-img-style.js +45 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-img-alt.js +8 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-img-object-fit-style.js +55 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-img-regular-style.js +21 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-img-src.js +14 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-modal-img-transform.js +22 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-scale.js +27 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-style-ghost.js +31 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-style-modal-img.js +75 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/get-target-dimension.js +4 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/parse-position.js +7 -0
- package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/utils/test-has-scalable-src.js +5 -0
- package/dist/og/takumi.d.ts +21 -0
- package/dist/og/takumi.js +91 -0
- package/dist/og.d.ts +22 -0
- package/dist/og.js +91 -0
- package/dist/page.d.ts +35 -0
- package/dist/page.js +33 -0
- package/dist/provider/base.d.ts +49 -0
- package/dist/provider/base.js +32 -0
- package/dist/provider/next.d.ts +20 -0
- package/dist/provider/next.js +17 -0
- package/dist/provider/react-router.d.ts +20 -0
- package/dist/provider/react-router.js +17 -0
- package/dist/provider/tanstack.d.ts +20 -0
- package/dist/provider/tanstack.js +17 -0
- package/dist/provider/waku.d.ts +20 -0
- package/dist/provider/waku.js +17 -0
- package/dist/style.css +3534 -0
- 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 -0
- package/dist/utils/use-copy-button.js +26 -0
- package/dist/utils/use-footer-items.d.ts +9 -0
- package/dist/utils/use-footer-items.js +24 -0
- package/dist/utils/use-is-scroll-top.d.ts +8 -0
- package/dist/utils/use-is-scroll-top.js +20 -0
- package/package.json +200 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useI18n } from "../../contexts/i18n.js";
|
|
3
|
+
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, TagsList, TagsListItem } from "./search.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useMemo, useState } from "react";
|
|
6
|
+
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
7
|
+
import { useDocsSearch } from "fumadocs-core/search/client";
|
|
8
|
+
import { algoliaClient } from "fumadocs-core/search/client/algolia";
|
|
9
|
+
//#region src/components/dialog/search-algolia.tsx
|
|
10
|
+
function AlgoliaSearchDialog({ searchOptions, tags = [], defaultTag, showAlgolia = false, allowClear = false, links = [], footer, ...props }) {
|
|
11
|
+
const [tag, setTag] = useState(defaultTag);
|
|
12
|
+
const { locale } = useI18n();
|
|
13
|
+
const { search, setSearch, query } = useDocsSearch({ client: algoliaClient({
|
|
14
|
+
tag,
|
|
15
|
+
locale,
|
|
16
|
+
...searchOptions
|
|
17
|
+
}) });
|
|
18
|
+
const defaultItems = useMemo(() => {
|
|
19
|
+
if (links.length === 0) return null;
|
|
20
|
+
return links.map(([name, link]) => ({
|
|
21
|
+
type: "page",
|
|
22
|
+
id: name,
|
|
23
|
+
content: name,
|
|
24
|
+
url: link
|
|
25
|
+
}));
|
|
26
|
+
}, [links]);
|
|
27
|
+
useOnChange(defaultTag, (v) => {
|
|
28
|
+
setTag(v);
|
|
29
|
+
});
|
|
30
|
+
const label = showAlgolia && /* @__PURE__ */ jsx(AlgoliaTitle, {});
|
|
31
|
+
return /* @__PURE__ */ jsxs(SearchDialog, {
|
|
32
|
+
search,
|
|
33
|
+
onSearchChange: setSearch,
|
|
34
|
+
isLoading: query.isLoading,
|
|
35
|
+
...props,
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx(SearchDialogOverlay, {}),
|
|
38
|
+
/* @__PURE__ */ jsxs(SearchDialogContent, { children: [/* @__PURE__ */ jsxs(SearchDialogHeader, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(SearchDialogIcon, {}),
|
|
40
|
+
/* @__PURE__ */ jsx(SearchDialogInput, {}),
|
|
41
|
+
/* @__PURE__ */ jsx(SearchDialogClose, {})
|
|
42
|
+
] }), /* @__PURE__ */ jsx(SearchDialogList, { items: query.data !== "empty" ? query.data : defaultItems })] }),
|
|
43
|
+
/* @__PURE__ */ jsxs(SearchDialogFooter, { children: [tags.length > 0 ? /* @__PURE__ */ jsxs(TagsList, {
|
|
44
|
+
tag,
|
|
45
|
+
onTagChange: setTag,
|
|
46
|
+
allowClear,
|
|
47
|
+
children: [tags.map((tag) => /* @__PURE__ */ jsx(TagsListItem, {
|
|
48
|
+
value: tag.value,
|
|
49
|
+
children: tag.name
|
|
50
|
+
}, tag.value)), label]
|
|
51
|
+
}) : label, footer] })
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function AlgoliaTitle() {
|
|
56
|
+
return /* @__PURE__ */ jsx("a", {
|
|
57
|
+
href: "https://algolia.com",
|
|
58
|
+
rel: "noreferrer noopener",
|
|
59
|
+
className: "ms-auto text-xs text-fd-muted-foreground",
|
|
60
|
+
children: "Search powered by Algolia"
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { AlgoliaSearchDialog as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SearchLink, SharedProps, TagItem } from "../../contexts/search.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/dialog/search-default.d.ts
|
|
5
|
+
interface DefaultSearchDialogProps extends SharedProps {
|
|
6
|
+
links?: SearchLink[];
|
|
7
|
+
defaultTag?: string;
|
|
8
|
+
tags?: TagItem[];
|
|
9
|
+
/**
|
|
10
|
+
* Search API URL
|
|
11
|
+
*/
|
|
12
|
+
api?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The debounced delay for performing a search.
|
|
15
|
+
*/
|
|
16
|
+
delayMs?: number;
|
|
17
|
+
footer?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Allow to clear tag filters
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*/
|
|
23
|
+
allowClear?: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare function DefaultSearchDialog({
|
|
26
|
+
defaultTag,
|
|
27
|
+
tags,
|
|
28
|
+
api,
|
|
29
|
+
delayMs,
|
|
30
|
+
allowClear,
|
|
31
|
+
links,
|
|
32
|
+
footer,
|
|
33
|
+
...props
|
|
34
|
+
}: DefaultSearchDialogProps): import("react").JSX.Element;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { DefaultSearchDialogProps, DefaultSearchDialog as default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useI18n } from "../../contexts/i18n.js";
|
|
3
|
+
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, TagsList, TagsListItem } from "./search.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useMemo, useState } from "react";
|
|
6
|
+
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
7
|
+
import { useDocsSearch } from "fumadocs-core/search/client";
|
|
8
|
+
import { fetchClient } from "fumadocs-core/search/client/fetch";
|
|
9
|
+
//#region src/components/dialog/search-default.tsx
|
|
10
|
+
function DefaultSearchDialog({ defaultTag, tags = [], api, delayMs, allowClear = false, links = [], footer, ...props }) {
|
|
11
|
+
const { locale } = useI18n();
|
|
12
|
+
const [tag, setTag] = useState(defaultTag);
|
|
13
|
+
const { search, setSearch, query } = useDocsSearch({
|
|
14
|
+
client: fetchClient({
|
|
15
|
+
api,
|
|
16
|
+
locale,
|
|
17
|
+
tag
|
|
18
|
+
}),
|
|
19
|
+
delayMs
|
|
20
|
+
});
|
|
21
|
+
const defaultItems = useMemo(() => {
|
|
22
|
+
if (links.length === 0) return null;
|
|
23
|
+
return links.map(([name, link]) => ({
|
|
24
|
+
type: "page",
|
|
25
|
+
id: name,
|
|
26
|
+
content: name,
|
|
27
|
+
url: link
|
|
28
|
+
}));
|
|
29
|
+
}, [links]);
|
|
30
|
+
useOnChange(defaultTag, (v) => {
|
|
31
|
+
setTag(v);
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsxs(SearchDialog, {
|
|
34
|
+
search,
|
|
35
|
+
onSearchChange: setSearch,
|
|
36
|
+
isLoading: query.isLoading,
|
|
37
|
+
...props,
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx(SearchDialogOverlay, {}),
|
|
40
|
+
/* @__PURE__ */ jsxs(SearchDialogContent, { children: [/* @__PURE__ */ jsxs(SearchDialogHeader, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(SearchDialogIcon, {}),
|
|
42
|
+
/* @__PURE__ */ jsx(SearchDialogInput, {}),
|
|
43
|
+
/* @__PURE__ */ jsx(SearchDialogClose, {})
|
|
44
|
+
] }), /* @__PURE__ */ jsx(SearchDialogList, { items: query.data !== "empty" ? query.data : defaultItems })] }),
|
|
45
|
+
/* @__PURE__ */ jsxs(SearchDialogFooter, { children: [tags.length > 0 && /* @__PURE__ */ jsx(TagsList, {
|
|
46
|
+
tag,
|
|
47
|
+
onTagChange: setTag,
|
|
48
|
+
allowClear,
|
|
49
|
+
children: tags.map((tag) => /* @__PURE__ */ jsx(TagsListItem, {
|
|
50
|
+
value: tag.value,
|
|
51
|
+
children: tag.name
|
|
52
|
+
}, tag.value))
|
|
53
|
+
}), footer] })
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { DefaultSearchDialog as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SearchLink, SharedProps, TagItem } from "../../contexts/search.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { OramaCloudOptions } from "fumadocs-core/search/client";
|
|
4
|
+
|
|
5
|
+
//#region src/components/dialog/search-orama.d.ts
|
|
6
|
+
interface OramaSearchDialogProps extends SharedProps {
|
|
7
|
+
links?: SearchLink[];
|
|
8
|
+
client: OramaCloudOptions['client'];
|
|
9
|
+
searchOptions?: OramaCloudOptions['params'];
|
|
10
|
+
index?: OramaCloudOptions['index'];
|
|
11
|
+
footer?: ReactNode;
|
|
12
|
+
defaultTag?: string;
|
|
13
|
+
tags?: TagItem[];
|
|
14
|
+
/**
|
|
15
|
+
* Add the "Powered by Orama" label
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue true
|
|
18
|
+
*/
|
|
19
|
+
showOrama?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Allow to clear tag filters
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue false
|
|
24
|
+
*/
|
|
25
|
+
allowClear?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Orama Cloud integration
|
|
29
|
+
*/
|
|
30
|
+
declare function OramaSearchDialog({
|
|
31
|
+
client,
|
|
32
|
+
searchOptions,
|
|
33
|
+
tags,
|
|
34
|
+
defaultTag,
|
|
35
|
+
showOrama,
|
|
36
|
+
allowClear,
|
|
37
|
+
index,
|
|
38
|
+
footer,
|
|
39
|
+
links,
|
|
40
|
+
...props
|
|
41
|
+
}: OramaSearchDialogProps): import("react").JSX.Element;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { OramaSearchDialogProps, OramaSearchDialog as default };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useI18n } from "../../contexts/i18n.js";
|
|
3
|
+
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, TagsList, TagsListItem } from "./search.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useMemo, useState } from "react";
|
|
6
|
+
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
7
|
+
import { useDocsSearch } from "fumadocs-core/search/client";
|
|
8
|
+
import { oramaCloudClient } from "fumadocs-core/search/client/orama-cloud";
|
|
9
|
+
//#region src/components/dialog/search-orama.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Orama Cloud integration
|
|
12
|
+
*/
|
|
13
|
+
function OramaSearchDialog({ client, searchOptions, tags = [], defaultTag, showOrama = true, allowClear = false, index, footer, links = [], ...props }) {
|
|
14
|
+
const { locale } = useI18n();
|
|
15
|
+
const [tag, setTag] = useState(defaultTag);
|
|
16
|
+
const { search, setSearch, query } = useDocsSearch({ client: oramaCloudClient({
|
|
17
|
+
client,
|
|
18
|
+
index,
|
|
19
|
+
params: searchOptions,
|
|
20
|
+
locale,
|
|
21
|
+
tag
|
|
22
|
+
}) });
|
|
23
|
+
const defaultItems = useMemo(() => {
|
|
24
|
+
if (links.length === 0) return null;
|
|
25
|
+
return links.map(([name, link]) => ({
|
|
26
|
+
type: "page",
|
|
27
|
+
id: name,
|
|
28
|
+
content: name,
|
|
29
|
+
url: link
|
|
30
|
+
}));
|
|
31
|
+
}, [links]);
|
|
32
|
+
useOnChange(defaultTag, (v) => {
|
|
33
|
+
setTag(v);
|
|
34
|
+
});
|
|
35
|
+
const label = showOrama && /* @__PURE__ */ jsx(Label, {});
|
|
36
|
+
return /* @__PURE__ */ jsxs(SearchDialog, {
|
|
37
|
+
search,
|
|
38
|
+
onSearchChange: setSearch,
|
|
39
|
+
isLoading: query.isLoading,
|
|
40
|
+
...props,
|
|
41
|
+
children: [/* @__PURE__ */ jsx(SearchDialogOverlay, {}), /* @__PURE__ */ jsxs(SearchDialogContent, { children: [
|
|
42
|
+
/* @__PURE__ */ jsxs(SearchDialogHeader, { children: [
|
|
43
|
+
/* @__PURE__ */ jsx(SearchDialogIcon, {}),
|
|
44
|
+
/* @__PURE__ */ jsx(SearchDialogInput, {}),
|
|
45
|
+
/* @__PURE__ */ jsx(SearchDialogClose, {})
|
|
46
|
+
] }),
|
|
47
|
+
/* @__PURE__ */ jsx(SearchDialogList, { items: query.data !== "empty" ? query.data : defaultItems }),
|
|
48
|
+
/* @__PURE__ */ jsxs(SearchDialogFooter, { children: [tags.length > 0 ? /* @__PURE__ */ jsxs(TagsList, {
|
|
49
|
+
tag,
|
|
50
|
+
onTagChange: setTag,
|
|
51
|
+
allowClear,
|
|
52
|
+
children: [tags.map((tag) => /* @__PURE__ */ jsx(TagsListItem, {
|
|
53
|
+
value: tag.value,
|
|
54
|
+
children: tag.name
|
|
55
|
+
}, tag.value)), label]
|
|
56
|
+
}) : label, footer] })
|
|
57
|
+
] })]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function Label() {
|
|
61
|
+
return /* @__PURE__ */ jsx("a", {
|
|
62
|
+
href: "https://orama.com",
|
|
63
|
+
rel: "noreferrer noopener",
|
|
64
|
+
className: "ms-auto text-xs text-fd-muted-foreground",
|
|
65
|
+
children: "Search powered by Orama"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { OramaSearchDialog as default };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { SharedProps } from "../../contexts/search.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import { DialogContent, DialogOverlay } from "@radix-ui/react-dialog";
|
|
4
|
+
import { HighlightedText, ReactSortedResult } from "fumadocs-core/search";
|
|
5
|
+
|
|
6
|
+
//#region src/components/dialog/search.d.ts
|
|
7
|
+
type SearchItemType = (ReactSortedResult & {
|
|
8
|
+
external?: boolean;
|
|
9
|
+
}) | {
|
|
10
|
+
id: string;
|
|
11
|
+
type: 'action';
|
|
12
|
+
node: ReactNode;
|
|
13
|
+
onSelect: () => void;
|
|
14
|
+
};
|
|
15
|
+
interface SearchDialogProps extends SharedProps {
|
|
16
|
+
search: string;
|
|
17
|
+
onSearchChange: (v: string) => void;
|
|
18
|
+
onSelect?: (item: SearchItemType) => void;
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare function SearchDialog({
|
|
23
|
+
open,
|
|
24
|
+
onOpenChange,
|
|
25
|
+
search,
|
|
26
|
+
onSearchChange,
|
|
27
|
+
isLoading,
|
|
28
|
+
onSelect: onSelectProp,
|
|
29
|
+
children
|
|
30
|
+
}: SearchDialogProps): import("react").JSX.Element;
|
|
31
|
+
declare function SearchDialogHeader(props: ComponentProps<'div'>): import("react").JSX.Element;
|
|
32
|
+
declare function SearchDialogInput(props: ComponentProps<'input'>): import("react").JSX.Element;
|
|
33
|
+
declare function SearchDialogClose({
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
}: ComponentProps<'button'>): import("react").JSX.Element;
|
|
38
|
+
declare function SearchDialogFooter(props: ComponentProps<'div'>): import("react").JSX.Element;
|
|
39
|
+
declare function SearchDialogOverlay(props: ComponentProps<typeof DialogOverlay>): import("react").JSX.Element;
|
|
40
|
+
declare function SearchDialogContent({
|
|
41
|
+
children,
|
|
42
|
+
...props
|
|
43
|
+
}: ComponentProps<typeof DialogContent>): import("react").JSX.Element;
|
|
44
|
+
declare function SearchDialogList({
|
|
45
|
+
items,
|
|
46
|
+
Empty,
|
|
47
|
+
Item,
|
|
48
|
+
...props
|
|
49
|
+
}: Omit<ComponentProps<'div'>, 'children'> & {
|
|
50
|
+
items: SearchItemType[] | null | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Renderer for empty list UI
|
|
53
|
+
*/
|
|
54
|
+
Empty?: () => ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Renderer for items
|
|
57
|
+
*/
|
|
58
|
+
Item?: (props: {
|
|
59
|
+
item: SearchItemType;
|
|
60
|
+
onClick: () => void;
|
|
61
|
+
}) => ReactNode;
|
|
62
|
+
}): import("react").JSX.Element;
|
|
63
|
+
declare function SearchDialogListItem({
|
|
64
|
+
item,
|
|
65
|
+
className,
|
|
66
|
+
children,
|
|
67
|
+
renderMarkdown,
|
|
68
|
+
renderHighlights: _,
|
|
69
|
+
...props
|
|
70
|
+
}: ComponentProps<'button'> & {
|
|
71
|
+
renderMarkdown?: (v: string) => ReactNode; /** @deprecated highlight blocks is now wrapped in `<mark />`, use `renderMarkdown` to handle instead. */
|
|
72
|
+
renderHighlights?: (blocks: HighlightedText<ReactNode>[]) => ReactNode;
|
|
73
|
+
item: SearchItemType;
|
|
74
|
+
}): import("react").JSX.Element;
|
|
75
|
+
declare function SearchDialogIcon(props: ComponentProps<'svg'>): import("react").JSX.Element;
|
|
76
|
+
interface TagsListProps extends ComponentProps<'div'> {
|
|
77
|
+
tag?: string;
|
|
78
|
+
onTagChange: (tag: string | undefined) => void;
|
|
79
|
+
allowClear?: boolean;
|
|
80
|
+
}
|
|
81
|
+
declare function TagsList({
|
|
82
|
+
tag,
|
|
83
|
+
onTagChange,
|
|
84
|
+
allowClear,
|
|
85
|
+
...props
|
|
86
|
+
}: TagsListProps): import("react").JSX.Element;
|
|
87
|
+
declare function TagsListItem({
|
|
88
|
+
value,
|
|
89
|
+
className,
|
|
90
|
+
...props
|
|
91
|
+
}: ComponentProps<'button'> & {
|
|
92
|
+
value: string;
|
|
93
|
+
}): import("react").JSX.Element;
|
|
94
|
+
declare function useSearch(): {
|
|
95
|
+
open: boolean;
|
|
96
|
+
onOpenChange: (open: boolean) => void;
|
|
97
|
+
search: string;
|
|
98
|
+
onSearchChange: (v: string) => void;
|
|
99
|
+
onSelect: (item: SearchItemType) => void;
|
|
100
|
+
isLoading: boolean;
|
|
101
|
+
};
|
|
102
|
+
declare function useTagsList(): {
|
|
103
|
+
value?: string;
|
|
104
|
+
onValueChange: (value: string | undefined) => void;
|
|
105
|
+
allowClear: boolean;
|
|
106
|
+
};
|
|
107
|
+
declare function useSearchList(): {
|
|
108
|
+
active: string | null;
|
|
109
|
+
setActive: (v: string | null) => void;
|
|
110
|
+
};
|
|
111
|
+
//#endregion
|
|
112
|
+
export { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, SearchDialogProps, SearchItemType, type SharedProps, TagsList, TagsListItem, TagsListProps, useSearch, useSearchList, useTagsList };
|