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,65 @@
1
+ "use client";
2
+ import { cn } from "../../../utils/cn.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { Airplay, Moon, Sun } from "lucide-react";
5
+ import { cva } from "class-variance-authority";
6
+ import { useEffect, useState } from "react";
7
+ import { useTranslations } from "@fuma-translate/react";
8
+ import { useTheme } from "next-themes";
9
+ //#region src/layouts/shared/slots/theme-switch.tsx
10
+ const itemVariants = cva("size-6.5 p-1.5 text-fd-muted-foreground", { variants: { active: {
11
+ true: "bg-fd-accent text-fd-accent-foreground",
12
+ false: "text-fd-muted-foreground"
13
+ } } });
14
+ const full = [
15
+ ["light", Sun],
16
+ ["dark", Moon],
17
+ ["system", Airplay]
18
+ ];
19
+ function ThemeSwitch({ className, mode = "light-dark", ...props }) {
20
+ const { setTheme, theme, resolvedTheme } = useTheme();
21
+ const [mounted, setMounted] = useState(false);
22
+ const t = useTranslations({ note: "theme switcher" });
23
+ const themeAriaLabels = {
24
+ light: t("Light", { note: "aria-label" }),
25
+ dark: t("Dark", { note: "aria-label" }),
26
+ system: t("System", { note: "aria-label" })
27
+ };
28
+ useEffect(() => {
29
+ setMounted(true);
30
+ }, []);
31
+ const container = cn("inline-flex items-center rounded-full border p-1 overflow-hidden *:rounded-full", className);
32
+ if (mode === "light-dark") {
33
+ const value = mounted ? resolvedTheme : null;
34
+ return /* @__PURE__ */ jsx("button", {
35
+ className: container,
36
+ "aria-label": t("Toggle Theme", { note: "aria-label" }),
37
+ onClick: () => setTheme(value === "light" ? "dark" : "light"),
38
+ "data-theme-toggle": "",
39
+ children: full.map(([key, Icon]) => {
40
+ if (key === "system") return;
41
+ return /* @__PURE__ */ jsx(Icon, {
42
+ fill: "currentColor",
43
+ className: cn(itemVariants({ active: value === key }))
44
+ }, key);
45
+ })
46
+ });
47
+ }
48
+ const value = mounted ? theme : null;
49
+ return /* @__PURE__ */ jsx("div", {
50
+ className: container,
51
+ "data-theme-toggle": "",
52
+ ...props,
53
+ children: full.map(([key, Icon]) => /* @__PURE__ */ jsx("button", {
54
+ "aria-label": themeAriaLabels[key],
55
+ className: cn(itemVariants({ active: value === key })),
56
+ onClick: () => setTheme(key),
57
+ children: /* @__PURE__ */ jsx(Icon, {
58
+ className: "size-full",
59
+ fill: "currentColor"
60
+ })
61
+ }, key))
62
+ });
63
+ }
64
+ //#endregion
65
+ export { ThemeSwitch };
@@ -0,0 +1,36 @@
1
+ import { ReactNode } from "react";
2
+
3
+ //#region src/legacy/layout.d.ts
4
+ interface PageStyles {
5
+ tocNav?: string;
6
+ toc?: string;
7
+ page?: string;
8
+ article?: string;
9
+ }
10
+ declare function usePageStyles(): PageStyles;
11
+ declare function StylesProvider({
12
+ children,
13
+ ...value
14
+ }: PageStyles & {
15
+ children: ReactNode;
16
+ }): import("react").JSX.Element;
17
+ interface NavProviderProps {
18
+ /**
19
+ * Use transparent background
20
+ *
21
+ * @defaultValue none
22
+ */
23
+ transparentMode?: 'always' | 'top' | 'none';
24
+ }
25
+ interface NavContextType {
26
+ isTransparent: boolean;
27
+ }
28
+ declare function NavProvider({
29
+ transparentMode,
30
+ children
31
+ }: NavProviderProps & {
32
+ children: ReactNode;
33
+ }): import("react").JSX.Element;
34
+ declare function useNav(): NavContextType;
35
+ //#endregion
36
+ export { NavProvider, NavProviderProps, PageStyles, StylesProvider, useNav, usePageStyles };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, use, useEffect, useMemo, useState } from "react";
4
+ //#region src/legacy/layout.tsx
5
+ /**
6
+ * applied styles to different layout components in `Page` from layouts
7
+ */
8
+ const StylesContext = createContext({
9
+ tocNav: "xl:hidden",
10
+ toc: "max-xl:hidden"
11
+ });
12
+ function usePageStyles() {
13
+ return use(StylesContext);
14
+ }
15
+ function StylesProvider({ children, ...value }) {
16
+ return /* @__PURE__ */ jsx(StylesContext.Provider, {
17
+ value,
18
+ children
19
+ });
20
+ }
21
+ const NavContext = createContext({ isTransparent: false });
22
+ function NavProvider({ transparentMode = "none", children }) {
23
+ const [transparent, setTransparent] = useState(transparentMode !== "none");
24
+ useEffect(() => {
25
+ if (transparentMode !== "top") return;
26
+ const listener = () => {
27
+ setTransparent(window.scrollY < 10);
28
+ };
29
+ listener();
30
+ window.addEventListener("scroll", listener);
31
+ return () => {
32
+ window.removeEventListener("scroll", listener);
33
+ };
34
+ }, [transparentMode]);
35
+ return /* @__PURE__ */ jsx(NavContext, {
36
+ value: useMemo(() => ({ isTransparent: transparent }), [transparent]),
37
+ children
38
+ });
39
+ }
40
+ function useNav() {
41
+ return use(NavContext);
42
+ }
43
+ //#endregion
44
+ export { NavProvider, StylesProvider, useNav, usePageStyles };
@@ -0,0 +1,17 @@
1
+ import { Dispatch, ReactNode, RefObject, SetStateAction } from "react";
2
+
3
+ //#region src/legacy/sidebar.d.ts
4
+ declare function useSidebar(): {
5
+ open: boolean;
6
+ setOpen: Dispatch<SetStateAction<boolean>>;
7
+ collapsed: boolean;
8
+ setCollapsed: Dispatch<SetStateAction<boolean>>;
9
+ closeOnRedirect: RefObject<boolean>;
10
+ };
11
+ declare function SidebarProvider({
12
+ children
13
+ }: {
14
+ children: ReactNode;
15
+ }): import("react").JSX.Element;
16
+ //#endregion
17
+ export { SidebarProvider, useSidebar };
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { usePathname } from "fumadocs-core/framework";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createContext, use, useMemo, useRef, useState } from "react";
5
+ import { useOnChange } from "fumadocs-core/utils/use-on-change";
6
+ //#region src/legacy/sidebar.tsx
7
+ const SidebarContext = createContext(null);
8
+ function useSidebar() {
9
+ const ctx = use(SidebarContext);
10
+ if (!ctx) throw new Error("the component must be wrapped under <SidebarProvider /> (opin-ui/legacy/sidebar)");
11
+ return ctx;
12
+ }
13
+ function SidebarProvider({ children }) {
14
+ const [open, setOpen] = useState(false);
15
+ const [collapsed, setCollapsed] = useState(false);
16
+ const closeOnRedirect = useRef(true);
17
+ useOnChange(usePathname(), () => {
18
+ if (closeOnRedirect.current) setOpen(false);
19
+ else closeOnRedirect.current = true;
20
+ });
21
+ return /* @__PURE__ */ jsx(SidebarContext, {
22
+ value: useMemo(() => ({
23
+ closeOnRedirect,
24
+ collapsed,
25
+ open,
26
+ setCollapsed,
27
+ setOpen
28
+ }), [open, collapsed]),
29
+ children
30
+ });
31
+ }
32
+ //#endregion
33
+ export { SidebarProvider, useSidebar };
package/dist/mdx.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { Callout, CalloutContainer, CalloutDescription, CalloutTitle } from "./components/callout.js";
2
+ import { Card, Cards } from "./components/card.js";
3
+ import { CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger } from "./components/codeblock.js";
4
+ import { createRelativeLink as createRelativeLink$1 } from "./mdx.server.js";
5
+ import React, { AnchorHTMLAttributes, FC, HTMLAttributes, ImgHTMLAttributes, TableHTMLAttributes } from "react";
6
+
7
+ //#region src/mdx.d.ts
8
+ /**
9
+ * global types for MDX.js
10
+ */
11
+ declare module 'mdx/types.js' {
12
+ namespace JSX {
13
+ type Element = React.JSX.Element;
14
+ type ElementClass = React.JSX.ElementClass;
15
+ type ElementType = React.JSX.ElementType;
16
+ type IntrinsicElements = React.JSX.IntrinsicElements;
17
+ }
18
+ }
19
+ declare function Image(props: ImgHTMLAttributes<HTMLImageElement>): React.JSX.Element;
20
+ declare function Table(props: TableHTMLAttributes<HTMLTableElement>): React.JSX.Element;
21
+ declare const defaultMdxComponents: {
22
+ CodeBlockTab: typeof CodeBlockTab;
23
+ CodeBlockTabs: typeof CodeBlockTabs;
24
+ CodeBlockTabsList: typeof CodeBlockTabsList;
25
+ CodeBlockTabsTrigger: typeof CodeBlockTabsTrigger;
26
+ pre: (props: HTMLAttributes<HTMLPreElement>) => React.JSX.Element;
27
+ Card: typeof Card;
28
+ Cards: typeof Cards;
29
+ a: FC<AnchorHTMLAttributes<HTMLAnchorElement>>;
30
+ img: typeof Image;
31
+ h1: (props: HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
32
+ h2: (props: HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
33
+ h3: (props: HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
34
+ h4: (props: HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
35
+ h5: (props: HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
36
+ h6: (props: HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
37
+ table: typeof Table;
38
+ Callout: typeof Callout;
39
+ CalloutContainer: typeof CalloutContainer;
40
+ CalloutTitle: typeof CalloutTitle;
41
+ CalloutDescription: typeof CalloutDescription;
42
+ };
43
+ declare const createRelativeLink: typeof createRelativeLink$1;
44
+ //#endregion
45
+ export { createRelativeLink, defaultMdxComponents as default };
package/dist/mdx.js ADDED
@@ -0,0 +1,70 @@
1
+ import { cn } from "./utils/cn.js";
2
+ import { Card, Cards } from "./components/card.js";
3
+ import { Callout, CalloutContainer, CalloutDescription, CalloutTitle } from "./components/callout.js";
4
+ import { Heading } from "./components/heading.js";
5
+ import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "./components/codeblock.js";
6
+ import Link from "fumadocs-core/link";
7
+ import { Image } from "fumadocs-core/framework";
8
+ import { jsx } from "react/jsx-runtime";
9
+ //#region src/mdx.tsx
10
+ function Image$1(props) {
11
+ return /* @__PURE__ */ jsx(Image, {
12
+ sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 70vw, 900px",
13
+ ...props,
14
+ className: cn("rounded-lg", props.className)
15
+ });
16
+ }
17
+ function Table(props) {
18
+ return /* @__PURE__ */ jsx("div", {
19
+ className: "relative overflow-auto prose-no-margin my-6",
20
+ children: /* @__PURE__ */ jsx("table", { ...props })
21
+ });
22
+ }
23
+ const defaultMdxComponents = {
24
+ CodeBlockTab,
25
+ CodeBlockTabs,
26
+ CodeBlockTabsList,
27
+ CodeBlockTabsTrigger,
28
+ pre: (props) => /* @__PURE__ */ jsx(CodeBlock, {
29
+ ...props,
30
+ children: /* @__PURE__ */ jsx(Pre, { children: props.children })
31
+ }),
32
+ Card,
33
+ Cards,
34
+ a: Link,
35
+ img: Image$1,
36
+ h1: (props) => /* @__PURE__ */ jsx(Heading, {
37
+ as: "h1",
38
+ ...props
39
+ }),
40
+ h2: (props) => /* @__PURE__ */ jsx(Heading, {
41
+ as: "h2",
42
+ ...props
43
+ }),
44
+ h3: (props) => /* @__PURE__ */ jsx(Heading, {
45
+ as: "h3",
46
+ ...props
47
+ }),
48
+ h4: (props) => /* @__PURE__ */ jsx(Heading, {
49
+ as: "h4",
50
+ ...props
51
+ }),
52
+ h5: (props) => /* @__PURE__ */ jsx(Heading, {
53
+ as: "h5",
54
+ ...props
55
+ }),
56
+ h6: (props) => /* @__PURE__ */ jsx(Heading, {
57
+ as: "h6",
58
+ ...props
59
+ }),
60
+ table: Table,
61
+ Callout,
62
+ CalloutContainer,
63
+ CalloutTitle,
64
+ CalloutDescription
65
+ };
66
+ const createRelativeLink = () => {
67
+ throw new Error("`createRelativeLink` is only supported in Node.js environment");
68
+ };
69
+ //#endregion
70
+ export { createRelativeLink, defaultMdxComponents as default };
@@ -0,0 +1,15 @@
1
+ import defaultMdxComponents from "./mdx.js";
2
+ import { ComponentProps, FC } from "react";
3
+ import { LoaderConfig, LoaderOutput, Page } from "fumadocs-core/source";
4
+
5
+ //#region src/mdx.server.d.ts
6
+ /**
7
+ * Extend the default Link component to resolve relative file paths in `href`.
8
+ *
9
+ * @param page the current page
10
+ * @param source the source object
11
+ * @param OverrideLink The component to override from
12
+ */
13
+ declare function createRelativeLink<C extends LoaderConfig>(source: LoaderOutput<C>, page: Page | C['page'], OverrideLink?: FC<ComponentProps<'a'>>): FC<ComponentProps<'a'>>;
14
+ //#endregion
15
+ export { createRelativeLink, defaultMdxComponents as default };
@@ -0,0 +1,20 @@
1
+ import defaultMdxComponents from "./mdx.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/mdx.server.tsx
4
+ /**
5
+ * Extend the default Link component to resolve relative file paths in `href`.
6
+ *
7
+ * @param page the current page
8
+ * @param source the source object
9
+ * @param OverrideLink The component to override from
10
+ */
11
+ function createRelativeLink(source, page, OverrideLink = defaultMdxComponents.a) {
12
+ return async function RelativeLink({ href, ...props }) {
13
+ return /* @__PURE__ */ jsx(OverrideLink, {
14
+ href: href ? source.resolveHref(href, page) : href,
15
+ ...props
16
+ });
17
+ };
18
+ }
19
+ //#endregion
20
+ export { createRelativeLink, defaultMdxComponents as default };
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+
3
+ //#region ../../node_modules/.bun/react-medium-image-zoom@5.4.8+7492c01c6988791b/node_modules/react-medium-image-zoom/dist/controlled.d.ts
4
+ type ModalState = 'LOADED' | 'LOADING' | 'UNLOADED' | 'UNLOADING';
5
+ interface ControlledProps {
6
+ a11yNameButtonUnzoom?: string;
7
+ a11yNameButtonZoom?: string;
8
+ canSwipeToUnzoom?: boolean;
9
+ children: React.ReactNode;
10
+ classDialog?: string;
11
+ IconUnzoom?: React.ElementType;
12
+ IconZoom?: React.ElementType;
13
+ isDisabled?: boolean;
14
+ isZoomed: boolean;
15
+ onZoomChange?: (value: boolean, data: {
16
+ event: React.SyntheticEvent | Event;
17
+ }) => void;
18
+ swipeToUnzoomThreshold?: number;
19
+ wrapElement?: 'div' | 'span';
20
+ ZoomContent?: (data: {
21
+ buttonUnzoom: React.ReactElement<HTMLButtonElement>;
22
+ img: React.ReactElement | null;
23
+ isZoomImgLoaded: boolean;
24
+ modalState: ModalState;
25
+ onUnzoom: (e: Event) => void;
26
+ }) => React.ReactElement;
27
+ zoomImg?: React.ImgHTMLAttributes<HTMLImageElement>;
28
+ zoomMargin?: number;
29
+ }
30
+ //#endregion
31
+ export { ControlledProps };