fumadocs-ui 15.2.8 → 16.0.3

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 (202) hide show
  1. package/README.md +1 -1
  2. package/css/black.css +4 -2
  3. package/css/catppuccin.css +2 -0
  4. package/css/default.css +33 -0
  5. package/css/dusk.css +2 -0
  6. package/css/neutral.css +11 -8
  7. package/css/ocean.css +5 -3
  8. package/css/preset.css +237 -16
  9. package/css/purple.css +12 -10
  10. package/css/shadcn.css +31 -0
  11. package/css/shiki.css +78 -51
  12. package/css/solar.css +48 -0
  13. package/css/vitepress.css +3 -4
  14. package/dist/components/accordion.d.ts +6 -3
  15. package/dist/components/accordion.d.ts.map +1 -1
  16. package/dist/components/accordion.js +19 -11
  17. package/dist/components/banner.d.ts +8 -2
  18. package/dist/components/banner.d.ts.map +1 -1
  19. package/dist/components/banner.js +25 -30
  20. package/dist/components/callout.d.ts +2 -2
  21. package/dist/components/callout.d.ts.map +1 -1
  22. package/dist/components/callout.js +15 -18
  23. package/dist/components/card.d.ts.map +1 -1
  24. package/dist/components/card.js +2 -2
  25. package/dist/components/codeblock.d.ts +19 -23
  26. package/dist/components/codeblock.d.ts.map +1 -1
  27. package/dist/components/codeblock.js +55 -24
  28. package/dist/components/dialog/search-algolia.d.ts +5 -4
  29. package/dist/components/dialog/search-algolia.d.ts.map +1 -1
  30. package/dist/components/dialog/search-algolia.js +21 -7
  31. package/dist/components/dialog/search-default.d.ts +4 -2
  32. package/dist/components/dialog/search-default.d.ts.map +1 -1
  33. package/dist/components/dialog/search-default.js +22 -6
  34. package/dist/components/dialog/search-orama.d.ts +5 -3
  35. package/dist/components/dialog/search-orama.d.ts.map +1 -1
  36. package/dist/components/dialog/search-orama.js +21 -6
  37. package/dist/components/dialog/search.d.ts +61 -27
  38. package/dist/components/dialog/search.d.ts.map +1 -1
  39. package/dist/components/dialog/search.js +155 -67
  40. package/dist/components/dynamic-codeblock.d.ts +16 -2
  41. package/dist/components/dynamic-codeblock.d.ts.map +1 -1
  42. package/dist/components/dynamic-codeblock.js +22 -10
  43. package/dist/components/files.d.ts.map +1 -1
  44. package/dist/components/files.js +1 -1
  45. package/dist/components/github-info.js +1 -1
  46. package/dist/components/heading.js +1 -1
  47. package/dist/components/image-zoom.css +4 -0
  48. package/dist/components/inline-toc.d.ts +2 -2
  49. package/dist/components/inline-toc.d.ts.map +1 -1
  50. package/dist/components/inline-toc.js +1 -1
  51. package/dist/components/layout/language-toggle.js +1 -1
  52. package/dist/components/layout/root-toggle.d.ts +5 -15
  53. package/dist/components/layout/root-toggle.d.ts.map +1 -1
  54. package/dist/components/layout/root-toggle.js +10 -12
  55. package/dist/components/layout/search-toggle.d.ts +6 -4
  56. package/dist/components/layout/search-toggle.d.ts.map +1 -1
  57. package/dist/components/layout/search-toggle.js +5 -5
  58. package/dist/components/layout/sidebar.d.ts +21 -13
  59. package/dist/components/layout/sidebar.d.ts.map +1 -1
  60. package/dist/components/layout/sidebar.js +67 -65
  61. package/dist/components/layout/theme-toggle.js +1 -1
  62. package/dist/components/layout/toc-clerk.d.ts +2 -4
  63. package/dist/components/layout/toc-clerk.d.ts.map +1 -1
  64. package/dist/components/layout/toc-clerk.js +9 -5
  65. package/dist/components/layout/toc-thumb.js +1 -1
  66. package/dist/components/layout/toc.d.ts +6 -22
  67. package/dist/components/layout/toc.d.ts.map +1 -1
  68. package/dist/components/layout/toc.js +14 -18
  69. package/dist/components/tabs.d.ts +18 -18
  70. package/dist/components/tabs.d.ts.map +1 -1
  71. package/dist/components/tabs.js +44 -105
  72. package/dist/components/tabs.unstyled.d.ts +24 -0
  73. package/dist/components/tabs.unstyled.d.ts.map +1 -0
  74. package/dist/components/tabs.unstyled.js +89 -0
  75. package/dist/components/type-table.d.ts +19 -10
  76. package/dist/components/type-table.d.ts.map +1 -1
  77. package/dist/components/type-table.js +19 -10
  78. package/dist/components/ui/button.d.ts +2 -1
  79. package/dist/components/ui/button.d.ts.map +1 -1
  80. package/dist/components/ui/button.js +12 -8
  81. package/dist/components/ui/navigation-menu.js +2 -2
  82. package/dist/components/ui/popover.js +1 -1
  83. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  84. package/dist/components/ui/scroll-area.js +1 -1
  85. package/dist/contexts/search.d.ts +10 -2
  86. package/dist/contexts/search.d.ts.map +1 -1
  87. package/dist/contexts/search.js +7 -1
  88. package/dist/contexts/sidebar.d.ts.map +1 -1
  89. package/dist/contexts/sidebar.js +2 -3
  90. package/dist/contexts/tree.d.ts +2 -1
  91. package/dist/contexts/tree.d.ts.map +1 -1
  92. package/dist/contexts/tree.js +9 -2
  93. package/dist/i18n.d.ts +13 -11
  94. package/dist/i18n.d.ts.map +1 -1
  95. package/dist/i18n.js +14 -37
  96. package/dist/icons.d.ts +49 -0
  97. package/dist/icons.d.ts.map +1 -0
  98. package/dist/icons.js +282 -0
  99. package/dist/layouts/docs/client.d.ts +9 -0
  100. package/dist/layouts/docs/client.d.ts.map +1 -0
  101. package/dist/layouts/docs/client.js +46 -0
  102. package/dist/layouts/docs/index.d.ts +36 -0
  103. package/dist/layouts/docs/index.d.ts.map +1 -0
  104. package/dist/layouts/docs/index.js +77 -0
  105. package/dist/layouts/docs/page-client.d.ts +25 -0
  106. package/dist/layouts/docs/page-client.d.ts.map +1 -0
  107. package/dist/layouts/docs/page-client.js +157 -0
  108. package/dist/layouts/docs/page.d.ts +17 -0
  109. package/dist/layouts/docs/page.d.ts.map +1 -0
  110. package/dist/layouts/docs/page.js +26 -0
  111. package/dist/layouts/{home.d.ts → home/index.d.ts} +2 -3
  112. package/dist/layouts/home/index.d.ts.map +1 -0
  113. package/dist/layouts/home/index.js +56 -0
  114. package/dist/layouts/home/menu.d.ts +1 -1
  115. package/dist/layouts/home/menu.d.ts.map +1 -1
  116. package/dist/layouts/home/menu.js +3 -6
  117. package/dist/layouts/home/navbar.d.ts +4 -4
  118. package/dist/layouts/home/navbar.d.ts.map +1 -1
  119. package/dist/layouts/home/navbar.js +3 -4
  120. package/dist/layouts/notebook/client.d.ts +11 -0
  121. package/dist/layouts/notebook/client.d.ts.map +1 -0
  122. package/dist/layouts/notebook/client.js +45 -0
  123. package/dist/layouts/notebook/index.d.ts +34 -0
  124. package/dist/layouts/notebook/index.d.ts.map +1 -0
  125. package/dist/layouts/notebook/index.js +112 -0
  126. package/dist/layouts/shared/client.d.ts +6 -0
  127. package/dist/layouts/shared/client.d.ts.map +1 -0
  128. package/dist/layouts/{links.js → shared/client.js} +4 -6
  129. package/dist/layouts/shared/index.d.ts +122 -0
  130. package/dist/layouts/shared/index.d.ts.map +1 -0
  131. package/dist/layouts/{shared.js → shared/index.js} +1 -15
  132. package/dist/mdx.d.ts +7 -2
  133. package/dist/mdx.d.ts.map +1 -1
  134. package/dist/mdx.js +5 -1
  135. package/dist/mdx.server.d.ts.map +1 -1
  136. package/dist/mdx.server.js +10 -3
  137. package/dist/page.d.ts +33 -35
  138. package/dist/page.d.ts.map +1 -1
  139. package/dist/page.js +28 -32
  140. package/dist/provider/base.d.ts +1 -1
  141. package/dist/provider/base.d.ts.map +1 -1
  142. package/dist/provider/base.js +9 -9
  143. package/dist/provider/index.d.ts +5 -3
  144. package/dist/provider/index.d.ts.map +1 -1
  145. package/dist/provider/index.js +6 -6
  146. package/dist/provider/next.d.ts +4 -0
  147. package/dist/provider/next.d.ts.map +1 -0
  148. package/dist/provider/next.js +7 -0
  149. package/dist/provider/react-router.d.ts +4 -0
  150. package/dist/provider/react-router.d.ts.map +1 -0
  151. package/dist/provider/react-router.js +7 -0
  152. package/dist/provider/tanstack.d.ts +4 -0
  153. package/dist/provider/tanstack.d.ts.map +1 -0
  154. package/dist/provider/tanstack.js +7 -0
  155. package/dist/provider/waku.d.ts +4 -0
  156. package/dist/provider/waku.d.ts.map +1 -0
  157. package/dist/provider/waku.js +7 -0
  158. package/dist/style.css +944 -470
  159. package/dist/utils/get-sidebar-tabs.d.ts +18 -4
  160. package/dist/utils/get-sidebar-tabs.d.ts.map +1 -1
  161. package/dist/utils/get-sidebar-tabs.js +11 -8
  162. package/dist/utils/is-active.d.ts +2 -0
  163. package/dist/utils/is-active.d.ts.map +1 -1
  164. package/dist/utils/is-active.js +12 -4
  165. package/dist/utils/merge-refs.d.ts +3 -0
  166. package/dist/utils/merge-refs.d.ts.map +1 -0
  167. package/dist/utils/merge-refs.js +12 -0
  168. package/dist/utils/use-copy-button.d.ts +1 -1
  169. package/dist/utils/use-copy-button.d.ts.map +1 -1
  170. package/dist/utils/use-copy-button.js +9 -7
  171. package/package.json +76 -32
  172. package/css/animations.css +0 -199
  173. package/dist/components/ui/tabs.d.ts +0 -8
  174. package/dist/components/ui/tabs.d.ts.map +0 -1
  175. package/dist/components/ui/tabs.js +0 -16
  176. package/dist/layouts/docs/shared.d.ts +0 -25
  177. package/dist/layouts/docs/shared.d.ts.map +0 -1
  178. package/dist/layouts/docs/shared.js +0 -24
  179. package/dist/layouts/docs-client.d.ts +0 -5
  180. package/dist/layouts/docs-client.d.ts.map +0 -1
  181. package/dist/layouts/docs-client.js +0 -33
  182. package/dist/layouts/docs.d.ts +0 -30
  183. package/dist/layouts/docs.d.ts.map +0 -1
  184. package/dist/layouts/docs.js +0 -50
  185. package/dist/layouts/home.d.ts.map +0 -1
  186. package/dist/layouts/home.js +0 -44
  187. package/dist/layouts/links.d.ts +0 -79
  188. package/dist/layouts/links.d.ts.map +0 -1
  189. package/dist/layouts/notebook-client.d.ts +0 -12
  190. package/dist/layouts/notebook-client.d.ts.map +0 -1
  191. package/dist/layouts/notebook-client.js +0 -47
  192. package/dist/layouts/notebook.d.ts +0 -17
  193. package/dist/layouts/notebook.d.ts.map +0 -1
  194. package/dist/layouts/notebook.js +0 -68
  195. package/dist/layouts/shared.d.ts +0 -65
  196. package/dist/layouts/shared.d.ts.map +0 -1
  197. package/dist/page-client.d.ts +0 -28
  198. package/dist/page-client.d.ts.map +0 -1
  199. package/dist/page-client.js +0 -150
  200. package/dist/page.server.d.ts +0 -13
  201. package/dist/page.server.d.ts.map +0 -1
  202. package/dist/page.server.js +0 -36
package/css/solar.css ADDED
@@ -0,0 +1,48 @@
1
+ @import './neutral.css';
2
+
3
+ @theme {
4
+ --color-fd-primary: oklch(0.487 0.083 262.691);
5
+ --color-fd-article: hsl(0, 0%, 97%);
6
+ }
7
+
8
+ :root {
9
+ letter-spacing: -0.25px;
10
+ --fd-layout-width: 1600px;
11
+ --fd-page-width: 1400px;
12
+ }
13
+
14
+ .dark {
15
+ --color-fd-primary: oklch(0.902 0.0461 259.51);
16
+ --color-fd-article: hsl(0, 0%, 7.04%);
17
+ --color-fd-background: hsl(0, 0%, 5.04%);
18
+ }
19
+
20
+ @variant md {
21
+ #nd-page article {
22
+ @apply bg-fd-article rounded-xl border shadow-xl my-4;
23
+ }
24
+
25
+ #nd-tocnav,
26
+ #nd-subnav > div {
27
+ border: none;
28
+ }
29
+
30
+ .fd-default-layout #nd-page article {
31
+ @apply mx-4;
32
+ }
33
+
34
+ .fd-notebook-layout #nd-page article {
35
+ @apply mx-6;
36
+ }
37
+ }
38
+
39
+ #nd-sidebar {
40
+ @apply bg-fd-background;
41
+ }
42
+
43
+ #nd-sidebar[data-collapsed='false'] {
44
+ border: none;
45
+ --color-fd-muted: inherit;
46
+ --color-fd-secondary: inherit;
47
+ --color-fd-muted-foreground: inherit;
48
+ }
package/css/vitepress.css CHANGED
@@ -1,3 +1,5 @@
1
+ @import './default.css';
2
+
1
3
  @theme {
2
4
  --color-fd-muted: hsl(0, 0%, 96.1%);
3
5
  --color-fd-popover: hsl(0, 0%, 100%);
@@ -63,16 +65,13 @@
63
65
 
64
66
  #nd-sidebar {
65
67
  background-color: hsl(240, 6%, 97%);
68
+ border-color: transparent;
66
69
  }
67
70
 
68
71
  .dark #nd-sidebar {
69
72
  background-color: hsl(240, 4%, 9%);
70
73
  }
71
74
 
72
- #nd-sidebar > div {
73
- border-color: transparent;
74
- }
75
-
76
75
  button[data-search-full] {
77
76
  background-color: var(--color-fd-background);
78
77
  }
@@ -1,6 +1,9 @@
1
+ import type { AccordionMultipleProps, AccordionSingleProps } from '@radix-ui/react-accordion';
1
2
  import * as AccordionPrimitive from '@radix-ui/react-accordion';
2
- export declare const Accordions: import("react").ForwardRefExoticComponent<(Omit<AccordionPrimitive.AccordionSingleProps, "value" | "onValueChange"> | Omit<AccordionPrimitive.AccordionMultipleProps, "value" | "onValueChange">) & import("react").RefAttributes<HTMLDivElement>>;
3
- export declare const Accordion: import("react").ForwardRefExoticComponent<Omit<Omit<AccordionPrimitive.AccordionItemProps & import("react").RefAttributes<HTMLDivElement>, "ref">, "value"> & {
4
- title: string;
3
+ import { type ReactNode } from 'react';
4
+ export declare const Accordions: import("react").ForwardRefExoticComponent<(Omit<AccordionSingleProps, "value" | "onValueChange"> | Omit<AccordionMultipleProps, "value" | "onValueChange">) & import("react").RefAttributes<HTMLDivElement>>;
5
+ export declare const Accordion: import("react").ForwardRefExoticComponent<Omit<Omit<AccordionPrimitive.AccordionItemProps & import("react").RefAttributes<HTMLDivElement>, "ref">, "title" | "value"> & {
6
+ title: string | ReactNode;
7
+ value?: string;
5
8
  } & import("react").RefAttributes<HTMLDivElement>>;
6
9
  //# sourceMappingURL=accordion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../src/components/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,kBAAkB,MAAM,2BAA2B,CAAC;AAgBhE,eAAO,MAAM,UAAU,oPA+BrB,CAAC;AAIH,eAAO,MAAM,SAAS;WAGX,MAAM;kDA0Bf,CAAC"}
1
+ {"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../src/components/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,kBAAkB,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAMf,eAAO,MAAM,UAAU,8MAuCrB,CAAC;AAIH,eAAO,MAAM,SAAS;WAMX,MAAM,GAAG,SAAS;YACjB,MAAM;kDAiCjB,CAAC"}
@@ -1,33 +1,41 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as AccordionPrimitive from '@radix-ui/react-accordion';
4
- import { Check, ChevronRight, LinkIcon } from 'lucide-react';
5
- import { forwardRef, useState, useEffect, } from 'react';
4
+ import { Check, ChevronRight, Link as LinkIcon } from '../icons.js';
5
+ import { forwardRef, useEffect, useRef, useState, } from 'react';
6
6
  import { cn } from '../utils/cn.js';
7
7
  import { useCopyButton } from '../utils/use-copy-button.js';
8
8
  import { buttonVariants } from '../components/ui/button.js';
9
+ import { mergeRefs } from '../utils/merge-refs.js';
9
10
  export const Accordions = forwardRef(({ type = 'single', className, defaultValue, ...props }, ref) => {
10
- const [value, setValue] = useState(type === 'single' ? (defaultValue ?? '') : (defaultValue ?? []));
11
+ const rootRef = useRef(null);
12
+ const composedRef = mergeRefs(ref, rootRef);
13
+ const [value, setValue] = useState(() => type === 'single' ? (defaultValue ?? '') : (defaultValue ?? []));
11
14
  useEffect(() => {
12
15
  const id = window.location.hash.substring(1);
13
- if (id.length > 0)
14
- setValue((prev) => (typeof prev === 'string' ? id : [id, ...prev]));
16
+ const element = rootRef.current;
17
+ if (!element || id.length === 0)
18
+ return;
19
+ const selected = document.getElementById(id);
20
+ if (!selected || !element.contains(selected))
21
+ return;
22
+ const value = selected.getAttribute('data-accordion-value');
23
+ if (value)
24
+ setValue((prev) => (typeof prev === 'string' ? value : [value, ...prev]));
15
25
  }, []);
16
26
  return (
17
27
  // @ts-expect-error -- Multiple types
18
- _jsx(AccordionPrimitive.Root, { type: type, ref: ref, value: value, onValueChange: setValue, collapsible: type === 'single' ? true : undefined, className: cn('divide-y divide-fd-border overflow-hidden rounded-lg border bg-fd-card', className), ...props }));
28
+ _jsx(AccordionPrimitive.Root, { type: type, ref: composedRef, value: value, onValueChange: setValue, collapsible: type === 'single' ? true : undefined, className: cn('divide-y divide-fd-border overflow-hidden rounded-lg border bg-fd-card', className), ...props }));
19
29
  });
20
30
  Accordions.displayName = 'Accordions';
21
- export const Accordion = forwardRef(({ title, className, id, children, ...props }, ref) => {
22
- return (_jsxs(AccordionPrimitive.Item, { ref: ref,
23
- // Use `id` instead if presents
24
- value: id ?? title, className: cn('group/accordion relative scroll-m-20', className), ...props, children: [_jsxs(AccordionPrimitive.Header, { id: id, className: "not-prose flex flex-row items-center text-fd-card-foreground font-medium has-focus-visible:bg-fd-accent", children: [_jsxs(AccordionPrimitive.Trigger, { className: "flex flex-1 items-center gap-2 px-4 py-2.5 text-start focus-visible:outline-none", children: [_jsx(ChevronRight, { className: "-ms-1 size-4 shrink-0 text-fd-muted-foreground transition-transform duration-200 group-data-[state=open]/accordion:rotate-90" }), title] }), id ? _jsx(CopyButton, { id: id }) : null] }), _jsx(AccordionPrimitive.Content, { className: "overflow-hidden data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down", children: _jsx("div", { className: "px-4 py-2 prose-no-margin", children: children }) })] }));
31
+ export const Accordion = forwardRef(({ title, className, id, value = String(title), children, ...props }, ref) => {
32
+ return (_jsxs(AccordionPrimitive.Item, { ref: ref, value: value, className: cn('scroll-m-24', className), ...props, children: [_jsxs(AccordionPrimitive.Header, { id: id, "data-accordion-value": value, className: "not-prose flex flex-row items-center text-fd-card-foreground font-medium has-focus-visible:bg-fd-accent", children: [_jsxs(AccordionPrimitive.Trigger, { className: "group flex flex-1 items-center gap-2 px-3 py-2.5 text-start focus-visible:outline-none", children: [_jsx(ChevronRight, { className: "size-4 shrink-0 text-fd-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-90" }), title] }), id ? _jsx(CopyButton, { id: id }) : null] }), _jsx(AccordionPrimitive.Content, { className: "overflow-hidden data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down", children: _jsx("div", { className: "px-4 pb-2 text-[15px] prose-no-margin", children: children }) })] }));
25
33
  });
26
34
  function CopyButton({ id }) {
27
35
  const [checked, onClick] = useCopyButton(() => {
28
36
  const url = new URL(window.location.href);
29
37
  url.hash = id;
30
- void navigator.clipboard.writeText(url.toString());
38
+ return navigator.clipboard.writeText(url.toString());
31
39
  });
32
40
  return (_jsx("button", { type: "button", "aria-label": "Copy Link", className: cn(buttonVariants({
33
41
  color: 'ghost',
@@ -1,5 +1,6 @@
1
1
  import { type HTMLAttributes } from 'react';
2
- export declare function Banner({ id, variant, changeLayout, height, ...props }: HTMLAttributes<HTMLDivElement> & {
2
+ type BannerVariant = 'rainbow' | 'normal';
3
+ export declare function Banner({ id, variant, changeLayout, height, rainbowColors, ...props }: HTMLAttributes<HTMLDivElement> & {
3
4
  /**
4
5
  * @defaultValue 3rem
5
6
  */
@@ -7,7 +8,11 @@ export declare function Banner({ id, variant, changeLayout, height, ...props }:
7
8
  /**
8
9
  * @defaultValue 'normal'
9
10
  */
10
- variant?: 'rainbow' | 'normal';
11
+ variant?: BannerVariant;
12
+ /**
13
+ * For rainbow variant only, customise the colors
14
+ */
15
+ rainbowColors?: string[];
11
16
  /**
12
17
  * Change Fumadocs layout styles
13
18
  *
@@ -15,4 +20,5 @@ export declare function Banner({ id, variant, changeLayout, height, ...props }:
15
20
  */
16
21
  changeLayout?: boolean;
17
22
  }): import("react/jsx-runtime").JSX.Element | null;
23
+ export {};
18
24
  //# sourceMappingURL=banner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/components/banner.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAKjE,wBAAgB,MAAM,CAAC,EACrB,EAAE,EACF,OAAkB,EAClB,YAAmB,EACnB,MAAe,EACf,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAE/B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,kDAkEA"}
1
+ {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/components/banner.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAKjE,KAAK,aAAa,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1C,wBAAgB,MAAM,CAAC,EACrB,EAAE,EACF,OAAkB,EAClB,YAAmB,EACnB,MAAe,EACf,aAKC,EACD,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,kDAuEA"}
@@ -1,10 +1,15 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from 'react';
4
- import { X } from 'lucide-react';
4
+ import { X } from '../icons.js';
5
5
  import { cn } from '../utils/cn.js';
6
6
  import { buttonVariants } from '../components/ui/button.js';
7
- export function Banner({ id, variant = 'normal', changeLayout = true, height = '3rem', ...props }) {
7
+ export function Banner({ id, variant = 'normal', changeLayout = true, height = '3rem', rainbowColors = [
8
+ 'rgba(0,149,255,0.56)',
9
+ 'rgba(231,77,255,0.77)',
10
+ 'rgba(255,0,0,0.73)',
11
+ 'rgba(131,255,166,0.66)',
12
+ ], ...props }) {
8
13
  const [open, setOpen] = useState(true);
9
14
  const globalKey = id ? `nd-banner-${id}` : null;
10
15
  useEffect(() => {
@@ -13,47 +18,37 @@ export function Banner({ id, variant = 'normal', changeLayout = true, height = '
13
18
  }, [globalKey]);
14
19
  if (!open)
15
20
  return null;
16
- return (_jsxs("div", { id: id, ...props, className: cn('sticky top-0 z-40 flex flex-row items-center justify-center bg-fd-secondary px-4 text-center text-sm font-medium', variant === 'rainbow' && 'bg-fd-background', !open && 'hidden', props.className), style: {
21
+ return (_jsxs("div", { id: id, ...props, className: cn('sticky top-0 z-40 flex flex-row items-center justify-center px-4 text-center text-sm font-medium', variant === 'normal' && 'bg-fd-secondary', variant === 'rainbow' && 'bg-fd-background', !open && 'hidden', props.className), style: {
17
22
  height,
18
23
  }, children: [changeLayout && open ? (_jsx("style", { children: globalKey
19
24
  ? `:root:not(.${globalKey}) { --fd-banner-height: ${height}; }`
20
25
  : `:root { --fd-banner-height: ${height}; }` })) : null, globalKey ? (_jsx("style", { children: `.${globalKey} #${id} { display: none; }` })) : null, globalKey ? (_jsx("script", { dangerouslySetInnerHTML: {
21
26
  __html: `if (localStorage.getItem('${globalKey}') === 'true') document.documentElement.classList.add('${globalKey}');`,
22
- } })) : null, variant === 'rainbow' ? rainbowLayer : null, props.children, id ? (_jsx("button", { type: "button", "aria-label": "Close Banner", onClick: () => {
27
+ } })) : null, variant === 'rainbow'
28
+ ? flow({
29
+ colors: rainbowColors,
30
+ })
31
+ : null, props.children, id ? (_jsx("button", { type: "button", "aria-label": "Close Banner", onClick: () => {
23
32
  setOpen(false);
24
33
  if (globalKey)
25
34
  localStorage.setItem(globalKey, 'true');
26
35
  }, className: cn(buttonVariants({
27
36
  color: 'ghost',
28
- className: 'absolute end-2 top-1/2 -translate-y-1/2 text-fd-muted-foreground',
29
- size: 'icon',
37
+ className: 'absolute end-2 top-1/2 -translate-y-1/2 text-fd-muted-foreground/50',
38
+ size: 'icon-sm',
30
39
  })), children: _jsx(X, {}) })) : null] }));
31
40
  }
32
41
  const maskImage = 'linear-gradient(to bottom,white,transparent), radial-gradient(circle at top center, white, transparent)';
33
- const rainbowLayer = (_jsxs(_Fragment, { children: [_jsx("div", { className: "absolute inset-0 z-[-1]", style: {
34
- maskImage,
35
- maskComposite: 'intersect',
36
- animation: 'fd-moving-banner 16s linear infinite',
37
- '--start': 'rgba(0,87,255,0.5)',
38
- '--mid': 'rgba(255,0,166,0.77)',
39
- '--end': 'rgba(255,77,0,0.4)',
40
- '--via': 'rgba(164,255,68,0.4)',
41
- animationDirection: 'reverse',
42
- backgroundImage: 'repeating-linear-gradient(60deg, var(--end), var(--start) 2%, var(--start) 5%, transparent 8%, transparent 14%, var(--via) 18%, var(--via) 22%, var(--mid) 28%, var(--mid) 30%, var(--via) 34%, var(--via) 36%, transparent, var(--end) calc(50% - 12px))',
43
- backgroundSize: '200% 100%',
44
- mixBlendMode: 'difference',
45
- } }), _jsx("div", { className: "absolute inset-0 z-[-1]", style: {
46
- maskImage,
47
- maskComposite: 'intersect',
48
- animation: 'fd-moving-banner 20s linear infinite',
49
- '--start': 'rgba(255,120,120,0.5)',
50
- '--mid': 'rgba(36,188,255,0.4)',
51
- '--end': 'rgba(64,0,255,0.51)',
52
- '--via': 'rgba(255,89,0,0.56)',
53
- backgroundImage: 'repeating-linear-gradient(45deg, var(--end), var(--start) 4%, var(--start) 8%, transparent 9%, transparent 14%, var(--mid) 16%, var(--mid) 20%, transparent, var(--via) 36%, var(--via) 40%, transparent 42%, var(--end) 46%, var(--end) calc(50% - 16.8px))',
54
- backgroundSize: '200% 100%',
55
- mixBlendMode: 'color-dodge',
56
- } }), _jsx("style", { children: `@keyframes fd-moving-banner {
42
+ function flow({ colors }) {
43
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "absolute inset-0 z-[-1]", style: {
44
+ maskImage,
45
+ maskComposite: 'intersect',
46
+ animation: 'fd-moving-banner 20s linear infinite',
47
+ backgroundImage: `repeating-linear-gradient(70deg, ${[...colors, colors[0]].map((color, i) => `${color} ${(i * 50) / colors.length}%`).join(', ')})`,
48
+ backgroundSize: '200% 100%',
49
+ filter: 'saturate(2)',
50
+ } }), _jsx("style", { children: `@keyframes fd-moving-banner {
57
51
  from { background-position: 0% 0; }
58
52
  to { background-position: 100% 0; }
59
53
  }` })] }));
54
+ }
@@ -1,10 +1,10 @@
1
1
  import { type HTMLAttributes, type ReactNode } from 'react';
2
- export declare const Callout: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "icon" | "type" | "title"> & {
2
+ export declare const Callout: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "title" | "type" | "icon"> & {
3
3
  title?: ReactNode;
4
4
  /**
5
5
  * @defaultValue info
6
6
  */
7
- type?: "info" | "warn" | "error";
7
+ type?: "info" | "warn" | "error" | "success" | "warning";
8
8
  /**
9
9
  * Force an icon
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"callout.d.ts","sourceRoot":"","sources":["../../src/components/callout.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAiCxE,eAAO,MAAM,OAAO;YAzBV,SAAS;IACjB;;OAEG;WACI,MAAM,GAAG,MAAM,GAAG,OAAO;IAEhC;;OAEG;WACI,SAAS;kDA8CjB,CAAC"}
1
+ {"version":3,"file":"callout.d.ts","sourceRoot":"","sources":["../../src/components/callout.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAqBxE,eAAO,MAAM,OAAO;YAdV,SAAS;IACjB;;OAEG;WACI,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS;IAExD;;OAEG;WACI,SAAS;kDA0CjB,CAAC"}
@@ -1,25 +1,22 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AlertTriangle, CircleX, Info } from 'lucide-react';
2
+ import { CircleCheck, CircleX, Info, TriangleAlert } from '../icons.js';
3
3
  import { forwardRef } from 'react';
4
4
  import { cn } from '../utils/cn.js';
5
- import { cva } from 'class-variance-authority';
6
- const calloutVariants = cva('my-6 flex flex-row gap-2 rounded-lg border border-s-2 bg-fd-card p-3 text-sm text-fd-card-foreground shadow-md', {
7
- variants: {
8
- type: {
9
- info: 'border-s-blue-500/50',
10
- warn: 'border-s-orange-500/50',
11
- error: 'border-s-red-500/50',
12
- },
13
- },
14
- });
5
+ const iconClass = 'size-5 -me-0.5 fill-(--callout-color) text-fd-card';
15
6
  export const Callout = forwardRef(({ className, children, title, type = 'info', icon, ...props }, ref) => {
16
- return (_jsxs("div", { ref: ref, className: cn(calloutVariants({
17
- type: type,
18
- }), className), ...props, children: [icon ??
7
+ if (type === 'warn')
8
+ type = 'warning';
9
+ if (type === 'tip')
10
+ type = 'info';
11
+ return (_jsxs("div", { ref: ref, className: cn('flex gap-2 my-4 rounded-xl border bg-fd-card p-3 ps-1 text-sm text-fd-card-foreground shadow-md', className), ...props, style: {
12
+ '--callout-color': `var(--color-fd-${type}, var(--color-fd-muted))`,
13
+ ...props.style,
14
+ }, children: [_jsx("div", { role: "none", className: "w-0.5 bg-(--callout-color)/50 rounded-sm" }), icon ??
19
15
  {
20
- info: _jsx(Info, { className: "size-5 fill-blue-500 text-fd-card" }),
21
- warn: (_jsx(AlertTriangle, { className: "size-5 fill-orange-500 text-fd-card" })),
22
- error: _jsx(CircleX, { className: "size-5 fill-red-500 text-fd-card" }),
23
- }[type], _jsxs("div", { className: "min-w-0 flex-1", children: [title ? _jsx("p", { className: "not-prose mb-2 font-medium", children: title }) : null, _jsx("div", { className: "text-fd-muted-foreground prose-no-margin", children: children })] })] }));
16
+ info: _jsx(Info, { className: iconClass }),
17
+ warning: _jsx(TriangleAlert, { className: iconClass }),
18
+ error: _jsx(CircleX, { className: iconClass }),
19
+ success: _jsx(CircleCheck, { className: iconClass }),
20
+ }[type], _jsxs("div", { className: "flex flex-col gap-2 min-w-0 flex-1", children: [title && _jsx("p", { className: "font-medium !my-0", children: title }), _jsx("div", { className: "text-fd-muted-foreground prose-no-margin empty:hidden", children: children })] })] }));
24
21
  });
25
22
  Callout.displayName = 'Callout';
@@ -1 +1 @@
1
- {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/components/card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,wBAAgB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,2CAS1D;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IACnE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CA6BrE"}
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/components/card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,wBAAgB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,2CAS1D;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IACnE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CA2BrE"}
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Link from 'fumadocs-core/link';
3
3
  import { cn } from '../utils/cn.js';
4
4
  export function Cards(props) {
5
- return (_jsx("div", { ...props, className: cn('grid grid-cols-2 gap-4 @container', props.className), children: props.children }));
5
+ return (_jsx("div", { ...props, className: cn('grid grid-cols-2 gap-3 @container', props.className), children: props.children }));
6
6
  }
7
7
  export function Card({ icon, title, description, ...props }) {
8
8
  const E = props.href ? Link : 'div';
9
- return (_jsxs(E, { ...props, "data-card": true, className: cn('block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full', props.href && 'hover:bg-fd-accent/80', props.className), children: [icon ? (_jsx("div", { className: "not-prose mb-2 w-fit rounded-md border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon })) : null, _jsx("h3", { className: "not-prose mb-1 text-sm font-medium", children: title }), description ? (_jsx("p", { className: "!my-0 text-sm text-fd-muted-foreground", children: description })) : null, props.children ? (_jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin", children: props.children })) : null] }));
9
+ return (_jsxs(E, { ...props, "data-card": true, className: cn('block rounded-xl border bg-fd-card p-4 text-fd-card-foreground transition-colors @max-lg:col-span-full', props.href && 'hover:bg-fd-accent/80', props.className), children: [icon ? (_jsx("div", { className: "not-prose mb-2 w-fit shadow-md rounded-lg border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon })) : null, _jsx("h3", { className: "not-prose mb-1 text-sm font-medium", children: title }), description ? (_jsx("p", { className: "!my-0 text-sm text-fd-muted-foreground", children: description })) : null, _jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin empty:hidden", children: props.children })] }));
10
10
  }
@@ -1,6 +1,6 @@
1
- import { type HTMLAttributes, type ReactNode } from 'react';
2
- import type { ScrollAreaViewportProps } from '@radix-ui/react-scroll-area';
3
- export type CodeBlockProps = HTMLAttributes<HTMLElement> & {
1
+ import { type ComponentProps, type HTMLAttributes, type ReactNode } from 'react';
2
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '../components/tabs.unstyled.js';
3
+ export interface CodeBlockProps extends ComponentProps<'figure'> {
4
4
  /**
5
5
  * Icon of code block
6
6
  *
@@ -19,28 +19,24 @@ export type CodeBlockProps = HTMLAttributes<HTMLElement> & {
19
19
  * @defaultValue false
20
20
  */
21
21
  keepBackground?: boolean;
22
- viewportProps?: ScrollAreaViewportProps;
23
- };
24
- export declare const Pre: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLPreElement> & import("react").RefAttributes<HTMLPreElement>>;
25
- export declare const CodeBlock: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
22
+ viewportProps?: HTMLAttributes<HTMLElement>;
26
23
  /**
27
- * Icon of code block
28
- *
29
- * When passed as a string, it assumes the value is the HTML of icon
30
- */
31
- icon?: ReactNode;
32
- /**
33
- * Allow to copy code with copy button
34
- *
35
- * @defaultValue true
24
+ * show line numbers
36
25
  */
37
- allowCopy?: boolean;
26
+ 'data-line-numbers'?: boolean;
38
27
  /**
39
- * Keep original background color generated by Shiki or Rehype Code
40
- *
41
- * @defaultValue false
28
+ * @defaultValue 1
42
29
  */
43
- keepBackground?: boolean;
44
- viewportProps?: ScrollAreaViewportProps;
45
- } & import("react").RefAttributes<HTMLElement>>;
30
+ 'data-line-numbers-start'?: number;
31
+ Actions?: (props: {
32
+ className?: string;
33
+ children?: ReactNode;
34
+ }) => ReactNode;
35
+ }
36
+ export declare function Pre(props: ComponentProps<'pre'>): import("react/jsx-runtime").JSX.Element;
37
+ export declare function CodeBlock({ ref, title, allowCopy, keepBackground, icon, viewportProps, children, Actions, ...props }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
38
+ export declare function CodeBlockTabs({ ref, ...props }: ComponentProps<typeof Tabs>): import("react/jsx-runtime").JSX.Element;
39
+ export declare function CodeBlockTabsList(props: ComponentProps<typeof TabsList>): import("react/jsx-runtime").JSX.Element;
40
+ export declare function CodeBlockTabsTrigger({ children, ...props }: ComponentProps<typeof TabsTrigger>): import("react/jsx-runtime").JSX.Element;
41
+ export declare function CodeBlockTab(props: ComponentProps<typeof TabsContent>): import("react/jsx-runtime").JSX.Element;
46
42
  //# sourceMappingURL=codeblock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codeblock.d.ts","sourceRoot":"","sources":["../../src/components/codeblock.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IACzD;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,GAAG,2HAYf,CAAC;AAIF,eAAO,MAAM,SAAS;IAxCpB;;;;OAIG;WACI,SAAS;IAEhB;;;;OAIG;gBACS,OAAO;IAEnB;;;;OAIG;qBACc,OAAO;oBAER,uBAAuB;+CAkGxC,CAAC"}
1
+ {"version":3,"file":"codeblock.d.ts","sourceRoot":"","sources":["../../src/components/codeblock.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAIf,OAAO,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAGpC,MAAM,WAAW,cAAe,SAAQ,cAAc,CAAC,QAAQ,CAAC;IAC9D;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,aAAa,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IAE5C;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,KAAK,SAAS,CAAC;CAC9E;AAOD,wBAAgB,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,2CAS/C;AAED,wBAAgB,SAAS,CAAC,EACxB,GAAG,EACH,KAAK,EACL,SAAgB,EAChB,cAAsB,EACtB,IAAI,EACJ,aAAkB,EAClB,QAAQ,EACR,OAEC,EACD,GAAG,KAAK,EACT,EAAE,cAAc,2CAkEhB;AA0CD,wBAAgB,aAAa,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,2CA2B3E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,QAAQ,CAAC,2CAYvE;AAED,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,WAAW,CAAC,2CAapC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,WAAW,CAAC,2CAErE"}
@@ -1,37 +1,68 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Check, Copy } from 'lucide-react';
4
- import { forwardRef, useCallback, useRef, } from 'react';
3
+ import { Check, Clipboard } from '../icons.js';
4
+ import { createContext, useContext, useMemo, useRef, } from 'react';
5
5
  import { cn } from '../utils/cn.js';
6
- import { ScrollArea, ScrollBar, ScrollViewport, } from '../components/ui/scroll-area.js';
7
6
  import { useCopyButton } from '../utils/use-copy-button.js';
8
7
  import { buttonVariants } from '../components/ui/button.js';
9
- export const Pre = forwardRef(({ className, ...props }, ref) => {
10
- return (_jsx("pre", { ref: ref, className: cn('p-4 focus-visible:outline-none', className), ...props, children: props.children }));
11
- });
12
- Pre.displayName = 'Pre';
13
- export const CodeBlock = forwardRef(({ title, allowCopy = true, keepBackground = false, icon, viewportProps, ...props }, ref) => {
8
+ import { Tabs, TabsContent, TabsList, TabsTrigger, } from '../components/tabs.unstyled.js';
9
+ import { mergeRefs } from '../utils/merge-refs.js';
10
+ const TabsContext = createContext(null);
11
+ export function Pre(props) {
12
+ return (_jsx("pre", { ...props, className: cn('min-w-full w-max *:flex *:flex-col', props.className), children: props.children }));
13
+ }
14
+ export function CodeBlock({ ref, title, allowCopy = true, keepBackground = false, icon, viewportProps = {}, children, Actions = (props) => (_jsx("div", { ...props, className: cn('empty:hidden', props.className) })), ...props }) {
15
+ const inTab = useContext(TabsContext) !== null;
14
16
  const areaRef = useRef(null);
15
- const onCopy = useCallback(() => {
16
- const pre = areaRef.current?.getElementsByTagName('pre').item(0);
17
+ return (_jsxs("figure", { ref: ref, dir: "ltr", ...props, className: cn(inTab
18
+ ? 'bg-fd-secondary -mx-px -mb-px last:rounded-b-xl'
19
+ : 'my-4 bg-fd-card rounded-xl', keepBackground && 'bg-(--shiki-light-bg) dark:bg-(--shiki-dark-bg)', 'shiki relative border shadow-sm outline-none not-prose overflow-hidden text-sm', props.className), children: [title ? (_jsxs("div", { className: "flex text-fd-muted-foreground items-center gap-2 h-9.5 border-b px-4", children: [typeof icon === 'string' ? (_jsx("div", { className: "[&_svg]:size-3.5", dangerouslySetInnerHTML: {
20
+ __html: icon,
21
+ } })) : (icon), _jsx("figcaption", { className: "flex-1 truncate", children: title }), Actions({
22
+ className: '-me-2',
23
+ children: allowCopy && _jsx(CopyButton, { containerRef: areaRef }),
24
+ })] })) : (Actions({
25
+ className: 'absolute top-2 right-2 z-2 backdrop-blur-lg rounded-lg text-fd-muted-foreground',
26
+ children: allowCopy && _jsx(CopyButton, { containerRef: areaRef }),
27
+ })), _jsx("div", { ref: areaRef, ...viewportProps, className: cn('text-[13px] py-3.5 overflow-auto max-h-[600px] fd-scroll-container', viewportProps.className), style: {
28
+ // space for toolbar
29
+ '--padding-right': !title ? 'calc(var(--spacing) * 8)' : undefined,
30
+ counterSet: props['data-line-numbers']
31
+ ? `line ${Number(props['data-line-numbers-start'] ?? 1) - 1}`
32
+ : undefined,
33
+ ...viewportProps.style,
34
+ }, children: children })] }));
35
+ }
36
+ function CopyButton({ className, containerRef, ...props }) {
37
+ const [checked, onClick] = useCopyButton(() => {
38
+ const pre = containerRef.current?.getElementsByTagName('pre').item(0);
17
39
  if (!pre)
18
40
  return;
19
41
  const clone = pre.cloneNode(true);
20
42
  clone.querySelectorAll('.nd-copy-ignore').forEach((node) => {
21
- node.remove();
43
+ node.replaceWith('\n');
22
44
  });
23
45
  void navigator.clipboard.writeText(clone.textContent ?? '');
24
- }, []);
25
- return (_jsxs("figure", { ref: ref, ...props, className: cn('not-prose group fd-codeblock relative my-6 overflow-hidden rounded-lg border bg-fd-secondary/50 text-sm', keepBackground && 'bg-(--shiki-light-bg) dark:bg-(--shiki-dark-bg)', props.className), children: [title ? (_jsxs("div", { className: "flex flex-row items-center gap-2 border-b bg-fd-muted px-4 py-1.5", children: [icon ? (_jsx("div", { className: "text-fd-muted-foreground [&_svg]:size-3.5", dangerouslySetInnerHTML: typeof icon === 'string'
26
- ? {
27
- __html: icon,
28
- }
29
- : undefined, children: typeof icon !== 'string' ? icon : null })) : null, _jsx("figcaption", { className: "flex-1 truncate text-fd-muted-foreground", children: title }), allowCopy ? (_jsx(CopyButton, { className: "-me-2", onCopy: onCopy })) : null] })) : (allowCopy && (_jsx(CopyButton, { className: "absolute right-2 top-2 z-[2] backdrop-blur-md", onCopy: onCopy }))), _jsxs(ScrollArea, { ref: areaRef, dir: "ltr", children: [_jsx(ScrollViewport, { ...viewportProps, className: cn('max-h-[600px]', viewportProps?.className), children: props.children }), _jsx(ScrollBar, { orientation: "horizontal" })] })] }));
30
- });
31
- CodeBlock.displayName = 'CodeBlock';
32
- function CopyButton({ className, onCopy, ...props }) {
33
- const [checked, onClick] = useCopyButton(onCopy);
34
- return (_jsxs("button", { type: "button", className: cn(buttonVariants({
35
- color: 'ghost',
36
- }), 'transition-opacity group-hover:opacity-100 [&_svg]:size-3.5', !checked && '[@media(hover:hover)]:opacity-0', className), "aria-label": checked ? 'Copied Text' : 'Copy Text', onClick: onClick, ...props, children: [_jsx(Check, { className: cn('transition-transform', !checked && 'scale-0') }), _jsx(Copy, { className: cn('absolute transition-transform', checked && 'scale-0') })] }));
46
+ });
47
+ return (_jsx("button", { type: "button", "data-checked": checked || undefined, className: cn(buttonVariants({
48
+ className: 'hover:text-fd-accent-foreground data-[checked]:text-fd-accent-foreground',
49
+ size: 'icon-xs',
50
+ }), className), "aria-label": checked ? 'Copied Text' : 'Copy Text', onClick: onClick, ...props, children: checked ? _jsx(Check, {}) : _jsx(Clipboard, {}) }));
51
+ }
52
+ export function CodeBlockTabs({ ref, ...props }) {
53
+ const containerRef = useRef(null);
54
+ const nested = useContext(TabsContext) !== null;
55
+ return (_jsx(Tabs, { ref: mergeRefs(containerRef, ref), ...props, className: cn('bg-fd-card rounded-xl border', !nested && 'my-4', props.className), children: _jsx(TabsContext.Provider, { value: useMemo(() => ({
56
+ containerRef,
57
+ nested,
58
+ }), [nested]), children: props.children }) }));
59
+ }
60
+ export function CodeBlockTabsList(props) {
61
+ return (_jsx(TabsList, { ...props, className: cn('flex flex-row px-2 overflow-x-auto text-fd-muted-foreground', props.className), children: props.children }));
62
+ }
63
+ export function CodeBlockTabsTrigger({ children, ...props }) {
64
+ return (_jsxs(TabsTrigger, { ...props, className: cn('relative group inline-flex text-sm font-medium text-nowrap items-center transition-colors gap-2 px-2 py-1.5 hover:text-fd-accent-foreground data-[state=active]:text-fd-primary [&_svg]:size-3.5', props.className), children: [_jsx("div", { className: "absolute inset-x-2 bottom-0 h-px group-data-[state=active]:bg-fd-primary" }), children] }));
65
+ }
66
+ export function CodeBlockTab(props) {
67
+ return _jsx(TabsContent, { ...props });
37
68
  }
@@ -1,9 +1,10 @@
1
1
  import { type AlgoliaOptions } from 'fumadocs-core/search/client';
2
2
  import { type ReactNode } from 'react';
3
- import { type SharedProps, type TagItem } from './search.js';
3
+ import { type SharedProps } from './search.js';
4
+ import type { SearchLink, TagItem } from '../../contexts/search.js';
4
5
  export interface AlgoliaSearchDialogProps extends SharedProps {
5
- index: AlgoliaOptions['index'];
6
- searchOptions?: Omit<AlgoliaOptions, 'index'>;
6
+ searchOptions: AlgoliaOptions;
7
+ links?: SearchLink[];
7
8
  footer?: ReactNode;
8
9
  defaultTag?: string;
9
10
  tags?: TagItem[];
@@ -20,5 +21,5 @@ export interface AlgoliaSearchDialogProps extends SharedProps {
20
21
  */
21
22
  allowClear?: boolean;
22
23
  }
23
- export default function AlgoliaSearchDialog({ index, searchOptions, tags, defaultTag, showAlgolia, allowClear, ...props }: AlgoliaSearchDialogProps): ReactNode;
24
+ export default function AlgoliaSearchDialog({ searchOptions, tags, defaultTag, showAlgolia, allowClear, links, footer, ...props }: AlgoliaSearchDialogProps): import("react/jsx-runtime").JSX.Element;
24
25
  //# sourceMappingURL=search-algolia.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-algolia.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-algolia.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAEjD,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,OAAO,EACb,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IAEjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,KAAK,EACL,aAAa,EACb,IAAI,EACJ,UAAU,EACV,WAAmB,EACnB,UAAkB,EAClB,GAAG,KAAK,EACT,EAAE,wBAAwB,GAAG,SAAS,CA0CtC"}
1
+ {"version":3,"file":"search-algolia.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/search-algolia.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAE1D,OAAO,EAUL,KAAK,WAAW,EAGjB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG7D,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,aAAa,EAAE,cAAc,CAAC;IAC9B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IAErB,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IAEjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,aAAa,EACb,IAAS,EACT,UAAU,EACV,WAAmB,EACnB,UAAkB,EAClB,KAAU,EACV,MAAM,EACN,GAAG,KAAK,EACT,EAAE,wBAAwB,2CA4D1B"}
@@ -1,20 +1,34 @@
1
1
  'use client';
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useDocsSearch, } from 'fumadocs-core/search/client';
4
- import { useState } from 'react';
4
+ import { useMemo, useState } from 'react';
5
5
  import { useOnChange } from 'fumadocs-core/utils/use-on-change';
6
- import { SearchDialog, TagsList, } from './search.js';
7
- export default function AlgoliaSearchDialog({ index, searchOptions, tags, defaultTag, showAlgolia = false, allowClear = false, ...props }) {
6
+ import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay, TagsList, TagsListItem, } from './search.js';
7
+ import { useI18n } from '../../contexts/i18n.js';
8
+ export default function AlgoliaSearchDialog({ searchOptions, tags = [], defaultTag, showAlgolia = false, allowClear = false, links = [], footer, ...props }) {
8
9
  const [tag, setTag] = useState(defaultTag);
10
+ const { locale } = useI18n();
9
11
  const { search, setSearch, query } = useDocsSearch({
10
12
  type: 'algolia',
11
- index,
13
+ tag,
14
+ locale,
12
15
  ...searchOptions,
13
- }, undefined, tag);
16
+ });
17
+ const defaultItems = useMemo(() => {
18
+ if (links.length === 0)
19
+ return null;
20
+ return links.map(([name, link]) => ({
21
+ type: 'page',
22
+ id: name,
23
+ content: name,
24
+ url: link,
25
+ }));
26
+ }, [links]);
14
27
  useOnChange(defaultTag, (v) => {
15
28
  setTag(v);
16
29
  });
17
- return (_jsx(SearchDialog, { search: search, onSearchChange: setSearch, results: query.data ?? [], isLoading: query.isLoading, ...props, footer: tags ? (_jsxs(_Fragment, { children: [_jsx(TagsList, { tag: tag, onTagChange: setTag, items: tags, allowClear: allowClear, children: showAlgolia ? _jsx(AlgoliaTitle, {}) : null }), props.footer] })) : (props.footer) }));
30
+ const label = showAlgolia && _jsx(AlgoliaTitle, {});
31
+ return (_jsxs(SearchDialog, { search: search, onSearchChange: setSearch, isLoading: query.isLoading, ...props, children: [_jsx(SearchDialogOverlay, {}), _jsxs(SearchDialogContent, { children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { items: query.data !== 'empty' ? query.data : defaultItems })] }), _jsxs(SearchDialogFooter, { children: [tags.length > 0 ? (_jsxs(TagsList, { tag: tag, onTagChange: setTag, allowClear: allowClear, children: [tags.map((tag) => (_jsx(TagsListItem, { value: tag.value, children: tag.name }, tag.value))), label] })) : (label), footer] })] }));
18
32
  }
19
33
  function AlgoliaTitle() {
20
34
  return (_jsx("a", { href: "https://algolia.com", rel: "noreferrer noopener", className: "ms-auto text-xs text-fd-muted-foreground", children: "Search powered by Algolia" }));
@@ -1,6 +1,8 @@
1
1
  import { type ReactNode } from 'react';
2
- import { type SharedProps, type TagItem } from './search.js';
2
+ import { type SharedProps } from './search.js';
3
+ import type { SearchLink, TagItem } from '../../contexts/search.js';
3
4
  export interface DefaultSearchDialogProps extends SharedProps {
5
+ links?: SearchLink[];
4
6
  /**
5
7
  * @defaultValue 'fetch'
6
8
  */
@@ -23,5 +25,5 @@ export interface DefaultSearchDialogProps extends SharedProps {
23
25
  */
24
26
  allowClear?: boolean;
25
27
  }
26
- export default function DefaultSearchDialog({ defaultTag, tags, api, delayMs, type, allowClear, ...props }: DefaultSearchDialogProps): ReactNode;
28
+ export default function DefaultSearchDialog({ defaultTag, tags, api, delayMs, type, allowClear, links, footer, ...props }: DefaultSearchDialogProps): import("react/jsx-runtime").JSX.Element;
27
29
  //# sourceMappingURL=search-default.d.ts.map