fumadocs-ui 9.0.0 → 9.1.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
declare const Callout: React.ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "title" | "
|
|
4
|
+
declare const Callout: React.ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "title" | "icon" | "type"> & {
|
|
5
5
|
title?: ReactNode;
|
|
6
6
|
/**
|
|
7
7
|
* @defaultValue info
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageTree } from 'fumadocs-core/server';
|
|
2
|
-
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
import { ReactNode, FC, HTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
interface NavLinkProps {
|
|
5
5
|
icon: ReactNode;
|
|
@@ -36,10 +36,23 @@ interface SidebarProps {
|
|
|
36
36
|
* @defaultValue 1
|
|
37
37
|
*/
|
|
38
38
|
defaultOpenLevel?: number;
|
|
39
|
+
components?: Partial<Components>;
|
|
39
40
|
banner?: ReactNode;
|
|
40
41
|
footer?: ReactNode;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
interface Components {
|
|
44
|
+
Item: FC<{
|
|
45
|
+
item: PageTree.Item;
|
|
46
|
+
}>;
|
|
47
|
+
Folder: FC<{
|
|
48
|
+
item: PageTree.Folder;
|
|
49
|
+
level: number;
|
|
50
|
+
}>;
|
|
51
|
+
Separator: FC<{
|
|
52
|
+
item: PageTree.Separator;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
declare function Sidebar({ banner, footer, components, items, defaultOpenLevel, }: SidebarProps): JSX.Element;
|
|
43
56
|
|
|
44
57
|
interface LinkItem {
|
|
45
58
|
url: string;
|
package/dist/layout.client.d.mts
CHANGED
package/dist/layout.client.js
CHANGED
|
@@ -303,17 +303,31 @@ var itemVariants = cva3(
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
);
|
|
306
|
+
var defaultComponents = {
|
|
307
|
+
Folder: FolderNode,
|
|
308
|
+
Separator: SeparatorNode,
|
|
309
|
+
Item: ({ item }) => /* @__PURE__ */ jsx3(BaseItem, { item: { text: item.name, url: item.url, icon: item.icon } })
|
|
310
|
+
};
|
|
306
311
|
var SidebarContext = createContext({
|
|
307
|
-
defaultOpenLevel: 1
|
|
312
|
+
defaultOpenLevel: 1,
|
|
313
|
+
components: defaultComponents
|
|
308
314
|
});
|
|
309
315
|
function Sidebar({
|
|
310
316
|
banner,
|
|
311
317
|
footer,
|
|
318
|
+
components,
|
|
312
319
|
items = [],
|
|
313
320
|
defaultOpenLevel = 1
|
|
314
321
|
}) {
|
|
315
322
|
const [open] = useSidebarCollapse();
|
|
316
323
|
const { root } = useTreeContext();
|
|
324
|
+
const context = useMemo(
|
|
325
|
+
() => ({
|
|
326
|
+
defaultOpenLevel,
|
|
327
|
+
components: { ...defaultComponents, ...components }
|
|
328
|
+
}),
|
|
329
|
+
[components, defaultOpenLevel]
|
|
330
|
+
);
|
|
317
331
|
return /* @__PURE__ */ jsx3(
|
|
318
332
|
Base.SidebarList,
|
|
319
333
|
{
|
|
@@ -323,10 +337,10 @@ function Sidebar({
|
|
|
323
337
|
!open ? "md:hidden" : "md:sticky md:top-16 md:h-body md:w-[240px] md:text-sm xl:w-[260px]",
|
|
324
338
|
"max-md:fixed max-md:inset-0 max-md:z-40 max-md:bg-background/80 max-md:pt-16 max-md:backdrop-blur-md max-md:data-[open=false]:hidden"
|
|
325
339
|
),
|
|
326
|
-
children: /* @__PURE__ */ jsxs3(SidebarContext.Provider, { value:
|
|
340
|
+
children: /* @__PURE__ */ jsxs3(SidebarContext.Provider, { value: context, children: [
|
|
327
341
|
/* @__PURE__ */ jsx3(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-8 pb-10 pt-4 max-md:px-4 md:pr-3 md:pt-10", children: [
|
|
328
342
|
banner,
|
|
329
|
-
/* @__PURE__ */ jsx3("div", { className: "lg:hidden", children: items.map((item) => /* @__PURE__ */ jsx3(BaseItem, { item, nested: true }, item.url)) }),
|
|
343
|
+
items.length > 0 && /* @__PURE__ */ jsx3("div", { className: "lg:hidden", children: items.map((item) => /* @__PURE__ */ jsx3(BaseItem, { item, nested: true }, item.url)) }),
|
|
330
344
|
/* @__PURE__ */ jsx3(NodeList, { items: root.children })
|
|
331
345
|
] }) }),
|
|
332
346
|
/* @__PURE__ */ jsxs3(
|
|
@@ -347,21 +361,16 @@ function Sidebar({
|
|
|
347
361
|
);
|
|
348
362
|
}
|
|
349
363
|
function NodeList({ items, level = 0, ...props }) {
|
|
364
|
+
const { components } = useContext(SidebarContext);
|
|
350
365
|
return /* @__PURE__ */ jsx3("div", { ...props, children: items.map((item) => {
|
|
351
366
|
const id = `${item.type}_${item.name}`;
|
|
352
367
|
switch (item.type) {
|
|
353
368
|
case "separator":
|
|
354
|
-
return /* @__PURE__ */ jsx3(
|
|
369
|
+
return /* @__PURE__ */ jsx3(components.Separator, { item }, id);
|
|
355
370
|
case "folder":
|
|
356
|
-
return /* @__PURE__ */ jsx3(Folder, { item, level: level + 1 }, id);
|
|
371
|
+
return /* @__PURE__ */ jsx3(components.Folder, { item, level: level + 1 }, id);
|
|
357
372
|
default:
|
|
358
|
-
return /* @__PURE__ */ jsx3(
|
|
359
|
-
BaseItem,
|
|
360
|
-
{
|
|
361
|
-
item: { text: item.name, url: item.url, icon: item.icon }
|
|
362
|
-
},
|
|
363
|
-
item.url
|
|
364
|
-
);
|
|
373
|
+
return /* @__PURE__ */ jsx3(components.Item, { item }, item.url);
|
|
365
374
|
}
|
|
366
375
|
}) });
|
|
367
376
|
}
|
|
@@ -384,8 +393,8 @@ function BaseItem({
|
|
|
384
393
|
}
|
|
385
394
|
);
|
|
386
395
|
}
|
|
387
|
-
function
|
|
388
|
-
item: { name, children, index, icon },
|
|
396
|
+
function FolderNode({
|
|
397
|
+
item: { name, children, index, icon, defaultOpen = false },
|
|
389
398
|
level
|
|
390
399
|
}) {
|
|
391
400
|
const { defaultOpenLevel } = useContext(SidebarContext);
|
|
@@ -396,7 +405,7 @@ function Folder({
|
|
|
396
405
|
[children, pathname]
|
|
397
406
|
);
|
|
398
407
|
const [extend, setExtend] = useState2(
|
|
399
|
-
active || childActive || defaultOpenLevel >= level
|
|
408
|
+
active || childActive || defaultOpenLevel >= level || defaultOpen
|
|
400
409
|
);
|
|
401
410
|
useEffect2(() => {
|
|
402
411
|
if (active || childActive)
|
package/dist/layout.d.mts
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-W7dJ6OHQ.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-ui",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "The framework for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"react-medium-image-zoom": "^5.1.8",
|
|
98
98
|
"tailwind-merge": "^2.0.0",
|
|
99
99
|
"tailwindcss": "^3.4.1",
|
|
100
|
-
"fumadocs-core": "9.
|
|
100
|
+
"fumadocs-core": "9.1.0"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@algolia/client-search": "^4.20.0",
|