fumadocs-core 15.0.10 → 15.0.11

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/sidebar.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import { ReactNode, ElementType, ComponentPropsWithoutRef, ReactElement } from 'react';
2
3
 
3
4
  interface SidebarProviderProps {
@@ -5,7 +6,7 @@ interface SidebarProviderProps {
5
6
  onOpenChange?: (v: boolean) => void;
6
7
  children: ReactNode;
7
8
  }
8
- declare function SidebarProvider(props: SidebarProviderProps): React.ReactElement;
9
+ declare function SidebarProvider(props: SidebarProviderProps): react_jsx_runtime.JSX.Element;
9
10
  type AsProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, 'as'> & {
10
11
  as?: T;
11
12
  };
package/dist/sidebar.js CHANGED
@@ -6,22 +6,29 @@ import {
6
6
  createContext,
7
7
  useContext,
8
8
  useEffect,
9
- useState
9
+ useState,
10
+ useMemo
10
11
  } from "react";
11
12
  import { RemoveScroll } from "react-remove-scroll";
12
13
  import { jsx } from "react/jsx-runtime";
13
- var SidebarContext = createContext(void 0);
14
+ var SidebarContext = createContext(null);
14
15
  function useSidebarContext() {
15
16
  const ctx = useContext(SidebarContext);
16
17
  if (!ctx) throw new Error("Missing sidebar provider");
17
18
  return ctx;
18
19
  }
19
20
  function SidebarProvider(props) {
20
- const [openInner, setOpenInner] = useState(false);
21
+ const [open, setOpen] = props.open === void 0 ? (
22
+ // eslint-disable-next-line react-hooks/rules-of-hooks
23
+ useState(false)
24
+ ) : [props.open, props.onOpenChange];
21
25
  return /* @__PURE__ */ jsx(
22
26
  SidebarContext.Provider,
23
27
  {
24
- value: [props.open ?? openInner, props.onOpenChange ?? setOpenInner],
28
+ value: useMemo(
29
+ () => ({ open, setOpen: setOpen ?? (() => void 0) }),
30
+ [open, setOpen]
31
+ ),
25
32
  children: props.children
26
33
  }
27
34
  );
@@ -30,7 +37,7 @@ function SidebarTrigger({
30
37
  as,
31
38
  ...props
32
39
  }) {
33
- const [open, setOpen] = useSidebarContext();
40
+ const { open, setOpen } = useSidebarContext();
34
41
  const As = as ?? "button";
35
42
  return /* @__PURE__ */ jsx(
36
43
  As,
@@ -49,7 +56,7 @@ function SidebarList({
49
56
  blockScrollingWidth,
50
57
  ...props
51
58
  }) {
52
- const [open] = useSidebarContext();
59
+ const { open } = useSidebarContext();
53
60
  const [isBlocking, setIsBlocking] = useState(false);
54
61
  useEffect(() => {
55
62
  if (!blockScrollingWidth) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.0.10",
3
+ "version": "15.0.11",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -86,8 +86,8 @@
86
86
  "@shikijs/rehype": "^3.0.0",
87
87
  "@shikijs/transformers": "^3.0.0",
88
88
  "github-slugger": "^2.0.0",
89
- "hast-util-to-estree": "^3.1.1",
90
- "hast-util-to-jsx-runtime": "^2.3.2",
89
+ "hast-util-to-estree": "^3.1.2",
90
+ "hast-util-to-jsx-runtime": "^2.3.3",
91
91
  "image-size": "^1.2.0",
92
92
  "negotiator": "^1.0.0",
93
93
  "react-remove-scroll": "^2.6.3",
@@ -118,8 +118,8 @@
118
118
  "typescript": "^5.7.3",
119
119
  "unified": "^11.0.5",
120
120
  "vfile": "^6.0.3",
121
- "tsconfig": "0.0.0",
122
- "eslint-config-custom": "0.0.0"
121
+ "eslint-config-custom": "0.0.0",
122
+ "tsconfig": "0.0.0"
123
123
  },
124
124
  "peerDependencies": {
125
125
  "@orama/tokenizers": "2.x.x",