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.
Files changed (243) hide show
  1. package/README.md +5 -0
  2. package/css/aspen.css +39 -0
  3. package/css/black.css +39 -0
  4. package/css/catppuccin.css +49 -0
  5. package/css/dusk.css +47 -0
  6. package/css/emerald.css +39 -0
  7. package/css/generated/docs.css +1 -0
  8. package/css/generated/flux.css +1 -0
  9. package/css/generated/home.css +1 -0
  10. package/css/generated/notebook.css +1 -0
  11. package/css/generated/shared.css +1 -0
  12. package/css/lib/base.css +314 -0
  13. package/css/lib/default-colors.css +51 -0
  14. package/css/lib/shiki.css +108 -0
  15. package/css/neutral.css +7 -0
  16. package/css/ocean.css +44 -0
  17. package/css/preset-legacy.css +43 -0
  18. package/css/preset.css +11 -0
  19. package/css/purple.css +39 -0
  20. package/css/ruby.css +39 -0
  21. package/css/shadcn.css +36 -0
  22. package/css/solar.css +75 -0
  23. package/css/style.css +9 -0
  24. package/css/vitepress.css +65 -0
  25. package/dist/.translations/index.d.ts +49 -0
  26. package/dist/.translations/keys.js +49 -0
  27. package/dist/_virtual/_rolldown/runtime.js +13 -0
  28. package/dist/components/accordion.d.ts +23 -0
  29. package/dist/components/accordion.js +68 -0
  30. package/dist/components/banner.d.ts +33 -0
  31. package/dist/components/banner.js +85 -0
  32. package/dist/components/callout.d.ts +41 -0
  33. package/dist/components/callout.js +53 -0
  34. package/dist/components/card.d.ts +19 -0
  35. package/dist/components/card.js +38 -0
  36. package/dist/components/codeblock.d.ts +61 -0
  37. package/dist/components/codeblock.js +173 -0
  38. package/dist/components/codeblock.rsc.d.ts +20 -0
  39. package/dist/components/codeblock.rsc.js +22 -0
  40. package/dist/components/dialog/search-algolia.d.ts +36 -0
  41. package/dist/components/dialog/search-algolia.js +64 -0
  42. package/dist/components/dialog/search-default.d.ts +36 -0
  43. package/dist/components/dialog/search-default.js +58 -0
  44. package/dist/components/dialog/search-orama.d.ts +43 -0
  45. package/dist/components/dialog/search-orama.js +69 -0
  46. package/dist/components/dialog/search.d.ts +112 -0
  47. package/dist/components/dialog/search.js +350 -0
  48. package/dist/components/dynamic-codeblock.core.d.ts +34 -0
  49. package/dist/components/dynamic-codeblock.core.js +51 -0
  50. package/dist/components/dynamic-codeblock.d.ts +9 -0
  51. package/dist/components/dynamic-codeblock.js +17 -0
  52. package/dist/components/files.d.ts +34 -0
  53. package/dist/components/files.js +40 -0
  54. package/dist/components/github-info.d.ts +35 -0
  55. package/dist/components/github-info.js +75 -0
  56. package/dist/components/heading.d.ts +13 -0
  57. package/dist/components/heading.js +38 -0
  58. package/dist/components/image-zoom.d.ts +23 -0
  59. package/dist/components/image-zoom.js +32 -0
  60. package/dist/components/image-zoom2.css +71 -0
  61. package/dist/components/inline-toc.d.ts +14 -0
  62. package/dist/components/inline-toc.js +28 -0
  63. package/dist/components/sidebar/base.d.ts +131 -0
  64. package/dist/components/sidebar/base.js +274 -0
  65. package/dist/components/sidebar/link-item.d.ts +22 -0
  66. package/dist/components/sidebar/link-item.js +38 -0
  67. package/dist/components/sidebar/page-tree.d.ts +28 -0
  68. package/dist/components/sidebar/page-tree.js +71 -0
  69. package/dist/components/sidebar/tabs/dropdown.d.ts +16 -0
  70. package/dist/components/sidebar/tabs/dropdown.js +71 -0
  71. package/dist/components/sidebar/tabs/index.d.ts +11 -0
  72. package/dist/components/sidebar/tabs/index.js +46 -0
  73. package/dist/components/steps.d.ts +15 -0
  74. package/dist/components/steps.js +16 -0
  75. package/dist/components/tabs.d.ts +49 -0
  76. package/dist/components/tabs.js +88 -0
  77. package/dist/components/toc/clerk.d.ts +20 -0
  78. package/dist/components/toc/clerk.js +226 -0
  79. package/dist/components/toc/default.d.ts +23 -0
  80. package/dist/components/toc/default.js +259 -0
  81. package/dist/components/toc/index.d.ts +19 -0
  82. package/dist/components/toc/index.js +45 -0
  83. package/dist/components/type-table.d.ts +43 -0
  84. package/dist/components/type-table.js +117 -0
  85. package/dist/components/ui/accordion.d.ts +30 -0
  86. package/dist/components/ui/accordion.js +42 -0
  87. package/dist/components/ui/button.d.ts +11 -0
  88. package/dist/components/ui/button.js +20 -0
  89. package/dist/components/ui/collapsible.d.ts +15 -0
  90. package/dist/components/ui/collapsible.js +21 -0
  91. package/dist/components/ui/navigation-menu.d.ts +30 -0
  92. package/dist/components/ui/navigation-menu.js +41 -0
  93. package/dist/components/ui/popover.d.ts +15 -0
  94. package/dist/components/ui/popover.js +20 -0
  95. package/dist/components/ui/scroll-area.d.ts +22 -0
  96. package/dist/components/ui/scroll-area.js +34 -0
  97. package/dist/components/ui/tabs.d.ts +36 -0
  98. package/dist/components/ui/tabs.js +77 -0
  99. package/dist/contexts/i18n.d.ts +41 -0
  100. package/dist/contexts/i18n.js +37 -0
  101. package/dist/contexts/search.d.ts +73 -0
  102. package/dist/contexts/search.js +68 -0
  103. package/dist/contexts/tree.d.ts +20 -0
  104. package/dist/contexts/tree.js +38 -0
  105. package/dist/i18n.d.ts +16 -0
  106. package/dist/i18n.js +38 -0
  107. package/dist/layouts/docs/client.d.ts +34 -0
  108. package/dist/layouts/docs/client.js +92 -0
  109. package/dist/layouts/docs/index.d.ts +44 -0
  110. package/dist/layouts/docs/index.js +22 -0
  111. package/dist/layouts/docs/page/index.d.ts +115 -0
  112. package/dist/layouts/docs/page/index.js +124 -0
  113. package/dist/layouts/docs/page/slots/breadcrumb.d.ts +13 -0
  114. package/dist/layouts/docs/page/slots/breadcrumb.js +44 -0
  115. package/dist/layouts/docs/page/slots/container.d.ts +6 -0
  116. package/dist/layouts/docs/page/slots/container.js +17 -0
  117. package/dist/layouts/docs/page/slots/footer.d.ts +22 -0
  118. package/dist/layouts/docs/page/slots/footer.js +56 -0
  119. package/dist/layouts/docs/page/slots/toc.d.ts +62 -0
  120. package/dist/layouts/docs/page/slots/toc.js +182 -0
  121. package/dist/layouts/docs/slots/container.d.ts +6 -0
  122. package/dist/layouts/docs/slots/container.js +36 -0
  123. package/dist/layouts/docs/slots/header.d.ts +6 -0
  124. package/dist/layouts/docs/slots/header.js +38 -0
  125. package/dist/layouts/docs/slots/sidebar.d.ts +29 -0
  126. package/dist/layouts/docs/slots/sidebar.js +326 -0
  127. package/dist/layouts/flux/index.d.ts +73 -0
  128. package/dist/layouts/flux/index.js +146 -0
  129. package/dist/layouts/flux/page/index.d.ts +102 -0
  130. package/dist/layouts/flux/page/index.js +104 -0
  131. package/dist/layouts/flux/page/slots/breadcrumb.d.ts +13 -0
  132. package/dist/layouts/flux/page/slots/breadcrumb.js +44 -0
  133. package/dist/layouts/flux/page/slots/container.d.ts +6 -0
  134. package/dist/layouts/flux/page/slots/container.js +17 -0
  135. package/dist/layouts/flux/page/slots/footer.d.ts +22 -0
  136. package/dist/layouts/flux/page/slots/footer.js +56 -0
  137. package/dist/layouts/flux/page/slots/toc.d.ts +38 -0
  138. package/dist/layouts/flux/page/slots/toc.js +181 -0
  139. package/dist/layouts/flux/slots/container.d.ts +6 -0
  140. package/dist/layouts/flux/slots/container.js +13 -0
  141. package/dist/layouts/flux/slots/sidebar.d.ts +22 -0
  142. package/dist/layouts/flux/slots/sidebar.js +237 -0
  143. package/dist/layouts/flux/slots/tab-dropdown.d.ts +16 -0
  144. package/dist/layouts/flux/slots/tab-dropdown.js +85 -0
  145. package/dist/layouts/home/index.d.ts +28 -0
  146. package/dist/layouts/home/index.js +40 -0
  147. package/dist/layouts/home/navbar.d.ts +10 -0
  148. package/dist/layouts/home/navbar.js +34 -0
  149. package/dist/layouts/home/not-found.d.ts +7 -0
  150. package/dist/layouts/home/not-found.js +41 -0
  151. package/dist/layouts/home/slots/container.d.ts +6 -0
  152. package/dist/layouts/home/slots/container.js +13 -0
  153. package/dist/layouts/home/slots/header.d.ts +9 -0
  154. package/dist/layouts/home/slots/header.js +239 -0
  155. package/dist/layouts/notebook/client.d.ts +36 -0
  156. package/dist/layouts/notebook/client.js +69 -0
  157. package/dist/layouts/notebook/index.d.ts +37 -0
  158. package/dist/layouts/notebook/index.js +22 -0
  159. package/dist/layouts/notebook/page/index.d.ts +115 -0
  160. package/dist/layouts/notebook/page/index.js +124 -0
  161. package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +13 -0
  162. package/dist/layouts/notebook/page/slots/breadcrumb.js +44 -0
  163. package/dist/layouts/notebook/page/slots/container.d.ts +6 -0
  164. package/dist/layouts/notebook/page/slots/container.js +17 -0
  165. package/dist/layouts/notebook/page/slots/footer.d.ts +22 -0
  166. package/dist/layouts/notebook/page/slots/footer.js +56 -0
  167. package/dist/layouts/notebook/page/slots/toc.d.ts +62 -0
  168. package/dist/layouts/notebook/page/slots/toc.js +181 -0
  169. package/dist/layouts/notebook/slots/container.d.ts +6 -0
  170. package/dist/layouts/notebook/slots/container.js +38 -0
  171. package/dist/layouts/notebook/slots/header.d.ts +6 -0
  172. package/dist/layouts/notebook/slots/header.js +194 -0
  173. package/dist/layouts/notebook/slots/sidebar.d.ts +30 -0
  174. package/dist/layouts/notebook/slots/sidebar.js +298 -0
  175. package/dist/layouts/shared/client.d.ts +44 -0
  176. package/dist/layouts/shared/client.js +84 -0
  177. package/dist/layouts/shared/index.d.ts +178 -0
  178. package/dist/layouts/shared/index.js +98 -0
  179. package/dist/layouts/shared/page-actions.d.ts +35 -0
  180. package/dist/layouts/shared/page-actions.js +195 -0
  181. package/dist/layouts/shared/slots/language-select.d.ts +18 -0
  182. package/dist/layouts/shared/slots/language-select.js +43 -0
  183. package/dist/layouts/shared/slots/search-trigger.d.ts +22 -0
  184. package/dist/layouts/shared/slots/search-trigger.js +53 -0
  185. package/dist/layouts/shared/slots/theme-switch.d.ts +13 -0
  186. package/dist/layouts/shared/slots/theme-switch.js +65 -0
  187. package/dist/legacy/layout.d.ts +36 -0
  188. package/dist/legacy/layout.js +44 -0
  189. package/dist/legacy/sidebar.d.ts +17 -0
  190. package/dist/legacy/sidebar.js +33 -0
  191. package/dist/mdx.d.ts +45 -0
  192. package/dist/mdx.js +70 -0
  193. package/dist/mdx.server.d.ts +15 -0
  194. package/dist/mdx.server.js +20 -0
  195. 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
  196. package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/controlled.js +461 -0
  197. 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
  198. 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
  199. package/dist/node_modules/.bun/react-medium-image-zoom@5.4.8_7492c01c6988791b/node_modules/react-medium-image-zoom/dist/uncontrolled.js +17 -0
  200. 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
  201. 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
  202. 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
  203. 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
  204. 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
  205. 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
  206. 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
  207. 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
  208. 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
  209. 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
  210. 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
  211. 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
  212. 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
  213. 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
  214. 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
  215. package/dist/og/takumi.d.ts +21 -0
  216. package/dist/og/takumi.js +91 -0
  217. package/dist/og.d.ts +22 -0
  218. package/dist/og.js +91 -0
  219. package/dist/page.d.ts +35 -0
  220. package/dist/page.js +33 -0
  221. package/dist/provider/base.d.ts +49 -0
  222. package/dist/provider/base.js +32 -0
  223. package/dist/provider/next.d.ts +20 -0
  224. package/dist/provider/next.js +17 -0
  225. package/dist/provider/react-router.d.ts +20 -0
  226. package/dist/provider/react-router.js +17 -0
  227. package/dist/provider/tanstack.d.ts +20 -0
  228. package/dist/provider/tanstack.js +17 -0
  229. package/dist/provider/waku.d.ts +20 -0
  230. package/dist/provider/waku.js +17 -0
  231. package/dist/style.css +3534 -0
  232. package/dist/tailwind/typography.d.ts +2 -0
  233. package/dist/tailwind/typography.js +2 -0
  234. package/dist/utils/cn.js +2 -0
  235. package/dist/utils/merge-refs.js +11 -0
  236. package/dist/utils/urls.js +15 -0
  237. package/dist/utils/use-copy-button.d.ts +6 -0
  238. package/dist/utils/use-copy-button.js +26 -0
  239. package/dist/utils/use-footer-items.d.ts +9 -0
  240. package/dist/utils/use-footer-items.js +24 -0
  241. package/dist/utils/use-is-scroll-top.d.ts +8 -0
  242. package/dist/utils/use-is-scroll-top.js +20 -0
  243. package/package.json +200 -0
@@ -0,0 +1,194 @@
1
+ "use client";
2
+ import { cn } from "../../../utils/cn.js";
3
+ import { buttonVariants } from "../../../components/ui/button.js";
4
+ import { Popover, PopoverContent, PopoverTrigger } from "../../../components/ui/popover.js";
5
+ import { LinkItem } from "../../shared/client.js";
6
+ import { isLayoutTabActive } from "../../shared/index.js";
7
+ import { useNotebookLayout } from "../client.js";
8
+ import Link from "fumadocs-core/link";
9
+ import { usePathname } from "fumadocs-core/framework";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { ChevronDown, Languages, Sidebar } from "lucide-react";
12
+ import { Fragment as Fragment$1, useMemo, useRef, useState } from "react";
13
+ //#region src/layouts/notebook/slots/header.tsx
14
+ function Header(props) {
15
+ const { slots, navItems, isNavTransparent, props: { tabMode, nav, tabs, sidebar } } = useNotebookLayout();
16
+ const { open } = slots.sidebar?.useSidebar?.() ?? {};
17
+ const navMode = nav?.mode ?? "auto";
18
+ const sidebarCollapsible = sidebar.collapsible ?? true;
19
+ const showLayoutTabs = tabMode === "navbar" && tabs.length > 0;
20
+ if (nav?.component) return nav.component;
21
+ return /* @__PURE__ */ jsxs("header", {
22
+ id: "nd-subnav",
23
+ "data-transparent": isNavTransparent && !open,
24
+ ...props,
25
+ className: cn("sticky [grid-area:header] flex flex-col top-(--fd-docs-row-1) z-10 backdrop-blur-sm transition-colors data-[transparent=false]:bg-fd-background/80 layout:[--fd-header-height:--spacing(14)]", showLayoutTabs && "lg:layout:[--fd-header-height:--spacing(24)]", props.className),
26
+ children: [/* @__PURE__ */ jsxs("div", {
27
+ "data-header-body": "",
28
+ className: "flex border-b px-4 gap-2 h-14 md:px-6",
29
+ children: [
30
+ /* @__PURE__ */ jsxs("div", {
31
+ className: cn("items-center", navMode === "top" && "flex flex-1", navMode === "auto" && "hidden has-data-[collapsed=true]:md:flex max-md:flex"),
32
+ children: [
33
+ sidebarCollapsible && slots.sidebar && navMode === "auto" && /* @__PURE__ */ jsx(slots.sidebar.collapseTrigger, {
34
+ className: cn(buttonVariants({
35
+ color: "ghost",
36
+ size: "icon-sm"
37
+ }), "-ms-1.5 text-fd-muted-foreground data-[collapsed=false]:hidden max-md:hidden"),
38
+ children: /* @__PURE__ */ jsx(Sidebar, {})
39
+ }),
40
+ slots.navTitle && /* @__PURE__ */ jsx(slots.navTitle, { className: cn("inline-flex items-center gap-2.5 font-semibold", navMode === "auto" && "md:hidden") }),
41
+ nav?.children
42
+ ]
43
+ }),
44
+ slots.searchTrigger && /* @__PURE__ */ jsx(slots.searchTrigger.full, {
45
+ hideIfDisabled: true,
46
+ className: cn("w-full my-auto max-md:hidden", navMode === "top" ? "ps-2.5 rounded-xl max-w-sm" : "max-w-[240px]")
47
+ }),
48
+ /* @__PURE__ */ jsxs("div", {
49
+ className: "flex flex-1 items-center justify-end md:gap-2",
50
+ children: [
51
+ /* @__PURE__ */ jsx("div", {
52
+ className: "flex items-center gap-6 empty:hidden max-lg:hidden",
53
+ children: navItems.filter((item) => item.type !== "icon").map((item, i) => /* @__PURE__ */ jsx(NavbarLinkItem, { item }, i))
54
+ }),
55
+ navItems.filter((item) => item.type === "icon").map((item, i) => /* @__PURE__ */ jsx(LinkItem, {
56
+ item,
57
+ className: cn(buttonVariants({
58
+ size: "icon-sm",
59
+ color: "ghost"
60
+ }), "text-fd-muted-foreground max-lg:hidden"),
61
+ "aria-label": item.label,
62
+ children: item.icon
63
+ }, i)),
64
+ /* @__PURE__ */ jsxs("div", {
65
+ className: "flex items-center md:hidden",
66
+ children: [slots.searchTrigger && /* @__PURE__ */ jsx(slots.searchTrigger.sm, {
67
+ hideIfDisabled: true,
68
+ className: "p-2"
69
+ }), slots.sidebar && /* @__PURE__ */ jsx(slots.sidebar.trigger, {
70
+ className: cn(buttonVariants({
71
+ color: "ghost",
72
+ size: "icon-sm",
73
+ className: "p-2 -me-1.5"
74
+ })),
75
+ children: /* @__PURE__ */ jsx(Sidebar, {})
76
+ })]
77
+ }),
78
+ /* @__PURE__ */ jsxs("div", {
79
+ className: "flex items-center gap-2 max-md:hidden",
80
+ children: [
81
+ slots.languageSelect && /* @__PURE__ */ jsx(slots.languageSelect.root, { children: /* @__PURE__ */ jsx(Languages, { className: "size-4.5 text-fd-muted-foreground" }) }),
82
+ slots.themeSwitch && /* @__PURE__ */ jsx(slots.themeSwitch, {}),
83
+ sidebarCollapsible && slots.sidebar && navMode === "top" && /* @__PURE__ */ jsx(slots.sidebar.collapseTrigger, {
84
+ className: cn(buttonVariants({
85
+ color: "secondary",
86
+ size: "icon-sm"
87
+ }), "text-fd-muted-foreground rounded-full -me-1.5"),
88
+ children: /* @__PURE__ */ jsx(Sidebar, {})
89
+ })
90
+ ]
91
+ })
92
+ ]
93
+ })
94
+ ]
95
+ }), showLayoutTabs && /* @__PURE__ */ jsx(LayoutHeaderTabs, {
96
+ "data-header-tabs": "",
97
+ className: "overflow-x-auto border-b px-6 h-10 max-lg:hidden",
98
+ tabs
99
+ })]
100
+ });
101
+ }
102
+ function LayoutHeaderTabs({ tabs, className, ...props }) {
103
+ const pathname = usePathname();
104
+ const selectedIdx = useMemo(() => {
105
+ return tabs.findLastIndex((option) => isLayoutTabActive(option, pathname));
106
+ }, [tabs, pathname]);
107
+ return /* @__PURE__ */ jsx("div", {
108
+ className: cn("flex flex-row items-end gap-6", className),
109
+ ...props,
110
+ children: tabs.map((option, i) => {
111
+ const { title, url, unlisted, props: { className, ...rest } = {} } = option;
112
+ const isSelected = selectedIdx === i;
113
+ return /* @__PURE__ */ jsx(Link, {
114
+ href: url,
115
+ className: cn("inline-flex border-b-2 border-transparent transition-colors items-center pb-1.5 font-medium gap-2 text-fd-muted-foreground text-sm text-nowrap hover:text-fd-accent-foreground", unlisted && !isSelected && "hidden", isSelected && "border-fd-primary text-fd-primary", className),
116
+ ...rest,
117
+ children: title
118
+ }, i);
119
+ })
120
+ });
121
+ }
122
+ function NavbarLinkItem({ item, className, ...props }) {
123
+ if (item.type === "custom") return item.children;
124
+ if (item.type === "menu") return /* @__PURE__ */ jsx(NavbarLinkItemMenu, {
125
+ item,
126
+ className,
127
+ ...props
128
+ });
129
+ return /* @__PURE__ */ jsx(LinkItem, {
130
+ item,
131
+ className: cn("text-sm text-fd-muted-foreground transition-colors hover:text-fd-accent-foreground data-[active=true]:text-fd-primary", className),
132
+ ...props,
133
+ children: item.text
134
+ });
135
+ }
136
+ function NavbarLinkItemMenu({ item, hoverDelay = 50, className, ...props }) {
137
+ const [open, setOpen] = useState(false);
138
+ const timeoutRef = useRef(null);
139
+ const freezeUntil = useRef(null);
140
+ const delaySetOpen = (value) => {
141
+ if (timeoutRef.current) {
142
+ clearTimeout(timeoutRef.current);
143
+ timeoutRef.current = null;
144
+ }
145
+ timeoutRef.current = window.setTimeout(() => {
146
+ setOpen(value);
147
+ freezeUntil.current = Date.now() + 300;
148
+ }, hoverDelay);
149
+ };
150
+ const onPointerEnter = (e) => {
151
+ if (e.pointerType === "touch") return;
152
+ delaySetOpen(true);
153
+ };
154
+ const onPointerLeave = (e) => {
155
+ if (e.pointerType === "touch") return;
156
+ delaySetOpen(false);
157
+ };
158
+ function isTouchDevice() {
159
+ return "ontouchstart" in window || navigator.maxTouchPoints > 0;
160
+ }
161
+ return /* @__PURE__ */ jsxs(Popover, {
162
+ open,
163
+ onOpenChange: (value) => {
164
+ if (freezeUntil.current === null || Date.now() >= freezeUntil.current) setOpen(value);
165
+ },
166
+ children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
167
+ className: cn("inline-flex items-center gap-1.5 p-1 text-sm text-fd-muted-foreground transition-colors has-data-[active=true]:text-fd-primary data-[state=open]:text-fd-accent-foreground focus-visible:outline-none", className),
168
+ onPointerEnter,
169
+ onPointerLeave,
170
+ ...props,
171
+ children: [item.url ? /* @__PURE__ */ jsx(LinkItem, {
172
+ item,
173
+ children: item.text
174
+ }) : item.text, /* @__PURE__ */ jsx(ChevronDown, { className: "size-3" })]
175
+ }), /* @__PURE__ */ jsx(PopoverContent, {
176
+ className: "flex flex-col p-1 text-fd-muted-foreground text-start",
177
+ onPointerEnter,
178
+ onPointerLeave,
179
+ children: item.items.map((child, i) => {
180
+ if (child.type === "custom") return /* @__PURE__ */ jsx(Fragment$1, { children: child.children }, i);
181
+ return /* @__PURE__ */ jsxs(LinkItem, {
182
+ item: child,
183
+ className: "inline-flex items-center gap-2 rounded-md p-2 transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground data-[active=true]:text-fd-primary [&_svg]:size-4",
184
+ onClick: () => {
185
+ if (isTouchDevice()) setOpen(false);
186
+ },
187
+ children: [child.icon, child.text]
188
+ }, i);
189
+ })
190
+ })]
191
+ });
192
+ }
193
+ //#endregion
194
+ export { Header };
@@ -0,0 +1,30 @@
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, FC, ReactNode } from "react";
4
+
5
+ //#region src/layouts/notebook/slots/sidebar.d.ts
6
+ interface SidebarProps extends ComponentProps<'aside'> {
7
+ components?: Partial<SidebarPageTreeComponents>;
8
+ banner?: ReactNode | FC<ComponentProps<'div'>>;
9
+ footer?: ReactNode | FC<ComponentProps<'div'>>;
10
+ /**
11
+ * Support collapsing the sidebar on desktop mode
12
+ *
13
+ * @defaultValue true
14
+ */
15
+ collapsible?: boolean;
16
+ }
17
+ type SidebarProviderProps = SidebarProviderProps$1;
18
+ declare const useSidebar: typeof useSidebar$1;
19
+ declare function SidebarProvider(props: SidebarProviderProps): import("react").JSX.Element;
20
+ declare function SidebarTrigger(props: ComponentProps<'button'>): import("react").JSX.Element;
21
+ declare function SidebarCollapseTrigger(props: ComponentProps<'button'>): import("react").JSX.Element;
22
+ declare function Sidebar({
23
+ banner,
24
+ footer,
25
+ components,
26
+ collapsible,
27
+ ...rest
28
+ }: SidebarProps): import("react").JSX.Element;
29
+ //#endregion
30
+ export { Sidebar, SidebarCollapseTrigger, SidebarProps, SidebarProvider, SidebarProviderProps, SidebarTrigger, useSidebar };
@@ -0,0 +1,298 @@
1
+ "use client";
2
+ import { cn } from "../../../utils/cn.js";
3
+ import { buttonVariants } from "../../../components/ui/button.js";
4
+ import { mergeRefs } from "../../../utils/merge-refs.js";
5
+ import { Popover, PopoverContent, PopoverTrigger } from "../../../components/ui/popover.js";
6
+ import { LinkItem } from "../../shared/client.js";
7
+ import { isLayoutTabActive } from "../../shared/index.js";
8
+ import { SidebarCollapseTrigger as SidebarCollapseTrigger$1, SidebarContent as SidebarContent$1, SidebarDrawerContent, SidebarDrawerOverlay, 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, SidebarTrigger as SidebarTrigger$1, SidebarViewport, base_exports, useFolder, useFolderDepth } from "../../../components/sidebar/base.js";
9
+ import { createPageTreeRenderer } from "../../../components/sidebar/page-tree.js";
10
+ import { createLinkItemRenderer } from "../../../components/sidebar/link-item.js";
11
+ import { useNotebookLayout } from "../client.js";
12
+ import Link from "fumadocs-core/link";
13
+ import { usePathname } from "fumadocs-core/framework";
14
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
+ import { Check, ChevronsUpDown, Languages, SidebarIcon, X } from "lucide-react";
16
+ import { cva } from "class-variance-authority";
17
+ import { createElement, useMemo, useRef, useState } from "react";
18
+ //#region src/layouts/notebook/slots/sidebar.tsx
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:inset-s-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 SidebarTrigger(props) {
34
+ return /* @__PURE__ */ jsx(SidebarTrigger$1, { ...props });
35
+ }
36
+ function SidebarCollapseTrigger(props) {
37
+ return /* @__PURE__ */ jsx(SidebarCollapseTrigger$1, { ...props });
38
+ }
39
+ function SidebarContent({ ref: refProp, className, children, ...props }) {
40
+ const { props: { nav } } = useNotebookLayout();
41
+ const navMode = nav?.mode ?? "auto";
42
+ const ref = useRef(null);
43
+ return /* @__PURE__ */ jsx(SidebarContent$1, { children: ({ collapsed, hovered, ref: asideRef, ...rest }) => /* @__PURE__ */ jsxs("div", {
44
+ "data-sidebar-placeholder": "",
45
+ className: cn("sticky z-20 [grid-area:sidebar] pointer-events-none *:pointer-events-auto md:layout:[--fd-sidebar-width:268px] max-md:hidden", navMode === "auto" ? "top-(--fd-docs-row-1) h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))]" : "top-(--fd-docs-row-2) h-[calc(var(--fd-docs-height)-var(--fd-docs-row-2))]"),
46
+ children: [collapsed && /* @__PURE__ */ jsx("div", {
47
+ className: "absolute inset-s-0 inset-y-0 w-4",
48
+ ...rest
49
+ }), /* @__PURE__ */ jsx("aside", {
50
+ id: "nd-sidebar",
51
+ ref: mergeRefs(ref, refProp, asideRef),
52
+ "data-collapsed": collapsed,
53
+ "data-hovered": collapsed && hovered,
54
+ className: cn("absolute flex flex-col w-full inset-s-0 inset-y-0 items-end text-sm duration-250 *:w-(--fd-sidebar-width)", navMode === "auto" && "bg-fd-card border-e", collapsed && ["inset-y-2 rounded-xl bg-fd-card transition-transform border w-(--fd-sidebar-width)", hovered ? "shadow-lg translate-x-2 rtl:-translate-x-2" : "-translate-x-(--fd-sidebar-width) rtl:translate-x-full"], ref.current && ref.current.getAttribute("data-collapsed") === "true" !== collapsed && "transition-[width,inset-block,translate,background-color]", className),
55
+ ...props,
56
+ ...rest,
57
+ children
58
+ })]
59
+ }) });
60
+ }
61
+ function SidebarDrawer({ children, className, ...props }) {
62
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SidebarDrawerOverlay, { className: "fixed z-40 inset-0 backdrop-blur-xs data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out" }), /* @__PURE__ */ jsx(SidebarDrawerContent, {
63
+ className: cn("fixed text-[0.9375rem] flex flex-col shadow-lg border-s inset-e-0 inset-y-0 w-[85%] max-w-[380px] z-40 bg-fd-background data-[state=open]:animate-fd-sidebar-in data-[state=closed]:animate-fd-sidebar-out", className),
64
+ ...props,
65
+ children
66
+ })] });
67
+ }
68
+ function SidebarFolder(props) {
69
+ return /* @__PURE__ */ jsx(SidebarFolder$1, { ...props });
70
+ }
71
+ function SidebarSeparator({ className, style, children, ...props }) {
72
+ const depth = useFolderDepth();
73
+ return /* @__PURE__ */ jsx(SidebarSeparator$1, {
74
+ 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),
75
+ style: {
76
+ paddingInlineStart: getItemOffset(depth),
77
+ ...style
78
+ },
79
+ ...props,
80
+ children
81
+ });
82
+ }
83
+ function SidebarItem({ className, style, children, ...props }) {
84
+ const depth = useFolderDepth();
85
+ return /* @__PURE__ */ jsx(SidebarItem$1, {
86
+ className: cn(itemVariants({
87
+ variant: "link",
88
+ highlight: depth >= 1
89
+ }), className),
90
+ style: {
91
+ paddingInlineStart: getItemOffset(depth),
92
+ ...style
93
+ },
94
+ ...props,
95
+ children
96
+ });
97
+ }
98
+ function SidebarFolderTrigger({ className, style, ...props }) {
99
+ const { depth, collapsible } = useFolder();
100
+ return /* @__PURE__ */ jsx(SidebarFolderTrigger$1, {
101
+ className: cn(itemVariants({ variant: collapsible ? "button" : null }), "w-full", className),
102
+ style: {
103
+ paddingInlineStart: getItemOffset(depth - 1),
104
+ ...style
105
+ },
106
+ ...props,
107
+ children: props.children
108
+ });
109
+ }
110
+ function SidebarFolderLink({ className, style, ...props }) {
111
+ const depth = useFolderDepth();
112
+ return /* @__PURE__ */ jsx(SidebarFolderLink$1, {
113
+ className: cn(itemVariants({
114
+ variant: "link",
115
+ highlight: depth > 1
116
+ }), "w-full", className),
117
+ style: {
118
+ paddingInlineStart: getItemOffset(depth - 1),
119
+ ...style
120
+ },
121
+ ...props,
122
+ children: props.children
123
+ });
124
+ }
125
+ function SidebarFolderContent({ className, children, ...props }) {
126
+ return /* @__PURE__ */ jsx(SidebarFolderContent$1, {
127
+ className: cn("relative", useFolderDepth() === 1 && "before:content-[''] before:absolute before:w-px before:inset-y-1 before:bg-fd-border before:inset-s-2.5", className),
128
+ ...props,
129
+ children: /* @__PURE__ */ jsx("div", {
130
+ className: "flex flex-col gap-0.5 pt-0.5",
131
+ children
132
+ })
133
+ });
134
+ }
135
+ const SidebarPageTree = createPageTreeRenderer({
136
+ SidebarFolder,
137
+ SidebarFolderContent,
138
+ SidebarFolderLink,
139
+ SidebarFolderTrigger,
140
+ SidebarItem,
141
+ SidebarSeparator
142
+ });
143
+ const SidebarLinkItem = createLinkItemRenderer({
144
+ SidebarFolder,
145
+ SidebarFolderContent,
146
+ SidebarFolderLink,
147
+ SidebarFolderTrigger,
148
+ SidebarItem
149
+ });
150
+ function Sidebar({ banner, footer, components, collapsible = true, ...rest }) {
151
+ const { menuItems, slots, props: { nav, tabs, tabMode } } = useNotebookLayout();
152
+ const navMode = nav?.mode ?? "auto";
153
+ const iconLinks = menuItems.filter((item) => item.type === "icon");
154
+ function renderHeader(props) {
155
+ if (typeof banner === "function") return createElement(banner, props);
156
+ return /* @__PURE__ */ jsxs("div", {
157
+ ...props,
158
+ className: cn("flex flex-col gap-3 p-4 pb-2 empty:hidden", props.className),
159
+ children: [props.children, banner]
160
+ });
161
+ }
162
+ function renderFooter(props) {
163
+ if (typeof footer === "function") return createElement(footer, props);
164
+ return /* @__PURE__ */ jsxs("div", {
165
+ ...props,
166
+ children: [props.children, footer]
167
+ });
168
+ }
169
+ const viewport = /* @__PURE__ */ jsxs(SidebarViewport, { children: [menuItems.filter((item) => item.type !== "icon").map((item, i, arr) => /* @__PURE__ */ jsx(SidebarLinkItem, {
170
+ item,
171
+ className: cn("lg:hidden", i === arr.length - 1 && "mb-3")
172
+ }, i)), /* @__PURE__ */ jsx(SidebarPageTree, { ...components })] });
173
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(SidebarContent, {
174
+ ...rest,
175
+ children: [
176
+ renderHeader({ children: /* @__PURE__ */ jsxs(Fragment, { children: [navMode === "auto" && /* @__PURE__ */ jsxs("div", {
177
+ className: "flex justify-between",
178
+ children: [
179
+ slots.navTitle && /* @__PURE__ */ jsx(slots.navTitle, { className: "inline-flex items-center gap-2.5 font-medium" }),
180
+ nav?.children,
181
+ collapsible && /* @__PURE__ */ jsx(SidebarCollapseTrigger, {
182
+ className: cn(buttonVariants({
183
+ color: "ghost",
184
+ size: "icon-sm",
185
+ className: "mt-px mb-auto text-fd-muted-foreground"
186
+ })),
187
+ children: /* @__PURE__ */ jsx(SidebarIcon, {})
188
+ })
189
+ ]
190
+ }), tabs.length > 0 && /* @__PURE__ */ jsx(SidebarTabsDropdown, {
191
+ options: tabs,
192
+ className: cn(tabMode === "navbar" && "lg:hidden")
193
+ })] }) }),
194
+ viewport,
195
+ renderFooter({
196
+ className: cn("hidden flex-row text-fd-muted-foreground items-center border-t px-4 py-2.5", iconLinks.length > 0 && "max-lg:flex"),
197
+ children: iconLinks.map((item, i) => /* @__PURE__ */ jsx(LinkItem, {
198
+ item,
199
+ className: cn(buttonVariants({
200
+ size: "icon-sm",
201
+ color: "ghost",
202
+ className: "lg:hidden"
203
+ })),
204
+ "aria-label": item.label,
205
+ children: item.icon
206
+ }, i))
207
+ })
208
+ ]
209
+ }), /* @__PURE__ */ jsxs(SidebarDrawer, {
210
+ ...rest,
211
+ children: [
212
+ renderHeader({ children: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SidebarTrigger, {
213
+ className: cn(buttonVariants({
214
+ size: "icon-sm",
215
+ color: "ghost",
216
+ className: "ms-auto text-fd-muted-foreground"
217
+ })),
218
+ children: /* @__PURE__ */ jsx(X, {})
219
+ }), tabs.length > 0 && /* @__PURE__ */ jsx(SidebarTabsDropdown, { options: tabs })] }) }),
220
+ viewport,
221
+ renderFooter({
222
+ className: cn("hidden flex-row text-fd-muted-foreground items-center border-t p-4 pt-2 justify-end", (slots.languageSelect || slots.themeSwitch) && "flex", iconLinks.length > 0 && "max-lg:flex"),
223
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
224
+ iconLinks.map((item, i) => /* @__PURE__ */ jsx(LinkItem, {
225
+ item,
226
+ className: cn(buttonVariants({
227
+ size: "icon-sm",
228
+ color: "ghost"
229
+ }), "text-fd-muted-foreground lg:hidden", i === iconLinks.length - 1 && "me-auto"),
230
+ "aria-label": item.label,
231
+ children: item.icon
232
+ }, i)),
233
+ slots.languageSelect && /* @__PURE__ */ jsx(slots.languageSelect.root, { children: /* @__PURE__ */ jsx(Languages, { className: "size-4.5 text-fd-muted-foreground" }) }),
234
+ slots.themeSwitch && /* @__PURE__ */ jsx(slots.themeSwitch, {})
235
+ ] })
236
+ })
237
+ ]
238
+ })] });
239
+ }
240
+ function SidebarTabsDropdown({ options, placeholder, ...props }) {
241
+ const [open, setOpen] = useState(false);
242
+ const { closeOnRedirect } = useSidebar();
243
+ const pathname = usePathname();
244
+ const selected = useMemo(() => {
245
+ return options.findLast((item) => isLayoutTabActive(item, pathname));
246
+ }, [options, pathname]);
247
+ const onClick = () => {
248
+ closeOnRedirect.current = false;
249
+ setOpen(false);
250
+ };
251
+ const item = selected ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
252
+ className: "size-9 shrink-0 empty:hidden md:size-5",
253
+ children: selected.icon
254
+ }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
255
+ className: "text-sm font-medium",
256
+ children: selected.title
257
+ }), /* @__PURE__ */ jsx("p", {
258
+ className: "text-sm text-fd-muted-foreground empty:hidden md:hidden",
259
+ children: selected.description
260
+ })] })] }) : placeholder;
261
+ return /* @__PURE__ */ jsxs(Popover, {
262
+ open,
263
+ onOpenChange: setOpen,
264
+ children: [item && /* @__PURE__ */ jsxs(PopoverTrigger, {
265
+ ...props,
266
+ className: cn("flex items-center gap-2 rounded-lg p-2 border bg-fd-secondary/50 text-start text-fd-secondary-foreground transition-colors hover:bg-fd-accent data-[state=open]:bg-fd-accent data-[state=open]:text-fd-accent-foreground", props.className),
267
+ children: [item, /* @__PURE__ */ jsx(ChevronsUpDown, { className: "shrink-0 ms-auto size-4 text-fd-muted-foreground" })]
268
+ }), /* @__PURE__ */ jsx(PopoverContent, {
269
+ className: "flex flex-col gap-1 w-(--radix-popover-trigger-width) p-1 fd-scroll-container",
270
+ children: options.map((item) => {
271
+ const isActive = selected && item.url === selected.url;
272
+ if (!isActive && item.unlisted) return;
273
+ return /* @__PURE__ */ jsxs(Link, {
274
+ href: item.url,
275
+ onClick,
276
+ ...item.props,
277
+ className: cn("flex items-center gap-2 rounded-lg p-1.5 hover:bg-fd-accent hover:text-fd-accent-foreground", item.props?.className),
278
+ children: [
279
+ /* @__PURE__ */ jsx("div", {
280
+ className: "shrink-0 size-9 md:mb-auto md:size-5 empty:hidden",
281
+ children: item.icon
282
+ }),
283
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
284
+ className: "text-sm font-medium leading-none",
285
+ children: item.title
286
+ }), /* @__PURE__ */ jsx("p", {
287
+ className: "text-[0.8125rem] text-fd-muted-foreground mt-1 empty:hidden",
288
+ children: item.description
289
+ })] }),
290
+ /* @__PURE__ */ jsx(Check, { className: cn("shrink-0 ms-auto size-3.5 text-fd-primary", !isActive && "invisible") })
291
+ ]
292
+ }, item.url);
293
+ })
294
+ })]
295
+ });
296
+ }
297
+ //#endregion
298
+ export { Sidebar, SidebarCollapseTrigger, SidebarProvider, SidebarTrigger, useSidebar };
@@ -0,0 +1,44 @@
1
+ import { LanguageSelectProps, LanguageSelectTextProps } from "./slots/language-select.js";
2
+ import { FullSearchTriggerProps, SearchTriggerProps } from "./slots/search-trigger.js";
3
+ import { ThemeSwitchProps } from "./slots/theme-switch.js";
4
+ import { BaseLayoutProps, LinkItemType } from "./index.js";
5
+ import { ComponentProps, FC } from "react";
6
+
7
+ //#region src/layouts/shared/client.d.ts
8
+ declare function LinkItem({
9
+ ref,
10
+ item,
11
+ ...props
12
+ }: Omit<ComponentProps<'a'>, 'href'> & {
13
+ item: Extract<LinkItemType, {
14
+ url: string;
15
+ }>;
16
+ }): import("react").JSX.Element;
17
+ interface BaseSlots {
18
+ navTitle: FC<ComponentProps<'a'>>;
19
+ themeSwitch: FC<ThemeSwitchProps> | false;
20
+ searchTrigger: {
21
+ sm: FC<SearchTriggerProps>;
22
+ full: FC<FullSearchTriggerProps>;
23
+ } | false;
24
+ languageSelect: {
25
+ root: FC<LanguageSelectProps>;
26
+ text: FC<LanguageSelectTextProps>;
27
+ } | false;
28
+ }
29
+ interface BaseSlotsProps<P extends BaseLayoutProps = BaseLayoutProps> extends Pick<P, 'nav'> {
30
+ themeSwitch: Omit<NonNullable<P['themeSwitch']>, 'enabled'>;
31
+ searchToggle: Omit<NonNullable<P['searchToggle']>, 'enabled'>;
32
+ }
33
+ declare function baseSlots({
34
+ useProps
35
+ }: {
36
+ useProps: () => BaseSlotsProps;
37
+ }): {
38
+ useProvider(options: BaseLayoutProps): {
39
+ baseSlots: BaseSlots;
40
+ baseProps: BaseSlotsProps;
41
+ };
42
+ };
43
+ //#endregion
44
+ export { BaseSlots, BaseSlotsProps, LinkItem, baseSlots };
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ import { useI18n } from "../../contexts/i18n.js";
3
+ import { LanguageSelect, LanguageSelectText } from "./slots/language-select.js";
4
+ import { FullSearchTrigger, SearchTrigger } from "./slots/search-trigger.js";
5
+ import { ThemeSwitch } from "./slots/theme-switch.js";
6
+ import { isLinkItemActive } from "./index.js";
7
+ import Link from "fumadocs-core/link";
8
+ import { usePathname } from "fumadocs-core/framework";
9
+ import { jsx } from "react/jsx-runtime";
10
+ //#region src/layouts/shared/client.tsx
11
+ function LinkItem({ ref, item, ...props }) {
12
+ const active = isLinkItemActive(item, usePathname());
13
+ return /* @__PURE__ */ jsx(Link, {
14
+ ref,
15
+ href: item.url,
16
+ external: item.external,
17
+ ...props,
18
+ "data-active": active,
19
+ children: props.children
20
+ });
21
+ }
22
+ function baseSlots({ useProps }) {
23
+ function InlineThemeSwitch(props) {
24
+ const { themeSwitch } = useProps();
25
+ if (themeSwitch.component) return themeSwitch.component;
26
+ return /* @__PURE__ */ jsx(ThemeSwitch, {
27
+ ...props,
28
+ ...themeSwitch
29
+ });
30
+ }
31
+ function InlineSearchTrigger(props) {
32
+ const { searchToggle } = useProps();
33
+ if (searchToggle.components?.sm) return searchToggle.components.sm;
34
+ return /* @__PURE__ */ jsx(SearchTrigger, {
35
+ ...props,
36
+ ...searchToggle.sm
37
+ });
38
+ }
39
+ function InlineSearchTriggerFull(props) {
40
+ const { searchToggle } = useProps();
41
+ if (searchToggle.components?.lg) return searchToggle.components.lg;
42
+ return /* @__PURE__ */ jsx(FullSearchTrigger, {
43
+ ...props,
44
+ ...searchToggle.full
45
+ });
46
+ }
47
+ function InlineNavTitle({ href: defaultUrl = "/", ...props }) {
48
+ const { url = defaultUrl, title } = useProps().nav ?? {};
49
+ if (typeof title === "function") return title({
50
+ href: url,
51
+ ...props
52
+ });
53
+ return /* @__PURE__ */ jsx(Link, {
54
+ href: url,
55
+ ...props,
56
+ children: title
57
+ });
58
+ }
59
+ return { useProvider(options) {
60
+ const { locales = [] } = useI18n();
61
+ const { nav, slots = {}, i18n = locales.length > 1, searchToggle: { enabled: searchToggleEnabled = true, ...searchToggle } = {}, themeSwitch: { enabled: themeSwitchEnabled = true, ...themeSwitch } = {} } = options;
62
+ return {
63
+ baseSlots: {
64
+ navTitle: slots.navTitle ?? InlineNavTitle,
65
+ themeSwitch: themeSwitchEnabled && (slots.themeSwitch ?? InlineThemeSwitch),
66
+ languageSelect: i18n ? slots.languageSelect ?? {
67
+ root: LanguageSelect,
68
+ text: LanguageSelectText
69
+ } : false,
70
+ searchTrigger: searchToggleEnabled && (slots.searchTrigger ?? {
71
+ sm: InlineSearchTrigger,
72
+ full: InlineSearchTriggerFull
73
+ })
74
+ },
75
+ baseProps: {
76
+ nav,
77
+ searchToggle,
78
+ themeSwitch
79
+ }
80
+ };
81
+ } };
82
+ }
83
+ //#endregion
84
+ export { LinkItem, baseSlots };