@fumadocs/ui 16.4.1 → 16.4.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 (73) hide show
  1. package/css/colors/ocean.css +1 -5
  2. package/css/colors/vitepress.css +3 -15
  3. package/dist/cn.d.ts +2 -2
  4. package/dist/cn.js +3 -1
  5. package/dist/components/toc/clerk.d.ts +11 -2
  6. package/dist/components/toc/clerk.d.ts.map +1 -1
  7. package/dist/components/toc/clerk.js +105 -69
  8. package/dist/components/toc/clerk.js.map +1 -0
  9. package/dist/components/toc/default.d.ts +11 -2
  10. package/dist/components/toc/default.d.ts.map +1 -1
  11. package/dist/components/toc/default.js +36 -15
  12. package/dist/components/toc/default.js.map +1 -0
  13. package/dist/components/toc/index.d.ts +23 -8
  14. package/dist/components/toc/index.d.ts.map +1 -1
  15. package/dist/components/toc/index.js +74 -59
  16. package/dist/components/toc/index.js.map +1 -0
  17. package/dist/contexts/i18n.d.ts +53 -43
  18. package/dist/contexts/i18n.d.ts.map +1 -1
  19. package/dist/contexts/i18n.js +55 -50
  20. package/dist/contexts/i18n.js.map +1 -0
  21. package/dist/contexts/search.d.ts +62 -49
  22. package/dist/contexts/search.d.ts.map +1 -1
  23. package/dist/contexts/search.js +56 -50
  24. package/dist/contexts/search.js.map +1 -0
  25. package/dist/contexts/tree.d.ts +18 -11
  26. package/dist/contexts/tree.d.ts.map +1 -1
  27. package/dist/contexts/tree.js +36 -26
  28. package/dist/contexts/tree.js.map +1 -0
  29. package/dist/hooks/use-copy-button.d.ts +6 -2
  30. package/dist/hooks/use-copy-button.d.ts.map +1 -1
  31. package/dist/hooks/use-copy-button.js +28 -25
  32. package/dist/hooks/use-copy-button.js.map +1 -0
  33. package/dist/hooks/use-footer-items.d.ts +7 -2
  34. package/dist/hooks/use-footer-items.d.ts.map +1 -1
  35. package/dist/hooks/use-footer-items.js +26 -25
  36. package/dist/hooks/use-footer-items.js.map +1 -0
  37. package/dist/hooks/use-is-scroll-top.d.ts +7 -2
  38. package/dist/hooks/use-is-scroll-top.d.ts.map +1 -1
  39. package/dist/hooks/use-is-scroll-top.js +23 -16
  40. package/dist/hooks/use-is-scroll-top.js.map +1 -0
  41. package/dist/i18n.d.ts +11 -11
  42. package/dist/i18n.d.ts.map +1 -1
  43. package/dist/i18n.js +19 -15
  44. package/dist/i18n.js.map +1 -0
  45. package/dist/link-item.d.ts +74 -66
  46. package/dist/link-item.d.ts.map +1 -1
  47. package/dist/link-item.js +23 -10
  48. package/dist/link-item.js.map +1 -0
  49. package/dist/merge-refs.d.ts +6 -2
  50. package/dist/merge-refs.d.ts.map +1 -1
  51. package/dist/merge-refs.js +12 -11
  52. package/dist/merge-refs.js.map +1 -0
  53. package/dist/og/next.d.ts +20 -12
  54. package/dist/og/next.d.ts.map +1 -1
  55. package/dist/og/next.js +68 -43
  56. package/dist/og/next.js.map +1 -0
  57. package/dist/typography/index.d.ts +10 -8
  58. package/dist/typography/index.d.ts.map +1 -1
  59. package/dist/typography/index.js +1714 -127
  60. package/dist/typography/index.js.map +1 -0
  61. package/dist/typography/styles.d.ts +92 -89
  62. package/dist/typography/styles.d.ts.map +1 -1
  63. package/dist/typography/styles.js +337 -423
  64. package/dist/typography/styles.js.map +1 -0
  65. package/dist/urls.d.ts +5 -2
  66. package/dist/urls.d.ts.map +1 -1
  67. package/dist/urls.js +14 -10
  68. package/dist/urls.js.map +1 -0
  69. package/package.json +20 -20
  70. package/dist/cn.d.ts.map +0 -1
  71. package/dist/icons.d.ts +0 -50
  72. package/dist/icons.d.ts.map +0 -1
  73. package/dist/icons.js +0 -292
@@ -1,50 +1,60 @@
1
- import { type ReactNode } from 'react';
2
- export interface Translations {
3
- search: string;
4
- searchNoResult: string;
5
- toc: string;
6
- tocNoHeadings: string;
7
- lastUpdate: string;
8
- chooseLanguage: string;
9
- nextPage: string;
10
- previousPage: string;
11
- chooseTheme: string;
12
- editOnGithub: string;
1
+ import { ReactNode } from "react";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+
4
+ //#region src/contexts/i18n.d.ts
5
+ interface Translations {
6
+ search: string;
7
+ searchNoResult: string;
8
+ toc: string;
9
+ tocNoHeadings: string;
10
+ lastUpdate: string;
11
+ chooseLanguage: string;
12
+ nextPage: string;
13
+ previousPage: string;
14
+ chooseTheme: string;
15
+ editOnGithub: string;
13
16
  }
14
- export interface LocaleItem {
15
- name: string;
16
- locale: string;
17
+ interface LocaleItem {
18
+ name: string;
19
+ locale: string;
17
20
  }
18
21
  interface I18nContextType {
19
- locale?: string;
20
- onChange?: (v: string) => void;
21
- text: Translations;
22
- locales?: LocaleItem[];
22
+ locale?: string;
23
+ onChange?: (v: string) => void;
24
+ text: Translations;
25
+ locales?: LocaleItem[];
23
26
  }
24
- export declare const defaultTranslations: Translations;
25
- export declare function I18nLabel(props: {
26
- label: keyof Translations;
27
+ declare const defaultTranslations: Translations;
28
+ declare function I18nLabel(props: {
29
+ label: keyof Translations;
27
30
  }): string;
28
- export declare function useI18n(): I18nContextType;
29
- export interface I18nProviderProps {
30
- /**
31
- * Current locale
32
- */
33
- locale: string;
34
- /**
35
- * Handle changes to the locale, redirect user when not specified.
36
- */
37
- onLocaleChange?: (v: string) => void;
38
- /**
39
- * Translations of current locale
40
- */
41
- translations?: Partial<Translations>;
42
- /**
43
- * Available languages
44
- */
45
- locales?: LocaleItem[];
46
- children?: ReactNode;
31
+ declare function useI18n(): I18nContextType;
32
+ interface I18nProviderProps {
33
+ /**
34
+ * Current locale
35
+ */
36
+ locale: string;
37
+ /**
38
+ * Handle changes to the locale, redirect user when not specified.
39
+ */
40
+ onLocaleChange?: (v: string) => void;
41
+ /**
42
+ * Translations of current locale
43
+ */
44
+ translations?: Partial<Translations>;
45
+ /**
46
+ * Available languages
47
+ */
48
+ locales?: LocaleItem[];
49
+ children?: ReactNode;
47
50
  }
48
- export declare function I18nProvider({ locales, locale, onLocaleChange, children, translations, }: I18nProviderProps): import("react/jsx-runtime").JSX.Element;
49
- export {};
51
+ declare function I18nProvider({
52
+ locales,
53
+ locale,
54
+ onLocaleChange,
55
+ children,
56
+ translations
57
+ }: I18nProviderProps): react_jsx_runtime0.JSX.Element;
58
+ //#endregion
59
+ export { I18nLabel, I18nProvider, I18nProviderProps, LocaleItem, Translations, defaultTranslations, useI18n };
50
60
  //# sourceMappingURL=i18n.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/contexts/i18n.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IAEvB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IAEtB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,eAAe;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,EAAE,YAWjC,CAAC;AAMF,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,YAAY,CAAA;CAAE,GAAG,MAAM,CAItE;AAED,wBAAgB,OAAO,IAAI,eAAe,CAEzC;AAED,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAErC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAErC;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IAEvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,OAAY,EACZ,MAAM,EACN,cAAc,EACd,QAAQ,EACR,YAAY,GACb,EAAE,iBAAiB,2CAuCnB"}
1
+ {"version":3,"file":"i18n.d.ts","names":[],"sources":["../../src/contexts/i18n.tsx"],"sourcesContent":[],"mappings":";;;;UAIiB,YAAA;;;EAAA,GAAA,EAAA,MAAA;EAeA,aAAU,EAAA,MAAA;EAKjB,UAAA,EAAA,MAAe;EAOZ,cAAA,EAAA,MAWZ;EAMe,QAAA,EAAA,MAAS;EAMT,YAAO,EAAA,MAAA;EAIN,WAAA,EAAA,MAAA;EAcQ,YAAA,EAAA,MAAA;;AAKb,UA1DK,UAAA,CA0DL;EAEC,IAAA,EAAA,MAAA;EAAS,MAAA,EAAA,MAAA;AAGtB;UA1DU,eAAA,CA2DR;EACA,MAAA,CAAA,EAAA,MAAA;EACA,QAAA,CAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EACA,IAAA,EA3DM,YA2DN;EACA,OAAA,CAAA,EA3DU,UA2DV,EAAA;;AACkB,cAzDP,mBAyDO,EAzDc,YAyDd;AAAA,iBAxCJ,SAAA,CAwCI,KAAA,EAAA;eAxC4B;;iBAMhC,OAAA,CAAA,GAAW;UAIV,iBAAA;;;;;;;;;;;;iBAcA,QAAQ;;;;YAKb;aAEC;;iBAGG,YAAA;;;;;;GAMb,oBAAiB,kBAAA,CAAA,GAAA,CAAA"}
@@ -1,55 +1,60 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createContext, useContext, useMemo, useRef, } from 'react';
4
- import { usePathname, useRouter } from 'fumadocs-core/framework';
5
- export const defaultTranslations = {
6
- search: 'Search',
7
- searchNoResult: 'No results found',
8
- toc: 'On this page',
9
- tocNoHeadings: 'No Headings',
10
- lastUpdate: 'Last updated on',
11
- chooseLanguage: 'Choose a language',
12
- nextPage: 'Next Page',
13
- previousPage: 'Previous Page',
14
- chooseTheme: 'Theme',
15
- editOnGithub: 'Edit on GitHub',
2
+
3
+ import { createContext, useContext, useMemo, useRef } from "react";
4
+ import { usePathname, useRouter } from "fumadocs-core/framework";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/contexts/i18n.tsx
8
+ const defaultTranslations = {
9
+ search: "Search",
10
+ searchNoResult: "No results found",
11
+ toc: "On this page",
12
+ tocNoHeadings: "No Headings",
13
+ lastUpdate: "Last updated on",
14
+ chooseLanguage: "Choose a language",
15
+ nextPage: "Next Page",
16
+ previousPage: "Previous Page",
17
+ chooseTheme: "Theme",
18
+ editOnGithub: "Edit on GitHub"
16
19
  };
17
- const I18nContext = createContext({
18
- text: defaultTranslations,
19
- });
20
- export function I18nLabel(props) {
21
- const { text } = useI18n();
22
- return text[props.label];
20
+ const I18nContext = createContext({ text: defaultTranslations });
21
+ function I18nLabel(props) {
22
+ const { text } = useI18n();
23
+ return text[props.label];
23
24
  }
24
- export function useI18n() {
25
- return useContext(I18nContext);
25
+ function useI18n() {
26
+ return useContext(I18nContext);
26
27
  }
27
- export function I18nProvider({ locales = [], locale, onLocaleChange, children, translations, }) {
28
- const router = useRouter();
29
- const pathname = usePathname();
30
- const onChange = (value) => {
31
- if (onLocaleChange) {
32
- return onLocaleChange(value);
33
- }
34
- const segments = pathname.split('/').filter((v) => v.length > 0);
35
- // If locale prefix hidden
36
- if (segments[0] !== locale) {
37
- segments.unshift(value);
38
- }
39
- else {
40
- segments[0] = value;
41
- }
42
- router.push(`/${segments.join('/')}`);
43
- };
44
- const onChangeRef = useRef(onChange);
45
- onChangeRef.current = onChange;
46
- return (_jsx(I18nContext, { value: useMemo(() => ({
47
- locale,
48
- locales,
49
- text: {
50
- ...defaultTranslations,
51
- ...translations,
52
- },
53
- onChange: (v) => onChangeRef.current(v),
54
- }), [locale, locales, translations]), children: children }));
28
+ function I18nProvider({ locales = [], locale, onLocaleChange, children, translations }) {
29
+ const router = useRouter();
30
+ const pathname = usePathname();
31
+ const onChange = (value) => {
32
+ if (onLocaleChange) return onLocaleChange(value);
33
+ const segments = pathname.split("/").filter((v) => v.length > 0);
34
+ if (segments[0] !== locale) segments.unshift(value);
35
+ else segments[0] = value;
36
+ router.push(`/${segments.join("/")}`);
37
+ };
38
+ const onChangeRef = useRef(onChange);
39
+ onChangeRef.current = onChange;
40
+ return /* @__PURE__ */ jsx(I18nContext, {
41
+ value: useMemo(() => ({
42
+ locale,
43
+ locales,
44
+ text: {
45
+ ...defaultTranslations,
46
+ ...translations
47
+ },
48
+ onChange: (v) => onChangeRef.current(v)
49
+ }), [
50
+ locale,
51
+ locales,
52
+ translations
53
+ ]),
54
+ children
55
+ });
55
56
  }
57
+
58
+ //#endregion
59
+ export { I18nLabel, I18nProvider, defaultTranslations, useI18n };
60
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","names":["defaultTranslations: Translations"],"sources":["../../src/contexts/i18n.tsx"],"sourcesContent":["'use client';\nimport { createContext, type ReactNode, useContext, useMemo, useRef } from 'react';\nimport { usePathname, useRouter } from 'fumadocs-core/framework';\n\nexport interface Translations {\n search: string;\n searchNoResult: string;\n\n toc: string;\n tocNoHeadings: string;\n\n lastUpdate: string;\n chooseLanguage: string;\n nextPage: string;\n previousPage: string;\n chooseTheme: string;\n editOnGithub: string;\n}\n\nexport interface LocaleItem {\n name: string;\n locale: string;\n}\n\ninterface I18nContextType {\n locale?: string;\n onChange?: (v: string) => void;\n text: Translations;\n locales?: LocaleItem[];\n}\n\nexport const defaultTranslations: Translations = {\n search: 'Search',\n searchNoResult: 'No results found',\n toc: 'On this page',\n tocNoHeadings: 'No Headings',\n lastUpdate: 'Last updated on',\n chooseLanguage: 'Choose a language',\n nextPage: 'Next Page',\n previousPage: 'Previous Page',\n chooseTheme: 'Theme',\n editOnGithub: 'Edit on GitHub',\n};\n\nconst I18nContext = createContext<I18nContextType>({\n text: defaultTranslations,\n});\n\nexport function I18nLabel(props: { label: keyof Translations }): string {\n const { text } = useI18n();\n\n return text[props.label];\n}\n\nexport function useI18n(): I18nContextType {\n return useContext(I18nContext);\n}\n\nexport interface I18nProviderProps {\n /**\n * Current locale\n */\n locale: string;\n\n /**\n * Handle changes to the locale, redirect user when not specified.\n */\n onLocaleChange?: (v: string) => void;\n\n /**\n * Translations of current locale\n */\n translations?: Partial<Translations>;\n\n /**\n * Available languages\n */\n locales?: LocaleItem[];\n\n children?: ReactNode;\n}\n\nexport function I18nProvider({\n locales = [],\n locale,\n onLocaleChange,\n children,\n translations,\n}: I18nProviderProps) {\n const router = useRouter();\n const pathname = usePathname();\n const onChange = (value: string) => {\n if (onLocaleChange) {\n return onLocaleChange(value);\n }\n const segments = pathname.split('/').filter((v) => v.length > 0);\n\n // If locale prefix hidden\n if (segments[0] !== locale) {\n segments.unshift(value);\n } else {\n segments[0] = value;\n }\n\n router.push(`/${segments.join('/')}`);\n };\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n return (\n <I18nContext\n value={useMemo(\n () => ({\n locale,\n locales,\n text: {\n ...defaultTranslations,\n ...translations,\n },\n onChange: (v) => onChangeRef.current(v),\n }),\n [locale, locales, translations],\n )}\n >\n {children}\n </I18nContext>\n );\n}\n"],"mappings":";;;;;;;AA+BA,MAAaA,sBAAoC;CAC/C,QAAQ;CACR,gBAAgB;CAChB,KAAK;CACL,eAAe;CACf,YAAY;CACZ,gBAAgB;CAChB,UAAU;CACV,cAAc;CACd,aAAa;CACb,cAAc;CACf;AAED,MAAM,cAAc,cAA+B,EACjD,MAAM,qBACP,CAAC;AAEF,SAAgB,UAAU,OAA8C;CACtE,MAAM,EAAE,SAAS,SAAS;AAE1B,QAAO,KAAK,MAAM;;AAGpB,SAAgB,UAA2B;AACzC,QAAO,WAAW,YAAY;;AA2BhC,SAAgB,aAAa,EAC3B,UAAU,EAAE,EACZ,QACA,gBACA,UACA,gBACoB;CACpB,MAAM,SAAS,WAAW;CAC1B,MAAM,WAAW,aAAa;CAC9B,MAAM,YAAY,UAAkB;AAClC,MAAI,eACF,QAAO,eAAe,MAAM;EAE9B,MAAM,WAAW,SAAS,MAAM,IAAI,CAAC,QAAQ,MAAM,EAAE,SAAS,EAAE;AAGhE,MAAI,SAAS,OAAO,OAClB,UAAS,QAAQ,MAAM;MAEvB,UAAS,KAAK;AAGhB,SAAO,KAAK,IAAI,SAAS,KAAK,IAAI,GAAG;;CAEvC,MAAM,cAAc,OAAO,SAAS;AACpC,aAAY,UAAU;AAEtB,QACE,oBAAC;EACC,OAAO,eACE;GACL;GACA;GACA,MAAM;IACJ,GAAG;IACH,GAAG;IACJ;GACD,WAAW,MAAM,YAAY,QAAQ,EAAE;GACxC,GACD;GAAC;GAAQ;GAAS;GAAa,CAChC;EAEA;GACW"}
@@ -1,61 +1,74 @@
1
- import { type ComponentType, type ReactNode } from 'react';
1
+ import { ComponentType, ReactNode } from "react";
2
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
3
+
4
+ //#region src/contexts/search.d.ts
2
5
  interface HotKey {
3
- display: ReactNode;
4
- /**
5
- * Key code or a function determining whether the key is pressed.
6
- */
7
- key: string | ((e: KeyboardEvent) => boolean);
6
+ display: ReactNode;
7
+ /**
8
+ * Key code or a function determining whether the key is pressed.
9
+ */
10
+ key: string | ((e: KeyboardEvent) => boolean);
8
11
  }
9
- export interface SharedProps {
10
- open: boolean;
11
- onOpenChange: (open: boolean) => void;
12
+ interface SharedProps {
13
+ open: boolean;
14
+ onOpenChange: (open: boolean) => void;
12
15
  }
13
- export type SearchLink = [name: string, href: string];
14
- export interface TagItem {
15
- name: string;
16
- value: string;
16
+ type SearchLink = [name: string, href: string];
17
+ interface TagItem {
18
+ name: string;
19
+ value: string;
17
20
  }
18
- export interface SearchProviderProps {
19
- /**
20
- * Preload search dialog before opening it
21
- *
22
- * @defaultValue `true`
23
- */
24
- preload?: boolean;
25
- /**
26
- * Custom links to be displayed if search is empty
27
- */
28
- links?: SearchLink[];
29
- /**
30
- * Hotkeys for triggering search dialog
31
- *
32
- * @defaultValue Meta/Ctrl + K
33
- */
34
- hotKey?: HotKey[];
35
- /**
36
- * Replace default search dialog, allowing you to use other solutions such as Algolia Search
37
- *
38
- * It receives the `open` and `onOpenChange` prop, can be lazy loaded with `next/dynamic`
39
- */
40
- SearchDialog: ComponentType<SharedProps>;
41
- /**
42
- * Additional props to the dialog
43
- */
44
- options?: Partial<SharedProps & Record<string, unknown>>;
45
- children?: ReactNode;
21
+ interface SearchProviderProps {
22
+ /**
23
+ * Preload search dialog before opening it
24
+ *
25
+ * @defaultValue `true`
26
+ */
27
+ preload?: boolean;
28
+ /**
29
+ * Custom links to be displayed if search is empty
30
+ */
31
+ links?: SearchLink[];
32
+ /**
33
+ * Hotkeys for triggering search dialog
34
+ *
35
+ * @defaultValue Meta/Ctrl + K
36
+ */
37
+ hotKey?: HotKey[];
38
+ /**
39
+ * Replace default search dialog, allowing you to use other solutions such as Algolia Search
40
+ *
41
+ * It receives the `open` and `onOpenChange` prop, can be lazy loaded with `next/dynamic`
42
+ */
43
+ SearchDialog: ComponentType<SharedProps>;
44
+ /**
45
+ * Additional props to the dialog
46
+ */
47
+ options?: Partial<SharedProps & Record<string, unknown>>;
48
+ children?: ReactNode;
46
49
  }
47
50
  interface SearchContextType {
48
- enabled: boolean;
49
- hotKey: HotKey[];
50
- setOpenSearch: (value: boolean) => void;
51
+ enabled: boolean;
52
+ hotKey: HotKey[];
53
+ setOpenSearch: (value: boolean) => void;
51
54
  }
52
- export declare function useSearchContext(): SearchContextType;
53
- export declare function SearchProvider({ SearchDialog, children, preload, options, hotKey, links, }: SearchProviderProps): import("react/jsx-runtime").JSX.Element;
55
+ declare function useSearchContext(): SearchContextType;
56
+ declare function SearchProvider({
57
+ SearchDialog,
58
+ children,
59
+ preload,
60
+ options,
61
+ hotKey,
62
+ links
63
+ }: SearchProviderProps): react_jsx_runtime1.JSX.Element;
54
64
  /**
55
65
  * Show children only when search is enabled via React Context
56
66
  */
57
- export declare function SearchOnly({ children }: {
58
- children: ReactNode;
67
+ declare function SearchOnly({
68
+ children
69
+ }: {
70
+ children: ReactNode;
59
71
  }): ReactNode;
60
- export {};
72
+ //#endregion
73
+ export { SearchLink, SearchOnly, SearchProvider, SearchProviderProps, SharedProps, TagItem, useSearchContext };
61
74
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/contexts/search.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAEf,UAAU,MAAM;IACd,OAAO,EAAE,SAAS,CAAC;IAEnB;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEtD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IAErB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;OAIG;IACH,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAEzC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEzD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC;AAQD,wBAAgB,gBAAgB,IAAI,iBAAiB,CAEpD;AAcD,wBAAgB,cAAc,CAAC,EAC7B,YAAY,EACZ,QAAQ,EACR,OAAc,EACd,OAAO,EACP,MASC,EACD,KAAK,GACN,EAAE,mBAAmB,2CA2CrB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,aAI/D"}
1
+ {"version":3,"file":"search.d.ts","names":[],"sources":["../../src/contexts/search.tsx"],"sourcesContent":[],"mappings":";;;;UAYU,MAAA;WACC;;AAHI;AAWf;EAKY,GAAA,EAAA,MAAA,GAAU,CAAA,CAAA,CAAA,EARD,aAQC,EAAA,GAAA,OAAA,CAAA;AAEtB;AAKiB,UAZA,WAAA,CAYmB;EAW1B,IAAA,EAAA,OAAA;EAOC,YAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GAAA,IAAA;;AAOK,KAhCJ,UAAA,GAgCI,CAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA;AAKI,UAnCH,OAAA,CAmCG;EAAc,IAAA,EAAA,MAAA;EAAtB,KAAA,EAAA,MAAA;;AAEU,UAhCL,mBAAA,CAgCK;EAGZ;AAYV;AAgBA;;;EAGE,OAAA,CAAA,EAAA,OAAA;EACA;;;EAYC,KAAA,CAAA,EApEO,UAoEP,EAAA;EAAmB;;AA4CtB;;;EAAgE,MAAA,CAAA,EAzGrD,MAyGqD,EAAA;EAAA;;;;;gBAlGhD,cAAc;;;;YAKlB,QAAQ,cAAc;aAErB;;UAGH,iBAAA;;UAEA;;;iBAUM,gBAAA,CAAA,GAAoB;iBAgBpB,cAAA;;;;;;;GAgBb,sBAAmB,kBAAA,CAAA,GAAA,CAAA;;;;iBA4CN,UAAA;;;YAAqC;IAAW"}
@@ -1,59 +1,65 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, use, useEffect, useEffectEvent, useMemo, useState, } from 'react';
2
+
3
+ import { createContext, use, useEffect, useEffectEvent, useMemo, useState } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+
6
+ //#region src/contexts/search.tsx
4
7
  const SearchContext = createContext({
5
- enabled: false,
6
- hotKey: [],
7
- setOpenSearch: () => undefined,
8
+ enabled: false,
9
+ hotKey: [],
10
+ setOpenSearch: () => void 0
8
11
  });
9
- export function useSearchContext() {
10
- return use(SearchContext);
12
+ function useSearchContext() {
13
+ return use(SearchContext);
11
14
  }
12
15
  function MetaOrControl() {
13
- const [key, setKey] = useState('');
14
- useEffect(() => {
15
- const isWindows = window.navigator.userAgent.includes('Windows');
16
- if (isWindows)
17
- setKey('Ctrl');
18
- }, []);
19
- return key;
16
+ const [key, setKey] = useState("");
17
+ useEffect(() => {
18
+ if (window.navigator.userAgent.includes("Windows")) setKey("Ctrl");
19
+ }, []);
20
+ return key;
20
21
  }
21
- export function SearchProvider({ SearchDialog, children, preload = true, options, hotKey = [
22
- {
23
- key: (e) => e.metaKey || e.ctrlKey,
24
- display: _jsx(MetaOrControl, {}),
25
- },
26
- {
27
- key: 'k',
28
- display: 'K',
29
- },
30
- ], links, }) {
31
- const [isOpen, setIsOpen] = useState(preload ? false : undefined);
32
- const onKeyDown = useEffectEvent((e) => {
33
- if (hotKey.every((v) => typeof v.key === 'string' ? e.key === v.key : v.key(e))) {
34
- setIsOpen((open) => !open);
35
- e.preventDefault();
36
- }
37
- });
38
- useEffect(() => {
39
- window.addEventListener('keydown', onKeyDown);
40
- return () => {
41
- window.removeEventListener('keydown', onKeyDown);
42
- };
43
- }, [hotKey]);
44
- return (_jsxs(SearchContext, { value: useMemo(() => ({
45
- enabled: true,
46
- hotKey,
47
- setOpenSearch: setIsOpen,
48
- }), [hotKey]), children: [isOpen !== undefined && (_jsx(SearchDialog, { open: isOpen, onOpenChange: setIsOpen,
49
- // @ts-expect-error -- insert prop for official UIs
50
- links: links, ...options })), children] }));
22
+ function SearchProvider({ SearchDialog, children, preload = true, options, hotKey = [{
23
+ key: (e) => e.metaKey || e.ctrlKey,
24
+ display: /* @__PURE__ */ jsx(MetaOrControl, {})
25
+ }, {
26
+ key: "k",
27
+ display: "K"
28
+ }], links }) {
29
+ const [isOpen, setIsOpen] = useState(preload ? false : void 0);
30
+ const onKeyDown = useEffectEvent((e) => {
31
+ if (hotKey.every((v) => typeof v.key === "string" ? e.key === v.key : v.key(e))) {
32
+ setIsOpen((open) => !open);
33
+ e.preventDefault();
34
+ }
35
+ });
36
+ useEffect(() => {
37
+ window.addEventListener("keydown", onKeyDown);
38
+ return () => {
39
+ window.removeEventListener("keydown", onKeyDown);
40
+ };
41
+ }, [hotKey]);
42
+ return /* @__PURE__ */ jsxs(SearchContext, {
43
+ value: useMemo(() => ({
44
+ enabled: true,
45
+ hotKey,
46
+ setOpenSearch: setIsOpen
47
+ }), [hotKey]),
48
+ children: [isOpen !== void 0 && /* @__PURE__ */ jsx(SearchDialog, {
49
+ open: isOpen,
50
+ onOpenChange: setIsOpen,
51
+ links,
52
+ ...options
53
+ }), children]
54
+ });
51
55
  }
52
56
  /**
53
- * Show children only when search is enabled via React Context
54
- */
55
- export function SearchOnly({ children }) {
56
- const search = useSearchContext();
57
- if (search.enabled)
58
- return children;
57
+ * Show children only when search is enabled via React Context
58
+ */
59
+ function SearchOnly({ children }) {
60
+ if (useSearchContext().enabled) return children;
59
61
  }
62
+
63
+ //#endregion
64
+ export { SearchOnly, SearchProvider, useSearchContext };
65
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","names":[],"sources":["../../src/contexts/search.tsx"],"sourcesContent":["'use client';\nimport {\n type ComponentType,\n createContext,\n type ReactNode,\n use,\n useEffect,\n useEffectEvent,\n useMemo,\n useState,\n} from 'react';\n\ninterface HotKey {\n display: ReactNode;\n\n /**\n * Key code or a function determining whether the key is pressed.\n */\n key: string | ((e: KeyboardEvent) => boolean);\n}\n\nexport interface SharedProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}\n\nexport type SearchLink = [name: string, href: string];\n\nexport interface TagItem {\n name: string;\n value: string;\n}\n\nexport interface SearchProviderProps {\n /**\n * Preload search dialog before opening it\n *\n * @defaultValue `true`\n */\n preload?: boolean;\n\n /**\n * Custom links to be displayed if search is empty\n */\n links?: SearchLink[];\n\n /**\n * Hotkeys for triggering search dialog\n *\n * @defaultValue Meta/Ctrl + K\n */\n hotKey?: HotKey[];\n\n /**\n * Replace default search dialog, allowing you to use other solutions such as Algolia Search\n *\n * It receives the `open` and `onOpenChange` prop, can be lazy loaded with `next/dynamic`\n */\n SearchDialog: ComponentType<SharedProps>;\n\n /**\n * Additional props to the dialog\n */\n options?: Partial<SharedProps & Record<string, unknown>>;\n\n children?: ReactNode;\n}\n\ninterface SearchContextType {\n enabled: boolean;\n hotKey: HotKey[];\n setOpenSearch: (value: boolean) => void;\n}\n\nconst SearchContext = createContext<SearchContextType>({\n enabled: false,\n hotKey: [],\n setOpenSearch: () => undefined,\n});\n\nexport function useSearchContext(): SearchContextType {\n return use(SearchContext);\n}\n\nfunction MetaOrControl() {\n const [key, setKey] = useState('⌘');\n\n useEffect(() => {\n const isWindows = window.navigator.userAgent.includes('Windows');\n\n if (isWindows) setKey('Ctrl');\n }, []);\n\n return key;\n}\n\nexport function SearchProvider({\n SearchDialog,\n children,\n preload = true,\n options,\n hotKey = [\n {\n key: (e) => e.metaKey || e.ctrlKey,\n display: <MetaOrControl />,\n },\n {\n key: 'k',\n display: 'K',\n },\n ],\n links,\n}: SearchProviderProps) {\n const [isOpen, setIsOpen] = useState(preload ? false : undefined);\n const onKeyDown = useEffectEvent((e: KeyboardEvent) => {\n if (hotKey.every((v) => (typeof v.key === 'string' ? e.key === v.key : v.key(e)))) {\n setIsOpen((open) => !open);\n e.preventDefault();\n }\n });\n\n useEffect(() => {\n window.addEventListener('keydown', onKeyDown);\n return () => {\n window.removeEventListener('keydown', onKeyDown);\n };\n }, [hotKey]);\n\n return (\n <SearchContext\n value={useMemo(\n () => ({\n enabled: true,\n hotKey,\n setOpenSearch: setIsOpen,\n }),\n [hotKey],\n )}\n >\n {isOpen !== undefined && (\n <SearchDialog\n open={isOpen}\n onOpenChange={setIsOpen}\n // @ts-expect-error -- insert prop for official UIs\n links={links}\n {...options}\n />\n )}\n {children}\n </SearchContext>\n );\n}\n\n/**\n * Show children only when search is enabled via React Context\n */\nexport function SearchOnly({ children }: { children: ReactNode }) {\n const search = useSearchContext();\n\n if (search.enabled) return children;\n}\n"],"mappings":";;;;;;AA0EA,MAAM,gBAAgB,cAAiC;CACrD,SAAS;CACT,QAAQ,EAAE;CACV,qBAAqB;CACtB,CAAC;AAEF,SAAgB,mBAAsC;AACpD,QAAO,IAAI,cAAc;;AAG3B,SAAS,gBAAgB;CACvB,MAAM,CAAC,KAAK,UAAU,SAAS,IAAI;AAEnC,iBAAgB;AAGd,MAFkB,OAAO,UAAU,UAAU,SAAS,UAAU,CAEjD,QAAO,OAAO;IAC5B,EAAE,CAAC;AAEN,QAAO;;AAGT,SAAgB,eAAe,EAC7B,cACA,UACA,UAAU,MACV,SACA,SAAS,CACP;CACE,MAAM,MAAM,EAAE,WAAW,EAAE;CAC3B,SAAS,oBAAC,kBAAgB;CAC3B,EACD;CACE,KAAK;CACL,SAAS;CACV,CACF,EACD,SACsB;CACtB,MAAM,CAAC,QAAQ,aAAa,SAAS,UAAU,QAAQ,OAAU;CACjE,MAAM,YAAY,gBAAgB,MAAqB;AACrD,MAAI,OAAO,OAAO,MAAO,OAAO,EAAE,QAAQ,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAE,EAAE;AACjF,cAAW,SAAS,CAAC,KAAK;AAC1B,KAAE,gBAAgB;;GAEpB;AAEF,iBAAgB;AACd,SAAO,iBAAiB,WAAW,UAAU;AAC7C,eAAa;AACX,UAAO,oBAAoB,WAAW,UAAU;;IAEjD,CAAC,OAAO,CAAC;AAEZ,QACE,qBAAC;EACC,OAAO,eACE;GACL,SAAS;GACT;GACA,eAAe;GAChB,GACD,CAAC,OAAO,CACT;aAEA,WAAW,UACV,oBAAC;GACC,MAAM;GACN,cAAc;GAEP;GACP,GAAI;IACJ,EAEH;GACa;;;;;AAOpB,SAAgB,WAAW,EAAE,YAAqC;AAGhE,KAFe,kBAAkB,CAEtB,QAAS,QAAO"}
@@ -1,15 +1,22 @@
1
- import type * as PageTree from 'fumadocs-core/page-tree';
2
- import { type ReactNode } from 'react';
1
+ import { ReactNode } from "react";
2
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
3
+ import * as PageTree from "fumadocs-core/page-tree";
4
+
5
+ //#region src/contexts/tree.d.ts
3
6
  type MakeRequired<O, K extends keyof O> = Omit<O, K> & Pick<Required<O>, K>;
4
7
  interface TreeContextType {
5
- root: MakeRequired<PageTree.Root | PageTree.Folder, '$id'>;
6
- full: PageTree.Root;
8
+ root: MakeRequired<PageTree.Root | PageTree.Folder, '$id'>;
9
+ full: PageTree.Root;
7
10
  }
8
- export declare function TreeContextProvider({ tree: rawTree, children, }: {
9
- tree: PageTree.Root;
10
- children: ReactNode;
11
- }): import("react/jsx-runtime").JSX.Element;
12
- export declare function useTreePath(): PageTree.Node[];
13
- export declare function useTreeContext(): TreeContextType;
14
- export {};
11
+ declare function TreeContextProvider({
12
+ tree: rawTree,
13
+ children
14
+ }: {
15
+ tree: PageTree.Root;
16
+ children: ReactNode;
17
+ }): react_jsx_runtime2.JSX.Element;
18
+ declare function useTreePath(): PageTree.Node[];
19
+ declare function useTreeContext(): TreeContextType;
20
+ //#endregion
21
+ export { TreeContextProvider, useTreeContext, useTreePath };
15
22
  //# sourceMappingURL=tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/contexts/tree.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,KAAK,SAAS,EAAuC,MAAM,OAAO,CAAC;AAG5E,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5E,UAAU,eAAe;IACvB,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3D,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;CACrB;AAKD,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EAAE,OAAO,EACb,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CA8BA;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAAC,IAAI,EAAE,CAE7C;AAED,wBAAgB,cAAc,IAAI,eAAe,CAMhD"}
1
+ {"version":3,"file":"tree.d.ts","names":[],"sources":["../../src/contexts/tree.tsx"],"sourcesContent":[],"mappings":";;;;;KAMK,gCAAgC,KAAK,KAAK,GAAG,KAAK,KAAK,SAAS,IAAI;UAE/D,eAAA;QACF,aAAa,QAAA,CAAS,OAAO,QAAA,CAAS;EAHzC,IAAA,EAIG,QAAA,CAAS,IAJA;;AAA8B,iBAU/B,mBAAA,CAV+B;EAAA,IAAA,EAWvC,OAXuC;EAAA;CAAA,EAAA;EAAG,IAAA,EAc1C,QAAA,CAAS,IAdiC;EAAR,QAAA,EAe9B,SAf8B;CAA2B,CAAA,EAgBpE,kBAAA,CAAA,GAAA,CAAA,OAhBoE;AAAT,iBA0C5C,WAAA,CAAA,CA1C4C,EA0C7B,QAAA,CAAS,IA1CoB,EAAA;AAAa,iBA8CzD,cAAA,CAAA,CA9CyD,EA8CvC,eA9CuC"}
@@ -1,32 +1,42 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { usePathname } from 'fumadocs-core/framework';
4
- import { useMemo, useRef, createContext, use } from 'react';
5
- import { searchPath } from 'fumadocs-core/breadcrumb';
2
+
3
+ import { createContext, use, useMemo, useRef } from "react";
4
+ import { usePathname } from "fumadocs-core/framework";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { searchPath } from "fumadocs-core/breadcrumb";
7
+
8
+ //#region src/contexts/tree.tsx
6
9
  const TreeContext = createContext(null);
7
10
  const PathContext = createContext([]);
8
- export function TreeContextProvider({ tree: rawTree, children, }) {
9
- const nextIdRef = useRef(0);
10
- const pathname = usePathname();
11
- // I found that object-typed props passed from a RSC will be re-constructed, hence breaking all hooks' dependencies
12
- // using the id here to make sure this never happens
13
- // eslint-disable-next-line react-hooks/exhaustive-deps
14
- const tree = useMemo(() => rawTree, [rawTree.$id ?? rawTree]);
15
- const path = useMemo(() => {
16
- return (searchPath(tree.children, pathname) ??
17
- (tree.fallback ? searchPath(tree.fallback.children, pathname) : null) ??
18
- []);
19
- }, [tree, pathname]);
20
- const root = path.findLast((item) => item.type === 'folder' && item.root) ?? tree;
21
- root.$id ?? (root.$id = String(nextIdRef.current++));
22
- return (_jsx(TreeContext, { value: useMemo(() => ({ root, full: tree }), [root, tree]), children: _jsx(PathContext, { value: path, children: children }) }));
11
+ function TreeContextProvider({ tree: rawTree, children }) {
12
+ const nextIdRef = useRef(0);
13
+ const pathname = usePathname();
14
+ const tree = useMemo(() => rawTree, [rawTree.$id ?? rawTree]);
15
+ const path = useMemo(() => {
16
+ return searchPath(tree.children, pathname) ?? (tree.fallback ? searchPath(tree.fallback.children, pathname) : null) ?? [];
17
+ }, [tree, pathname]);
18
+ const root = path.findLast((item) => item.type === "folder" && item.root) ?? tree;
19
+ root.$id ??= String(nextIdRef.current++);
20
+ return /* @__PURE__ */ jsx(TreeContext, {
21
+ value: useMemo(() => ({
22
+ root,
23
+ full: tree
24
+ }), [root, tree]),
25
+ children: /* @__PURE__ */ jsx(PathContext, {
26
+ value: path,
27
+ children
28
+ })
29
+ });
23
30
  }
24
- export function useTreePath() {
25
- return use(PathContext);
31
+ function useTreePath() {
32
+ return use(PathContext);
26
33
  }
27
- export function useTreeContext() {
28
- const ctx = use(TreeContext);
29
- if (!ctx)
30
- throw new Error('You must wrap this component under <DocsLayout />');
31
- return ctx;
34
+ function useTreeContext() {
35
+ const ctx = use(TreeContext);
36
+ if (!ctx) throw new Error("You must wrap this component under <DocsLayout />");
37
+ return ctx;
32
38
  }
39
+
40
+ //#endregion
41
+ export { TreeContextProvider, useTreeContext, useTreePath };
42
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","names":[],"sources":["../../src/contexts/tree.tsx"],"sourcesContent":["'use client';\nimport type * as PageTree from 'fumadocs-core/page-tree';\nimport { usePathname } from 'fumadocs-core/framework';\nimport { type ReactNode, useMemo, useRef, createContext, use } from 'react';\nimport { searchPath } from 'fumadocs-core/breadcrumb';\n\ntype MakeRequired<O, K extends keyof O> = Omit<O, K> & Pick<Required<O>, K>;\n\ninterface TreeContextType {\n root: MakeRequired<PageTree.Root | PageTree.Folder, '$id'>;\n full: PageTree.Root;\n}\n\nconst TreeContext = createContext<TreeContextType | null>(null);\nconst PathContext = createContext<PageTree.Node[]>([]);\n\nexport function TreeContextProvider({\n tree: rawTree,\n children,\n}: {\n tree: PageTree.Root;\n children: ReactNode;\n}) {\n const nextIdRef = useRef(0);\n const pathname = usePathname();\n\n // I found that object-typed props passed from a RSC will be re-constructed, hence breaking all hooks' dependencies\n // using the id here to make sure this never happens\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const tree = useMemo(() => rawTree, [rawTree.$id ?? rawTree]);\n const path = useMemo(() => {\n return (\n searchPath(tree.children, pathname) ??\n (tree.fallback ? searchPath(tree.fallback.children, pathname) : null) ??\n []\n );\n }, [tree, pathname]);\n\n const root = path.findLast((item) => item.type === 'folder' && item.root) ?? tree;\n root.$id ??= String(nextIdRef.current++);\n\n return (\n <TreeContext value={useMemo(() => ({ root, full: tree }) as TreeContextType, [root, tree])}>\n <PathContext value={path}>{children}</PathContext>\n </TreeContext>\n );\n}\n\nexport function useTreePath(): PageTree.Node[] {\n return use(PathContext);\n}\n\nexport function useTreeContext(): TreeContextType {\n const ctx = use(TreeContext);\n\n if (!ctx) throw new Error('You must wrap this component under <DocsLayout />');\n return ctx;\n}\n"],"mappings":";;;;;;;;AAaA,MAAM,cAAc,cAAsC,KAAK;AAC/D,MAAM,cAAc,cAA+B,EAAE,CAAC;AAEtD,SAAgB,oBAAoB,EAClC,MAAM,SACN,YAIC;CACD,MAAM,YAAY,OAAO,EAAE;CAC3B,MAAM,WAAW,aAAa;CAK9B,MAAM,OAAO,cAAc,SAAS,CAAC,QAAQ,OAAO,QAAQ,CAAC;CAC7D,MAAM,OAAO,cAAc;AACzB,SACE,WAAW,KAAK,UAAU,SAAS,KAClC,KAAK,WAAW,WAAW,KAAK,SAAS,UAAU,SAAS,GAAG,SAChE,EAAE;IAEH,CAAC,MAAM,SAAS,CAAC;CAEpB,MAAM,OAAO,KAAK,UAAU,SAAS,KAAK,SAAS,YAAY,KAAK,KAAK,IAAI;AAC7E,MAAK,QAAQ,OAAO,UAAU,UAAU;AAExC,QACE,oBAAC;EAAY,OAAO,eAAe;GAAE;GAAM,MAAM;GAAM,GAAsB,CAAC,MAAM,KAAK,CAAC;YACxF,oBAAC;GAAY,OAAO;GAAO;IAAuB;GACtC;;AAIlB,SAAgB,cAA+B;AAC7C,QAAO,IAAI,YAAY;;AAGzB,SAAgB,iBAAkC;CAChD,MAAM,MAAM,IAAI,YAAY;AAE5B,KAAI,CAAC,IAAK,OAAM,IAAI,MAAM,oDAAoD;AAC9E,QAAO"}