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,38 @@
|
|
|
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 { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { CopyCheckIcon, LinkIcon } from "lucide-react";
|
|
7
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
8
|
+
//#region src/components/heading.tsx
|
|
9
|
+
function Heading({ as, ...props }) {
|
|
10
|
+
const As = as ?? "h1";
|
|
11
|
+
const t = useTranslations({ note: "heading anchor" });
|
|
12
|
+
const [isChecked, onCopy] = useCopyButton(() => {
|
|
13
|
+
if (!props.id) return;
|
|
14
|
+
const url = new URL(window.location.href);
|
|
15
|
+
url.hash = props.id;
|
|
16
|
+
return navigator.clipboard.writeText(url.href);
|
|
17
|
+
});
|
|
18
|
+
if (!props.id) return /* @__PURE__ */ jsx(As, { ...props });
|
|
19
|
+
return /* @__PURE__ */ jsxs(As, {
|
|
20
|
+
...props,
|
|
21
|
+
className: cn("group/heading flex scroll-m-28 flex-row items-center gap-1", props.className),
|
|
22
|
+
children: [/* @__PURE__ */ jsx("a", {
|
|
23
|
+
"data-card": "",
|
|
24
|
+
href: `#${props.id}`,
|
|
25
|
+
children: props.children
|
|
26
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
27
|
+
"aria-label": t("Copy Anchor Link", { note: "aria-label" }),
|
|
28
|
+
className: cn(buttonVariants({
|
|
29
|
+
variant: "ghost",
|
|
30
|
+
size: "icon-xs"
|
|
31
|
+
}), "not-prose shrink-0 text-fd-muted-foreground opacity-0 transition-opacity group-hover/heading:opacity-100"),
|
|
32
|
+
onClick: onCopy,
|
|
33
|
+
children: isChecked ? /* @__PURE__ */ jsx(CopyCheckIcon, {}) : /* @__PURE__ */ jsx(LinkIcon, {})
|
|
34
|
+
})]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Heading };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UncontrolledProps } from "../node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/uncontrolled.js";
|
|
2
|
+
import { ImageProps } from "fumadocs-core/framework";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/image-zoom.d.ts
|
|
6
|
+
type ImageZoomProps = ImageProps & {
|
|
7
|
+
/**
|
|
8
|
+
* Image props when zoom in
|
|
9
|
+
*/
|
|
10
|
+
zoomInProps?: ComponentProps<'img'>;
|
|
11
|
+
/**
|
|
12
|
+
* Props for `react-medium-image-zoom`
|
|
13
|
+
*/
|
|
14
|
+
rmiz?: UncontrolledProps;
|
|
15
|
+
};
|
|
16
|
+
declare function ImageZoom({
|
|
17
|
+
zoomInProps,
|
|
18
|
+
children,
|
|
19
|
+
rmiz,
|
|
20
|
+
...props
|
|
21
|
+
}: ImageZoomProps): import("react").JSX.Element;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ImageZoom, ImageZoomProps };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Uncontrolled } from "../node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/uncontrolled.js";
|
|
3
|
+
import "./image-zoom2.css";
|
|
4
|
+
import { Image } from "fumadocs-core/framework";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/image-zoom.tsx
|
|
7
|
+
function getImageSrc(src) {
|
|
8
|
+
if (typeof src === "string") return src;
|
|
9
|
+
if (typeof src === "object") {
|
|
10
|
+
if ("default" in src) return src.default.src;
|
|
11
|
+
return src.src;
|
|
12
|
+
}
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
function ImageZoom({ zoomInProps, children, rmiz, ...props }) {
|
|
16
|
+
return /* @__PURE__ */ jsx(Uncontrolled, {
|
|
17
|
+
zoomMargin: 20,
|
|
18
|
+
wrapElement: "span",
|
|
19
|
+
...rmiz,
|
|
20
|
+
zoomImg: {
|
|
21
|
+
src: getImageSrc(props.src),
|
|
22
|
+
sizes: void 0,
|
|
23
|
+
...zoomInProps
|
|
24
|
+
},
|
|
25
|
+
children: children ?? /* @__PURE__ */ jsx(Image, {
|
|
26
|
+
sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 70vw, 900px",
|
|
27
|
+
...props
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ImageZoom };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[data-rmiz] {
|
|
2
|
+
display: block;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[data-rmiz-ghost] {
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
position: absolute;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[data-rmiz-btn-zoom], [data-rmiz-btn-unzoom] {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[data-rmiz-content="found"] img {
|
|
16
|
+
cursor: zoom-in;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[data-rmiz-modal][open] {
|
|
20
|
+
background-color: #0000;
|
|
21
|
+
width: 100dvw;
|
|
22
|
+
max-width: none;
|
|
23
|
+
height: 100dvh;
|
|
24
|
+
max-height: none;
|
|
25
|
+
margin: 0;
|
|
26
|
+
padding: 0;
|
|
27
|
+
position: fixed;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-rmiz-modal]:focus-visible {
|
|
32
|
+
outline: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[data-rmiz-modal-overlay] {
|
|
36
|
+
transition: background-color .3s;
|
|
37
|
+
position: absolute;
|
|
38
|
+
inset: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-rmiz-modal-overlay="visible"] {
|
|
42
|
+
background-color: var(--color-fd-background);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-rmiz-modal-overlay="hidden"] {
|
|
46
|
+
background-color: #0000;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[data-rmiz-modal-content] {
|
|
50
|
+
width: 100%;
|
|
51
|
+
height: 100%;
|
|
52
|
+
position: relative;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[data-rmiz-modal]::backdrop {
|
|
56
|
+
display: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[data-rmiz-modal-img] {
|
|
60
|
+
cursor: zoom-out;
|
|
61
|
+
image-rendering: high-quality;
|
|
62
|
+
transform-origin: 0 0;
|
|
63
|
+
transition: transform .3s;
|
|
64
|
+
position: absolute;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@media (prefers-reduced-motion: reduce) {
|
|
68
|
+
[data-rmiz-modal-overlay], [data-rmiz-modal-img] {
|
|
69
|
+
transition-duration: .01ms !important;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Collapsible } from "./ui/collapsible.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
import { TOCItemType } from "fumadocs-core/toc";
|
|
4
|
+
|
|
5
|
+
//#region src/components/inline-toc.d.ts
|
|
6
|
+
interface InlineTocProps extends ComponentProps<typeof Collapsible> {
|
|
7
|
+
items: TOCItemType[];
|
|
8
|
+
}
|
|
9
|
+
declare function InlineTOC({
|
|
10
|
+
items,
|
|
11
|
+
...props
|
|
12
|
+
}: InlineTocProps): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { InlineTOC, InlineTocProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ChevronDown } from "lucide-react";
|
|
6
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
7
|
+
//#region src/components/inline-toc.tsx
|
|
8
|
+
function InlineTOC({ items, ...props }) {
|
|
9
|
+
const t = useTranslations({ note: "inline table of contents" });
|
|
10
|
+
return /* @__PURE__ */ jsxs(Collapsible, {
|
|
11
|
+
...props,
|
|
12
|
+
className: cn("not-prose rounded-3xl bg-fd-card text-fd-card-foreground", props.className),
|
|
13
|
+
children: [/* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
14
|
+
className: "group inline-flex w-full items-center justify-between px-4 py-2.5 font-medium focus-visible:outline-none focus-visible:bg-fd-accent/40 rounded-3xl",
|
|
15
|
+
children: [props.children ?? t("Table of Contents"), /* @__PURE__ */ jsx(ChevronDown, { className: "size-4 transition-transform duration-200 group-data-[state=open]:rotate-180" })]
|
|
16
|
+
}), /* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx("div", {
|
|
17
|
+
className: "flex flex-col p-3 pt-0 text-sm text-fd-muted-foreground",
|
|
18
|
+
children: items.map((item) => /* @__PURE__ */ jsx("a", {
|
|
19
|
+
href: item.url,
|
|
20
|
+
className: "py-1.5 hover:text-fd-accent-foreground transition-colors",
|
|
21
|
+
style: { paddingInlineStart: 12 * Math.max(item.depth - 1, 0) },
|
|
22
|
+
children: item.title
|
|
23
|
+
}, item.url))
|
|
24
|
+
}) })]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { InlineTOC };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { CollapsibleContentProps, CollapsibleTriggerProps } from "../ui/collapsible.js";
|
|
2
|
+
import { ScrollArea, ScrollViewport } from "../ui/scroll-area.js";
|
|
3
|
+
import { LinkProps } from "fumadocs-core/link";
|
|
4
|
+
import { ComponentProps, PointerEvent, ReactNode, RefObject } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/sidebar/base.d.ts
|
|
7
|
+
declare namespace base_d_exports {
|
|
8
|
+
export { SidebarCollapseTrigger, SidebarContent, SidebarDrawerContent, SidebarDrawerOverlay, SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem, SidebarProvider, SidebarProviderProps, SidebarSeparator, SidebarTrigger, SidebarViewport, useAutoScroll, useFolder, useFolderDepth, useSidebar };
|
|
9
|
+
}
|
|
10
|
+
interface SidebarContext {
|
|
11
|
+
open: boolean;
|
|
12
|
+
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
13
|
+
collapsed: boolean;
|
|
14
|
+
setCollapsed: React.Dispatch<React.SetStateAction<boolean>>;
|
|
15
|
+
/**
|
|
16
|
+
* When set to false, don't close the sidebar when navigate to another page
|
|
17
|
+
*/
|
|
18
|
+
closeOnRedirect: RefObject<boolean>;
|
|
19
|
+
defaultOpenLevel: number;
|
|
20
|
+
prefetch?: boolean;
|
|
21
|
+
mode: Mode;
|
|
22
|
+
showIcons: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface SidebarProviderProps {
|
|
25
|
+
/**
|
|
26
|
+
* Open folders by default if their level is lower or equal to a specific level
|
|
27
|
+
* (Starting from 1)
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue 0
|
|
30
|
+
*/
|
|
31
|
+
defaultOpenLevel?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Prefetch links, default behaviour depends on your React.js framework.
|
|
34
|
+
*/
|
|
35
|
+
prefetch?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Show page-tree icons next to sidebar items.
|
|
38
|
+
*
|
|
39
|
+
* @defaultValue false
|
|
40
|
+
*/
|
|
41
|
+
showIcons?: boolean;
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
type Mode = 'drawer' | 'full';
|
|
45
|
+
declare const SidebarContext: import("react").Context<SidebarContext | null>;
|
|
46
|
+
declare function SidebarProvider({
|
|
47
|
+
defaultOpenLevel,
|
|
48
|
+
prefetch,
|
|
49
|
+
showIcons,
|
|
50
|
+
children
|
|
51
|
+
}: SidebarProviderProps): import("react").JSX.Element;
|
|
52
|
+
declare function useSidebar(): SidebarContext;
|
|
53
|
+
declare function useFolder(): {
|
|
54
|
+
open: boolean;
|
|
55
|
+
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
56
|
+
depth: number;
|
|
57
|
+
collapsible: boolean;
|
|
58
|
+
} | null;
|
|
59
|
+
declare function useFolderDepth(): number;
|
|
60
|
+
declare function SidebarContent({
|
|
61
|
+
mode: allowedMode,
|
|
62
|
+
children
|
|
63
|
+
}: {
|
|
64
|
+
mode?: Mode | true;
|
|
65
|
+
children: (state: {
|
|
66
|
+
ref: RefObject<HTMLElement | null>;
|
|
67
|
+
collapsed: boolean;
|
|
68
|
+
hovered: boolean;
|
|
69
|
+
onPointerEnter: (event: PointerEvent) => void;
|
|
70
|
+
onPointerLeave: (event: PointerEvent) => void;
|
|
71
|
+
}) => ReactNode;
|
|
72
|
+
}): ReactNode;
|
|
73
|
+
declare function SidebarViewport({
|
|
74
|
+
area,
|
|
75
|
+
viewport,
|
|
76
|
+
children
|
|
77
|
+
}: {
|
|
78
|
+
area?: ComponentProps<typeof ScrollArea>;
|
|
79
|
+
viewport?: ComponentProps<typeof ScrollViewport>;
|
|
80
|
+
children: ReactNode;
|
|
81
|
+
}): import("react").JSX.Element;
|
|
82
|
+
declare function SidebarDrawerOverlay(props: ComponentProps<'div'>): import("react").JSX.Element | undefined;
|
|
83
|
+
declare function SidebarDrawerContent({
|
|
84
|
+
className,
|
|
85
|
+
children,
|
|
86
|
+
...props
|
|
87
|
+
}: ComponentProps<'aside'>): import("react").JSX.Element | undefined;
|
|
88
|
+
declare function SidebarSeparator(props: ComponentProps<'p'>): import("react").JSX.Element;
|
|
89
|
+
declare function SidebarItem({
|
|
90
|
+
icon,
|
|
91
|
+
active,
|
|
92
|
+
children,
|
|
93
|
+
...props
|
|
94
|
+
}: LinkProps & {
|
|
95
|
+
active?: boolean;
|
|
96
|
+
icon?: ReactNode;
|
|
97
|
+
}): import("react").JSX.Element;
|
|
98
|
+
declare function SidebarFolder({
|
|
99
|
+
defaultOpen: defaultOpenProp,
|
|
100
|
+
collapsible,
|
|
101
|
+
active,
|
|
102
|
+
children,
|
|
103
|
+
...props
|
|
104
|
+
}: ComponentProps<'div'> & {
|
|
105
|
+
active?: boolean;
|
|
106
|
+
defaultOpen?: boolean;
|
|
107
|
+
collapsible?: boolean;
|
|
108
|
+
}): import("react").JSX.Element;
|
|
109
|
+
declare function SidebarFolderTrigger({
|
|
110
|
+
children,
|
|
111
|
+
...props
|
|
112
|
+
}: CollapsibleTriggerProps): import("react").JSX.Element;
|
|
113
|
+
declare function SidebarFolderLink({
|
|
114
|
+
children,
|
|
115
|
+
active,
|
|
116
|
+
...props
|
|
117
|
+
}: LinkProps & {
|
|
118
|
+
active?: boolean;
|
|
119
|
+
}): import("react").JSX.Element;
|
|
120
|
+
declare function SidebarFolderContent(props: CollapsibleContentProps): import("react").JSX.Element;
|
|
121
|
+
declare function SidebarTrigger({
|
|
122
|
+
children,
|
|
123
|
+
...props
|
|
124
|
+
}: ComponentProps<'button'>): import("react").JSX.Element;
|
|
125
|
+
declare function SidebarCollapseTrigger(props: ComponentProps<'button'>): import("react").JSX.Element;
|
|
126
|
+
/**
|
|
127
|
+
* scroll to the element if `active` is true
|
|
128
|
+
*/
|
|
129
|
+
declare function useAutoScroll(active: boolean, ref: RefObject<HTMLElement | null>): void;
|
|
130
|
+
//#endregion
|
|
131
|
+
export { SidebarCollapseTrigger, SidebarContent, SidebarDrawerContent, SidebarDrawerOverlay, SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem, SidebarProvider, SidebarProviderProps, SidebarSeparator, SidebarTrigger, SidebarViewport, base_d_exports, useAutoScroll, useFolder, useFolderDepth, useSidebar };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible.js";
|
|
5
|
+
import { ScrollArea, ScrollViewport } from "../ui/scroll-area.js";
|
|
6
|
+
import Link from "fumadocs-core/link";
|
|
7
|
+
import { usePathname } from "fumadocs-core/framework";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ChevronDown, ExternalLink } from "lucide-react";
|
|
10
|
+
import { createContext, use, useEffect, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
12
|
+
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
13
|
+
import { useMediaQuery } from "fumadocs-core/utils/use-media-query";
|
|
14
|
+
import { Presence } from "@radix-ui/react-presence";
|
|
15
|
+
import scrollIntoView from "scroll-into-view-if-needed";
|
|
16
|
+
//#region src/components/sidebar/base.tsx
|
|
17
|
+
var base_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
+
SidebarCollapseTrigger: () => SidebarCollapseTrigger,
|
|
19
|
+
SidebarContent: () => SidebarContent,
|
|
20
|
+
SidebarDrawerContent: () => SidebarDrawerContent,
|
|
21
|
+
SidebarDrawerOverlay: () => SidebarDrawerOverlay,
|
|
22
|
+
SidebarFolder: () => SidebarFolder,
|
|
23
|
+
SidebarFolderContent: () => SidebarFolderContent,
|
|
24
|
+
SidebarFolderLink: () => SidebarFolderLink,
|
|
25
|
+
SidebarFolderTrigger: () => SidebarFolderTrigger,
|
|
26
|
+
SidebarItem: () => SidebarItem,
|
|
27
|
+
SidebarProvider: () => SidebarProvider,
|
|
28
|
+
SidebarSeparator: () => SidebarSeparator,
|
|
29
|
+
SidebarTrigger: () => SidebarTrigger,
|
|
30
|
+
SidebarViewport: () => SidebarViewport,
|
|
31
|
+
useAutoScroll: () => useAutoScroll,
|
|
32
|
+
useFolder: () => useFolder,
|
|
33
|
+
useFolderDepth: () => useFolderDepth,
|
|
34
|
+
useSidebar: () => useSidebar
|
|
35
|
+
});
|
|
36
|
+
const SidebarContext = createContext(null);
|
|
37
|
+
const FolderContext = createContext(null);
|
|
38
|
+
function SidebarProvider({ defaultOpenLevel = 0, prefetch, showIcons = false, children }) {
|
|
39
|
+
const closeOnRedirect = useRef(true);
|
|
40
|
+
const [open, setOpen] = useState(false);
|
|
41
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
42
|
+
const pathname = usePathname();
|
|
43
|
+
const mode = useMediaQuery("(width < 768px)") ? "drawer" : "full";
|
|
44
|
+
useOnChange(pathname, () => {
|
|
45
|
+
if (closeOnRedirect.current) setOpen(false);
|
|
46
|
+
closeOnRedirect.current = true;
|
|
47
|
+
});
|
|
48
|
+
return /* @__PURE__ */ jsx(SidebarContext, {
|
|
49
|
+
value: useMemo(() => ({
|
|
50
|
+
open,
|
|
51
|
+
setOpen,
|
|
52
|
+
collapsed,
|
|
53
|
+
setCollapsed,
|
|
54
|
+
closeOnRedirect,
|
|
55
|
+
defaultOpenLevel,
|
|
56
|
+
prefetch,
|
|
57
|
+
showIcons,
|
|
58
|
+
mode
|
|
59
|
+
}), [
|
|
60
|
+
open,
|
|
61
|
+
collapsed,
|
|
62
|
+
defaultOpenLevel,
|
|
63
|
+
prefetch,
|
|
64
|
+
showIcons,
|
|
65
|
+
mode
|
|
66
|
+
]),
|
|
67
|
+
children
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function useSidebar() {
|
|
71
|
+
const ctx = use(SidebarContext);
|
|
72
|
+
if (!ctx) throw new Error("Missing SidebarContext, make sure you have wrapped the component in <DocsLayout /> and the context is available.");
|
|
73
|
+
return ctx;
|
|
74
|
+
}
|
|
75
|
+
function useFolder() {
|
|
76
|
+
return use(FolderContext);
|
|
77
|
+
}
|
|
78
|
+
function useFolderDepth() {
|
|
79
|
+
return use(FolderContext)?.depth ?? 0;
|
|
80
|
+
}
|
|
81
|
+
function SidebarContent({ mode: allowedMode = "full", children }) {
|
|
82
|
+
const { collapsed, mode } = useSidebar();
|
|
83
|
+
const [hover, setHover] = useState(false);
|
|
84
|
+
const ref = useRef(null);
|
|
85
|
+
const timerRef = useRef(0);
|
|
86
|
+
useOnChange(collapsed, () => {
|
|
87
|
+
if (collapsed) setHover(false);
|
|
88
|
+
});
|
|
89
|
+
if (allowedMode !== true && allowedMode !== mode) return;
|
|
90
|
+
function shouldIgnoreHover(e) {
|
|
91
|
+
const element = ref.current;
|
|
92
|
+
if (!element) return true;
|
|
93
|
+
return !collapsed || e.pointerType === "touch" || element.getAnimations().length > 0;
|
|
94
|
+
}
|
|
95
|
+
return children({
|
|
96
|
+
ref,
|
|
97
|
+
collapsed,
|
|
98
|
+
hovered: hover,
|
|
99
|
+
onPointerEnter(e) {
|
|
100
|
+
if (shouldIgnoreHover(e)) return;
|
|
101
|
+
window.clearTimeout(timerRef.current);
|
|
102
|
+
setHover(true);
|
|
103
|
+
},
|
|
104
|
+
onPointerLeave(e) {
|
|
105
|
+
if (shouldIgnoreHover(e)) return;
|
|
106
|
+
window.clearTimeout(timerRef.current);
|
|
107
|
+
timerRef.current = window.setTimeout(() => setHover(false), Math.min(e.clientX, document.body.clientWidth - e.clientX) > 100 ? 0 : 500);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function SidebarViewport({ area, viewport, children }) {
|
|
112
|
+
return /* @__PURE__ */ jsx(ScrollArea, {
|
|
113
|
+
...area,
|
|
114
|
+
className: cn("min-h-0 flex-1", area?.className),
|
|
115
|
+
children: /* @__PURE__ */ jsx(ScrollViewport, {
|
|
116
|
+
...viewport,
|
|
117
|
+
className: cn("*:flex! *:flex-col! *:gap-0.5! p-4 overscroll-contain mask-[linear-gradient(to_bottom,transparent,white_12px,white_calc(100%-12px),transparent)]", viewport?.className),
|
|
118
|
+
children
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function SidebarDrawerOverlay(props) {
|
|
123
|
+
const { open, setOpen, mode } = useSidebar();
|
|
124
|
+
if (mode !== "drawer") return;
|
|
125
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
126
|
+
present: open,
|
|
127
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
128
|
+
"data-state": open ? "open" : "closed",
|
|
129
|
+
onClick: () => setOpen(false),
|
|
130
|
+
...props
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function SidebarDrawerContent({ className, children, ...props }) {
|
|
135
|
+
const { open, mode } = useSidebar();
|
|
136
|
+
const state = open ? "open" : "closed";
|
|
137
|
+
if (mode !== "drawer") return;
|
|
138
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
139
|
+
present: open,
|
|
140
|
+
children: ({ present }) => /* @__PURE__ */ jsx("aside", {
|
|
141
|
+
id: "nd-sidebar-mobile",
|
|
142
|
+
"data-state": state,
|
|
143
|
+
className: cn(!present && "invisible", className),
|
|
144
|
+
...props,
|
|
145
|
+
children
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function SidebarSeparator(props) {
|
|
150
|
+
return /* @__PURE__ */ jsx("p", { ...props });
|
|
151
|
+
}
|
|
152
|
+
function SidebarItem({ icon, active = false, children, ...props }) {
|
|
153
|
+
const ref = useRef(null);
|
|
154
|
+
const { prefetch, showIcons } = useSidebar();
|
|
155
|
+
useAutoScroll(active, ref);
|
|
156
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
157
|
+
ref,
|
|
158
|
+
"data-active": active,
|
|
159
|
+
prefetch,
|
|
160
|
+
...props,
|
|
161
|
+
children: [showIcons && (icon ?? (props.external ? /* @__PURE__ */ jsx(ExternalLink, {}) : null)), children]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function SidebarFolder({ defaultOpen: defaultOpenProp, collapsible = true, active = false, children, ...props }) {
|
|
165
|
+
const { defaultOpenLevel } = useSidebar();
|
|
166
|
+
const depth = useFolderDepth() + 1;
|
|
167
|
+
const defaultOpen = collapsible === false || active || (defaultOpenProp ?? defaultOpenLevel >= depth);
|
|
168
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
169
|
+
useOnChange(defaultOpen, (v) => {
|
|
170
|
+
if (v) setOpen(v);
|
|
171
|
+
});
|
|
172
|
+
return /* @__PURE__ */ jsx(Collapsible, {
|
|
173
|
+
open,
|
|
174
|
+
onOpenChange: setOpen,
|
|
175
|
+
disabled: !collapsible,
|
|
176
|
+
...props,
|
|
177
|
+
children: /* @__PURE__ */ jsx(FolderContext, {
|
|
178
|
+
value: useMemo(() => ({
|
|
179
|
+
open,
|
|
180
|
+
setOpen,
|
|
181
|
+
depth,
|
|
182
|
+
collapsible
|
|
183
|
+
}), [
|
|
184
|
+
collapsible,
|
|
185
|
+
depth,
|
|
186
|
+
open
|
|
187
|
+
]),
|
|
188
|
+
children
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function SidebarFolderTrigger({ children, ...props }) {
|
|
193
|
+
const { open, collapsible } = use(FolderContext);
|
|
194
|
+
if (collapsible) return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
195
|
+
...props,
|
|
196
|
+
children: [children, /* @__PURE__ */ jsx(ChevronDown, {
|
|
197
|
+
"data-icon": true,
|
|
198
|
+
className: cn("ms-auto transition-transform", !open && "-rotate-90 rtl:rotate-90")
|
|
199
|
+
})]
|
|
200
|
+
});
|
|
201
|
+
return /* @__PURE__ */ jsx("div", {
|
|
202
|
+
...props,
|
|
203
|
+
children
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function SidebarFolderLink({ children, active = false, ...props }) {
|
|
207
|
+
const ref = useRef(null);
|
|
208
|
+
const { open, setOpen, collapsible } = use(FolderContext);
|
|
209
|
+
const { prefetch } = useSidebar();
|
|
210
|
+
useAutoScroll(active, ref);
|
|
211
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
212
|
+
ref,
|
|
213
|
+
"data-active": active,
|
|
214
|
+
onClick: (e) => {
|
|
215
|
+
if (!collapsible) return;
|
|
216
|
+
if (e.target instanceof Element && e.target.matches("[data-icon], [data-icon] *")) {
|
|
217
|
+
setOpen(!open);
|
|
218
|
+
e.preventDefault();
|
|
219
|
+
} else setOpen(active ? !open : true);
|
|
220
|
+
},
|
|
221
|
+
prefetch,
|
|
222
|
+
...props,
|
|
223
|
+
children: [children, collapsible && /* @__PURE__ */ jsx(ChevronDown, {
|
|
224
|
+
"data-icon": true,
|
|
225
|
+
className: cn("ms-auto transition-transform", !open && "-rotate-90 rtl:rotate-90")
|
|
226
|
+
})]
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function SidebarFolderContent(props) {
|
|
230
|
+
return /* @__PURE__ */ jsx(CollapsibleContent, {
|
|
231
|
+
...props,
|
|
232
|
+
children: props.children
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function SidebarTrigger({ children, ...props }) {
|
|
236
|
+
const { setOpen } = useSidebar();
|
|
237
|
+
return /* @__PURE__ */ jsx("button", {
|
|
238
|
+
"aria-label": useTranslations({ note: "sidebar" })("Open Sidebar", { note: "aria-label" }),
|
|
239
|
+
onClick: () => setOpen((prev) => !prev),
|
|
240
|
+
...props,
|
|
241
|
+
children
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function SidebarCollapseTrigger(props) {
|
|
245
|
+
const { collapsed, setCollapsed } = useSidebar();
|
|
246
|
+
return /* @__PURE__ */ jsx("button", {
|
|
247
|
+
type: "button",
|
|
248
|
+
"aria-label": useTranslations({ note: "sidebar" })("Collapse Sidebar", { note: "aria-label" }),
|
|
249
|
+
"data-collapsed": collapsed,
|
|
250
|
+
onClick: () => {
|
|
251
|
+
setCollapsed((prev) => !prev);
|
|
252
|
+
},
|
|
253
|
+
...props,
|
|
254
|
+
children: props.children
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* scroll to the element if `active` is true
|
|
259
|
+
*/
|
|
260
|
+
function useAutoScroll(active, ref) {
|
|
261
|
+
const { mode } = useSidebar();
|
|
262
|
+
useEffect(() => {
|
|
263
|
+
if (active && ref.current) scrollIntoView(ref.current, {
|
|
264
|
+
boundary: document.getElementById(mode === "drawer" ? "nd-sidebar-mobile" : "nd-sidebar"),
|
|
265
|
+
scrollMode: "if-needed"
|
|
266
|
+
});
|
|
267
|
+
}, [
|
|
268
|
+
active,
|
|
269
|
+
mode,
|
|
270
|
+
ref
|
|
271
|
+
]);
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
export { SidebarCollapseTrigger, SidebarContent, SidebarDrawerContent, SidebarDrawerOverlay, SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem, SidebarProvider, SidebarSeparator, SidebarTrigger, SidebarViewport, base_exports, useAutoScroll, useFolder, useFolderDepth, useSidebar };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { base_d_exports } from "./base.js";
|
|
2
|
+
import { LinkItemType } from "../../layouts/shared/index.js";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/sidebar/link-item.d.ts
|
|
6
|
+
type InternalComponents = Pick<typeof base_d_exports, 'SidebarFolder' | 'SidebarFolderLink' | 'SidebarFolderContent' | 'SidebarFolderTrigger' | 'SidebarItem'>;
|
|
7
|
+
declare function createLinkItemRenderer({
|
|
8
|
+
SidebarFolder,
|
|
9
|
+
SidebarFolderContent,
|
|
10
|
+
SidebarFolderLink,
|
|
11
|
+
SidebarFolderTrigger,
|
|
12
|
+
SidebarItem
|
|
13
|
+
}: InternalComponents): ({
|
|
14
|
+
item,
|
|
15
|
+
...props
|
|
16
|
+
}: HTMLAttributes<HTMLElement> & {
|
|
17
|
+
item: Exclude<LinkItemType, {
|
|
18
|
+
type: "icon";
|
|
19
|
+
}>;
|
|
20
|
+
}) => import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createLinkItemRenderer };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isLinkItemActive } from "../../layouts/shared/index.js";
|
|
3
|
+
import { useSidebar } from "./base.js";
|
|
4
|
+
import { usePathname } from "fumadocs-core/framework";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/sidebar/link-item.tsx
|
|
7
|
+
function createLinkItemRenderer({ SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem }) {
|
|
8
|
+
/**
|
|
9
|
+
* Render sidebar items from page tree
|
|
10
|
+
*/
|
|
11
|
+
return function SidebarLinkItem({ item, ...props }) {
|
|
12
|
+
const active = isLinkItemActive(item, usePathname());
|
|
13
|
+
const { showIcons } = useSidebar();
|
|
14
|
+
if (item.type === "custom") return /* @__PURE__ */ jsx("div", {
|
|
15
|
+
...props,
|
|
16
|
+
children: item.children
|
|
17
|
+
});
|
|
18
|
+
if (item.type === "menu") return /* @__PURE__ */ jsxs(SidebarFolder, {
|
|
19
|
+
...props,
|
|
20
|
+
children: [item.url ? /* @__PURE__ */ jsxs(SidebarFolderLink, {
|
|
21
|
+
href: item.url,
|
|
22
|
+
active,
|
|
23
|
+
external: item.external,
|
|
24
|
+
children: [showIcons && item.icon, item.text]
|
|
25
|
+
}) : /* @__PURE__ */ jsxs(SidebarFolderTrigger, { children: [showIcons && item.icon, item.text] }), /* @__PURE__ */ jsx(SidebarFolderContent, { children: item.items.map((child, i) => /* @__PURE__ */ jsx(SidebarLinkItem, { item: child }, i)) })]
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsx(SidebarItem, {
|
|
28
|
+
href: item.url,
|
|
29
|
+
icon: item.icon,
|
|
30
|
+
external: item.external,
|
|
31
|
+
active,
|
|
32
|
+
...props,
|
|
33
|
+
children: item.text
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createLinkItemRenderer };
|