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,181 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../../utils/cn.js";
|
|
3
|
+
import { TOCScrollArea, toc_exports, useItems, useTOCItems } from "../../../../components/toc/index.js";
|
|
4
|
+
import { default_exports } from "../../../../components/toc/default.js";
|
|
5
|
+
import { clerk_exports } from "../../../../components/toc/clerk.js";
|
|
6
|
+
import { useTreePath } from "../../../../contexts/tree.js";
|
|
7
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../../components/ui/collapsible.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ChevronDown } from "lucide-react";
|
|
10
|
+
import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
13
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
14
|
+
//#region src/layouts/flux/page/slots/toc.tsx
|
|
15
|
+
const TocPopoverContext = createContext(null);
|
|
16
|
+
const { TOCProvider } = toc_exports;
|
|
17
|
+
function TOC({ container, trigger, content, header, footer, style = "normal", list }) {
|
|
18
|
+
const items = useTOCItems();
|
|
19
|
+
const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
|
|
20
|
+
if (items.length === 0 && !header && !footer) return;
|
|
21
|
+
return /* @__PURE__ */ jsxs(PageTOCPopover, {
|
|
22
|
+
...container,
|
|
23
|
+
children: [/* @__PURE__ */ jsxs(PageTOCPopoverContent, {
|
|
24
|
+
...content,
|
|
25
|
+
children: [
|
|
26
|
+
header,
|
|
27
|
+
/* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
28
|
+
...list,
|
|
29
|
+
children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, { item }, item.url))]
|
|
30
|
+
}) }),
|
|
31
|
+
footer
|
|
32
|
+
]
|
|
33
|
+
}), /* @__PURE__ */ jsx(PageTOCPopoverTrigger, { ...trigger })]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function PageTOCPopover(props) {
|
|
37
|
+
const [container, setContainer] = useState(null);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const element = document.getElementById("flux-layout-slot");
|
|
40
|
+
if (!element) return;
|
|
41
|
+
setContainer(element);
|
|
42
|
+
}, []);
|
|
43
|
+
if (!container) return;
|
|
44
|
+
return createPortal(/* @__PURE__ */ jsx(PageTOCPopoverPhysical, { ...props }), container);
|
|
45
|
+
}
|
|
46
|
+
function PageTOCPopoverPhysical({ className, children, ...rest }) {
|
|
47
|
+
const ref = useRef(null);
|
|
48
|
+
const [open, setOpen] = useState(false);
|
|
49
|
+
const onClick = useEffectEvent((e) => {
|
|
50
|
+
if (!open) return;
|
|
51
|
+
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
52
|
+
});
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
window.addEventListener("click", onClick);
|
|
55
|
+
return () => {
|
|
56
|
+
window.removeEventListener("click", onClick);
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
return /* @__PURE__ */ jsx(TocPopoverContext, {
|
|
60
|
+
value: useMemo(() => ({
|
|
61
|
+
open,
|
|
62
|
+
setOpen
|
|
63
|
+
}), [setOpen, open]),
|
|
64
|
+
children: /* @__PURE__ */ jsx(Collapsible, {
|
|
65
|
+
open,
|
|
66
|
+
onOpenChange: setOpen,
|
|
67
|
+
"data-toc-popover": "",
|
|
68
|
+
className: cn("relative h-9 animate-fd-fade-in", className),
|
|
69
|
+
...rest,
|
|
70
|
+
children: /* @__PURE__ */ jsx("header", {
|
|
71
|
+
ref,
|
|
72
|
+
className: cn("absolute w-full bottom-0 border rounded-xl transition-colors bg-fd-secondary text-fd-secondary-foreground backdrop-blur-sm", open && "shadow-lg bg-fd-popover/80 text-fd-popover-foreground"),
|
|
73
|
+
children
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function PageTOCPopoverTrigger({ className, ...props }) {
|
|
79
|
+
const t = useTranslations({ note: "table of contents" });
|
|
80
|
+
const { open } = use(TocPopoverContext);
|
|
81
|
+
const items = useItems();
|
|
82
|
+
const selectedIdx = items.findIndex((item) => item.active);
|
|
83
|
+
const path = useTreePath().at(-1);
|
|
84
|
+
const spanProps = {
|
|
85
|
+
transition: { duration: .1 },
|
|
86
|
+
initial: {
|
|
87
|
+
opacity: 0,
|
|
88
|
+
y: 10
|
|
89
|
+
},
|
|
90
|
+
animate: {
|
|
91
|
+
opacity: 1,
|
|
92
|
+
y: 0
|
|
93
|
+
},
|
|
94
|
+
exit: {
|
|
95
|
+
opacity: 0,
|
|
96
|
+
y: -10
|
|
97
|
+
},
|
|
98
|
+
className: cn(open && "text-fd-popover-foreground")
|
|
99
|
+
};
|
|
100
|
+
return /* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
101
|
+
className: cn("flex w-full h-8.5 items-center text-sm text-fd-muted-foreground gap-2.5 px-2 text-start focus-visible:outline-none [&_svg]:size-4", className),
|
|
102
|
+
"data-toc-popover-trigger": "",
|
|
103
|
+
...props,
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsx(ProgressCircle, {
|
|
106
|
+
value: (items.findLastIndex((item) => item.active) + 1) / Math.max(1, items.length),
|
|
107
|
+
max: 1,
|
|
108
|
+
className: cn("shrink-0", open && "text-fd-primary")
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ jsx(AnimatePresence, {
|
|
111
|
+
mode: "wait",
|
|
112
|
+
children: items[selectedIdx] && !open ? /* @__PURE__ */ jsx(motion.span, {
|
|
113
|
+
...spanProps,
|
|
114
|
+
children: items[selectedIdx].original.title
|
|
115
|
+
}, selectedIdx) : path ? /* @__PURE__ */ jsx(motion.span, {
|
|
116
|
+
...spanProps,
|
|
117
|
+
children: path.name
|
|
118
|
+
}, path.$id ?? ":pathId") : /* @__PURE__ */ jsx(motion.span, {
|
|
119
|
+
...spanProps,
|
|
120
|
+
children: t("On this page")
|
|
121
|
+
}, ":toc")
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: cn("ms-auto shrink-0 transition-transform", open && "rotate-180") })
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function clamp(input, min, max) {
|
|
128
|
+
if (input < min) return min;
|
|
129
|
+
if (input > max) return max;
|
|
130
|
+
return input;
|
|
131
|
+
}
|
|
132
|
+
function ProgressCircle({ value, strokeWidth = 1.5, size = 18, min = 0, max = 100, style, ...restSvgProps }) {
|
|
133
|
+
const normalizedValue = clamp(value, min, max);
|
|
134
|
+
const radius = size / 2 - strokeWidth;
|
|
135
|
+
const circumference = 2 * Math.PI * radius;
|
|
136
|
+
const progress = normalizedValue / max * circumference;
|
|
137
|
+
const circleProps = {
|
|
138
|
+
cx: size / 2,
|
|
139
|
+
cy: size / 2,
|
|
140
|
+
r: radius,
|
|
141
|
+
fill: "none",
|
|
142
|
+
strokeWidth
|
|
143
|
+
};
|
|
144
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
145
|
+
role: "progressbar",
|
|
146
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
147
|
+
"aria-valuenow": normalizedValue,
|
|
148
|
+
"aria-valuemin": min,
|
|
149
|
+
"aria-valuemax": max,
|
|
150
|
+
style: {
|
|
151
|
+
width: size,
|
|
152
|
+
height: size,
|
|
153
|
+
...style
|
|
154
|
+
},
|
|
155
|
+
...restSvgProps,
|
|
156
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
157
|
+
...circleProps,
|
|
158
|
+
className: "stroke-current/25"
|
|
159
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
160
|
+
...circleProps,
|
|
161
|
+
stroke: "currentColor",
|
|
162
|
+
strokeDasharray: circumference,
|
|
163
|
+
strokeDashoffset: circumference - progress,
|
|
164
|
+
strokeLinecap: "round",
|
|
165
|
+
transform: `rotate(-90 ${size / 2} ${size / 2})`,
|
|
166
|
+
className: "transition-all"
|
|
167
|
+
})]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function PageTOCPopoverContent(props) {
|
|
171
|
+
return /* @__PURE__ */ jsx(CollapsibleContent, {
|
|
172
|
+
"data-toc-popover-content": "",
|
|
173
|
+
...props,
|
|
174
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
175
|
+
className: "flex flex-col px-2 max-h-[50vh]",
|
|
176
|
+
children: props.children
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { TOC, TOCProvider };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/layouts/flux/slots/container.tsx
|
|
5
|
+
function Container(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
id: "nd-flux-layout",
|
|
8
|
+
...props,
|
|
9
|
+
className: cn("flex flex-col items-center pb-24 overflow-x-clip", props.className)
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Container };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SidebarProviderProps as SidebarProviderProps$1, useSidebar as useSidebar$1 } from "../../../components/sidebar/base.js";
|
|
2
|
+
import { SidebarPageTreeComponents } from "../../../components/sidebar/page-tree.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/layouts/flux/slots/sidebar.d.ts
|
|
6
|
+
interface SidebarProps extends ComponentProps<'aside'> {
|
|
7
|
+
components?: Partial<SidebarPageTreeComponents>;
|
|
8
|
+
banner?: ReactNode;
|
|
9
|
+
footer?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
type SidebarProviderProps = SidebarProviderProps$1;
|
|
12
|
+
declare const useSidebar: typeof useSidebar$1;
|
|
13
|
+
declare function SidebarProvider(props: SidebarProviderProps): import("react").JSX.Element;
|
|
14
|
+
declare function Sidebar({
|
|
15
|
+
footer,
|
|
16
|
+
banner,
|
|
17
|
+
components,
|
|
18
|
+
...rest
|
|
19
|
+
}: SidebarProps): import("react").JSX.Element;
|
|
20
|
+
declare function SidebarTrigger(props: ComponentProps<'button'>): import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Sidebar, SidebarProps, SidebarProvider, SidebarProviderProps, SidebarTrigger, useSidebar };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { mergeRefs } from "../../../utils/merge-refs.js";
|
|
4
|
+
import { SidebarFolder as SidebarFolder$1, SidebarFolderContent as SidebarFolderContent$1, SidebarFolderLink as SidebarFolderLink$1, SidebarFolderTrigger as SidebarFolderTrigger$1, SidebarItem as SidebarItem$1, SidebarProvider as SidebarProvider$1, SidebarSeparator as SidebarSeparator$1, SidebarViewport, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
|
|
5
|
+
import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
|
|
6
|
+
import { createLinkItemRenderer } from "../../../components/sidebar/link-item.js";
|
|
7
|
+
import { useFluxLayout } from "../index.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { SidebarIcon, XIcon } from "lucide-react";
|
|
10
|
+
import { cva } from "class-variance-authority";
|
|
11
|
+
import { useEffect, useEffectEvent, useRef, useState } from "react";
|
|
12
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
13
|
+
import { RemoveScroll } from "react-remove-scroll";
|
|
14
|
+
//#region src/layouts/flux/slots/sidebar.tsx
|
|
15
|
+
const MotionSidebarItem = motion.create(SidebarItem$1);
|
|
16
|
+
const MotionSidebarFolderTrigger = motion.create(SidebarFolderTrigger$1);
|
|
17
|
+
const MotionSidebarFolderLink = motion.create(SidebarFolderLink$1);
|
|
18
|
+
const MotionSidebarFolderContent = motion.create(SidebarFolderContent$1);
|
|
19
|
+
const itemVariants = cva("relative flex flex-row items-center gap-2 rounded-lg p-2 text-start text-fd-muted-foreground wrap-anywhere [&_svg]:size-4 [&_svg]:shrink-0", { variants: {
|
|
20
|
+
variant: {
|
|
21
|
+
link: "transition-colors hover:bg-fd-accent/50 hover:text-fd-accent-foreground/80 hover:transition-none data-[active=true]:bg-fd-primary/10 data-[active=true]:text-fd-primary data-[active=true]:hover:transition-colors",
|
|
22
|
+
button: "transition-colors hover:bg-fd-accent/50 hover:text-fd-accent-foreground/80 hover:transition-none"
|
|
23
|
+
},
|
|
24
|
+
highlight: { true: "data-[active=true]:before:content-[''] data-[active=true]:before:bg-fd-primary data-[active=true]:before:absolute data-[active=true]:before:w-px data-[active=true]:before:inset-y-2.5 data-[active=true]:before:start-2.5" }
|
|
25
|
+
} });
|
|
26
|
+
function getItemOffset(depth) {
|
|
27
|
+
return `calc(${2 + 3 * depth} * var(--spacing))`;
|
|
28
|
+
}
|
|
29
|
+
const { useSidebar } = base_exports;
|
|
30
|
+
function SidebarProvider(props) {
|
|
31
|
+
return /* @__PURE__ */ jsx(SidebarProvider$1, { ...props });
|
|
32
|
+
}
|
|
33
|
+
function Sidebar({ footer, banner, components, ...rest }) {
|
|
34
|
+
const { menuItems } = useFluxLayout();
|
|
35
|
+
return /* @__PURE__ */ jsxs(SidebarContent, {
|
|
36
|
+
...rest,
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: "flex flex-col gap-3 p-4 pb-2 empty:hidden",
|
|
40
|
+
children: banner
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ jsxs(SidebarViewport, {
|
|
43
|
+
viewport: { className: "*:gap-0!" },
|
|
44
|
+
children: [menuItems.filter((v) => v.type !== "icon").map((item, i, list) => /* @__PURE__ */ jsx(SidebarLinkItem, {
|
|
45
|
+
item,
|
|
46
|
+
className: cn(i === list.length - 1 && "mb-4")
|
|
47
|
+
}, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })]
|
|
48
|
+
}),
|
|
49
|
+
footer
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function SidebarTrigger(props) {
|
|
54
|
+
const { open, setOpen } = useSidebar();
|
|
55
|
+
return /* @__PURE__ */ jsx("button", {
|
|
56
|
+
onClick: () => setOpen((prev) => !prev),
|
|
57
|
+
...props,
|
|
58
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
59
|
+
mode: "wait",
|
|
60
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
61
|
+
transition: { duration: .2 },
|
|
62
|
+
initial: {
|
|
63
|
+
y: "100%",
|
|
64
|
+
opacity: 0
|
|
65
|
+
},
|
|
66
|
+
animate: {
|
|
67
|
+
y: 0,
|
|
68
|
+
opacity: 1
|
|
69
|
+
},
|
|
70
|
+
exit: {
|
|
71
|
+
y: "100%",
|
|
72
|
+
opacity: 0
|
|
73
|
+
},
|
|
74
|
+
children: open ? /* @__PURE__ */ jsx(XIcon, {}) : /* @__PURE__ */ jsx(SidebarIcon, {})
|
|
75
|
+
}, open ? "open" : "closed")
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function SidebarContent({ ref: refProp, className, children, ...props }) {
|
|
80
|
+
const ref = useRef(null);
|
|
81
|
+
const [blockScroll, setBlockScroll] = useState(false);
|
|
82
|
+
const { open, setOpen } = useSidebar();
|
|
83
|
+
const listener = useEffectEvent((e) => {
|
|
84
|
+
if (open && e.key === "Escape") {
|
|
85
|
+
setOpen(false);
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
window.addEventListener("keydown", listener);
|
|
91
|
+
return () => {
|
|
92
|
+
window.removeEventListener("keydown", listener);
|
|
93
|
+
};
|
|
94
|
+
}, []);
|
|
95
|
+
if (open && !blockScroll) setBlockScroll(true);
|
|
96
|
+
return /* @__PURE__ */ jsx(RemoveScroll, {
|
|
97
|
+
enabled: blockScroll,
|
|
98
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
99
|
+
className: cn("fixed inset-0 py-10 z-30 backdrop-blur-md bg-fd-background/60", !open && "pointer-events-none"),
|
|
100
|
+
initial: "hide",
|
|
101
|
+
variants: {
|
|
102
|
+
show: { opacity: 1 },
|
|
103
|
+
hide: { opacity: 0 }
|
|
104
|
+
},
|
|
105
|
+
animate: open ? "show" : "hide",
|
|
106
|
+
exit: "hide",
|
|
107
|
+
onClick: () => {
|
|
108
|
+
setOpen(false);
|
|
109
|
+
},
|
|
110
|
+
onAnimationComplete: (definition) => {
|
|
111
|
+
if (definition === "hide") setBlockScroll(false);
|
|
112
|
+
},
|
|
113
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
114
|
+
className: "absolute top-0 min-h-0 inset-x-0 bottom-26 overflow-y-auto fd-scroll-container pr-(--removed-body-scroll-bar-size,0) py-16 mask-[linear-gradient(to_bottom,transparent,white_--spacing(14),white_calc(100%---spacing(14)),transparent)] lg:text-sm",
|
|
115
|
+
variants: {
|
|
116
|
+
show: {
|
|
117
|
+
y: 0,
|
|
118
|
+
opacity: 1
|
|
119
|
+
},
|
|
120
|
+
hide: {
|
|
121
|
+
y: "80%",
|
|
122
|
+
opacity: 0
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
transition: {
|
|
126
|
+
duration: .4,
|
|
127
|
+
ease: [
|
|
128
|
+
.16,
|
|
129
|
+
1,
|
|
130
|
+
.3,
|
|
131
|
+
1
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
children: /* @__PURE__ */ jsx(motion.aside, {
|
|
135
|
+
id: "nd-sidebar",
|
|
136
|
+
ref: mergeRefs(ref, refProp),
|
|
137
|
+
className: cn("mx-auto sm:max-w-[400px]", className),
|
|
138
|
+
onClick: (e) => e.stopPropagation(),
|
|
139
|
+
...props,
|
|
140
|
+
children
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function SidebarFolder(props) {
|
|
147
|
+
return /* @__PURE__ */ jsx(SidebarFolder$1, { ...props });
|
|
148
|
+
}
|
|
149
|
+
function SidebarSeparator({ className, style, children, ...props }) {
|
|
150
|
+
const depth = useFolderDepth();
|
|
151
|
+
return /* @__PURE__ */ jsx(SidebarSeparator$1, {
|
|
152
|
+
className: cn("inline-flex items-center gap-2 mb-1.5 px-2 mt-6 empty:mb-0 [&_svg]:size-4 [&_svg]:shrink-0", depth === 0 && "first:mt-0", className),
|
|
153
|
+
style: {
|
|
154
|
+
paddingInlineStart: getItemOffset(depth),
|
|
155
|
+
...style
|
|
156
|
+
},
|
|
157
|
+
...props,
|
|
158
|
+
children
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function SidebarItem({ className, style, children, ...props }) {
|
|
162
|
+
const depth = useFolderDepth();
|
|
163
|
+
return /* @__PURE__ */ jsx(MotionSidebarItem, {
|
|
164
|
+
className: cn(itemVariants({
|
|
165
|
+
variant: "link",
|
|
166
|
+
highlight: depth >= 1
|
|
167
|
+
}), className),
|
|
168
|
+
style: {
|
|
169
|
+
paddingInlineStart: getItemOffset(depth),
|
|
170
|
+
...style
|
|
171
|
+
},
|
|
172
|
+
...props,
|
|
173
|
+
children
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function SidebarFolderTrigger({ className, style, ...props }) {
|
|
177
|
+
const { depth, collapsible } = useFolder();
|
|
178
|
+
return /* @__PURE__ */ jsx(MotionSidebarFolderTrigger, {
|
|
179
|
+
className: cn(itemVariants({ variant: collapsible ? "button" : null }), "w-full", className),
|
|
180
|
+
style: {
|
|
181
|
+
paddingInlineStart: getItemOffset(depth - 1),
|
|
182
|
+
...style
|
|
183
|
+
},
|
|
184
|
+
...props,
|
|
185
|
+
children: props.children
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function SidebarFolderLink({ className, style, ...props }) {
|
|
189
|
+
const depth = useFolderDepth();
|
|
190
|
+
return /* @__PURE__ */ jsx(MotionSidebarFolderLink, {
|
|
191
|
+
className: cn(itemVariants({
|
|
192
|
+
variant: "link",
|
|
193
|
+
highlight: depth > 1
|
|
194
|
+
}), "w-full", className),
|
|
195
|
+
style: {
|
|
196
|
+
paddingInlineStart: getItemOffset(depth - 1),
|
|
197
|
+
...style
|
|
198
|
+
},
|
|
199
|
+
...props,
|
|
200
|
+
children: props.children
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function SidebarFolderContent({ className, children, ...props }) {
|
|
204
|
+
const depth = useFolderDepth();
|
|
205
|
+
const { open } = useFolder();
|
|
206
|
+
return /* @__PURE__ */ jsx(MotionSidebarFolderContent, {
|
|
207
|
+
className: cn("relative", depth === 1 && "before:content-[''] before:absolute before:w-px before:inset-y-1 before:bg-fd-border before:start-2.5", className),
|
|
208
|
+
...props,
|
|
209
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
210
|
+
initial: "hide",
|
|
211
|
+
animate: open ? "show" : "hide",
|
|
212
|
+
exit: "hide",
|
|
213
|
+
variants: {
|
|
214
|
+
show: { opacity: 1 },
|
|
215
|
+
hide: { opacity: 0 }
|
|
216
|
+
},
|
|
217
|
+
children
|
|
218
|
+
})
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const SidebarPageTree = createPageTreeRenderer({
|
|
222
|
+
SidebarFolder,
|
|
223
|
+
SidebarFolderContent,
|
|
224
|
+
SidebarSeparator,
|
|
225
|
+
SidebarFolderLink,
|
|
226
|
+
SidebarFolderTrigger,
|
|
227
|
+
SidebarItem
|
|
228
|
+
});
|
|
229
|
+
const SidebarLinkItem = createLinkItemRenderer({
|
|
230
|
+
SidebarFolder,
|
|
231
|
+
SidebarFolderContent,
|
|
232
|
+
SidebarFolderLink,
|
|
233
|
+
SidebarFolderTrigger,
|
|
234
|
+
SidebarItem
|
|
235
|
+
});
|
|
236
|
+
//#endregion
|
|
237
|
+
export { Sidebar, SidebarProvider, SidebarTrigger, useSidebar };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LayoutTab } from "../../shared/index.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/layouts/flux/slots/tab-dropdown.d.ts
|
|
5
|
+
interface TabDropdownProps extends ComponentProps<'button'> {
|
|
6
|
+
placeholder?: ReactNode;
|
|
7
|
+
tabs: LayoutTab[];
|
|
8
|
+
}
|
|
9
|
+
declare function TabDropdown({
|
|
10
|
+
tabs,
|
|
11
|
+
placeholder,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: TabDropdownProps): import("react").JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { TabDropdown, TabDropdownProps };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../../components/ui/popover.js";
|
|
4
|
+
import { isLayoutTabActive } from "../../shared/index.js";
|
|
5
|
+
import Link from "fumadocs-core/link";
|
|
6
|
+
import { usePathname } from "fumadocs-core/framework";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
9
|
+
import { useMemo, useState } from "react";
|
|
10
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
11
|
+
//#region src/layouts/flux/slots/tab-dropdown.tsx
|
|
12
|
+
function TabDropdown({ tabs, placeholder, className, ...props }) {
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
const pathname = usePathname();
|
|
15
|
+
const selectedIdx = useMemo(() => {
|
|
16
|
+
return tabs.findLastIndex((item) => isLayoutTabActive(item, pathname));
|
|
17
|
+
}, [tabs, pathname]);
|
|
18
|
+
const selected = selectedIdx !== -1 ? tabs[selectedIdx] : void 0;
|
|
19
|
+
const onClick = () => {
|
|
20
|
+
setOpen(false);
|
|
21
|
+
};
|
|
22
|
+
const item = selected ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
23
|
+
className: "size-4.5 shrink-0 empty:hidden",
|
|
24
|
+
children: selected.icon
|
|
25
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
26
|
+
className: "font-medium",
|
|
27
|
+
children: selected.title
|
|
28
|
+
})] }) : placeholder;
|
|
29
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
30
|
+
open,
|
|
31
|
+
onOpenChange: setOpen,
|
|
32
|
+
children: [item && /* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
33
|
+
className: cn("flex items-center gap-2 rounded-xl overflow-hidden p-1.5 border shadow-sm text-sm text-start transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground data-[state=open]:bg-fd-accent data-[state=open]:text-fd-accent-foreground", className),
|
|
34
|
+
...props,
|
|
35
|
+
children: [/* @__PURE__ */ jsx(AnimatePresence, {
|
|
36
|
+
mode: "popLayout",
|
|
37
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
38
|
+
className: "flex w-full min-w-0 overflow-hidden items-center text-nowrap gap-1.5",
|
|
39
|
+
initial: {
|
|
40
|
+
opacity: 0,
|
|
41
|
+
y: "100%"
|
|
42
|
+
},
|
|
43
|
+
animate: {
|
|
44
|
+
opacity: 1,
|
|
45
|
+
y: 0
|
|
46
|
+
},
|
|
47
|
+
exit: {
|
|
48
|
+
opacity: 0,
|
|
49
|
+
y: "-100%"
|
|
50
|
+
},
|
|
51
|
+
children: item
|
|
52
|
+
}, selectedIdx)
|
|
53
|
+
}), /* @__PURE__ */ jsx(ChevronsUpDown, { className: "shrink-0 ms-auto size-4 text-fd-muted-foreground" })]
|
|
54
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
55
|
+
align: "start",
|
|
56
|
+
className: "flex flex-col gap-1 max-w-svw p-1 fd-scroll-container",
|
|
57
|
+
children: tabs.map((item, i) => {
|
|
58
|
+
const isActive = i === selectedIdx;
|
|
59
|
+
if (!isActive && item.unlisted) return;
|
|
60
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
61
|
+
href: item.url,
|
|
62
|
+
onClick,
|
|
63
|
+
...item.props,
|
|
64
|
+
className: cn("flex items-center gap-1.5 rounded-lg p-1.5 hover:bg-fd-accent hover:text-fd-accent-foreground", item.props?.className),
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: "shrink-0 mb-auto size-4.5 empty:hidden",
|
|
68
|
+
children: item.icon
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
71
|
+
className: "text-sm font-medium leading-none",
|
|
72
|
+
children: item.title
|
|
73
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
74
|
+
className: "text-[0.8125rem] text-fd-muted-foreground mt-1 empty:hidden",
|
|
75
|
+
children: item.description
|
|
76
|
+
})] }),
|
|
77
|
+
/* @__PURE__ */ jsx(Check, { className: cn("shrink-0 ms-auto size-3.5 text-fd-primary", !isActive && "invisible") })
|
|
78
|
+
]
|
|
79
|
+
}, item.url);
|
|
80
|
+
})
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { TabDropdown };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseSlots, BaseSlotsProps } from "../shared/client.js";
|
|
2
|
+
import { BaseLayoutProps, LinkItemType, NavOptions } from "../shared/index.js";
|
|
3
|
+
import { ComponentProps, FC } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/layouts/home/index.d.ts
|
|
6
|
+
interface HomeLayoutProps extends BaseLayoutProps, ComponentProps<'main'> {
|
|
7
|
+
nav?: Nav;
|
|
8
|
+
slots?: Partial<HomeSlots>;
|
|
9
|
+
}
|
|
10
|
+
interface Nav extends NavOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Open mobile menu when hovering the trigger
|
|
13
|
+
*/
|
|
14
|
+
enableHoverToOpen?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface HomeSlots extends BaseSlots {
|
|
17
|
+
header: FC<ComponentProps<'header'>>;
|
|
18
|
+
container: FC<ComponentProps<'main'>>;
|
|
19
|
+
}
|
|
20
|
+
declare function useHomeLayout(): {
|
|
21
|
+
props: BaseSlotsProps<HomeLayoutProps>;
|
|
22
|
+
navItems: LinkItemType[];
|
|
23
|
+
menuItems: LinkItemType[];
|
|
24
|
+
slots: HomeSlots;
|
|
25
|
+
};
|
|
26
|
+
declare function HomeLayout(props: HomeLayoutProps): import("react").JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { HomeLayout, HomeLayoutProps, HomeSlots, useHomeLayout };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { baseSlots } from "../shared/client.js";
|
|
3
|
+
import { useLinkItems } from "../shared/index.js";
|
|
4
|
+
import { Container } from "./slots/container.js";
|
|
5
|
+
import { Header } from "./slots/header.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { createContext, use } from "react";
|
|
8
|
+
//#region src/layouts/home/index.tsx
|
|
9
|
+
const LayoutContext = createContext(null);
|
|
10
|
+
function useHomeLayout() {
|
|
11
|
+
const context = use(LayoutContext);
|
|
12
|
+
if (!context) throw new Error("Please use this component under <HomeLayout /> (`opin-ui/layouts/home`).");
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
const { useProvider } = baseSlots({ useProps() {
|
|
16
|
+
return useHomeLayout().props;
|
|
17
|
+
} });
|
|
18
|
+
function HomeLayout(props) {
|
|
19
|
+
const { nav: { enabled: navEnabled = true } = {}, slots: defaultSlots, children, i18n: _i18n, githubUrl: _githubUrl, links: _links, themeSwitch: _themeSwitch, searchToggle: _searchToggle, ...rest } = props;
|
|
20
|
+
const { baseSlots, baseProps } = useProvider(props);
|
|
21
|
+
const linkItems = useLinkItems(props);
|
|
22
|
+
const slots = {
|
|
23
|
+
...baseSlots,
|
|
24
|
+
header: defaultSlots?.header ?? Header,
|
|
25
|
+
container: defaultSlots?.container ?? Container
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ jsx(LayoutContext, {
|
|
28
|
+
value: {
|
|
29
|
+
props: baseProps,
|
|
30
|
+
slots,
|
|
31
|
+
...linkItems
|
|
32
|
+
},
|
|
33
|
+
children: /* @__PURE__ */ jsxs(slots.container, {
|
|
34
|
+
...rest,
|
|
35
|
+
children: [navEnabled && /* @__PURE__ */ jsx(slots.header, {}), children]
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { HomeLayout, useHomeLayout };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NavigationMenuContentProps, NavigationMenuItem, NavigationMenuTriggerProps } from "../../components/ui/navigation-menu.js";
|
|
2
|
+
import { LinkProps } from "fumadocs-core/link";
|
|
3
|
+
|
|
4
|
+
//#region src/layouts/home/navbar.d.ts
|
|
5
|
+
declare const NavbarMenu: typeof NavigationMenuItem;
|
|
6
|
+
declare function NavbarMenuContent(props: NavigationMenuContentProps): import("react").JSX.Element;
|
|
7
|
+
declare function NavbarMenuTrigger(props: NavigationMenuTriggerProps): import("react").JSX.Element;
|
|
8
|
+
declare function NavbarMenuLink(props: LinkProps): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { NavbarMenu, NavbarMenuContent, NavbarMenuLink, NavbarMenuTrigger };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuTrigger } from "../../components/ui/navigation-menu.js";
|
|
4
|
+
import { navItemVariants } from "./slots/header.js";
|
|
5
|
+
import Link from "fumadocs-core/link";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/layouts/home/navbar.tsx
|
|
8
|
+
const NavbarMenu = NavigationMenuItem;
|
|
9
|
+
function NavbarMenuContent(props) {
|
|
10
|
+
return /* @__PURE__ */ jsx(NavigationMenuContent, {
|
|
11
|
+
...props,
|
|
12
|
+
className: cn("grid grid-cols-1 gap-2 p-4 md:grid-cols-2 lg:grid-cols-3", props.className),
|
|
13
|
+
children: props.children
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function NavbarMenuTrigger(props) {
|
|
17
|
+
return /* @__PURE__ */ jsx(NavigationMenuTrigger, {
|
|
18
|
+
...props,
|
|
19
|
+
className: cn(navItemVariants(), "text-sm rounded-md", props.className),
|
|
20
|
+
children: props.children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function NavbarMenuLink(props) {
|
|
24
|
+
return /* @__PURE__ */ jsx(NavigationMenuLink, {
|
|
25
|
+
asChild: true,
|
|
26
|
+
children: /* @__PURE__ */ jsx(Link, {
|
|
27
|
+
...props,
|
|
28
|
+
className: cn("flex flex-col gap-2 rounded-lg border bg-fd-card p-3 transition-colors hover:bg-fd-accent/80 hover:text-fd-accent-foreground", props.className),
|
|
29
|
+
children: props.children
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { NavbarMenu, NavbarMenuContent, NavbarMenuLink, NavbarMenuTrigger };
|