@fumadocs/base-ui 16.9.3 → 16.10.0

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 (141) hide show
  1. package/css/generated/docs.css +1 -234
  2. package/css/generated/flux.css +1 -162
  3. package/css/generated/home.css +1 -65
  4. package/css/generated/notebook.css +1 -258
  5. package/css/generated/shared.css +1 -1189
  6. package/dist/.translations/index.d.ts +49 -0
  7. package/dist/.translations/keys.js +49 -0
  8. package/dist/components/accordion.d.ts +2 -3
  9. package/dist/components/accordion.js +3 -3
  10. package/dist/components/banner.d.ts +1 -2
  11. package/dist/components/banner.js +3 -3
  12. package/dist/components/callout.d.ts +4 -5
  13. package/dist/components/card.d.ts +2 -3
  14. package/dist/components/codeblock.d.ts +6 -7
  15. package/dist/components/codeblock.js +3 -3
  16. package/dist/components/codeblock.rsc.d.ts +1 -2
  17. package/dist/components/dialog/search-algolia.d.ts +1 -2
  18. package/dist/components/dialog/search-default.d.ts +1 -2
  19. package/dist/components/dialog/search-orama.d.ts +1 -2
  20. package/dist/components/dialog/search.d.ts +12 -13
  21. package/dist/components/dialog/search.js +13 -10
  22. package/dist/components/dynamic-codeblock.core.d.ts +1 -2
  23. package/dist/components/dynamic-codeblock.d.ts +1 -2
  24. package/dist/components/github-info.d.ts +1 -2
  25. package/dist/components/heading.d.ts +1 -2
  26. package/dist/components/heading.js +3 -3
  27. package/dist/components/image-zoom.d.ts +2 -3
  28. package/dist/components/image-zoom.js +1 -1
  29. package/dist/components/inline-toc.d.ts +1 -2
  30. package/dist/components/inline-toc.js +3 -3
  31. package/dist/components/sidebar/base.d.ts +13 -15
  32. package/dist/components/sidebar/base.js +3 -3
  33. package/dist/components/sidebar/link-item.d.ts +1 -2
  34. package/dist/components/sidebar/page-tree.d.ts +1 -2
  35. package/dist/components/sidebar/tabs/dropdown.d.ts +1 -2
  36. package/dist/components/steps.d.ts +2 -3
  37. package/dist/components/tabs.d.ts +5 -6
  38. package/dist/components/toc/clerk.d.ts +3 -4
  39. package/dist/components/toc/clerk.js +2 -2
  40. package/dist/components/toc/default.d.ts +3 -4
  41. package/dist/components/toc/default.js +2 -2
  42. package/dist/components/toc/index.d.ts +2 -3
  43. package/dist/components/type-table.d.ts +1 -2
  44. package/dist/components/type-table.js +9 -9
  45. package/dist/components/ui/accordion.d.ts +5 -6
  46. package/dist/components/ui/button.d.ts +1 -2
  47. package/dist/components/ui/collapsible.d.ts +3 -6
  48. package/dist/components/ui/navigation-menu.d.ts +6 -8
  49. package/dist/components/ui/popover.d.ts +2 -4
  50. package/dist/components/ui/scroll-area.d.ts +3 -4
  51. package/dist/components/ui/tabs.d.ts +4 -7
  52. package/dist/contexts/i18n.d.ts +5 -30
  53. package/dist/contexts/i18n.js +10 -22
  54. package/dist/contexts/search.d.ts +1 -2
  55. package/dist/contexts/tree.d.ts +1 -2
  56. package/dist/i18n.d.ts +9 -63
  57. package/dist/i18n.js +23 -70
  58. package/dist/layouts/docs/index.d.ts +1 -2
  59. package/dist/layouts/docs/page/index.d.ts +6 -7
  60. package/dist/layouts/docs/page/index.js +5 -4
  61. package/dist/layouts/docs/page/slots/breadcrumb.d.ts +1 -2
  62. package/dist/layouts/docs/page/slots/container.d.ts +1 -2
  63. package/dist/layouts/docs/page/slots/footer.d.ts +1 -2
  64. package/dist/layouts/docs/page/slots/footer.js +3 -3
  65. package/dist/layouts/docs/page/slots/toc.d.ts +3 -4
  66. package/dist/layouts/docs/page/slots/toc.js +5 -4
  67. package/dist/layouts/docs/slots/container.d.ts +1 -2
  68. package/dist/layouts/docs/slots/header.d.ts +1 -3
  69. package/dist/layouts/docs/slots/sidebar.d.ts +3 -4
  70. package/dist/layouts/flux/index.d.ts +3 -4
  71. package/dist/layouts/flux/page/index.d.ts +6 -7
  72. package/dist/layouts/flux/page/index.js +5 -4
  73. package/dist/layouts/flux/page/slots/breadcrumb.d.ts +1 -2
  74. package/dist/layouts/flux/page/slots/container.d.ts +1 -2
  75. package/dist/layouts/flux/page/slots/footer.d.ts +1 -2
  76. package/dist/layouts/flux/page/slots/footer.js +3 -3
  77. package/dist/layouts/flux/page/slots/toc.d.ts +1 -2
  78. package/dist/layouts/flux/page/slots/toc.js +3 -3
  79. package/dist/layouts/flux/slots/container.d.ts +1 -2
  80. package/dist/layouts/flux/slots/sidebar.d.ts +3 -4
  81. package/dist/layouts/flux/slots/tab-dropdown.d.ts +1 -2
  82. package/dist/layouts/home/index.d.ts +1 -2
  83. package/dist/layouts/home/navbar.d.ts +3 -4
  84. package/dist/layouts/home/not-found.d.ts +1 -3
  85. package/dist/layouts/home/not-found.js +6 -4
  86. package/dist/layouts/home/slots/container.d.ts +1 -2
  87. package/dist/layouts/home/slots/header.d.ts +2 -4
  88. package/dist/layouts/home/slots/header.js +3 -3
  89. package/dist/layouts/notebook/index.d.ts +1 -2
  90. package/dist/layouts/notebook/page/index.d.ts +6 -7
  91. package/dist/layouts/notebook/page/index.js +5 -4
  92. package/dist/layouts/notebook/page/slots/breadcrumb.d.ts +1 -2
  93. package/dist/layouts/notebook/page/slots/container.d.ts +1 -2
  94. package/dist/layouts/notebook/page/slots/footer.d.ts +1 -2
  95. package/dist/layouts/notebook/page/slots/footer.js +3 -3
  96. package/dist/layouts/notebook/page/slots/toc.d.ts +3 -4
  97. package/dist/layouts/notebook/page/slots/toc.js +5 -4
  98. package/dist/layouts/notebook/slots/container.d.ts +1 -2
  99. package/dist/layouts/notebook/slots/header.d.ts +1 -3
  100. package/dist/layouts/notebook/slots/sidebar.d.ts +5 -6
  101. package/dist/layouts/shared/client.d.ts +1 -2
  102. package/dist/layouts/shared/index.d.ts +1 -1
  103. package/dist/layouts/shared/page-actions.d.ts +2 -3
  104. package/dist/layouts/shared/page-actions.js +12 -13
  105. package/dist/layouts/shared/slots/language-select.d.ts +1 -2
  106. package/dist/layouts/shared/slots/language-select.js +5 -2
  107. package/dist/layouts/shared/slots/search-trigger.d.ts +2 -3
  108. package/dist/layouts/shared/slots/search-trigger.js +5 -5
  109. package/dist/layouts/shared/slots/theme-switch.d.ts +1 -2
  110. package/dist/layouts/shared/slots/theme-switch.js +43 -30
  111. package/dist/mdx.d.ts +9 -10
  112. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/controlled.d.ts +1 -1
  113. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/controlled.js +6 -2
  114. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/uncontrolled.d.ts +1 -1
  115. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/uncontrolled.js +1 -1
  116. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/adjust-svg-ids.js +1 -1
  117. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/compute-positioned-style.js +1 -1
  118. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/element-tests.js +1 -1
  119. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-div-img-style.js +1 -1
  120. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-img-alt.js +1 -1
  121. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-img-object-fit-style.js +1 -1
  122. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-img-regular-style.js +1 -1
  123. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-img-src.js +1 -1
  124. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-modal-img-transform.js +1 -1
  125. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-scale.js +1 -1
  126. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-style-ghost.js +1 -1
  127. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-style-modal-img.js +1 -1
  128. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/get-target-dimension.js +1 -1
  129. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/parse-position.js +1 -1
  130. package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/utils/test-has-scalable-src.js +1 -1
  131. package/dist/og/takumi.d.ts +1 -2
  132. package/dist/og.d.ts +1 -2
  133. package/dist/page.d.ts +2 -3
  134. package/dist/provider/base.d.ts +1 -2
  135. package/dist/provider/next.d.ts +1 -2
  136. package/dist/provider/react-router.d.ts +1 -2
  137. package/dist/provider/tanstack.d.ts +1 -2
  138. package/dist/provider/waku.d.ts +1 -2
  139. package/dist/style.css +3 -0
  140. package/package.json +10 -9
  141. /package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.5_react-dom@19.2.6_react@19.2.6__react@19.2.6 → react-medium-image-zoom@5.4.6_react-dom@19.2.7_react@19.2.7__react@19.2.7}/node_modules/react-medium-image-zoom/dist/index.d.ts +0 -0
@@ -1,8 +1,5 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as _$react from "react";
3
1
  import { ComponentProps } from "react";
4
2
  import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
5
- import * as _$_base_ui_react0 from "@base-ui/react";
6
3
 
7
4
  //#region src/components/ui/tabs.d.ts
8
5
  interface TabsProps extends ComponentProps<typeof Tabs$1.Root> {
@@ -20,8 +17,8 @@ interface TabsProps extends ComponentProps<typeof Tabs$1.Root> {
20
17
  updateAnchor?: boolean;
21
18
  onValueChange?: (value: string) => void;
22
19
  }
23
- declare const TabsList: _$react.ForwardRefExoticComponent<Omit<_$_base_ui_react0.TabsListProps, "ref"> & _$react.RefAttributes<HTMLDivElement>>;
24
- declare const TabsTrigger: _$react.ForwardRefExoticComponent<Omit<_$_base_ui_react0.TabsTabProps, "ref"> & _$react.RefAttributes<HTMLElement>>;
20
+ declare const TabsList: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").TabsListProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
21
+ declare const TabsTrigger: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").TabsTabProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
25
22
  declare function Tabs({
26
23
  ref,
27
24
  groupId,
@@ -31,10 +28,10 @@ declare function Tabs({
31
28
  value: _value,
32
29
  onValueChange: _onValueChange,
33
30
  ...props
34
- }: TabsProps): _$react_jsx_runtime0.JSX.Element;
31
+ }: TabsProps): import("react").JSX.Element;
35
32
  declare function TabsContent({
36
33
  value,
37
34
  ...props
38
- }: ComponentProps<typeof Tabs$1.Panel>): _$react_jsx_runtime0.JSX.Element;
35
+ }: ComponentProps<typeof Tabs$1.Panel>): import("react").JSX.Element;
39
36
  //#endregion
40
37
  export { Tabs, TabsContent, TabsList, TabsProps, TabsTrigger };
@@ -1,45 +1,20 @@
1
- import { Translations } from "../i18n.js";
2
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
1
  import { ReactNode } from "react";
4
- import { TranslationObject, TranslationValue } from "fumadocs-core/i18n";
5
2
 
6
3
  //#region src/contexts/i18n.d.ts
7
4
  interface LocaleItem {
8
5
  name: string;
9
6
  locale: string;
10
7
  }
11
- interface I18nContextType {
12
- text: Translations & Record<string, string | Record<string, string>>;
8
+ interface LocaleContextType {
13
9
  locale?: string;
14
10
  onChange?: (v: string) => void;
15
11
  locales?: LocaleItem[];
16
12
  }
17
- declare function I18nLabel<K extends keyof Translations = keyof Translations>({
18
- label,
19
- params
20
- }: {
21
- label: K;
22
- params?: Translations[K] extends TranslationValue<infer Params> ? Record<Params, string> : never;
23
- }): string;
24
- declare function useI18n(): I18nContextType;
25
- declare function useTranslations(): Translations;
26
- declare function useTranslations<Obj extends TranslationObject>(namespace: string): Obj | undefined;
13
+ declare function useI18n(): LocaleContextType;
27
14
  interface I18nProviderProps {
28
- /**
29
- * Current locale
30
- */
31
15
  locale?: string;
32
- /**
33
- * Handle changes to the locale, redirect user when not specified.
34
- */
35
16
  onLocaleChange?: (v: string) => void;
36
- /**
37
- * Translations of current locale
38
- */
39
- translations?: Partial<I18nContextType['text']>;
40
- /**
41
- * Available languages
42
- */
17
+ translations?: Partial<Record<string, string>>;
43
18
  locales?: LocaleItem[];
44
19
  children?: ReactNode;
45
20
  }
@@ -49,6 +24,6 @@ declare function I18nProvider({
49
24
  onLocaleChange,
50
25
  children,
51
26
  translations
52
- }: I18nProviderProps): _$react_jsx_runtime0.JSX.Element;
27
+ }: I18nProviderProps): import("react").JSX.Element;
53
28
  //#endregion
54
- export { I18nLabel, I18nProvider, I18nProviderProps, useI18n, useTranslations };
29
+ export { I18nProvider, I18nProviderProps, useI18n };
@@ -1,19 +1,12 @@
1
1
  "use client";
2
- import { defaultTranslations } from "../i18n.js";
3
2
  import { usePathname, useRouter } from "fumadocs-core/framework";
4
3
  import { jsx } from "react/jsx-runtime";
5
4
  import { createContext, use, useMemo, useRef } from "react";
6
- import { renderTranslation } from "fumadocs-core/i18n";
5
+ import { TranslationProvider } from "@fuma-translate/react";
7
6
  //#region src/contexts/i18n.tsx
8
- const I18nContext = createContext({ text: defaultTranslations });
9
- function I18nLabel({ label, params }) {
10
- return renderTranslation(useTranslations()[label], params);
11
- }
7
+ const LocaleContext = createContext({});
12
8
  function useI18n() {
13
- return use(I18nContext);
14
- }
15
- function useTranslations(namespace) {
16
- return namespace ? use(I18nContext).text[namespace] : use(I18nContext).text;
9
+ return use(LocaleContext);
17
10
  }
18
11
  function I18nProvider({ locales = [], locale, onLocaleChange, children, translations }) {
19
12
  const router = useRouter();
@@ -27,22 +20,17 @@ function I18nProvider({ locales = [], locale, onLocaleChange, children, translat
27
20
  };
28
21
  const onChangeRef = useRef(onChange);
29
22
  onChangeRef.current = onChange;
30
- return /* @__PURE__ */ jsx(I18nContext, {
23
+ return /* @__PURE__ */ jsx(LocaleContext, {
31
24
  value: useMemo(() => ({
32
25
  locale,
33
26
  locales,
34
- text: {
35
- ...defaultTranslations,
36
- ...translations
37
- },
38
27
  onChange: (v) => onChangeRef.current(v)
39
- }), [
40
- locale,
41
- locales,
42
- translations
43
- ]),
44
- children
28
+ }), [locale, locales]),
29
+ children: /* @__PURE__ */ jsx(TranslationProvider, {
30
+ translations: translations ?? {},
31
+ children
32
+ })
45
33
  });
46
34
  }
47
35
  //#endregion
48
- export { I18nLabel, I18nProvider, useI18n, useTranslations };
36
+ export { I18nProvider, useI18n };
@@ -1,4 +1,3 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
1
  import { ComponentType, ReactNode } from "react";
3
2
 
4
3
  //#region src/contexts/search.d.ts
@@ -61,7 +60,7 @@ declare function SearchProvider({
61
60
  options,
62
61
  hotKey,
63
62
  links
64
- }: SearchProviderProps): _$react_jsx_runtime0.JSX.Element;
63
+ }: SearchProviderProps): import("react").JSX.Element;
65
64
  /**
66
65
  * Show children only when search is enabled via React Context
67
66
  */
@@ -1,4 +1,3 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
1
  import { ReactNode } from "react";
3
2
  import * as PageTree from "fumadocs-core/page-tree";
4
3
 
@@ -14,7 +13,7 @@ declare function TreeContextProvider({
14
13
  }: {
15
14
  tree: PageTree.Root;
16
15
  children: ReactNode;
17
- }): _$react_jsx_runtime0.JSX.Element;
16
+ }): import("react").JSX.Element;
18
17
  declare function useTreePath(): PageTree.Node[];
19
18
  declare function useTreeContext(): TreeContextType;
20
19
  //#endregion
package/dist/i18n.d.ts CHANGED
@@ -1,70 +1,16 @@
1
1
  import { I18nProviderProps } from "./contexts/i18n.js";
2
- import { I18nConfig, TranslationValue, TranslationsAPI, TranslationsAPIExtension } from "fumadocs-core/i18n";
2
+ import { Translations } from "./.translations/index.js";
3
+ import { I18nConfig, SingularTranslationsAPI, TranslationExtension, TranslationsAPI } from "fumadocs-core/i18n";
3
4
 
4
5
  //#region src/i18n.d.ts
5
- type Translations = {
6
- displayName: string;
7
- search: string;
8
- searchNoResult: string;
9
- searchOpen: string;
10
- searchClose: string;
11
- toc: string;
12
- tocNoHeadings: string;
13
- tocInline: string;
14
- lastUpdate: string;
15
- chooseLanguage: string;
16
- nextPage: string;
17
- previousPage: string;
18
- chooseTheme: string;
19
- editOnGithub: string;
20
- themeToggle: string;
21
- themeLight: string;
22
- themeDark: string;
23
- themeSystem: string;
24
- codeBlockCopy: string;
25
- codeBlockCopied: string;
26
- accordionCopyAnchor: string;
27
- headingCopyAnchor: string;
28
- bannerClose: string;
29
- menuToggle: string;
30
- pageActionsCopyMarkdown: string;
31
- pageActionsOpen: string;
32
- pageActionsOpenGitHub: string;
33
- pageActionsViewMarkdown: string;
34
- pageActionsOpenScira: string;
35
- pageActionsOpenChatGPT: string;
36
- pageActionsOpenClaude: string;
37
- pageActionsOpenCursor: string;
38
- pageActionsOpenInLLMPrompt: TranslationValue<'url'>;
39
- sidebarOpen: string;
40
- sidebarCollapse: string;
41
- typeTableProp: string;
42
- typeTableType: string;
43
- typeTableDefault: string;
44
- typeTableParameters: string;
45
- typeTableReturns: string;
46
- notFoundTitle: string;
47
- notFoundDescription: string;
48
- notFoundLink: string;
49
- };
50
- declare const defaultTranslations: Translations;
51
- type TranslationsConfig<Languages extends string> = { [K in Languages]?: Partial<Translations> };
52
- declare function uiTranslations(): TranslationsAPIExtension<'ui', Translations>;
53
- declare function i18nProvider<Languages extends string, P extends {
54
- ui: Translations;
55
- }>(translations: TranslationsAPI<Languages, P>, lang?: NoInfer<Languages> | (string & {})): I18nProviderProps;
6
+ declare function uiTranslations(): TranslationExtension<keyof Translations>;
7
+ declare function i18nProvider(translations: SingularTranslationsAPI): I18nProviderProps;
8
+ declare function i18nProvider<Languages extends string>(translations: TranslationsAPI<Languages>, lang?: NoInfer<Languages> | (string & {})): I18nProviderProps;
56
9
  interface I18nUIConfig<Languages extends string> extends I18nConfig<Languages> {
57
- /**
58
- * get i18n config for Fumadocs UI `<RootProvider i18n={config} />`.
59
- */
60
10
  provider: (locale?: Languages | (string & {})) => I18nProviderProps;
61
11
  }
62
- /** @deprecated use the `i18n.translations()` & `uiTranslations()` APIs instead */
63
- declare function defineI18nUI<Languages extends string>(config: I18nConfig<Languages>, options?: {
64
- /**
65
- * @deprecated you can directly define the translations in outer scope (the parent object of `translations`)
66
- */
67
- translations: TranslationsConfig<Languages>;
68
- } | TranslationsConfig<Languages>): I18nUIConfig<Languages>;
12
+ declare function defineI18nUI<Languages extends string>(config: I18nConfig<Languages>, localeTranslations?: Partial<Record<Languages, Record<string, string> & {
13
+ displayName?: string;
14
+ }>>): I18nUIConfig<Languages>;
69
15
  //#endregion
70
- export { I18nUIConfig, Translations, defaultTranslations, defineI18nUI, i18nProvider, uiTranslations };
16
+ export { I18nUIConfig, type Translations, defineI18nUI, i18nProvider, uiTranslations };
package/dist/i18n.js CHANGED
@@ -1,86 +1,39 @@
1
+ import keys_default from "./.translations/keys.js";
1
2
  //#region src/i18n.tsx
2
- const defaultTranslations = {
3
- displayName: "English",
4
- search: "Search",
5
- searchNoResult: "No results found",
6
- toc: "On this page",
7
- tocNoHeadings: "No Headings",
8
- lastUpdate: "Last updated on",
9
- chooseLanguage: "Choose a language",
10
- nextPage: "Next Page",
11
- previousPage: "Previous Page",
12
- chooseTheme: "Theme",
13
- editOnGithub: "Edit on GitHub",
14
- themeLight: "Light",
15
- themeDark: "Dark",
16
- themeSystem: "System",
17
- codeBlockCopy: "Copy Text",
18
- codeBlockCopied: "Copied Text",
19
- accordionCopyAnchor: "Copy Link",
20
- headingCopyAnchor: "Copy Anchor Link",
21
- pageActionsCopyMarkdown: "Copy Markdown",
22
- pageActionsOpen: "Open",
23
- pageActionsOpenGitHub: "Open in GitHub",
24
- pageActionsViewMarkdown: "View as Markdown",
25
- pageActionsOpenScira: "Open in Scira AI",
26
- pageActionsOpenChatGPT: "Open in ChatGPT",
27
- pageActionsOpenClaude: "Open in Claude",
28
- pageActionsOpenCursor: "Open in Cursor",
29
- pageActionsOpenInLLMPrompt: "Read {url}, I want to ask questions about it.",
30
- bannerClose: "Close Banner",
31
- searchOpen: "Open Search",
32
- searchClose: "Close Search",
33
- menuToggle: "Toggle Menu",
34
- themeToggle: "Toggle Theme",
35
- sidebarOpen: "Open Sidebar",
36
- sidebarCollapse: "Collapse Sidebar",
37
- tocInline: "Table of Contents",
38
- typeTableProp: "Prop",
39
- typeTableType: "Type",
40
- typeTableDefault: "Default",
41
- typeTableParameters: "Parameters",
42
- typeTableReturns: "Returns",
43
- notFoundTitle: "Page Not Found",
44
- notFoundDescription: "The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.",
45
- notFoundLink: "Back to Home"
46
- };
47
3
  function uiTranslations() {
48
- return {
49
- namespace: "ui",
50
- defaultValue: defaultTranslations
51
- };
4
+ return { keys: keys_default };
52
5
  }
53
6
  function i18nProvider(translations, lang) {
54
- const { defaultLanguage, languages } = translations.config;
55
- const { ui, ...rest } = translations.get(lang ?? defaultLanguage) ?? translations.get(defaultLanguage);
56
- return {
57
- locale: lang,
58
- translations: {
59
- ...ui,
60
- ...rest
61
- },
62
- locales: languages.map((locale) => ({
63
- locale,
64
- name: translations.get(locale).ui.displayName ?? locale
65
- }))
66
- };
7
+ const t = translations.extend(uiTranslations());
8
+ if ("config" in t) {
9
+ const { defaultLanguage, languages } = t.config;
10
+ const locale = lang ?? defaultLanguage;
11
+ const values = t.get(locale) ?? t.get(defaultLanguage);
12
+ return {
13
+ locale: lang,
14
+ translations: values,
15
+ locales: languages.map((code) => ({
16
+ locale: code,
17
+ name: values.displayName ?? code
18
+ }))
19
+ };
20
+ }
21
+ return { translations: t.get() };
67
22
  }
68
- /** @deprecated use the `i18n.translations()` & `uiTranslations()` APIs instead */
69
- function defineI18nUI(config, options = {}) {
70
- const translations = "translations" in options ? options.translations : options;
23
+ function defineI18nUI(config, localeTranslations = {}) {
71
24
  return {
72
25
  ...config,
73
26
  provider(locale = config.defaultLanguage) {
74
27
  return {
75
28
  locale,
76
- translations: translations[locale],
77
- locales: config.languages.map((locale) => ({
78
- locale,
79
- name: translations[locale]?.displayName ?? locale
29
+ translations: localeTranslations[locale],
30
+ locales: config.languages.map((code) => ({
31
+ locale: code,
32
+ name: localeTranslations[code]?.displayName ?? code
80
33
  }))
81
34
  };
82
35
  }
83
36
  };
84
37
  }
85
38
  //#endregion
86
- export { defaultTranslations, defineI18nUI, i18nProvider, uiTranslations };
39
+ export { defineI18nUI, i18nProvider, uiTranslations };
@@ -1,7 +1,6 @@
1
1
  import { BaseLayoutProps, GetLayoutTabsOptions, LayoutTab } from "../shared/index.js";
2
2
  import { SidebarProps, SidebarProviderProps } from "./slots/sidebar.js";
3
3
  import { DocsSlots, useDocsLayout } from "./client.js";
4
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
5
4
  import { HTMLAttributes, ReactNode } from "react";
6
5
  import * as PageTree from "fumadocs-core/page-tree";
7
6
 
@@ -40,6 +39,6 @@ declare function DocsLayout({
40
39
  tabMode,
41
40
  children,
42
41
  ...props
43
- }: DocsLayoutProps): _$react_jsx_runtime0.JSX.Element;
42
+ }: DocsLayoutProps): import("react").JSX.Element;
44
43
  //#endregion
45
44
  export { DocsLayout, DocsLayoutProps, type DocsSlots, useDocsLayout };
@@ -2,7 +2,6 @@ import { TOCPopoverProps, TOCProps, TOCProviderProps } from "./slots/toc.js";
2
2
  import { Footer, FooterProps } from "./slots/footer.js";
3
3
  import { Breadcrumb, BreadcrumbProps } from "./slots/breadcrumb.js";
4
4
  import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-actions.js";
5
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
6
5
  import { ComponentProps, FC, ReactNode } from "react";
7
6
  import { TOCItemType } from "fumadocs-core/toc";
8
7
 
@@ -86,8 +85,8 @@ declare function DocsPage({
86
85
  slots: defaultSlots,
87
86
  children,
88
87
  ...containerProps
89
- }: DocsPageProps): _$react_jsx_runtime0.JSX.Element;
90
- declare function EditOnGitHub(props: ComponentProps<'a'>): _$react_jsx_runtime0.JSX.Element;
88
+ }: DocsPageProps): import("react").JSX.Element;
89
+ declare function EditOnGitHub(props: ComponentProps<'a'>): import("react").JSX.Element;
91
90
  /**
92
91
  * Add typography styles
93
92
  */
@@ -95,22 +94,22 @@ declare function DocsBody({
95
94
  children,
96
95
  className,
97
96
  ...props
98
- }: ComponentProps<'div'>): _$react_jsx_runtime0.JSX.Element;
97
+ }: ComponentProps<'div'>): import("react").JSX.Element;
99
98
  declare function DocsDescription({
100
99
  children,
101
100
  className,
102
101
  ...props
103
- }: ComponentProps<'p'>): _$react_jsx_runtime0.JSX.Element | null;
102
+ }: ComponentProps<'p'>): import("react").JSX.Element | null;
104
103
  declare function DocsTitle({
105
104
  children,
106
105
  className,
107
106
  ...props
108
- }: ComponentProps<'h1'>): _$react_jsx_runtime0.JSX.Element;
107
+ }: ComponentProps<'h1'>): import("react").JSX.Element;
109
108
  declare function PageLastUpdate({
110
109
  date: value,
111
110
  ...props
112
111
  }: Omit<ComponentProps<'p'>, 'children'> & {
113
112
  date: Date;
114
- }): _$react_jsx_runtime0.JSX.Element;
113
+ }): import("react").JSX.Element;
115
114
  //#endregion
116
115
  export { type BreadcrumbProps, DocsBody, DocsDescription, DocsPage, DocsPageProps, DocsTitle, EditOnGitHub, type FooterProps, MarkdownCopyButton, Breadcrumb as PageBreadcrumb, Footer as PageFooter, PageLastUpdate, ViewOptionsPopover, useDocsPage };
@@ -2,7 +2,6 @@
2
2
  import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
3
3
  import { cn } from "../../../utils/cn.js";
4
4
  import { buttonVariants } from "../../../components/ui/button.js";
5
- import { I18nLabel, useTranslations } from "../../../contexts/i18n.js";
6
5
  import { TOC, TOCPopover, TOCProvider } from "./slots/toc.js";
7
6
  import { Footer } from "./slots/footer.js";
8
7
  import { Breadcrumb } from "./slots/breadcrumb.js";
@@ -11,6 +10,7 @@ import { MarkdownCopyButton, ViewOptionsPopover } from "../../shared/page-action
11
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
11
  import { Edit } from "lucide-react";
13
12
  import { createContext, use, useEffect, useState } from "react";
13
+ import { useTranslations } from "@fuma-translate/react";
14
14
  //#region src/layouts/docs/page/index.tsx
15
15
  var page_exports = /* @__PURE__ */ __exportAll({
16
16
  DocsBody: () => DocsBody,
@@ -67,6 +67,7 @@ function DocsPage({ full = false, tableOfContent: { enabled: tocEnabled = !full,
67
67
  });
68
68
  }
69
69
  function EditOnGitHub(props) {
70
+ const t = useTranslations({ note: "edit page" });
70
71
  return /* @__PURE__ */ jsx("a", {
71
72
  target: "_blank",
72
73
  rel: "noreferrer noopener",
@@ -75,7 +76,7 @@ function EditOnGitHub(props) {
75
76
  color: "secondary",
76
77
  size: "sm"
77
78
  }), "gap-1.5 not-prose", props.className),
78
- children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Edit, { className: "size-3.5" }), /* @__PURE__ */ jsx(I18nLabel, { label: "editOnGithub" })] })
79
+ children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Edit, { className: "size-3.5" }), t("Edit on GitHub")] })
79
80
  });
80
81
  }
81
82
  /**
@@ -104,7 +105,7 @@ function DocsTitle({ children, className, ...props }) {
104
105
  });
105
106
  }
106
107
  function PageLastUpdate({ date: value, ...props }) {
107
- const t = useTranslations();
108
+ const t = useTranslations({ note: "page footer" });
108
109
  const [date, setDate] = useState("");
109
110
  useEffect(() => {
110
111
  setDate(value.toLocaleDateString());
@@ -113,7 +114,7 @@ function PageLastUpdate({ date: value, ...props }) {
113
114
  ...props,
114
115
  className: cn("text-sm text-fd-muted-foreground", props.className),
115
116
  children: [
116
- t.lastUpdate,
117
+ t("Last updated on"),
117
118
  " ",
118
119
  date
119
120
  ]
@@ -1,4 +1,3 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
1
  import { ComponentProps } from "react";
3
2
  import { BreadcrumbOptions } from "fumadocs-core/breadcrumb";
4
3
 
@@ -9,6 +8,6 @@ declare function Breadcrumb({
9
8
  includeSeparator,
10
9
  includePage,
11
10
  ...props
12
- }: BreadcrumbProps): _$react_jsx_runtime0.JSX.Element | null;
11
+ }: BreadcrumbProps): import("react").JSX.Element | null;
13
12
  //#endregion
14
13
  export { Breadcrumb, BreadcrumbProps };
@@ -1,7 +1,6 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
1
  import { ComponentProps } from "react";
3
2
 
4
3
  //#region src/layouts/docs/page/slots/container.d.ts
5
- declare function Container(props: ComponentProps<'article'>): _$react_jsx_runtime0.JSX.Element;
4
+ declare function Container(props: ComponentProps<'article'>): import("react").JSX.Element;
6
5
  //#endregion
7
6
  export { Container };
@@ -1,4 +1,3 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
1
  import { ComponentProps } from "react";
3
2
  import * as PageTree from "fumadocs-core/page-tree";
4
3
 
@@ -18,6 +17,6 @@ declare function Footer({
18
17
  children,
19
18
  className,
20
19
  ...props
21
- }: FooterProps): _$react_jsx_runtime0.JSX.Element;
20
+ }: FooterProps): import("react").JSX.Element;
22
21
  //#endregion
23
22
  export { Footer, FooterProps };
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { cn } from "../../../../utils/cn.js";
3
- import { useTranslations } from "../../../../contexts/i18n.js";
4
3
  import { isActive } from "../../../../utils/urls.js";
5
4
  import { useFooterItems } from "../../../../utils/use-footer-items.js";
6
5
  import Link from "fumadocs-core/link";
@@ -8,6 +7,7 @@ import { usePathname } from "fumadocs-core/framework";
8
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
8
  import { ChevronLeft, ChevronRight } from "lucide-react";
10
9
  import { useMemo } from "react";
10
+ import { useTranslations } from "@fuma-translate/react";
11
11
  //#region src/layouts/docs/page/slots/footer.tsx
12
12
  function Footer({ items, children, className, ...props }) {
13
13
  const footerList = useFooterItems();
@@ -38,7 +38,7 @@ function Footer({ items, children, className, ...props }) {
38
38
  }), children] });
39
39
  }
40
40
  function FooterItem({ item, index }) {
41
- const t = useTranslations();
41
+ const t = useTranslations({ note: "pagination" });
42
42
  const Icon = index === 0 ? ChevronLeft : ChevronRight;
43
43
  return /* @__PURE__ */ jsxs(Link, {
44
44
  href: item.url,
@@ -48,7 +48,7 @@ function FooterItem({ item, index }) {
48
48
  children: [/* @__PURE__ */ jsx(Icon, { className: "-mx-1 size-4 shrink-0 rtl:rotate-180" }), /* @__PURE__ */ jsx("p", { children: item.name })]
49
49
  }), /* @__PURE__ */ jsx("p", {
50
50
  className: "text-fd-muted-foreground truncate",
51
- children: item.description ?? (index === 0 ? t.previousPage : t.nextPage)
51
+ children: item.description ?? (index === 0 ? t("Previous Page") : t("Next Page"))
52
52
  })]
53
53
  });
54
54
  }
@@ -1,12 +1,11 @@
1
1
  import { TOCItemsProps } from "../../../../components/toc/clerk.js";
2
2
  import { TOCItemsProps as TOCItemsProps$1 } from "../../../../components/toc/default.js";
3
3
  import { TOCProviderProps as TOCProviderProps$1 } from "../../../../components/toc/index.js";
4
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
5
4
  import { ComponentProps, ReactNode } from "react";
6
5
 
7
6
  //#region src/layouts/docs/page/slots/toc.d.ts
8
7
  type TOCProviderProps = TOCProviderProps$1;
9
- declare function TOCProvider(props: TOCProviderProps): _$react_jsx_runtime0.JSX.Element;
8
+ declare function TOCProvider(props: TOCProviderProps): import("react").JSX.Element;
10
9
  type TOCProps = {
11
10
  container?: ComponentProps<'div'>;
12
11
  /**
@@ -30,7 +29,7 @@ declare function TOC({
30
29
  footer,
31
30
  style,
32
31
  list
33
- }: TOCProps): _$react_jsx_runtime0.JSX.Element;
32
+ }: TOCProps): import("react").JSX.Element;
34
33
  type TOCPopoverProps = {
35
34
  container?: ComponentProps<'div'>;
36
35
  trigger?: ComponentProps<'button'>;
@@ -58,6 +57,6 @@ declare function TOCPopover({
58
57
  footer,
59
58
  style,
60
59
  list
61
- }: TOCPopoverProps): _$react_jsx_runtime0.JSX.Element;
60
+ }: TOCPopoverProps): import("react").JSX.Element;
62
61
  //#endregion
63
62
  export { TOC, TOCPopover, TOCPopoverProps, TOCProps, TOCProvider, TOCProviderProps };
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { cn } from "../../../../utils/cn.js";
3
- import { I18nLabel, useTranslations } from "../../../../contexts/i18n.js";
4
3
  import { TOCProvider as TOCProvider$1, TOCScrollArea, useItems, useTOCItems } from "../../../../components/toc/index.js";
5
4
  import { default_exports } from "../../../../components/toc/default.js";
6
5
  import { clerk_exports } from "../../../../components/toc/clerk.js";
@@ -11,11 +10,13 @@ import "../../index.js";
11
10
  import { jsx, jsxs } from "react/jsx-runtime";
12
11
  import { ChevronDown, Text } from "lucide-react";
13
12
  import { createContext, use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
13
+ import { useTranslations } from "@fuma-translate/react";
14
14
  //#region src/layouts/docs/page/slots/toc.tsx
15
15
  function TOCProvider(props) {
16
16
  return /* @__PURE__ */ jsx(TOCProvider$1, { ...props });
17
17
  }
18
18
  function TOC({ container, header, footer, style = "normal", list }) {
19
+ const t = useTranslations({ note: "table of contents" });
19
20
  const items = useTOCItems();
20
21
  const { TOCItems, TOCEmpty, TOCItem } = style === "clerk" ? clerk_exports : default_exports;
21
22
  if (items.length === 0 && !header && !footer) return /* @__PURE__ */ jsx("div", {
@@ -31,7 +32,7 @@ function TOC({ container, header, footer, style = "normal", list }) {
31
32
  /* @__PURE__ */ jsxs("h3", {
32
33
  id: "toc-title",
33
34
  className: "inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground",
34
- children: [/* @__PURE__ */ jsx(Text, { className: "size-4" }), /* @__PURE__ */ jsx(I18nLabel, { label: "toc" })]
35
+ children: [/* @__PURE__ */ jsx(Text, { className: "size-4" }), t("On this page")]
35
36
  }),
36
37
  /* @__PURE__ */ jsx(TOCScrollArea, { children: /* @__PURE__ */ jsxs(TOCItems, {
37
38
  ...list,
@@ -94,7 +95,7 @@ function TOCPopover({ container, trigger, content, header, footer, style = "norm
94
95
  });
95
96
  }
96
97
  function PageTOCPopoverTrigger({ className, ...props }) {
97
- const t = useTranslations();
98
+ const t = useTranslations({ note: "table of contents" });
98
99
  const { open } = use(TocPopoverContext);
99
100
  const items = useItems();
100
101
  const selectedIdx = items.findIndex((item) => item.active);
@@ -114,7 +115,7 @@ function PageTOCPopoverTrigger({ className, ...props }) {
114
115
  className: "grid flex-1 *:my-auto *:row-start-1 *:col-start-1",
115
116
  children: [/* @__PURE__ */ jsx("span", {
116
117
  className: cn("truncate transition-[opacity,translate,color]", open && "text-fd-foreground", showItem && "opacity-0 -translate-y-full pointer-events-none"),
117
- children: path?.name ?? t.toc
118
+ children: path?.name ?? t("On this page")
118
119
  }), /* @__PURE__ */ jsx("span", {
119
120
  className: cn("truncate transition-[opacity,translate]", !showItem && "opacity-0 translate-y-full pointer-events-none"),
120
121
  children: items[selectedIdx]?.original.title
@@ -1,7 +1,6 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
1
  import { ComponentProps } from "react";
3
2
 
4
3
  //#region src/layouts/docs/slots/container.d.ts
5
- declare function Container(props: ComponentProps<'div'>): _$react_jsx_runtime0.JSX.Element;
4
+ declare function Container(props: ComponentProps<'div'>): import("react").JSX.Element;
6
5
  //#endregion
7
6
  export { Container };
@@ -1,8 +1,6 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as _$react from "react";
3
1
  import { ComponentProps } from "react";
4
2
 
5
3
  //#region src/layouts/docs/slots/header.d.ts
6
- declare function Header(props: ComponentProps<'header'>): string | number | bigint | true | _$react_jsx_runtime0.JSX.Element | Iterable<_$react.ReactNode> | Promise<string | number | bigint | boolean | _$react.ReactPortal | _$react.ReactElement<unknown, string | _$react.JSXElementConstructor<any>> | Iterable<_$react.ReactNode> | null | undefined>;
4
+ declare function Header(props: ComponentProps<'header'>): string | number | bigint | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined>;
7
5
  //#endregion
8
6
  export { Header };