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
@@ -1,33 +1,29 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as Primitive from 'fumadocs-core/toc';
4
- import { useRef, } from 'react';
4
+ import { createContext, useContext, useRef } from 'react';
5
5
  import { cn } from '../../utils/cn.js';
6
6
  import { useI18n } from '../../contexts/i18n.js';
7
7
  import { TocThumb } from '../../components/layout/toc-thumb.js';
8
- import { ScrollArea, ScrollViewport } from '../ui/scroll-area.js';
9
- import { usePageStyles } from '../../contexts/layout.js';
10
- export function Toc(props) {
11
- const { toc } = usePageStyles();
12
- return (_jsx("div", { id: "nd-toc", ...props, className: cn('sticky top-[calc(var(--fd-banner-height)+var(--fd-nav-height))] h-(--fd-toc-height) pb-2 pt-12', toc, props.className), style: {
13
- ...props.style,
14
- '--fd-toc-height': 'calc(100dvh - var(--fd-banner-height) - var(--fd-nav-height))',
15
- }, children: _jsx("div", { className: "flex h-full w-(--fd-toc-width) max-w-full flex-col gap-3 pe-4", children: props.children }) }));
8
+ import { mergeRefs } from '../../utils/merge-refs.js';
9
+ const TOCContext = createContext([]);
10
+ export function useTOCItems() {
11
+ return useContext(TOCContext);
16
12
  }
17
- export function TocItemsEmpty() {
18
- const { text } = useI18n();
19
- return (_jsx("div", { className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground", children: text.tocNoHeadings }));
13
+ export function TOCProvider({ toc, children, ...props }) {
14
+ return (_jsx(TOCContext, { value: toc, children: _jsx(Primitive.AnchorProvider, { toc: toc, ...props, children: children }) }));
20
15
  }
21
- export function TOCScrollArea({ isMenu, ...props }) {
16
+ export function TOCScrollArea({ ref, className, ...props }) {
22
17
  const viewRef = useRef(null);
23
- return (_jsx(ScrollArea, { ...props, className: cn('flex flex-col ps-px', props.className), children: _jsx(ScrollViewport, { ref: viewRef, className: cn('relative min-h-0 text-sm', isMenu &&
24
- '[mask-image:linear-gradient(to_bottom,transparent,white_16px,white_calc(100%-16px),transparent)] px-4 md:px-6 py-2'), children: _jsx(Primitive.ScrollProvider, { containerRef: viewRef, children: props.children }) }) }));
18
+ return (_jsx("div", { ref: mergeRefs(viewRef, ref), className: cn('relative min-h-0 text-sm ms-px overflow-auto [scrollbar-width:none] [mask-image:linear-gradient(to_bottom,transparent,white_16px,white_calc(100%-16px),transparent)] py-3', className), ...props, children: _jsx(Primitive.ScrollProvider, { containerRef: viewRef, children: props.children }) }));
25
19
  }
26
- export function TOCItems({ items }) {
20
+ export function TOCItems({ ref, className, ...props }) {
27
21
  const containerRef = useRef(null);
22
+ const items = useTOCItems();
23
+ const { text } = useI18n();
28
24
  if (items.length === 0)
29
- return _jsx(TocItemsEmpty, {});
30
- return (_jsxs(_Fragment, { children: [_jsx(TocThumb, { containerRef: containerRef, className: "absolute top-(--fd-top) h-(--fd-height) w-px bg-fd-primary transition-all" }), _jsx("div", { ref: containerRef, className: "flex flex-col border-s border-fd-foreground/10", children: items.map((item) => (_jsx(TOCItem, { item: item }, item.url))) })] }));
25
+ return (_jsx("div", { className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground", children: text.tocNoHeadings }));
26
+ return (_jsxs(_Fragment, { children: [_jsx(TocThumb, { containerRef: containerRef, className: "absolute top-(--fd-top) h-(--fd-height) w-px bg-fd-primary transition-all" }), _jsx("div", { ref: mergeRefs(ref, containerRef), className: cn('flex flex-col border-s border-fd-foreground/10', className), ...props, children: items.map((item) => (_jsx(TOCItem, { item: item }, item.url))) })] }));
31
27
  }
32
28
  function TOCItem({ item }) {
33
29
  return (_jsx(Primitive.TOCItem, { href: item.url, className: cn('prose py-1.5 text-sm text-fd-muted-foreground transition-colors [overflow-wrap:anywhere] first:pt-0 last:pb-0 data-[active=true]:text-fd-primary', item.depth <= 2 && 'ps-3', item.depth === 3 && 'ps-6', item.depth >= 4 && 'ps-8'), children: item.title }));
@@ -1,31 +1,31 @@
1
- import type { TabsContentProps, TabsProps as BaseProps } from '@radix-ui/react-tabs';
2
- import * as Primitive from './ui/tabs.js';
3
- export { Primitive };
4
- export interface TabsProps extends BaseProps {
1
+ import * as React from 'react';
2
+ import { type ComponentProps, type ReactNode } from 'react';
3
+ import * as Unstyled from './tabs.unstyled.js';
4
+ export interface TabsProps extends Omit<ComponentProps<typeof Unstyled.Tabs>, 'value' | 'onValueChange'> {
5
5
  /**
6
- * Identifier for Sharing value of tabs
6
+ * Use simple mode instead of advanced usage as documented in https://radix-ui.com/primitives/docs/components/tabs.
7
7
  */
8
- groupId?: string;
9
- /**
10
- * Enable persistent
11
- */
12
- persist?: boolean;
8
+ items?: string[];
13
9
  /**
10
+ * Shortcut for `defaultValue` when `items` is provided.
11
+ *
14
12
  * @defaultValue 0
15
13
  */
16
14
  defaultIndex?: number;
17
- items?: string[];
18
15
  /**
19
- * If true, updates the URL hash based on the tab's id
16
+ * Additional label in tabs list when `items` is provided.
20
17
  */
21
- updateAnchor?: boolean;
18
+ label?: ReactNode;
22
19
  }
23
- export declare function Tabs({ groupId, items, persist, defaultIndex, updateAnchor, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
24
- export type TabProps = Omit<TabsContentProps, 'value'> & {
20
+ export declare const TabsList: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-tabs").TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
21
+ export declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-tabs").TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
22
+ export declare function Tabs({ ref, className, items, label, defaultIndex, defaultValue, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
23
+ export interface TabProps extends Omit<ComponentProps<typeof Unstyled.TabsContent>, 'value'> {
25
24
  /**
26
25
  * Value of tab, detect from index if unspecified.
27
26
  */
28
- value?: TabsContentProps['value'];
29
- };
30
- export declare function Tab({ value, className, ...props }: TabProps): import("react/jsx-runtime").JSX.Element;
27
+ value?: string;
28
+ }
29
+ export declare function Tab({ value, ...props }: TabProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function TabsContent({ value, className, ...props }: ComponentProps<typeof Unstyled.TabsContent>): import("react/jsx-runtime").JSX.Element;
31
31
  //# sourceMappingURL=tabs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,IAAI,SAAS,EACvB,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,CAAC;AAmBrB,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAQD,wBAAgB,IAAI,CAAC,EACnB,OAAO,EACP,KAAU,EACV,OAAe,EACf,YAAgB,EAChB,YAAoB,EACpB,GAAG,KAAK,EACT,EAAE,SAAS,2CAgFX;AAMD,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IACvD;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,QAAQ,2CA6B3D"}
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAI5C,MAAM,WAAW,SACf,SAAQ,IAAI,CACV,cAAc,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,EACpC,OAAO,GAAG,eAAe,CAC1B;IACD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAaD,eAAO,MAAM,QAAQ,wKAYnB,CAAC;AAGH,eAAO,MAAM,WAAW,iLAYtB,CAAC;AAGH,wBAAgB,IAAI,CAAC,EACnB,GAAG,EACH,SAAS,EACT,KAAK,EACL,KAAK,EACL,YAAgB,EAChB,YAAmE,EACnE,GAAG,KAAK,EACT,EAAE,SAAS,2CAqCX;AAED,MAAM,WAAW,QACf,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAClE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,QAAQ,2CAgBhD;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,QAAQ,CAAC,WAAW,CAAC,2CAc7C"}
@@ -1,94 +1,40 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useMemo, useState, createContext, useContext, useLayoutEffect, useId, useEffect, } from 'react';
3
+ import * as React from 'react';
4
+ import { createContext, useContext, useEffect, useId, useMemo, useState, } from 'react';
4
5
  import { cn } from '../utils/cn.js';
5
- import * as Primitive from './ui/tabs.js';
6
- import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
7
- export { Primitive };
8
- const listeners = new Map();
9
- function addChangeListener(id, listener) {
10
- const list = listeners.get(id) ?? [];
11
- list.push(listener);
12
- listeners.set(id, list);
13
- }
14
- function removeChangeListener(id, listener) {
15
- const list = listeners.get(id) ?? [];
16
- listeners.set(id, list.filter((item) => item !== listener));
17
- }
6
+ import * as Unstyled from './tabs.unstyled.js';
18
7
  const TabsContext = createContext(null);
19
- export function Tabs({ groupId, items = [], persist = false, defaultIndex = 0, updateAnchor = false, ...props }) {
20
- const values = useMemo(() => items.map((item) => toValue(item)), [items]);
21
- const [value, setValue] = useState(values[defaultIndex]);
22
- const valueToIdMap = useMemo(() => new Map(), []);
23
- // eslint-disable-next-line react-hooks/exhaustive-deps -- re-reconstruct the collection if items changed
24
- const collection = useMemo(() => createCollection(), [items]);
25
- const onUpdate = useEffectEvent((v) => {
26
- if (values.includes(v))
27
- setValue(v);
28
- });
29
- useLayoutEffect(() => {
30
- if (!groupId)
31
- return;
32
- const previous = persist
33
- ? localStorage.getItem(groupId)
34
- : sessionStorage.getItem(groupId);
35
- if (previous)
36
- onUpdate(previous);
37
- addChangeListener(groupId, onUpdate);
38
- return () => {
39
- removeChangeListener(groupId, onUpdate);
40
- };
41
- }, [groupId, onUpdate, persist]);
42
- useLayoutEffect(() => {
43
- const hash = window.location.hash.slice(1);
44
- if (!hash)
45
- return;
46
- for (const [value, id] of valueToIdMap.entries()) {
47
- if (id === hash) {
48
- setValue(value);
49
- break;
50
- }
51
- }
52
- }, [valueToIdMap]);
53
- return (_jsxs(Primitive.Tabs, { value: value, onValueChange: (v) => {
54
- if (updateAnchor) {
55
- const id = valueToIdMap.get(v);
56
- if (id) {
57
- window.history.replaceState(null, '', `#${id}`);
58
- }
59
- }
60
- if (groupId) {
61
- listeners.get(groupId)?.forEach((item) => {
62
- item(v);
63
- });
64
- if (persist)
65
- localStorage.setItem(groupId, v);
66
- else
67
- sessionStorage.setItem(groupId, v);
68
- }
69
- else {
70
- setValue(v);
71
- }
72
- }, ...props, className: cn('my-4', props.className), children: [_jsx(Primitive.TabsList, { children: values.map((v, i) => (_jsx(Primitive.TabsTrigger, { value: v, children: items[i] }, v))) }), _jsx(TabsContext.Provider, { value: useMemo(() => ({ items, valueToIdMap, collection }), [valueToIdMap, collection, items]), children: props.children })] }));
8
+ function useTabContext() {
9
+ const ctx = useContext(TabsContext);
10
+ if (!ctx)
11
+ throw new Error('You must wrap your component in <Tabs>');
12
+ return ctx;
73
13
  }
74
- function toValue(v) {
75
- return v.toLowerCase().replace(/\s/, '-');
14
+ export const TabsList = React.forwardRef((props, ref) => (_jsx(Unstyled.TabsList, { ref: ref, ...props, className: cn('flex gap-3.5 text-fd-secondary-foreground overflow-x-auto px-4 not-prose', props.className) })));
15
+ TabsList.displayName = 'TabsList';
16
+ export const TabsTrigger = React.forwardRef((props, ref) => (_jsx(Unstyled.TabsTrigger, { ref: ref, ...props, className: cn('inline-flex items-center gap-2 whitespace-nowrap text-fd-muted-foreground border-b border-transparent py-2 text-sm font-medium transition-colors [&_svg]:size-4 hover:text-fd-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-fd-primary data-[state=active]:text-fd-primary', props.className) })));
17
+ TabsTrigger.displayName = 'TabsTrigger';
18
+ export function Tabs({ ref, className, items, label, defaultIndex = 0, defaultValue = items ? escapeValue(items[defaultIndex]) : undefined, ...props }) {
19
+ const [value, setValue] = useState(defaultValue);
20
+ const collection = useMemo(() => [], []);
21
+ return (_jsxs(Unstyled.Tabs, { ref: ref, className: cn('flex flex-col overflow-hidden rounded-xl border bg-fd-secondary my-4', className), value: value, onValueChange: (v) => {
22
+ if (items && !items.some((item) => escapeValue(item) === v))
23
+ return;
24
+ setValue(v);
25
+ }, ...props, children: [items && (_jsxs(TabsList, { children: [label && (_jsx("span", { className: "text-sm font-medium my-auto me-auto", children: label })), items.map((item) => (_jsx(TabsTrigger, { value: escapeValue(item), children: item }, item)))] })), _jsx(TabsContext.Provider, { value: useMemo(() => ({ items, collection }), [collection, items]), children: props.children })] }));
76
26
  }
77
- export function Tab({ value, className, ...props }) {
78
- const ctx = useContext(TabsContext);
79
- const resolvedValue = value ??
27
+ export function Tab({ value, ...props }) {
28
+ const { items } = useTabContext();
29
+ const resolved = value ??
80
30
  // eslint-disable-next-line react-hooks/rules-of-hooks -- `value` is not supposed to change
81
- ctx?.items.at(useCollectionIndex());
82
- if (!resolvedValue)
31
+ items?.at(useCollectionIndex());
32
+ if (!resolved)
83
33
  throw new Error('Failed to resolve tab `value`, please pass a `value` prop to the Tab component.');
84
- const v = toValue(resolvedValue);
85
- if (props.id && ctx) {
86
- ctx.valueToIdMap.set(v, props.id);
87
- }
88
- return (_jsx(Primitive.TabsContent, { value: v, className: cn('prose-no-margin [&>figure:only-child]:-m-4 [&>figure:only-child]:rounded-none [&>figure:only-child]:border-none', className), ...props, children: props.children }));
34
+ return (_jsx(TabsContent, { value: escapeValue(resolved), ...props, children: props.children }));
89
35
  }
90
- function createCollection() {
91
- return [];
36
+ export function TabsContent({ value, className, ...props }) {
37
+ return (_jsx(Unstyled.TabsContent, { value: value, forceMount: true, className: cn('p-4 text-[15px] bg-fd-background rounded-xl outline-none prose-no-margin data-[state=inactive]:hidden [&>figure:only-child]:-m-4 [&>figure:only-child]:border-none', className), ...props, children: props.children }));
92
38
  }
93
39
  /**
94
40
  * Inspired by Headless UI.
@@ -98,28 +44,21 @@ function createCollection() {
98
44
  */
99
45
  function useCollectionIndex() {
100
46
  const key = useId();
101
- const ctx = useContext(TabsContext);
102
- if (!ctx)
103
- throw new Error('You must wrap your component in <Tabs>');
104
- const list = ctx.collection;
105
- function register() {
106
- if (!list.includes(key))
107
- list.push(key);
108
- }
109
- function unregister() {
110
- const idx = list.indexOf(key);
111
- if (idx !== -1)
112
- list.splice(idx, 1);
113
- }
114
- useMemo(() => {
115
- // re-order the item to the bottom if registered
116
- unregister();
117
- register();
118
- // eslint-disable-next-line -- register
119
- }, [list]);
47
+ const { collection } = useTabContext();
120
48
  useEffect(() => {
121
- return unregister;
122
- // eslint-disable-next-line -- clean up only
123
- }, []);
124
- return list.indexOf(key);
49
+ return () => {
50
+ const idx = collection.indexOf(key);
51
+ if (idx !== -1)
52
+ collection.splice(idx, 1);
53
+ };
54
+ }, [key, collection]);
55
+ if (!collection.includes(key))
56
+ collection.push(key);
57
+ return collection.indexOf(key);
58
+ }
59
+ /**
60
+ * only escape whitespaces in values in simple mode
61
+ */
62
+ function escapeValue(v) {
63
+ return v.toLowerCase().replace(/\s/, '-');
125
64
  }
@@ -0,0 +1,24 @@
1
+ import { type ComponentProps } from 'react';
2
+ import * as Primitive from '@radix-ui/react-tabs';
3
+ export interface TabsProps extends ComponentProps<typeof Primitive.Tabs> {
4
+ /**
5
+ * Identifier for Sharing value of tabs
6
+ */
7
+ groupId?: string;
8
+ /**
9
+ * Enable persistent
10
+ */
11
+ persist?: boolean;
12
+ /**
13
+ * If true, updates the URL hash based on the tab's id
14
+ */
15
+ updateAnchor?: boolean;
16
+ }
17
+ export declare const TabsList: import("react").ForwardRefExoticComponent<Primitive.TabsListProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ export declare const TabsTrigger: import("react").ForwardRefExoticComponent<Primitive.TabsTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
19
+ /**
20
+ * @internal You better not use it
21
+ */
22
+ export declare function Tabs({ ref, groupId, persist, updateAnchor, defaultValue, value: _value, onValueChange: _onValueChange, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function TabsContent({ value, ...props }: ComponentProps<typeof Primitive.TabsContent>): import("react/jsx-runtime").JSX.Element;
24
+ //# sourceMappingURL=tabs.unstyled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.unstyled.d.ts","sourceRoot":"","sources":["../../src/components/tabs.unstyled.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAOpB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAqBlD,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC;IACtE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAYD,eAAO,MAAM,QAAQ,oHAAqB,CAAC;AAE3C,eAAO,MAAM,WAAW,0HAAwB,CAAC;AAEjD;;GAEG;AACH,wBAAgB,IAAI,CAAC,EACnB,GAAG,EACH,OAAO,EACP,OAAe,EACf,YAAoB,EACpB,YAAY,EACZ,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,cAAc,EAC7B,GAAG,KAAK,EACT,EAAE,SAAS,2CAsEX;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,WAAW,CAAC,2CAY9C"}
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useLayoutEffect, useMemo, useRef, useState, } from 'react';
4
+ import * as Primitive from '@radix-ui/react-tabs';
5
+ import { mergeRefs } from '../utils/merge-refs.js';
6
+ import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
7
+ const listeners = new Map();
8
+ function addChangeListener(id, listener) {
9
+ const list = listeners.get(id) ?? [];
10
+ list.push(listener);
11
+ listeners.set(id, list);
12
+ }
13
+ function removeChangeListener(id, listener) {
14
+ const list = listeners.get(id) ?? [];
15
+ listeners.set(id, list.filter((item) => item !== listener));
16
+ }
17
+ const TabsContext = createContext(null);
18
+ function useTabContext() {
19
+ const ctx = useContext(TabsContext);
20
+ if (!ctx)
21
+ throw new Error('You must wrap your component in <Tabs>');
22
+ return ctx;
23
+ }
24
+ export const TabsList = Primitive.TabsList;
25
+ export const TabsTrigger = Primitive.TabsTrigger;
26
+ /**
27
+ * @internal You better not use it
28
+ */
29
+ export function Tabs({ ref, groupId, persist = false, updateAnchor = false, defaultValue, value: _value, onValueChange: _onValueChange, ...props }) {
30
+ const tabsRef = useRef(null);
31
+ const [value, setValue] = _value === undefined
32
+ ? // eslint-disable-next-line react-hooks/rules-of-hooks -- not supposed to change controlled/uncontrolled
33
+ useState(defaultValue)
34
+ : [_value, _onValueChange ?? (() => undefined)];
35
+ const onChange = useEffectEvent((v) => setValue(v));
36
+ const valueToIdMap = useMemo(() => new Map(), []);
37
+ useLayoutEffect(() => {
38
+ if (!groupId)
39
+ return;
40
+ const previous = persist
41
+ ? localStorage.getItem(groupId)
42
+ : sessionStorage.getItem(groupId);
43
+ if (previous)
44
+ onChange(previous);
45
+ addChangeListener(groupId, onChange);
46
+ return () => {
47
+ removeChangeListener(groupId, onChange);
48
+ };
49
+ }, [groupId, persist]);
50
+ useLayoutEffect(() => {
51
+ const hash = window.location.hash.slice(1);
52
+ if (!hash)
53
+ return;
54
+ for (const [value, id] of valueToIdMap.entries()) {
55
+ if (id === hash) {
56
+ onChange(value);
57
+ tabsRef.current?.scrollIntoView();
58
+ break;
59
+ }
60
+ }
61
+ }, [valueToIdMap]);
62
+ return (_jsx(Primitive.Tabs, { ref: mergeRefs(ref, tabsRef), value: value, onValueChange: (v) => {
63
+ if (updateAnchor) {
64
+ const id = valueToIdMap.get(v);
65
+ if (id) {
66
+ window.history.replaceState(null, '', `#${id}`);
67
+ }
68
+ }
69
+ if (groupId) {
70
+ listeners.get(groupId)?.forEach((item) => {
71
+ item(v);
72
+ });
73
+ if (persist)
74
+ localStorage.setItem(groupId, v);
75
+ else
76
+ sessionStorage.setItem(groupId, v);
77
+ }
78
+ else {
79
+ setValue(v);
80
+ }
81
+ }, ...props, children: _jsx(TabsContext.Provider, { value: useMemo(() => ({ valueToIdMap }), [valueToIdMap]), children: props.children }) }));
82
+ }
83
+ export function TabsContent({ value, ...props }) {
84
+ const { valueToIdMap } = useTabContext();
85
+ if (props.id) {
86
+ valueToIdMap.set(value, props.id);
87
+ }
88
+ return (_jsx(Primitive.TabsContent, { value: value, ...props, children: props.children }));
89
+ }
@@ -1,23 +1,32 @@
1
- import type { ReactNode } from 'react';
2
- export declare function Info({ children }: {
3
- children: ReactNode;
4
- }): ReactNode;
5
- interface ObjectType {
1
+ import { type ReactNode } from 'react';
2
+ export interface ParameterNode {
3
+ name: string;
4
+ description: ReactNode;
5
+ }
6
+ export interface TypeNode {
6
7
  /**
7
8
  * Additional description of the field
8
9
  */
9
10
  description?: ReactNode;
10
- type: string;
11
+ /**
12
+ * type signature (short)
13
+ */
14
+ type: ReactNode;
15
+ /**
16
+ * type signature (full)
17
+ */
11
18
  typeDescription?: ReactNode;
12
19
  /**
13
- * Optional link to the type
20
+ * Optional `href` for the type
14
21
  */
15
22
  typeDescriptionLink?: string;
16
- default?: string;
23
+ default?: ReactNode;
17
24
  required?: boolean;
25
+ deprecated?: boolean;
26
+ parameters?: ParameterNode[];
27
+ returns?: ReactNode;
18
28
  }
19
29
  export declare function TypeTable({ type }: {
20
- type: Record<string, ObjectType>;
30
+ type: Record<string, TypeNode>;
21
31
  }): import("react/jsx-runtime").JSX.Element;
22
- export {};
23
32
  //# sourceMappingURL=type-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-table.d.ts","sourceRoot":"","sources":["../../src/components/type-table.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAWrE;AAED,UAAU,UAAU;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAYD,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,2CAiDvE"}
1
+ {"version":3,"file":"type-table.d.ts","sourceRoot":"","sources":["../../src/components/type-table.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAOjD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,SAAS,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;IAE5B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAYD,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAAE,2CAYrE"}
@@ -1,19 +1,28 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { InfoIcon } from 'lucide-react';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { ChevronDown } from '../icons.js';
4
4
  import Link from 'fumadocs-core/link';
5
5
  import { cva } from 'class-variance-authority';
6
6
  import { cn } from '../utils/cn.js';
7
- import { Popover, PopoverContent, PopoverTrigger, } from '../components/ui/popover.js';
8
- export function Info({ children }) {
9
- return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { children: _jsx(InfoIcon, { className: "size-4" }) }), _jsx(PopoverContent, { className: "prose max-h-[400px] min-w-[220px] max-w-[400px] overflow-auto text-sm prose-no-margin", children: children })] }));
10
- }
11
- const field = cva('inline-flex flex-row items-center gap-1');
12
- const code = cva('rounded-md bg-fd-secondary p-1 text-fd-secondary-foreground', {
7
+ import { useState } from 'react';
8
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from '../components/ui/collapsible.js';
9
+ const keyVariants = cva('text-fd-primary', {
13
10
  variants: {
14
- color: { primary: 'bg-fd-primary/10 text-fd-primary' },
11
+ deprecated: {
12
+ true: 'line-through text-fd-primary/50',
13
+ },
15
14
  },
16
15
  });
16
+ const fieldVariants = cva('text-fd-muted-foreground not-prose pe-2');
17
17
  export function TypeTable({ type }) {
18
- return (_jsx("div", { className: "prose my-6 overflow-auto prose-no-margin", children: _jsxs("table", { className: "whitespace-nowrap text-sm text-fd-muted-foreground", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "w-[45%]", children: "Prop" }), _jsx("th", { className: "w-[30%]", children: "Type" }), _jsx("th", { className: "w-1/4", children: "Default" })] }) }), _jsx("tbody", { children: Object.entries(type).map(([key, value]) => (_jsxs("tr", { children: [_jsx("td", { children: _jsxs("div", { className: field(), children: [_jsxs("code", { className: cn(code({ color: 'primary' })), children: [key, !value.required && '?'] }), value.description ? _jsx(Info, { children: value.description }) : null] }) }), _jsx("td", { children: _jsxs("div", { className: field(), children: [_jsx("code", { className: code(), children: value.type }), value.typeDescription ? (_jsx(Info, { children: value.typeDescription })) : null, value.typeDescriptionLink ? (_jsx(Link, { href: value.typeDescriptionLink, children: _jsx(InfoIcon, { className: "size-4" }) })) : null] }) }), _jsx("td", { children: value.default ? (_jsx("code", { className: code(), children: value.default })) : (_jsx("span", { children: "-" })) })] }, key))) })] }) }));
18
+ return (_jsxs("div", { className: "@container flex flex-col p-1 bg-fd-card text-fd-card-foreground rounded-2xl border my-6 text-sm overflow-hidden", children: [_jsxs("div", { className: "flex font-medium items-center px-3 py-1 not-prose text-fd-muted-foreground", children: [_jsx("p", { className: "w-[25%]", children: "Prop" }), _jsx("p", { className: "@max-xl:hidden", children: "Type" })] }), Object.entries(type).map(([key, value]) => (_jsx(Item, { name: key, item: value }, key)))] }));
19
+ }
20
+ function Item({ name, item: { parameters = [], description, required = false, deprecated, typeDescription, default: defaultValue, type, typeDescriptionLink, returns, }, }) {
21
+ const [open, setOpen] = useState(false);
22
+ return (_jsxs(Collapsible, { open: open, onOpenChange: setOpen, className: cn('rounded-xl border overflow-hidden transition-all', open
23
+ ? 'shadow-sm bg-fd-background not-last:mb-2'
24
+ : 'border-transparent'), children: [_jsxs(CollapsibleTrigger, { className: "relative flex flex-row items-center w-full group text-start px-3 py-2 not-prose hover:bg-fd-accent", children: [_jsxs("code", { className: cn(keyVariants({
25
+ deprecated,
26
+ className: 'min-w-fit w-[25%] font-medium',
27
+ })), children: [name, !required && '?'] }), typeDescriptionLink ? (_jsx(Link, { href: typeDescriptionLink, className: "underline @max-xl:hidden", children: type })) : (_jsx("span", { className: "@max-xl:hidden", children: type })), _jsx(ChevronDown, { className: "absolute end-2 size-4 text-fd-muted-foreground transition-transform group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { children: _jsxs("div", { className: "grid grid-cols-[1fr_3fr] gap-y-4 text-sm p-3 overflow-auto fd-scroll-container border-t", children: [_jsx("div", { className: "text-sm prose col-span-full prose-no-margin empty:hidden", children: description }), typeDescription && (_jsxs(_Fragment, { children: [_jsx("p", { className: cn(fieldVariants()), children: "Type" }), _jsx("p", { className: "my-auto not-prose", children: typeDescription })] })), defaultValue && (_jsxs(_Fragment, { children: [_jsx("p", { className: cn(fieldVariants()), children: "Default" }), _jsx("p", { className: "my-auto not-prose", children: defaultValue })] })), parameters.length > 0 && (_jsxs(_Fragment, { children: [_jsx("p", { className: cn(fieldVariants()), children: "Parameters" }), _jsx("div", { className: "flex flex-col gap-2", children: parameters.map((param) => (_jsxs("div", { className: "inline-flex items-center flex-wrap gap-1", children: [_jsxs("p", { className: "font-medium not-prose text-nowrap", children: [param.name, " -"] }), _jsx("div", { className: "text-sm prose prose-no-margin", children: param.description })] }, param.name))) })] })), returns && (_jsxs(_Fragment, { children: [_jsx("p", { className: cn(fieldVariants()), children: "Returns" }), _jsx("div", { className: "my-auto text-sm prose prose-no-margin", children: returns })] }))] }) })] }));
19
28
  }
@@ -1,7 +1,8 @@
1
1
  import { type VariantProps } from 'class-variance-authority';
2
2
  export declare const buttonVariants: (props?: ({
3
+ variant?: "primary" | "outline" | "ghost" | "secondary" | null | undefined;
3
4
  color?: "primary" | "outline" | "ghost" | "secondary" | null | undefined;
4
- size?: "sm" | "icon" | "icon-sm" | null | undefined;
5
+ size?: "sm" | "icon" | "icon-sm" | "icon-xs" | null | undefined;
5
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
7
  export type ButtonProps = VariantProps<typeof buttonVariants>;
7
8
  //# sourceMappingURL=button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,cAAc;;;8EAmB1B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAUlE,eAAO,MAAM,cAAc;;;;8EAe1B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -1,16 +1,20 @@
1
1
  import { cva } from 'class-variance-authority';
2
- export 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', {
2
+ const variants = {
3
+ primary: 'bg-fd-primary text-fd-primary-foreground hover:bg-fd-primary/80',
4
+ outline: 'border hover:bg-fd-accent hover:text-fd-accent-foreground',
5
+ ghost: 'hover:bg-fd-accent hover:text-fd-accent-foreground',
6
+ secondary: 'border bg-fd-secondary text-fd-secondary-foreground hover:bg-fd-accent hover:text-fd-accent-foreground',
7
+ };
8
+ export 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:ring-2 focus-visible:ring-fd-ring', {
3
9
  variants: {
4
- color: {
5
- primary: 'bg-fd-primary text-fd-primary-foreground hover:bg-fd-primary/80',
6
- outline: 'border hover:bg-fd-accent hover:text-fd-accent-foreground',
7
- ghost: 'hover:bg-fd-accent hover:text-fd-accent-foreground',
8
- secondary: 'border bg-fd-secondary text-fd-secondary-foreground hover:bg-fd-accent hover:text-fd-accent-foreground',
9
- },
10
+ variant: variants,
11
+ // fumadocs use `color` instead of `variant`
12
+ color: variants,
10
13
  size: {
11
- sm: 'gap-1 p-1 text-xs',
14
+ sm: 'gap-1 px-2 py-1.5 text-xs',
12
15
  icon: 'p-1.5 [&_svg]:size-5',
13
16
  'icon-sm': 'p-1.5 [&_svg]:size-4.5',
17
+ 'icon-xs': 'p-1 [&_svg]:size-4',
14
18
  },
15
19
  },
16
20
  });
@@ -9,9 +9,9 @@ const NavigationMenuItem = React.forwardRef(({ className, children, ...props },
9
9
  NavigationMenuItem.displayName = Primitive.NavigationMenuItem.displayName;
10
10
  const NavigationMenuTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsx(Primitive.Trigger, { ref: ref, className: cn('data-[state=open]:bg-fd-accent/50', className), ...props, children: children })));
11
11
  NavigationMenuTrigger.displayName = Primitive.Trigger.displayName;
12
- const NavigationMenuContent = React.forwardRef(({ className, ...props }, ref) => (_jsx(Primitive.Content, { ref: ref, className: cn('absolute inset-x-0 top-0 data-[motion=from-end]:animate-fd-enterFromRight data-[motion=from-start]:animate-fd-enterFromLeft data-[motion=to-end]:animate-fd-exitToRight data-[motion=to-start]:animate-fd-exitToLeft', className), ...props })));
12
+ const NavigationMenuContent = React.forwardRef(({ className, ...props }, ref) => (_jsx(Primitive.Content, { ref: ref, className: cn('absolute inset-x-0 top-0 overflow-auto fd-scroll-container max-h-[80svh] data-[motion=from-end]:animate-fd-enterFromRight data-[motion=from-start]:animate-fd-enterFromLeft data-[motion=to-end]:animate-fd-exitToRight data-[motion=to-start]:animate-fd-exitToLeft', className), ...props })));
13
13
  NavigationMenuContent.displayName = Primitive.Content.displayName;
14
14
  const NavigationMenuLink = Primitive.Link;
15
- const NavigationMenuViewport = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: "flex w-full justify-center", children: _jsx(Primitive.Viewport, { ...props, className: cn('relative h-(--radix-navigation-menu-viewport-height) w-full origin-[top_center] overflow-hidden text-fd-popover-foreground transition-[width,height] duration-300 data-[state=closed]:animate-fd-nav-menu-out data-[state=open]:animate-fd-nav-menu-in', className) }) })));
15
+ const NavigationMenuViewport = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: "flex w-full justify-center", children: _jsx(Primitive.Viewport, { ...props, className: cn('relative h-(--radix-navigation-menu-viewport-height) w-full origin-[top_center] overflow-hidden transition-[width,height] duration-300 data-[state=closed]:animate-fd-nav-menu-out data-[state=open]:animate-fd-nav-menu-in', className) }) })));
16
16
  NavigationMenuViewport.displayName = Primitive.Viewport.displayName;
17
17
  export { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuContent, NavigationMenuTrigger, NavigationMenuLink, NavigationMenuViewport, };
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import { cn } from '../../utils/cn.js';
6
6
  const Popover = PopoverPrimitive.Root;
7
7
  const PopoverTrigger = PopoverPrimitive.Trigger;
8
- const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, side: "bottom", className: cn('z-50 min-w-[220px] max-w-[98vw] rounded-lg border bg-fd-popover p-2 text-sm text-fd-popover-foreground shadow-lg focus-visible:outline-none data-[state=closed]:animate-fd-popover-out data-[state=open]:animate-fd-popover-in', className), ...props }) })));
8
+ const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, side: "bottom", className: cn('z-50 origin-(--radix-popover-content-transform-origin) overflow-y-auto max-h-(--radix-popover-content-available-height) min-w-[240px] max-w-[98vw] rounded-xl border bg-fd-popover/60 backdrop-blur-lg p-2 text-sm text-fd-popover-foreground shadow-lg focus-visible:outline-none data-[state=closed]:animate-fd-popover-out data-[state=open]:animate-fd-popover-in', className), ...props }) })));
9
9
  PopoverContent.displayName = PopoverPrimitive.Content.displayName;
10
10
  const PopoverClose = PopoverPrimitive.PopoverClose;
11
11
  export { Popover, PopoverTrigger, PopoverContent, PopoverClose };
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../../src/components/ui/scroll-area.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,QAAA,MAAM,UAAU,+JAad,CAAC;AAIH,QAAA,MAAM,cAAc,uKAWlB,CAAC;AAIH,QAAA,MAAM,SAAS,wKAiBb,CAAC;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../../src/components/ui/scroll-area.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,QAAA,MAAM,UAAU,+JAcd,CAAC;AAIH,QAAA,MAAM,cAAc,uKAWlB,CAAC;AAIH,QAAA,MAAM,SAAS,wKAiBb,CAAC;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
3
3
  import * as React from 'react';
4
4
  import { cn } from '../../utils/cn.js';
5
- const ScrollArea = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(ScrollAreaPrimitive.Root, { ref: ref, className: cn('overflow-hidden', className), ...props, children: [children, _jsx(ScrollAreaPrimitive.Corner, {}), _jsx(ScrollBar, { orientation: "vertical" })] })));
5
+ const ScrollArea = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(ScrollAreaPrimitive.Root, { ref: ref, type: "scroll", className: cn('overflow-hidden', className), ...props, children: [children, _jsx(ScrollAreaPrimitive.Corner, {}), _jsx(ScrollBar, { orientation: "vertical" })] })));
6
6
  ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
7
7
  const ScrollViewport = React.forwardRef(({ className, children, ...props }, ref) => (_jsx(ScrollAreaPrimitive.Viewport, { ref: ref, className: cn('size-full rounded-[inherit]', className), ...props, children: children })));
8
8
  ScrollViewport.displayName = ScrollAreaPrimitive.Viewport.displayName;
@@ -1,5 +1,4 @@
1
1
  import { type ComponentType, type ReactNode } from 'react';
2
- import type { SearchLink, SharedProps } from '../components/dialog/search.js';
3
2
  interface HotKey {
4
3
  display: ReactNode;
5
4
  /**
@@ -7,6 +6,15 @@ interface HotKey {
7
6
  */
8
7
  key: string | ((e: KeyboardEvent) => boolean);
9
8
  }
9
+ export interface SharedProps {
10
+ open: boolean;
11
+ onOpenChange: (open: boolean) => void;
12
+ }
13
+ export type SearchLink = [name: string, href: string];
14
+ export interface TagItem {
15
+ name: string;
16
+ value: string;
17
+ }
10
18
  export interface SearchProviderProps {
11
19
  /**
12
20
  * Preload search dialog before opening it
@@ -33,7 +41,7 @@ export interface SearchProviderProps {
33
41
  /**
34
42
  * Additional props to the dialog
35
43
  */
36
- options?: Partial<SharedProps>;
44
+ options?: Partial<SharedProps & Record<string, unknown>>;
37
45
  children?: ReactNode;
38
46
  }
39
47
  interface SearchContextType {