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,73 @@
|
|
|
1
|
+
import { BaseSlots, BaseSlotsProps } from "../shared/client.js";
|
|
2
|
+
import { BaseLayoutProps, GetLayoutTabsOptions, LayoutTab, LinkItemType } from "../shared/index.js";
|
|
3
|
+
import { TabDropdownProps } from "./slots/tab-dropdown.js";
|
|
4
|
+
import { SidebarProps, SidebarProviderProps } from "./slots/sidebar.js";
|
|
5
|
+
import { ComponentProps, FC, ReactNode } from "react";
|
|
6
|
+
import * as PageTree from "fumadocs-core/page-tree";
|
|
7
|
+
import { motion } from "motion/react";
|
|
8
|
+
|
|
9
|
+
//#region src/layouts/flux/index.d.ts
|
|
10
|
+
interface DocsSlots extends BaseSlots {
|
|
11
|
+
container: FC<ComponentProps<'div'>>;
|
|
12
|
+
tabDropdown: FC<TabDropdownProps>;
|
|
13
|
+
sidebar: {
|
|
14
|
+
provider: FC<SidebarProviderProps>;
|
|
15
|
+
trigger: FC<ComponentProps<'button'>>;
|
|
16
|
+
root: FC<SidebarProps>;
|
|
17
|
+
useSidebar: () => {
|
|
18
|
+
collapsed: boolean;
|
|
19
|
+
open: boolean;
|
|
20
|
+
setOpen: (v: boolean) => void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
interface DocsLayoutProps extends BaseLayoutProps {
|
|
25
|
+
tree: PageTree.Root;
|
|
26
|
+
sidebar?: SidebarOptions;
|
|
27
|
+
tabs?: LayoutTab[] | GetLayoutTabsOptions | false;
|
|
28
|
+
slots?: Partial<DocsSlots>;
|
|
29
|
+
renderNavigationPanel?: (props: NavigationPanelProps) => ReactNode;
|
|
30
|
+
containerProps?: ComponentProps<'div'>;
|
|
31
|
+
}
|
|
32
|
+
interface SidebarOptions extends SidebarProps, SidebarProviderProps {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated use layout-level `tabs` instead.
|
|
36
|
+
*/
|
|
37
|
+
tabs?: LayoutTab[] | GetLayoutTabsOptions | false;
|
|
38
|
+
}
|
|
39
|
+
declare function useFluxLayout(): {
|
|
40
|
+
props: BaseSlotsProps;
|
|
41
|
+
menuItems: LinkItemType[];
|
|
42
|
+
navItems: LinkItemType[];
|
|
43
|
+
slots: DocsSlots;
|
|
44
|
+
};
|
|
45
|
+
declare function DocsLayout(props: DocsLayoutProps): import("react").JSX.Element;
|
|
46
|
+
interface NavigationPanelProps {
|
|
47
|
+
head: ReactNode;
|
|
48
|
+
tabDropdown: ReactNode;
|
|
49
|
+
tool: ReactNode;
|
|
50
|
+
link: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
declare function NavigationPanel({
|
|
53
|
+
head,
|
|
54
|
+
tabDropdown,
|
|
55
|
+
tool,
|
|
56
|
+
link,
|
|
57
|
+
children,
|
|
58
|
+
...props
|
|
59
|
+
}: NavigationPanelProps & Omit<ComponentProps<typeof motion.div>, 'children'> & {
|
|
60
|
+
/**
|
|
61
|
+
* replace default children
|
|
62
|
+
*/
|
|
63
|
+
children?: (defaultChildren: ReactNode) => ReactNode;
|
|
64
|
+
}): import("react").JSX.Element;
|
|
65
|
+
declare function NavigationPanelOverlay({
|
|
66
|
+
enabled,
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: ComponentProps<typeof motion.div> & {
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
}): import("react").JSX.Element;
|
|
72
|
+
//#endregion
|
|
73
|
+
export { DocsLayout, DocsLayoutProps, DocsSlots, NavigationPanel, NavigationPanelOverlay, NavigationPanelProps, useFluxLayout };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "../../components/ui/button.js";
|
|
4
|
+
import { TreeContextProvider } from "../../contexts/tree.js";
|
|
5
|
+
import { useSearchContext } from "../../contexts/search.js";
|
|
6
|
+
import { LinkItem, baseSlots } from "../shared/client.js";
|
|
7
|
+
import { getLayoutTabs, useLinkItems } from "../shared/index.js";
|
|
8
|
+
import { TabDropdown } from "./slots/tab-dropdown.js";
|
|
9
|
+
import { Sidebar as Sidebar$1, SidebarProvider, SidebarTrigger, useSidebar } from "./slots/sidebar.js";
|
|
10
|
+
import { Container } from "./slots/container.js";
|
|
11
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Languages } from "lucide-react";
|
|
13
|
+
import { createContext, use, useMemo } from "react";
|
|
14
|
+
import { motion } from "motion/react";
|
|
15
|
+
import { RemoveScroll } from "react-remove-scroll";
|
|
16
|
+
//#region src/layouts/flux/index.tsx
|
|
17
|
+
const LayoutContext = createContext(null);
|
|
18
|
+
function useFluxLayout() {
|
|
19
|
+
const context = use(LayoutContext);
|
|
20
|
+
if (!context) throw new Error("Please use Flux layout components under <DocsLayout /> (`opin-ui/layouts/flux`).");
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
const { useProvider } = baseSlots({ useProps() {
|
|
24
|
+
return useFluxLayout().props;
|
|
25
|
+
} });
|
|
26
|
+
function DocsLayout(props) {
|
|
27
|
+
const { tree, nav = {}, sidebar: { enabled: sidebarEnabled = true, tabs: _tabs, defaultOpenLevel, prefetch, ...sidebarProps } = {}, tabs: defaultTabs = _tabs, children, containerProps, renderNavigationPanel = (props) => /* @__PURE__ */ jsx(NavigationPanel, { ...props }), slots: defaultSlots = {} } = props;
|
|
28
|
+
const linkItems = useLinkItems(props);
|
|
29
|
+
const { baseSlots, baseProps } = useProvider(props);
|
|
30
|
+
const tabs = useMemo(() => {
|
|
31
|
+
if (Array.isArray(defaultTabs)) return defaultTabs;
|
|
32
|
+
if (typeof defaultTabs === "object") return getLayoutTabs(tree, defaultTabs);
|
|
33
|
+
if (defaultTabs !== false) return getLayoutTabs(tree);
|
|
34
|
+
return [];
|
|
35
|
+
}, [tree, defaultTabs]);
|
|
36
|
+
const slots = {
|
|
37
|
+
...baseSlots,
|
|
38
|
+
container: defaultSlots.container ?? Container,
|
|
39
|
+
tabDropdown: defaultSlots.tabDropdown ?? TabDropdown,
|
|
40
|
+
sidebar: defaultSlots.sidebar ?? {
|
|
41
|
+
root: Sidebar$1,
|
|
42
|
+
provider: SidebarProvider,
|
|
43
|
+
trigger: SidebarTrigger,
|
|
44
|
+
useSidebar
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ jsx(LayoutContext, {
|
|
48
|
+
value: {
|
|
49
|
+
props: baseProps,
|
|
50
|
+
slots,
|
|
51
|
+
...linkItems
|
|
52
|
+
},
|
|
53
|
+
children: /* @__PURE__ */ jsxs(TreeContextProvider, {
|
|
54
|
+
tree,
|
|
55
|
+
children: [/* @__PURE__ */ jsx(slots.sidebar.provider, {
|
|
56
|
+
defaultOpenLevel,
|
|
57
|
+
prefetch,
|
|
58
|
+
children: /* @__PURE__ */ jsxs(slots.container, {
|
|
59
|
+
...containerProps,
|
|
60
|
+
children: [sidebarEnabled && /* @__PURE__ */ jsx(slots.sidebar.root, { ...sidebarProps }), children]
|
|
61
|
+
})
|
|
62
|
+
}), renderNavigationPanel({
|
|
63
|
+
head: /* @__PURE__ */ jsxs(Fragment, { children: [slots.navTitle && /* @__PURE__ */ jsx(slots.navTitle, { className: "inline-flex items-center gap-2.5 text-sm font-semibold" }), nav.children] }),
|
|
64
|
+
tabDropdown: slots.tabDropdown && tabs.length > 0 && /* @__PURE__ */ jsx(slots.tabDropdown, {
|
|
65
|
+
className: "flex-1",
|
|
66
|
+
tabs
|
|
67
|
+
}),
|
|
68
|
+
tool: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
69
|
+
slots.languageSelect && /* @__PURE__ */ jsx(slots.languageSelect.root, { children: /* @__PURE__ */ jsx(Languages, { className: "size-4.5" }) }),
|
|
70
|
+
slots.searchTrigger && /* @__PURE__ */ jsx(slots.searchTrigger.sm, {
|
|
71
|
+
hideIfDisabled: true,
|
|
72
|
+
className: "rounded-lg"
|
|
73
|
+
}),
|
|
74
|
+
slots.sidebar && /* @__PURE__ */ jsx(slots.sidebar.trigger, { className: cn(buttonVariants({
|
|
75
|
+
variant: "ghost",
|
|
76
|
+
size: "icon-sm",
|
|
77
|
+
className: "overflow-hidden"
|
|
78
|
+
})) }),
|
|
79
|
+
slots.themeSwitch && /* @__PURE__ */ jsx(slots.themeSwitch, { className: "p-1 h-full ms-1 rounded-xl bg-fd-muted *:rounded-lg" })
|
|
80
|
+
] }),
|
|
81
|
+
link: linkItems.menuItems.filter((item) => item.type === "icon").map((item, i) => /* @__PURE__ */ jsx(LinkItem, {
|
|
82
|
+
item,
|
|
83
|
+
className: cn(buttonVariants({
|
|
84
|
+
size: "icon-sm",
|
|
85
|
+
color: "ghost"
|
|
86
|
+
})),
|
|
87
|
+
"aria-label": item.label,
|
|
88
|
+
children: item.icon
|
|
89
|
+
}, i))
|
|
90
|
+
})]
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function NavigationPanel({ head, tabDropdown, tool, link, children = (v) => v, ...props }) {
|
|
95
|
+
const { open } = useSearchContext();
|
|
96
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
97
|
+
...props,
|
|
98
|
+
className: cn("fixed left-1/2 w-[calc(100%-var(--removed-body-scroll-bar-size,0px))] translate-x-[calc(-50%-var(--removed-body-scroll-bar-size,0px)/2)] bottom-0 z-40 bg-fd-popover text-fd-popover-foreground border-t shadow-lg sm:bottom-6 sm:rounded-2xl sm:border sm:max-w-[380px]", props.className),
|
|
99
|
+
animate: props.animate ?? {
|
|
100
|
+
scale: open ? .9 : 1,
|
|
101
|
+
translateY: open ? 20 : 0,
|
|
102
|
+
opacity: open ? .8 : 1
|
|
103
|
+
},
|
|
104
|
+
children: children(/* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
105
|
+
className: "flex flex-row items-center ps-2.5 p-1 gap-2 min-h-11",
|
|
106
|
+
children: [head, /* @__PURE__ */ jsx("div", {
|
|
107
|
+
id: "flux-layout-slot",
|
|
108
|
+
className: "flex-1"
|
|
109
|
+
})]
|
|
110
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
111
|
+
className: "flex flex-row gap-1.5 overflow-x-auto overflow-y-hidden p-2 sm:p-1",
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx("div", {
|
|
114
|
+
className: "flex flex-row items-center gap-2 min-w-0 flex-1",
|
|
115
|
+
children: tabDropdown
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx("div", {
|
|
118
|
+
className: "flex flex-row items-center text-fd-muted-foreground border-x px-0.5 empty:hidden",
|
|
119
|
+
children: link
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: "flex flex-row items-center text-fd-muted-foreground empty:hidden",
|
|
123
|
+
children: tool
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
})] }))
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function NavigationPanelOverlay({ enabled = false, className, ...props }) {
|
|
130
|
+
return /* @__PURE__ */ jsx(RemoveScroll, {
|
|
131
|
+
enabled,
|
|
132
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
133
|
+
className: cn("fixed inset-0 z-30 pr-(--removed-body-scroll-bar-size,0) backdrop-blur-md bg-fd-background/60", !enabled && "pointer-events-none", className),
|
|
134
|
+
initial: "hide",
|
|
135
|
+
variants: {
|
|
136
|
+
show: { opacity: 1 },
|
|
137
|
+
hide: { opacity: 0 }
|
|
138
|
+
},
|
|
139
|
+
animate: enabled ? "show" : "hide",
|
|
140
|
+
exit: "hide",
|
|
141
|
+
...props
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { DocsLayout, NavigationPanel, NavigationPanelOverlay, useFluxLayout };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
|
|
2
|
+
import { TOCProps, TOCProviderProps } from "./slots/toc.js";
|
|
3
|
+
import { Footer, FooterProps } from "./slots/footer.js";
|
|
4
|
+
import { Breadcrumb, BreadcrumbProps } from "./slots/breadcrumb.js";
|
|
5
|
+
import { ComponentProps, FC, ReactNode } from "react";
|
|
6
|
+
import { TOCItemType } from "fumadocs-core/toc";
|
|
7
|
+
|
|
8
|
+
//#region src/layouts/flux/page/index.d.ts
|
|
9
|
+
interface DocsPageProps extends ComponentProps<'article'> {
|
|
10
|
+
toc?: TOCItemType[];
|
|
11
|
+
/**
|
|
12
|
+
* Extend the page to fill all available space
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue false
|
|
15
|
+
*/
|
|
16
|
+
full?: boolean | undefined;
|
|
17
|
+
slots?: Partial<DocsPageSlots>;
|
|
18
|
+
footer?: FooterOptions;
|
|
19
|
+
breadcrumb?: BreadcrumbOptions;
|
|
20
|
+
tableOfContent?: TableOfContentOptions;
|
|
21
|
+
}
|
|
22
|
+
type TableOfContentOptions = Pick<TOCProviderProps, 'single'> & TOCProps & {
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated use `slots.toc` instead.
|
|
26
|
+
*/
|
|
27
|
+
component?: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
interface BreadcrumbOptions extends BreadcrumbProps {
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated use `slots.breadcrumb` instead.
|
|
33
|
+
*/
|
|
34
|
+
component?: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
interface FooterOptions extends FooterProps {
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated use `slots.footer` instead.
|
|
40
|
+
*/
|
|
41
|
+
component?: ReactNode;
|
|
42
|
+
}
|
|
43
|
+
interface DocsPageSlots {
|
|
44
|
+
toc: {
|
|
45
|
+
provider: FC<TOCProviderProps>;
|
|
46
|
+
main: FC<TOCProps>;
|
|
47
|
+
};
|
|
48
|
+
container: FC<ComponentProps<'article'>>;
|
|
49
|
+
footer: FC<FooterProps>;
|
|
50
|
+
breadcrumb: FC<BreadcrumbProps>;
|
|
51
|
+
}
|
|
52
|
+
declare function useDocsPage(): {
|
|
53
|
+
full: NonNullable<DocsPageProps["full"]>;
|
|
54
|
+
slots: DocsPageSlots;
|
|
55
|
+
};
|
|
56
|
+
declare function DocsPage({
|
|
57
|
+
full,
|
|
58
|
+
tableOfContent: {
|
|
59
|
+
enabled: tocEnabled,
|
|
60
|
+
single,
|
|
61
|
+
...tocProps
|
|
62
|
+
},
|
|
63
|
+
breadcrumb: {
|
|
64
|
+
enabled: breadcrumbEnabled,
|
|
65
|
+
...breadcrumb
|
|
66
|
+
},
|
|
67
|
+
footer: {
|
|
68
|
+
enabled: footerEnabled,
|
|
69
|
+
...footer
|
|
70
|
+
},
|
|
71
|
+
toc,
|
|
72
|
+
slots: defaultSlots,
|
|
73
|
+
children,
|
|
74
|
+
...containerProps
|
|
75
|
+
}: DocsPageProps): import("react").JSX.Element;
|
|
76
|
+
declare function EditOnGitHub(props: ComponentProps<'a'>): import("react").JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* Add typography styles
|
|
79
|
+
*/
|
|
80
|
+
declare function DocsBody({
|
|
81
|
+
children,
|
|
82
|
+
className,
|
|
83
|
+
...props
|
|
84
|
+
}: ComponentProps<'div'>): import("react").JSX.Element;
|
|
85
|
+
declare function DocsDescription({
|
|
86
|
+
children,
|
|
87
|
+
className,
|
|
88
|
+
...props
|
|
89
|
+
}: ComponentProps<'p'>): import("react").JSX.Element | null;
|
|
90
|
+
declare function DocsTitle({
|
|
91
|
+
children,
|
|
92
|
+
className,
|
|
93
|
+
...props
|
|
94
|
+
}: ComponentProps<'h1'>): import("react").JSX.Element;
|
|
95
|
+
declare function PageLastUpdate({
|
|
96
|
+
date: value,
|
|
97
|
+
...props
|
|
98
|
+
}: Omit<ComponentProps<'p'>, 'children'> & {
|
|
99
|
+
date: Date;
|
|
100
|
+
}): import("react").JSX.Element;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { type BreadcrumbProps, DocsBody, DocsDescription, DocsPage, DocsPageProps, DocsTitle, EditOnGitHub, type FooterProps, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "../../../components/ui/button.js";
|
|
4
|
+
import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
|
|
5
|
+
import { TOC, TOCProvider } from "./slots/toc.js";
|
|
6
|
+
import { Footer } from "./slots/footer.js";
|
|
7
|
+
import { Breadcrumb } from "./slots/breadcrumb.js";
|
|
8
|
+
import { Container } from "./slots/container.js";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Edit } from "lucide-react";
|
|
11
|
+
import { createContext, use, useEffect, useState } from "react";
|
|
12
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
13
|
+
//#region src/layouts/flux/page/index.tsx
|
|
14
|
+
const PageContext = createContext(null);
|
|
15
|
+
function useDocsPage() {
|
|
16
|
+
const context = use(PageContext);
|
|
17
|
+
if (!context) throw new Error("Please use page components under <DocsPage /> (`opin-ui/layouts/flux/page`).");
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
function DocsPage({ full = false, tableOfContent: { enabled: tocEnabled = !full, single, ...tocProps } = {}, breadcrumb: { enabled: breadcrumbEnabled = true, ...breadcrumb } = {}, footer: { enabled: footerEnabled = true, ...footer } = {}, toc = [], slots: defaultSlots = {}, children, ...containerProps }) {
|
|
21
|
+
const slots = {
|
|
22
|
+
breadcrumb: defaultSlots.breadcrumb ?? Breadcrumb,
|
|
23
|
+
footer: defaultSlots.footer ?? Footer,
|
|
24
|
+
container: defaultSlots.container ?? Container,
|
|
25
|
+
toc: defaultSlots.toc ?? {
|
|
26
|
+
provider: TOCProvider,
|
|
27
|
+
main: TOC
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return /* @__PURE__ */ jsx(PageContext, {
|
|
31
|
+
value: {
|
|
32
|
+
full,
|
|
33
|
+
slots
|
|
34
|
+
},
|
|
35
|
+
children: /* @__PURE__ */ jsxs(slots.toc.provider, {
|
|
36
|
+
single,
|
|
37
|
+
toc: tocEnabled ? toc : [],
|
|
38
|
+
children: [tocEnabled && (tocProps.component ?? /* @__PURE__ */ jsx(slots.toc.main, { ...tocProps })), /* @__PURE__ */ jsxs(slots.container, {
|
|
39
|
+
...containerProps,
|
|
40
|
+
children: [
|
|
41
|
+
breadcrumbEnabled && (breadcrumb.component ?? /* @__PURE__ */ jsx(slots.breadcrumb, { ...breadcrumb })),
|
|
42
|
+
children,
|
|
43
|
+
footerEnabled && (footer.component ?? /* @__PURE__ */ jsx(slots.footer, { ...footer }))
|
|
44
|
+
]
|
|
45
|
+
})]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function EditOnGitHub(props) {
|
|
50
|
+
const t = useTranslations({ note: "edit page" });
|
|
51
|
+
return /* @__PURE__ */ jsx("a", {
|
|
52
|
+
target: "_blank",
|
|
53
|
+
rel: "noreferrer noopener",
|
|
54
|
+
...props,
|
|
55
|
+
className: cn(buttonVariants({
|
|
56
|
+
color: "secondary",
|
|
57
|
+
size: "sm"
|
|
58
|
+
}), "gap-1.5 not-prose", props.className),
|
|
59
|
+
children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Edit, { className: "size-3.5" }), t("Edit on GitHub")] })
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Add typography styles
|
|
64
|
+
*/
|
|
65
|
+
function DocsBody({ children, className, ...props }) {
|
|
66
|
+
return /* @__PURE__ */ jsx("div", {
|
|
67
|
+
...props,
|
|
68
|
+
className: cn("prose flex-1", className),
|
|
69
|
+
children
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function DocsDescription({ children, className, ...props }) {
|
|
73
|
+
if (children === void 0) return null;
|
|
74
|
+
return /* @__PURE__ */ jsx("p", {
|
|
75
|
+
...props,
|
|
76
|
+
className: cn("mb-8 text-lg text-fd-muted-foreground", className),
|
|
77
|
+
children
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function DocsTitle({ children, className, ...props }) {
|
|
81
|
+
return /* @__PURE__ */ jsx("h1", {
|
|
82
|
+
...props,
|
|
83
|
+
className: cn("text-[1.75em] font-semibold", className),
|
|
84
|
+
children
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function PageLastUpdate({ date: value, ...props }) {
|
|
88
|
+
const t = useTranslations({ note: "page footer" });
|
|
89
|
+
const [date, setDate] = useState("");
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
setDate(value.toLocaleDateString());
|
|
92
|
+
}, [value]);
|
|
93
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
94
|
+
...props,
|
|
95
|
+
className: cn("text-sm text-fd-muted-foreground", props.className),
|
|
96
|
+
children: [
|
|
97
|
+
t("Last updated on"),
|
|
98
|
+
" ",
|
|
99
|
+
date
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { DocsBody, DocsDescription, DocsPage, DocsTitle, EditOnGitHub, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { BreadcrumbOptions } from "fumadocs-core/breadcrumb";
|
|
3
|
+
|
|
4
|
+
//#region src/layouts/flux/page/slots/breadcrumb.d.ts
|
|
5
|
+
type BreadcrumbProps = BreadcrumbOptions & ComponentProps<'div'>;
|
|
6
|
+
declare function Breadcrumb({
|
|
7
|
+
includeRoot,
|
|
8
|
+
includeSeparator,
|
|
9
|
+
includePage,
|
|
10
|
+
...props
|
|
11
|
+
}: BreadcrumbProps): import("react").JSX.Element | null;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Breadcrumb, BreadcrumbProps };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../../utils/cn.js";
|
|
3
|
+
import { useTreeContext, useTreePath } from "../../../../contexts/tree.js";
|
|
4
|
+
import Link from "fumadocs-core/link";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { ChevronRight } from "lucide-react";
|
|
7
|
+
import { Fragment as Fragment$1, useMemo } from "react";
|
|
8
|
+
import { getBreadcrumbItemsFromPath } from "fumadocs-core/breadcrumb";
|
|
9
|
+
//#region src/layouts/flux/page/slots/breadcrumb.tsx
|
|
10
|
+
function Breadcrumb({ includeRoot, includeSeparator, includePage, ...props }) {
|
|
11
|
+
const path = useTreePath();
|
|
12
|
+
const { root } = useTreeContext();
|
|
13
|
+
const items = useMemo(() => {
|
|
14
|
+
return getBreadcrumbItemsFromPath(root, path, {
|
|
15
|
+
includePage,
|
|
16
|
+
includeSeparator,
|
|
17
|
+
includeRoot
|
|
18
|
+
});
|
|
19
|
+
}, [
|
|
20
|
+
includePage,
|
|
21
|
+
includeRoot,
|
|
22
|
+
includeSeparator,
|
|
23
|
+
path,
|
|
24
|
+
root
|
|
25
|
+
]);
|
|
26
|
+
if (items.length === 0) return null;
|
|
27
|
+
return /* @__PURE__ */ jsx("div", {
|
|
28
|
+
...props,
|
|
29
|
+
className: cn("flex items-center gap-1.5 text-sm text-fd-muted-foreground", props.className),
|
|
30
|
+
children: items.map((item, i) => {
|
|
31
|
+
const className = cn("truncate", i === items.length - 1 && "text-fd-primary font-medium");
|
|
32
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [i !== 0 && /* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 shrink-0" }), item.url ? /* @__PURE__ */ jsx(Link, {
|
|
33
|
+
href: item.url,
|
|
34
|
+
className: cn(className, "transition-opacity hover:opacity-80"),
|
|
35
|
+
children: item.name
|
|
36
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
37
|
+
className,
|
|
38
|
+
children: item.name
|
|
39
|
+
})] }, i);
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../../utils/cn.js";
|
|
3
|
+
import { useDocsPage } from "../index.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/layouts/flux/page/slots/container.tsx
|
|
6
|
+
function Container(props) {
|
|
7
|
+
const { full } = useDocsPage();
|
|
8
|
+
return /* @__PURE__ */ jsx("article", {
|
|
9
|
+
id: "nd-page",
|
|
10
|
+
"data-full": full,
|
|
11
|
+
...props,
|
|
12
|
+
className: cn("flex flex-col w-full max-w-[900px] mx-auto [grid-area:main] px-4 py-6 gap-4 md:px-6 md:pt-8 xl:px-8 xl:pt-14", full && "max-w-[1200px]", props.className),
|
|
13
|
+
children: props.children
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Container };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import * as PageTree from "fumadocs-core/page-tree";
|
|
3
|
+
|
|
4
|
+
//#region src/layouts/flux/page/slots/footer.d.ts
|
|
5
|
+
type Item = Pick<PageTree.Item, 'name' | 'description' | 'url'>;
|
|
6
|
+
interface FooterProps extends ComponentProps<'div'> {
|
|
7
|
+
/**
|
|
8
|
+
* Items including information for the next and previous page
|
|
9
|
+
*/
|
|
10
|
+
items?: {
|
|
11
|
+
previous?: Item;
|
|
12
|
+
next?: Item;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
declare function Footer({
|
|
16
|
+
items,
|
|
17
|
+
children,
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
}: FooterProps): import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Footer, FooterProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../../utils/cn.js";
|
|
3
|
+
import { isActive } from "../../../../utils/urls.js";
|
|
4
|
+
import { useFooterItems } from "../../../../utils/use-footer-items.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 { ChevronLeft, ChevronRight } from "lucide-react";
|
|
9
|
+
import { useMemo } from "react";
|
|
10
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
11
|
+
//#region src/layouts/flux/page/slots/footer.tsx
|
|
12
|
+
function Footer({ items, children, className, ...props }) {
|
|
13
|
+
const footerList = useFooterItems();
|
|
14
|
+
const pathname = usePathname();
|
|
15
|
+
const { previous, next } = useMemo(() => {
|
|
16
|
+
if (items) return items;
|
|
17
|
+
const idx = footerList.findIndex((item) => isActive(item.url, pathname));
|
|
18
|
+
if (idx === -1) return {};
|
|
19
|
+
return {
|
|
20
|
+
previous: footerList[idx - 1],
|
|
21
|
+
next: footerList[idx + 1]
|
|
22
|
+
};
|
|
23
|
+
}, [
|
|
24
|
+
footerList,
|
|
25
|
+
items,
|
|
26
|
+
pathname
|
|
27
|
+
]);
|
|
28
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
29
|
+
className: cn("@container grid gap-4", previous && next ? "grid-cols-2" : "grid-cols-1", className),
|
|
30
|
+
...props,
|
|
31
|
+
children: [previous && /* @__PURE__ */ jsx(FooterItem, {
|
|
32
|
+
item: previous,
|
|
33
|
+
index: 0
|
|
34
|
+
}), next && /* @__PURE__ */ jsx(FooterItem, {
|
|
35
|
+
item: next,
|
|
36
|
+
index: 1
|
|
37
|
+
})]
|
|
38
|
+
}), children] });
|
|
39
|
+
}
|
|
40
|
+
function FooterItem({ item, index }) {
|
|
41
|
+
const t = useTranslations({ note: "pagination" });
|
|
42
|
+
const Icon = index === 0 ? ChevronLeft : ChevronRight;
|
|
43
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
44
|
+
href: item.url,
|
|
45
|
+
className: cn("flex flex-col gap-2 rounded-lg border p-4 text-sm transition-colors hover:bg-fd-accent/80 hover:text-fd-accent-foreground @max-lg:col-span-full", index === 1 && "text-end"),
|
|
46
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
47
|
+
className: cn("inline-flex items-center gap-1.5 font-medium", index === 1 && "flex-row-reverse"),
|
|
48
|
+
children: [/* @__PURE__ */ jsx(Icon, { className: "-mx-1 size-4 shrink-0 rtl:rotate-180" }), /* @__PURE__ */ jsx("p", { children: item.name })]
|
|
49
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
50
|
+
className: "text-fd-muted-foreground truncate",
|
|
51
|
+
children: item.description ?? (index === 0 ? t("Previous Page") : t("Next Page"))
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Footer };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TOCItemsProps } from "../../../../components/toc/clerk.js";
|
|
2
|
+
import { TOCItemsProps as TOCItemsProps$1 } from "../../../../components/toc/default.js";
|
|
3
|
+
import { TOCProvider as TOCProvider$1, TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
|
|
4
|
+
import { ComponentProps, ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/layouts/flux/page/slots/toc.d.ts
|
|
7
|
+
type TOCProviderProps = TOCProviderProps$1;
|
|
8
|
+
declare const TOCProvider: typeof TOCProvider$1;
|
|
9
|
+
type TOCProps = {
|
|
10
|
+
container?: ComponentProps<'div'>;
|
|
11
|
+
trigger?: ComponentProps<'button'>;
|
|
12
|
+
content?: ComponentProps<'div'>;
|
|
13
|
+
/**
|
|
14
|
+
* Custom content in TOC container, before the main TOC
|
|
15
|
+
*/
|
|
16
|
+
header?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Custom content in TOC container, after the main TOC
|
|
19
|
+
*/
|
|
20
|
+
footer?: ReactNode;
|
|
21
|
+
} & ({
|
|
22
|
+
style?: 'normal';
|
|
23
|
+
list?: TOCItemsProps$1;
|
|
24
|
+
} | {
|
|
25
|
+
style: 'clerk';
|
|
26
|
+
list?: TOCItemsProps;
|
|
27
|
+
});
|
|
28
|
+
declare function TOC({
|
|
29
|
+
container,
|
|
30
|
+
trigger,
|
|
31
|
+
content,
|
|
32
|
+
header,
|
|
33
|
+
footer,
|
|
34
|
+
style,
|
|
35
|
+
list
|
|
36
|
+
}: TOCProps): import("react").JSX.Element | undefined;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { TOC, TOCProps, TOCProvider, TOCProviderProps };
|