fumadocs-ui 11.0.5 → 11.0.7
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.
- package/dist/{chunk-T7VFHVWK.js → chunk-2KA2UOM3.js} +17 -8
- package/dist/{chunk-SHMZYIS4.js → chunk-XP3DGFDZ.js} +1 -1
- package/dist/components/dialog/search-algolia.js +2 -2
- package/dist/components/dialog/search-default.js +2 -2
- package/dist/components/dialog/search.js +2 -2
- package/dist/{layout-2oBm-QYW.d.ts → layout-q1ZKzm34.d.ts} +5 -0
- package/dist/layout.client.d.ts +1 -1
- package/dist/layout.client.js +6 -6
- package/dist/layout.d.ts +1 -1
- package/dist/provider.d.ts +12 -4
- package/dist/provider.js +4 -2
- package/package.json +2 -2
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// src/contexts/search.tsx
|
|
2
2
|
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
var SearchContext = createContext(
|
|
4
|
+
var SearchContext = createContext({
|
|
5
|
+
enabled: false,
|
|
6
|
+
setOpenSearch: () => void 0
|
|
7
|
+
});
|
|
5
8
|
function useSearchContext() {
|
|
6
|
-
|
|
7
|
-
if (!ctx)
|
|
8
|
-
throw new Error("Missing root provider");
|
|
9
|
-
return ctx;
|
|
9
|
+
return useContext(SearchContext);
|
|
10
10
|
}
|
|
11
11
|
function SearchProvider({
|
|
12
12
|
SearchDialog,
|
|
13
13
|
children,
|
|
14
14
|
preload = true,
|
|
15
|
-
options
|
|
15
|
+
options,
|
|
16
|
+
links
|
|
16
17
|
}) {
|
|
17
18
|
const [isOpen, setIsOpen] = useState(preload ? false : void 0);
|
|
18
19
|
useEffect(() => {
|
|
@@ -28,11 +29,19 @@ function SearchProvider({
|
|
|
28
29
|
};
|
|
29
30
|
}, []);
|
|
30
31
|
const ctx = useMemo(
|
|
31
|
-
() => ({ setOpenSearch: setIsOpen }),
|
|
32
|
+
() => ({ enabled: true, setOpenSearch: setIsOpen }),
|
|
32
33
|
[]
|
|
33
34
|
);
|
|
34
35
|
return /* @__PURE__ */ jsxs(SearchContext.Provider, { value: ctx, children: [
|
|
35
|
-
isOpen !== void 0 && /* @__PURE__ */ jsx(
|
|
36
|
+
isOpen !== void 0 && /* @__PURE__ */ jsx(
|
|
37
|
+
SearchDialog,
|
|
38
|
+
{
|
|
39
|
+
open: isOpen,
|
|
40
|
+
onOpenChange: setIsOpen,
|
|
41
|
+
links,
|
|
42
|
+
...options
|
|
43
|
+
}
|
|
44
|
+
),
|
|
36
45
|
children
|
|
37
46
|
] });
|
|
38
47
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
SearchDialog
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-XP3DGFDZ.js";
|
|
5
|
+
import "../../chunk-2KA2UOM3.js";
|
|
6
6
|
import "../../chunk-YAHHY62W.js";
|
|
7
7
|
import "../../chunk-7GZKFBAP.js";
|
|
8
8
|
import "../../chunk-TK3TM3MR.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SearchDialog
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-XP3DGFDZ.js";
|
|
4
|
+
import "../../chunk-2KA2UOM3.js";
|
|
5
5
|
import "../../chunk-YAHHY62W.js";
|
|
6
6
|
import "../../chunk-7GZKFBAP.js";
|
|
7
7
|
import "../../chunk-TK3TM3MR.js";
|
|
@@ -11,6 +11,11 @@ interface NavProps {
|
|
|
11
11
|
url?: string;
|
|
12
12
|
items: LinkItem[];
|
|
13
13
|
enableSidebar: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Show/hide search toggle
|
|
16
|
+
*
|
|
17
|
+
* Note: Enable/disable search from root provider instead
|
|
18
|
+
*/
|
|
14
19
|
enableSearch?: boolean;
|
|
15
20
|
/**
|
|
16
21
|
* When to use transparent navbar
|
package/dist/layout.client.d.ts
CHANGED
package/dist/layout.client.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-7F2LGCS6.js";
|
|
22
22
|
import {
|
|
23
23
|
useSearchContext
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-2KA2UOM3.js";
|
|
25
25
|
import {
|
|
26
26
|
useI18n
|
|
27
27
|
} from "./chunk-YAHHY62W.js";
|
|
@@ -45,8 +45,7 @@ import { SidebarTrigger } from "fumadocs-core/sidebar";
|
|
|
45
45
|
import { usePathname } from "next/navigation";
|
|
46
46
|
import {
|
|
47
47
|
useEffect,
|
|
48
|
-
useState
|
|
49
|
-
useCallback as useCallback2
|
|
48
|
+
useState
|
|
50
49
|
} from "react";
|
|
51
50
|
|
|
52
51
|
// src/components/theme-toggle.tsx
|
|
@@ -101,6 +100,7 @@ function Nav({
|
|
|
101
100
|
enableSearch = true,
|
|
102
101
|
children
|
|
103
102
|
}) {
|
|
103
|
+
const search = useSearchContext();
|
|
104
104
|
const [transparent, setTransparent] = useState(transparentMode !== "none");
|
|
105
105
|
useEffect(() => {
|
|
106
106
|
if (transparentMode !== "top")
|
|
@@ -133,7 +133,7 @@ function Nav({
|
|
|
133
133
|
children,
|
|
134
134
|
items.filter((item) => item.type === "main" || !item.type).map((item) => /* @__PURE__ */ jsx2(NavItem, { item, className: "max-lg:hidden" }, item.url)),
|
|
135
135
|
/* @__PURE__ */ jsxs2("div", { className: "flex flex-1 flex-row items-center justify-end md:gap-2", children: [
|
|
136
|
-
enableSearch ? /* @__PURE__ */ jsx2(SearchToggle, {}) : null,
|
|
136
|
+
enableSearch && search.enabled ? /* @__PURE__ */ jsx2(SearchToggle, {}) : null,
|
|
137
137
|
enableSidebar ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
138
138
|
/* @__PURE__ */ jsx2(ThemeToggle, { className: "max-md:hidden" }),
|
|
139
139
|
/* @__PURE__ */ jsx2(
|
|
@@ -210,9 +210,9 @@ function LinksMenu({ items }) {
|
|
|
210
210
|
function SearchToggle() {
|
|
211
211
|
const { setOpenSearch } = useSearchContext();
|
|
212
212
|
const { text } = useI18n();
|
|
213
|
-
const onClick =
|
|
213
|
+
const onClick = () => {
|
|
214
214
|
setOpenSearch(true);
|
|
215
|
-
}
|
|
215
|
+
};
|
|
216
216
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
217
217
|
/* @__PURE__ */ jsx2(
|
|
218
218
|
"button",
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'fumadocs-core/server';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { B as BaseLayoutProps, b as DocsLayout, D as DocsLayoutProps, a as Layout, L as LinkItem } from './layout-
|
|
3
|
+
export { B as BaseLayoutProps, b as DocsLayout, D as DocsLayoutProps, a as Layout, L as LinkItem } from './layout-q1ZKzm34.js';
|
package/dist/provider.d.ts
CHANGED
|
@@ -27,10 +27,11 @@ interface SearchProviderProps {
|
|
|
27
27
|
/**
|
|
28
28
|
* Additional props to the dialog
|
|
29
29
|
*/
|
|
30
|
-
options?:
|
|
30
|
+
options?: Partial<SharedProps>;
|
|
31
31
|
children?: React$1.ReactNode;
|
|
32
32
|
}
|
|
33
33
|
interface SearchContextType {
|
|
34
|
+
enabled: boolean;
|
|
34
35
|
setOpenSearch: (value: boolean) => void;
|
|
35
36
|
}
|
|
36
37
|
declare function useSearchContext(): SearchContextType;
|
|
@@ -39,6 +40,15 @@ type SidebarCollapseContext = [open: boolean, setOpen: (v: boolean) => void];
|
|
|
39
40
|
declare const SidebarCollapseContext: React$1.Context<SidebarCollapseContext | undefined>;
|
|
40
41
|
declare function useSidebarCollapse(): SidebarCollapseContext;
|
|
41
42
|
|
|
43
|
+
interface SearchOptions extends Omit<SearchProviderProps, 'options' | 'children'> {
|
|
44
|
+
options?: Partial<DefaultSearchDialogProps> | SearchProviderProps['options'];
|
|
45
|
+
/**
|
|
46
|
+
* Enable search functionality
|
|
47
|
+
*
|
|
48
|
+
* @defaultValue `true`
|
|
49
|
+
*/
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
}
|
|
42
52
|
interface RootProviderProps {
|
|
43
53
|
/**
|
|
44
54
|
* `dir` option for Radix UI
|
|
@@ -47,9 +57,7 @@ interface RootProviderProps {
|
|
|
47
57
|
/**
|
|
48
58
|
* @remarks `SearchProviderProps`
|
|
49
59
|
*/
|
|
50
|
-
search?: Partial<
|
|
51
|
-
options?: Partial<DefaultSearchDialogProps> | object;
|
|
52
|
-
}>;
|
|
60
|
+
search?: Partial<SearchOptions>;
|
|
53
61
|
/**
|
|
54
62
|
* Wrap the body in `ThemeProvider` (next-themes)
|
|
55
63
|
*
|
package/dist/provider.js
CHANGED
|
@@ -10,7 +10,7 @@ import "./chunk-7F2LGCS6.js";
|
|
|
10
10
|
import {
|
|
11
11
|
SearchProvider,
|
|
12
12
|
useSearchContext
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2KA2UOM3.js";
|
|
14
14
|
import {
|
|
15
15
|
useI18n
|
|
16
16
|
} from "./chunk-YAHHY62W.js";
|
|
@@ -32,7 +32,9 @@ function RootProvider({
|
|
|
32
32
|
enableThemeProvider = true,
|
|
33
33
|
search
|
|
34
34
|
}) {
|
|
35
|
-
let body = /* @__PURE__ */ jsx(SidebarProvider, { children: /* @__PURE__ */ jsx(SidebarCollapseProvider, { children
|
|
35
|
+
let body = /* @__PURE__ */ jsx(SidebarProvider, { children: /* @__PURE__ */ jsx(SidebarCollapseProvider, { children }) });
|
|
36
|
+
if (search?.enabled !== false)
|
|
37
|
+
body = /* @__PURE__ */ jsx(SearchProvider, { SearchDialog: DefaultSearchDialog, ...search, children: body });
|
|
36
38
|
if (enableThemeProvider)
|
|
37
39
|
body = /* @__PURE__ */ jsx(
|
|
38
40
|
ThemeProvider,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-ui",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.7",
|
|
4
4
|
"description": "The framework for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"next-themes": "^0.3.0",
|
|
97
97
|
"react-medium-image-zoom": "^5.1.11",
|
|
98
98
|
"tailwind-merge": "^2.3.0",
|
|
99
|
-
"fumadocs-core": "11.0.
|
|
99
|
+
"fumadocs-core": "11.0.7"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@algolia/client-search": "^4.23.3",
|