fumadocs-core 10.0.1 → 10.0.2
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/toc.d.ts +15 -14
- package/dist/toc.js +13 -5
- package/package.json +1 -1
package/dist/toc.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { HTMLAttributes, AnchorHTMLAttributes } from 'react';
|
|
3
|
-
import { T as TableOfContents
|
|
2
|
+
import { HTMLAttributes, RefObject, ReactNode, AnchorHTMLAttributes } from 'react';
|
|
3
|
+
import { T as TableOfContents } from './get-toc-YF_TdazL.js';
|
|
4
4
|
|
|
5
5
|
declare const useActiveAnchor: (url: string) => boolean;
|
|
6
|
-
|
|
6
|
+
interface TOCProviderProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
7
|
toc: TableOfContents;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
}
|
|
9
|
+
declare const TOCProvider: react.ForwardRefExoticComponent<TOCProviderProps & react.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
interface TOCScrollProvider {
|
|
11
|
+
containerRef: RefObject<HTMLElement>;
|
|
12
|
+
toc: TableOfContents;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
declare function TOCScrollProvider({ toc, containerRef, children, }: TOCScrollProvider): JSX.Element;
|
|
16
|
+
interface TOCItemProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
15
17
|
href: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} & react.RefAttributes<HTMLAnchorElement>>;
|
|
18
|
+
}
|
|
19
|
+
declare const TOCItem: react.ForwardRefExoticComponent<TOCItemProps & react.RefAttributes<HTMLAnchorElement>>;
|
|
19
20
|
|
|
20
|
-
export { TOCItem, type TOCItemProps, TOCProvider, useActiveAnchor };
|
|
21
|
+
export { TOCItem, type TOCItemProps, TOCProvider, type TOCProviderProps, TOCScrollProvider, useActiveAnchor };
|
package/dist/toc.js
CHANGED
|
@@ -74,16 +74,23 @@ var useActiveAnchor = (url) => {
|
|
|
74
74
|
var TOCProvider = forwardRef(
|
|
75
75
|
(_a, ref) => {
|
|
76
76
|
var _b = _a, { toc } = _b, props = __objRest(_b, ["toc"]);
|
|
77
|
-
const headings = useMemo(() => {
|
|
78
|
-
return toc.map((item) => item.url.split("#")[1]);
|
|
79
|
-
}, [toc]);
|
|
80
77
|
const containerRef = useRef(null);
|
|
81
78
|
const mergedRef = mergeRefs(containerRef, ref);
|
|
82
|
-
|
|
83
|
-
return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({ ref: mergedRef }, props), { children: /* @__PURE__ */ jsx(ActiveAnchorContext.Provider, { value: { containerRef, activeAnchor }, children: props.children }) }));
|
|
79
|
+
return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({ ref: mergedRef }, props), { children: /* @__PURE__ */ jsx(TOCScrollProvider, { toc, containerRef, children: props.children }) }));
|
|
84
80
|
}
|
|
85
81
|
);
|
|
86
82
|
TOCProvider.displayName = "TOCProvider";
|
|
83
|
+
function TOCScrollProvider({
|
|
84
|
+
toc,
|
|
85
|
+
containerRef,
|
|
86
|
+
children
|
|
87
|
+
}) {
|
|
88
|
+
const headings = useMemo(() => {
|
|
89
|
+
return toc.map((item) => item.url.split("#")[1]);
|
|
90
|
+
}, [toc]);
|
|
91
|
+
const activeAnchor = useAnchorObserver(headings);
|
|
92
|
+
return /* @__PURE__ */ jsx(ActiveAnchorContext.Provider, { value: { containerRef, activeAnchor }, children });
|
|
93
|
+
}
|
|
87
94
|
var TOCItem = forwardRef(
|
|
88
95
|
(props, ref) => {
|
|
89
96
|
const { containerRef } = useContext(ActiveAnchorContext);
|
|
@@ -109,5 +116,6 @@ TOCItem.displayName = "TOCItem";
|
|
|
109
116
|
export {
|
|
110
117
|
TOCItem,
|
|
111
118
|
TOCProvider,
|
|
119
|
+
TOCScrollProvider,
|
|
112
120
|
useActiveAnchor
|
|
113
121
|
};
|