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,23 @@
1
+ import { ComponentProps } from "react";
2
+ import * as Primitive from "fumadocs-core/toc";
3
+
4
+ //#region src/components/toc/default.d.ts
5
+ interface TOCItemsProps extends ComponentProps<'div'> {
6
+ thumbBox?: boolean;
7
+ }
8
+ declare function TOCItems({
9
+ ref,
10
+ className,
11
+ thumbBox,
12
+ children,
13
+ ...props
14
+ }: TOCItemsProps): import("react").JSX.Element;
15
+ declare function TOCEmpty(): import("react").JSX.Element;
16
+ declare function TOCItem({
17
+ item,
18
+ ...props
19
+ }: Primitive.TOCItemProps & {
20
+ item: Primitive.TOCItemType;
21
+ }): import("react").JSX.Element;
22
+ //#endregion
23
+ export { TOCEmpty, TOCItem, TOCItems, TOCItemsProps };
@@ -0,0 +1,259 @@
1
+ "use client";
2
+ import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
3
+ import { cn } from "../../utils/cn.js";
4
+ import { mergeRefs } from "../../utils/merge-refs.js";
5
+ import { useTOCItems } from "./index.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8
+ import { useTranslations } from "@fuma-translate/react";
9
+ import * as Primitive from "fumadocs-core/toc";
10
+ //#region src/components/toc/default.tsx
11
+ var default_exports = /* @__PURE__ */ __exportAll({
12
+ TOCEmpty: () => TOCEmpty,
13
+ TOCItem: () => TOCItem,
14
+ TOCItems: () => TOCItems
15
+ });
16
+ function TOCItems({ ref, className, thumbBox = true, children, ...props }) {
17
+ const containerRef = useRef(null);
18
+ const items = useTOCItems();
19
+ const [svg, setSvg] = useState(null);
20
+ const onPrint = useCallback(() => {
21
+ const container = containerRef.current;
22
+ if (!container || container.clientHeight === 0) return;
23
+ if (items.length === 0) {
24
+ setSvg(null);
25
+ return;
26
+ }
27
+ let w = 0;
28
+ let h = 0;
29
+ let d = "";
30
+ const positions = [];
31
+ const output = [];
32
+ for (let i = 0; i < items.length; i++) {
33
+ const item = items[i];
34
+ const element = container.querySelector(`a[href="${item.url}"]`);
35
+ if (!element) continue;
36
+ const styles = getComputedStyle(element);
37
+ const x = getLineOffset(item.depth) + .5;
38
+ const top = element.offsetTop + parseFloat(styles.paddingTop);
39
+ const bottom = element.offsetTop + element.clientHeight - parseFloat(styles.paddingBottom);
40
+ w = Math.max(x + 8, w);
41
+ h = Math.max(h, bottom);
42
+ if (i === 0) d += ` M${x} ${top} L${x} ${bottom}`;
43
+ else {
44
+ const [, upperBottom, upperX] = i > 0 ? positions[i - 1] : [
45
+ 0,
46
+ 0,
47
+ 0
48
+ ];
49
+ d += ` C ${upperX} ${top - 4} ${x} ${upperBottom + 4} ${x} ${top} L${x} ${bottom}`;
50
+ }
51
+ if (item._step !== void 0) output.push(/* @__PURE__ */ jsxs("g", {
52
+ transform: `translate(${x}, ${(top + bottom) / 2})`,
53
+ children: [/* @__PURE__ */ jsx("circle", {
54
+ cx: "0",
55
+ cy: "0",
56
+ r: "8",
57
+ className: "fill-fd-primary"
58
+ }), /* @__PURE__ */ jsx("text", {
59
+ cx: "0",
60
+ cy: "0",
61
+ textAnchor: "middle",
62
+ alignmentBaseline: "central",
63
+ dominantBaseline: "middle",
64
+ className: "fill-fd-primary-foreground font-medium text-xs leading-none font-mono rtl:-scale-x-100",
65
+ children: item._step
66
+ })]
67
+ }, i));
68
+ positions.push([
69
+ top,
70
+ bottom,
71
+ x
72
+ ]);
73
+ }
74
+ output.unshift(/* @__PURE__ */ jsx("path", {
75
+ d,
76
+ className: "stroke-fd-primary",
77
+ strokeWidth: "1",
78
+ fill: "none"
79
+ }, "path"));
80
+ const itemLineLengths = [];
81
+ if (thumbBox) {
82
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
83
+ path.setAttribute("d", d);
84
+ const n = path.getTotalLength();
85
+ for (let i = 0; i < positions.length; i++) {
86
+ const [top, bottom] = positions[i];
87
+ let l = i > 0 ? itemLineLengths[i - 1][1] + (top - positions[i - 1][1]) : top;
88
+ while (l < n && path.getPointAtLength(l).y < top) l++;
89
+ itemLineLengths.push([l, l + bottom - top]);
90
+ }
91
+ }
92
+ setSvg({
93
+ content: output,
94
+ width: w,
95
+ height: h,
96
+ d,
97
+ itemLineLengths,
98
+ positions
99
+ });
100
+ }, [items, thumbBox]);
101
+ useEffect(() => {
102
+ const container = containerRef.current;
103
+ if (!container) return;
104
+ const observer = new ResizeObserver(onPrint);
105
+ observer.observe(container);
106
+ onPrint();
107
+ return () => {
108
+ observer.unobserve(container);
109
+ };
110
+ }, [onPrint]);
111
+ return /* @__PURE__ */ jsxs("div", {
112
+ ref: mergeRefs(containerRef, ref),
113
+ className: cn("relative flex flex-col", className),
114
+ ...props,
115
+ children: [svg && /* @__PURE__ */ jsx(ThumbTrack, {
116
+ computed: svg,
117
+ thumbBox
118
+ }), children]
119
+ });
120
+ }
121
+ function TOCEmpty() {
122
+ return /* @__PURE__ */ jsx("div", {
123
+ className: "rounded-3xl bg-fd-card p-3 text-xs text-fd-muted-foreground",
124
+ children: useTranslations({ note: "table of contents" })("No Headings")
125
+ });
126
+ }
127
+ function ThumbTrack({ computed, thumbBox }) {
128
+ const ref = useRef(null);
129
+ const previousRef = useRef(null);
130
+ const tocInfo = Primitive.useTOC();
131
+ function calculate(items) {
132
+ const out = {};
133
+ const startIdx = items.findIndex((item) => item.active);
134
+ if (startIdx === -1) return out;
135
+ const endIdx = items.findLastIndex((item) => item.active);
136
+ out["--track-top"] = `${computed.positions[startIdx][0]}px`;
137
+ out["--track-bottom"] = `${computed.positions[endIdx][1]}px`;
138
+ if (thumbBox) {
139
+ let isUp = false;
140
+ if (previousRef.current) {
141
+ const prev = previousRef.current;
142
+ isUp = prev.startIdx > startIdx || prev.endIdx > endIdx || prev.startIdx === startIdx && prev.endIdx === endIdx && prev.isUp;
143
+ }
144
+ previousRef.current = {
145
+ startIdx,
146
+ endIdx,
147
+ isUp
148
+ };
149
+ out["--offset-distance"] = isUp ? `${computed.itemLineLengths[startIdx][0]}px` : `${computed.itemLineLengths[endIdx][1]}px`;
150
+ out["--opacity"] = items[isUp ? startIdx : endIdx].original._step !== void 0 ? "0" : "1";
151
+ }
152
+ return out;
153
+ }
154
+ Primitive.useTOCListener((items) => {
155
+ const element = ref.current;
156
+ if (!element) return;
157
+ for (const [k, v] of Object.entries(calculate(items))) element.style.setProperty(k, v);
158
+ });
159
+ return /* @__PURE__ */ jsxs("div", {
160
+ ref,
161
+ className: "absolute top-0 inset-s-0 origin-center rtl:-scale-x-100",
162
+ style: {
163
+ width: computed.width,
164
+ height: computed.height,
165
+ ...calculate(tocInfo.get())
166
+ },
167
+ children: [/* @__PURE__ */ jsx("svg", {
168
+ xmlns: "http://www.w3.org/2000/svg",
169
+ viewBox: `0 0 ${computed.width} ${computed.height}`,
170
+ className: "absolute transition-[clip-path]",
171
+ style: {
172
+ width: computed.width,
173
+ height: computed.height,
174
+ clipPath: `polygon(0 var(--track-top,0), 100% var(--track-top,0), 100% var(--track-bottom,0), 0 var(--track-bottom,0))`
175
+ },
176
+ children: computed.content
177
+ }), thumbBox && /* @__PURE__ */ jsx("div", {
178
+ className: "absolute left-0 size-1 bg-fd-primary rounded-full [offset-distance:var(--offset-distance,0)] opacity-(--opacity,0) transition-[opacity,offset-distance]",
179
+ style: { offsetPath: `path("${computed.d}")` }
180
+ })]
181
+ });
182
+ }
183
+ const BASE = 8;
184
+ function getItemOffset(depth) {
185
+ if (depth <= 2) return 20;
186
+ if (depth === 3) return 32;
187
+ return 44;
188
+ }
189
+ function getLineOffset(depth) {
190
+ if (depth <= 2) return BASE;
191
+ if (depth === 3) return 16;
192
+ return 24;
193
+ }
194
+ function TOCItem({ item, ...props }) {
195
+ const items = useTOCItems();
196
+ const { isFirst, isLast, svg } = useMemo(() => {
197
+ const index = items.indexOf(item);
198
+ const isFirst = index === 0;
199
+ const isLast = index === items.length - 1;
200
+ const l1 = getLineOffset(item.depth);
201
+ const l0 = isFirst ? l1 : getLineOffset(items[index - 1].depth);
202
+ const l2 = isLast ? l1 : getLineOffset(items[index + 1].depth);
203
+ return {
204
+ isFirst,
205
+ isLast,
206
+ svg: /* @__PURE__ */ jsxs("svg", {
207
+ xmlns: "http://www.w3.org/2000/svg",
208
+ className: cn("absolute -top-1.5 inset-s-0 bottom-0 h-[calc(100%+--spacing(1.5))] -z-1 rtl:-scale-x-100", l1 !== l2 && "h-full bottom-1.5"),
209
+ style: { width: Math.max(l0, l1) + 9 },
210
+ children: [
211
+ l0 !== l1 && /* @__PURE__ */ jsx("path", {
212
+ d: `M ${l0 + .5} 0 C ${l0 + .5} 8 ${l1 + .5} 4 ${l1 + .5} 12`,
213
+ stroke: "black",
214
+ strokeWidth: "1",
215
+ fill: "none",
216
+ className: "stroke-fd-foreground/10"
217
+ }),
218
+ /* @__PURE__ */ jsx("line", {
219
+ x1: l1 + .5,
220
+ y1: l0 === l1 ? "6" : "12",
221
+ x2: l1 + .5,
222
+ y2: "100%",
223
+ strokeWidth: "1",
224
+ className: "stroke-fd-foreground/10"
225
+ }),
226
+ item._step !== void 0 && /* @__PURE__ */ jsxs("g", {
227
+ transform: `translate(${l1 + .5}, ${l1 === l2 ? "3" : "6"})`,
228
+ children: [/* @__PURE__ */ jsx("circle", {
229
+ cx: "0",
230
+ cy: "50%",
231
+ r: "8",
232
+ className: "fill-fd-muted"
233
+ }), /* @__PURE__ */ jsx("text", {
234
+ x: "0",
235
+ y: "50%",
236
+ textAnchor: "middle",
237
+ alignmentBaseline: "central",
238
+ dominantBaseline: "middle",
239
+ className: "fill-fd-muted-foreground font-medium text-xs leading-none font-mono rtl:-scale-x-100",
240
+ children: item._step
241
+ })]
242
+ })
243
+ ]
244
+ })
245
+ };
246
+ }, [items, item]);
247
+ return /* @__PURE__ */ jsxs(Primitive.TOCItem, {
248
+ href: item.url,
249
+ ...props,
250
+ className: cn("prose relative py-1.5 text-sm scroll-m-4 text-fd-muted-foreground hover:text-fd-accent-foreground transition-colors wrap-anywhere data-[active=true]:text-fd-primary", isFirst && "pt-0", isLast && "pb-0", props.className),
251
+ style: {
252
+ paddingInlineStart: getItemOffset(item.depth),
253
+ ...props.style
254
+ },
255
+ children: [svg, item.title]
256
+ });
257
+ }
258
+ //#endregion
259
+ export { TOCEmpty, TOCItem, TOCItems, default_exports };
@@ -0,0 +1,19 @@
1
+ import { ComponentProps } from "react";
2
+ import * as Primitive from "fumadocs-core/toc";
3
+
4
+ //#region src/components/toc/index.d.ts
5
+ declare function useTOCItems(): Primitive.TOCItemType[];
6
+ type TOCProviderProps = Primitive.AnchorProviderProps;
7
+ declare const useActiveAnchor: typeof Primitive.useActiveAnchor, useActiveAnchors: typeof Primitive.useActiveAnchors, useItems: typeof Primitive.useItems;
8
+ declare function TOCProvider({
9
+ toc,
10
+ children,
11
+ ...props
12
+ }: TOCProviderProps): import("react").JSX.Element;
13
+ declare function TOCScrollArea({
14
+ ref,
15
+ className,
16
+ ...props
17
+ }: ComponentProps<'div'>): import("react").JSX.Element;
18
+ //#endregion
19
+ export { TOCProvider, TOCProviderProps, TOCScrollArea, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
3
+ import { cn } from "../../utils/cn.js";
4
+ import { mergeRefs } from "../../utils/merge-refs.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { createContext, use, useRef } from "react";
7
+ import * as Primitive from "fumadocs-core/toc";
8
+ //#region src/components/toc/index.tsx
9
+ var toc_exports = /* @__PURE__ */ __exportAll({
10
+ TOCProvider: () => TOCProvider,
11
+ TOCScrollArea: () => TOCScrollArea,
12
+ useActiveAnchor: () => useActiveAnchor,
13
+ useActiveAnchors: () => useActiveAnchors,
14
+ useItems: () => useItems,
15
+ useTOCItems: () => useTOCItems
16
+ });
17
+ const TOCContext = createContext([]);
18
+ function useTOCItems() {
19
+ return use(TOCContext);
20
+ }
21
+ const { useActiveAnchor, useActiveAnchors, useItems } = Primitive;
22
+ function TOCProvider({ toc, children, ...props }) {
23
+ return /* @__PURE__ */ jsx(TOCContext, {
24
+ value: toc,
25
+ children: /* @__PURE__ */ jsx(Primitive.AnchorProvider, {
26
+ toc,
27
+ ...props,
28
+ children
29
+ })
30
+ });
31
+ }
32
+ function TOCScrollArea({ ref, className, ...props }) {
33
+ const viewRef = useRef(null);
34
+ return /* @__PURE__ */ jsx("div", {
35
+ ref: mergeRefs(viewRef, ref),
36
+ className: cn("relative min-h-0 text-sm ms-px overflow-auto [scrollbar-width:none] mask-[linear-gradient(to_bottom,transparent,white_16px,white_calc(100%-16px),transparent)] py-3", className),
37
+ ...props,
38
+ children: /* @__PURE__ */ jsx(Primitive.ScrollProvider, {
39
+ containerRef: viewRef,
40
+ children: props.children
41
+ })
42
+ });
43
+ }
44
+ //#endregion
45
+ export { TOCProvider, TOCScrollArea, toc_exports, useActiveAnchor, useActiveAnchors, useItems, useTOCItems };
@@ -0,0 +1,43 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+
3
+ //#region src/components/type-table.d.ts
4
+ interface ParameterNode {
5
+ name: string;
6
+ description: ReactNode;
7
+ }
8
+ interface TypeNode {
9
+ /**
10
+ * Additional description of the field
11
+ */
12
+ description?: ReactNode;
13
+ /**
14
+ * type signature (short)
15
+ */
16
+ type: ReactNode;
17
+ /**
18
+ * type signature (full)
19
+ */
20
+ typeDescription?: ReactNode;
21
+ /**
22
+ * Optional `href` for the type
23
+ */
24
+ typeDescriptionLink?: string;
25
+ default?: ReactNode;
26
+ required?: boolean;
27
+ deprecated?: boolean;
28
+ /**
29
+ * a list of parameters info if the type is a function.
30
+ */
31
+ parameters?: ParameterNode[];
32
+ returns?: ReactNode;
33
+ }
34
+ declare function TypeTable({
35
+ id,
36
+ type,
37
+ className,
38
+ ...props
39
+ }: {
40
+ type: Record<string, TypeNode>;
41
+ } & ComponentProps<'div'>): import("react").JSX.Element;
42
+ //#endregion
43
+ export { ParameterNode, TypeNode, TypeTable };
@@ -0,0 +1,117 @@
1
+ "use client";
2
+ import { cn } from "../utils/cn.js";
3
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible.js";
4
+ import Link from "fumadocs-core/link";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { ChevronDown } from "lucide-react";
7
+ import { cva } from "class-variance-authority";
8
+ import { useEffect, useState } from "react";
9
+ import { useTranslations } from "@fuma-translate/react";
10
+ //#region src/components/type-table.tsx
11
+ const fieldVariants = cva("text-fd-muted-foreground not-prose pe-2");
12
+ function TypeTable({ id, type, className, ...props }) {
13
+ const t = useTranslations({ note: "type table" });
14
+ return /* @__PURE__ */ jsxs("div", {
15
+ id,
16
+ className: cn("@container flex flex-col p-2 bg-fd-card text-fd-card-foreground rounded-3xl my-6 text-sm overflow-hidden", className),
17
+ ...props,
18
+ children: [/* @__PURE__ */ jsxs("div", {
19
+ className: "flex font-medium items-center px-3 py-1 not-prose text-fd-muted-foreground",
20
+ children: [/* @__PURE__ */ jsx("p", {
21
+ className: "w-1/4",
22
+ children: t("Prop")
23
+ }), /* @__PURE__ */ jsx("p", {
24
+ className: "@max-xl:hidden",
25
+ children: t("Type")
26
+ })]
27
+ }), Object.entries(type).map(([key, value]) => /* @__PURE__ */ jsx(Item, {
28
+ parentId: id,
29
+ name: key,
30
+ item: value
31
+ }, key))]
32
+ });
33
+ }
34
+ function Item({ parentId, name, item: { parameters = [], description, required = false, deprecated, typeDescription, default: defaultValue, type, typeDescriptionLink, returns } }) {
35
+ const t = useTranslations({ note: "type table" });
36
+ const [open, setOpen] = useState(false);
37
+ const id = parentId ? `${parentId}-${name}` : void 0;
38
+ useEffect(() => {
39
+ const hash = window.location.hash;
40
+ if (!id || !hash) return;
41
+ if (`#${id}` === hash) setOpen(true);
42
+ }, [id]);
43
+ return /* @__PURE__ */ jsxs(Collapsible, {
44
+ id,
45
+ open,
46
+ onOpenChange: (v) => {
47
+ if (v && id) window.history.replaceState(null, "", `#${id}`);
48
+ setOpen(v);
49
+ },
50
+ className: cn("rounded-2xl overflow-hidden scroll-m-20 transition-all", open ? "bg-fd-background not-last:mb-2" : ""),
51
+ children: [/* @__PURE__ */ jsxs(CollapsibleTrigger, {
52
+ className: "relative flex flex-row items-center w-full group text-start px-3 py-2 not-prose hover:bg-fd-accent rounded-2xl focus-visible:outline-none focus-visible:bg-fd-accent",
53
+ children: [
54
+ /* @__PURE__ */ jsxs("code", {
55
+ className: cn("text-fd-primary min-w-fit w-1/4 font-mono font-medium pe-2", deprecated && "line-through text-fd-primary/50"),
56
+ children: [name, !required && "?"]
57
+ }),
58
+ typeDescriptionLink ? /* @__PURE__ */ jsx(Link, {
59
+ href: typeDescriptionLink,
60
+ className: "underline @max-xl:hidden",
61
+ children: type
62
+ }) : /* @__PURE__ */ jsx("span", {
63
+ className: "@max-xl:hidden",
64
+ children: type
65
+ }),
66
+ /* @__PURE__ */ jsx(ChevronDown, { className: "absolute end-2 size-4 text-fd-muted-foreground transition-transform group-data-[state=open]:rotate-180" })
67
+ ]
68
+ }), /* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsxs("div", {
69
+ className: "grid grid-cols-[1fr_3fr] gap-y-4 text-sm p-2 overflow-auto fd-scroll-container bg-fd-muted/40",
70
+ children: [
71
+ /* @__PURE__ */ jsx("div", {
72
+ className: "text-sm prose col-span-full prose-no-margin empty:hidden",
73
+ children: description
74
+ }),
75
+ typeDescription && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
76
+ className: cn(fieldVariants()),
77
+ children: t("Type")
78
+ }), /* @__PURE__ */ jsx("p", {
79
+ className: "my-auto not-prose",
80
+ children: typeDescription
81
+ })] }),
82
+ defaultValue && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
83
+ className: cn(fieldVariants()),
84
+ children: t("Default")
85
+ }), /* @__PURE__ */ jsx("p", {
86
+ className: "my-auto not-prose",
87
+ children: defaultValue
88
+ })] }),
89
+ parameters.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
90
+ className: cn(fieldVariants()),
91
+ children: t("Parameters")
92
+ }), /* @__PURE__ */ jsx("div", {
93
+ className: "flex flex-col gap-2",
94
+ children: parameters.map((param) => /* @__PURE__ */ jsxs("div", {
95
+ className: "inline-flex items-center flex-wrap gap-1",
96
+ children: [/* @__PURE__ */ jsxs("p", {
97
+ className: "font-medium not-prose text-nowrap",
98
+ children: [param.name, " -"]
99
+ }), /* @__PURE__ */ jsx("div", {
100
+ className: "text-sm prose prose-no-margin",
101
+ children: param.description
102
+ })]
103
+ }, param.name))
104
+ })] }),
105
+ returns && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
106
+ className: cn(fieldVariants()),
107
+ children: t("Returns")
108
+ }), /* @__PURE__ */ jsx("div", {
109
+ className: "my-auto text-sm prose prose-no-margin",
110
+ children: returns
111
+ })] })
112
+ ]
113
+ }) })]
114
+ });
115
+ }
116
+ //#endregion
117
+ export { TypeTable };
@@ -0,0 +1,30 @@
1
+ import { ComponentProps } from "react";
2
+ import * as Primitive from "@radix-ui/react-accordion";
3
+
4
+ //#region src/components/ui/accordion.d.ts
5
+ declare function Accordion({
6
+ className,
7
+ ...props
8
+ }: ComponentProps<typeof Primitive.Root>): import("react").JSX.Element;
9
+ declare function AccordionItem({
10
+ className,
11
+ children,
12
+ ...props
13
+ }: ComponentProps<typeof Primitive.Item>): import("react").JSX.Element;
14
+ declare function AccordionHeader({
15
+ className,
16
+ children,
17
+ ...props
18
+ }: ComponentProps<typeof Primitive.Header>): import("react").JSX.Element;
19
+ declare function AccordionTrigger({
20
+ className,
21
+ children,
22
+ ...props
23
+ }: ComponentProps<typeof Primitive.Trigger>): import("react").JSX.Element;
24
+ declare function AccordionContent({
25
+ className,
26
+ children,
27
+ ...props
28
+ }: ComponentProps<typeof Primitive.Content>): import("react").JSX.Element;
29
+ //#endregion
30
+ export { Accordion, AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger };
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { cn } from "../../utils/cn.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { ChevronRight } from "lucide-react";
5
+ import * as Primitive from "@radix-ui/react-accordion";
6
+ //#region src/components/ui/accordion.tsx
7
+ function Accordion({ className, ...props }) {
8
+ return /* @__PURE__ */ jsx(Primitive.Root, {
9
+ className: cn("flex flex-col gap-2 overflow-hidden rounded-3xl bg-fd-muted p-2", className),
10
+ ...props
11
+ });
12
+ }
13
+ function AccordionItem({ className, children, ...props }) {
14
+ return /* @__PURE__ */ jsx(Primitive.Item, {
15
+ className: cn("scroll-m-24 overflow-hidden rounded-2xl bg-fd-card", className),
16
+ ...props,
17
+ children
18
+ });
19
+ }
20
+ function AccordionHeader({ className, children, ...props }) {
21
+ return /* @__PURE__ */ jsx(Primitive.Header, {
22
+ className: cn("not-prose flex flex-row items-center text-fd-card-foreground font-medium transition-colors has-focus-visible:bg-fd-accent/50", className),
23
+ ...props,
24
+ children
25
+ });
26
+ }
27
+ function AccordionTrigger({ className, children, ...props }) {
28
+ return /* @__PURE__ */ jsxs(Primitive.Trigger, {
29
+ className: cn("group flex flex-1 items-center gap-2 px-3 py-2.5 text-start focus-visible:outline-none", className),
30
+ ...props,
31
+ children: [/* @__PURE__ */ jsx(ChevronRight, { className: "size-4 shrink-0 text-fd-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-90" }), children]
32
+ });
33
+ }
34
+ function AccordionContent({ className, children, ...props }) {
35
+ return /* @__PURE__ */ jsx(Primitive.Content, {
36
+ className: cn("overflow-hidden data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down", className),
37
+ ...props,
38
+ children
39
+ });
40
+ }
41
+ //#endregion
42
+ export { Accordion, AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger };
@@ -0,0 +1,11 @@
1
+ import { VariantProps } from "class-variance-authority";
2
+
3
+ //#region src/components/ui/button.d.ts
4
+ declare const buttonVariants: (props?: ({
5
+ variant?: "primary" | "outline" | "ghost" | "secondary" | null | undefined;
6
+ color?: "primary" | "outline" | "ghost" | "secondary" | null | undefined;
7
+ size?: "icon" | "sm" | "icon-sm" | "icon-xs" | null | undefined;
8
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
+ type ButtonProps = VariantProps<typeof buttonVariants>;
10
+ //#endregion
11
+ export { ButtonProps, buttonVariants };
@@ -0,0 +1,20 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/ui/button.tsx
3
+ const variants = {
4
+ primary: "bg-fd-primary text-fd-primary-foreground hover:bg-fd-primary/80 disabled:bg-fd-secondary disabled:text-fd-secondary-foreground",
5
+ outline: "hover:bg-fd-accent hover:text-fd-accent-foreground",
6
+ ghost: "hover:bg-fd-accent hover:text-fd-accent-foreground",
7
+ secondary: "bg-fd-secondary text-fd-secondary-foreground hover:bg-fd-accent hover:text-fd-accent-foreground"
8
+ };
9
+ const buttonVariants = cva("inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100 disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:bg-fd-accent", { variants: {
10
+ variant: variants,
11
+ color: variants,
12
+ size: {
13
+ sm: "gap-1 px-2 py-1.5 text-xs",
14
+ icon: "p-1.5 [&_svg]:size-5",
15
+ "icon-sm": "p-1.5 [&_svg]:size-4.5",
16
+ "icon-xs": "p-1 [&_svg]:size-4"
17
+ }
18
+ } });
19
+ //#endregion
20
+ export { buttonVariants };
@@ -0,0 +1,15 @@
1
+ import * as React$1 from "react";
2
+ import * as Primitive from "@radix-ui/react-collapsible";
3
+
4
+ //#region src/components/ui/collapsible.d.ts
5
+ declare const Collapsible: React$1.ForwardRefExoticComponent<Primitive.CollapsibleProps & React$1.RefAttributes<HTMLDivElement>>;
6
+ declare const CollapsibleTrigger: React$1.ForwardRefExoticComponent<Primitive.CollapsibleTriggerProps & React$1.RefAttributes<HTMLButtonElement>>;
7
+ declare function CollapsibleContent({
8
+ children,
9
+ ...props
10
+ }: React$1.ComponentPropsWithRef<typeof Primitive.CollapsibleContent>): React$1.JSX.Element;
11
+ type CollapsibleProps = Primitive.CollapsibleProps;
12
+ type CollapsibleContentProps = Primitive.CollapsibleContentProps;
13
+ type CollapsibleTriggerProps = Primitive.CollapsibleTriggerProps;
14
+ //#endregion
15
+ export { Collapsible, CollapsibleContent, CollapsibleContentProps, CollapsibleProps, CollapsibleTrigger, CollapsibleTriggerProps };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { cn } from "../../utils/cn.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { useEffect, useState } from "react";
5
+ import * as Primitive from "@radix-ui/react-collapsible";
6
+ //#region src/components/ui/collapsible.tsx
7
+ const Collapsible = Primitive.Root;
8
+ const CollapsibleTrigger = Primitive.CollapsibleTrigger;
9
+ function CollapsibleContent({ children, ...props }) {
10
+ const [mounted, setMounted] = useState(false);
11
+ useEffect(() => {
12
+ setMounted(true);
13
+ }, []);
14
+ return /* @__PURE__ */ jsx(Primitive.CollapsibleContent, {
15
+ ...props,
16
+ className: cn("overflow-hidden", mounted && "data-[state=closed]:animate-fd-collapsible-up data-[state=open]:animate-fd-collapsible-down", props.className),
17
+ children
18
+ });
19
+ }
20
+ //#endregion
21
+ export { Collapsible, CollapsibleContent, CollapsibleTrigger };