fumadocs-ui 16.12.0 → 16.13.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 { ComponentProps } from "react";
|
|
2
2
|
//#region src/layouts/home/slots/header.d.ts
|
|
3
3
|
declare const navItemVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "icon" | "main" | "button" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
declare function Header(props: ComponentProps<'header'>): string | number | bigint | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined>;
|
|
7
7
|
//#endregion
|
package/dist/provider/base.d.ts
CHANGED
|
@@ -18,6 +18,14 @@ interface ThemeOptions extends ThemeProviderProps {
|
|
|
18
18
|
* @defaultValue true
|
|
19
19
|
*/
|
|
20
20
|
enabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Hotkey for toggling between light/dark mode, pass `false` to disable it.
|
|
23
|
+
*
|
|
24
|
+
* It is ignored while typing in an editable element (e.g. `<input />`), or when a dialog is opened.
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue `d`
|
|
27
|
+
*/
|
|
28
|
+
hotKey?: string | ((e: KeyboardEvent) => boolean) | false;
|
|
21
29
|
}
|
|
22
30
|
interface RootProviderProps {
|
|
23
31
|
/**
|
package/dist/provider/base.js
CHANGED
|
@@ -1,24 +1,65 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { I18nProvider } from "../contexts/i18n.js";
|
|
3
3
|
import { SearchProvider } from "../contexts/search.js";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect, useEffectEvent } from "react";
|
|
6
|
+
import { ThemeProvider, useTheme, useTheme as useTheme$1 } from "next-themes";
|
|
7
|
+
import { flushSync } from "react-dom";
|
|
6
8
|
import { DirectionProvider } from "@radix-ui/react-direction";
|
|
7
9
|
//#region src/provider/base.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Whether the event should be ignored because the user is interacting with an editable element,
|
|
12
|
+
* or an opened dialog (e.g. the search dialog).
|
|
13
|
+
*/
|
|
14
|
+
function isTypingTarget(target) {
|
|
15
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
16
|
+
if (target.isContentEditable) return true;
|
|
17
|
+
if ([
|
|
18
|
+
"INPUT",
|
|
19
|
+
"TEXTAREA",
|
|
20
|
+
"SELECT"
|
|
21
|
+
].includes(target.tagName)) return true;
|
|
22
|
+
return target.closest("[role=\"dialog\"]") !== null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Toggle between light/dark mode with a hotkey, must be placed under `next-themes` provider.
|
|
26
|
+
*/
|
|
27
|
+
function ThemeHotKey({ hotKey }) {
|
|
28
|
+
const { setTheme, resolvedTheme } = useTheme$1();
|
|
29
|
+
const onKeyDown = useEffectEvent((e) => {
|
|
30
|
+
if (e.defaultPrevented || e.isComposing) return;
|
|
31
|
+
if (isTypingTarget(e.target)) return;
|
|
32
|
+
if (!(typeof hotKey === "string" ? !e.metaKey && !e.ctrlKey && !e.altKey && e.key.toLowerCase() === hotKey.toLowerCase() : hotKey(e))) return;
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
const next = resolvedTheme === "dark" ? "light" : "dark";
|
|
35
|
+
if (document?.startViewTransition) document.startViewTransition(() => flushSync(() => setTheme(next)));
|
|
36
|
+
else setTheme(next);
|
|
37
|
+
});
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
window.addEventListener("keydown", onKeyDown);
|
|
40
|
+
return () => {
|
|
41
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
8
46
|
function RootProvider({ children, dir = "ltr", theme = {}, search, i18n }) {
|
|
9
47
|
let body = children;
|
|
10
48
|
if (search?.enabled !== false) body = /* @__PURE__ */ jsx(SearchProvider, {
|
|
11
49
|
...search,
|
|
12
50
|
children: body
|
|
13
51
|
});
|
|
14
|
-
if (theme?.enabled !== false)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
52
|
+
if (theme?.enabled !== false) {
|
|
53
|
+
const { enabled: _, hotKey = "d", ...themeProps } = theme;
|
|
54
|
+
body = /* @__PURE__ */ jsxs(ThemeProvider, {
|
|
55
|
+
attribute: "class",
|
|
56
|
+
defaultTheme: "system",
|
|
57
|
+
enableSystem: true,
|
|
58
|
+
disableTransitionOnChange: true,
|
|
59
|
+
...themeProps,
|
|
60
|
+
children: [hotKey !== false && /* @__PURE__ */ jsx(ThemeHotKey, { hotKey }), body]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
22
63
|
if (i18n) body = /* @__PURE__ */ jsx(I18nProvider, {
|
|
23
64
|
...i18n,
|
|
24
65
|
children: body
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-ui",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.13.0",
|
|
4
4
|
"description": "The Radix UI version of Fumadocs UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -172,8 +172,8 @@
|
|
|
172
172
|
"tsdown": "0.22.13",
|
|
173
173
|
"unified": "^11.0.5",
|
|
174
174
|
"@fumadocs/cli": "1.4.1",
|
|
175
|
-
"
|
|
176
|
-
"
|
|
175
|
+
"tsconfig": "0.0.0",
|
|
176
|
+
"fumadocs-core": "16.13.0"
|
|
177
177
|
},
|
|
178
178
|
"peerDependencies": {
|
|
179
179
|
"@types/mdx": "*",
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"react": "^19.2.0",
|
|
183
183
|
"react-dom": "^19.2.0",
|
|
184
184
|
"takumi-js": "*",
|
|
185
|
-
"fumadocs-core": "16.
|
|
185
|
+
"fumadocs-core": "16.13.0"
|
|
186
186
|
},
|
|
187
187
|
"peerDependenciesMeta": {
|
|
188
188
|
"next": {
|