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,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "./ui/button.js";
|
|
4
|
+
import { useCopyButton } from "../utils/use-copy-button.js";
|
|
5
|
+
import { mergeRefs } from "../utils/merge-refs.js";
|
|
6
|
+
import { Accordion as Accordion$1, AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger } from "./ui/accordion.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Check, LinkIcon } from "lucide-react";
|
|
9
|
+
import { useEffect, useRef, useState } from "react";
|
|
10
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
11
|
+
//#region src/components/accordion.tsx
|
|
12
|
+
function Accordions({ type = "single", ref, className, defaultValue, ...props }) {
|
|
13
|
+
const rootRef = useRef(null);
|
|
14
|
+
const composedRef = mergeRefs(ref, rootRef);
|
|
15
|
+
const [value, setValue] = useState(() => type === "single" ? defaultValue ?? "" : defaultValue ?? []);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const id = window.location.hash.substring(1);
|
|
18
|
+
const element = rootRef.current;
|
|
19
|
+
if (!element || id.length === 0) return;
|
|
20
|
+
const selected = document.getElementById(id);
|
|
21
|
+
if (!selected || !element.contains(selected)) return;
|
|
22
|
+
const value = selected.getAttribute("data-accordion-value");
|
|
23
|
+
if (value) setValue((prev) => typeof prev === "string" ? value : [value, ...prev]);
|
|
24
|
+
}, []);
|
|
25
|
+
return /* @__PURE__ */ jsx(Accordion$1, {
|
|
26
|
+
type,
|
|
27
|
+
ref: composedRef,
|
|
28
|
+
value,
|
|
29
|
+
onValueChange: setValue,
|
|
30
|
+
collapsible: type === "single" ? true : void 0,
|
|
31
|
+
className: cn("overflow-hidden rounded-3xl bg-fd-card", className),
|
|
32
|
+
...props
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function Accordion({ title, id, value = String(title), children, ...props }) {
|
|
36
|
+
return /* @__PURE__ */ jsxs(AccordionItem, {
|
|
37
|
+
value,
|
|
38
|
+
...props,
|
|
39
|
+
children: [/* @__PURE__ */ jsxs(AccordionHeader, {
|
|
40
|
+
id,
|
|
41
|
+
"data-accordion-value": value,
|
|
42
|
+
children: [/* @__PURE__ */ jsx(AccordionTrigger, { children: title }), id ? /* @__PURE__ */ jsx(CopyButton, { id }) : null]
|
|
43
|
+
}), /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsx("div", {
|
|
44
|
+
className: "px-3 pb-3 text-[0.9375rem] prose-no-margin",
|
|
45
|
+
children
|
|
46
|
+
}) })]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function CopyButton({ id }) {
|
|
50
|
+
const t = useTranslations({ note: "accordion" });
|
|
51
|
+
const [checked, onClick] = useCopyButton(() => {
|
|
52
|
+
const url = new URL(window.location.href);
|
|
53
|
+
url.hash = id;
|
|
54
|
+
return navigator.clipboard.writeText(url.toString());
|
|
55
|
+
});
|
|
56
|
+
return /* @__PURE__ */ jsx("button", {
|
|
57
|
+
type: "button",
|
|
58
|
+
"aria-label": t("Copy Link", { note: "aria-label" }),
|
|
59
|
+
className: cn(buttonVariants({
|
|
60
|
+
color: "ghost",
|
|
61
|
+
className: "text-fd-muted-foreground me-2"
|
|
62
|
+
})),
|
|
63
|
+
onClick,
|
|
64
|
+
children: checked ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : /* @__PURE__ */ jsx(LinkIcon, { className: "size-3.5" })
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Accordion, Accordions };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/banner.d.ts
|
|
4
|
+
type BannerVariant = 'rainbow' | 'normal';
|
|
5
|
+
declare function Banner({
|
|
6
|
+
id,
|
|
7
|
+
variant,
|
|
8
|
+
changeLayout,
|
|
9
|
+
height,
|
|
10
|
+
rainbowColors,
|
|
11
|
+
...props
|
|
12
|
+
}: HTMLAttributes<HTMLDivElement> & {
|
|
13
|
+
/**
|
|
14
|
+
* @defaultValue 3rem
|
|
15
|
+
*/
|
|
16
|
+
height?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @defaultValue 'normal'
|
|
19
|
+
*/
|
|
20
|
+
variant?: BannerVariant;
|
|
21
|
+
/**
|
|
22
|
+
* For rainbow variant only, customize the colors
|
|
23
|
+
*/
|
|
24
|
+
rainbowColors?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Change Fumadocs layout styles
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue true
|
|
29
|
+
*/
|
|
30
|
+
changeLayout?: boolean;
|
|
31
|
+
}): import("react").JSX.Element | null;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Banner };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "./ui/button.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
8
|
+
//#region src/components/banner.tsx
|
|
9
|
+
function Banner({ id, variant = "normal", changeLayout = true, height = "3rem", rainbowColors = [
|
|
10
|
+
"rgba(0,149,255,0.56)",
|
|
11
|
+
"rgba(231,77,255,0.77)",
|
|
12
|
+
"rgba(255,0,0,0.73)",
|
|
13
|
+
"rgba(131,255,166,0.66)"
|
|
14
|
+
], ...props }) {
|
|
15
|
+
const t = useTranslations({ note: "banner" });
|
|
16
|
+
const [open, setOpen] = useState(true);
|
|
17
|
+
const globalKey = id ? `nd-banner-${encodeBase32(id)}` : null;
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (globalKey && localStorage.getItem(globalKey) === "true") setOpen(false);
|
|
20
|
+
}, [globalKey]);
|
|
21
|
+
function onClose() {
|
|
22
|
+
setOpen(false);
|
|
23
|
+
if (globalKey) localStorage.setItem(globalKey, "true");
|
|
24
|
+
}
|
|
25
|
+
if (!open) return null;
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
27
|
+
id,
|
|
28
|
+
...props,
|
|
29
|
+
className: cn("sticky top-0 z-40 flex flex-row items-center justify-center px-4 text-center text-sm font-medium", variant === "normal" && "bg-fd-secondary", variant === "rainbow" && "bg-fd-background", !open && "hidden", props.className),
|
|
30
|
+
style: { height },
|
|
31
|
+
children: [
|
|
32
|
+
changeLayout && open ? /* @__PURE__ */ jsx("style", { children: globalKey ? `:root:not(.${globalKey}) { --fd-banner-height: ${height}; }` : `:root { --fd-banner-height: ${height}; }` }) : null,
|
|
33
|
+
globalKey ? /* @__PURE__ */ jsx("style", { children: `.${globalKey} #${id} { display: none; }` }) : null,
|
|
34
|
+
globalKey ? /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: `if (localStorage.getItem('${globalKey}') === 'true') document.documentElement.classList.add('${globalKey}');` } }) : null,
|
|
35
|
+
variant === "rainbow" ? flow({ colors: rainbowColors }) : null,
|
|
36
|
+
props.children,
|
|
37
|
+
id ? /* @__PURE__ */ jsx("button", {
|
|
38
|
+
type: "button",
|
|
39
|
+
"aria-label": t("Close Banner", { note: "aria-label" }),
|
|
40
|
+
onClick: onClose,
|
|
41
|
+
className: cn(buttonVariants({
|
|
42
|
+
color: "ghost",
|
|
43
|
+
className: "absolute inset-e-2 top-1/2 -translate-y-1/2 text-fd-muted-foreground/50",
|
|
44
|
+
size: "icon-sm"
|
|
45
|
+
})),
|
|
46
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
47
|
+
}) : null
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const maskImage = "linear-gradient(to bottom,white,transparent), radial-gradient(circle at top center, white, transparent)";
|
|
52
|
+
function flow({ colors }) {
|
|
53
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
54
|
+
className: "absolute inset-0 -z-1",
|
|
55
|
+
style: {
|
|
56
|
+
maskImage,
|
|
57
|
+
maskComposite: "intersect",
|
|
58
|
+
animation: "fd-moving-banner 20s linear infinite",
|
|
59
|
+
backgroundImage: `repeating-linear-gradient(70deg, ${[...colors, colors[0]].map((color, i) => `${color} ${i * 50 / colors.length}%`).join(", ")})`,
|
|
60
|
+
backgroundSize: "200% 100%",
|
|
61
|
+
filter: "saturate(2)"
|
|
62
|
+
}
|
|
63
|
+
}), /* @__PURE__ */ jsx("style", { children: `@keyframes fd-moving-banner {
|
|
64
|
+
from { background-position: 0% 0; }
|
|
65
|
+
to { background-position: 100% 0; }
|
|
66
|
+
}` })] });
|
|
67
|
+
}
|
|
68
|
+
function encodeBase32(str) {
|
|
69
|
+
const alphabet = "abcdefghijklmnopqrstuvwxyz234567";
|
|
70
|
+
let encoded = "";
|
|
71
|
+
let buffer = 0;
|
|
72
|
+
let bitsLeft = 0;
|
|
73
|
+
for (let i = 0; i < str.length; i++) {
|
|
74
|
+
buffer = buffer << 8 | str.charCodeAt(i);
|
|
75
|
+
bitsLeft += 8;
|
|
76
|
+
while (bitsLeft >= 5) {
|
|
77
|
+
bitsLeft -= 5;
|
|
78
|
+
encoded += alphabet[buffer >> bitsLeft & 31];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (bitsLeft > 0) encoded += alphabet[buffer << 5 - bitsLeft & 31];
|
|
82
|
+
return encoded;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { Banner };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/callout.d.ts
|
|
4
|
+
type CalloutType = 'info' | 'warn' | 'error' | 'success' | 'warning' | 'idea';
|
|
5
|
+
declare function Callout({
|
|
6
|
+
children,
|
|
7
|
+
title,
|
|
8
|
+
...props
|
|
9
|
+
}: {
|
|
10
|
+
title?: ReactNode;
|
|
11
|
+
} & Omit<CalloutContainerProps, 'title'>): import("react").JSX.Element;
|
|
12
|
+
interface CalloutContainerProps extends ComponentProps<'div'> {
|
|
13
|
+
/**
|
|
14
|
+
* @defaultValue info
|
|
15
|
+
*/
|
|
16
|
+
type?: CalloutType;
|
|
17
|
+
/**
|
|
18
|
+
* Force an icon
|
|
19
|
+
*/
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare function CalloutContainer({
|
|
23
|
+
type: inputType,
|
|
24
|
+
icon,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
style,
|
|
28
|
+
...props
|
|
29
|
+
}: CalloutContainerProps): import("react").JSX.Element;
|
|
30
|
+
declare function CalloutTitle({
|
|
31
|
+
children,
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}: ComponentProps<'p'>): import("react").JSX.Element;
|
|
35
|
+
declare function CalloutDescription({
|
|
36
|
+
children,
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}: ComponentProps<'p'>): import("react").JSX.Element;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Callout, CalloutContainer, CalloutContainerProps, CalloutDescription, CalloutTitle, CalloutType };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CircleCheck, CircleX, Info, Lightbulb, TriangleAlert } from "lucide-react";
|
|
4
|
+
//#region src/components/callout.tsx
|
|
5
|
+
const iconClass = "size-5 -me-0.5 fill-(--callout-color) text-fd-card";
|
|
6
|
+
function Callout({ children, title, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs(CalloutContainer, {
|
|
8
|
+
...props,
|
|
9
|
+
children: [title && /* @__PURE__ */ jsx(CalloutTitle, { children: title }), /* @__PURE__ */ jsx(CalloutDescription, { children })]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function resolveAlias(type) {
|
|
13
|
+
if (type === "warn") return "warning";
|
|
14
|
+
if (type === "tip") return "info";
|
|
15
|
+
return type;
|
|
16
|
+
}
|
|
17
|
+
function CalloutContainer({ type: inputType = "info", icon, children, className, style, ...props }) {
|
|
18
|
+
const type = resolveAlias(inputType);
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: cn("flex gap-2 my-4 rounded-3xl bg-fd-card p-3 ps-2 text-sm text-fd-card-foreground", className),
|
|
21
|
+
style: {
|
|
22
|
+
"--callout-color": `var(--color-fd-${type}, var(--color-fd-muted))`,
|
|
23
|
+
...style
|
|
24
|
+
},
|
|
25
|
+
...props,
|
|
26
|
+
children: [icon ?? {
|
|
27
|
+
info: /* @__PURE__ */ jsx(Info, { className: iconClass }),
|
|
28
|
+
warning: /* @__PURE__ */ jsx(TriangleAlert, { className: iconClass }),
|
|
29
|
+
error: /* @__PURE__ */ jsx(CircleX, { className: iconClass }),
|
|
30
|
+
success: /* @__PURE__ */ jsx(CircleCheck, { className: iconClass }),
|
|
31
|
+
idea: /* @__PURE__ */ jsx(Lightbulb, { className: "size-5 -me-0.5 fill-(--callout-color) text-(--callout-color)" })
|
|
32
|
+
}[type], /* @__PURE__ */ jsx("div", {
|
|
33
|
+
className: "flex flex-col gap-2 min-w-0 flex-1",
|
|
34
|
+
children
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function CalloutTitle({ children, className, ...props }) {
|
|
39
|
+
return /* @__PURE__ */ jsx("p", {
|
|
40
|
+
className: cn("font-medium my-0!", className),
|
|
41
|
+
...props,
|
|
42
|
+
children
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function CalloutDescription({ children, className, ...props }) {
|
|
46
|
+
return /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: cn("text-fd-muted-foreground prose-no-margin empty:hidden", className),
|
|
48
|
+
...props,
|
|
49
|
+
children
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { Callout, CalloutContainer, CalloutDescription, CalloutTitle };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/card.d.ts
|
|
4
|
+
declare function Cards(props: HTMLAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
5
|
+
type CardProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
href?: string;
|
|
10
|
+
external?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare function Card({
|
|
13
|
+
icon,
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
...props
|
|
17
|
+
}: CardProps): import("react").JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Card, CardProps, Cards };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import Link from "fumadocs-core/link";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/card.tsx
|
|
5
|
+
function Cards(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
...props,
|
|
8
|
+
className: cn("grid grid-cols-2 gap-3 @container", props.className),
|
|
9
|
+
children: props.children
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function Card({ icon, title, description, ...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsxs(props.href ? Link : "div", {
|
|
14
|
+
...props,
|
|
15
|
+
"data-card": true,
|
|
16
|
+
className: cn("block rounded-3xl bg-fd-card p-4 text-fd-card-foreground transition-colors @max-lg:col-span-full", props.href && "hover:bg-fd-accent/80", props.className),
|
|
17
|
+
children: [
|
|
18
|
+
icon ? /* @__PURE__ */ jsx("div", {
|
|
19
|
+
className: "not-prose mb-2 w-fit rounded-lg bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4",
|
|
20
|
+
children: icon
|
|
21
|
+
}) : null,
|
|
22
|
+
/* @__PURE__ */ jsx("h3", {
|
|
23
|
+
className: "not-prose mb-1 text-sm font-medium",
|
|
24
|
+
children: title
|
|
25
|
+
}),
|
|
26
|
+
description ? /* @__PURE__ */ jsx("p", {
|
|
27
|
+
className: "my-0! text-sm text-fd-muted-foreground",
|
|
28
|
+
children: description
|
|
29
|
+
}) : null,
|
|
30
|
+
/* @__PURE__ */ jsx("div", {
|
|
31
|
+
className: "text-sm text-fd-muted-foreground prose-no-margin empty:hidden",
|
|
32
|
+
children: props.children
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Card, Cards };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./ui/tabs.js";
|
|
2
|
+
import { ComponentProps, HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/codeblock.d.ts
|
|
5
|
+
interface CodeBlockProps extends ComponentProps<'figure'> {
|
|
6
|
+
/**
|
|
7
|
+
* Icon of code block
|
|
8
|
+
*
|
|
9
|
+
* When passed as a string, it assumes the value is the HTML of icon
|
|
10
|
+
*/
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Allow to copy code with copy button
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue true
|
|
16
|
+
*/
|
|
17
|
+
allowCopy?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Keep original background color generated by Shiki or Rehype Code
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*/
|
|
23
|
+
keepBackground?: boolean;
|
|
24
|
+
viewportProps?: HTMLAttributes<HTMLElement>;
|
|
25
|
+
/**
|
|
26
|
+
* show line numbers
|
|
27
|
+
*/
|
|
28
|
+
'data-line-numbers'?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @defaultValue 1
|
|
31
|
+
*/
|
|
32
|
+
'data-line-numbers-start'?: number;
|
|
33
|
+
Actions?: (props: {
|
|
34
|
+
className?: string;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}) => ReactNode;
|
|
37
|
+
}
|
|
38
|
+
declare function Pre(props: ComponentProps<'pre'>): import("react").JSX.Element;
|
|
39
|
+
declare function CodeBlock({
|
|
40
|
+
ref,
|
|
41
|
+
title,
|
|
42
|
+
allowCopy,
|
|
43
|
+
keepBackground,
|
|
44
|
+
icon,
|
|
45
|
+
viewportProps,
|
|
46
|
+
children,
|
|
47
|
+
Actions,
|
|
48
|
+
...props
|
|
49
|
+
}: CodeBlockProps): import("react").JSX.Element;
|
|
50
|
+
declare function CodeBlockTabs({
|
|
51
|
+
ref,
|
|
52
|
+
...props
|
|
53
|
+
}: ComponentProps<typeof Tabs>): import("react").JSX.Element;
|
|
54
|
+
declare function CodeBlockTabsList(props: ComponentProps<typeof TabsList>): import("react").JSX.Element;
|
|
55
|
+
declare function CodeBlockTabsTrigger({
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
}: ComponentProps<typeof TabsTrigger>): import("react").JSX.Element;
|
|
59
|
+
declare function CodeBlockTab(props: ComponentProps<typeof TabsContent>): import("react").JSX.Element;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { CodeBlock, CodeBlockProps, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "./ui/button.js";
|
|
4
|
+
import { useCopyButton } from "../utils/use-copy-button.js";
|
|
5
|
+
import { mergeRefs } from "../utils/merge-refs.js";
|
|
6
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./ui/tabs.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { createContext, use, useMemo, useRef } from "react";
|
|
9
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
10
|
+
//#region src/components/codeblock.tsx
|
|
11
|
+
const TabsContext = createContext(null);
|
|
12
|
+
function Pre(props) {
|
|
13
|
+
return /* @__PURE__ */ jsx("pre", {
|
|
14
|
+
...props,
|
|
15
|
+
className: cn("min-w-full w-max *:flex *:flex-col", props.className),
|
|
16
|
+
children: props.children
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function CodeBlock({ ref, title, allowCopy = true, keepBackground = false, icon, viewportProps = {}, children, Actions = (props) => /* @__PURE__ */ jsx("div", {
|
|
20
|
+
...props,
|
|
21
|
+
className: cn("empty:hidden", props.className)
|
|
22
|
+
}), ...props }) {
|
|
23
|
+
const inTab = use(TabsContext) !== null;
|
|
24
|
+
const areaRef = useRef(null);
|
|
25
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
26
|
+
ref,
|
|
27
|
+
dir: "ltr",
|
|
28
|
+
...props,
|
|
29
|
+
tabIndex: -1,
|
|
30
|
+
className: cn(inTab ? "bg-fd-secondary -mx-px -mb-px last:rounded-b-3xl" : "my-4 bg-fd-card rounded-3xl", keepBackground && "bg-(--shiki-light-bg) dark:bg-(--shiki-dark-bg)", "shiki relative not-prose overflow-hidden text-sm", props.className),
|
|
31
|
+
children: [title ? /* @__PURE__ */ jsxs("div", {
|
|
32
|
+
className: "flex text-fd-muted-foreground items-center gap-2 h-9.5 bg-fd-muted/40 px-4",
|
|
33
|
+
children: [
|
|
34
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx("div", {
|
|
35
|
+
className: "[&_svg]:size-3.5",
|
|
36
|
+
dangerouslySetInnerHTML: { __html: icon }
|
|
37
|
+
}) : icon,
|
|
38
|
+
/* @__PURE__ */ jsx("figcaption", {
|
|
39
|
+
className: "flex-1 truncate",
|
|
40
|
+
children: title
|
|
41
|
+
}),
|
|
42
|
+
Actions({
|
|
43
|
+
className: "-me-2",
|
|
44
|
+
children: allowCopy && /* @__PURE__ */ jsx(CopyButton, { containerRef: areaRef })
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
}) : Actions({
|
|
48
|
+
className: "absolute top-3 right-2 z-2 backdrop-blur-lg rounded-xl text-fd-muted-foreground",
|
|
49
|
+
children: allowCopy && /* @__PURE__ */ jsx(CopyButton, { containerRef: areaRef })
|
|
50
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
51
|
+
ref: areaRef,
|
|
52
|
+
...viewportProps,
|
|
53
|
+
role: "region",
|
|
54
|
+
tabIndex: 0,
|
|
55
|
+
className: cn("text-[0.8125rem] py-3.5 overflow-auto max-h-[600px] fd-scroll-container focus-visible:outline-none focus-visible:bg-fd-accent/5", viewportProps.className),
|
|
56
|
+
style: {
|
|
57
|
+
"--padding-right": !title ? "calc(var(--spacing) * 8)" : void 0,
|
|
58
|
+
counterSet: props["data-line-numbers"] ? `line ${Number(props["data-line-numbers-start"] ?? 1) - 1}` : void 0,
|
|
59
|
+
...viewportProps.style
|
|
60
|
+
},
|
|
61
|
+
children
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function CopyIcon() {
|
|
66
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
67
|
+
viewBox: "0 0 24 24",
|
|
68
|
+
fill: "none",
|
|
69
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
70
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
71
|
+
d: "M16 12.9V17.1C16 20.6 14.6 22 11.1 22H6.9C3.4 22 2 20.6 2 17.1V12.9C2 9.4 3.4 8 6.9 8H11.1C14.6 8 16 9.4 16 12.9Z",
|
|
72
|
+
stroke: "currentColor",
|
|
73
|
+
strokeWidth: "1.5",
|
|
74
|
+
strokeLinecap: "round",
|
|
75
|
+
strokeLinejoin: "round"
|
|
76
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
77
|
+
d: "M22 6.9V11.1C22 14.6 20.6 16 17.1 16H16V12.9C16 9.4 14.6 8 11.1 8H8V6.9C8 3.4 9.4 2 12.9 2H17.1C20.6 2 22 3.4 22 6.9Z",
|
|
78
|
+
stroke: "currentColor",
|
|
79
|
+
strokeWidth: "1.5",
|
|
80
|
+
strokeLinecap: "round",
|
|
81
|
+
strokeLinejoin: "round"
|
|
82
|
+
})]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function CopiedIcon() {
|
|
86
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
87
|
+
viewBox: "0 0 24 24",
|
|
88
|
+
fill: "none",
|
|
89
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ jsx("path", {
|
|
92
|
+
d: "M22 11.1V6.9C22 3.4 20.6 2 17.1 2H12.9C9.4 2 8 3.4 8 6.9V8H11.1C14.6 8 16 9.4 16 12.9V16H17.1C20.6 16 22 14.6 22 11.1Z",
|
|
93
|
+
stroke: "currentColor",
|
|
94
|
+
strokeWidth: "1.5",
|
|
95
|
+
strokeLinecap: "round",
|
|
96
|
+
strokeLinejoin: "round"
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx("path", {
|
|
99
|
+
d: "M16 17.1V12.9C16 9.4 14.6 8 11.1 8H6.9C3.4 8 2 9.4 2 12.9V17.1C2 20.6 3.4 22 6.9 22H11.1C14.6 22 16 20.6 16 17.1Z",
|
|
100
|
+
stroke: "currentColor",
|
|
101
|
+
strokeWidth: "1.5",
|
|
102
|
+
strokeLinecap: "round",
|
|
103
|
+
strokeLinejoin: "round"
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ jsx("path", {
|
|
106
|
+
d: "M6.08008 15L8.03008 16.95L11.9201 13.05",
|
|
107
|
+
stroke: "currentColor",
|
|
108
|
+
strokeWidth: "1.5",
|
|
109
|
+
strokeLinecap: "round",
|
|
110
|
+
strokeLinejoin: "round"
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function CopyButton({ className, containerRef, ...props }) {
|
|
116
|
+
const t = useTranslations({ note: "code block" });
|
|
117
|
+
const [checked, onClick] = useCopyButton(() => {
|
|
118
|
+
const pre = containerRef.current?.getElementsByTagName("pre").item(0);
|
|
119
|
+
if (!pre) return;
|
|
120
|
+
const clone = pre.cloneNode(true);
|
|
121
|
+
clone.querySelectorAll(".nd-copy-ignore").forEach((node) => {
|
|
122
|
+
node.replaceWith("\n");
|
|
123
|
+
});
|
|
124
|
+
navigator.clipboard.writeText(clone.textContent ?? "");
|
|
125
|
+
});
|
|
126
|
+
return /* @__PURE__ */ jsx("button", {
|
|
127
|
+
type: "button",
|
|
128
|
+
"data-checked": checked || void 0,
|
|
129
|
+
className: cn(buttonVariants({
|
|
130
|
+
className: "hover:text-fd-accent-foreground data-checked:text-fd-accent-foreground",
|
|
131
|
+
size: "icon-xs"
|
|
132
|
+
}), className),
|
|
133
|
+
"aria-label": checked ? t("Copied Text", { note: "aria-label" }) : t("Copy Text", { note: "aria-label" }),
|
|
134
|
+
onClick,
|
|
135
|
+
...props,
|
|
136
|
+
children: checked ? /* @__PURE__ */ jsx(CopiedIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {})
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function CodeBlockTabs({ ref, ...props }) {
|
|
140
|
+
const containerRef = useRef(null);
|
|
141
|
+
const nested = use(TabsContext) !== null;
|
|
142
|
+
return /* @__PURE__ */ jsx(Tabs, {
|
|
143
|
+
ref: mergeRefs(containerRef, ref),
|
|
144
|
+
...props,
|
|
145
|
+
className: cn("bg-fd-card rounded-3xl", !nested && "my-4", props.className),
|
|
146
|
+
children: /* @__PURE__ */ jsx(TabsContext, {
|
|
147
|
+
value: useMemo(() => ({
|
|
148
|
+
containerRef,
|
|
149
|
+
nested
|
|
150
|
+
}), [nested]),
|
|
151
|
+
children: props.children
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function CodeBlockTabsList(props) {
|
|
156
|
+
return /* @__PURE__ */ jsx(TabsList, {
|
|
157
|
+
...props,
|
|
158
|
+
className: cn("flex flex-row px-2 overflow-x-auto text-fd-muted-foreground", props.className),
|
|
159
|
+
children: props.children
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function CodeBlockTabsTrigger({ children, ...props }) {
|
|
163
|
+
return /* @__PURE__ */ jsxs(TabsTrigger, {
|
|
164
|
+
...props,
|
|
165
|
+
className: cn("relative group inline-flex text-sm font-medium text-nowrap items-center transition-colors gap-2 px-2 py-1.5 hover:text-fd-accent-foreground data-[state=active]:text-fd-primary [&_svg]:size-3.5", props.className),
|
|
166
|
+
children: [/* @__PURE__ */ jsx("div", { className: "absolute inset-x-2 bottom-0 h-px group-data-[state=active]:bg-fd-primary" }), children]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function CodeBlockTab(props) {
|
|
170
|
+
return /* @__PURE__ */ jsx(TabsContent, { ...props });
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CodeBlockProps } from "./codeblock.js";
|
|
2
|
+
import { HighlightOptions } from "fumadocs-core/highlight";
|
|
3
|
+
|
|
4
|
+
//#region src/components/codeblock.rsc.d.ts
|
|
5
|
+
type ServerCodeBlockProps = HighlightOptions & {
|
|
6
|
+
code: string;
|
|
7
|
+
/**
|
|
8
|
+
* Extra props for the underlying `<CodeBlock />` component.
|
|
9
|
+
*
|
|
10
|
+
* Ignored if you defined your own `pre` component in `components`.
|
|
11
|
+
*/
|
|
12
|
+
codeblock?: CodeBlockProps;
|
|
13
|
+
};
|
|
14
|
+
declare function ServerCodeBlock({
|
|
15
|
+
code,
|
|
16
|
+
codeblock,
|
|
17
|
+
...options
|
|
18
|
+
}: ServerCodeBlockProps): Promise<import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | (string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined)>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ServerCodeBlock, ServerCodeBlockProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import { CodeBlock, Pre } from "./codeblock.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { highlight } from "fumadocs-core/highlight";
|
|
5
|
+
//#region src/components/codeblock.rsc.tsx
|
|
6
|
+
async function ServerCodeBlock({ code, codeblock, ...options }) {
|
|
7
|
+
return await highlight(code, {
|
|
8
|
+
defaultColor: false,
|
|
9
|
+
...options,
|
|
10
|
+
components: {
|
|
11
|
+
pre: (props) => /* @__PURE__ */ jsx(CodeBlock, {
|
|
12
|
+
...props,
|
|
13
|
+
...codeblock,
|
|
14
|
+
className: cn("my-0", props.className, codeblock?.className),
|
|
15
|
+
children: /* @__PURE__ */ jsx(Pre, { children: props.children })
|
|
16
|
+
}),
|
|
17
|
+
...options.components
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ServerCodeBlock };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SearchLink, SharedProps, TagItem } from "../../contexts/search.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { AlgoliaOptions } from "fumadocs-core/search/client";
|
|
4
|
+
|
|
5
|
+
//#region src/components/dialog/search-algolia.d.ts
|
|
6
|
+
interface AlgoliaSearchDialogProps extends SharedProps {
|
|
7
|
+
searchOptions: AlgoliaOptions;
|
|
8
|
+
links?: SearchLink[];
|
|
9
|
+
footer?: ReactNode;
|
|
10
|
+
defaultTag?: string;
|
|
11
|
+
tags?: TagItem[];
|
|
12
|
+
/**
|
|
13
|
+
* Add the "Powered by Algolia" label, this is useful for free tier users
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue false
|
|
16
|
+
*/
|
|
17
|
+
showAlgolia?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Allow to clear tag filters
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*/
|
|
23
|
+
allowClear?: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare function AlgoliaSearchDialog({
|
|
26
|
+
searchOptions,
|
|
27
|
+
tags,
|
|
28
|
+
defaultTag,
|
|
29
|
+
showAlgolia,
|
|
30
|
+
allowClear,
|
|
31
|
+
links,
|
|
32
|
+
footer,
|
|
33
|
+
...props
|
|
34
|
+
}: AlgoliaSearchDialogProps): import("react").JSX.Element;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { AlgoliaSearchDialogProps, AlgoliaSearchDialog as default };
|